Add (develop) GCI - interface of GCI and Laatzen - GciBridge component

This commit is contained in:
Marek Frniak 2026-04-15 08:46:19 +02:00
parent eda0644b4b
commit c6d4a016b5
29 changed files with 1824 additions and 84 deletions

View File

@ -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<string>();
@ -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; }
}
/// <summary>
/// Represents the result of a connect operation.
/// </summary>
@ -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
};
}
}
/// <summary>
/// Connects to a Genesis meter for the specified slot.
/// </summary>
@ -439,9 +496,102 @@ namespace GenesisCordonelInterface.API
/// }
/// </code>
/// </example>
public ConnectResult Connect(int slotNo, PasswordSource usePasswordSource, List<string> 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<GenesisMeter>()
.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
};
}
}
/// <summary>
/// Connects to a Genesis meter for the specified slot.
/// </summary>
/// <param name="slotNo">Slot number.</param>
/// <param name="useOfflinePasswords">Specifies whether offline passwords should be used.</param>
/// <returns>
/// Connect operation result including PCB ID, firmware/configuration info, and register snapshots.
/// </returns>
/// <example>
/// <code>
/// 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);
/// }
/// </code>
/// </example>
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

View File

@ -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
/// <param name="slotNo">Slot number.</param>
/// <param name="usePasswordsSource">Specifies whether offline passwords should be used.</param>
/// <returns>Connect operation result.</returns>
public InterfaceGCIToLaatzen.ConnectResult Connect(int slotNo, int usePasswordSource, List<string> 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);
}
/// <summary>
/// Connects to the meter on the specified slot.
/// </summary>
/// <param name="slotNo">Slot number.</param>
/// <param name="usePasswordsSource">Specifies whether offline passwords should be used.</param>
/// <returns>Connect operation result.</returns>
public InterfaceGCIToLaatzen.ConnectResult ConnectOneMeter(int slotNo)
{
return _innerMeterAPI.ConnectOneMeter(slotNo);
}
/// <summary>
/// Connects to the meter on the specified slot.
/// </summary>
/// <param name="slotNo">Slot number.</param>
/// <param name="usePasswordsSource">Specifies whether offline passwords should be used.</param>
/// <returns>Connect operation result.</returns>
public InterfaceGCIToLaatzen.ConnectResult ConnectAllMeters(int slotNo)
{
return _innerMeterAPI.ConnectAllMeters(slotNo);
}
/// <summary>

View File

@ -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
//...
}
}

View File

