From e193b2e07734eb48c12d97413e1f7b1567705b93 Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Tue, 3 Jan 2023 11:57:26 +0100 Subject: [PATCH] ReSharper: -LegacyGenesisControl\ctlBatch - Part 3 --- Common/Ui/LegacyGenesisControl/ctlBatch.cs | 104 +++++++++++---------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/Common/Ui/LegacyGenesisControl/ctlBatch.cs b/Common/Ui/LegacyGenesisControl/ctlBatch.cs index f55a8761..ecf3db50 100644 --- a/Common/Ui/LegacyGenesisControl/ctlBatch.cs +++ b/Common/Ui/LegacyGenesisControl/ctlBatch.cs @@ -105,7 +105,10 @@ namespace XylemCommonUiLegacyGenCtl private DataTable dtBatch; #region busy - public Boolean IsBusy { get; private set; } + public Boolean IsBusy + { + get; private set; + } private Int32? ProgressTotal; private Int32? ProgressCurrent; @@ -114,8 +117,11 @@ namespace XylemCommonUiLegacyGenCtl private Dictionary slotLut = new Dictionary(); private Dictionary slotPreadjustment = new Dictionary(); private Dictionary> labelValueCollection; - - public Boolean IsFlyingStartStop { get; private set; } + + public Boolean IsFlyingStartStop + { + get; private set; + } private Double StoreRefVolume, StoreTestTimeRef; @@ -128,7 +134,7 @@ namespace XylemCommonUiLegacyGenCtl { _logger = NLogHelper.CreateOrGetMultiLogger("ctlBatch", "", "Batch", "", ""); - _logger.Info($"start construct ctlBatch"); + _logger.Info("start construct ctlBatch"); //RefreshTimerWatch.Enabled = true; //RefreshTimerWatch.Interval = 5000; //RefreshTimerWatch.Tick += RefreshTimerWatch_Tick; @@ -142,10 +148,10 @@ namespace XylemCommonUiLegacyGenCtl //kick off the state machine _currentState = BatchState.Init; _backupState = BatchState.Idle; - _logger.Info($"construct ctlBatch end"); + _logger.Info("construct ctlBatch end"); } - + private void CtlBatch_Disposed(Object sender, EventArgs e) { try @@ -155,7 +161,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error at CtlBatch_Disposed"); + _logger.Error(ex, "error at CtlBatch_Disposed"); } } #endregion @@ -297,8 +303,11 @@ namespace XylemCommonUiLegacyGenCtl { try { - TryInvoke(new Action(() => { probarBusy.Value = (Int32)Math.Round( - ProgressCurrent.Value / (Double)ProgressTotal.Value * 100, 0); })); + TryInvoke(new Action(() => + { + probarBusy.Value = (Int32)Math.Round( + ProgressCurrent.Value / (Double)ProgressTotal.Value * 100, 0); + })); } catch (Exception exception) @@ -356,7 +365,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error at RefreshTimerWatch_Tick()"); + _logger.Error(ex, "error at RefreshTimerWatch_Tick()"); } } @@ -513,7 +522,7 @@ namespace XylemCommonUiLegacyGenCtl } private T getCellValue(String Row, Int32 Slot) { - if (dgvBatch != null && dgvBatch.Rows.Count > rowIndex.First(k => k.Value == Row).Key + if (dgvBatch != null && dgvBatch.Rows.Count > rowIndex.First(k => k.Value == Row).Key && dgvBatch.Rows[rowIndex.First(k => k.Value == Row).Key].Cells.Count > Slot) { var currentRowIndex = rowIndex.First(k => k.Value == Row).Key; @@ -924,7 +933,7 @@ namespace XylemCommonUiLegacyGenCtl { try { - setBusy(true, $"Setze Fehlergrenze"); + setBusy(true, "Setze Fehlergrenze"); updateCell("Fehlergrenze [%]", slot, errorFrame); if (slotErrorFrameDic.ContainsKey(slot)) @@ -957,7 +966,7 @@ namespace XylemCommonUiLegacyGenCtl } } - public void PrepareMeters(String meterDn = "-", Double refPulseValence = 0.0, Double predictedQFlow = 0.0, + public void PrepareMeters(String meterDn = "-", Double refPulseValence = 0.0, Double predictedQFlow = 0.0, Double predictedTs = 0.0, Double refError = 0.0, Boolean isAdjustment = false, Boolean isFlyingStartStop = true) { try @@ -968,7 +977,7 @@ namespace XylemCommonUiLegacyGenCtl $"isAdjustment={isAdjustment},IsFlyingStartStop={IsFlyingStartStop}"); WarningMetersAlarms = new ConcurrentDictionary(); ErrorMetersAlarms = new ConcurrentDictionary(); - setBusy(true, $"Bereite Zähler vor"); + setBusy(true, "Bereite Zähler vor"); initAction(meterDn, refPulseValence, predictedQFlow, predictedTs, refError, isFlyingStartStop); _isAdjustment = isAdjustment; @@ -1003,9 +1012,9 @@ namespace XylemCommonUiLegacyGenCtl if (_useRequest) { - var r = ((GenesisMeter)meter).ReLogin(); + ((GenesisMeter)meter).ReLogin(); ((GenesisMeter)meter).WriteLog("Prepare meter for Measurement/Adjustment "); - _logger.Debug($"Prepare Meters for Measurement/Adjustment"); + _logger.Debug("Prepare Meters for Measurement/Adjustment"); if (isAdjustment) { ((GenesisMeter)meter).InitCalibration(); @@ -1020,10 +1029,7 @@ namespace XylemCommonUiLegacyGenCtl } } - TryInvoke(new Action(() => - { - UpdateBatch(); - })); + TryInvoke(new Action(UpdateBatch)); CheckMetersAreReadyForTest(); setBusy(false); @@ -1088,16 +1094,16 @@ namespace XylemCommonUiLegacyGenCtl _logger.Info($" Meter {meter.Slot} Meter no update display; loops left {i}; state {state}"); } - catch (Exception) + catch (Exception ex) { - + _logger.Error(ex, $" Meter {meter.Slot} CheckMetersAreReadyForTest loops {i};delay {sleepTimeS}S"); } TryInvoke(new Action(() => { - updateCell($"Status", meter.Slot, $"Warte auf Zählerstand wechsel ", Color.LightYellow); + updateCell("Status", meter.Slot, "Warte auf Zählerstand wechsel ", Color.LightYellow); })); } @@ -1109,7 +1115,7 @@ namespace XylemCommonUiLegacyGenCtl _logger.Info($" Meter {meter.Slot} Meter has NO! progress"); TryInvoke(new Action(() => { - updateCell($"Status", meter.Slot, $"Zählerstand wechsel nicht erfasst", Color.LightPink); + updateCell("Status", meter.Slot, "Zählerstand wechsel nicht erfasst", Color.LightPink); })); } @@ -1127,10 +1133,10 @@ namespace XylemCommonUiLegacyGenCtl private void CheckMetersAreReadyForTest() { - _logger.Trace($"CheckMetersAreReadyForTest"); + _logger.Trace("CheckMetersAreReadyForTest"); TryInvoke(new Action(() => { - lblAction.Text = "Warte auf Zählerstand wechsel von allen Zählern"; + lblAction.Text = @"Warte auf Zählerstand wechsel von allen Zählern"; })); @@ -1143,16 +1149,13 @@ namespace XylemCommonUiLegacyGenCtl if (!(meter is GenesisMeter)) { - if (!(meter is GenesisMeter)) - { - continue; - } + continue; } TryInvoke(new Action(() => { - updateCell($"Status", meter.Slot, $"Warte auf Zählerstand wechsel", Color.LightYellow); + updateCell("Status", meter.Slot, "Warte auf Zählerstand wechsel", Color.LightYellow); })); @@ -1170,8 +1173,9 @@ namespace XylemCommonUiLegacyGenCtl try { var r = ((GenesisMeter)meter).GetMainMeasurementResult(null, null, true); - i = i - sleepTimeS; - if (r.DutVolumeCm != 0) + i -= sleepTimeS; + + if (r.DutVolumeCm != 0.0d) { _logger.Info($" Meter {meter.Slot} Meter has progress {r.DutVolumeCm}"); TryInvoke(new Action(() => @@ -1181,13 +1185,11 @@ namespace XylemCommonUiLegacyGenCtl MeterReadyForTest = true; break; } - else - { - _logger.Info($" Meter {meter.Slot} Meter no update display {r.DutVolumeCm}; loops left {i}"); - } + _logger.Info($" Meter {meter.Slot} display frozen {r.DutVolumeCm} ccm; loops left {i} s"); } - catch (Exception) + catch (Exception ex) { + _logger.Error(ex, $" Meter {meter.Slot} Meter has progress error"); } @@ -1195,7 +1197,7 @@ namespace XylemCommonUiLegacyGenCtl TryInvoke(new Action(() => { - updateCell($"Status", meter.Slot, $"Warte auf Zählerstand wechsel ", Color.LightYellow); + updateCell("Status", meter.Slot, "Warte auf Zählerstand wechsel ", Color.LightYellow); })); } @@ -1206,7 +1208,7 @@ namespace XylemCommonUiLegacyGenCtl _logger.Info($" Meter {meter.Slot} Meter has NO! progress"); TryInvoke(new Action(() => { - updateCell($"Status", meter.Slot, $"Zählerstand wechsel nicht erfasst", Color.LightPink); + updateCell("Status", meter.Slot, "Zählerstand wechsel nicht erfasst", Color.LightPink); })); } @@ -1293,7 +1295,7 @@ namespace XylemCommonUiLegacyGenCtl { if (item is GenesisMeter gm) { - gm.CurrentActionText = $"FlowTest"; + gm.CurrentActionText = "FlowTest"; } var settings = TestSetupContainer.meterTestSettings.First(f => f != null && f.Slot == item.Slot); @@ -1446,7 +1448,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error on GetCalibrationIsDone"); + _logger.Error(ex, "error on GetCalibrationIsDone"); return LegacyCalibrationResult.CheckAllMeters; } @@ -1473,7 +1475,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error on GetCalibrationIsDone"); + _logger.Error(ex, "error on GetCalibrationIsDone"); return LegacyCalibrationResult.CheckAllMeters; } } @@ -1526,7 +1528,7 @@ namespace XylemCommonUiLegacyGenCtl updateCell("Einbauplatz", Slot, Slot.ToString()); updateCell("Seriennummer", Slot, SerialNumber); updateCell("PcbId", Slot, PcbId); - + TryInvoke(new Action(() => { dgvBatch.Columns[Slot].Visible = true; @@ -1568,7 +1570,7 @@ namespace XylemCommonUiLegacyGenCtl // } //} - private void initAction(String meterDn = "-", Double refPulseValence = 0, Double predictedQFlow = 0, + private void initAction(String meterDn = "-", Double refPulseValence = 0, Double predictedQFlow = 0, Double predictedTs = 0, Double refError = 0, Boolean isFlyingStartStop = true) { TryInvoke(new Action(() => @@ -1599,7 +1601,7 @@ namespace XylemCommonUiLegacyGenCtl } - public void Init(String meterDn = "-", Double refPulseValence = 0, Double predictedQFlow = 0, Double predictedTs = 0, + public void Init(String meterDn = "-", Double refPulseValence = 0, Double predictedQFlow = 0, Double predictedTs = 0, Double refError = 0, Boolean isFlyingStartStop = true) { try @@ -1664,7 +1666,7 @@ namespace XylemCommonUiLegacyGenCtl if ((_isAdjustment && !settings.FlowAdjustment) || (!_isAdjustment && !settings.FlowTesting)) { - updateCell($"Status", item.Slot, "-", Color.Gray); + updateCell("Status", item.Slot, "-", Color.Gray); continue; } @@ -1696,7 +1698,7 @@ namespace XylemCommonUiLegacyGenCtl break; } - updateCell($"Status", _meter.Slot, textState, statusColor); + updateCell("Status", _meter.Slot, textState, statusColor); Double? testTime = null; if (IsFlyingStartStop) { @@ -1818,7 +1820,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error on Clear()"); + _logger.Error(ex, "error on Clear()"); } @@ -1852,7 +1854,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error on ManuleUpdate()"); + _logger.Error(ex, "error on ManuleUpdate()"); } } @@ -1981,7 +1983,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - _logger.Error(ex, $"error on btnOk_Click()"); + _logger.Error(ex, "error on btnOk_Click()"); } } private void btnUpdate_Click(Object sender, EventArgs e)