private void LoadBroadcastLogTable(GXXmlReader reader)
 {
     BroadcastLogTable.Clear();
     if (reader.IsStartElement("BroadcastLogTable", true))
     {
         while (reader.IsStartElement("Item", false))
         {
             GXDLMSBroadcastLogTable it = new GXDLMSBroadcastLogTable();
             BroadcastLogTable.Add(it);
             it.SourceAddress  = (UInt16)reader.ReadElementContentAsInt("SourceAddress");
             it.SequenceNumber = (byte)reader.ReadElementContentAsInt("SequenceNumber");
             it.ValidTime      = (UInt16)reader.ReadElementContentAsInt("ValidTime");
         }
         reader.ReadEndElement("BroadcastLogTable");
     }
 }
Example #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)
     {
         MaxHops = Convert.ToByte(e.Value);
     }
     else if (e.Index == 3)
     {
         WeakLqiValue = Convert.ToByte(e.Value);
     }
     else if (e.Index == 4)
     {
         SecurityLevel = Convert.ToByte(e.Value);
     }
     else if (e.Index == 5)
     {
         List <object> list = new List <object>();
         if (e.Value != null)
         {
             list.AddRange((object[])e.Value);
         }
         PrefixTable = list.ToArray();
     }
     else if (e.Index == 6)
     {
         RoutingConfiguration.Clear();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[] tmp = (object[])v;
                 GXDLMSRoutingConfiguration it = new GXDLMSRoutingConfiguration();
                 it.NetTraversalTime     = Convert.ToByte(tmp[0]);
                 it.RoutingTableEntryTtl = Convert.ToUInt16(tmp[1]);
                 it.Kr                     = Convert.ToByte(tmp[2]);
                 it.Km                     = Convert.ToByte(tmp[3]);
                 it.Kc                     = Convert.ToByte(tmp[4]);
                 it.Kq                     = Convert.ToByte(tmp[5]);
                 it.Kh                     = Convert.ToByte(tmp[6]);
                 it.Krt                    = Convert.ToByte(tmp[7]);
                 it.RreqRetries            = Convert.ToByte(tmp[8]);
                 it.RreqRerrWait           = Convert.ToByte(tmp[9]);
                 it.BlacklistTableEntryTtl = Convert.ToUInt16(tmp[10]);
                 it.UnicastRreqGenEnable   = Convert.ToBoolean(tmp[11]);
                 it.RlcEnabled             = Convert.ToBoolean(tmp[12]);
                 it.AddRevLinkCost         = Convert.ToByte(tmp[13]);
                 RoutingConfiguration.Add(it);
             }
         }
     }
     else if (e.Index == 7)
     {
         BroadcastLogTableEntryTtl = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 8)
     {
         RoutingTable.Clear();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[]           tmp = (object[])v;
                 GXDLMSRoutingTable it  = new GXDLMSRoutingTable();
                 it.DestinationAddress = Convert.ToUInt16(tmp[10]);
                 it.NextHopAddress     = Convert.ToUInt16(tmp[10]);
                 it.RouteCost          = Convert.ToUInt16(tmp[10]);
                 it.HopCount           = Convert.ToByte(tmp[10]);
                 it.WeakLinkCount      = Convert.ToByte(tmp[10]);
                 it.ValidTime          = Convert.ToUInt16(tmp[10]);
                 RoutingTable.Add(it);
             }
         }
     }
     else if (e.Index == 9)
     {
         ContextInformationTable.Clear();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[] tmp = (object[])v;
                 GXDLMSContextInformationTable it = new GXDLMSContextInformationTable();
                 it.CID           = (string)tmp[0];
                 it.Context       = (byte[])tmp[2];
                 it.Compression   = Convert.ToBoolean(tmp[3]);
                 it.ValidLifetime = Convert.ToUInt16(tmp[4]);
                 ContextInformationTable.Add(it);
             }
         }
     }
     else if (e.Index == 10)
     {
         List <GXKeyValuePair <UInt16, UInt16> > list = new List <GXKeyValuePair <UInt16, UInt16> >();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[] tmp = (object[])v;
                 list.Add(new GXKeyValuePair <UInt16, UInt16>(Convert.ToUInt16(tmp[0]), Convert.ToUInt16(tmp[1])));
             }
         }
         BlacklistTable = list;
     }
     else if (e.Index == 11)
     {
         BroadcastLogTable.Clear();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[] tmp = (object[])v;
                 GXDLMSBroadcastLogTable it = new GXDLMSBroadcastLogTable();
                 it.SourceAddress  = Convert.ToUInt16(tmp[0]);
                 it.SequenceNumber = Convert.ToByte(tmp[1]);
                 it.ValidTime      = Convert.ToUInt16(tmp[2]);
                 BroadcastLogTable.Add(it);
             }
         }
     }
     else if (e.Index == 12)
     {
         List <UInt16> list = new List <UInt16>();
         if (e.Value != null)
         {
             foreach (object it in (object[])e.Value)
             {
                 list.Add(Convert.ToUInt16(it));
             }
         }
         GroupTable = list.ToArray();
     }
     else if (e.Index == 13)
     {
         MaxJoinWaitTime = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 14)
     {
         PathDiscoveryTime = Convert.ToByte(e.Value);
     }
     else if (e.Index == 15)
     {
         ActiveKeyIndex = Convert.ToByte(e.Value);
     }
     else if (e.Index == 16)
     {
         MetricType = Convert.ToByte(e.Value);
     }
     else if (e.Index == 17)
     {
         CoordShortAddress = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 18)
     {
         DisableDefaultRouting = (bool)e.Value;
     }
     else if (e.Index == 19)
     {
         DeviceType = (DeviceType)Convert.ToInt32(e.Value);
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }