예제 #1
0
파일: SCSDisplay.cs 프로젝트: lenloe1/Stuff
        /// <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;
            }
        }
예제 #2
0
파일: SCSDisplay.cs 프로젝트: lenloe1/Stuff
        /// <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;
            }
        }
예제 #3
0
        /// <summary>
        /// Constructs an SCS display item from the bit mapped, 4 byte SCS display item
        /// record.
        /// </summary>
        /// <param name="byDisplayTable"></param>
        /// <param name="nTableOffset"></param>
        /// <param name="boolTestMode"></param>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 12/15/06 mah 8.00.00  N/A   Created
        /// </remarks>
        public SCSDisplayItem(ref byte[] byDisplayTable, int nTableOffset, bool boolTestMode)
            : base()
        {
            // If the first byte contains an FF then this is an end of file marker

            m_boolEndOfFile = (byDisplayTable[nTableOffset] == END_OF_TABLE);

            if (!m_boolEndOfFile)
            {
                // make a copy of the unprocessed display item data for later interpretation if needed
                m_abyItemData = new byte[DISPLAYITEM_LENGTH];
                Array.Copy(byDisplayTable, nTableOffset, m_abyItemData, 0, DISPLAYITEM_LENGTH);

                // Decode the register type and class in order to determine what meaning of the
                // display table

                m_byRegisterType  = (byte)((byDisplayTable[nTableOffset] & 0x70) >> 4);
                m_byRegisterClass = (SCSDisplayClass)(byDisplayTable[nTableOffset] & 0x0F);

                // Extract the ID code from the second byte of the display table

                m_byDisplayID = BCD.BCDtoByte(byDisplayTable[nTableOffset + ID_OFFSET]);

                // Note that an ID code of zero indicates that no ID was programmed.  Therefore
                // return an empty string rather than display a 0
                if (m_byDisplayID == 0)
                {
                    m_strDisplayID = "";
                }
                else
                {
                    m_strDisplayID = m_byDisplayID.ToString(CultureInfo.InvariantCulture);
                }

                if (boolTestMode)
                {
                    m_DisplayType = ItronDevice.DisplayMode.TEST_MODE;
                }
                else if ((byDisplayTable[nTableOffset + DISPLAYMODE_OFFSET] & ALTMODE_MASK) != 0)
                {
                    m_DisplayType = ItronDevice.DisplayMode.ALT_MODE;
                }
                else
                {
                    m_DisplayType = ItronDevice.DisplayMode.NORMAL_MODE;
                }

                m_byTOURate = (byte)((byDisplayTable[nTableOffset + TOURATE_OFFSET] & 0x70) >> 4);

                m_byUpperAddress = BCD.BCDtoByte((byte)(byDisplayTable[nTableOffset + ADDRESSBANK_OFFSET] & 0x0F));
                m_byLowerAddress = byDisplayTable[nTableOffset + ADDRESS_OFFSET];
            }
            else
            {
                m_strDescription = "End of Table";
                m_DisplayType    = ItronDevice.DisplayMode.NORMAL_MODE;
            }
        }