Stand von WE . Prüfung laufen gut

This commit is contained in:
Roland Drabesch
2023-01-06 17:23:32 +01:00
parent ae52e6e258
commit 04b893d79d
5 changed files with 242 additions and 125 deletions
@@ -957,8 +957,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
if (string.IsNullOrEmpty(PcbId)) if (string.IsNullOrEmpty(PcbId))
{ {
//GetPcbId fills the PsbId property //GetPcbId fills the PsbId property
if (string.IsNullOrEmpty(GetPcbId()))
return ""; if (string.IsNullOrEmpty(GetPcbId()) || string.IsNullOrEmpty(PcbId) || PcbId.Length < 8)
{
if (string.IsNullOrEmpty(GetPcbId()))
{
return "";
}
}
} }
url += PcbId; url += PcbId;
@@ -983,12 +991,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
{ {
_logger.Info($"Slot:{Slot} - Cannot get password from GenesisPasswordService, " + _logger.Info($"Slot:{Slot} - Cannot get password from GenesisPasswordService, " +
$"URL({url}), Error({ex.Message})"); $"URL({url}), Error({ex.Message})");
var listOfOfflinePasswords = JsonConvert.DeserializeObject<List<OfflinePasswordItem>>(File.ReadAllText(ProgramConfig.OfflineInfoFile)); if (File.Exists(ProgramConfig.OfflineInfoFile))
password = listOfOfflinePasswords.First(x => x.PcbId == PcbId).Password;
if (!string.IsNullOrEmpty(password))
{ {
_logger.Info($"Slot:{Slot} - Got password from password file!"); var listOfOfflinePasswords = JsonConvert.DeserializeObject<List<OfflinePasswordItem>>(File.ReadAllText(ProgramConfig.OfflineInfoFile));
password = listOfOfflinePasswords.First(x => x.PcbId == PcbId).Password;
if (!string.IsNullOrEmpty(password))
{
_logger.Info($"Slot:{Slot} - Got password from password file!");
}
} }
password = "";
} }
return password; return password;
@@ -1003,7 +1017,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
if (string.IsNullOrEmpty(_password) || string.IsNullOrEmpty(PcbId)) if (string.IsNullOrEmpty(_password) || string.IsNullOrEmpty(PcbId))
{ {
var password = GetPassword(); var password = GetPassword();
return !string.IsNullOrEmpty(password) && Login(password); if (string.IsNullOrEmpty(password))
{
return false;
}
return Login(password);
} }
return Login(_password); return Login(_password);
+58 -4
View File
@@ -31,6 +31,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.txtPcbId = new System.Windows.Forms.TextBox(); this.txtPcbId = new System.Windows.Forms.TextBox();
this.btnLoadHistory = new System.Windows.Forms.Button(); this.btnLoadHistory = new System.Windows.Forms.Button();
@@ -98,6 +104,14 @@ namespace Xylem.Common.Ui.GenesisToolBox
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.dgvCalibrationResults.AutoGenerateColumns = false; this.dgvCalibrationResults.AutoGenerateColumns = false;
this.dgvCalibrationResults.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; this.dgvCalibrationResults.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvCalibrationResults.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.dgvCalibrationResults.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvCalibrationResults.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvCalibrationResults.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dgvCalibrationResults.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dbIdDataGridViewTextBoxColumn, this.dbIdDataGridViewTextBoxColumn,
@@ -118,12 +132,28 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.toFTempOffset3DataGridViewTextBoxColumn, this.toFTempOffset3DataGridViewTextBoxColumn,
this.dateDataGridViewTextBoxColumn}); this.dateDataGridViewTextBoxColumn});
this.dgvCalibrationResults.DataSource = this.calibrationResultBindingSource; this.dgvCalibrationResults.DataSource = this.calibrationResultBindingSource;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvCalibrationResults.DefaultCellStyle = dataGridViewCellStyle2;
this.dgvCalibrationResults.Location = new System.Drawing.Point(12, 45); this.dgvCalibrationResults.Location = new System.Drawing.Point(12, 45);
this.dgvCalibrationResults.MultiSelect = false; this.dgvCalibrationResults.MultiSelect = false;
this.dgvCalibrationResults.Name = "dgvCalibrationResults"; this.dgvCalibrationResults.Name = "dgvCalibrationResults";
this.dgvCalibrationResults.ReadOnly = true; this.dgvCalibrationResults.ReadOnly = true;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvCalibrationResults.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.dgvCalibrationResults.RowHeadersVisible = false; this.dgvCalibrationResults.RowHeadersVisible = false;
this.dgvCalibrationResults.Size = new System.Drawing.Size(1684, 150); this.dgvCalibrationResults.Size = new System.Drawing.Size(1516, 150);
this.dgvCalibrationResults.TabIndex = 6; this.dgvCalibrationResults.TabIndex = 6;
this.dgvCalibrationResults.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCalibrationResults_CellClick); this.dgvCalibrationResults.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCalibrationResults_CellClick);
this.dgvCalibrationResults.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCalibrationResults_CellContentClick); this.dgvCalibrationResults.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCalibrationResults_CellContentClick);
@@ -266,7 +296,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
// //
// calibrationResultBindingSource // calibrationResultBindingSource
// //
this.calibrationResultBindingSource.DataSource = typeof(CalibrationResult); this.calibrationResultBindingSource.DataSource = typeof(Logic.ProductionToProductMapper.Cordonel.CalibrationResult);
// //
// dgvAdditionalLoginfo // dgvAdditionalLoginfo
// //
@@ -276,17 +306,41 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.dgvAdditionalLoginfo.AllowUserToResizeRows = false; this.dgvAdditionalLoginfo.AllowUserToResizeRows = false;
this.dgvAdditionalLoginfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.dgvAdditionalLoginfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvAdditionalLoginfo.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.dgvAdditionalLoginfo.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvAdditionalLoginfo.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvAdditionalLoginfo.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dgvAdditionalLoginfo.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID, this.ID,
this.Key, this.Key,
this.Text}); this.Text});
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvAdditionalLoginfo.DefaultCellStyle = dataGridViewCellStyle5;
this.dgvAdditionalLoginfo.Location = new System.Drawing.Point(15, 212); this.dgvAdditionalLoginfo.Location = new System.Drawing.Point(15, 212);
this.dgvAdditionalLoginfo.MultiSelect = false; this.dgvAdditionalLoginfo.MultiSelect = false;
this.dgvAdditionalLoginfo.Name = "dgvAdditionalLoginfo"; this.dgvAdditionalLoginfo.Name = "dgvAdditionalLoginfo";
this.dgvAdditionalLoginfo.ReadOnly = true; this.dgvAdditionalLoginfo.ReadOnly = true;
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvAdditionalLoginfo.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
this.dgvAdditionalLoginfo.RowHeadersVisible = false; this.dgvAdditionalLoginfo.RowHeadersVisible = false;
this.dgvAdditionalLoginfo.Size = new System.Drawing.Size(1681, 150); this.dgvAdditionalLoginfo.Size = new System.Drawing.Size(1513, 150);
this.dgvAdditionalLoginfo.TabIndex = 7; this.dgvAdditionalLoginfo.TabIndex = 7;
// //
// ID // ID
@@ -311,7 +365,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1708, 450); this.ClientSize = new System.Drawing.Size(1540, 450);
this.Controls.Add(this.dgvAdditionalLoginfo); this.Controls.Add(this.dgvAdditionalLoginfo);
this.Controls.Add(this.dgvCalibrationResults); this.Controls.Add(this.dgvCalibrationResults);
this.Controls.Add(this.btnLoadHistory); this.Controls.Add(this.btnLoadHistory);
+1 -1
View File
@@ -374,7 +374,7 @@ namespace GenesisToolBox
isMeasurement = false; isMeasurement = false;
} }
controlBatch.PrepareMeters("50", 12, 1, 60, 1.7, !isMeasurement, true); //controlBatch.PrepareMeters("50", 12, 1, 60, 1.7, !isMeasurement, true);
} }
catch (Exception ex) catch (Exception ex)
{ {
+11 -12
View File
@@ -49,12 +49,22 @@ namespace XylemCommonUiLegacyGenCtl
/// <summary> /// <summary>
/// Add all meters from a TestSetupContainer to the Bach an do general preparations (setup and login) /// Add all meters from a TestSetupContainer to the Bach an do general preparations (setup and login)
/// Set Meters in test mode an delay till all meters have a flow detected
/// First call for every TestPOINT (Prüfpunkt) /// First call for every TestPOINT (Prüfpunkt)
/// Required that a TestContainer is present <see cref="SetTestSetupContainer"/> /// Required that a TestContainer is present <see cref="SetTestSetupContainer"/>
/// If no TestSetupContainer is present you could use <see cref="AddMeter"/> /// If no TestSetupContainer is present you could use <see cref="AddMeter"/>
///
/// </summary> /// </summary>
void AddAllMeters(); /// <param name="meterDn"> only for GUI -> size of the pipe</param>
/// <param name="refPulseValence">only for GUI -> </param>
/// <param name="predictedQFlow">only for GUI -> </param>
/// <param name="predictedTs">only for GUI -> </param>
/// <param name="refError">only for GUI -> </param>
/// <param name="isAdjustment">if this test point is an calibration (other test mode) </param>
/// <param name="IsFlyingStartStop">Just for logging (Test run against scale or ref meter)</param>
void AddAllMeters(string meterDn = "-", double refPulseValence = 0.0, double predictedQFlow = 0.0, double predictedTs = 0.0, double refError = 0.0, bool isAdjustment = false, bool IsFlyingStartStop = true);
/// <summary> /// <summary>
/// Add a meter to the batch and control, possibly obsolete (used only on TBF) /// Add a meter to the batch and control, possibly obsolete (used only on TBF)
/// </summary> /// </summary>
@@ -101,17 +111,6 @@ namespace XylemCommonUiLegacyGenCtl
void SetErrorFrame(int slot, double errorFrame = 0.0); void SetErrorFrame(int slot, double errorFrame = 0.0);
/// <summary>
/// Set Meters in test mode an delay till all meters have a flow detected
/// </summary>
/// <param name="meterDn"> only for GUI -> size of the pipe</param>
/// <param name="refPulseValence">only for GUI -> </param>
/// <param name="predictedQFlow">only for GUI -> </param>
/// <param name="predictedTs">only for GUI -> </param>
/// <param name="refError">only for GUI -> </param>
/// <param name="isAdjustment">if this test point is an calibration (other test mode) </param>
/// <param name="IsFlyingStartStop">Just for logging (Test run against scale or ref meter)</param>
void PrepareMeters(string meterDn = "-", double refPulseValence = 0.0, double predictedQFlow = 0.0, double predictedTs = 0.0, double refError = 0.0, bool isAdjustment = false, bool IsFlyingStartStop = true);
/// <summary> /// <summary>
/// All parameters has pass to the batch and just witing till mesurement can start /// All parameters has pass to the batch and just witing till mesurement can start
+147 -101
View File
@@ -191,6 +191,7 @@ namespace XylemCommonUiLegacyGenCtl
{ {
// this loop calls the function and assigns the return states on success and error // this loop calls the function and assigns the return states on success and error
// remind backup state to avoid repeated execution and side effects // remind backup state to avoid repeated execution and side effects
_logger.Info($"StateMachine has change from {_backupState} to {_currentState}");
_backupState = _currentState; _backupState = _currentState;
switch (_currentState) switch (_currentState)
{ {
@@ -227,7 +228,7 @@ namespace XylemCommonUiLegacyGenCtl
case BatchState.MeasurementActive: case BatchState.MeasurementActive:
// wait for singal that the messuremnt can be stopped // wait for singal that the messuremnt can be stopped
break; break;
case BatchState.StopMesurement: case BatchState.StopMesurement:
_currentState = StopMeasurement_Internal() ? BatchState.MeasurementCompleted : BatchState.Error; _currentState = StopMeasurement_Internal() ? BatchState.MeasurementCompleted : BatchState.Error;
break; break;
@@ -740,17 +741,32 @@ namespace XylemCommonUiLegacyGenCtl
{ {
if (batch.ListOfMeters.All(f => f.Slot != item.Slot)) if (batch.ListOfMeters.All(f => f.Slot != item.Slot))
{ {
var meter = new GenesisMeter(); var meter = new GenesisMeter();
meter.SerialNumber = item.SerialNr; try
meter.CurrentActionText = "FlowTest"; {
meter.SetupFromConfigFile(item.Slot, false, _useRequest, true);
meter.LogRawData(_rawLogging); 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 = true;
meter.WriteLog("Add from AddAllMeters");
}
catch (Exception ex)
{
meter.WriteLog(ex.Message);
}
batch.AddMeter(meter);
meter.Login();
meter.EnableAutoLogon();
meter.WriteLog("Add from AddAllMeters");
} }
})); }));
} }
@@ -770,12 +786,37 @@ namespace XylemCommonUiLegacyGenCtl
} }
} }
public void AddAllMeters() public void AddAllMeters(String meterDn = "-", Double refPulseValence = 0.0, Double predictedQFlow = 0.0,
Double predictedTs = 0.0, Double refError = 0.0, Boolean isAdjustment = false, Boolean isFlyingStartStop = true)
{ {
_currentState = BatchState.AddMeters; try
setBusy(true, "alle Zähler hinzufügen"); {
setBusy(true, "alle Zähler hinzufügen");
IsFlyingStartStop = isFlyingStartStop;
_logger.Trace($"Start PrepareMeters(meterDn={meterDn},refPulseValence={refPulseValence}," +
$"predictedQFlow ={predictedQFlow},predictedTs={predictedTs},refError={refError}," +
$"isAdjustment={isAdjustment},IsFlyingStartStop={IsFlyingStartStop}");
WarningMetersAlarms = new ConcurrentDictionary<Int32, GenesisMeter.Alarm>();
ErrorMetersAlarms = new ConcurrentDictionary<Int32, GenesisMeter.Alarm>();
initAction(meterDn, refPulseValence, predictedQFlow, predictedTs, refError, isFlyingStartStop);
IsAdjustment = isAdjustment;
_currentState = BatchState.AddMeters;
}
catch (Exception ex)
{
_logger.Error(ex, $"error at PrepareMeters(meterDn={meterDn},refPulseValence={refPulseValence}," +
$"predictedQFlow ={predictedQFlow},predictedTs={predictedTs},refError={refError}," +
$"isAdjustment={isAdjustment},IsFlyingStartStop={IsFlyingStartStop}");
}
} }
public void AddMeter(String serialNumber, Int32 slot, Boolean SkipPrepearation) public void AddMeter(String serialNumber, Int32 slot, Boolean SkipPrepearation)
{ {
try try
@@ -1016,6 +1057,7 @@ namespace XylemCommonUiLegacyGenCtl
{ {
try try
{ {
setBusy(true, "Bereite Zähler vor");
if (IsAdjustment) if (IsAdjustment)
{ {
CalibrationIsDone = new Dictionary<Int32, LegacyCalibrationResult>(); CalibrationIsDone = new Dictionary<Int32, LegacyCalibrationResult>();
@@ -1084,133 +1126,129 @@ namespace XylemCommonUiLegacyGenCtl
} }
} }
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
{
IsFlyingStartStop = isFlyingStartStop;
_logger.Trace($"Start PrepareMeters(meterDn={meterDn},refPulseValence={refPulseValence}," +
$"predictedQFlow ={predictedQFlow},predictedTs={predictedTs},refError={refError}," +
$"isAdjustment={isAdjustment},IsFlyingStartStop={IsFlyingStartStop}");
WarningMetersAlarms = new ConcurrentDictionary<Int32, GenesisMeter.Alarm>();
ErrorMetersAlarms = new ConcurrentDictionary<Int32, GenesisMeter.Alarm>();
setBusy(true, "Bereite Zähler vor");
initAction(meterDn, refPulseValence, predictedQFlow, predictedTs, refError, isFlyingStartStop);
IsAdjustment = isAdjustment;
}
catch (Exception ex)
{
_logger.Error(ex, $"error at PrepareMeters(meterDn={meterDn},refPulseValence={refPulseValence}," +
$"predictedQFlow ={predictedQFlow},predictedTs={predictedTs},refError={refError}," +
$"isAdjustment={isAdjustment},IsFlyingStartStop={IsFlyingStartStop}");
}
}
private void CheckMetersAreReadyForTest() private void CheckMetersAreReadyForTest()
{ {
_logger.Trace("CheckMetersAreReadyForTest"); _logger.Trace("CheckMetersAreReadyForTest");
TryInvoke(new Action(() =>
{
lblAction.Text = @"Warte auf Zählerstand wechsel von allen Zählern";
})); try
var listOfTasks = new List<Task>();
foreach (var meter in batch.ListOfMeters)
{ {
if (!(meter is GenesisMeter))
{
continue;
}
TryInvoke(new Action(() => TryInvoke(new Action(() =>
{ {
lblAction.Text = @"Warte auf Zählerstand wechsel von allen Zählern";
updateCell("Status", meter.Slot, "Warte auf Zählerstand wechsel", Color.LightYellow);
})); }));
var listOfTasks = new List<Task>();
listOfTasks.Add(new Task(() => listOfTasks.Add(new Task(() =>
{ {
var i = 120; var SlotsWithoutProgress = new List<int>();
var TotalTimeForCheck = 65;
var sleepTimeS = 5; var sleepTimeS = 5;
_logger.Debug($" Meter {meter.Slot} CheckMetersAreReadyForTest loops {i};delay {sleepTimeS}S");
((GenesisMeter)meter).StartMeasurement(); foreach (var meter in batch.ListOfMeters)
var MeterReadyForTest = false;
while (i >= 0)
{ {
new System.Threading.ManualResetEvent(false).WaitOne(i * 2000); if (!(meter is GenesisMeter))
try
{ {
var r = ((GenesisMeter)meter).GetMainMeasurementResult(null, null, true); continue;
i -= sleepTimeS;
//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}");
TryInvoke(new Action(() =>
{
// updateCell($"Status", meter.Slot, $"Zählerstand wechsel erfasst Von:{r.DutStartRecord.GetVolumeCm()} Auf: {r.DutStopRecord.GetVolumeCm()}", Color.LimeGreen);
}));
MeterReadyForTest = true;
break;
}
_logger.Info($" Meter {meter.Slot} display frozen {r.DutVolumeCm} ccm; loops left {i} s");
} }
catch (Exception ex) _logger.Debug($" Meter {meter.Slot} CheckMetersAreReadyForTest loops {TotalTimeForCheck};delay {sleepTimeS}S");
{ ((GenesisMeter)meter).StartMeasurement();
_logger.Error(ex, $" Meter {meter.Slot} Meter has progress error");
} SlotsWithoutProgress.Add(((GenesisMeter)meter).Slot);
TryInvoke(new Action(() =>
{
updateCell("Status", meter.Slot, "Warte auf Zählerstand wechsel ", Color.LightYellow);
}));
} }
((GenesisMeter)meter).StopMeasurement();
if (MeterReadyForTest) 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())
{ {
_logger.Info($" Meter {meter.Slot} Meter has NO! progress"); Thread.Sleep(sleepTimeS * 1000);
TryInvoke(new Action(() => TotalTimeForCheck -= sleepTimeS;
foreach (var meter in batch.ListOfMeters)
{ {
updateCell("Status", meter.Slot, "Zählerstand wechsel nicht erfasst", Color.LightPink); try
})); {
if (SlotsWithoutProgress.Contains(meter.Slot))
{
try
{
var r = ((GenesisMeter)meter).GetMainMeasurementResult(null, null, true);
//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();
SlotsWithoutProgress.Remove(meter.Slot);
}
_logger.Info($" Meter {meter.Slot} display frozen {r.DutVolumeCm} ccm; loops left {TotalTimeForCheck} s");
}
catch (Exception ex)
{
if (ex is ApplicationException aex && aex.Message.Contains("Measurement records missing"))
{
_logger.Info($" Meter {meter.Slot} display frozen record is missing; loops left {TotalTimeForCheck} s");
}
else
{
_logger.Info($" Meter {meter.Slot} display frozen record is missing; loops left {TotalTimeForCheck} s");
_logger.Error(ex);
}
}
}
}
catch (Exception ex)
{
_logger.Error(ex, $" Meter {meter.Slot} Meter has progress error");
}
}
}
if (SlotsWithoutProgress.Any())
{
foreach (var item in SlotsWithoutProgress)
{
_logger.Warn($"Slot {item} has no progress");
}
}
else
{
_logger.Debug($"All Meters have progress");
} }
})); }));
listOfTasks.ForEach(t => t.Start());
Task.WaitAll(listOfTasks.ToArray());
}
catch (Exception ex)
{
_logger.Error(ex);
//in case something went wrong this check can be skip
} }
listOfTasks.ForEach(t => t.Start());
Task.WaitAll(listOfTasks.ToArray());
} }
public Boolean StartMeasurement_Internal() public Boolean StartMeasurement_Internal()
{ {
try try
{ {
_logger.Debug($"StartMesurment from state machien");
var listOfTasks = new List<Task>(); var listOfTasks = new List<Task>();
foreach (var item in batch.ListOfMeters) foreach (var item in batch.ListOfMeters)
{ {
@@ -1246,6 +1284,7 @@ namespace XylemCommonUiLegacyGenCtl
public void StartMeasurement() public void StartMeasurement()
{ {
_logger.Info("Caller start Measurement");
_currentState = BatchState.StartMesurement; _currentState = BatchState.StartMesurement;
} }
public void SetLoggerActionText(String ActionText) public void SetLoggerActionText(String ActionText)
@@ -1260,6 +1299,7 @@ namespace XylemCommonUiLegacyGenCtl
} }
public void StopMeasurement() public void StopMeasurement()
{ {
_logger.Info("Caller stop Measurement");
_currentState = BatchState.StopMesurement; _currentState = BatchState.StopMesurement;
} }
public Boolean StopMeasurement_Internal() public Boolean StopMeasurement_Internal()
@@ -1267,7 +1307,7 @@ namespace XylemCommonUiLegacyGenCtl
try try
{ {
var nrOfRetrys = 40; var nrOfRetrys = 40;
_logger.Info("SM Call StopMeasurement_Internal");
foreach (var item in batch.ListOfMeters) foreach (var item in batch.ListOfMeters)
{ {
var settings = TestSetupContainer.meterTestSettings.First(f => f != null && f.Slot == item.Slot); var settings = TestSetupContainer.meterTestSettings.First(f => f != null && f.Slot == item.Slot);
@@ -1290,6 +1330,7 @@ namespace XylemCommonUiLegacyGenCtl
item.StopMeasurement(); item.StopMeasurement();
} }
} }
_logger.Info("All Meters Stopped");
var listOfTasks = new List<Task>(); var listOfTasks = new List<Task>();
foreach (var item in batch.ListOfMeters) foreach (var item in batch.ListOfMeters)
{ {
@@ -2181,26 +2222,31 @@ namespace XylemCommonUiLegacyGenCtl
public void SetReadyForMesuremnt() public void SetReadyForMesuremnt()
{ {
_logger.Debug($"Caller set batch state to state ReadyForMesuremnt");
_currentState = BatchState.ReadyForMesuremnt; _currentState = BatchState.ReadyForMesuremnt;
} }
public Boolean MeasurementIsActive() public Boolean MeasurementIsActive()
{ {
_logger.Debug($"Caller MeasurementIsActive state is{_currentState}");
return _currentState == BatchState.MeasurementActive; return _currentState == BatchState.MeasurementActive;
} }
public Boolean MeasurementIsCompleted() public Boolean MeasurementIsCompleted()
{ {
_logger.Debug($"Caller MeasurementIsCompleted state is{_currentState}");
return _currentState == BatchState.MeasurementCompleted; return _currentState == BatchState.MeasurementCompleted;
} }
public Boolean MetersArePrepared() public Boolean MetersArePrepared()
{ {
_logger.Debug($"Caller MetersArePrepared state is{_currentState}");
return _currentState == BatchState.MetersPrepared; return _currentState == BatchState.MetersPrepared;
} }
public Boolean IsReadyForMesuremnt() public Boolean IsReadyForMesuremnt()
{ {
_logger.Debug($"Caller IsReadyForMesuremnt state is{_currentState}");
return _currentState == BatchState.ReadyForMesuremnt; return _currentState == BatchState.ReadyForMesuremnt;
} }
} }