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) { if (value is byte[]) { CalendarNameActive = GXDLMSClient.ChangeType((byte[])value, DataType.String).ToString(); } else { CalendarNameActive = Convert.ToString(value); } } else if (index == 3) { SeasonProfileActive = null; if (value != null) { List<GXDLMSSeasonProfile> items = new List<GXDLMSSeasonProfile>(); foreach (object[] item in (object[])value) { GXDLMSSeasonProfile it = new GXDLMSSeasonProfile(); it.Name = GXDLMSClient.ChangeType((byte[]) item[0], DataType.String).ToString(); it.Start = (GXDateTime) GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime); it.WeekName = GXDLMSClient.ChangeType((byte[]) item[2], DataType.String).ToString(); items.Add(it); } SeasonProfileActive = items.ToArray(); } } else if (index == 4) { WeekProfileTableActive = null; if (value != null) { List<GXDLMSWeekProfile> items = new List<GXDLMSWeekProfile>(); foreach (object[] item in (object[])value) { GXDLMSWeekProfile it = new GXDLMSWeekProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Monday = Convert.ToInt32(item[1]); it.Tuesday = Convert.ToInt32(item[2]); it.Wednesday= Convert.ToInt32(item[3]); it.Thursday = Convert.ToInt32(item[4]); it.Friday = Convert.ToInt32(item[5]); it.Saturday = Convert.ToInt32(item[6]); it.Sunday = Convert.ToInt32(item[7]); items.Add(it); } WeekProfileTableActive = items.ToArray(); } } else if (index == 5) { DayProfileTableActive = null; if (value != null) { List<GXDLMSDayProfile> items = new List<GXDLMSDayProfile>(); foreach (object[] item in (object[])value) { GXDLMSDayProfile it = new GXDLMSDayProfile(); it.DayId = Convert.ToInt32(item[0]); List<GXDLMSDayProfileAction> actions = new List<GXDLMSDayProfileAction>(); foreach (object[] it2 in (object[])item[1]) { GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction(); ac.StartTime = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time); ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.String).ToString(); ac.ScriptSelector = Convert.ToUInt16(it2[2]); actions.Add(ac); } it.DaySchedules = actions.ToArray(); items.Add(it); } DayProfileTableActive = items.ToArray(); } } else if (index == 6) { if (value is byte[]) { CalendarNamePassive = GXDLMSClient.ChangeType((byte[])value, DataType.String).ToString(); } else { CalendarNamePassive = Convert.ToString(value); } } else if (index == 7) { SeasonProfilePassive = null; if (value != null) { List<GXDLMSSeasonProfile> items = new List<GXDLMSSeasonProfile>(); foreach (object[] item in (object[])value) { GXDLMSSeasonProfile it = new GXDLMSSeasonProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime); it.WeekName = GXDLMSClient.ChangeType((byte[])item[2], DataType.String).ToString(); items.Add(it); } SeasonProfilePassive = items.ToArray(); } } else if (index == 8) { WeekProfileTablePassive = null; if (value != null) { List<GXDLMSWeekProfile> items = new List<GXDLMSWeekProfile>(); foreach (object[] item in (object[])value) { GXDLMSWeekProfile it = new GXDLMSWeekProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Monday = Convert.ToInt32(item[1]); it.Tuesday = Convert.ToInt32(item[2]); it.Wednesday = Convert.ToInt32(item[3]); it.Thursday = Convert.ToInt32(item[4]); it.Friday = Convert.ToInt32(item[5]); it.Saturday = Convert.ToInt32(item[6]); it.Sunday = Convert.ToInt32(item[7]); items.Add(it); } WeekProfileTablePassive = items.ToArray(); } } else if (index == 9) { DayProfileTablePassive = null; if (value != null) { List<GXDLMSDayProfile> items = new List<GXDLMSDayProfile>(); foreach (object[] item in (object[])value) { GXDLMSDayProfile it = new GXDLMSDayProfile(); it.DayId = Convert.ToInt32(item[0]); List<GXDLMSDayProfileAction> actions = new List<GXDLMSDayProfileAction>(); foreach (object[] it2 in (object[])item[1]) { GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction(); ac.StartTime = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time); ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.String).ToString(); ac.ScriptSelector = Convert.ToUInt16(it2[2]); actions.Add(ac); } it.DaySchedules = actions.ToArray(); items.Add(it); } DayProfileTablePassive = items.ToArray(); } } else if (index == 10) { if (value is byte[]) { Time = (GXDateTime)GXDLMSClient.ChangeType((byte[])value, DataType.DateTime); } else { Time = new GXDateTime(Convert.ToDateTime(value)); } } else { throw new ArgumentException("SetValue failed. Invalid attribute index."); } }
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).ToString(); } } else if (e.Index == 2) { if (e.Value is byte[]) { CalendarNameActive = GXDLMSClient.ChangeType((byte[])e.Value, DataType.String).ToString(); } else { CalendarNameActive = Convert.ToString(e.Value); } } else if (e.Index == 3) { SeasonProfileActive = null; if (e.Value != null) { List<GXDLMSSeasonProfile> items = new List<GXDLMSSeasonProfile>(); foreach (object[] item in (object[])e.Value) { GXDLMSSeasonProfile it = new GXDLMSSeasonProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime); it.WeekName = GXDLMSClient.ChangeType((byte[])item[2], DataType.String).ToString(); items.Add(it); } SeasonProfileActive = items.ToArray(); } } else if (e.Index == 4) { WeekProfileTableActive = null; if (e.Value != null) { List<GXDLMSWeekProfile> items = new List<GXDLMSWeekProfile>(); foreach (object[] item in (object[])e.Value) { GXDLMSWeekProfile it = new GXDLMSWeekProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Monday = Convert.ToInt32(item[1]); it.Tuesday = Convert.ToInt32(item[2]); it.Wednesday = Convert.ToInt32(item[3]); it.Thursday = Convert.ToInt32(item[4]); it.Friday = Convert.ToInt32(item[5]); it.Saturday = Convert.ToInt32(item[6]); it.Sunday = Convert.ToInt32(item[7]); items.Add(it); } WeekProfileTableActive = items.ToArray(); } } else if (e.Index == 5) { DayProfileTableActive = null; if (e.Value != null) { List<GXDLMSDayProfile> items = new List<GXDLMSDayProfile>(); foreach (object[] item in (object[])e.Value) { GXDLMSDayProfile it = new GXDLMSDayProfile(); it.DayId = Convert.ToInt32(item[0]); List<GXDLMSDayProfileAction> actions = new List<GXDLMSDayProfileAction>(); foreach (object[] it2 in (object[])item[1]) { GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction(); if (it2[0] is GXDateTime) { ac.StartTime = (GXDateTime)it2[0]; } else { ac.StartTime = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time); } ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.OctetString).ToString(); ac.ScriptSelector = Convert.ToUInt16(it2[2]); actions.Add(ac); } it.DaySchedules = actions.ToArray(); items.Add(it); } DayProfileTableActive = items.ToArray(); } } else if (e.Index == 6) { if (e.Value is byte[]) { CalendarNamePassive = GXDLMSClient.ChangeType((byte[])e.Value, DataType.String).ToString(); } else { CalendarNamePassive = Convert.ToString(e.Value); } } else if (e.Index == 7) { SeasonProfilePassive = null; if (e.Value != null) { List<GXDLMSSeasonProfile> items = new List<GXDLMSSeasonProfile>(); foreach (object[] item in (object[])e.Value) { GXDLMSSeasonProfile it = new GXDLMSSeasonProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime); byte[] weekName = (byte[])item[2]; //If week name is ignored. if (weekName != null && weekName.Length == 1 && weekName[0] == 0xFF) { it.WeekName = ""; } else { it.WeekName = GXDLMSClient.ChangeType((byte[])item[2], DataType.String).ToString(); } items.Add(it); } SeasonProfilePassive = items.ToArray(); } } else if (e.Index == 8) { WeekProfileTablePassive = null; if (e.Value != null) { List<GXDLMSWeekProfile> items = new List<GXDLMSWeekProfile>(); foreach (object[] item in (object[])e.Value) { GXDLMSWeekProfile it = new GXDLMSWeekProfile(); it.Name = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString(); it.Monday = Convert.ToInt32(item[1]); it.Tuesday = Convert.ToInt32(item[2]); it.Wednesday = Convert.ToInt32(item[3]); it.Thursday = Convert.ToInt32(item[4]); it.Friday = Convert.ToInt32(item[5]); it.Saturday = Convert.ToInt32(item[6]); it.Sunday = Convert.ToInt32(item[7]); items.Add(it); } WeekProfileTablePassive = items.ToArray(); } } else if (e.Index == 9) { DayProfileTablePassive = null; if (e.Value != null) { List<GXDLMSDayProfile> items = new List<GXDLMSDayProfile>(); foreach (object[] item in (object[])e.Value) { GXDLMSDayProfile it = new GXDLMSDayProfile(); it.DayId = Convert.ToInt32(item[0]); List<GXDLMSDayProfileAction> actions = new List<GXDLMSDayProfileAction>(); foreach (object[] it2 in (object[])item[1]) { GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction(); if (it2[0] is GXDateTime) { ac.StartTime = (GXDateTime)it2[0]; } else { ac.StartTime = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time); } ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.OctetString).ToString(); ac.ScriptSelector = Convert.ToUInt16(it2[2]); actions.Add(ac); } it.DaySchedules = actions.ToArray(); items.Add(it); } DayProfileTablePassive = items.ToArray(); } } else if (e.Index == 10) { if (e.Value is byte[]) { Time = (GXDateTime)GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime); } else { Time = new GXDateTime(Convert.ToDateTime(e.Value)); } } else { e.Error = ErrorCode.ReadWriteDenied; } }