using System; using System.Collections.Generic; using System.Threading; using System.Windows.Controls; using LaaPackages.Features.Cordonel.Models; using Xylem.Common.CommonCore.Consts; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus; using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum; using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EventArgs; namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses { public interface IProductionProcess { /// /// Cancellation token to stop operation /// CancellationToken CancellationToken { set; get; } /// /// Event for process list change or state of single process step change from wait to execute to done or error /// event EventHandler OnProcessStateChanged; /// /// Entire process changed status due to state change of process execution /// event EventHandler OnForceStateMachineStateChange; /// /// Log event to log file and signal to GUI /// event EventHandler OnProcessLogRequest; /// /// Send progress information to GUI for progress bars /// event EventHandler OnProcessProgressChanged; /// /// Send messages to GUI /// event EventHandler OnGuiMessageDispatcher; /// /// State of single production process /// /// process name SingleProcessState SingleProcessState { get; } /// /// Name of actual production process /// /// process name String ProcessName { get; } /// /// Version of assembly /// /// process name Version Version { get; } /// /// Set reference to status of meter /// GenesisStatus ProductionStatus { set; } /// /// Set reference to end of line (EOL) progress of meter /// EOLProgressModel EolProgress { set; } /// /// Set reference to production requirements of meter /// CordonelRequirements ProductionRequirements { set; } /// /// Genesis meter /// IGenesisMeter Meter { set; get; } /// /// Register restorer /// RegisterRestorer RegisterRestorer { set; } /// /// Sensus radio encryption key as list of string as a single string is defined as object but /// cannot be changed in derived classes as "Strings are immutable". But objects of a list can /// be changed so the trick is to take a list instead of a strings. /// List RadioEncryptionKey { set; } /// /// Password container /// MeterPwdDb PwdContainer { set; } /// /// Get the user control for the GUI and cleans the content. /// /// specific user control for GUI /// /// Update the sand clock on image /// /// /// - Initial /// /// /// - Clear content, is important for recurrent call on a retry to clean it. /// UserControl GetUserControl(); /// /// Production process kick off with all current- and exit states. /// /// ATTENTION: The OverallStateEvent has to be fired before the SingleProcessState event, as the /// SingleProcessState event will uninstall the event handlers on finalizing! /// /// /// success exit state, if set to null, leave state as is /// /// /// /// - Initial /// void StartProcess(ProcessState? successExitState, ProcessState errorExitState = ProcessState.Error, ProcessState breakExitState = ProcessState.Stop); /// /// Preparation of process in advance to execution routine. /// This will set the process state to "SingleProcessState.Waiting" /// void InitProcess(); /// /// Preparation of process for recurrent run to unblocking this state. /// This will set the process state to "SingleProcessState.Idle" /// void IdleProcess(); /// /// Preparation of process to signal abort request. /// This will set the process state to "SingleProcessState.Abort" /// void AbortProcess(); /// /// Preparation of process to signal retry request. /// This will set the process state to "SingleProcessState.Idle" /// void RetryProcess(); /// /// Pre execution process to isolate database calls from the ExecuteProcess method. /// This is useful for unit tests to separate the peripheral calls. /// /// StatusReturn PreExecuteProcess(); /// /// Process execution routine which will be executed in separate thread. /// /// StatusReturn ExecuteProcess(); /// /// Routine for finalization of each process like cleaning and setting a status or control /// Finalization of process. /// /// successful execution /// objects containing process states sorted success-, error-, /// break exit state /// /// - Initial /// void FinalizeProcess(StatusReturn success, IReadOnlyList exitProcessStateObjects); /// /// Routine for error handling: /// - Log success with Genesis write log, /// - Color output to GUI in green, /// - Dispatch message to UI. /// /// message to dispatch /// /// - Initial /// void SuccessMsgDispatcher(String successMsg); /// /// Routine for warning handling: /// - Log error with Genesis write log, /// - Color output to GUI in orange, /// - Dispatch message to UI. /// /// message to dispatch /// /// - Initial /// void WarningMsgDispatcher(String warningMsg); /// /// Routine for error handling: /// - Log error with Genesis write log, /// - Color output to GUI in red, /// - Dispatch message to UI. /// /// message to dispatch /// /// - Initial /// void ErrorMsgDispatcher(String errorMsg); } }