common/Production/ProductionUiCordonel/ProductionProcesses/ProcessStateStruct.cs
2026-04-23 17:50:07 +02:00

109 lines
4.7 KiB
C#

using System;
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum;
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
{
/// <summary>
/// Concatenation between test state and text feeding the state machine with next state.
/// </summary>
public struct ProcessStateStruct
{
/// <summary>
/// Assign process state information
/// </summary>
/// <param name="productionProcess">production process, set to null for "invisible" states</param>
/// <param name="processState">assigned state for call of this process used by the state machine</param>
/// <param name="processInfo">name for process to display a message in the GUI</param>
/// <param name="productionProcessNo">set a unique number to sort the table of production processes,
/// set to null for all hidden processes which are not a production process</param>
/// <param name="nextStateOnSuccess">BaseProductionProcess.DoNotChangeStateAfterCompletion will not
/// change the state automatically</param>
/// <param name="errorExitState"></param>
/// <param name="breakExitState"></param>
/// <param name="kickOffParallelState">start a parallel process</param>
/// <param name="waitForSingleProcess">wait for single processes to complete before execution</param>
/// <param name="waitForAllProcesses">wait for all processes to complete before execution</param>
/// <param name="startAlways">start even if abort is required</param>
/// <remarks date="2023-Jan-17" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
/// <remarks date="2025-Apr-14" author="Thomas Wiedebusch">
/// - Extended to steer state machine with this struct.
/// </remarks>
public ProcessStateStruct(IProductionProcess productionProcess, ProcessState processState, String processInfo,
UInt32? productionProcessNo, ProcessState? nextStateOnSuccess, ProcessState errorExitState = ProcessState.Error,
ProcessState breakExitState = ProcessState.Stop,
ProcessState? kickOffParallelState = null,
ProcessState? waitForSingleProcess = null,
Boolean waitForAllProcesses = false, Boolean startAlways = false)
{
ProductionProcess = productionProcess;
ProcessState = processState;
ProcessInfo = processInfo;
ProductionProcessNo = productionProcessNo;
NextStateOnSuccess = nextStateOnSuccess;
ErrorExitState = errorExitState;
BreakExitState = breakExitState;
KickOffParallelState = kickOffParallelState;
WaitForSingleProcess = waitForSingleProcess;
WaitForAllProcesses = waitForAllProcesses;
StartAlways = startAlways;
}
/// <summary>
/// Start a parallel process
/// </summary>
public ProcessState? KickOffParallelState { get; }
/// <summary>
/// The state of the final test
/// </summary>
public IProductionProcess ProductionProcess { get; }
/// <summary>
/// The state of the final test
/// </summary>
public ProcessState ProcessState { get; }
/// <summary>
/// The info message of the state
/// </summary>
public String ProcessInfo { get; }
/// <summary>
/// Processes which are relevant for the production have a number for the sequence they should be displayed
/// in the GUI, all hidden (non-)production processes are set to null
/// </summary>
public UInt32? ProductionProcessNo { get; }
/// <summary>
/// Next state required after successfully execution
/// </summary>
public ProcessState? NextStateOnSuccess { get; }
/// <summary>
/// Special state used for error or for the second output of the process
/// </summary>
public ProcessState ErrorExitState { get; }
/// <summary>
/// Special state required on user break
/// </summary>
public ProcessState BreakExitState { get; }
/// <summary>
/// Wait for a single process named here to take the result into account
/// </summary>
public ProcessState? WaitForSingleProcess { get; }
/// <summary>
/// Wait until all preceding processes are finished with success
/// </summary>
public Boolean WaitForAllProcesses { get; }
/// <summary>
/// Sate which has to be active always even if a predecessor failed (e.g. error state)
/// </summary>
public Boolean StartAlways { get; }
}
}