Exemplo n.º 1
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         Mode = (AutoConnectMode)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 3)
     {
         Repetitions = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         RepetitionDelay = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         CallingWindow.Clear();
         if (e.Value != null)
         {
             foreach (List <object> item in (List <object>)e.Value)
             {
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime, settings.UseUtc2NormalTime);
                 GXDateTime end   = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime, settings.UseUtc2NormalTime);
                 CallingWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 6)
     {
         Destinations = null;
         if (e.Value != null)
         {
             List <string> items = new List <string>();
             foreach (object item in (List <object>)e.Value)
             {
                 string it;
                 if (item is byte[])
                 {
                     it = GXDLMSClient.ChangeType((byte[])item, DataType.String, false).ToString();
                 }
                 else
                 {
                     it = Convert.ToString(item);
                     DestinationsAsString = true;
                 }
                 items.Add(it);
             }
             Destinations = items.ToArray();
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Exemplo n.º 2
0
 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)
     {
         Mode = (AutoConnectMode)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 3)
     {
         Repetitions = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         RepetitionDelay = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         CallingWindow.Clear();
         if (e.Value != null)
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime);
                 GXDateTime end   = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime);
                 CallingWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 6)
     {
         Destinations = null;
         if (e.Value != null)
         {
             List <string> items = new List <string>();
             foreach (byte[] item in (object[])e.Value)
             {
                 string it = GXDLMSClient.ChangeType(item, DataType.String).ToString();
                 items.Add(it);
             }
             Destinations = items.ToArray();
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Exemplo n.º 3
0
 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)
     {
         Mode = (AutoConnectMode)Convert.ToInt32(value);
     }
     else if (index == 3)
     {
         Repetitions = Convert.ToInt32(value);
     }
     else if (index == 4)
     {
         RepetitionDelay = Convert.ToInt32(value);
     }
     else if (index == 5)
     {
         CallingWindow.Clear();
         if (value != null)
         {
             foreach (Object[] item in (Object[])value)
             {
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime);
                 GXDateTime end   = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime);
                 CallingWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (index == 6)
     {
         Destinations = null;
         if (value != null)
         {
             List <string> items = new List <string>();
             foreach (byte[] item in (object[])value)
             {
                 string it = GXDLMSClient.ChangeType(item, DataType.String).ToString();
                 items.Add(it);
             }
             Destinations = items.ToArray();
         }
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
Exemplo n.º 4
0
 void IGXDLMSBase.Load(GXXmlReader reader)
 {
     Mode            = (AutoConnectMode)reader.ReadElementContentAsInt("Mode");
     Repetitions     = reader.ReadElementContentAsInt("Repetitions");
     RepetitionDelay = reader.ReadElementContentAsInt("RepetitionDelay");
     CallingWindow.Clear();
     if (reader.IsStartElement("CallingWindow", true))
     {
         while (reader.IsStartElement("Item", true))
         {
             GXDateTime start = new GXDateTime(reader.ReadElementContentAsString("Start"), CultureInfo.InvariantCulture);
             GXDateTime end   = new GXDateTime(reader.ReadElementContentAsString("End"), CultureInfo.InvariantCulture);
             CallingWindow.Add(new KeyValuePair <DLMS.GXDateTime, DLMS.GXDateTime>(start, end));
         }
         reader.ReadEndElement("CallingWindow");
     }
     Destinations = reader.ReadElementContentAsString("Destinations", "").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
 }