/// <summary> /// This method reads a 3 byte BCD date from an SCS device. /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual internal void ReadBCDDate(int nBasepageAddress, out int nYear, out int nMonth, out int nDay) { byte[] byBCDValue; // Upload the date string SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, 3, out byBCDValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { nYear = (int)BCD.BCDtoByte(byBCDValue[0]); nMonth = (int)BCD.BCDtoByte(byBCDValue[1]); nDay = (int)BCD.BCDtoByte(byBCDValue[2]); } else { nYear = 0; nMonth = 0; nDay = 0; SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "Display date"); throw scsException; } }
} // End ReorderFloats() /// <summary> /// This method reads a 4 byte floating point value from an SCS device. /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/13/06 mah 8.00.00 N/A Created /// </remarks> virtual internal float ReadFloatingPointValue(int nBasepageAddress) { byte[] byValue; float fltValue = (float)0.0; SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, 4, out byValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { ReorderFloats(ref byValue); MemoryStream TempStream = new MemoryStream(byValue); BinaryReader TempBReader = new BinaryReader(TempStream); // Interpret the toolbox data fltValue = TempBReader.ReadSingle(); } else { SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "Floating point value"); throw scsException; } return(fltValue); }
/// <summary> /// This method reads a 3 byte BCD time from an SCS device. /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual internal void ReadBCDTime(int nBasepageAddress, out int nHour, out int nMinute, out int nSecond) { byte[] byBCDValue; // Upload the date string SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, 3, out byBCDValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { nHour = (int)BCD.BCDtoByte(byBCDValue[0]); nMinute = (int)BCD.BCDtoByte(byBCDValue[1]); nSecond = (int)BCD.BCDtoByte(byBCDValue[2]); } else { nHour = 0; nMinute = 0; nSecond = 0; SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "Display time"); throw scsException; } }
/// <summary> /// This method a 4 byte floating point BCD value from an SCS device. /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual internal String ReadASCIIValue(int nBasepageAddress, int nLength) { String strAsciiValue = ""; ASCIIEncoding Encoder = new ASCIIEncoding(); // For converting byte array to string byte[] byASCIIValue; SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, nLength, out byASCIIValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { char[] chrNull = { '\0' }; strAsciiValue = Encoder.GetString(byASCIIValue, 0, nLength); strAsciiValue = strAsciiValue.Trim(chrNull); } else { SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "ASCII Value"); throw scsException; } return(strAsciiValue); }
/// <summary> /// This method reads and translates a single nibble from an SCS device /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual internal int ReadNibble(int nBasepageAddress, bool boolReadMSN) { int nValue = 0; byte[] byValue; SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, 1, out byValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { if (boolReadMSN) { nValue = (byValue[0] >> 4); } else { nValue = (byValue[0] & 0x0F); } } else { SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "Read nibble"); throw scsException; } return(nValue); }
/// <summary> /// This method reads and caches all of the display /// format settings. Note that this may involve more /// than one basepage field. The goal is to read all of the display /// formats in a single shot and cache the values so that they do /// not have to be re-read for each display item. /// /// This method must be overriden if the meter does not use the /// display format structures common to the MT200, CENTRON, and /// VECTRON meters /// </summary> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual protected void ReadDisplayFormats() { byte[] byDisplayFormats; SCSProtocolResponse ProtocolResponse; // In order to be efficient we will try to read & cache all three display formats at the same time m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reading display formats"); ProtocolResponse = m_SCSProtocol.Upload(EnergyFormatAddress, 3, out byDisplayFormats); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { m_EnergyFormat.MeterDisplayFormat = byDisplayFormats[0]; m_DemandFormat.MeterDisplayFormat = byDisplayFormats[1]; m_CumulativeFormat.MeterDisplayFormat = byDisplayFormats[2]; } if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { ProtocolResponse = m_SCSProtocol.Upload(DisplayOptionsAddress, 1, out byDisplayFormats); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { if ((byDisplayFormats[0] & 0x10) != 0) { m_DemandFormat.Units = SCSDisplayFormat.DisplayUnits.Units; m_CumulativeFormat.Units = SCSDisplayFormat.DisplayUnits.Units; } else { m_DemandFormat.Units = SCSDisplayFormat.DisplayUnits.Kilo; m_CumulativeFormat.Units = SCSDisplayFormat.DisplayUnits.Kilo; } if ((byDisplayFormats[0] & 0x80) != 0) { m_EnergyFormat.Units = SCSDisplayFormat.DisplayUnits.Units; } else { m_EnergyFormat.Units = SCSDisplayFormat.DisplayUnits.Kilo; } } } if (SCSProtocolResponse.SCS_ACK != ProtocolResponse) { SCSException scsException = new SCSException(SCSCommands.SCS_U, ProtocolResponse, EnergyFormatAddress, "Display Formats"); throw scsException; } }
/// <summary> /// This method reads a integer BCD value from an SCS device. /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual internal int ReadBCDInteger(int nBasepageAddress, int nLength) { int nValue = 0; byte[] byBCDValue; SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, nLength, out byBCDValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { nValue = BCD.BCDtoInt(ref byBCDValue, nLength); } else { SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "Integer BCD Value"); throw scsException; } return(nValue); }
/// <summary> /// This method a 4 byte floating point BCD value from an SCS device. /// </summary> /// <exception cref="SCSException"> /// Thrown when the value cannot be retreived from the meter. /// </exception> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/07/06 mah 8.00.00 N/A Created /// </remarks> virtual internal String ReadFloatingBCDValue(int nBasepageAddress, int nLength) { String strValue = ""; byte[] byBCDValue; SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Upload(nBasepageAddress, nLength, out byBCDValue); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { strValue = BCD.FloatingBCDtoString(ref byBCDValue, nLength); } else { SCSException scsException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, nBasepageAddress, "Floating BCD Value"); throw scsException; } return(strValue); }
/// <summary> /// Implements the ISiteScan interface. Resets the diagnostic counters /// </summary> /// <exception cref="SCSException"> /// Thrown when the diagnostic counters cannot be reset in the meter. /// </exception> /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 04/27/06 mrj 7.30.00 N/A Created /// 05/26/06 jrf 7.30.00 N/A Modified /// ItronDeviceResult ISiteScan.ResetDiagCounters() { ItronDeviceResult Result = ItronDeviceResult.SUCCESS; byte[] byDiagnostic1To4Counters = new byte[VEC_DIAGNOSTIC_1_TO_4_COUNTS_LENGTH]; byte[] byDiagnostic5Counters = new byte[VEC_DIAGNOSTIC_5_COUNTS_LENGTH]; SCSProtocolResponse ProtocolResponse = SCSProtocolResponse.NoResponse; int iExceptionAddress = (int)VECAddresses.DIAGNOSTICS_COUNTS; m_Logger.WriteLine( Logger.LoggingLevel.Functional, "Starting Reset Diagnositc Counters"); // Prepare arrays to reset all diagnostic counters byDiagnostic1To4Counters.Initialize(); byDiagnostic5Counters.Initialize(); m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reset Diagnostic Counters 1-4"); // Reset diagnostic 1 to 4 counters ProtocolResponse = m_SCSProtocol.Download( (int)VECAddresses.DIAGNOSTICS_COUNTS, VEC_DIAGNOSTIC_1_TO_4_COUNTS_LENGTH, ref byDiagnostic1To4Counters); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reset Diagnostic 5 Counters"); // Reset diagnostic 5 counters ProtocolResponse = m_SCSProtocol.Download( (int)VECAddresses.DIAGNOSTIC_5_COUNTS, VEC_DIAGNOSTIC_5_COUNTS_LENGTH, ref byDiagnostic5Counters); iExceptionAddress = (int)VECAddresses.DIAGNOSTIC_5_COUNTS; } if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { Result = ItronDeviceResult.SUCCESS; } else if (SCSProtocolResponse.SCS_CAN == ProtocolResponse) { Result = ItronDeviceResult.ERROR; } else if (SCSProtocolResponse.NoResponse == ProtocolResponse) { Result = ItronDeviceResult.ERROR; } else { SCSException objSCSException = new SCSException( SCSCommands.SCS_U, ProtocolResponse, iExceptionAddress, m_rmStrings.GetString("RESET_DIAG")); throw objSCSException; } return(Result); } //End ISiteScan.ResetDiagCounters()
/// <summary> /// Returns a list of values currently shown on the meter's normal mode display /// </summary> /// <remarks > /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 12/05/06 mah 8.00.00 N/A Created /// </remarks> virtual protected void ReadDisplayConfigurations() { byte[] byDisplayItem; SCSProtocolResponse ProtocolResponse; m_NormalDisplayList = new List <DisplayItem>(); m_AlternateDisplayList = new List <DisplayItem>(); m_TestDisplayList = new List <DisplayItem>(); // All SCS devices MUST have at least one item in the normal display // list. Read each of the items in the list until we reach either an end // of table indicator or we find the first item in the alternate display list int nDisplayItemAddress = DisplayTableAddress; Boolean boolEndOfList = false; m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reading display table"); while (!boolEndOfList) { // Read the entire display item from the meter ProtocolResponse = m_SCSProtocol.Upload(nDisplayItemAddress, SCS_DISPLAYITEM_LENGTH, out byDisplayItem); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { SCSDisplayItem displayItem = CreateDisplayItem(ref byDisplayItem, 0, false); if (!displayItem.EndOfFIle) { if (displayItem.DisplayType == ItronDevice.DisplayMode.NORMAL_MODE) { m_NormalDisplayList.Add(displayItem); } else { m_AlternateDisplayList.Add(displayItem); } // set the address of the next item nDisplayItemAddress += SCS_DISPLAYITEM_LENGTH; } else { boolEndOfList = true; nDisplayItemAddress += 1; // The end of list is only one byte long - reset the address to point to the next item } } else { SCSException scsException = new SCSException(SCSCommands.SCS_U, ProtocolResponse, nDisplayItemAddress, "Display table item"); throw scsException; } } // The test mode list immediately follows the normal and alternate mode lists and has the same // format boolEndOfList = false; m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reading test mode display table"); while (!boolEndOfList) { // Read the entire display item from the meter ProtocolResponse = m_SCSProtocol.Upload(nDisplayItemAddress, SCS_DISPLAYITEM_LENGTH, out byDisplayItem); if (SCSProtocolResponse.SCS_ACK == ProtocolResponse) { SCSDisplayItem displayItem = new SCSDisplayItem(ref byDisplayItem, 0, true); if (!displayItem.EndOfFIle) { m_TestDisplayList.Add(displayItem); // set the address of the next item nDisplayItemAddress += SCS_DISPLAYITEM_LENGTH; } else { boolEndOfList = true; } } else { SCSException scsException = new SCSException(SCSCommands.SCS_U, ProtocolResponse, nDisplayItemAddress, "Test Mode display item"); throw scsException; } } }