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; }
private SmlListEntry(string a_obis, UInt64?a_status, SmlTime a_valTime, uint?a_unit, int?a_scaler, SmlBase a_valueNode, SmlBase a_smlSignature) { Obis = a_obis; Status = a_status; ValTime = a_valTime; Unit = a_unit; Scaler = a_scaler; ValueNode = a_valueNode; SmlSignature = a_smlSignature; Value = null; double factor = 1; if (a_scaler.HasValue) { factor = Math.Pow(10, a_scaler.Value); } switch (a_valueNode.SmlFieldType) { case SmlFieldType.Signed8: Value = (double)((a_valueNode as SmlSigned8).Value) * factor; break; case SmlFieldType.Signed16: Value = (double)((a_valueNode as SmlSigned16).Value) * factor; break; case SmlFieldType.Signed32: Value = (double)((a_valueNode as SmlSigned32).Value) * factor; break; case SmlFieldType.Signed64: Value = (double)((a_valueNode as SmlSigned64).Value) * factor; break; case SmlFieldType.Unsigned8: Value = (double)((a_valueNode as SmlUnsigned8).Value) * factor; break; case SmlFieldType.Unsigned16: Value = (double)((a_valueNode as SmlUnsigned16).Value) * factor; break; case SmlFieldType.Unsigned32: Value = (double)((a_valueNode as SmlUnsigned32).Value) * factor; break; case SmlFieldType.Unsigned64: Value = (double)((a_valueNode as SmlUnsigned64).Value) * factor; break; } }
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; }
internal static SmlMessageBody Create(SmlBase a_baseNode) { var list = a_baseNode as SmlList; if (list == null || list.Length != 7) { return(null); } var clientId = list.GetElement(0) as SmlString; if (clientId == null && !list.GetElement(0).IsOptional) { return(null); } var serverId = list.GetElement(1) as SmlString; if (serverId == null) { return(null); } var listName = list.GetElement(2) as SmlString; if (listName == null && !list.GetElement(2).IsOptional) { return(null); } SmlTime actSensorTime = null; if (!list.GetElement(3).IsOptional) { actSensorTime = SmlTime.Create(list.GetElement(3)); if (actSensorTime == null) { return(null); } } var valListNode = list.GetElement(4) as SmlList; if (valListNode == null) { return(null); } var valList = new List <SmlListEntry>(valListNode.Length); for (int i = 0; i < valListNode.Length; i++) { var listEntry = SmlListEntry.Create(valListNode.GetElement(i)); if (listEntry == null) { return(null); } valList.Add(listEntry); } var smlSignature = list.GetElement(5); SmlTime actGatewayTime = null; if (!list.GetElement(6).IsOptional) { actGatewayTime = SmlTime.Create(list.GetElement(6)); if (actGatewayTime == null) { return(null); } } return(new SmlGetListResponse(clientId, serverId, listName, actSensorTime, valList, smlSignature, actGatewayTime)); }
public static SmlListEntry Create(SmlBase a_baseNode) { var list = a_baseNode as SmlList; if (list == null || list.Length != 7) { return(null); } var objName = list.GetElement(0) as SmlString; if (objName == null) { return(null); } var obis = GenerateObis(objName); if (obis == null) { return(null); } UInt64?status = null; switch (list.GetElement(1).SmlFieldType) { case SmlFieldType.Optional: break; case SmlFieldType.Unsigned8: status = (list.GetElement(1) as SmlUnsigned8).Value; break; case SmlFieldType.Unsigned16: status = (list.GetElement(1) as SmlUnsigned16).Value; break; case SmlFieldType.Unsigned32: status = (list.GetElement(1) as SmlUnsigned32).Value; break; case SmlFieldType.Unsigned64: status = (list.GetElement(1) as SmlUnsigned64).Value; break; default: return(null); } SmlTime valTime = null; if (!list.GetElement(2).IsOptional) { valTime = SmlTime.Create(list.GetElement(2)); if (valTime == null) { return(null); } } uint?unit = (list.GetElement(3) as SmlUnsigned8)?.Value; if (list.GetElement(3).IsOptional) { unit = null; } int?scaler = (list.GetElement(4) as SmlSigned8)?.Value; if (scaler == null && !list.GetElement(4).IsOptional) { return(null); } var value = list.GetElement(5); if (list.GetElement(5).IsOptional) { return(null); } var smlSignature = list.GetElement(6); if (list.GetElement(6).IsOptional) { smlSignature = null; } return(new SmlListEntry(obis, status, valTime, unit, scaler, value, smlSignature)); }
internal static SmlMessageBody Create(SmlBase a_baseNode) { var list = a_baseNode as SmlList; if (list == null || list.Length != 6) { return(null); } var codePage = list.GetElement(0) as SmlString; if (codePage == null && !list.GetElement(0).IsOptional) { return(null); } var encoding = codePage != null?Encoding.GetEncoding(codePage.ValueString) : null; var clientId = list.GetElement(1) as SmlString; if (clientId == null && !list.GetElement(1).IsOptional) { return(null); } var requestFileId = list.GetElement(2) as SmlString; if (requestFileId == null) { return(null); } var serverId = list.GetElement(3) as SmlString; if (serverId == null) { return(null); } var refTime = list.GetElement(4); SmlTime time; if (refTime.IsOptional) { time = null; } else { time = SmlTime.Create(refTime); if (time == null) { return(null); } } var version = list.GetElement(5) as SmlUnsigned8; if (version == null && !list.GetElement(1).IsOptional) { return(null); } return(new SmlOpenResponse(codePage, clientId, requestFileId, serverId, time, version)); }