From 7996e270de4edf7c79b9e221182ba83e5eba2831 Mon Sep 17 00:00:00 2001 From: Roland Drabesch Date: Tue, 6 Jun 2023 12:15:22 +0200 Subject: [PATCH] =?UTF-8?q?Justage=20f=C3=BCr=20Magflux=20l=C3=A4uft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/.vs/config/applicationhost.config | 2 +- .../DataPackage/TestSetupContainer.cs | 50 ++++- Common/Ui/LegacyGenesisControl/PreAdjWr.cs | 10 + Common/Ui/LegacyGenesisControl/TstContHlp.cs | 1 + Common/Ui/LegacyGenesisControl/ctlBatch.cs | 205 +++++++++++------- 5 files changed, 182 insertions(+), 86 deletions(-) diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 12afd122..40cde372 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Ui/LegacyGenesisControl/DataPackage/TestSetupContainer.cs b/Common/Ui/LegacyGenesisControl/DataPackage/TestSetupContainer.cs index 442fc00a..c79dfcb9 100644 --- a/Common/Ui/LegacyGenesisControl/DataPackage/TestSetupContainer.cs +++ b/Common/Ui/LegacyGenesisControl/DataPackage/TestSetupContainer.cs @@ -1,4 +1,5 @@ -using Xylem.Common.Logic.ProductionOrderCore.OrderData; +using System.Text; +using Xylem.Common.Logic.ProductionOrderCore.OrderData; using XylemCommonUiLegacyGenCtl.Enums; namespace XylemCommonUiLegacyGenCtl.DataPackage @@ -25,6 +26,53 @@ namespace XylemCommonUiLegacyGenCtl.DataPackage public MeterTestResults[] meterTestResults { get; set; } + public override string ToString() + { + + var sb = new StringBuilder(); + + sb.AppendLine($"WatingForDecision={WatingForDecision}"); + sb.AppendLine($"TempSouce={TempSouce}"); + sb.AppendLine($"MeterSize={MeterSize}"); + sb.AppendLine($"DelayInSBeforStart={DelayInSBeforStart}"); + sb.AppendLine($"AllChanelsRequired={AllChanelsRequired}"); + sb.AppendLine($"ProductionMode={ProductionMode}"); + + foreach (var item in meterTestSettings) + { + if (item == null) + { + continue; + } + sb.AppendLine($"Slot={item.Slot}"); + sb.AppendLine($"SerialNr={item.SerialNr}"); + sb.AppendLine($"FlowTesting={item.FlowTesting}"); + sb.AppendLine($"PreAdjustment={item.PreAdjustment}"); + sb.AppendLine($"FlowAdjustment={item.FlowAdjustment}"); + sb.AppendLine($"FlowAdjustmentTarget={item.FlowAdjustmentTarget}"); + sb.AppendLine($"meterType={item.meterType}"); + } + + + foreach (var item in meterTestResults) + { + if (item == null) + { + continue; + } + + sb.AppendLine($"Slot={item.Slot}"); + sb.AppendLine($"Sr={item.SerialNr}"); + + foreach (var flows in item.Results) + { + sb.AppendLine($"MeasuredRefFlowQmPerH={flows.MeasuredRefFlowQmPerH}"); + sb.AppendLine($"MeasuredDutFlowQmPerH={flows.MeasuredDutFlowQmPerH}"); + } + } + + return sb.ToString(); + } } } diff --git a/Common/Ui/LegacyGenesisControl/PreAdjWr.cs b/Common/Ui/LegacyGenesisControl/PreAdjWr.cs index 8cf51345..94e2509e 100644 --- a/Common/Ui/LegacyGenesisControl/PreAdjWr.cs +++ b/Common/Ui/LegacyGenesisControl/PreAdjWr.cs @@ -171,6 +171,7 @@ namespace XylemCommonUiLegacyGenCtl if (TestsetuptContainer == null) { + TestsetuptContainer = new TestSetupContainer(); TestsetuptContainer.TempSouce = Enums.TempSouceType.PtOverSps; TestsetuptContainer.ProductionMode = false; @@ -311,6 +312,14 @@ namespace XylemCommonUiLegacyGenCtl MessageBox.Show(ex.Message); } + Thread.Sleep(1000); + var RetryLeft = 10; + while (meter.GetMeasurementState(0) != Xylem.Common.Metrology.Measurements.Consts.MeasurementStates.IsCompleted && RetryLeft >0) + { + Thread.Sleep(1000); + RetryLeft = RetryLeft - 1; + } + var resU = meter.GetMainMeasurementResult(0, 60); @@ -429,6 +438,7 @@ namespace XylemCommonUiLegacyGenCtl public dynamic GetTestSetupContainer() { + MessageBox.Show(TestsetuptContainer.ToString(), "after PreAjdustemnt GetTestSetupContainer"); return TestsetuptContainer; } } diff --git a/Common/Ui/LegacyGenesisControl/TstContHlp.cs b/Common/Ui/LegacyGenesisControl/TstContHlp.cs index 15067b00..bf87aed5 100644 --- a/Common/Ui/LegacyGenesisControl/TstContHlp.cs +++ b/Common/Ui/LegacyGenesisControl/TstContHlp.cs @@ -189,6 +189,7 @@ namespace XylemCommonUiLegacyGenCtl if (testSetup.meterTestSettings[Slot - 1] == null) { + System.Windows.Forms.MessageBox.Show("new testresults from setmetertestsettings"); testSetup.meterTestResults[Slot - 1] = new MeterTestResults(); } diff --git a/Common/Ui/LegacyGenesisControl/ctlBatch.cs b/Common/Ui/LegacyGenesisControl/ctlBatch.cs index 52e3f6b4..2beaa60f 100644 --- a/Common/Ui/LegacyGenesisControl/ctlBatch.cs +++ b/Common/Ui/LegacyGenesisControl/ctlBatch.cs @@ -18,7 +18,6 @@ using System.Threading.Tasks; using System.Windows.Forms; using Xylem.Common.CommonCore.Configuration; 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.MagFlux.MagFluxCore; using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; @@ -885,6 +884,7 @@ namespace XylemCommonUiLegacyGenCtl { if (TestSetupContainer == null) { + MessageBox.Show("TestSetupContainer is null so add a new one"); TestSetupContainer = new TestSetupContainer(); TestSetupContainer.AllChanelsRequired = true; TestSetupContainer.meterTestSettings = new MeterTestSettings[10]; @@ -893,6 +893,7 @@ namespace XylemCommonUiLegacyGenCtl if (!TestSetupContainer.meterTestSettings.Any(f => f != null && f.Slot == slot)) { + MessageBox.Show($"TestSetupContainer has no entrys for Slot {slot}"); TestSetupContainer.meterTestSettings[slot] = new MeterTestSettings() { SerialNr = serialNumber, Slot = slot, FlowAdjustment = true, FlowTesting = true }; TestSetupContainer.meterTestResults[slot] = new MeterTestResults() { SerialNr = serialNumber, Slot = slot, meterType = MeterTypes.MagFlux, Results = new List() }; @@ -938,46 +939,56 @@ namespace XylemCommonUiLegacyGenCtl } public void MeterDoneWithDetails(Int32 slot, Boolean Succeed) { - if (!slotLut.ContainsKey(slot)) - { - slotLut.Add(slot, ""); - } - else - { - slotLut[slot] = ""; - } - if (!slotPreadjustment.ContainsKey(slot)) - { - slotPreadjustment.Add(slot, false); - } - else - { - slotPreadjustment[slot] = false; - } - - - MeterDone(slot, Succeed); var meter = batch.ListOfMeters.First(f => f.Slot == slot); - if (meter is GenesisMeter gen) + if (meter is MagFluxMeter mag) { - slotLut[slot] = gen.LutCrc; - try + MeterDone(slot, Succeed); + + } + else + { + + + if (!slotLut.ContainsKey(slot)) { - var responseJson = LocalWebRequest.GetRequest($"{ServiceUrls.MeterInfoForTestBench()}{gen.PcbId}"); - var a = JsonConvert.DeserializeObject(responseJson); - var SerialNumber = a[0]; - if (!string.IsNullOrEmpty(SerialNumber)) + slotLut.Add(slot, ""); + } + else + { + slotLut[slot] = ""; + } + if (!slotPreadjustment.ContainsKey(slot)) + { + slotPreadjustment.Add(slot, false); + } + else + { + slotPreadjustment[slot] = false; + } + + + MeterDone(slot, Succeed); + if (meter is GenesisMeter gen) + { + slotLut[slot] = gen.LutCrc; + try { - slotPreadjustment[slot] = int.TryParse(a[4], out _); + var responseJson = LocalWebRequest.GetRequest($"{ServiceUrls.MeterInfoForTestBench()}{gen.PcbId}"); + var a = JsonConvert.DeserializeObject(responseJson); + var SerialNumber = a[0]; + if (!string.IsNullOrEmpty(SerialNumber)) + { + slotPreadjustment[slot] = int.TryParse(a[4], out _); + } } - } - catch (Exception ex) - { - _logger.Error(ex, $"error at meter done web request (PcbId={gen.PcbId}"); + catch (Exception ex) + { + _logger.Error(ex, $"error at meter done web request (PcbId={gen.PcbId}"); - throw; - } + throw; + } + } } } @@ -985,28 +996,44 @@ namespace XylemCommonUiLegacyGenCtl { try { + setBusy(true, $"Set {slot} LCD"); Task.Factory.StartNew(() => { //FF-55-00-00 var meter = batch.ListOfMeters.First(f => f.Slot == slot); var state = DisplayCodes.FlowTested; - + if (meter is MagFluxMeter mag) { - var sb = new StringBuilder(); - if (TestSetupContainer.meterTestSettings.Any(s => s.Slot == slot && s.PreAdjustment)) - { - var result = TestSetupContainer.meterTestResults.First(s => s.Slot == slot); - sb.AppendLine($"Results: {result.SerialNr} on ep. {result.Slot}"); - foreach (var flowDeviations in result.Results) - { - sb.AppendLine($"RefFlow {flowDeviations.MeasuredRefFlowQmPerH} (for {flowDeviations.RefTimeS} Seconds) vs DutFlow {flowDeviations.MeasuredDutFlowQmPerH} (for {flowDeviations.DutTimeS} Seconds)"); + try + { + var sb = new StringBuilder(); + + + if (TestSetupContainer.meterTestSettings.Any(s => s != null && s.Slot == slot && s.PreAdjustment)) + { + //MessageBox.Show($"has meter with Zeroflow {slot}"); + + var result = TestSetupContainer.meterTestResults.First(s => s != null && s.Slot == slot); + sb.AppendLine($"Results: {result.SerialNr} on ep. {result.Slot}"); + foreach (var flowDeviations in result.Results) + { + MessageBox.Show($"RefFlow {flowDeviations.MeasuredRefFlowQmPerH} (for {flowDeviations.RefTimeS} Seconds) vs DutFlow {flowDeviations.MeasuredDutFlowQmPerH} (for {flowDeviations.DutTimeS} Seconds)"); + sb.AppendLine($"RefFlow {flowDeviations.MeasuredRefFlowQmPerH} (for {flowDeviations.RefTimeS} Seconds) vs DutFlow {flowDeviations.MeasuredDutFlowQmPerH} (for {flowDeviations.DutTimeS} Seconds)"); + } + //MessageBox.Show(sb.ToString()); + mag.WriteLog(sb.ToString()); + mag.WriteCalibrationTestBench(result.Results); } - mag.WriteCalibrationTestBench(result.Results); } + catch (Exception ex ) + { + MessageBox.Show(ex.Message); + } + @@ -1244,8 +1271,8 @@ namespace XylemCommonUiLegacyGenCtl } Thread.Sleep(sleepTimeS * 1000); - //Run as long the Checktime is not zero or we dont have a meter left without progress - while (TotalTimeForCheck >= 0 && SlotsWithoutProgress.Any()) + //Run as long the Checktime is not zero or we dont have a meter left without progress + while (TotalTimeForCheck >= 0 && SlotsWithoutProgress.Any()) { Thread.Sleep(sleepTimeS * 1000); TotalTimeForCheck -= sleepTimeS; @@ -1260,13 +1287,13 @@ namespace XylemCommonUiLegacyGenCtl { var r = ((GenesisMeter)meter).GetMainMeasurementResult(null, null, true); - //when Start and Stop Record have different Volumes the meter is ready for test, - //if a measurement hasn't finished, the StopRecord is an intermediate record, as - //this will be used for intermediate tolerance calculation. - //ReSharper disable once CompareOfFloatsByEqualityOperator as the rounding will take place in the - //Cordonel and only an unequally value needs to be detected - //when Start and Stop Record have diffrent Volumes the meter is ready for test - if (r.DutStartRecord.GetVolumeCm() != r.DutStopRecord.GetVolumeCm()) + //when Start and Stop Record have different Volumes the meter is ready for test, + //if a measurement hasn't finished, the StopRecord is an intermediate record, as + //this will be used for intermediate tolerance calculation. + //ReSharper disable once CompareOfFloatsByEqualityOperator as the rounding will take place in the + //Cordonel and only an unequally value needs to be detected + //when Start and Stop Record have diffrent Volumes the meter is ready for test + if (r.DutStartRecord.GetVolumeCm() != r.DutStopRecord.GetVolumeCm()) { _logger.Info($" Meter {meter.Slot} Meter has progress {r.DutVolumeCm}"); ((GenesisMeter)meter).StopMeasurement(); @@ -1449,8 +1476,8 @@ namespace XylemCommonUiLegacyGenCtl else { Int32 retrys = 0; - //remove channel filter 0 - var onlyChnl = _checkAllChannels ? null : (Int32?)0; + //remove channel filter 0 + var onlyChnl = _checkAllChannels ? null : (Int32?)0; while (item.GetMeasurementState(onlyChnl) != MeasurementStates.IsCompleted && retrys < nrOfRetrys) { @@ -1562,22 +1589,27 @@ namespace XylemCommonUiLegacyGenCtl } if (Chnnl == 0) { - var results = TestSetupContainer.meterTestResults.First(f => f != null && f.Slot == Slot); + try + { - if (results == null) - { - MessageBox.Show("No TestContainer found"); - } - else - { - if (results.Results == null) + + if (TestSetupContainer.meterTestResults == null) { - results.Results = new List(); + MessageBox.Show("meterTestResults emtpty on getresults"); + var countMeters = TestSetupContainer.meterTestSettings?.Count() ?? 10; + + TestSetupContainer.meterTestResults = new MeterTestResults[countMeters]; + } + if (!TestSetupContainer.meterTestResults.Any(f => f != null && f.Slot == Slot)) + { + MessageBox.Show("meterTestResults not found on getresults"); + TestSetupContainer.meterTestResults[Slot - 1].Results = new List(); } - if (!results.Results.Any(f => f.MeasuredRefFlowQmPerH == result.Value.RefFlowRateCmPh)) + var results = TestSetupContainer.meterTestResults[Slot - 1].Results; + if (!results.Any(f => f.MeasuredRefFlowQmPerH == result.Value.RefFlowRateCmPh)) { - results.Results.Add(new Xylem.Common.Hardware.WaterMeter.DataPackages.MeasurementRecords.FlowDeviations() + results.Add(new Xylem.Common.Hardware.WaterMeter.DataPackages.MeasurementRecords.FlowDeviations() { MeasuredRefFlowQmPerH = result.Value.RefFlowRateCmPh ?? 0, RefTimeS = result.Value.RefTimeS ?? 0, @@ -1588,6 +1620,12 @@ namespace XylemCommonUiLegacyGenCtl }); } } + catch (Exception ex) + { + _logger.Error(ex, $"error on GetResults add testresult Slot={Slot},Chnnl={Chnnl},refVolQm={refVolQm},refTimeS={refTimeS}"); + + } + } return new Results(result.Value, sbError); @@ -1755,17 +1793,17 @@ namespace XylemCommonUiLegacyGenCtl PredictedTs = predictedTs; RefError = refError; currentMode = Mode.AutoRefresh; - //this.RefreshTimer.Interval = 10000; - //this.RefreshTimer.Tick += new EventHandler(this.RefreshTimer_Tick); - //this.RefreshTimer.Enabled = true; - pgbUpdate.Maximum = 10000; + //this.RefreshTimer.Interval = 10000; + //this.RefreshTimer.Tick += new EventHandler(this.RefreshTimer_Tick); + //this.RefreshTimer.Enabled = true; + pgbUpdate.Maximum = 10000; updateLabelCollection(); ExpertMode(cbxExpert.Checked); - // dgvBatch.Size = new Size(SizeOfMeter, dgvBatch.Size.Height); - pgbEndTime.Maximum = (Int32)predictedTs; + // dgvBatch.Size = new Size(SizeOfMeter, dgvBatch.Size.Height); + pgbEndTime.Maximum = (Int32)predictedTs; })); } @@ -1945,9 +1983,9 @@ namespace XylemCommonUiLegacyGenCtl currentMode = Mode.View; TryInvoke(new Action(() => { - //this.RefreshTimer.Enabled = false; - //this.pnlEndTime.Visible = false; - })); + //this.RefreshTimer.Enabled = false; + //this.pnlEndTime.Visible = false; + })); } else { @@ -1956,8 +1994,8 @@ namespace XylemCommonUiLegacyGenCtl TryInvoke(new Action(() => { - //this.RefreshTimer.Enabled = true; - })); + //this.RefreshTimer.Enabled = true; + })); stopWatch.Start(); } @@ -2005,8 +2043,8 @@ namespace XylemCommonUiLegacyGenCtl { if (item is GenesisMeter) { - // ((GenesisMeter)item).(); - } + // ((GenesisMeter)item).(); + } } Thread.Sleep(1000); @@ -2074,8 +2112,8 @@ namespace XylemCommonUiLegacyGenCtl genesis.ReLogin(); genesis.BuildAndCheckCalibFactorsAllChannels(StoreRefVolume, StoreTestTimeRef, calFactor); - //genesis.SetCalibFactorsAllChannels(true); - genesis.SetCalibFactorsAllChannels(); + //genesis.SetCalibFactorsAllChannels(true); + genesis.SetCalibFactorsAllChannels(); return new Tuple(true, baseMeter.Slot); } @@ -2096,8 +2134,8 @@ namespace XylemCommonUiLegacyGenCtl var t = new Task(() => { - // ReSharper disable once CoVariantArrayConversion - Task.WaitAll(taskList.ToArray()); + // ReSharper disable once CoVariantArrayConversion + Task.WaitAll(taskList.ToArray()); Boolean overallResult = true; foreach (var item in taskList) @@ -2346,7 +2384,6 @@ namespace XylemCommonUiLegacyGenCtl } - MessageBox.Show(sb.ToString()); TestSetupContainer = vbContainer; _currentState = BatchState.TestContainerIsReady; return;