Example #1
0
        /// <summary>
        /// This method stops and starts the metering operation of the CENTRON
        /// </summary>
        /// <param name="disableMeter">The boolean to determine if the meter needs
        /// to be disabled or enabled</param>
        /// <returns>A SCSProtocolResponse</returns>
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/26/07 KRC 8.00.09        Add stop metering for Edit registers.
        ///
        override protected SCSProtocolResponse StopMetering(bool disableMeter)
        {
            SCSProtocolResponse objProtocolResponse = SCSProtocolResponse.NoResponse;

            byte[] abytFlag = new byte[1];

            if (disableMeter)
            {
                m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Stopping Metering");
                abytFlag[0] = SCS_FLAG_ON;
            }
            else
            {
                m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Starting Metering");
                abytFlag[0] = SCS_FLAG_OFF;
            }

            m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Set Stop Meter Flag");
            objProtocolResponse = m_SCSProtocol.Download(
                (int)MT2Addresses.STOP_METER_FLAG,
                SCS_FLAG_LENGTH,
                ref abytFlag);

            return(objProtocolResponse);
        }
Example #2
0
        /// <summary>
        /// Constructor to create a SCSException.
        /// </summary>
        /// <param name="Command"></param>
        /// <param name="ProtocolResponse"></param>
        /// <param name="iAddress"></param>
        /// <param name="strItemName"></param>
        /// <example>
        /// <code>
        /// SCSException e = new SCSException(
        ///		SCSCommands.SCS_D,
        ///		SCSProtocolResponse.NoResponse,
        ///		0x2156,
        ///		"Unit ID");
        /// </code>
        /// </example>
        /// <remarks>
        /// Revision History
        /// MM/DD/YY who Version Issue# Description
        /// 05/22/06 mrj 7.30.00 N/A	Created
        /// 05/23/06 jrf 7.30.00 N/A	Modified
        /// </remarks>
        public SCSException(SCSCommands Command, SCSProtocolResponse ProtocolResponse,
                            int iAddress, string strItemName)
            :
            base("SCS Protocol error occurred")
        {
            CommandType      = Command;
            SCSResponse      = ProtocolResponse;
            FieldName        = strItemName;
            OffendingAddress = iAddress;

            switch (ProtocolResponse)
            {
            case SCSProtocolResponse.SCS_CAN:
                Description = "SecurityError (CAN)";
                break;

            case SCSProtocolResponse.SCS_NAK:
                Description = "InvalidRequest (NAK)";
                break;

            case SCSProtocolResponse.NoResponse:
                Description = "No Response";
                break;

            default:
                Description = "Unknown (" + ProtocolResponse.ToString() + ")";
                break;
            }
            Description += ": Item = " + FieldName + ": Address = 0x" +
                           OffendingAddress.ToString("X", CultureInfo.InvariantCulture) + ": Command = " + CommandType.ToString();
        }
Example #3
0
        } // 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);
        }
Example #4
0
        /// <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;
            }
        }
Example #5
0
        /// <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;
            }
        }
Example #6
0
        /// <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);
        }
Example #7
0
        /// <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);
        }
Example #8
0
        /// <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
        /// -------- --- ------- ------ ---------------------------------------
        /// 01/26/07 KRC 8.00.09        Adding Edit Registers
        /// </remarks>
        virtual internal ItronDeviceResult SetFloatingBCDValue(int nBasepageAddress, int nLength, string strValue)
        {
            ItronDeviceResult Result = ItronDeviceResult.SUCCESS;

            byte[] byBCDValue;
            double dblValue;

            // Get the double out of the string (This allows us to format the value as needed when doing the conversion)
            dblValue   = double.Parse(strValue, CultureInfo.CurrentCulture);
            byBCDValue = BCD.DoubleToFloatingBCD(dblValue, nLength);

            // Now that we have the byte array, we can send it to the meter.
            SCSProtocolResponse ProtocolResponse = m_SCSProtocol.Download(nBasepageAddress, nLength, ref byBCDValue);

            if (SCSProtocolResponse.SCS_CAN == ProtocolResponse)
            {
                Result = ItronDeviceResult.SECURITY_ERROR;
            }
            else if (SCSProtocolResponse.SCS_NAK == ProtocolResponse)
            {
                Result = ItronDeviceResult.ERROR;
            }


            return(Result);
        }
Example #9
0
        /// <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);
        }
Example #10
0
        /// <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);
        }
Example #11
0
        /// <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()