ProductionUiCordonel: -automatic mode

This commit is contained in:
Thomas Wiedebusch
2025-07-07 15:46:02 +02:00
parent 3cb609580b
commit 8c895bdcde
3 changed files with 38 additions and 20 deletions
@@ -34,7 +34,7 @@
<appSettings>
<add key="Mode" value="1" /> <!--1 = EOL ; 2 = Picking-->
<add key="Mode" value="2" /> <!--1 = EOL ; 2 = Picking-->
<add key="SirtComport433" value="14" /> <!--Individual for Thomas 14-->
<add key="SirtComport868" value="15" /> <!--Individual for Thomas 15-->
<add key="SirtBoxNr" value="2" /> <!--Roland and Thomas, box for development, box at shipping station is 1-->
@@ -83,10 +83,14 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Picki
ucBarCode.OnBarcodeInput -= UserControlInput_Handler;
if (!string.IsNullOrEmpty(_scan) && _scan.Length > 5)
if (!string.IsNullOrEmpty(_scan) && _scan.Length > 6)
{
//TODO Roland, Do something with the scanned order
return StatusReturn.Okay;
if (int.TryParse(_scan, out var result))
{
Meter.OrderNumber = result;
return StatusReturn.Okay;
}
}
ErrorMsgDispatcher(Resources.StrErrorMsgScanOrderNumber);
@@ -314,12 +314,12 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
}
else
{
// ATTENTION: Has to be the very first step here!
// Remind backup state to avoid repeated execution and side effects
_lockedStateMachineState = _stateMachineState;
try
{
// ATTENTION: Has to be the very first step here!
// Remind backup state to avoid repeated execution and side effects
_lockedStateMachineState = _stateMachineState;
// Signal overall process progress to GUI based on ready processes
CalcAndPushOverAllProgress();
@@ -330,15 +330,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
var startProcessState = _processStateDef.GetStateOfFirstProcess();
if (startProcessState == _stateMachineState)
{
// This state needs an external state change like user input to go ahead
// Remove cancellation token if idle reached for clean start
if (_cancellationToken.IsCancellationRequested)
{
// Reset the cancellation request
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
}
ResetCancellationToken();
// Set up the counter for maximum overall process progress bar in GUI
CalcAndPushMaxOverAllProcessSteps();
@@ -347,10 +339,10 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
// Get the processStateStruct of this new required stateMachineState
var processStateStruct = _processStateDef.GetProcessStateStructOfState(_stateMachineState);
switch (_stateMachineState)
switch (_stateMachineState)
{
case ProcessState.Idle:
break;
break;
case ProcessState.CheckNewMeter:
// Detection of Cordonel has to be completed before assigning next state. It has to be checked if
@@ -359,7 +351,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
// enter the "ConnectCordonel"!
if (processStateStruct.NextStateOnSuccess != null)
{
_stateMachineState = CheckForNewMeter() ? (ProcessState)processStateStruct.NextStateOnSuccess :
_stateMachineState = CheckForNewMeter() ? (ProcessState)processStateStruct.NextStateOnSuccess :
processStateStruct.ErrorExitState;
}
else
@@ -422,6 +414,24 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
#endregion --------------------------------------- State Machine ----------------------------------------------
#region ------------------------------------------ Tools ------------------------------------------------------
/// <summary>
/// Common routine to reset the cancellation token on restart or new meter
/// </summary>
/// <remarks date="2025-Jul-07" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
private void ResetCancellationToken()
{
// This state needs an external state change like user input to go ahead
// Remove cancellation token if idle reached for clean start
if (_cancellationToken.IsCancellationRequested)
{
// Reset the cancellation request
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
}
}
/// <summary>
/// Returns the currentGenesis information for display
/// </summary>
/// <returns></returns>
@@ -461,6 +471,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
/// <remarks date="2025-Mai-12" author="Thomas Wiedebusch">
/// - Check _genesisMeter not null before equality with old pcbid.
/// </remarks>
/// <remarks date="2025-Jun-07" author="Thomas Wiedebusch">
/// - ResetCancellationToken.
/// </remarks>
private Boolean CheckForNewMeter()
{
if (_genesisMeter == null ||
@@ -473,6 +486,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
RemoveMeter();
InitNewMeter();
InitProcesses();
ResetCancellationToken();
// Remind actual genesis
_lastPcbId = _genesisMeter?.PcbId;
@@ -609,7 +623,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
if (Processes == null)
Processes = new List<IProductionProcess>();
// Get all processes relevant for EOL from table which has to be sorted
// Get all processes relevant for production from table which has to be sorted
var processes = _processStateDef.GetAllProductionProcesses();
foreach (var process in processes)