void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         PHYReference = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 3)
     {
         List <GXDLMSPppSetupLcpOption> items = new List <GXDLMSPppSetupLcpOption>();
         if (e.Value is List <object> )
         {
             foreach (List <object> item in (List <object>)e.Value)
             {
                 GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                 it.Type   = (PppSetupLcpOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data   = item[2];
                 items.Add(it);
             }
         }
         LCPOptions = items.ToArray();
     }
     else if (e.Index == 4)
     {
         List <GXDLMSPppSetupIPCPOption> items = new List <GXDLMSPppSetupIPCPOption>();
         if (e.Value is List <object> )
         {
             foreach (List <object> item in (List <object>)e.Value)
             {
                 GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                 it.Type   = (PppSetupIPCPOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data   = item[2];
                 items.Add(it);
             }
         }
         IPCPOptions = items.ToArray();
     }
     else if (e.Index == 5)
     {
         if (e.Value != null)
         {
             UserName = (byte[])((List <object>)e.Value)[0];
             Password = (byte[])((List <object>)e.Value)[1];
         }
         else
         {
             UserName = Password = null;
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Example #2
0
        void IGXDLMSBase.Load(GXXmlReader reader)
        {
            PHYReference = reader.ReadElementContentAsString("PHYReference");
            List <GXDLMSPppSetupLcpOption> options = new List <GXDLMSPppSetupLcpOption>();

            if (reader.IsStartElement("LCPOptions", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                    it.Type   = (PppSetupLcpOptionType)reader.ReadElementContentAsInt("Type");
                    it.Length = (byte)reader.ReadElementContentAsInt("Length");
                    it.Data   = reader.ReadElementContentAsObject("Data", null);
                }
                reader.ReadEndElement("LCPOptions");
            }
            LCPOptions = options.ToArray();

            List <GXDLMSPppSetupIPCPOption> list = new List <GXDLMSPppSetupIPCPOption>();

            if (reader.IsStartElement("IPCPOptions", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                    it.Type   = (PppSetupIPCPOptionType)reader.ReadElementContentAsInt("Type");
                    it.Length = (byte)reader.ReadElementContentAsInt("Length");
                    it.Data   = reader.ReadElementContentAsObject("Data", null);
                }
                reader.ReadEndElement("IPCPOptions");
            }
            IPCPOptions = list.ToArray();

            UserName = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("UserName"));
            Password = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("Password"));
        }
Example #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ln">Logical Name of the object.</param>
 /// <param name="sn">Short Name of the object.</param>
 public GXDLMSPppSetup(string ln, ushort sn)
     : base(ObjectType.PppSetup, ln, sn)
 {
     LCPOptions  = new GXDLMSPppSetupLcpOption[0];
     IPCPOptions = new GXDLMSPppSetupIPCPOption[0];
 }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDLMSPppSetup()
     : base(ObjectType.PppSetup)
 {
     LCPOptions  = new GXDLMSPppSetupLcpOption[0];
     IPCPOptions = new GXDLMSPppSetupIPCPOption[0];
 }
Example #5
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, 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 string)
         {
             PHYReference = value.ToString();
         }
         else
         {
             PHYReference = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString();
         }
     }
     else if (index == 3)
     {
         List <GXDLMSPppSetupLcpOption> items = new List <GXDLMSPppSetupLcpOption>();
         if (value is Object[])
         {
             foreach (Object[] item in (Object[])value)
             {
                 GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                 it.Type   = (PppSetupLcpOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data   = item[2];
                 items.Add(it);
             }
         }
         LCPOptions = items.ToArray();
     }
     else if (index == 4)
     {
         List <GXDLMSPppSetupIPCPOption> items = new List <GXDLMSPppSetupIPCPOption>();
         if (value is Object[])
         {
             foreach (Object[] item in (Object[])value)
             {
                 GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                 it.Type   = (PppSetupIPCPOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data   = item[2];
                 items.Add(it);
             }
         }
         IPCPOptions = items.ToArray();
     }
     else if (index == 5)
     {
         UserName = (byte[])((Object[])value)[0];
         Password = (byte[])((Object[])value)[1];
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
Example #6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ln">Logical Name of the object.</param>
 /// <param name="sn">Short Name of the object.</param>
 public GXDLMSPppSetup(string ln, ushort sn)
 : base(ObjectType.PppSetup, ln, sn)
 {
     LCPOptions = new GXDLMSPppSetupLcpOption[0];
     IPCPOptions = new GXDLMSPppSetupIPCPOption[0];
 }
Example #7
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)
     {
         if (e.Value is string)
         {
             PHYReference = e.Value.ToString();
         }
         else
         {
             PHYReference = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 3)
     {
         List<GXDLMSPppSetupLcpOption> items = new List<GXDLMSPppSetupLcpOption>();
         if (e.Value is Object[])
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                 it.Type = (PppSetupLcpOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data = item[2];
                 items.Add(it);
             }
         }
         LCPOptions = items.ToArray();
     }
     else if (e.Index == 4)
     {
         List<GXDLMSPppSetupIPCPOption> items = new List<GXDLMSPppSetupIPCPOption>();
         if (e.Value is Object[])
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                 it.Type = (PppSetupIPCPOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data = item[2];
                 items.Add(it);
             }
         }
         IPCPOptions = items.ToArray();
     }
     else if (e.Index == 5)
     {
         UserName = (byte[])((Object[])e.Value)[0];
         Password = (byte[])((Object[])e.Value)[1];
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Example #8
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)
     {
         if (e.Value is string)
         {
             PHYReference = e.Value.ToString();
         }
         else
         {
             PHYReference = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 3)
     {
         List <GXDLMSPppSetupLcpOption> items = new List <GXDLMSPppSetupLcpOption>();
         if (e.Value is Object[])
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                 it.Type   = (PppSetupLcpOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data   = item[2];
                 items.Add(it);
             }
         }
         LCPOptions = items.ToArray();
     }
     else if (e.Index == 4)
     {
         List <GXDLMSPppSetupIPCPOption> items = new List <GXDLMSPppSetupIPCPOption>();
         if (e.Value is Object[])
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                 it.Type   = (PppSetupIPCPOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data   = item[2];
                 items.Add(it);
             }
         }
         IPCPOptions = items.ToArray();
     }
     else if (e.Index == 5)
     {
         UserName = (byte[])((Object[])e.Value)[0];
         Password = (byte[])((Object[])e.Value)[1];
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
 /// <summary> 
 /// Constructor.
 /// </summary> 
 public GXDLMSPppSetup()
     : base(ObjectType.PppSetup)
 {
     LCPOptions = new GXDLMSPppSetupLcpOption[0];
     IPCPOptions = new GXDLMSPppSetupIPCPOption[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)
     {
         if (value is string)
         {
             PHYReference = value.ToString();
         }
         else
         {
             PHYReference = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString();
         }
     }
     else if (index == 3)
     {
         List<GXDLMSPppSetupLcpOption> items = new List<GXDLMSPppSetupLcpOption>();
         if (value is Object[])
         {
             foreach (Object[] item in (Object[])value)
             {
                 GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                 it.Type = (GXDLMSPppSetupLcpOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data = item[2];
                 items.Add(it);
             }
         }
         LCPOptions = items.ToArray();
     }
     else if (index == 4)
     {
         List<GXDLMSPppSetupIPCPOption> items = new List<GXDLMSPppSetupIPCPOption>();
         if (value is Object[])
         {
             foreach (Object[] item in (Object[])value)
             {
                 GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                 it.Type = (GXDLMSPppSetupIPCPOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data = item[2];
                 items.Add(it);
             }
         }
         IPCPOptions = items.ToArray();
     }
     else if (index == 5)
     {
         UserName = (byte[]) ((Object[])value)[0];
         Password = (byte[])((Object[])value)[1];
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }