示例#1
0
        /// <summary>
        /// Parses the WPDU from the stream. Assumes the stream is at the start of a valid WPDU
        /// </summary>
        /// <param name="dataStream">The stream to parse from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public void Parse(Stream dataStream)
        {
            DLMSBinaryReader DataReader    = new DLMSBinaryReader(dataStream);
            ushort           PayloadLength = 0;

            if (DataReader.ReadUInt16() == VERSION)
            {
                m_SourcePort      = DataReader.ReadUInt16();
                m_DestinationPort = DataReader.ReadUInt16();
                PayloadLength     = DataReader.ReadUInt16();

                if (dataStream.Length - dataStream.Position >= PayloadLength)
                {
                    m_Payload = DataReader.ReadBytes(PayloadLength);
                }
                else
                {
                    throw new ArgumentException("The stream does not currently contain the entire WPDU.");
                }
            }
            else
            {
                throw new ArgumentException("The stream is not at the start of a valid WPDU.");
            }
        }
示例#2
0
        /// <summary>
        /// Parses the APDU from the stream
        /// </summary>
        /// <param name="apduStream">The stream to parse from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public override void Parse(Stream apduStream)
        {
            base.Parse(apduStream);
            DLMSBinaryReader DataReader = new DLMSBinaryReader(apduStream);

            RequestType = DataReader.ReadEnum <GetRequestChoice>();

            m_Request.Parse(apduStream);
        }
示例#3
0
        /// <summary>
        /// Parses the APDU from the stream
        /// </summary>
        /// <param name="apduStream">The stream to parse from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public override void Parse(Stream apduStream)
        {
            base.Parse(apduStream);
            DLMSBinaryReader DataReader = new DLMSBinaryReader(apduStream);

            ResponseType = DataReader.ReadEnum <GetResponseChoices>();

            // The Response data will be set by the ResponseType property so we can just call parse
            m_Response.Parse(apduStream);
        }
示例#4
0
        /// <summary>
        /// Parses the Get Request from the stream
        /// </summary>
        /// <param name="dataStream">The stream to parse from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public override void Parse(Stream dataStream)
        {
            // Parse the invoke ID and priority first
            base.Parse(dataStream);

            // Parse the Get Request Next specific values
            DLMSBinaryReader DataReader = new DLMSBinaryReader(dataStream);

            m_BlockNumber = DataReader.ReadUInt32();
        }
示例#5
0
        /// <summary>
        /// Parses the Get Request from the stream
        /// </summary>
        /// <param name="dataStream">The stream to parse the data from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public override void Parse(Stream dataStream)
        {
            DLMSBinaryReader DataReader = new DLMSBinaryReader(dataStream);

            base.Parse(dataStream);

            // Read the length
            int Length = DataReader.ReadLength();

            // Read the descriptors
            for (int iIndex = 0; iIndex < Length; iIndex++)
            {
                CosemAttributeDescriptorWithSelection CurrentDescriptor = new CosemAttributeDescriptorWithSelection();
                CurrentDescriptor.Parse(dataStream);

                m_AttributeDescriptorList.Add(CurrentDescriptor);
            }
        }
示例#6
0
        /// <summary>
        /// Parses the Get Response from the stream
        /// </summary>
        /// <param name="dataStream">The stream to parse from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public override void Parse(Stream dataStream)
        {
            DLMSBinaryReader DataReader = new DLMSBinaryReader(dataStream);

            base.Parse(dataStream);

            // Get the length of the list
            int Length = DataReader.ReadLength();

            m_Result = new List <GetDataResult>();

            for (int iIndex = 0; iIndex < Length; iIndex++)
            {
                GetDataResult NewResult = new GetDataResult();
                NewResult.Parse(dataStream);

                m_Result.Add(NewResult);
            }
        }
示例#7
0
        /// <summary>
        /// Parses the data from the stream
        /// </summary>
        /// <param name="dataStream">The stream to parse from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public override void Parse(Stream dataStream)
        {
            // Parse the Invoke ID and Priority bit first
            base.Parse(dataStream);

            // Parse the Get Request Normal specific items
            DLMSBinaryReader DataReader = new DLMSBinaryReader(dataStream);

            m_AttributeDescriptor = new CosemAttributeDescriptor();
            m_AttributeDescriptor.Parse(dataStream);

            // The Access Selection is optional so we need to read the usage flag
            if (DataReader.ReadUsageFlag() == true)
            {
                m_AccessSelection = new SelectiveAccessDescriptor();
                m_AccessSelection.Parse(dataStream);
            }
            else
            {
                m_AccessSelection = null;
            }
        }
示例#8
0
        /// <summary>
        /// Parses the Get Request from the stream
        /// </summary>
        /// <param name="dataStream">The stream to parse the request from</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public virtual void Parse(Stream dataStream)
        {
            DLMSBinaryReader DataReader = new DLMSBinaryReader(dataStream);

            m_InvokeIDAndPriority = DataReader.ReadByte();
        }