diff --git a/GenesisCordonelTester/API/InterfaceGCIToLaatzen.cs b/GenesisCordonelTester/API/InterfaceGCIToLaatzen.cs index e90e6327c..36b702bac 100644 --- a/GenesisCordonelTester/API/InterfaceGCIToLaatzen.cs +++ b/GenesisCordonelTester/API/InterfaceGCIToLaatzen.cs @@ -22,7 +22,6 @@ using Xylem.Common.CommonCore.Consts; using Xylem.Common.Hardware.Interfaces.Ports.PortCore; using Xylem.Common.Hardware.WaterMeter.Genesis.Applications.Const; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; -using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes; @@ -171,7 +170,7 @@ namespace GenesisCordonelInterface.API using (var mb = new MeterBatch()) using (var meter = new GenesisMeter()) { - meter.SetupFromConfigFile(slot, false); + //meter.SetupFromConfigFile(slot, false); mb.AddMeter(meter); var rawData = new ConcurrentBag(); @@ -227,7 +226,7 @@ namespace GenesisCordonelInterface.API using (var mb = new MeterBatch()) using (var meter = new GenesisMeter()) { - meter.SetupFromConfigFile(slot, false); + //meter.SetupFromConfigFile(slot, false); mb.AddMeter(meter); meter.Logout(); @@ -348,6 +347,16 @@ namespace GenesisCordonelInterface.API #endregion #region API - Connect + + public class InitResult + { + public bool Success { get; set; } + public int Slot { get; set; } + public string ErrorMessage { get; set; } + public string InterfaceVersion { get; set; } + public bool InterfaceSupportsFwVersion { get; set; } + } + /// /// Represents the result of a connect operation. /// @@ -415,6 +424,54 @@ namespace GenesisCordonelInterface.API public string Privilege { get; set; } } + + + public InitResult InitOneMeterFromExtern(Int32 slotNo, ConfigSource useConfigSource, PasswordSource usePasswordSource, PortConfig? requestPort, PortConfig? streamingPort) + { + try + { + if (slotNo <= 0) + throw new ArgumentOutOfRangeException(nameof(slotNo), "Slot number must be greater than zero."); + + //_meterBatch.RemoveMeter(slotNo); + _currentGenesis?.DisposeMeter(); + + _currentGenesis = new GenesisMeter(); + _currentGenesis.UseOfflinePasswords = usePasswordSource == PasswordSource.OfflineFile; + _currentGenesis.usePasswordSource = usePasswordSource; + _currentGenesis.useConfigSource = useConfigSource; + + _currentGenesis.SetupFromExternConfig( + slotNo, + requestPort, + streamingPort, + true); + + _meterBatch.AddMeter(_currentGenesis); + + return new InitResult + { + Success = true, + Slot = slotNo, + InterfaceVersion = _currentGenesis.InterfaceInfo?.InterfaceVersion, + InterfaceSupportsFwVersion = _currentGenesis.InterfaceSupportsFwVersion + }; + } + catch (Exception ex) + { + //_meterBatch.RemoveAllMeters(); + _currentGenesis?.DisposeMeter(); + _currentGenesis = null; + + return new InitResult + { + Success = false, + Slot = slotNo, + ErrorMessage = ex.Message + }; + } + } + /// /// Connects to a Genesis meter for the specified slot. /// @@ -439,9 +496,102 @@ namespace GenesisCordonelInterface.API /// } /// /// - public ConnectResult Connect(int slotNo, PasswordSource usePasswordSource, List externPasswords) + public ConnectResult ConnectOneMeter(int slotNo) { try + { + // Validate input + if (slotNo <= 0) + throw new ArgumentOutOfRangeException(nameof(slotNo), "Slot number must be greater than zero."); + + // Find meter in batch by slot + var meter = _meterBatch.ListOfMeters + .OfType() + .FirstOrDefault(m => m.Slot == slotNo); + + // Meter not initialized + if (meter == null) + { + return new ConnectResult + { + Success = false, + Slot = slotNo, + ErrorMessage = $"Meter for slot {slotNo} not found in batch." + }; + } + + // Set current working meter + _currentGenesis = meter; + + // Perform login for meters in batch + _meterBatch.MetersLogin(); + + // Validate connection result + if (!_currentGenesis.IsLoggedOn && string.IsNullOrEmpty(_currentGenesis.PcbId)) + { + return new ConnectResult + { + Success = false, + Slot = slotNo, + IsLoggedOn = false, + PcbId = _currentGenesis.PcbId, + ErrorMessage = "Cannot read out PcbId. Access to Cordonel denied." + }; + } + + // Build successful result + var result = new ConnectResult + { + Success = _currentGenesis.IsLoggedOn, + Slot = slotNo, + PcbId = _currentGenesis.PcbId, + IsLoggedOn = _currentGenesis.IsLoggedOn, + FwVersion = _currentGenesis.FwVersion, + InterfaceVersion = _currentGenesis.InterfaceInfo?.InterfaceVersion, + InterfaceSupportsFwVersion = _currentGenesis.InterfaceSupportsFwVersion + }; + + return result; + } + catch (Exception ex) + { + // Return failure result on exception + return new ConnectResult + { + Success = false, + Slot = slotNo, + ErrorMessage = ex.Message + }; + } + } + + /// + /// Connects to a Genesis meter for the specified slot. + /// + /// Slot number. + /// Specifies whether offline passwords should be used. + /// + /// Connect operation result including PCB ID, firmware/configuration info, and register snapshots. + /// + /// + /// + /// var api = new GenesisAPI(); + /// var result = api.Connect(3, true); + /// + /// if (result.Success) + /// { + /// Console.WriteLine(result.PcbId); + /// Console.WriteLine(result.InterfaceVersion); + /// } + /// else + /// { + /// Console.WriteLine(result.ErrorMessage); + /// } + /// + /// + public ConnectResult ConnectAllMeters(int slotNo) + { + /*try { if (slotNo <= 0) throw new ArgumentOutOfRangeException(nameof(slotNo), "Slot number must be greater than zero."); @@ -453,10 +603,11 @@ namespace GenesisCordonelInterface.API _currentGenesis = new GenesisMeter(); _currentGenesis.UseOfflinePasswords = usePasswordSource == PasswordSource.OfflineFile; _currentGenesis.usePasswordSource = usePasswordSource; - _currentGenesis.SetupFromConfigFile(slotNo); + _currentGenesis.useConfigSource = useConfigSource; + _currentGenesis.SetupFromConfigFile(slotNo);//...MF + _currentGenesis.SetupFromExternConfig(slotNo); _meterBatch.AddMeter(_currentGenesis); - _meterBatch._externPasswords = externPasswords; _meterBatch.MetersLogin(); if (!_currentGenesis.IsLoggedOn && string.IsNullOrEmpty(_currentGenesis.PcbId)) @@ -519,7 +670,8 @@ namespace GenesisCordonelInterface.API Slot = slotNo, ErrorMessage = ex.Message }; - } + }*/ + return null; } #endregion diff --git a/GenesisCordonelTester/API/InterfaceOutsideToGCI.cs b/GenesisCordonelTester/API/InterfaceOutsideToGCI.cs index 24b1d6d3e..a1d948462 100644 --- a/GenesisCordonelTester/API/InterfaceOutsideToGCI.cs +++ b/GenesisCordonelTester/API/InterfaceOutsideToGCI.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore; +using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; +using static Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.GenesisMeter; namespace GenesisCordonelInterface.API { @@ -36,9 +39,31 @@ namespace GenesisCordonelInterface.API /// Slot number. /// Specifies whether offline passwords should be used. /// Connect operation result. - public InterfaceGCIToLaatzen.ConnectResult Connect(int slotNo, int usePasswordSource, List externPasswords) + public InterfaceGCIToLaatzen.InitResult InitOneMeterFromExtern(Int32 slotNo, ConfigSource useConfigSource, PasswordSource usePasswordSource, PortConfig? requestPort, PortConfig? streamingPort) { - return _innerMeterAPI.Connect(slotNo, usePasswordSource, externPasswords); + return _innerMeterAPI.InitOneMeterFromExtern(slotNo, useConfigSource, usePasswordSource, requestPort, streamingPort); + } + + /// + /// Connects to the meter on the specified slot. + /// + /// Slot number. + /// Specifies whether offline passwords should be used. + /// Connect operation result. + public InterfaceGCIToLaatzen.ConnectResult ConnectOneMeter(int slotNo) + { + return _innerMeterAPI.ConnectOneMeter(slotNo); + } + + /// + /// Connects to the meter on the specified slot. + /// + /// Slot number. + /// Specifies whether offline passwords should be used. + /// Connect operation result. + public InterfaceGCIToLaatzen.ConnectResult ConnectAllMeters(int slotNo) + { + return _innerMeterAPI.ConnectAllMeters(slotNo); } /// diff --git a/GenesisCordonelTester/Core/Secondary.cs b/GenesisCordonelTester/Core/Secondary.cs deleted file mode 100644 index 582637aa9..000000000 --- a/GenesisCordonelTester/Core/Secondary.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GenesisCordonelInterface.Core -{ - internal class Secondary - { - //inicialization - - //registers - - //... - } -} diff --git a/GenesisCordonelTester/GenesisCordonelInterface.csproj b/GenesisCordonelTester/GenesisCordonelInterface.csproj index d1fad80b9..772a7dc8b 100644 --- a/GenesisCordonelTester/GenesisCordonelInterface.csproj +++ b/GenesisCordonelTester/GenesisCordonelInterface.csproj @@ -60,29 +60,28 @@ - - + Form - + FrmConfigurations.cs - + Form - + FrmCordonelPreadjustmentUI.cs - + Form - + FrmRegisterStore.cs - + Form - + FrmSetup.cs @@ -93,12 +92,18 @@ - + UserControl - + PreAdjustmentControl.cs + + Form + + + FrmGCIAPI.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -109,7 +114,7 @@ Resources.resx True - + FrmSetup.cs @@ -119,9 +124,12 @@ PreserveNewest - + PreAdjustmentControl.cs + + FrmGCIAPI.cs + SettingsSingleFileGenerator @@ -136,7 +144,10 @@ - + + + + diff --git a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.Designer.cs b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.Designer.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.Designer.cs rename to GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.Designer.cs index 9cff2bfeb..bc764d41e 100644 --- a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.Designer.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.Designer.cs @@ -1,4 +1,4 @@ -namespace GenesisCordonelInterface.UI +namespace GenesisCordonelInterface.UI.LaatzenAPI_CordonelPreadjustmentUI { partial class FrmCordonelPreadjustmentUI { diff --git a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.cs b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.cs rename to GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.cs index 5b2fa9187..789fb9ae0 100644 --- a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/FrmCordonelPreadjustmentUI.cs @@ -14,7 +14,7 @@ using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; using Xylem.Common.Ui.CordonelPreadjustmentUi; using CordonelPreadjustmentUi; -namespace GenesisCordonelInterface.UI +namespace GenesisCordonelInterface.UI.LaatzenAPI_CordonelPreadjustmentUI { public partial class FrmCordonelPreadjustmentUI : Form { diff --git a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/PreAdjustmentControl.Designer.cs b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/PreAdjustmentControl.Designer.cs similarity index 100% rename from GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/PreAdjustmentControl.Designer.cs rename to GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/PreAdjustmentControl.Designer.cs diff --git a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/PreAdjustmentControl.cs b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/PreAdjustmentControl.cs similarity index 100% rename from GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/PreAdjustmentControl.cs rename to GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/PreAdjustmentControl.cs diff --git a/GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/PreAdjustmentControl.resx b/GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/PreAdjustmentControl.resx similarity index 100% rename from GenesisCordonelTester/UI/Laatzen_CordonelPreadjustmentUI/PreAdjustmentControl.resx rename to GenesisCordonelTester/UI/LaatzenAPI_CordonelPreadjustmentUI/PreAdjustmentControl.resx diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmConfigurations.Designer.cs b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmConfigurations.Designer.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmConfigurations.Designer.cs rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmConfigurations.Designer.cs index 9597c03de..1b8b109d0 100644 --- a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmConfigurations.Designer.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmConfigurations.Designer.cs @@ -1,4 +1,4 @@ -namespace Xylem.Common.Ui.GenesisToolBox +namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox { partial class FrmConfigurations { diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmConfigurations.cs b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmConfigurations.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmConfigurations.cs rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmConfigurations.cs index 66d95f4e9..69ec86caf 100644 --- a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmConfigurations.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmConfigurations.cs @@ -12,7 +12,7 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; using Xylem.Common.Utils.Logging; -namespace Xylem.Common.Ui.GenesisToolBox +namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox { public enum METROLOGYASST_PulseMode { diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmRegisterStore.Designer.cs b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmRegisterStore.Designer.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmRegisterStore.Designer.cs rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmRegisterStore.Designer.cs index 2f2ea61ac..f09b49201 100644 --- a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmRegisterStore.Designer.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmRegisterStore.Designer.cs @@ -1,4 +1,4 @@ -namespace GenesisCordonelInterface.UI +namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox { partial class FrmRegisterStore { diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmRegisterStore.cs b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmRegisterStore.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmRegisterStore.cs rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmRegisterStore.cs index 171d70005..76e855ce1 100644 --- a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmRegisterStore.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmRegisterStore.cs @@ -33,7 +33,7 @@ using static Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.GenesisMeter; using Access = Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Access; using Register = Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Register; -namespace GenesisCordonelInterface.UI +namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox { public partial class FrmRegisterStore : Form { @@ -492,7 +492,7 @@ namespace GenesisCordonelInterface.UI DisableAllButtons(); _dataTable.Rows.Clear(); - var result = await Task.Run(() => interfaceToLaatzen.Connect(slotNo, cbxUseOfflinePwds.Checked == true ? PasswordSource.OfflineFile: PasswordSource.RestApi, null)); + var result = await Task.Run(() => interfaceToLaatzen.ConnectOneMeter(slotNo)); if (result.Success) { diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.Designer.cs b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.Designer.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.Designer.cs rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.Designer.cs index fffc88daa..94e89959a 100644 --- a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.Designer.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.Designer.cs @@ -1,4 +1,4 @@ -namespace GenesisCordonelInterface.UI +namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox { partial class FrmSetup { diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.cs b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.cs similarity index 99% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.cs rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.cs index 615a3ff86..dee7c4502 100644 --- a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.cs +++ b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.cs @@ -21,7 +21,7 @@ using Xylem.Common.Utils.Logging; using NLog; using GenesisCordonelInterface.API; -namespace GenesisCordonelInterface.UI +namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox { /// /// Setup of GTB diff --git a/GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.resx b/GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.resx similarity index 100% rename from GenesisCordonelTester/UI/Laatzen_GenesisToolBox/FrmSetup.resx rename to GenesisCordonelTester/UI/LaatzenAPI_GenesisToolBox/FrmSetup.resx diff --git a/GenesisCordonelTester/UI/MainForm.Designer.cs b/GenesisCordonelTester/UI/MainForm.Designer.cs index a9b82dbd9..1185f1038 100644 --- a/GenesisCordonelTester/UI/MainForm.Designer.cs +++ b/GenesisCordonelTester/UI/MainForm.Designer.cs @@ -14,9 +14,6 @@ private System.Windows.Forms.Panel pnlLeftMenu; private System.Windows.Forms.Panel pnlMain; - private System.Windows.Forms.Button btnSetup; - private System.Windows.Forms.Button btnRegisterStore; - private System.Windows.Forms.Button btnPulseSetup; private System.Windows.Forms.RichTextBox rtbMainLog; private System.Windows.Forms.StatusStrip statusStrip1; @@ -42,18 +39,31 @@ this.miHelp = new System.Windows.Forms.ToolStripMenuItem(); this.miHelpAbout = new System.Windows.Forms.ToolStripMenuItem(); this.pnlLeftMenu = new System.Windows.Forms.Panel(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); this.preadjustmentButton = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); this.btnPulseSetup = new System.Windows.Forms.Button(); - this.btnRegisterStore = new System.Windows.Forms.Button(); this.btnSetup = new System.Windows.Forms.Button(); + this.btnRegisterStore = new System.Windows.Forms.Button(); + this.tabPage2 = new System.Windows.Forms.TabPage(); this.pnlMain = new System.Windows.Forms.Panel(); this.rtbMainLog = new System.Windows.Forms.RichTextBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.tslStatus = new System.Windows.Forms.ToolStripStatusLabel(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.button1 = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.pnlLeftMenu.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.tabPage2.SuspendLayout(); this.pnlMain.SuspendLayout(); this.statusStrip1.SuspendLayout(); + this.groupBox3.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -65,7 +75,7 @@ this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); - this.menuStrip1.Size = new System.Drawing.Size(1284, 24); + this.menuStrip1.Size = new System.Drawing.Size(1309, 24); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // @@ -117,19 +127,48 @@ // pnlLeftMenu // this.pnlLeftMenu.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pnlLeftMenu.Controls.Add(this.preadjustmentButton); - this.pnlLeftMenu.Controls.Add(this.btnPulseSetup); - this.pnlLeftMenu.Controls.Add(this.btnRegisterStore); - this.pnlLeftMenu.Controls.Add(this.btnSetup); + this.pnlLeftMenu.Controls.Add(this.tabControl1); this.pnlLeftMenu.Dock = System.Windows.Forms.DockStyle.Left; this.pnlLeftMenu.Location = new System.Drawing.Point(0, 24); this.pnlLeftMenu.Name = "pnlLeftMenu"; - this.pnlLeftMenu.Size = new System.Drawing.Size(180, 474); + this.pnlLeftMenu.Size = new System.Drawing.Size(190, 474); this.pnlLeftMenu.TabIndex = 1; // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Location = new System.Drawing.Point(3, 5); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(186, 464); + this.tabControl1.TabIndex = 4; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.groupBox2); + this.tabPage1.Controls.Add(this.groupBox1); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(178, 438); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Laatzen API"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.preadjustmentButton); + this.groupBox2.Location = new System.Drawing.Point(6, 190); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(166, 66); + this.groupBox2.TabIndex = 5; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "CordonelPreadjustmentUI"; + // // preadjustmentButton // - this.preadjustmentButton.Location = new System.Drawing.Point(13, 219); + this.preadjustmentButton.Location = new System.Drawing.Point(6, 19); this.preadjustmentButton.Name = "preadjustmentButton"; this.preadjustmentButton.Size = new System.Drawing.Size(153, 35); this.preadjustmentButton.TabIndex = 3; @@ -137,9 +176,21 @@ this.preadjustmentButton.UseVisualStyleBackColor = true; this.preadjustmentButton.Click += new System.EventHandler(this.preadjustmentButton_Click); // + // groupBox1 + // + this.groupBox1.Controls.Add(this.btnPulseSetup); + this.groupBox1.Controls.Add(this.btnSetup); + this.groupBox1.Controls.Add(this.btnRegisterStore); + this.groupBox1.Location = new System.Drawing.Point(6, 17); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(166, 153); + this.groupBox1.TabIndex = 4; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "GenesisToolBox"; + // // btnPulseSetup // - this.btnPulseSetup.Location = new System.Drawing.Point(13, 96); + this.btnPulseSetup.Location = new System.Drawing.Point(7, 101); this.btnPulseSetup.Name = "btnPulseSetup"; this.btnPulseSetup.Size = new System.Drawing.Size(153, 35); this.btnPulseSetup.TabIndex = 2; @@ -147,19 +198,9 @@ this.btnPulseSetup.UseVisualStyleBackColor = true; this.btnPulseSetup.Click += new System.EventHandler(this.btnPulseSetup_Click); // - // btnRegisterStore - // - this.btnRegisterStore.Location = new System.Drawing.Point(13, 51); - this.btnRegisterStore.Name = "btnRegisterStore"; - this.btnRegisterStore.Size = new System.Drawing.Size(153, 35); - this.btnRegisterStore.TabIndex = 1; - this.btnRegisterStore.Text = "Register Store"; - this.btnRegisterStore.UseVisualStyleBackColor = true; - this.btnRegisterStore.Click += new System.EventHandler(this.btnRegisterStore_Click); - // // btnSetup // - this.btnSetup.Location = new System.Drawing.Point(13, 6); + this.btnSetup.Location = new System.Drawing.Point(7, 19); this.btnSetup.Name = "btnSetup"; this.btnSetup.Size = new System.Drawing.Size(153, 35); this.btnSetup.TabIndex = 0; @@ -167,14 +208,35 @@ this.btnSetup.UseVisualStyleBackColor = true; this.btnSetup.Click += new System.EventHandler(this.btnSetup_Click); // + // btnRegisterStore + // + this.btnRegisterStore.Location = new System.Drawing.Point(7, 60); + this.btnRegisterStore.Name = "btnRegisterStore"; + this.btnRegisterStore.Size = new System.Drawing.Size(153, 35); + this.btnRegisterStore.TabIndex = 1; + this.btnRegisterStore.Text = "Register Store"; + this.btnRegisterStore.UseVisualStyleBackColor = true; + this.btnRegisterStore.Click += new System.EventHandler(this.btnRegisterStore_Click); + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.groupBox3); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(178, 438); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "GCI API"; + this.tabPage2.UseVisualStyleBackColor = true; + // // pnlMain // this.pnlMain.Controls.Add(this.rtbMainLog); this.pnlMain.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlMain.Location = new System.Drawing.Point(180, 24); + this.pnlMain.Location = new System.Drawing.Point(190, 24); this.pnlMain.Name = "pnlMain"; this.pnlMain.Padding = new System.Windows.Forms.Padding(9); - this.pnlMain.Size = new System.Drawing.Size(1104, 474); + this.pnlMain.Size = new System.Drawing.Size(1119, 474); this.pnlMain.TabIndex = 2; // // rtbMainLog @@ -184,7 +246,7 @@ this.rtbMainLog.Location = new System.Drawing.Point(9, 9); this.rtbMainLog.Name = "rtbMainLog"; this.rtbMainLog.ReadOnly = true; - this.rtbMainLog.Size = new System.Drawing.Size(1086, 456); + this.rtbMainLog.Size = new System.Drawing.Size(1101, 456); this.rtbMainLog.TabIndex = 0; this.rtbMainLog.Text = ""; // @@ -195,7 +257,7 @@ this.statusStrip1.Location = new System.Drawing.Point(0, 498); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0); - this.statusStrip1.Size = new System.Drawing.Size(1284, 22); + this.statusStrip1.Size = new System.Drawing.Size(1309, 22); this.statusStrip1.TabIndex = 3; this.statusStrip1.Text = "statusStrip1"; // @@ -205,11 +267,31 @@ this.tslStatus.Size = new System.Drawing.Size(39, 17); this.tslStatus.Text = "Ready"; // + // groupBox3 + // + this.groupBox3.Controls.Add(this.button1); + this.groupBox3.Location = new System.Drawing.Point(6, 15); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(166, 66); + this.groupBox3.TabIndex = 6; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "GenesisCordonelInterface"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(6, 19); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 35); + this.button1.TabIndex = 3; + this.button1.Text = "API"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1284, 520); + this.ClientSize = new System.Drawing.Size(1309, 520); this.Controls.Add(this.pnlMain); this.Controls.Add(this.pnlLeftMenu); this.Controls.Add(this.statusStrip1); @@ -222,13 +304,30 @@ this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.pnlLeftMenu.ResumeLayout(false); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.tabPage2.ResumeLayout(false); this.pnlMain.ResumeLayout(false); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + this.groupBox3.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.Button btnSetup; private System.Windows.Forms.Button preadjustmentButton; + private System.Windows.Forms.Button btnRegisterStore; + private System.Windows.Forms.Button btnPulseSetup; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.Button button1; } } \ No newline at end of file diff --git a/GenesisCordonelTester/UI/MainForm.cs b/GenesisCordonelTester/UI/MainForm.cs index 80eca80ee..a41100ee2 100644 --- a/GenesisCordonelTester/UI/MainForm.cs +++ b/GenesisCordonelTester/UI/MainForm.cs @@ -1,13 +1,15 @@ -using NLog; +using GenesisCordonelInterface.UI.LaatzenAPI_CordonelPreadjustmentUI; +using GenesisCordonelInterface.UI.StaraTuraAPI_GenesisCordonelInterface; +using NLog; using System; -using System.Windows.Forms; +using System.Collections.Generic; +using System.Drawing; using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; using Xylem.Common.Ui.GenesisToolBox; using Xylem.Common.Utils.Logging; -using System.Drawing; -using System.Text.RegularExpressions; -using System.Linq; -using System.Collections.Generic; namespace GenesisCordonelInterface.UI { @@ -267,7 +269,6 @@ namespace GenesisCordonelInterface.UI Logger.Trace("FORM: ---------------------------------"); Logger.Trace("FORM: Preadjustment open."); - using (FrmCordonelPreadjustmentUI frm = new FrmCordonelPreadjustmentUI()) { frm.ShowDialog(this); @@ -275,5 +276,18 @@ namespace GenesisCordonelInterface.UI Logger.Trace("FORM: Preadjustment closed."); } + + private void button1_Click(object sender, EventArgs e) + { + Logger.Trace("FORM: ---------------------------------"); + Logger.Trace("FORM: GCI GUI interface open."); + + using (FrmGCIAPI frm = new FrmGCIAPI()) + { + frm.ShowDialog(this); + } + + Logger.Trace("FORM: GCI GUI interface closed."); + } } } \ No newline at end of file diff --git a/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.Designer.cs b/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.Designer.cs new file mode 100644 index 000000000..781298ad1 --- /dev/null +++ b/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.Designer.cs @@ -0,0 +1,383 @@ +namespace GenesisCordonelInterface.UI.StaraTuraAPI_GenesisCordonelInterface +{ + partial class FrmGCIAPI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support. + /// + private void InitializeComponent() + { + this.lblSlot = new System.Windows.Forms.Label(); + this.txtSlot = new System.Windows.Forms.TextBox(); + this.lblConfigSource = new System.Windows.Forms.Label(); + this.cmbConfigSource = new System.Windows.Forms.ComboBox(); + this.lblPasswordSource = new System.Windows.Forms.Label(); + this.cmbPasswordSource = new System.Windows.Forms.ComboBox(); + this.lblRequestPort = new System.Windows.Forms.Label(); + this.txtRequestPort = new System.Windows.Forms.TextBox(); + this.lblRequestBaudRate = new System.Windows.Forms.Label(); + this.txtRequestBaudRate = new System.Windows.Forms.TextBox(); + this.lblStreamingPort = new System.Windows.Forms.Label(); + this.txtStreamingPort = new System.Windows.Forms.TextBox(); + this.lblStreamingBaudRate = new System.Windows.Forms.Label(); + this.txtStreamingBaudRate = new System.Windows.Forms.TextBox(); + this.lblRegister = new System.Windows.Forms.Label(); + this.txtRegister = new System.Windows.Forms.TextBox(); + this.lblValue = new System.Windows.Forms.Label(); + this.txtValue = new System.Windows.Forms.TextBox(); + this.lblPassword = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.btnInit = new System.Windows.Forms.Button(); + this.btnConnectOne = new System.Windows.Forms.Button(); + this.btnConnectAll = new System.Windows.Forms.Button(); + this.btnDisconnect = new System.Windows.Forms.Button(); + this.btnGetPcbId = new System.Windows.Forms.Button(); + this.btnReadRegister = new System.Windows.Forms.Button(); + this.btnWriteRegister = new System.Windows.Forms.Button(); + this.btnSetPassword = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // lblSlot + // + this.lblSlot.AutoSize = true; + this.lblSlot.Location = new System.Drawing.Point(20, 20); + this.lblSlot.Name = "lblSlot"; + this.lblSlot.Size = new System.Drawing.Size(28, 13); + this.lblSlot.TabIndex = 0; + this.lblSlot.Text = "Slot:"; + // + // txtSlot + // + this.txtSlot.Location = new System.Drawing.Point(150, 17); + this.txtSlot.Name = "txtSlot"; + this.txtSlot.Size = new System.Drawing.Size(120, 20); + this.txtSlot.TabIndex = 1; + this.txtSlot.Text = "1"; + // + // lblConfigSource + // + this.lblConfigSource.AutoSize = true; + this.lblConfigSource.Location = new System.Drawing.Point(20, 55); + this.lblConfigSource.Name = "lblConfigSource"; + this.lblConfigSource.Size = new System.Drawing.Size(75, 13); + this.lblConfigSource.TabIndex = 2; + this.lblConfigSource.Text = "ConfigSource:"; + // + // cmbConfigSource + // + this.cmbConfigSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbConfigSource.FormattingEnabled = true; + this.cmbConfigSource.Location = new System.Drawing.Point(150, 52); + this.cmbConfigSource.Name = "cmbConfigSource"; + this.cmbConfigSource.Size = new System.Drawing.Size(180, 21); + this.cmbConfigSource.TabIndex = 3; + // + // lblPasswordSource + // + this.lblPasswordSource.AutoSize = true; + this.lblPasswordSource.Location = new System.Drawing.Point(20, 90); + this.lblPasswordSource.Name = "lblPasswordSource"; + this.lblPasswordSource.Size = new System.Drawing.Size(88, 13); + this.lblPasswordSource.TabIndex = 4; + this.lblPasswordSource.Text = "PasswordSource:"; + // + // cmbPasswordSource + // + this.cmbPasswordSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbPasswordSource.FormattingEnabled = true; + this.cmbPasswordSource.Location = new System.Drawing.Point(150, 87); + this.cmbPasswordSource.Name = "cmbPasswordSource"; + this.cmbPasswordSource.Size = new System.Drawing.Size(180, 21); + this.cmbPasswordSource.TabIndex = 5; + // + // lblRequestPort + // + this.lblRequestPort.AutoSize = true; + this.lblRequestPort.Location = new System.Drawing.Point(20, 125); + this.lblRequestPort.Name = "lblRequestPort"; + this.lblRequestPort.Size = new System.Drawing.Size(67, 13); + this.lblRequestPort.TabIndex = 6; + this.lblRequestPort.Text = "RequestPort:"; + // + // txtRequestPort + // + this.txtRequestPort.Location = new System.Drawing.Point(150, 122); + this.txtRequestPort.Name = "txtRequestPort"; + this.txtRequestPort.Size = new System.Drawing.Size(180, 20); + this.txtRequestPort.TabIndex = 7; + this.txtRequestPort.Text = "COM1"; + // + // lblRequestBaudRate + // + this.lblRequestBaudRate.AutoSize = true; + this.lblRequestBaudRate.Location = new System.Drawing.Point(360, 125); + this.lblRequestBaudRate.Name = "lblRequestBaudRate"; + this.lblRequestBaudRate.Size = new System.Drawing.Size(94, 13); + this.lblRequestBaudRate.TabIndex = 8; + this.lblRequestBaudRate.Text = "RequestBaudRate:"; + // + // txtRequestBaudRate + // + this.txtRequestBaudRate.Location = new System.Drawing.Point(480, 122); + this.txtRequestBaudRate.Name = "txtRequestBaudRate"; + this.txtRequestBaudRate.Size = new System.Drawing.Size(120, 20); + this.txtRequestBaudRate.TabIndex = 9; + this.txtRequestBaudRate.Text = "115200"; + // + // lblStreamingPort + // + this.lblStreamingPort.AutoSize = true; + this.lblStreamingPort.Location = new System.Drawing.Point(20, 160); + this.lblStreamingPort.Name = "lblStreamingPort"; + this.lblStreamingPort.Size = new System.Drawing.Size(74, 13); + this.lblStreamingPort.TabIndex = 10; + this.lblStreamingPort.Text = "StreamingPort:"; + // + // txtStreamingPort + // + this.txtStreamingPort.Location = new System.Drawing.Point(150, 157); + this.txtStreamingPort.Name = "txtStreamingPort"; + this.txtStreamingPort.Size = new System.Drawing.Size(180, 20); + this.txtStreamingPort.TabIndex = 11; + this.txtStreamingPort.Text = "COM2"; + // + // lblStreamingBaudRate + // + this.lblStreamingBaudRate.AutoSize = true; + this.lblStreamingBaudRate.Location = new System.Drawing.Point(360, 160); + this.lblStreamingBaudRate.Name = "lblStreamingBaudRate"; + this.lblStreamingBaudRate.Size = new System.Drawing.Size(101, 13); + this.lblStreamingBaudRate.TabIndex = 12; + this.lblStreamingBaudRate.Text = "StreamingBaudRate:"; + // + // txtStreamingBaudRate + // + this.txtStreamingBaudRate.Location = new System.Drawing.Point(480, 157); + this.txtStreamingBaudRate.Name = "txtStreamingBaudRate"; + this.txtStreamingBaudRate.Size = new System.Drawing.Size(120, 20); + this.txtStreamingBaudRate.TabIndex = 13; + this.txtStreamingBaudRate.Text = "115200"; + // + // lblRegister + // + this.lblRegister.AutoSize = true; + this.lblRegister.Location = new System.Drawing.Point(20, 195); + this.lblRegister.Name = "lblRegister"; + this.lblRegister.Size = new System.Drawing.Size(49, 13); + this.lblRegister.TabIndex = 14; + this.lblRegister.Text = "Register:"; + // + // txtRegister + // + this.txtRegister.Location = new System.Drawing.Point(150, 192); + this.txtRegister.Name = "txtRegister"; + this.txtRegister.Size = new System.Drawing.Size(450, 20); + this.txtRegister.TabIndex = 15; + this.txtRegister.Text = "GENESISFLOW_TriggerTest"; + // + // lblValue + // + this.lblValue.AutoSize = true; + this.lblValue.Location = new System.Drawing.Point(20, 230); + this.lblValue.Name = "lblValue"; + this.lblValue.Size = new System.Drawing.Size(37, 13); + this.lblValue.TabIndex = 16; + this.lblValue.Text = "Value:"; + // + // txtValue + // + this.txtValue.Location = new System.Drawing.Point(150, 227); + this.txtValue.Name = "txtValue"; + this.txtValue.Size = new System.Drawing.Size(450, 20); + this.txtValue.TabIndex = 17; + this.txtValue.Text = "1"; + // + // lblPassword + // + this.lblPassword.AutoSize = true; + this.lblPassword.Location = new System.Drawing.Point(20, 265); + this.lblPassword.Name = "lblPassword"; + this.lblPassword.Size = new System.Drawing.Size(56, 13); + this.lblPassword.TabIndex = 18; + this.lblPassword.Text = "Password:"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(150, 262); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.Size = new System.Drawing.Size(450, 20); + this.txtPassword.TabIndex = 19; + this.txtPassword.Text = "1234"; + // + // btnInit + // + this.btnInit.Location = new System.Drawing.Point(23, 310); + this.btnInit.Name = "btnInit"; + this.btnInit.Size = new System.Drawing.Size(180, 32); + this.btnInit.TabIndex = 20; + this.btnInit.Text = "Init One Meter From Extern"; + this.btnInit.UseVisualStyleBackColor = true; + this.btnInit.Click += new System.EventHandler(this.btnInit_Click); + // + // btnConnectOne + // + this.btnConnectOne.Location = new System.Drawing.Point(220, 310); + this.btnConnectOne.Name = "btnConnectOne"; + this.btnConnectOne.Size = new System.Drawing.Size(180, 32); + this.btnConnectOne.TabIndex = 21; + this.btnConnectOne.Text = "Connect One Meter"; + this.btnConnectOne.UseVisualStyleBackColor = true; + this.btnConnectOne.Click += new System.EventHandler(this.btnConnectOne_Click); + // + // btnConnectAll + // + this.btnConnectAll.Location = new System.Drawing.Point(417, 310); + this.btnConnectAll.Name = "btnConnectAll"; + this.btnConnectAll.Size = new System.Drawing.Size(180, 32); + this.btnConnectAll.TabIndex = 22; + this.btnConnectAll.Text = "Connect All Meters"; + this.btnConnectAll.UseVisualStyleBackColor = true; + this.btnConnectAll.Click += new System.EventHandler(this.btnConnectAll_Click); + // + // btnDisconnect + // + this.btnDisconnect.Location = new System.Drawing.Point(23, 355); + this.btnDisconnect.Name = "btnDisconnect"; + this.btnDisconnect.Size = new System.Drawing.Size(180, 32); + this.btnDisconnect.TabIndex = 23; + this.btnDisconnect.Text = "Disconnect"; + this.btnDisconnect.UseVisualStyleBackColor = true; + this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click); + // + // btnGetPcbId + // + this.btnGetPcbId.Location = new System.Drawing.Point(220, 355); + this.btnGetPcbId.Name = "btnGetPcbId"; + this.btnGetPcbId.Size = new System.Drawing.Size(180, 32); + this.btnGetPcbId.TabIndex = 24; + this.btnGetPcbId.Text = "Get PCB ID"; + this.btnGetPcbId.UseVisualStyleBackColor = true; + this.btnGetPcbId.Click += new System.EventHandler(this.btnGetPcbId_Click); + // + // btnReadRegister + // + this.btnReadRegister.Location = new System.Drawing.Point(417, 355); + this.btnReadRegister.Name = "btnReadRegister"; + this.btnReadRegister.Size = new System.Drawing.Size(180, 32); + this.btnReadRegister.TabIndex = 25; + this.btnReadRegister.Text = "Read Register"; + this.btnReadRegister.UseVisualStyleBackColor = true; + this.btnReadRegister.Click += new System.EventHandler(this.btnReadRegister_Click); + // + // btnWriteRegister + // + this.btnWriteRegister.Location = new System.Drawing.Point(23, 400); + this.btnWriteRegister.Name = "btnWriteRegister"; + this.btnWriteRegister.Size = new System.Drawing.Size(180, 32); + this.btnWriteRegister.TabIndex = 26; + this.btnWriteRegister.Text = "Write Register"; + this.btnWriteRegister.UseVisualStyleBackColor = true; + this.btnWriteRegister.Click += new System.EventHandler(this.btnWriteRegister_Click); + // + // btnSetPassword + // + this.btnSetPassword.Location = new System.Drawing.Point(220, 400); + this.btnSetPassword.Name = "btnSetPassword"; + this.btnSetPassword.Size = new System.Drawing.Size(180, 32); + this.btnSetPassword.TabIndex = 27; + this.btnSetPassword.Text = "Set Meter Password"; + this.btnSetPassword.UseVisualStyleBackColor = true; + this.btnSetPassword.Click += new System.EventHandler(this.btnSetPassword_Click); + // + // FrmGCIAPI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(624, 455); + this.Controls.Add(this.btnSetPassword); + this.Controls.Add(this.btnWriteRegister); + this.Controls.Add(this.btnReadRegister); + this.Controls.Add(this.btnGetPcbId); + this.Controls.Add(this.btnDisconnect); + this.Controls.Add(this.btnConnectAll); + this.Controls.Add(this.btnConnectOne); + this.Controls.Add(this.btnInit); + this.Controls.Add(this.txtPassword); + this.Controls.Add(this.lblPassword); + this.Controls.Add(this.txtValue); + this.Controls.Add(this.lblValue); + this.Controls.Add(this.txtRegister); + this.Controls.Add(this.lblRegister); + this.Controls.Add(this.txtStreamingBaudRate); + this.Controls.Add(this.lblStreamingBaudRate); + this.Controls.Add(this.txtStreamingPort); + this.Controls.Add(this.lblStreamingPort); + this.Controls.Add(this.txtRequestBaudRate); + this.Controls.Add(this.lblRequestBaudRate); + this.Controls.Add(this.txtRequestPort); + this.Controls.Add(this.lblRequestPort); + this.Controls.Add(this.cmbPasswordSource); + this.Controls.Add(this.lblPasswordSource); + this.Controls.Add(this.cmbConfigSource); + this.Controls.Add(this.lblConfigSource); + this.Controls.Add(this.txtSlot); + this.Controls.Add(this.lblSlot); + this.Name = "FrmGCIAPI"; + this.Text = "GCI API Test Panel"; + this.ResumeLayout(false); + this.PerformLayout(); + } + + #endregion + + private System.Windows.Forms.Label lblSlot; + private System.Windows.Forms.TextBox txtSlot; + private System.Windows.Forms.Label lblConfigSource; + private System.Windows.Forms.ComboBox cmbConfigSource; + private System.Windows.Forms.Label lblPasswordSource; + private System.Windows.Forms.ComboBox cmbPasswordSource; + private System.Windows.Forms.Label lblRequestPort; + private System.Windows.Forms.TextBox txtRequestPort; + private System.Windows.Forms.Label lblRequestBaudRate; + private System.Windows.Forms.TextBox txtRequestBaudRate; + private System.Windows.Forms.Label lblStreamingPort; + private System.Windows.Forms.TextBox txtStreamingPort; + private System.Windows.Forms.Label lblStreamingBaudRate; + private System.Windows.Forms.TextBox txtStreamingBaudRate; + private System.Windows.Forms.Label lblRegister; + private System.Windows.Forms.TextBox txtRegister; + private System.Windows.Forms.Label lblValue; + private System.Windows.Forms.TextBox txtValue; + private System.Windows.Forms.Label lblPassword; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.Button btnInit; + private System.Windows.Forms.Button btnConnectOne; + private System.Windows.Forms.Button btnConnectAll; + private System.Windows.Forms.Button btnDisconnect; + private System.Windows.Forms.Button btnGetPcbId; + private System.Windows.Forms.Button btnReadRegister; + private System.Windows.Forms.Button btnWriteRegister; + private System.Windows.Forms.Button btnSetPassword; + } +} \ No newline at end of file diff --git a/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.cs b/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.cs new file mode 100644 index 000000000..5ba4b7042 --- /dev/null +++ b/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.cs @@ -0,0 +1,193 @@ +using System; +using System.Windows.Forms; +using GenesisCordonelInterface.API; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore; +using static Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.GenesisMeter; + +namespace GenesisCordonelInterface.UI.StaraTuraAPI_GenesisCordonelInterface +{ + public partial class FrmGCIAPI : Form + { + private readonly InterfaceOutsideToGCI _api = new InterfaceOutsideToGCI(); + + public FrmGCIAPI() + { + InitializeComponent(); + InitializeDefaults(); + } + + private void InitializeDefaults() + { + cmbConfigSource.DataSource = Enum.GetValues(typeof(ConfigSource)); + cmbPasswordSource.DataSource = Enum.GetValues(typeof(PasswordSource)); + + cmbConfigSource.SelectedItem = ConfigSource.ExternStorage; + cmbPasswordSource.SelectedItem = PasswordSource.OfflineFile; + } + + private void ExecuteApiAction(Action action) + { + try + { + action(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "API call failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private int GetSlot() + { + if (!int.TryParse(txtSlot.Text, out int slot)) + throw new Exception("Invalid slot number."); + + return slot; + } + + private object ParseValue(string input) + { + if (int.TryParse(input, out int intValue)) + return intValue; + + if (uint.TryParse(input, out uint uintValue)) + return uintValue; + + if (bool.TryParse(input, out bool boolValue)) + return boolValue; + + return input; + } + + private PortConfig? CreatePortConfig(string portName, string baudRateText) + { + if (string.IsNullOrWhiteSpace(portName)) + return null; + + if (!int.TryParse(baudRateText, out int baudRate)) + throw new Exception($"Invalid baud rate for port {portName}."); + + var cfg = new PortConfig + { + PortName = portName, + Type = "Serial" + }; + + var sp = cfg.GetSerialPort(); + if (sp == null) + throw new Exception($"Serial port object was not created for {portName}."); + + sp.BaudRate = baudRate; + + return cfg; + } + + private ConfigSource GetConfigSource() + { + if (cmbConfigSource.SelectedItem == null) + throw new Exception("ConfigSource is not selected."); + + return (ConfigSource)cmbConfigSource.SelectedItem; + } + + private PasswordSource GetPasswordSource() + { + if (cmbPasswordSource.SelectedItem == null) + throw new Exception("PasswordSource is not selected."); + + return (PasswordSource)cmbPasswordSource.SelectedItem; + } + + private void btnInit_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + int slot = GetSlot(); + + var requestPort = CreatePortConfig(txtRequestPort.Text, txtRequestBaudRate.Text); + var streamingPort = CreatePortConfig(txtStreamingPort.Text, txtStreamingBaudRate.Text); + + _api.InitOneMeterFromExtern( + slot, + GetConfigSource(), + GetPasswordSource(), + requestPort, + streamingPort); + }); + } + + private void btnConnectOne_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + _api.ConnectOneMeter(GetSlot()); + }); + } + + private void btnConnectAll_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + _api.ConnectAllMeters(GetSlot()); + }); + } + + private void btnDisconnect_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + _api.Disconnect(); + }); + } + + private void btnGetPcbId_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + _api.GetPcbId(GetSlot()); + }); + } + + private void btnReadRegister_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + string registerName = txtRegister.Text; + + if (string.IsNullOrWhiteSpace(registerName)) + throw new Exception("Register name is empty."); + + _api.ReadRegister(registerName); + }); + } + + private void btnWriteRegister_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + string registerName = txtRegister.Text; + string valueText = txtValue.Text; + + if (string.IsNullOrWhiteSpace(registerName)) + throw new Exception("Register name is empty."); + + object value = ParseValue(valueText); + + _api.WriteRegister(registerName, value, false, false); + }); + } + + private void btnSetPassword_Click(object sender, EventArgs e) + { + ExecuteApiAction(() => + { + string password = txtPassword.Text; + + if (string.IsNullOrWhiteSpace(password)) + throw new Exception("Password is empty."); + + _api.SetMeterPassword(password); + }); + } + } +} \ No newline at end of file diff --git a/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.resx b/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/GenesisCordonelTester/UI/StaraTuraAPI_GenesisCordonelInterface/FrmGCIAPI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GenesisCordonelTester/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/GenesisCordonelTester/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 8116acfb1..05d300bd0 100644 Binary files a/GenesisCordonelTester/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/GenesisCordonelTester/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/TBF/Rig/BridgeComponents/GciBridge/Factory.cs b/TBF/Rig/BridgeComponents/GciBridge/Factory.cs new file mode 100644 index 000000000..b827c68ad --- /dev/null +++ b/TBF/Rig/BridgeComponents/GciBridge/Factory.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using TBF.Rig.Generic; + +namespace TBF.Rig.BridgeComponents.GciBridge +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return GetType().Namespace.Substring(12); } } + + public override string ToString() + { + return ClassName; + } + + public IComponent DummyComponent() + { + return new GciBridge(); + } + + public IComponent GetComponent(IComponentCfg cfg, IList components) + { + return new GciBridge(cfg, components); + } + + public IComponentCfg DefaultConfig() + { + return new GciBridgeCfg("GCI", this); + } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(GciBridgeCfg.Serializer, component, this); + } + } +} \ No newline at end of file diff --git a/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs b/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs new file mode 100644 index 000000000..3e5635ebf --- /dev/null +++ b/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs @@ -0,0 +1,208 @@ +/// +/// Copyright (c) 2015-2021 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using TBF.Rig.Generic; +using UdsReaderType = TBF.Rig.Input.DataStorage.UniDataStorageReader.UniDataStorageReader; +using UdsWriterType = TBF.Rig.Output.DataStorage.UniDataStorageWriter.UniDataStorageWriter; + +namespace TBF.Rig.BridgeComponents.GciBridge +{ + /// + /// TBF bridge component for integration with the sibling GCI project. + /// The component can be linked to UniDataStorage reader and writer components. + /// + public class GciBridge : ComponentBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(GciBridge)); + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); } + + readonly GciBridgeCfg gciBridgeCfg; + + /// + /// Linked UniDataStorage reader component. + /// + readonly UdsReaderType reader; + + /// + /// Linked UniDataStorage writer component. + /// + readonly UdsWriterType writer; + + /// + /// Placeholder for GCI GUI entry point. + /// Replace object with real GCI MainForm type later. + /// + object gciMainForm; + + /// + /// Placeholder for GCI external/public interface. + /// Replace object with real GCI interface type later. + /// + object gciExternalInterface; + + public bool HasReader { get { return reader != null; } } + public bool HasWriter { get { return writer != null; } } + public bool IsGuiInitialized { get { return gciMainForm != null; } } + public bool IsExternalInitialized { get { return gciExternalInterface != null; } } + + public GciBridge() { } + + public GciBridge(IComponentCfg cfg, IList components) + : base(cfg) + { + gciBridgeCfg = cfg as GciBridgeCfg; + if (gciBridgeCfg == null) throw new Exception("Invalid GciBridgeCfg."); + + if (!string.IsNullOrEmpty(gciBridgeCfg.ReaderName)) + { + reader = TbfComponents.FindComponent(gciBridgeCfg.ReaderName, components) as UdsReaderType; + if (reader == null) throw new Exception("Cannot find reader component '" + gciBridgeCfg.ReaderName + "'"); + } + + if (!string.IsNullOrEmpty(gciBridgeCfg.WriterName)) + { + writer = TbfComponents.FindComponent(gciBridgeCfg.WriterName, components) as UdsWriterType; + if (writer == null) throw new Exception("Cannot find writer component '" + gciBridgeCfg.WriterName + "'"); + } + } + + public override void Initialize() + { + if (gciBridgeCfg.EnableExternalAccess) + { + TryInitializeExternalInterface(); + } + + if (gciBridgeCfg.EnableGuiAccess) + { + TryInitializeGui(); + + if (gciBridgeCfg.ShowGuiOnInitialize) + { + ShowGui(); + } + } + + log.FatalFormat("{0} initialized: {1}", Name, this); + } + + /// + /// Initializes access to GCI GUI. + /// Replace placeholder implementation with real MainForm creation. + /// + void TryInitializeGui() + { + try + { + /// TODO: + /// Replace with real GCI MainForm initialization. + gciMainForm = new object(); + + log.InfoFormat("{0}: GCI GUI initialized.", Name); + } + catch (Exception ex) + { + log.Error("Failed to initialize GCI GUI.", ex); + } + } + + /// + /// Initializes access to GCI external/public interface. + /// Replace placeholder implementation with real interface creation. + /// + void TryInitializeExternalInterface() + { + try + { + /// TODO: + /// Replace with real GCI external interface initialization. + gciExternalInterface = new object(); + + log.InfoFormat("{0}: GCI external interface initialized.", Name); + } + catch (Exception ex) + { + log.Error("Failed to initialize GCI external interface.", ex); + } + } + + /// + /// Shows GCI GUI if GUI access is enabled. + /// + public void ShowGui() + { + if (!gciBridgeCfg.EnableGuiAccess) return; + + if (!IsGuiInitialized) + { + TryInitializeGui(); + } + + /// TODO: + /// Replace with real MainForm.Show() call. + log.InfoFormat("{0}: ShowGui invoked.", Name); + } + + /// + /// Hides GCI GUI if GUI access is enabled. + /// + public void HideGui() + { + if (!gciBridgeCfg.EnableGuiAccess) return; + if (!IsGuiInitialized) return; + + /// TODO: + /// Replace with real MainForm.Hide() call. + log.InfoFormat("{0}: HideGui invoked.", Name); + } + + /// + /// Connects the external GCI interface. + /// + public void ConnectExternal() + { + if (!gciBridgeCfg.EnableExternalAccess) return; + + if (!IsExternalInitialized) + { + TryInitializeExternalInterface(); + } + + /// TODO: + /// Replace with real external interface connect call. + log.InfoFormat("{0}: ConnectExternal invoked.", Name); + } + + /// + /// Disconnects the external GCI interface. + /// + public void DisconnectExternal() + { + if (!gciBridgeCfg.EnableExternalAccess) return; + if (!IsExternalInitialized) return; + + /// TODO: + /// Replace with real external interface disconnect call. + log.InfoFormat("{0}: DisconnectExternal invoked.", Name); + } + + /// + /// Returns linked reader component. + /// + public UdsReaderType GetReader() + { + return reader; + } + + /// + /// Returns linked writer component. + /// + public UdsWriterType GetWriter() + { + return writer; + } + } +} \ No newline at end of file diff --git a/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfg.cs b/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfg.cs new file mode 100644 index 000000000..fce514b5a --- /dev/null +++ b/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfg.cs @@ -0,0 +1,88 @@ +/// +/// Copyright (c) 2015-2021 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using System.Xml.Serialization; +using Config.Entities; +using TBF.Rig.Generic; + +namespace TBF.Rig.BridgeComponents.GciBridge +{ + /// + /// Configuration of GCI bridge component. + /// + public class GciBridgeCfg : ComponentCfgBase, IChildComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(GciBridgeCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + /// + /// Linked UniDataStorage reader component name. + /// + public string ReaderName; + + /// + /// Linked UniDataStorage writer component name. + /// + public string WriterName; + + /// + /// Enables access to GCI GUI layer. + /// + public bool EnableGuiAccess; + + /// + /// Enables access to GCI external/public interface. + /// + public bool EnableExternalAccess; + + /// + /// If true, GUI should be shown automatically after initialization. + /// + public bool ShowGuiOnInitialize; + + /// + /// Optional external interface type name or description. + /// + public string ExternalInterfaceTypeName; + + /// + /// Private parameterless constructor used by serializer. + /// + GciBridgeCfg() + { + } + + public GciBridgeCfg(string name, IComponentFactory factory) + { + Name = name; + Factory = factory; + ParentName = string.Empty; + + ReaderName = string.Empty; + WriterName = string.Empty; + EnableGuiAccess = true; + EnableExternalAccess = true; + ShowGuiOnInitialize = false; + ExternalInterfaceTypeName = string.Empty; + } + + public IComponentCfgCtrl GetControl(IList cmpntEntities) + { + return new GciBridgeCfgCtrl(); + } + + public string ToString(int i) + { + return string.Format( + "Name={0}, Reader={1}, Writer={2}, GuiAccess={3}, ExternalAccess={4}, ShowGuiOnInit={5}, ExternalType={6}", + Name, + string.IsNullOrEmpty(ReaderName) ? "-" : ReaderName, + string.IsNullOrEmpty(WriterName) ? "-" : WriterName, + EnableGuiAccess, + EnableExternalAccess, + ShowGuiOnInitialize, + string.IsNullOrEmpty(ExternalInterfaceTypeName) ? "-" : ExternalInterfaceTypeName); + } + } +} \ No newline at end of file diff --git a/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfgCtrl.Designer.cs b/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfgCtrl.Designer.cs new file mode 100644 index 000000000..db8c26c11 --- /dev/null +++ b/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfgCtrl.Designer.cs @@ -0,0 +1,236 @@ +namespace TBF.Rig.BridgeComponents.GciBridge +{ + partial class GciBridgeCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support. + /// + private void InitializeComponent() + { + this.classNameLabel = new System.Windows.Forms.Label(); + this.nameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.readerNameLabel = new System.Windows.Forms.Label(); + this.readerNameComboBox = new System.Windows.Forms.ComboBox(); + this.writerNameLabel = new System.Windows.Forms.Label(); + this.writerNameComboBox = new System.Windows.Forms.ComboBox(); + this.enableGuiCheckBox = new System.Windows.Forms.CheckBox(); + this.enableExternalCheckBox = new System.Windows.Forms.CheckBox(); + this.showGuiOnInitializeCheckBox = new System.Windows.Forms.CheckBox(); + this.externalTypeNameLabel = new System.Windows.Forms.Label(); + this.externalTypeNameTextBox = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.connectExternalButton = new System.Windows.Forms.Button(); + this.showGuiButton = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(136, 15); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(89, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComponentName"; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(28, 43); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(139, 40); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 2; + // + // readerNameLabel + // + this.readerNameLabel.AutoSize = true; + this.readerNameLabel.Location = new System.Drawing.Point(28, 70); + this.readerNameLabel.Name = "readerNameLabel"; + this.readerNameLabel.Size = new System.Drawing.Size(70, 13); + this.readerNameLabel.TabIndex = 3; + this.readerNameLabel.Text = "Reader Name"; + // + // readerNameComboBox + // + this.readerNameComboBox.Enabled = false; + this.readerNameComboBox.FormattingEnabled = true; + this.readerNameComboBox.Location = new System.Drawing.Point(139, 67); + this.readerNameComboBox.Name = "readerNameComboBox"; + this.readerNameComboBox.Size = new System.Drawing.Size(130, 21); + this.readerNameComboBox.TabIndex = 4; + // + // writerNameLabel + // + this.writerNameLabel.AutoSize = true; + this.writerNameLabel.Location = new System.Drawing.Point(28, 97); + this.writerNameLabel.Name = "writerNameLabel"; + this.writerNameLabel.Size = new System.Drawing.Size(67, 13); + this.writerNameLabel.TabIndex = 5; + this.writerNameLabel.Text = "Writer Name"; + // + // writerNameComboBox + // + this.writerNameComboBox.Enabled = false; + this.writerNameComboBox.FormattingEnabled = true; + this.writerNameComboBox.Location = new System.Drawing.Point(139, 94); + this.writerNameComboBox.Name = "writerNameComboBox"; + this.writerNameComboBox.Size = new System.Drawing.Size(130, 21); + this.writerNameComboBox.TabIndex = 6; + // + // enableGuiCheckBox + // + this.enableGuiCheckBox.AutoSize = true; + this.enableGuiCheckBox.Enabled = false; + this.enableGuiCheckBox.Location = new System.Drawing.Point(31, 129); + this.enableGuiCheckBox.Name = "enableGuiCheckBox"; + this.enableGuiCheckBox.Size = new System.Drawing.Size(114, 17); + this.enableGuiCheckBox.TabIndex = 7; + this.enableGuiCheckBox.Text = "Enable GUI access"; + this.enableGuiCheckBox.UseVisualStyleBackColor = true; + // + // enableExternalCheckBox + // + this.enableExternalCheckBox.AutoSize = true; + this.enableExternalCheckBox.Enabled = false; + this.enableExternalCheckBox.Location = new System.Drawing.Point(31, 152); + this.enableExternalCheckBox.Name = "enableExternalCheckBox"; + this.enableExternalCheckBox.Size = new System.Drawing.Size(134, 17); + this.enableExternalCheckBox.TabIndex = 8; + this.enableExternalCheckBox.Text = "Enable external access"; + this.enableExternalCheckBox.UseVisualStyleBackColor = true; + // + // showGuiOnInitializeCheckBox + // + this.showGuiOnInitializeCheckBox.AutoSize = true; + this.showGuiOnInitializeCheckBox.Enabled = false; + this.showGuiOnInitializeCheckBox.Location = new System.Drawing.Point(31, 175); + this.showGuiOnInitializeCheckBox.Name = "showGuiOnInitializeCheckBox"; + this.showGuiOnInitializeCheckBox.Size = new System.Drawing.Size(132, 17); + this.showGuiOnInitializeCheckBox.TabIndex = 9; + this.showGuiOnInitializeCheckBox.Text = "Show GUI on initialize"; + this.showGuiOnInitializeCheckBox.UseVisualStyleBackColor = true; + // + // externalTypeNameLabel + // + this.externalTypeNameLabel.AutoSize = true; + this.externalTypeNameLabel.Location = new System.Drawing.Point(28, 205); + this.externalTypeNameLabel.Name = "externalTypeNameLabel"; + this.externalTypeNameLabel.Size = new System.Drawing.Size(103, 13); + this.externalTypeNameLabel.TabIndex = 10; + this.externalTypeNameLabel.Text = "External type / name"; + // + // externalTypeNameTextBox + // + this.externalTypeNameTextBox.Enabled = false; + this.externalTypeNameTextBox.Location = new System.Drawing.Point(139, 202); + this.externalTypeNameTextBox.Name = "externalTypeNameTextBox"; + this.externalTypeNameTextBox.Size = new System.Drawing.Size(130, 20); + this.externalTypeNameTextBox.TabIndex = 11; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.connectExternalButton); + this.groupBox1.Controls.Add(this.showGuiButton); + this.groupBox1.Location = new System.Drawing.Point(10, 527); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(280, 60); + this.groupBox1.TabIndex = 12; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "GCI bridge"; + // + // connectExternalButton + // + this.connectExternalButton.Location = new System.Drawing.Point(14, 19); + this.connectExternalButton.Name = "connectExternalButton"; + this.connectExternalButton.Size = new System.Drawing.Size(107, 28); + this.connectExternalButton.TabIndex = 0; + this.connectExternalButton.Text = "Connect"; + this.connectExternalButton.UseVisualStyleBackColor = true; + this.connectExternalButton.Click += new System.EventHandler(this.connectExternalButton_Click); + // + // showGuiButton + // + this.showGuiButton.Location = new System.Drawing.Point(160, 19); + this.showGuiButton.Name = "showGuiButton"; + this.showGuiButton.Size = new System.Drawing.Size(107, 28); + this.showGuiButton.TabIndex = 1; + this.showGuiButton.Text = "Show GUI"; + this.showGuiButton.UseVisualStyleBackColor = true; + this.showGuiButton.Click += new System.EventHandler(this.showGuiButton_Click); + // + // GciBridgeCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.externalTypeNameTextBox); + this.Controls.Add(this.externalTypeNameLabel); + this.Controls.Add(this.showGuiOnInitializeCheckBox); + this.Controls.Add(this.enableExternalCheckBox); + this.Controls.Add(this.enableGuiCheckBox); + this.Controls.Add(this.writerNameComboBox); + this.Controls.Add(this.writerNameLabel); + this.Controls.Add(this.readerNameComboBox); + this.Controls.Add(this.readerNameLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "GciBridgeCfgCtrl"; + this.Size = new System.Drawing.Size(300, 700); + this.Load += new System.EventHandler(this.GciBridgeCfgCtrl_Load); + this.groupBox1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label readerNameLabel; + private System.Windows.Forms.ComboBox readerNameComboBox; + private System.Windows.Forms.Label writerNameLabel; + private System.Windows.Forms.ComboBox writerNameComboBox; + private System.Windows.Forms.CheckBox enableGuiCheckBox; + private System.Windows.Forms.CheckBox enableExternalCheckBox; + private System.Windows.Forms.CheckBox showGuiOnInitializeCheckBox; + private System.Windows.Forms.Label externalTypeNameLabel; + private System.Windows.Forms.TextBox externalTypeNameTextBox; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button connectExternalButton; + private System.Windows.Forms.Button showGuiButton; + } +} \ No newline at end of file diff --git a/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfgCtrl.cs b/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfgCtrl.cs new file mode 100644 index 000000000..68eb84bd2 --- /dev/null +++ b/TBF/Rig/BridgeComponents/GciBridge/GciBridgeCfgCtrl.cs @@ -0,0 +1,183 @@ +/// +/// Copyright (c) 2015-2021 Sensus Slovensko a.s. +/// +using Common; +using System; +using System.Windows.Forms; +using TBF.Rig.Generic; +using TBF.UI.Bench.Components; + +namespace TBF.Rig.BridgeComponents.GciBridge +{ + /// + /// Configuration control for GCI bridge component. + /// + public partial class GciBridgeCfgCtrl : UserControl, IComponentCfgCtrl + { + ComponentParametersDlg parent; + + public bool ShowMore { get { return true; } } + + GciBridgeCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as GciBridgeCfg; + Redraw(); + } + } + + public GciBridgeCfgCtrl() + { + InitializeComponent(); + } + + private void GciBridgeCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.CmpntEntities != null) + { + readerNameComboBox.Items.Add("---"); + writerNameComboBox.Items.Add("---"); + + foreach (var cmpnt in parent.CmpntEntities) + { + object factory = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName); + + if (factory is TBF.Rig.Input.DataStorage.UniDataStorageReader.Factory) + { + readerNameComboBox.Items.Add(cmpnt.Name); + } + + if (factory is TBF.Rig.Output.DataStorage.UniDataStorageWriter.Factory) + { + writerNameComboBox.Items.Add(cmpnt.Name); + } + } + } + + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; + + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + readerNameComboBox.Text = string.IsNullOrEmpty(config.ReaderName) ? "---" : config.ReaderName; + writerNameComboBox.Text = string.IsNullOrEmpty(config.WriterName) ? "---" : config.WriterName; + enableGuiCheckBox.Checked = config.EnableGuiAccess; + enableExternalCheckBox.Checked = config.EnableExternalAccess; + showGuiOnInitializeCheckBox.Checked = config.ShowGuiOnInitialize; + externalTypeNameTextBox.Text = config.ExternalInterfaceTypeName; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + readerNameComboBox.Enabled = true; + writerNameComboBox.Enabled = true; + enableGuiCheckBox.Enabled = true; + enableExternalCheckBox.Enabled = true; + showGuiOnInitializeCheckBox.Enabled = true; + externalTypeNameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (string.IsNullOrWhiteSpace(nameTextBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Name'"; + } + + if (!readerNameComboBox.Items.Contains(readerNameComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Reader Name'"; + } + + if (!writerNameComboBox.Items.Contains(writerNameComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Writer Name'"; + } + + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (config == null) return CfgUpdateFlags.Error; + + if (!config.Name.Equals(nameTextBox.Text)) + { + config.Name = nameTextBox.Text; + flags |= CfgUpdateFlags.RestartRqrd; + } + + string readerName = readerNameComboBox.Text.Equals("---") ? string.Empty : readerNameComboBox.Text; + if (!config.ReaderName.Equals(readerName)) + { + config.ReaderName = readerName; + flags |= CfgUpdateFlags.RestartRqrd; + } + + string writerName = writerNameComboBox.Text.Equals("---") ? string.Empty : writerNameComboBox.Text; + if (!config.WriterName.Equals(writerName)) + { + config.WriterName = writerName; + flags |= CfgUpdateFlags.RestartRqrd; + } + + if (config.EnableGuiAccess != enableGuiCheckBox.Checked) + { + config.EnableGuiAccess = enableGuiCheckBox.Checked; + flags |= CfgUpdateFlags.RestartRqrd; + } + + if (config.EnableExternalAccess != enableExternalCheckBox.Checked) + { + config.EnableExternalAccess = enableExternalCheckBox.Checked; + flags |= CfgUpdateFlags.RestartRqrd; + } + + if (config.ShowGuiOnInitialize != showGuiOnInitializeCheckBox.Checked) + { + config.ShowGuiOnInitialize = showGuiOnInitializeCheckBox.Checked; + flags |= CfgUpdateFlags.RestartRqrd; + } + + if (config.ExternalInterfaceTypeName != externalTypeNameTextBox.Text) + { + config.ExternalInterfaceTypeName = externalTypeNameTextBox.Text; + flags |= CfgUpdateFlags.RestartRqrd; + } + + return flags; + } + + private void connectExternalButton_Click(object sender, EventArgs e) + { + /// TODO + } + + private void showGuiButton_Click(object sender, EventArgs e) + { + /// TODO + } + } +} \ No newline at end of file diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 79fc0b6c0..f5ceb7869 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -23,6 +23,7 @@ namespace TBF.Rig { new Ambient.Comet.Factory(), new Ambient.Greco.Factory(), + new BridgeComponents.GciBridge.Factory(), new ControlBoard.Papouch.Factory(), new ControlBoard.Uni.Factory(), new DataContainer.BackupAndSecurityOptions.Factory(), diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 6b50527b3..565abb4ad 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -202,6 +202,15 @@ + + + + + UserControl + + + GciBridgeCfgCtrl.cs +