void IGXDLMSBase.Load(GXXmlReader reader) { SynchronizationRegister.Clear(); if (reader.IsStartElement("SynchronizationRegisters", true)) { while (reader.IsStartElement("Item", true)) { UInt16 k = (UInt16)reader.ReadElementContentAsInt("Key"); UInt32 v = (UInt32)reader.ReadElementContentAsInt("Value"); SynchronizationRegister.Add(new KeyValuePair <UInt16, UInt32>(k, v)); } reader.ReadEndElement("SynchronizationRegisters"); } PhysicalLayerDesynchronization = (UInt16)reader.ReadElementContentAsInt("PhysicalLayerDesynchronization"); TimeOutNotAddressedDesynchronization = (UInt16)reader.ReadElementContentAsInt("TimeOutNotAddressedDesynchronization"); TimeOutFrameNotOkDesynchronization = (UInt16)reader.ReadElementContentAsInt("TimeOutFrameNotOkDesynchronization"); WriteRequestDesynchronization = (UInt16)reader.ReadElementContentAsInt("WriteRequestDesynchronization"); WrongInitiatorDesynchronization = (UInt16)reader.ReadElementContentAsInt("WrongInitiatorDesynchronization"); BroadcastFramesCounter.Clear(); if (reader.IsStartElement("BroadcastFramesCounters", true)) { while (reader.IsStartElement("Item", true)) { UInt16 k = (UInt16)reader.ReadElementContentAsInt("Key"); UInt32 v = (UInt32)reader.ReadElementContentAsInt("Value"); BroadcastFramesCounter.Add(new KeyValuePair <UInt16, UInt32>(k, v)); } reader.ReadEndElement("BroadcastFramesCounters"); } RepetitionsCounter = (UInt16)reader.ReadElementContentAsInt("RepetitionsCounter"); TransmissionsCounter = (UInt16)reader.ReadElementContentAsInt("TransmissionsCounter"); CrcOkFramesCounter = (UInt16)reader.ReadElementContentAsInt("CrcOkFramesCounter"); CrcNOkFramesCounter = (UInt16)reader.ReadElementContentAsInt("CrcNOkFramesCounter"); }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { LogicalName = GXCommon.ToLogicalName(e.Value); } else if (e.Index == 2) { SynchronizationRegister.Clear(); if (e.Value != null) { foreach (object it in (object[])e.Value) { object[] tmp = (object[])it; SynchronizationRegister.Add(new KeyValuePair <ushort, uint>((ushort)tmp[0], (uint)tmp[1])); } } } else if (e.Index == 3) { object[] tmp = (object[])e.Value; PhysicalLayerDesynchronization = (uint)tmp[0]; TimeOutNotAddressedDesynchronization = (uint)tmp[1]; TimeOutFrameNotOkDesynchronization = (uint)tmp[2]; WriteRequestDesynchronization = (uint)tmp[3]; WrongInitiatorDesynchronization = (uint)tmp[4]; } else if (e.Index == 4) { BroadcastFramesCounter.Clear(); if (e.Value != null) { foreach (object it in (object[])e.Value) { object[] tmp = (object[])it; BroadcastFramesCounter.Add(new KeyValuePair <ushort, uint>((ushort)tmp[0], (uint)tmp[1])); } } } else if (e.Index == 5) { RepetitionsCounter = (uint)e.Value; } else if (e.Index == 6) { TransmissionsCounter = (uint)e.Value; } else if (e.Index == 7) { CrcOkFramesCounter = (uint)e.Value; } else if (e.Index == 8) { CrcNOkFramesCounter = (uint)e.Value; } else { e.Error = ErrorCode.ReadWriteDenied; } }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { if (e.Value is string) { LogicalName = e.Value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString, settings.UseUtc2NormalTime).ToString(); } } else if (e.Index == 2) { SynchronizationRegister.Clear(); if (e.Value != null) { foreach (object it in (object[])e.Value) { object[] tmp = (object[])it; SynchronizationRegister.Add(new KeyValuePair <UInt16, UInt32>((UInt16)tmp[0], (UInt32)tmp[1])); } } } else if (e.Index == 3) { object[] tmp = (object[])e.Value; PhysicalLayerDesynchronization = (UInt32)tmp[0]; TimeOutNotAddressedDesynchronization = (UInt32)tmp[1]; TimeOutFrameNotOkDesynchronization = (UInt32)tmp[2]; WriteRequestDesynchronization = (UInt32)tmp[3]; WrongInitiatorDesynchronization = (UInt32)tmp[4]; } else if (e.Index == 4) { BroadcastFramesCounter.Clear(); if (e.Value != null) { foreach (object it in (object[])e.Value) { object[] tmp = (object[])it; BroadcastFramesCounter.Add(new KeyValuePair <UInt16, UInt32>((UInt16)tmp[0], (UInt32)tmp[1])); } } } else if (e.Index == 5) { RepetitionsCounter = (UInt32)e.Value; } else if (e.Index == 6) { TransmissionsCounter = (UInt32)e.Value; } else if (e.Index == 7) { CrcOkFramesCounter = (UInt32)e.Value; } else if (e.Index == 8) { CrcNOkFramesCounter = (UInt32)e.Value; } else { e.Error = ErrorCode.ReadWriteDenied; } }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { LogicalName = GXCommon.ToLogicalName(e.Value); } else if (e.Index == 2) { SynchronizationRegister.Clear(); if (e.Value != null) { foreach (object tmp in (IEnumerable <object>)e.Value) { List <object> it; if (tmp is List <object> ) { it = (List <object>)tmp; } else { it = new List <object>((object[])tmp); } SynchronizationRegister.Add(new KeyValuePair <UInt16, UInt32>((UInt16)it[0], (UInt32)it[1])); } } } else if (e.Index == 3) { if (e.Value != null) { List <object> tmp; if (e.Value is List <object> ) { tmp = (List <object>)e.Value; } else { tmp = new List <object>((object[])e.Value); } PhysicalLayerDesynchronization = (UInt32)tmp[0]; TimeOutNotAddressedDesynchronization = (UInt32)tmp[1]; TimeOutFrameNotOkDesynchronization = (UInt32)tmp[2]; WriteRequestDesynchronization = (UInt32)tmp[3]; WrongInitiatorDesynchronization = (UInt32)tmp[4]; } else { PhysicalLayerDesynchronization = 0; TimeOutNotAddressedDesynchronization = 0; TimeOutFrameNotOkDesynchronization = 0; WriteRequestDesynchronization = 0; WrongInitiatorDesynchronization = 0; } } else if (e.Index == 4) { BroadcastFramesCounter.Clear(); if (e.Value != null) { foreach (List <object> it in (IEnumerable <object>)e.Value) { BroadcastFramesCounter.Add(new KeyValuePair <UInt16, UInt32>((UInt16)it[0], (UInt32)it[1])); } } } else if (e.Index == 5) { RepetitionsCounter = (UInt32)e.Value; } else if (e.Index == 6) { TransmissionsCounter = (UInt32)e.Value; } else if (e.Index == 7) { CrcOkFramesCounter = (UInt32)e.Value; } else if (e.Index == 8) { CrcNOkFramesCounter = (UInt32)e.Value; } else { e.Error = ErrorCode.ReadWriteDenied; } }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { switch (e.Index) { case 1: LogicalName = GXCommon.ToLogicalName(e.Value); break; case 2: { SynchronizationRegister.Clear(); if (e.Value != null) { foreach (object tmp in (IEnumerable <object>)e.Value) { List <object> it; if (tmp is List <object> ) { it = (List <object>)tmp; } else { it = new List <object>((object[])tmp); } SynchronizationRegister.Add(new KeyValuePair <ushort, uint>((ushort)it[0], (uint)it[1])); } } } break; case 3: { if (e.Value != null) { List <object> tmp; if (e.Value is List <object> ) { tmp = (List <object>)e.Value; } else { tmp = new List <object>((object[])e.Value); } PhysicalLayerDesynchronization = (uint)tmp[0]; TimeOutNotAddressedDesynchronization = (uint)tmp[1]; TimeOutFrameNotOkDesynchronization = (uint)tmp[2]; WriteRequestDesynchronization = (uint)tmp[3]; WrongInitiatorDesynchronization = (uint)tmp[4]; } else { PhysicalLayerDesynchronization = 0; TimeOutNotAddressedDesynchronization = 0; TimeOutFrameNotOkDesynchronization = 0; WriteRequestDesynchronization = 0; WrongInitiatorDesynchronization = 0; } } break; case 4: { BroadcastFramesCounter.Clear(); if (e.Value != null) { foreach (List <object> it in (IEnumerable <object>)e.Value) { BroadcastFramesCounter.Add(new KeyValuePair <ushort, uint>((ushort)it[0], (uint)it[1])); } } } break; case 5: RepetitionsCounter = (uint)e.Value; break; case 6: TransmissionsCounter = (uint)e.Value; break; case 7: CrcOkFramesCounter = (uint)e.Value; break; case 8: CrcNOkFramesCounter = (uint)e.Value; break; default: e.Error = ErrorCode.ReadWriteDenied; break; } }