diff --git a/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs b/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs index 0618e143..c60b2787 100644 --- a/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs +++ b/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs @@ -673,6 +673,32 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore SetupFromConfigFile(slot, ignoreCorruptedData, true, true); } + + /// + /// Copy list of flow results to and kick off the + /// writing of calibrations to MagFlux. + /// + /// List of flow results + public void WriteCalibrationTestBench(List results) + { + if (RequestProtocol == null) return; + var calibrationsCmPerH = new List(); + var calibrationCmPerH = new Calibration(); + foreach (var result in results) + { + calibrationCmPerH.refFlowRate = (Single)result.MeasuredRefFlowQmPerH; + calibrationCmPerH.dutFlowRate = (Single)result.MeasuredDutFlowQmPerH; + calibrationsCmPerH.Add(calibrationCmPerH); + } + + RequestProtocol.SetCalibrationPoints(calibrationsCmPerH); + } + + /// + void IMeter.SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData, Boolean useRequest, Boolean useStreaming) + { + SetupFromConfigFile(slot, ignoreCorruptedData); + } /// /// Setup water meter from configuration file: /// -slot, @@ -1159,17 +1185,6 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore } } } - - public void WriteCalibrationTestBench(List results) - { - //todo: convert to CalibrationPoints in L per H - } - - /// - void IMeter.SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData, Boolean useRequest, Boolean useStreaming) - { - SetupFromConfigFile(slot, ignoreCorruptedData); - } #endregion } } diff --git a/Common/Ui/LegacyGenesisControl/PreAdjWr.cs b/Common/Ui/LegacyGenesisControl/PreAdjWr.cs index c95f325d..9a7db70e 100644 --- a/Common/Ui/LegacyGenesisControl/PreAdjWr.cs +++ b/Common/Ui/LegacyGenesisControl/PreAdjWr.cs @@ -65,7 +65,7 @@ namespace XylemCommonUiLegacyGenCtl } else { - MessageBox.Show($"FATAL {ex.Message}"); + MessageBox.Show($"FATAL Ctor {ex.Message}"); } @@ -167,12 +167,16 @@ namespace XylemCommonUiLegacyGenCtl { try { + + if (TestsetuptContainer == null) { TestsetuptContainer = new TestSetupContainer(); TestsetuptContainer.TempSouce = Enums.TempSouceType.PtOverSps; TestsetuptContainer.ProductionMode = false; + TestsetuptContainer.meterTestSettings = new MeterTestSettings[slotCount]; + TestsetuptContainer.meterTestResults = new MeterTestResults[slotCount]; } @@ -217,7 +221,7 @@ namespace XylemCommonUiLegacyGenCtl } Mode = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.Cordonel; - if (TestsetuptContainer.meterTestSettings.All(a => a.meterType == Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.MagFlux)) + if (TestsetuptContainer.meterTestSettings.Any(a => a != null && a.meterType == Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.MagFlux)) { Mode = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.MagFlux; } @@ -226,7 +230,7 @@ namespace XylemCommonUiLegacyGenCtl catch (Exception ex) { _logger.Fatal(ex); - MessageBox.Show($"FATAL {ex.Message}"); + MessageBox.Show($"FATAL internalPrep {ex.Message}"); } } public void PrepareAction(Int32 slotCount, String cultureStr) @@ -244,7 +248,7 @@ namespace XylemCommonUiLegacyGenCtl catch (Exception ex) { _logger.Fatal(ex); - MessageBox.Show($"FATAL {ex.Message}"); + MessageBox.Show($"FATAL EnableMeter {ex.Message}"); } } @@ -276,6 +280,7 @@ namespace XylemCommonUiLegacyGenCtl if (item != null && item.PreAdjustment && item.meterType == MeterTypes.MagFlux) { var newMeter = new MagFluxMeter(); + newMeter.SetupFromConfigFile(item.Slot); newMeter.Login(); newMeter.SerialNumber = item.SerialNr; @@ -301,7 +306,7 @@ namespace XylemCommonUiLegacyGenCtl var c = TestsetuptContainer.meterTestSettings.Count(); TestsetuptContainer.meterTestResults = new MeterTestResults[c]; - for (int i = 0; i <= c; i++) + for (int i = 0; i < c; i++) { TestsetuptContainer.meterTestResults[c] = new MeterTestResults(); TestsetuptContainer.meterTestResults[c].Results = new List(); @@ -325,7 +330,7 @@ namespace XylemCommonUiLegacyGenCtl catch (Exception ex) { _logger.Fatal(ex); - MessageBox.Show($"FATAL {ex.Message}"); + MessageBox.Show($"FATAL Start Action {ex.Message}"); pollingAction = PollingAction.IsOnError; } finally diff --git a/Common/Ui/MagFluxToolBox/FrmTest.cs b/Common/Ui/MagFluxToolBox/FrmTest.cs index dfc03f21..ae972cc4 100644 --- a/Common/Ui/MagFluxToolBox/FrmTest.cs +++ b/Common/Ui/MagFluxToolBox/FrmTest.cs @@ -654,7 +654,7 @@ namespace Xylem.Common.Ui.MagFluxToolBox return; _magFluxMeter?.WriteCalibration(_calibPointsCmPerH); - SetControlsDownloadIsFinished(); + btnReadCalibration_Click(this, null); } private void btnAbortCalibration_Click(Object sender, EventArgs e)