Beispiel #1
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (NameTB.Text.Length == 0)
                {
                    throw new Exception("Invalid manufacturer name.");
                }
                if (ManufacturerIdTB.Text.Length != 3)
                {
                    throw new Exception("Invalid manufacturer identification.");
                }
                if (ManufacturerIdTB.Enabled && Manufacturers.FindByIdentification(ManufacturerIdTB.Text) != null)
                {
                    throw new Exception("Manufacturer identification already exists.");
                }
                if (!SerialNumberFormulaTB.ReadOnly && SerialNumberFormulaTB.Text.Length == 0)
                {
                    throw new Exception("Invalid Serial Number.");
                }
                Manufacturer.Name                      = NameTB.Text;
                Manufacturer.Identification            = ManufacturerIdTB.Text;
                Manufacturer.UseLogicalNameReferencing = UseLNCB.Checked;
                Manufacturer.UseIEC47                  = UseIEC47CB.Checked;
                Manufacturer.StartProtocol             = (StartProtocolType)StartProtocolCB.SelectedItem;
                Manufacturer.Standard                  = (Standard)StandardCb.SelectedItem;


                GXAuthentication authentication = Manufacturer.GetActiveAuthentication();
                authentication.ClientAddress = Convert.ToInt32(this.ClientAddTB.Value);
                //Save server values.
                UpdateServer((GXServerAddress)ServerAddressTypeCB.SelectedItem);
                Manufacturer.WebAddress = WebAddressTB.Text;
                if (!string.IsNullOrEmpty(InfoTB.Text))
                {
                    Manufacturer.Info = Convert.ToBase64String(ASCIIEncoding.UTF8.GetBytes(InfoTB.Text));
                }
                else
                {
                    Manufacturer.Info = null;
                }
                Manufacturer.Security          = (Security)SecurityCB.SelectedItem;
                Manufacturer.SystemTitle       = GXCommon.HexToBytes(DevicePropertiesForm.GetAsHex(SystemTitleTB.Text, SystemTitleAsciiCb.Checked));
                Manufacturer.BlockCipherKey    = GXCommon.HexToBytes(DevicePropertiesForm.GetAsHex(BlockCipherKeyTB.Text, BlockCipherKeyAsciiCb.Checked));
                Manufacturer.AuthenticationKey = GXCommon.HexToBytes(DevicePropertiesForm.GetAsHex(AuthenticationKeyTB.Text, AuthenticationKeyAsciiCb.Checked));
            }
            catch (Exception Ex)
            {
                GXDLMS.Common.Error.ShowError(this, Ex);
                this.DialogResult = DialogResult.None;
            }
        }
Beispiel #2
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (NameTB.Text.Length == 0)
                {
                    throw new Exception("Invalid manufacturer name.");
                }
                if (ManufacturerIdTB.Text.Length != 3)
                {
                    throw new Exception("Invalid manufacturer identification.");
                }
                if (ManufacturerIdTB.Enabled && Manufacturers.FindByIdentification(ManufacturerIdTB.Text) != null)
                {
                    throw new Exception("Manufacturer identification already exists.");
                }
                if (!SerialNumberFormulaTB.ReadOnly && SerialNumberFormulaTB.Text.Length == 0)
                {
                    throw new Exception("Invalid Serial Number.");
                }
                Manufacturer.Name                      = NameTB.Text;
                Manufacturer.Identification            = ManufacturerIdTB.Text;
                Manufacturer.UseLogicalNameReferencing = UseLNCB.Checked;
                Manufacturer.Standard                  = (Standard)StandardCb.SelectedItem;
                Manufacturer.UtcTimeZone               = UseUtcTimeZone.Checked;

                GXAuthentication authentication = Manufacturer.GetActiveAuthentication();
                authentication.ClientAddress = Convert.ToInt32(this.ClientAddTB.Value);
                //Save server values.
                UpdateServer((GXServerAddress)ServerAddressTypeCB.SelectedItem);
                Manufacturer.WebAddress = WebAddressTB.Text;
                if (!string.IsNullOrEmpty(InfoTB.Text))
                {
                    Manufacturer.Info = Convert.ToBase64String(ASCIIEncoding.UTF8.GetBytes(InfoTB.Text));
                }
                else
                {
                    Manufacturer.Info = null;
                }
                Manufacturer.Security          = (Security)SecurityCB.SelectedItem;
                Manufacturer.SystemTitle       = GXCommon.HexToBytes(DevicePropertiesForm.GetAsHex(SystemTitleTB.Text, SystemTitleAsciiCb.Checked));
                Manufacturer.BlockCipherKey    = GXCommon.HexToBytes(DevicePropertiesForm.GetAsHex(BlockCipherKeyTB.Text, BlockCipherKeyAsciiCb.Checked));
                Manufacturer.AuthenticationKey = GXCommon.HexToBytes(DevicePropertiesForm.GetAsHex(AuthenticationKeyTB.Text, AuthenticationKeyAsciiCb.Checked));

                Manufacturer.SupporterdInterfaces = 0;
                if (HdlcCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.HDLC;
                }
                if (HdlcWithModeECb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.HdlcWithModeE;
                }
                if (WrapperCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.WRAPPER;
                }
                if (WirelessMBusCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.WirelessMBus;
                }
                if (PlcCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.Plc;
                }
                if (PlcHdlcCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.PlcHdlc;
                }
                if (LpWanCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.LPWAN;
                }
                if (WiSunCb.Checked)
                {
                    Manufacturer.SupporterdInterfaces |= 1 << (int)InterfaceType.WiSUN;
                }
                if (Manufacturer.SupporterdInterfaces == 0)
                {
                    throw new Exception("Supporterd interfaces are not selected.");
                }
            }
            catch (Exception Ex)
            {
                GXDLMS.Common.Error.ShowError(this, Ex);
                this.DialogResult = DialogResult.None;
            }
        }