@ -60,29 +60,28 @@
<Compile Include="API\InterfaceGCIToLaatzen.cs" />
<Compile Include="Core\Logging\UiLogBus.cs" />
<Compile Include="Core\Logging\UiTarget.cs" />
<Compile Include="Core\Secondary.cs" />
<Compile Include="UI\Laatzen_GenesisToolBox\FrmConfigurations.cs">
<Compile Include="UI\LaatzenAPI_GenesisToolBox\FrmConfigurations.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Laatzen_GenesisToolBox\FrmConfigurations.Designer.cs">
<Compile Include="UI\LaatzenAPI_GenesisToolBox\FrmConfigurations.Designer.cs">
<DependentUpon>FrmConfigurations.cs</DependentUpon>
</Compile>
<Compile Include="UI\Laatzen_CordonelPreadjustmentUI\FrmCordonelPreadjustmentUI.cs">
<Compile Include="UI\LaatzenAPI_CordonelPreadjustmentUI\FrmCordonelPreadjustmentUI.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Laatzen_CordonelPreadjustmentUI\FrmCordonelPreadjustmentUI.Designer.cs">
<Compile Include="UI\LaatzenAPI_CordonelPreadjustmentUI\FrmCordonelPreadjustmentUI.Designer.cs">
<DependentUpon>FrmCordonelPreadjustmentUI.cs</DependentUpon>
</Compile>
<Compile Include="UI\Laatzen_GenesisToolBox\FrmRegisterStore.cs">
<Compile Include="UI\LaatzenAPI_GenesisToolBox\FrmRegisterStore.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Laatzen_GenesisToolBox\FrmRegisterStore.Designer.cs">
<Compile Include="UI\LaatzenAPI_GenesisToolBox\FrmRegisterStore.Designer.cs">
<DependentUpon>FrmRegisterStore.cs</DependentUpon>
</Compile>
<Compile Include="UI\Laatzen_GenesisToolBox\FrmSetup.cs">
<Compile Include="UI\LaatzenAPI_GenesisToolBox\FrmSetup.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Laatzen_GenesisToolBox\FrmSetup.Designer.cs">
<Compile Include="UI\LaatzenAPI_GenesisToolBox\FrmSetup.Designer.cs">
<DependentUpon>FrmSetup.cs</DependentUpon>
</Compile>
<Compile Include="UI\MainForm.cs">
@ -93,12 +92,18 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\Laatzen_CordonelPreadjustmentUI\PreAdjustmentControl.cs">
<Compile Include="UI\LaatzenAPI_CordonelPreadjustmentUI\PreAdjustmentControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\Laatzen_CordonelPreadjustmentUI\PreAdjustmentControl.Designer.cs">
<Compile Include="UI\LaatzenAPI_CordonelPreadjustmentUI\PreAdjustmentControl.Designer.cs">
<DependentUpon>PreAdjustmentControl.cs</DependentUpon>
</Compile>
<Compile Include="UI\StaraTuraAPI_GenesisCordonelInterface\FrmGCIAPI.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\StaraTuraAPI_GenesisCordonelInterface\FrmGCIAPI.Designer.cs">
<DependentUpon>FrmGCIAPI.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -109,7 +114,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="UI\Laatzen_GenesisToolBox\FrmSetup.resx">
<EmbeddedResource Include="UI\LaatzenAPI_GenesisToolBox\FrmSetup.resx">
<DependentUpon>FrmSetup.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\MainForm.resx">
@ -119,9 +124,12 @@
<Content Include="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="UI\Laatzen_CordonelPreadjustmentUI\PreAdjustmentControl.resx">
<EmbeddedResource Include="UI\LaatzenAPI_CordonelPreadjustmentUI\PreAdjustmentControl.resx">
<DependentUpon>PreAdjustmentControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\StaraTuraAPI_GenesisCordonelInterface\FrmGCIAPI.resx">
<DependentUpon>FrmGCIAPI.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
@ -136,7 +144,10 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Core\AsTbfComponent\" />
<Folder Include="UI\AsTbfComponent\" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>

View File

@ -1,4 +1,4 @@
namespace GenesisCordonelInterface.UI
namespace GenesisCordonelInterface.UI.LaatzenAPI_CordonelPreadjustmentUI
{
partial class FrmCordonelPreadjustmentUI
{

View File

@ -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
{

View File

@ -1,4 +1,4 @@
namespace Xylem.Common.Ui.GenesisToolBox
namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox
{
partial class FrmConfigurations
{

View File

@ -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
{

View File

@ -1,4 +1,4 @@
namespace GenesisCordonelInterface.UI
namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox
{
partial class FrmRegisterStore
{

View File

@ -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)
{

View File

@ -1,4 +1,4 @@
namespace GenesisCordonelInterface.UI
namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox
{
partial class FrmSetup
{

View File

@ -21,7 +21,7 @@ using Xylem.Common.Utils.Logging;
using NLog;
using GenesisCordonelInterface.API;
namespace GenesisCordonelInterface.UI
namespace GenesisCordonelInterface.UI.LaatzenAPI_GenesisToolBox
{
/// <summary>
/// Setup of GTB

View File

@ -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;
}
}

View File

@ -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.");
}
}
}

View File

@ -0,0 +1,383 @@
namespace GenesisCordonelInterface.UI.StaraTuraAPI_GenesisCordonelInterface
{
partial class FrmGCIAPI
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support.
/// </summary>
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;
}
}

View File

@ -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);
});
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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<IComponent> 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);
}
}
}

View File

