Adding Magflux to legacyControll [Not working]

This commit is contained in:
Roland Drabesch
2023-05-08 17:26:40 +02:00
parent 3a212f0215
commit 377887ba08
12 changed files with 187 additions and 102 deletions
+1 -1
View File
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\laa_production\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />
@@ -104,7 +104,9 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
/// </summary>
/// <param name="slot">Slot Number for Test bench</param>
/// <param name="ignoreCorruptedData">don´t send CRC error or telegrams with error flag to caller</param>
void SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData = true);
void SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData = true, Boolean useRequest = true, Boolean useStreaming = true);
/// <summary>
/// Logout from device
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
{
public enum MeterTypes
{
Cordonel,
MagFlux,
eRegister,
}
}
@@ -261,6 +261,7 @@
<Compile Include="MeterBatch.cs" />
<Compile Include="IMeter.cs" />
<Compile Include="IMeterEvents.cs" />
<Compile Include="MeterTypes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -1 +1 @@
1a3d4919c9c702245832d925951f2b7cb72fc333
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
@@ -1 +1 @@
f64d563def603c89cafafa61a3219ba97e1e344c
0d85a5b3a7561b41163c20e5dc7713bcd0d65555
+31 -77
View File
@@ -29,13 +29,10 @@
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnPreadjustment = new System.Windows.Forms.Button();
this.cbRequest = new System.Windows.Forms.CheckBox();
this.button2 = new System.Windows.Forms.Button();
this.rbFlowCalibration = new System.Windows.Forms.RadioButton();
this.rbMeasurement = new System.Windows.Forms.RadioButton();
this.label1 = new System.Windows.Forms.Label();
this.btnPrepareBatch = new System.Windows.Forms.Button();
this.cblSlots = new System.Windows.Forms.CheckedListBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnStoreCal = new System.Windows.Forms.Button();
@@ -44,42 +41,28 @@
this.btnMeasurementStop = new System.Windows.Forms.Button();
this.btnMeasurementPreparation = new System.Windows.Forms.Button();
this.btnMeasurementStart = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.ctlAutoDetect1 = new XylemCommonUiLegacyGenCtl.ctlAutoDetect();
this.ctlCheckTestBenchReady1 = new XylemCommonUiLegacyGenCtl.ctlBenchRdy();
this.btnCheckAll = new System.Windows.Forms.Button();
this.btnGetResults = new System.Windows.Forms.Button();
this.ctlBatch = new XylemCommonUiLegacyGenCtl.ctlBatch();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnPreadjustment);
this.groupBox1.Controls.Add(this.cbRequest);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.rbFlowCalibration);
this.groupBox1.Controls.Add(this.rbMeasurement);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.btnPrepareBatch);
this.groupBox1.Controls.Add(this.cblSlots);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(510, 105);
this.groupBox1.Size = new System.Drawing.Size(238, 105);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// btnPreadjustment
//
this.btnPreadjustment.Location = new System.Drawing.Point(453, 19);
this.btnPreadjustment.Name = "btnPreadjustment";
this.btnPreadjustment.Size = new System.Drawing.Size(51, 64);
this.btnPreadjustment.TabIndex = 13;
this.btnPreadjustment.Text = "preadjustement";
this.btnPreadjustment.UseVisualStyleBackColor = true;
this.btnPreadjustment.Click += new System.EventHandler(this.btnPreadjustment_Click);
//
// cbRequest
//
this.cbRequest.AutoSize = true;
@@ -90,16 +73,6 @@
this.cbRequest.Text = "Request";
this.cbRequest.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Location = new System.Drawing.Point(301, 19);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(146, 67);
this.button2.TabIndex = 12;
this.button2.Text = "AddMetersToControl";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// rbFlowCalibration
//
this.rbFlowCalibration.AutoSize = true;
@@ -131,16 +104,6 @@
this.label1.TabIndex = 6;
this.label1.Text = "Slot(s)";
//
// btnPrepareBatch
//
this.btnPrepareBatch.Location = new System.Drawing.Point(205, 19);
this.btnPrepareBatch.Name = "btnPrepareBatch";
this.btnPrepareBatch.Size = new System.Drawing.Size(90, 67);
this.btnPrepareBatch.TabIndex = 5;
this.btnPrepareBatch.Text = "PrepareBatch";
this.btnPrepareBatch.UseVisualStyleBackColor = true;
this.btnPrepareBatch.Click += new System.EventHandler(this.btnInit_Click);
//
// cblSlots
//
this.cblSlots.FormattingEnabled = true;
@@ -153,22 +116,23 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnGetResults);
this.groupBox2.Controls.Add(this.btnStoreCal);
this.groupBox2.Controls.Add(this.textBox1);
this.groupBox2.Controls.Add(this.btnUpdate);
this.groupBox2.Controls.Add(this.btnMeasurementStop);
this.groupBox2.Controls.Add(this.btnMeasurementPreparation);
this.groupBox2.Controls.Add(this.btnMeasurementStart);
this.groupBox2.Location = new System.Drawing.Point(546, 12);
this.groupBox2.Location = new System.Drawing.Point(282, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(554, 105);
this.groupBox2.Size = new System.Drawing.Size(656, 105);
this.groupBox2.TabIndex = 10;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Control";
//
// btnStoreCal
//
this.btnStoreCal.Location = new System.Drawing.Point(463, 13);
this.btnStoreCal.Location = new System.Drawing.Point(564, 13);
this.btnStoreCal.Name = "btnStoreCal";
this.btnStoreCal.Size = new System.Drawing.Size(83, 80);
this.btnStoreCal.TabIndex = 11;
@@ -223,33 +187,9 @@
this.btnMeasurementStart.UseVisualStyleBackColor = true;
this.btnMeasurementStart.Click += new System.EventHandler(this.btnMeasurementStart_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(1106, 31);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(146, 67);
this.button1.TabIndex = 13;
this.button1.Text = "AddMetersToControl";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// ctlAutoDetect1
//
this.ctlAutoDetect1.Location = new System.Drawing.Point(12, 123);
this.ctlAutoDetect1.Name = "ctlAutoDetect1";
this.ctlAutoDetect1.Size = new System.Drawing.Size(267, 305);
this.ctlAutoDetect1.TabIndex = 14;
//
// ctlCheckTestBenchReady1
//
this.ctlCheckTestBenchReady1.Location = new System.Drawing.Point(347, 222);
this.ctlCheckTestBenchReady1.Name = "ctlCheckTestBenchReady1";
this.ctlCheckTestBenchReady1.Size = new System.Drawing.Size(543, 506);
this.ctlCheckTestBenchReady1.TabIndex = 15;
//
// btnCheckAll
//
this.btnCheckAll.Location = new System.Drawing.Point(347, 149);
this.btnCheckAll.Location = new System.Drawing.Point(1167, 123);
this.btnCheckAll.Name = "btnCheckAll";
this.btnCheckAll.Size = new System.Drawing.Size(90, 67);
this.btnCheckAll.TabIndex = 14;
@@ -257,15 +197,32 @@
this.btnCheckAll.UseVisualStyleBackColor = true;
this.btnCheckAll.Click += new System.EventHandler(this.btnCheckAll_Click);
//
// btnGetResults
//
this.btnGetResults.Location = new System.Drawing.Point(463, 13);
this.btnGetResults.Name = "btnGetResults";
this.btnGetResults.Size = new System.Drawing.Size(83, 80);
this.btnGetResults.TabIndex = 12;
this.btnGetResults.Text = "Store Calibration";
this.btnGetResults.UseVisualStyleBackColor = true;
//
// ctlBatch
//
this.ctlBatch.AutoSize = true;
this.ctlBatch.BackColor = System.Drawing.SystemColors.Control;
this.ctlBatch.Location = new System.Drawing.Point(112, 145);
this.ctlBatch.MinimumSize = new System.Drawing.Size(660, 440);
this.ctlBatch.Name = "ctlBatch";
this.ctlBatch.Size = new System.Drawing.Size(697, 463);
this.ctlBatch.TabIndex = 15;
//
// FrmLegacyTestApp
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1378, 697);
this.Controls.Add(this.ctlBatch);
this.Controls.Add(this.btnCheckAll);
this.Controls.Add(this.ctlCheckTestBenchReady1);
this.Controls.Add(this.ctlAutoDetect1);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "FrmLegacyTestApp";
@@ -276,6 +233,7 @@
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -285,7 +243,6 @@
private System.Windows.Forms.RadioButton rbFlowCalibration;
private System.Windows.Forms.RadioButton rbMeasurement;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnPrepareBatch;
private System.Windows.Forms.CheckedListBox cblSlots;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnUpdate;
@@ -294,12 +251,9 @@
private System.Windows.Forms.Button btnMeasurementStart;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button btnStoreCal;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.CheckBox cbRequest;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btnPreadjustment;
private XylemCommonUiLegacyGenCtl.ctlAutoDetect ctlAutoDetect1;
private XylemCommonUiLegacyGenCtl.ctlBenchRdy ctlCheckTestBenchReady1;
private System.Windows.Forms.Button btnCheckAll;
private System.Windows.Forms.Button btnGetResults;
private XylemCommonUiLegacyGenCtl.ctlBatch ctlBatch;
}
}
+95 -8
View File
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Xylem.Common.CommonCore.Consts;
@@ -16,6 +17,7 @@ using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Metrology.Measurements;
using Xylem.Common.Utils.Logging;
using XylemCommonUiLegacyGenCtl;
using XylemCommonUiLegacyGenCtl.DataPackage;
namespace GenesisToolBox
{
@@ -116,7 +118,7 @@ namespace GenesisToolBox
private void TestForm_Load(Object sender, EventArgs e)
{
ctlAutoDetect1.Init(3);
}
private void btnInit_Click(Object sender, EventArgs e)
@@ -234,7 +236,7 @@ namespace GenesisToolBox
testTime = (DateTime.Now - startTime.Value).TotalSeconds;
}
controlBatch.SetBatchInfos(flowrateRef, testTime, 11, 5, 0, 20, "b");
ctlBatch.SetBatchInfos(flowrateRef, testTime, 11, 5, 0, 20, "b");
}
private void btnMeasurementStop_Click(Object sender, EventArgs e)
@@ -256,9 +258,34 @@ namespace GenesisToolBox
{
setBussy(false);
isMeasurementStarted = false;
stateChanged();
var flowrateRef = 0.23;
if (!double.TryParse(textBox1.Text, out flowrateRef))
{
var rnd = new Random(1);
flowrateRef = flowrateRef + (rnd.NextDouble() / 100);
}
if (endTime.HasValue && startTime.HasValue)
{
var timeMeasurement = (endTime.Value - startTime.Value);
MessageBox.Show($"MeasurementBuffered rund for {timeMeasurement}S");
foreach (var item in cblSlots.CheckedItems)
{
var slotNr = 0;
if (int.TryParse(item.ToString(), out slotNr))
{
var result = ctlBatch.GetResults(slotNr, 0, flowrateRef, timeMeasurement.TotalSeconds);
MessageBox.Show($"result.DutTimeS = {result.DutTimeS} & result.DutVolumeCm = {result.DutVolumeCm}");
}
}
//foreach (var m in mb.ListOfMeters)
//{
@@ -274,8 +301,7 @@ namespace GenesisToolBox
//}
var timeMeasurement = (endTime.Value - startTime.Value);
MessageBox.Show($"MeasurementBuffered rund for {timeMeasurement}S");
}
@@ -375,6 +401,58 @@ namespace GenesisToolBox
isMeasurement = false;
}
var container = new TestSetupContainer();
container.AllChanelsRequired = false;
container.DelayInSBeforStart = 0;
container.MeterSize = Xylem.Common.Logic.ProductionOrderCore.OrderData.MeterSize.DN50;
container.ProductionMode = false;
container.TempSouce = XylemCommonUiLegacyGenCtl.Enums.TempSouceType.ManualInput;
container.WatingForDecision = true;
container.meterTestSettings = new MeterTestSettings[cblSlots.CheckedItems.Count];
var i = 0;
foreach (var item in cblSlots.CheckedItems)
{
var slotNr = 0;
if (int.TryParse(item.ToString(), out slotNr))
{
container.meterTestSettings[i] = new MeterTestSettings();
container.meterTestSettings[i].Slot = slotNr;
container.meterTestSettings[i].FlowAdjustment = false;
container.meterTestSettings[i].FlowAdjustmentTarget = 0;
container.meterTestSettings[i].FlowTesting = true;
container.meterTestSettings[i].PreAdjustment = false;
container.meterTestSettings[i].SerialNr = $"450000{slotNr}";
container.meterTestSettings[i].meterType = MeterTypes.MagFlux;
}
i++;
}
ctlBatch.SetTestSetupContainer(container);
ctlBatch.PrepareBatch("FrmLeagcyTestApp");
ctlBatch.AddAllMeters("50", 0, 40, 60, 0.1, false);
while (!ctlBatch.MetersArePrepared())
{
Thread.Sleep(100);
}
foreach (var item in container.meterTestSettings)
{
ctlBatch.SetErrorFrame(item.Slot, 1.5);
}
ctlBatch.SetReadyForMesuremnt();
//controlBatch.PrepareMeters("50", 12, 1, 60, 1.7, !isMeasurement, true);
}
catch (Exception ex)
@@ -388,7 +466,13 @@ namespace GenesisToolBox
try
{
controlBatch.StartMeasurement();
ctlBatch.StartMeasurement();
while (!ctlBatch.MeasurementIsActive())
{
Thread.Sleep(100);
}
}
catch (Exception ex)
@@ -401,8 +485,11 @@ namespace GenesisToolBox
try
{
controlBatch.StopMeasurement();
var rest = controlBatch.GetResults(1, 0, 10, 0);
ctlBatch.StopMeasurement();
while (!ctlBatch.MeasurementIsCompleted())
{
Thread.Sleep(100);
}
}
catch (Exception ex)
+1 -1
View File
@@ -303,7 +303,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
private void btnLegacyTestApp_Click(Object sender, EventArgs e)
{
var form = new FrmLegacyTestAppStart();
var form = new FrmLegacyTestApp();
form.Show();
form.Closed += Form_Closed;
Hide();
@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
namespace XylemCommonUiLegacyGenCtl.DataPackage
{
public class MeterTestSettings
{
public MeterTypes meterType { get; set; }
public int Slot { get; set; }
public string SerialNr { get; set; }
public bool FlowAdjustment { get; set; }
@@ -218,6 +218,10 @@
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
<Name>Registers</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\MagFlux\MagFluxCore\MagFluxCore.csproj">
<Project>{b5da260c-71cc-45ca-b79e-d1b376af718c}</Project>
<Name>MagFluxCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\WaterMeterCore\WaterMeterCore.csproj">
<Project>{8203abb8-38e5-472e-a742-33f38b7a74a6}</Project>
<Name>WaterMeterCore</Name>
+31 -12
View File
@@ -19,6 +19,7 @@ using System.Windows.Forms;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Xylem.Common.Metrology.Measurements;
@@ -747,35 +748,53 @@ namespace XylemCommonUiLegacyGenCtl
{
if (batch.ListOfMeters.All(f => f.Slot != item.Slot))
{
var meter = new GenesisMeter();
try
{
IMeter meter;
switch (item.meterType)
{
case MeterTypes.Cordonel:
meter = new GenesisMeter();
break;
case MeterTypes.MagFlux:
meter = new MagFluxMeter();
break;
default:
meter = new GenesisMeter();
break;
}
meter.SerialNumber = item.SerialNr;
meter.CurrentActionText = "FlowTest";
meter.SetupFromConfigFile(item.Slot, false, _useRequest, true);
meter.LogRawData(_rawLogging);
batch.AddMeter(meter);
if (!meter.Login())
{
if (!meter.Login())
{
return;
}
}
meter.SkipPreparationForTestBench = false;
if (TestSetupContainer.ProductionMode)
{
meter.SkipPreparationForTestBench = true;
}
batch.AddMeter(meter);
var uniMeter = batch.GetMeter(item.Slot);
if (!uniMeter.Login())
{
if (!uniMeter.Login())
{
return;
}
}
//;
meter.WriteLog("Add from AddAllMeters");
uniMeter.WriteLog("Add from AddAllMeters");
}
catch (Exception ex)
{
meter.WriteLog(ex.Message);
_logger.Warn(ex.Message);
}
}