Esempio n. 1
0
        private static string GenerateObis(SmlString a_string)
        {
            if (a_string.ValueBytes.Length != 6)
            {
                return(null);
            }

            return($"{a_string.ValueBytes[0]}-{a_string.ValueBytes[1]}:{a_string.ValueBytes[2]}.{a_string.ValueBytes[3]}.{a_string.ValueBytes[4]}*{a_string.ValueBytes[5]}");
        }
Esempio n. 2
0
 private SmlGetListResponse(SmlString a_clientId, SmlString a_serverId, SmlString a_listName, SmlTime a_actSensorTime, List <SmlListEntry> a_values, SmlBase a_smlSignature, SmlTime a_actGatewayTime)
 {
     ClientId       = a_clientId;
     ServerId       = a_serverId;
     ListName       = a_listName;
     ActSensorTime  = a_actSensorTime;
     Values         = a_values;
     SmlSignature   = a_smlSignature;
     ActGatewayTime = a_actGatewayTime;
 }
Esempio n. 3
0
 private SmlOpenResponse(SmlString a_codePage, SmlString a_clientId, SmlString a_requestFileId, SmlString a_serverId, SmlTime a_time, SmlUnsigned8 a_version)
 {
     m_codePage = a_codePage;
     if (m_codePage != null)
     {
         m_encoding = Encoding.GetEncoding(m_codePage.ValueString);
     }
     else
     {
         m_encoding = null;
     }
     m_clientId      = m_encoding != null ? new SmlString(a_clientId.ValueBytes, m_encoding) : a_clientId;
     m_requestFileId = m_encoding != null ? new SmlString(a_requestFileId.ValueBytes, m_encoding) : a_requestFileId;
     m_serverId      = m_encoding != null ? new SmlString(a_serverId.ValueBytes, m_encoding) : a_serverId;
     m_time          = a_time;
     m_version       = a_version;
 }
Esempio n. 4
0
        public override ParseResult ContinuePopulate(byte a_byte)
        {
            var ret = m_tl.ContinuePopulate(a_byte);

            if (ret == ParseResult.MoreBytesNeeded)
            {
                return(ParseResult.MoreBytesNeeded);
            }

            if (ret == ParseResult.Failed)
            {
                return(EndWithFailed());
            }

            SmlList list = m_tl.EndPopulate() as SmlList;

            if (list == null || list.Length != 6)
            {
                return(EndWithFailed());
            }

            m_transactionId = list.GetElement(0) as SmlString;
            if (m_transactionId == null)
            {
                return(EndWithFailed());
            }

            m_groupNo = list.GetElement(1) as SmlUnsigned8;
            if (m_groupNo == null)
            {
                return(EndWithFailed());
            }

            m_abortOnError = list.GetElement(2) as SmlUnsigned8;
            if (m_abortOnError == null)
            {
                return(EndWithFailed());
            }

            var body = list.GetElement(3) as SmlList;

            if (body == null || body.Length != 2)
            {
                return(EndWithFailed());
            }
            var type = body.GetElement(0) as SmlUnsigned32;

            if (type == null || !Enum.IsDefined(typeof(SmlMessageType), type.Value))
            {
                return(EndWithFailed());
            }
            m_messageType = (SmlMessageType)type.Value;
            m_body        = SmlMessageBody.Create(m_messageType, body.GetElement(1));
            if (m_body == null)
            {
                return(EndWithFailed());
            }

            m_crc = list.GetElement(4) as SmlUnsigned16;
            if (m_crc == null)
            {
                return(EndWithFailed());
            }

            var eom = list.GetElement(5) as SmlTypeLengthField;

            if (eom == null || eom.SmlFieldType != SmlFieldType.EndOfMessage)
            {
                return(EndWithFailed());
            }

            m_state = State.Done;
            return(ParseResult.Done);
        }