Exemple #1
0
 private void LoadKeyTable(GXXmlReader reader)
 {
     KeyTable.Clear();
     if (reader.IsStartElement("KeyTable", true))
     {
         while (reader.IsStartElement("Item", true))
         {
             byte   k = (byte)reader.ReadElementContentAsInt("Key");
             byte[] d = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("Data"));
             KeyTable.Add(new GXKeyValuePair <byte, byte[]>(k, d));
         }
         reader.ReadEndElement("KeyTable");
     }
 }
Exemple #2
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         ShortAddress = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 3)
     {
         RcCoord = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 4)
     {
         PANId = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 5)
     {
         KeyTable.Clear();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[] tmp = (object[])v;
                 KeyTable.Add(new GXKeyValuePair <byte, byte[]>(Convert.ToByte(tmp[0]), (byte[])tmp[1]));
             }
         }
     }
     else if (e.Index == 6)
     {
         FrameCounter = Convert.ToUInt32(e.Value);
     }
     else if (e.Index == 7)
     {
         ToneMask = (string)e.Value;
     }
     else if (e.Index == 8)
     {
         TmrTtl = Convert.ToByte(e.Value);
     }
     else if (e.Index == 9)
     {
         MaxFrameRetries = Convert.ToByte(e.Value);
     }
     else if (e.Index == 10)
     {
         NeighbourTableEntryTtl = Convert.ToByte(e.Value);
     }
     else if (e.Index == 11)
     {
         List <GXDLMSNeighbourTable> list = new List <GXDLMSNeighbourTable>();
         if (e.Value != null)
         {
             foreach (object v in (object[])e.Value)
             {
                 object[]             tmp = (object[])v;
                 GXDLMSNeighbourTable it  = new GXDLMSNeighbourTable();
                 it.ShortAddress       = Convert.ToUInt16(tmp[0]);
                 it.Enabled            = Convert.ToBoolean(tmp[1]);
                 it.ToneMap            = (string)tmp[2];
                 it.Modulation         = (Modulation)Convert.ToInt32(tmp[3]);
                 it.TxGain             = Convert.ToSByte(tmp[4]);
                 it.TxRes              = (GainResolution)Convert.ToInt32(tmp[5]);
                 it.TxCoeff            = (string)tmp[6];
                 it.Lqi                = Convert.ToByte(tmp[7]);
                 it.PhaseDifferential  = Convert.ToSByte(tmp[8]);
                 it.TMRValidTime       = Convert.ToByte(tmp[9]);
                 it.NeighbourValidTime = Convert.ToByte(tmp[10]);
                 list.Add(it);
             }
         }
         NeighbourTable = list.ToArray();
     }
     else if (e.Index == 12)
     {
         HighPriorityWindowSize = Convert.ToByte(e.Value);
     }
     else if (e.Index == 13)
     {
         CscmFairnessLimit = Convert.ToByte(e.Value);
     }
     else if (e.Index == 14)
     {
         BeaconRandomizationWindowLength = Convert.ToByte(e.Value);
     }
     else if (e.Index == 15)
     {
         A = Convert.ToByte(e.Value);
     }
     else if (e.Index == 16)
     {
         K = Convert.ToByte(e.Value);
     }
     else if (e.Index == 17)
     {
         MinCwAttempts = Convert.ToByte(e.Value);
     }
     else if (e.Index == 18)
     {
         CenelecLegacyMode = Convert.ToByte(e.Value);
     }
     else if (e.Index == 19)
     {
         FccLegacyMode = Convert.ToByte(e.Value);
     }
     else if (e.Index == 20)
     {
         MaxBe = Convert.ToByte(e.Value);
     }
     else if (e.Index == 21)
     {
         MaxCsmaBackoffs = Convert.ToByte(e.Value);
     }
     else if (e.Index == 22)
     {
         MinBe = Convert.ToByte(e.Value);
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }