Example #1
0
        /// <summary>
        /// Reads Mfg table 564 out of the meter
        /// </summary>
        /// <returns>A PSEMResponse encapsulating the layer 7 response to the
        /// layer 7 request. (PSEM errors)</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  12/19/11 AF  2.53.21 184509 Created
        //  11/07/12 AF  2.70.36 242041 This is primarily a firmware issue but if the data
        //                              are missing, don't try to read 0 bytes.
        //
        public override PSEMResponse Read()
        {
            m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Read Table " + m_TableID.ToString(CultureInfo.CurrentCulture));

            // Read the table - Since Read does a full read and checks the length
            // which should never be the same size as the whole table we need to do
            // an offset read here
            PSEMResponse Result = base.Read(0, (ushort)TABLE_2612_HEADER_LENGTH);

            if (PSEMResponse.Ok == Result)
            {
                m_DataStream.Position = 0;

                m_TLVID         = m_Reader.ReadUInt32();
                m_TLVDataLength = m_Reader.ReadUInt32();

                //Handle when meter returns a TLVDataLength of 0xFFFF in error.
                if (m_TLVDataLength > 0 && m_TLVDataLength < 0xFFFF)
                {
                    m_TLVData = new byte[m_TLVDataLength];
                    m_Size   += m_TLVDataLength;

                    m_DataStream.Position = TABLE_2612_HEADER_LENGTH;

                    // Resize the data array
                    byte[] ResizedData = new byte[m_Size];
                    Array.Copy(m_Data, 0, ResizedData, 0, m_Data.Length);
                    m_Data = ResizedData;

                    m_DataStream = new MemoryStream(m_Data);
                    m_Reader     = new PSEMBinaryReader(m_DataStream);
                    m_Writer     = new PSEMBinaryWriter(m_DataStream);

                    Result = base.Read((ushort)TABLE_2612_HEADER_LENGTH, (ushort)m_TLVDataLength);

                    if (Result == PSEMResponse.Ok)
                    {
                        m_TLVData = m_Reader.ReadBytes((int)m_TLVDataLength);
                    }
                }
                else
                {
                    Result = PSEMResponse.Onp;
                }
            }
            else
            {
                Result = PSEMResponse.Onp;
            }

            return(Result);
        }
Example #2
0
        /// <summary>
        /// Write LID
        /// </summary>
        /// <param name="lid">The Lid to Write</param>
        /// <param name="fltValue">The float value to write to the meter</param>
        /// <returns>PSEMResponse</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  10/05/06 KRC 8.00.14 N/A    Created
        //
        public PSEMResponse WriteLID(LID lid, Single fltValue)
        {
            byte[] Data = new byte[LID_LENGTH + sizeof(float)];
            Data.Initialize();
            MemoryStream     DataStream = new MemoryStream(Data);
            PSEMBinaryWriter DataWriter = new PSEMBinaryWriter(DataStream);

            DataWriter.Write(lid.lidValue);
            DataWriter.Write(fltValue);

            PSEMResponse Result = m_PSEM.FullWrite(LID_WRITE_TABLE, Data);

            return(Result);
        }
Example #3
0
        /// <summary>
        /// Changes the size of the table to the specified value
        /// </summary>
        /// <param name="size">The new size of the table.</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  04/27/10 RCG 2.40.43 N/A    Created

        protected void ChangeTableSize(uint size)
        {
            m_Size = size;

            // Changeing the size of the table means that anything that has been read will be lost
            // This operation should really only be done for special cases
            m_Data = new byte[m_Size];
            m_Data.Initialize();
            m_DataStream = new MemoryStream(m_Data);
            m_Reader     = new PSEMBinaryReader(m_DataStream);
            m_Writer     = new PSEMBinaryWriter(m_DataStream);

            State = TableState.Unloaded;
        }
Example #4
0
        /// <summary>
        /// Write LID
        /// </summary>
        /// <param name="lid">The Lid to Write</param>
        /// <param name="dblValue">The double value to write to the meter</param>
        /// <returns>PSEMResponse</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  10/05/06 KRC 8.00.14 N/A    Created
        //
        public PSEMResponse WriteLID(LID lid, Double dblValue)
        {
            byte[] Data = new byte[LID_LENGTH + sizeof(double)];
            Data.Initialize();
            MemoryStream     DataStream = new MemoryStream(Data);
            PSEMBinaryWriter DataWriter = new PSEMBinaryWriter(DataStream);

            DataStream.Position = 0;
            DataWriter.Write(lid.lidValue);
            DataWriter.Write(dblValue);

            PSEMResponse Result = m_PSEM.FullWrite(LID_WRITE_TABLE, DataStream.ToArray());

            return(Result);
        }
