public ImportSettings(GXDevice device)
 {
     InitializeComponent();
     m_device = device as GXDLMSDevice;
     PasswordTB.ReadOnly = m_device.Authentication == Gurux.DLMS.Authentication.None;
     SerialNumberTB.ReadOnly = m_device.HDLCAddressing != HDLCAddressType.SerialNumber;
     PasswordTB.Text = m_device.Password;
     SerialNumberTB.Text = m_device.SerialNumber;
 }
		/// <summary>
		/// Initializes a new instance of the DlmsTypeWizardDlg class.
		/// </summary>
        public DlmsTypeWizardDlg(GXDevice device, object target)
		{
            Target = target;
			InitializeComponent();						
			this.TopLevel = false;
			this.FormBorderStyle = FormBorderStyle.None;
            Device = device as GXDLMSDevice;
            UpdateResources();
		}
 public GXDLMSDeviceUI(GXDLMSDevice device)
 {
     m_Device = device;            
     InitializeComponent();
     AddressTypeCB.DrawMode = DrawMode.OwnerDrawFixed;
     this.authLevelCb.SelectedIndexChanged += new System.EventHandler(this.AuthLevelCb_SelectedIndexChanged);
     this.AddressTypeCB.SelectedIndexChanged += new System.EventHandler(this.AddressTypeCB_SelectedIndexChanged);
     authLevelCb.Items.Add(Authentication.None);
     authLevelCb.Items.Add(Authentication.Low);
     authLevelCb.Items.Add(Authentication.High);
     authLevelCb.SelectedItem = m_Device.Authentication;
     StartProtocolCB.Items.Add(StartProtocolType.IEC);
     StartProtocolCB.Items.Add(StartProtocolType.DLMS);
     StartProtocolCB.SelectedItem = m_Device.StartProtocol;
     GXClient_OnMediaStateChange(null, null);
 }
 /// <summary>
 /// Initialize settings.
 /// </summary>
 /// <param name="sender"></param>
 public void Connect(object sender)
 {
     GXClient client = sender as GXClient;
     Device = client.Owner as GXDLMSDevice;
     object ClientID = 0;
     switch (Device.Authentication)
     {
         case Gurux.DLMS.Authentication.High:
             ClientID = Device.ClientIDHigh;
             break;
         case Gurux.DLMS.Authentication.Low:
             ClientID = Device.ClientIDLow;
             break;
         case Gurux.DLMS.Authentication.None:
             ClientID = Device.ClientID;
             break;
     }
     //If network media is used check is manufacturer supporting IEC 62056-47
     if (!Device.UseRemoteSerial && Device.GXClient.Media is GXNet && Device.SupportNetworkSpecificSettings)
     {
         parser.InterfaceType = Gurux.DLMS.InterfaceType.Net;
         parser.ClientID = Convert.ToUInt16(Device.ClientID);
         parser.ServerID = Convert.ToUInt16(Device.PhysicalAddress);
     }
     else
     {
         if (Device.HDLCAddressing == HDLCAddressType.Custom)
         {
             parser.ClientID = ClientID;
         }
         else
         {
             parser.ClientID = (byte)(Convert.ToByte(ClientID) << 1 | 0x1);
         }
         if (Device.HDLCAddressing == HDLCAddressType.SerialNumber)
         {
             parser.ServerID = GXManufacturer.CountServerAddress(Device.HDLCAddressing, Device.SNFormula, Convert.ToUInt32(Device.SerialNumber), Device.LogicalAddress);
         }
         else
         {
             parser.ServerID = GXManufacturer.CountServerAddress(Device.HDLCAddressing, Device.SNFormula, Device.PhysicalAddress, Device.LogicalAddress);
         }
     }
     parser.UseLogicalNameReferencing = Device.UseLogicalNameReferencing;
 }
		/// <summary>
		/// Initializes a new instance of the DlmsWizardPage1Dlg class.
		/// </summary>
        public DlmsWizardPage1Dlg(GXDevice device)
        {
            InitializeComponent();                        
            UpdateResources();
            AddressTypeCB.DrawMode = DrawMode.OwnerDrawFixed;
            this.TopLevel = false;
            this.FormBorderStyle = FormBorderStyle.None;
            m_Device = device as GXDLMSDevice;
            UpdateManufacturers();
            this.authLevelCb.SelectedIndexChanged += new System.EventHandler(this.AuthLevelCb_SelectedIndexChanged);
            UpdatemanufactureSettings((m_Device).PhysicalAddress == null);
            this.manufacturerTypeCb.SelectedIndexChanged += new System.EventHandler(this.manufacturerTypeCb_SelectedIndexChanged);
            this.AddressTypeCB.SelectedIndexChanged += new System.EventHandler(this.AddressTypeCB_SelectedIndexChanged);
            if (m_Device.PhysicalAddress != null)
            {
                UpdateOnlineBtn.Enabled = manufacturerTypeCb.Enabled = false;
            }
        }
 /// <summary>
 /// Update categories data.
 /// </summary>
 /// <param name="trace"></param>
 /// <param name="progressbar"></param>
 /// <param name="media"></param>
 /// <param name="Device"></param>
 /// <param name="wt"></param>
 /// <param name="cosem"></param>
 /// <param name="man"></param>
 /// <param name="objs"></param>
 /// <param name="dataItems"></param>
 /// <param name="registers"></param>
 private object UpdateData(Gurux.Common.IGXMedia media, GXDLMSDevice Device, int wt, GXDLMSClient cosem, GXManufacturer man, GXDLMSObject it, GXCategory dataItems, GXCategory registers)
 {
     GXObisCode code = man.ObisCodes.FindByLN(it.ObjectType, it.LogicalName, null);            
     if (it.ObjectType == ObjectType.Register)
     {
         GXDLMSRegister prop = new GXDLMSRegister();
         UpdateObject(it, prop, 2);
         registers.Properties.Add(prop);
         return prop;
     }
     else if (it.ObjectType == Gurux.DLMS.ObjectType.Data)
     {
         GXDLMSProperty prop = new GXDLMSProperty();
         prop.ObjectType = ObjectType.Data;
         UpdateObject(it, prop, 2);
         dataItems.Properties.Add(prop);
         return prop;
     }
     else if (it.ObjectType == Gurux.DLMS.ObjectType.ProfileGeneric)
     {
         GXDLMSProfileGeneric pg = it as GXDLMSProfileGeneric;
         GXDLMSTable table = new GXDLMSTable();
         table.Name = it.LogicalName + " " + it.Description;
         table.ShortName = it.ShortName;
         table.LogicalName = it.LogicalName;
         table.AccessMode = Gurux.Device.AccessMode.Read;
         foreach(var it2 in pg.CaptureObjects)
         {
             GXDLMSProperty prop;
             if (it2.Key is Gurux.DLMS.Objects.GXDLMSRegister)
             {
                 Gurux.DLMS.Objects.GXDLMSRegister tmp = it2.Key as Gurux.DLMS.Objects.GXDLMSRegister;
                 GXDLMSRegister r = new GXDLMSRegister();
                 prop = r;
                 r.Scaler = tmp.Scaler;
                 r.Unit = tmp.Unit.ToString();                    
             }
             else
             {
                 prop = new GXDLMSProperty();
             }
             int index = it2.Value.AttributeIndex;
             prop.Name = it2.Key.LogicalName + " " + it2.Key.Description;
             prop.ObjectType = it2.Key.ObjectType;
             prop.AttributeOrdinal = index;
             prop.LogicalName = it2.Key.LogicalName;
             table.Columns.Add(prop);
             prop.DLMSType = it.GetDataType(index);                    
             prop.ValueType = it2.Key.GetUIDataType(index);
         }
         Device.Tables.Add(table);
         return table; 
     }
     GXDLMSCategory cat = new GXDLMSCategory();
     cat.ObjectType = it.ObjectType;
     UpdateObject(it, cat);
     Device.Categories.Add(cat);
     return cat;            
 }
 internal void CreateColumns(Gurux.Common.IGXMedia media, GXDLMSDevice Device, GXManufacturer man, int wt, GXDLMSClient cosem, IGXManufacturerExtension Extension, GXCategory dataItems, GXCategory registers, GXDLMSObject it, GXDLMSTable table)
 {            
 }
 public void UpdateColumns(GXDLMSDevice Device, 
             GXManufacturer man, GXDLMSClient cosem,
             Gurux.Common.IGXMedia media, int wt, Gurux.DLMS.Objects.GXDLMSObject it,
             GXDLMSTable table, GXDLMSAddIn parent, GXCategory dataItems, GXCategory registers)
 {
     //Reading data.                
     //If Load profile1
     if (it.LogicalName == "0.0.99.1.2.255")
     {
         //Read Load Profile 1 information
         byte[] allData = parent.ReadDataBlock(cosem, media, cosem.Read("0.0.99.128.1.255", ObjectType.ProfileGeneric, 2)[0], wt, 0);
         object[] items = (object[])((object[])cosem.GetValue(allData)).GetValue(0);
         int pos = 0;
         AddColumn(cosem, man, table, null, null, 0, "DateTime");
         AddColumn(cosem, man, table, null, null, 1, "Status");
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 2, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 3, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 4, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 5, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 6, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 7, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 8, null);
         pos += 2;
         AddColumn(cosem, man, table, (byte[])items.GetValue(pos), items.GetValue(pos + 1), 9, null);                
         return;
     }           
     parent.CreateColumns(media, Device, man, wt, cosem, this, dataItems, registers, it, table);                    
 }