void IGXDLMSBase.SetValue(int index, object value) { if (index == 1) { if (value is string) { LogicalName = value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString(); } } else if (index == 2) { PushObjectList.Clear(); if (value is Object[]) { foreach (object it in value as Object[]) { Object[] tmp = it as Object[]; GXDLMSPushObject obj = new GXDLMSPushObject(); obj.Type = (ObjectType)Convert.ToInt32(tmp[0]); obj.LogicalName = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.BitString).ToString(); obj.AttributeIndex = Convert.ToInt32(tmp[2]); obj.DataIndex = Convert.ToInt32(tmp[3]); PushObjectList.Add(obj); } } } else if (index == 3) { object[] tmp = value as object[]; if (tmp != null) { SendDestinationAndMethod.Service = (ServiceType)Convert.ToInt32(tmp[0]); SendDestinationAndMethod.Destination = ASCIIEncoding.ASCII.GetString((byte[]) tmp[1]); SendDestinationAndMethod.Message = (MessageType)Convert.ToInt32(tmp[2]); } } else if (index == 4) { CommunicationWindow.Clear(); if (value is Object[]) { foreach(object it in value as Object[]) { Object[] tmp = it as Object[]; GXDateTime start = GXDLMSClient.ChangeType((byte[]) tmp[0], DataType.DateTime) as GXDateTime; GXDateTime end = GXDLMSClient.ChangeType((byte[]) tmp[1], DataType.DateTime) as GXDateTime; CommunicationWindow.Add(new KeyValuePair<GXDateTime, GXDateTime>(start, end)); } } } else if (index == 5) { RandomisationStartInterval = (UInt16) value; } else if (index == 6) { NumberOfRetries = (byte) value; } else if (index == 7) { RepetitionDelay = (UInt16)value; } else { throw new ArgumentException("SetValue failed. Invalid attribute index."); } }
void IGXDLMSBase.SetValue(int index, object value) { if (index == 1) { if (value is string) { LogicalName = value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString(); } } else if (index == 2) { PushObjectList.Clear(); if (value is Object[]) { foreach (object it in value as Object[]) { Object[] tmp = it as Object[]; GXDLMSPushObject obj = new GXDLMSPushObject(); obj.Type = (ObjectType)Convert.ToInt32(tmp[0]); obj.LogicalName = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.BitString).ToString(); obj.AttributeIndex = Convert.ToInt32(tmp[2]); obj.DataIndex = Convert.ToInt32(tmp[3]); PushObjectList.Add(obj); } } } else if (index == 3) { object[] tmp = value as object[]; if (tmp != null) { SendDestinationAndMethod.Service = (ServiceType)Convert.ToInt32(tmp[0]); SendDestinationAndMethod.Destination = ASCIIEncoding.ASCII.GetString((byte[])tmp[1]); SendDestinationAndMethod.Message = (MessageType)Convert.ToInt32(tmp[2]); } } else if (index == 4) { CommunicationWindow.Clear(); if (value is Object[]) { foreach (object it in value as Object[]) { Object[] tmp = it as Object[]; GXDateTime start = GXDLMSClient.ChangeType((byte[])tmp[0], DataType.DateTime) as GXDateTime; GXDateTime end = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.DateTime) as GXDateTime; CommunicationWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end)); } } } else if (index == 5) { RandomisationStartInterval = (UInt16)value; } else if (index == 6) { NumberOfRetries = (byte)value; } else if (index == 7) { RepetitionDelay = (UInt16)value; } else { throw new ArgumentException("SetValue failed. Invalid attribute index."); } }