Example #5
0
        /// <summary>
        /// Reconfigures the LED Quantity on a Polyphase meter.
        /// </summary>
        /// <param name="quantity">The quantity to reconfigure.</param>
        /// <param name="pulseWeight">The pulse weight to use. Note: The pulse weight will be divided by 40 to get the actual value.</param>
        /// <returns>The result of the procedure call.</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 03/07/11 RCG 2.50.06 N/A    Created

        public ProcedureResultCodes ReconfigurePolyLEDQuantity(LEDQuantity quantity, ushort pulseWeight)
        {
            ProcedureResultCodes Result = ProcedureResultCodes.UNRECOGNIZED_PROC;

            byte[]           ProcResponse    = null;
            MemoryStream     ParameterStream = new MemoryStream(new byte[6]);
            PSEMBinaryWriter ParameterWriter = new PSEMBinaryWriter(ParameterStream);

            ParameterWriter.Write(quantity.QuantityID);

            if (VersionChecker.CompareTo(FWRevision, VERSION_HYDROGEN_3_10) == 0)
            {
                // 3.10 builds had a bug in this procedure so we need to set this based on the Meter Class
                ParameterWriter.Write(CalculatePulseWeightValueForLEDReconfigureBug(pulseWeight));
            }
            else
            {
                ParameterWriter.Write(pulseWeight);
            }

            Result = ExecuteProcedure(Procedures.POLY_LED_RECONFIGURE, ParameterStream.ToArray(), out ProcResponse);

            return(Result);
        }
Example #6
0
        /// <summary>
        /// This method executes the enter/exit test mode.
        /// </summary>
        /// <param name="modeType">TestMode Type</param>
        /// <param name="timeInTestMode">time for the meter to remain in test minutes</param>
        /// <param name="pulseWeight">actual test mode kh</param>
        /// /// <param name="pulseQuantity">Quantity to be measured in test mode</param>
        /// <returns>The result of the test mode operation.</returns>
        // MM/DD/YY who Version Issue#   Description
        // -------- --- ------- -------- ---------------------------------------
        // 06/23/17 CFB 4.72.02 WR767058 Created
        //
        public virtual ItronDeviceResult EnterExitTestMode(TestMode modeType, byte timeInTestMode, float pulseWeight, uint pulseQuantity)
        {
            ItronDeviceResult    Result     = ItronDeviceResult.ERROR;
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;

            byte[] ProcParam = new byte[8];
            OpenWayMFGTable2170 Table2170 = new OpenWayMFGTable2170(m_PSEM, Table00);

            byte[]           ProcResponse;
            PSEMBinaryWriter PSEMWriter      = new PSEMBinaryWriter(new MemoryStream(ProcParam));
            bool             blnWaitResponse = true;
            int iSeconds = 0;
            //Pulse Weight Test value should be in increments of 0.025 so multiply by 40
            float fPulseWeightParam = pulseWeight * 40;

            PSEMWriter.Write((byte)modeType);
            PSEMWriter.Write(timeInTestMode);
            PSEMWriter.Write(pulseQuantity);
            PSEMWriter.Write((ushort)fPulseWeightParam);

            ProcResult = ExecuteProcedure(Procedures.ENTER_EXIT_TEST_MODE, ProcParam, out ProcResponse);

            if (ProcedureResultCodes.COMPLETED == ProcResult)
            {
                if (TestMode.ENTER_TEST_MODE == modeType)
                {
                    //If we are entering test mode then we will wait
                    //while IsInTestMode property is false.
                    blnWaitResponse = false;
                }

                while (blnWaitResponse == IsInTestMode && 5 > iSeconds)
                {
                    //Check mode every 1 sec. for 5 sec.
                    System.Threading.Thread.Sleep(1000);
                    iSeconds += 1;
                }
            }

            switch (ProcResult)
            {
            case ProcedureResultCodes.COMPLETED:
            {
                //Success
                Result = ItronDeviceResult.SUCCESS;
                break;
            }

            case ProcedureResultCodes.NO_AUTHORIZATION:
            {
                //Isc error
                Result = ItronDeviceResult.SECURITY_ERROR;
                break;
            }

            default:
            {
                //General Error
                Result = ItronDeviceResult.ERROR;
                break;
            }
            }

            return(Result);
        }