@ -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
{
/// <summary>
/// TBF bridge component for integration with the sibling GCI project.
/// The component can be linked to UniDataStorage reader and writer components.
/// </summary>
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;
/// <summary>
/// Linked UniDataStorage reader component.
/// </summary>
readonly UdsReaderType reader;
/// <summary>
/// Linked UniDataStorage writer component.
/// </summary>
readonly UdsWriterType writer;
/// <summary>
/// Placeholder for GCI GUI entry point.
/// Replace object with real GCI MainForm type later.
/// </summary>
object gciMainForm;
/// <summary>
/// Placeholder for GCI external/public interface.
/// Replace object with real GCI interface type later.
/// </summary>
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<IComponent> 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);
}
/// <summary>
/// Initializes access to GCI GUI.
/// Replace placeholder implementation with real MainForm creation.
/// </summary>
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);
}
}
/// <summary>
/// Initializes access to GCI external/public interface.
/// Replace placeholder implementation with real interface creation.
/// </summary>
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);
}
}
/// <summary>
/// Shows GCI GUI if GUI access is enabled.
/// </summary>
public void ShowGui()
{
if (!gciBridgeCfg.EnableGuiAccess) return;
if (!IsGuiInitialized)
{
TryInitializeGui();
}
/// TODO:
/// Replace with real MainForm.Show() call.
log.InfoFormat("{0}: ShowGui invoked.", Name);
}
/// <summary>
/// Hides GCI GUI if GUI access is enabled.
/// </summary>
public void HideGui()
{
if (!gciBridgeCfg.EnableGuiAccess) return;
if (!IsGuiInitialized) return;
/// TODO:
/// Replace with real MainForm.Hide() call.
log.InfoFormat("{0}: HideGui invoked.", Name);
}
/// <summary>
/// Connects the external GCI interface.
/// </summary>
public void ConnectExternal()
{
if (!gciBridgeCfg.EnableExternalAccess) return;
if (!IsExternalInitialized)
{
TryInitializeExternalInterface();
}
/// TODO:
/// Replace with real external interface connect call.
log.InfoFormat("{0}: ConnectExternal invoked.", Name);
}
/// <summary>
/// Disconnects the external GCI interface.
/// </summary>
public void DisconnectExternal()
{
if (!gciBridgeCfg.EnableExternalAccess) return;
if (!IsExternalInitialized) return;
/// TODO:
/// Replace with real external interface disconnect call.
log.InfoFormat("{0}: DisconnectExternal invoked.", Name);
}
/// <summary>
/// Returns linked reader component.
/// </summary>
public UdsReaderType GetReader()
{
return reader;
}
/// <summary>
/// Returns linked writer component.
/// </summary>
public UdsWriterType GetWriter()
{
return writer;
}
}
}

View File

@ -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
{
/// <summary>
/// Configuration of GCI bridge component.
/// </summary>
public class GciBridgeCfg : ComponentCfgBase, IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(GciBridgeCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
/// <summary>
/// Linked UniDataStorage reader component name.
/// </summary>
public string ReaderName;
/// <summary>
/// Linked UniDataStorage writer component name.
/// </summary>
public string WriterName;
/// <summary>
/// Enables access to GCI GUI layer.
/// </summary>
public bool EnableGuiAccess;
/// <summary>
/// Enables access to GCI external/public interface.
/// </summary>
public bool EnableExternalAccess;
/// <summary>
/// If true, GUI should be shown automatically after initialization.
/// </summary>
public bool ShowGuiOnInitialize;
/// <summary>
/// Optional external interface type name or description.
/// </summary>
public string ExternalInterfaceTypeName;
/// <summary>
/// Private parameterless constructor used by serializer.
/// </summary>
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<Component> 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);
}
}
}

View File

@ -0,0 +1,236 @@
namespace TBF.Rig.BridgeComponents.GciBridge
{
partial class GciBridgeCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support.
/// </summary>
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;
}
}

View File

@ -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
{
/// <summary>
/// Configuration control for GCI bridge component.
/// </summary>
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
}
}
}

View File

@ -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(),

View File

@ -202,6 +202,15 @@
<Compile Include="Rig\Ambient\Greco\Ambient.cs" />
<Compile Include="Rig\Ambient\Greco\AmbientCfg.cs" />
<Compile Include="Rig\Ambient\Greco\Factory.cs" />
<Compile Include="Rig\BridgeComponents\GciBridge\Factory.cs" />
<Compile Include="Rig\BridgeComponents\GciBridge\GciBridge.cs" />
<Compile Include="Rig\BridgeComponents\GciBridge\GciBridgeCfg.cs" />
<Compile Include="Rig\BridgeComponents\GciBridge\GciBridgeCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\BridgeComponents\GciBridge\GciBridgeCfgCtrl.Designer.cs">
<DependentUpon>GciBridgeCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\BuiltIn\PumpTandem\Pump.cs" />
<Compile Include="Rig\BuiltIn\PumpTandem\PumpCfg.cs" />
<Compile Include="Rig\BuiltIn\PumpTandem\PumpCfgCtrl.cs">