Finish the SM for ctlBatch
This commit is contained in:
@@ -155,7 +155,7 @@
|
||||
</site>
|
||||
<site name="MeterProcessState" id="2">
|
||||
<application path="/" applicationPool="Clr4IntegratedAppPool">
|
||||
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\laa_production\Common\Service\MeterProcessState" />
|
||||
<virtualDirectory path="/" physicalPath="C:\ProgrammeSensus\Repo\Lab\La_Operations\laa_production\Common\Service\MeterProcessState" />
|
||||
</application>
|
||||
<bindings>
|
||||
<binding protocol="http" bindingInformation="*:56011:localhost" />
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
|
||||
46bd00889699f5a20a4981a22f62b66368323855
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
f64d563def603c89cafafa61a3219ba97e1e344c
|
||||
81d60b90addc793525740e9993e19bf6665bd401
|
||||
|
||||
@@ -113,6 +113,10 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
/// <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>
|
||||
/// All parameters has pass to the batch and just witing till mesurement can start
|
||||
/// </summary>
|
||||
void SetReadyForMesuremnt();
|
||||
/// <summary>
|
||||
/// pass informations from current running test point
|
||||
/// </summary>
|
||||
@@ -203,6 +207,22 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
void Dispose(bool fromCode);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Check SM If the State is MessuremntActive
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool MeasurementIsActive();
|
||||
|
||||
/// <summary>
|
||||
/// Check SM If the State is MMeasurementCompleted
|
||||
/// // </summary>
|
||||
/// <returns></returns>
|
||||
bool MeasurementIsCompleted();
|
||||
|
||||
bool MetersArePrepared();
|
||||
|
||||
bool IsReadyForMesuremnt();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
AddMeters,
|
||||
PrepareMeters,
|
||||
MetersPrepared,
|
||||
WaitingForErrorFrame,
|
||||
ReadyForMesuremnt,
|
||||
StartMesurement,
|
||||
StopMesurement,
|
||||
}
|
||||
|
||||
private BatchState _currentState;
|
||||
@@ -202,10 +204,6 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
break;
|
||||
case BatchState.PrepareMeasurement:
|
||||
break;
|
||||
case BatchState.MeasurementActive:
|
||||
break;
|
||||
case BatchState.MeasurementCompleted:
|
||||
break;
|
||||
case BatchState.TestContainerIsReady:
|
||||
break;
|
||||
case BatchState.BatchIsReady:
|
||||
@@ -214,12 +212,29 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
_currentState = AddAllMeters_Internal() ? BatchState.PrepareMeters : BatchState.Error;
|
||||
break;
|
||||
case BatchState.PrepareMeters:
|
||||
_currentState = PrepareMeters_Internal() ? BatchState.WaitingForErrorFrame : BatchState.Error;
|
||||
break;
|
||||
case BatchState.WaitingForErrorFrame:
|
||||
_currentState = PrepareMeters_Internal() ? BatchState.MetersPrepared : BatchState.Error;
|
||||
break;
|
||||
case BatchState.MetersPrepared:
|
||||
//Wait For Caller when every thing is setup
|
||||
break;
|
||||
case BatchState.ReadyForMesuremnt:
|
||||
//Wait for caller to start Mesurment
|
||||
break;
|
||||
case BatchState.StartMesurement:
|
||||
_currentState = StartMeasurement_Internal() ? BatchState.MeasurementActive : BatchState.Error;
|
||||
break;
|
||||
|
||||
case BatchState.MeasurementActive:
|
||||
// wait for singal that the messuremnt can be stopped
|
||||
break;
|
||||
|
||||
case BatchState.StopMesurement:
|
||||
_currentState = StopMeasurement_Internal() ? BatchState.MeasurementCompleted : BatchState.Error;
|
||||
break;
|
||||
case BatchState.MeasurementCompleted:
|
||||
//Measurement waiting for caller to grab all the results
|
||||
break;
|
||||
|
||||
}// lock repeated execution of identical state
|
||||
}
|
||||
}
|
||||
@@ -714,9 +729,14 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
_logger.Error("Test setup container missing");
|
||||
return false;
|
||||
}
|
||||
var listOfTasks = new List<Task>();
|
||||
|
||||
|
||||
foreach (var item in TestSetupContainer.meterTestSettings)
|
||||
{
|
||||
if (item != null && (item.FlowAdjustment || item.FlowTesting))
|
||||
{
|
||||
listOfTasks.Add(new Task(() =>
|
||||
{
|
||||
if (batch.ListOfMeters.All(f => f.Slot != item.Slot))
|
||||
{
|
||||
@@ -732,8 +752,13 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
meter.EnableAutoLogon();
|
||||
meter.WriteLog("Add from AddAllMeters");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
listOfTasks.ForEach(t => t.Start());
|
||||
Task.WaitAll(listOfTasks.ToArray());
|
||||
|
||||
setBusy(false);
|
||||
return true;
|
||||
}
|
||||
@@ -995,7 +1020,7 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
{
|
||||
CalibrationIsDone = new Dictionary<Int32, LegacyCalibrationResult>();
|
||||
}
|
||||
|
||||
var listOfTasks = new List<Task>();
|
||||
foreach (var meter in batch.ListOfMeters)
|
||||
{
|
||||
|
||||
@@ -1018,6 +1043,10 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
|
||||
if (_useRequest)
|
||||
{
|
||||
|
||||
listOfTasks.Add(new Task(() =>
|
||||
{
|
||||
|
||||
((GenesisMeter)meter).ReLogin();
|
||||
((GenesisMeter)meter).WriteLog("Prepare meter for Measurement/Adjustment ");
|
||||
_logger.Debug("Prepare Meters for Measurement/Adjustment");
|
||||
@@ -1029,14 +1058,18 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
{
|
||||
((GenesisMeter)meter).InitMeasurement();
|
||||
}
|
||||
}));
|
||||
//// Reboot, HighPressure
|
||||
////ReadOut Alarms, Show and reset
|
||||
//_logger.Debug($"Start CheckMetersAreReadyForTest");
|
||||
}
|
||||
}
|
||||
|
||||
TryInvoke(new Action(UpdateBatch));
|
||||
|
||||
|
||||
listOfTasks.ForEach(t => t.Start());
|
||||
Task.WaitAll(listOfTasks.ToArray());
|
||||
TryInvoke(new Action(UpdateBatch));
|
||||
CheckMetersAreReadyForTest();
|
||||
setBusy(false);
|
||||
return true;
|
||||
@@ -1079,90 +1112,6 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
|
||||
}
|
||||
|
||||
private void CheckMetersAreReadyForTestStatic()
|
||||
{
|
||||
var listOfTasks = new List<Task>();
|
||||
|
||||
foreach (var meter in batch.ListOfMeters)
|
||||
{
|
||||
listOfTasks.Add(new Task(() =>
|
||||
{
|
||||
if (!(meter is GenesisMeter))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var i = 1;
|
||||
|
||||
var sleepTimeS = 1;
|
||||
_logger.Debug($" Meter {meter.Slot} CheckMetersAreReadyForTest loops {i};delay {sleepTimeS}S");
|
||||
((GenesisMeter)meter).StartMeasurement();
|
||||
var MeterReadyForTest = false;
|
||||
|
||||
|
||||
|
||||
while (i <= 7 && !MeterReadyForTest)
|
||||
{
|
||||
((GenesisMeter)meter).RequestIntermediateMeasurementState(0);
|
||||
Thread.Sleep(i * 2000);
|
||||
i = i + 1;
|
||||
try
|
||||
{
|
||||
var state = ((GenesisMeter)meter).GetMeasurementState(0);
|
||||
|
||||
|
||||
if (state != MeasurementStates.IsWaitingForStartData && state != MeasurementStates.NotStarted)
|
||||
{
|
||||
|
||||
var r = ((GenesisMeter)meter).GetMainMeasurementResult(null, null, true);
|
||||
|
||||
if (r.DutVolumeCm != 0)
|
||||
{
|
||||
_logger.Info($" Meter {meter.Slot} Meter has progress (Volume{r.DutVolumeCm})");
|
||||
|
||||
MeterReadyForTest = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
_logger.Info($" Meter {meter.Slot} Meter no update display; loops left {i}; state {state}");
|
||||
|
||||
}
|
||||
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);
|
||||
}));
|
||||
|
||||
}
|
||||
((GenesisMeter)meter).StopMeasurement();
|
||||
|
||||
if (!MeterReadyForTest)
|
||||
{
|
||||
//todo event remove meter
|
||||
_logger.Info($" Meter {meter.Slot} Meter has NO! progress");
|
||||
TryInvoke(new Action(() =>
|
||||
{
|
||||
updateCell("Status", meter.Slot, "Zählerstand wechsel nicht erfasst", Color.LightPink);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
listOfTasks.ForEach(t => t.Start());
|
||||
Task.WaitAll(listOfTasks.ToArray());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void CheckMetersAreReadyForTest()
|
||||
@@ -1203,13 +1152,14 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
var MeterReadyForTest = false;
|
||||
while (i >= 0)
|
||||
{
|
||||
Thread.Sleep(sleepTimeS * 1000);
|
||||
new System.Threading.ManualResetEvent(false).WaitOne(i * 2000);
|
||||
try
|
||||
{
|
||||
var r = ((GenesisMeter)meter).GetMainMeasurementResult(null, null, true);
|
||||
i -= sleepTimeS;
|
||||
|
||||
if (r.DutVolumeCm != 0.0d)
|
||||
//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(() =>
|
||||
@@ -1256,14 +1206,17 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
|
||||
}
|
||||
|
||||
public void StartMeasurement()
|
||||
public Boolean StartMeasurement_Internal()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
var listOfTasks = new List<Task>();
|
||||
foreach (var item in batch.ListOfMeters)
|
||||
{
|
||||
listOfTasks.Add(new Task(() =>
|
||||
{
|
||||
|
||||
var settings = TestSetupContainer.meterTestSettings.First(f => f != null && f.Slot == item.Slot);
|
||||
|
||||
if (IsAdjustment && settings.FlowAdjustment)
|
||||
@@ -1274,16 +1227,26 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
{
|
||||
item.StartMeasurement();
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
listOfTasks.ForEach(t => t.Start());
|
||||
Task.WaitAll(listOfTasks.ToArray());
|
||||
|
||||
|
||||
currentMode = Mode.AutoRefresh;
|
||||
//this.RefeshTimer.Enabled = true;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "StartMeasurement");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void StartMeasurement()
|
||||
{
|
||||
_currentState = BatchState.StartMesurement;
|
||||
}
|
||||
public void SetLoggerActionText(String ActionText)
|
||||
{
|
||||
@@ -1295,8 +1258,11 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopMeasurement()
|
||||
{
|
||||
_currentState = BatchState.StopMesurement;
|
||||
}
|
||||
public Boolean StopMeasurement_Internal()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1324,13 +1290,10 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
item.StopMeasurement();
|
||||
}
|
||||
}
|
||||
|
||||
var listOfTasks = new List<Task>();
|
||||
foreach (var item in batch.ListOfMeters)
|
||||
{
|
||||
if (item is GenesisMeter gm)
|
||||
{
|
||||
gm.CurrentActionText = "FlowTest";
|
||||
}
|
||||
|
||||
var settings = TestSetupContainer.meterTestSettings.First(f => f != null && f.Slot == item.Slot);
|
||||
|
||||
if (IsAdjustment && !settings.FlowAdjustment)
|
||||
@@ -1345,6 +1308,9 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
|
||||
|
||||
|
||||
listOfTasks.Add(new Task(() =>
|
||||
{
|
||||
|
||||
if (IsAdjustment)
|
||||
{
|
||||
Int32 retrys = 0;
|
||||
@@ -1375,14 +1341,22 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
retrys = retrys + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (item is GenesisMeter gm)
|
||||
{
|
||||
gm.CurrentActionText = "FlowTest";
|
||||
}
|
||||
|
||||
|
||||
}));
|
||||
}
|
||||
listOfTasks.ForEach(t => t.Start());
|
||||
Task.WaitAll(listOfTasks.ToArray());
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "StopMeasurement");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Boolean ICtlBatch.IsBusy()
|
||||
{
|
||||
@@ -2205,5 +2179,29 @@ namespace XylemCommonUiLegacyGenCtl
|
||||
CtlBatchStateMachine();
|
||||
}
|
||||
|
||||
public void SetReadyForMesuremnt()
|
||||
{
|
||||
_currentState = BatchState.ReadyForMesuremnt;
|
||||
}
|
||||
|
||||
public Boolean MeasurementIsActive()
|
||||
{
|
||||
return _currentState == BatchState.MeasurementActive;
|
||||
}
|
||||
|
||||
public Boolean MeasurementIsCompleted()
|
||||
{
|
||||
return _currentState == BatchState.MeasurementCompleted;
|
||||
}
|
||||
|
||||
public Boolean MetersArePrepared()
|
||||
{
|
||||
return _currentState == BatchState.MetersPrepared;
|
||||
}
|
||||
|
||||
public Boolean IsReadyForMesuremnt()
|
||||
{
|
||||
return _currentState == BatchState.ReadyForMesuremnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user