Ejemplo n.º 1
0
        /// <summary>
        /// Generates the raw data for the get request
        /// </summary>
        /// <returns>The Memory Stream containing the Get Request</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        protected override MemoryStream GenerateRawData()
        {
            MemoryStream     DataStream = base.GenerateRawData();
            DLMSBinaryWriter DataWriter = new DLMSBinaryWriter(DataStream);

            DataWriter.Write(m_BlockNumber);

            return(DataStream);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates the raw data for the get request
        /// </summary>
        /// <returns>The stream containing the raw data</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        protected virtual MemoryStream GenerateRawData()
        {
            MemoryStream     DataStream = new MemoryStream();
            DLMSBinaryWriter DataWriter = new DLMSBinaryWriter(DataStream);

            DataWriter.Write(m_InvokeIDAndPriority);

            return(DataStream);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates the raw data for the specified object
        /// </summary>
        /// <returns></returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        protected override MemoryStream GenerateRawData()
        {
            MemoryStream     DataStream = base.GenerateRawData();
            DLMSBinaryWriter DataWriter = new DLMSBinaryWriter(DataStream);

            DataWriter.WriteEnum <GetResponseChoices>(m_ResponseType);
            DataWriter.Write(m_Response.Data);

            return(DataStream);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Generates the raw data for the Get Response
        /// </summary>
        /// <returns>The Memory Stream containing the raw data</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        protected override MemoryStream GenerateRawData()
        {
            MemoryStream     DataStream = base.GenerateRawData();
            DLMSBinaryWriter DataWriter = new DLMSBinaryWriter(DataStream);

            DataWriter.WriteLength(m_Result.Count);

            foreach (GetDataResult CurrentResult in m_Result)
            {
                DataWriter.Write(CurrentResult.Data);
            }

            return(DataStream);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the raw data for the Get Request
        /// </summary>
        /// <returns>The Memory stream containing the raw data</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        protected override MemoryStream GenerateRawData()
        {
            MemoryStream     DataStream = base.GenerateRawData();
            DLMSBinaryWriter DataWriter = new DLMSBinaryWriter(DataStream);

            // Write the length
            DataWriter.WriteLength(m_AttributeDescriptorList.Count);

            // Write the entries
            foreach (CosemAttributeDescriptorWithSelection CurrentDescriptor in m_AttributeDescriptorList)
            {
                DataWriter.Write(CurrentDescriptor.Data);
            }

            return(DataStream);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Generates the raw data for the Get Request
        /// </summary>
        /// <returns>The Memory Stream containing the raw data</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        protected override MemoryStream GenerateRawData()
        {
            MemoryStream     DataStream = base.GenerateRawData();
            DLMSBinaryWriter DataWriter = new DLMSBinaryWriter(DataStream);

            DataWriter.Write(m_AttributeDescriptor.Data);

            if (m_AccessSelection == null)
            {
                // The Access Selection is not included so just write the usage flag
                DataWriter.WriteUsageFlag(false);
            }
            else
            {
                // It's included so write the usage flag and access selection
                DataWriter.WriteUsageFlag(true);
                DataWriter.Write(m_AccessSelection.Data);
            }

            return(DataStream);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Finds the start index of the WPDU
        /// </summary>
        /// <param name="source">The source port to search for</param>
        /// <param name="destination">The destination port to search for</param>
        /// <param name="data">That data to search</param>
        /// <returns>The index of the start of the WPDU or -1 if not found</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/04/12 RCG 2.70.63 N/A    Created

        public static int FindStartOfWPDU(ushort source, ushort destination, List <byte> data)
        {
            int StartIndex = -1;

            // Generate the sequence to find
            MemoryStream     SearchStream = new MemoryStream();
            DLMSBinaryWriter SearchWriter = new DLMSBinaryWriter(SearchStream);

            SearchWriter.Write(VERSION);
            SearchWriter.Write(source);
            SearchWriter.Write(destination);

            byte[] SearchSequence = SearchStream.ToArray();

            for (int iStartIndex = 0; iStartIndex < data.Count - SearchSequence.Length; iStartIndex++)
            {
                bool Found = true;

                for (int iSequenceIndex = 0; iSequenceIndex < SearchSequence.Length; iSequenceIndex++)
                {
                    if (SearchSequence[iSequenceIndex] != data[iStartIndex + iSequenceIndex])
                    {
                        Found = false;
                        break;
                    }
                }

                if (Found)
                {
                    StartIndex = iStartIndex;
                    break;
                }
            }

            return(StartIndex);
        }