LMES Process Engine
1. Overview
The LMES Process Engine is the core component responsible for scheduling and executing production processes. It manages the entire lifecycle of a product from raw material input to finished product output, based on the defined process route (Route).
2. Core Concepts
- Route: Defines the sequence of processes a product must go through.
- Process: A specific production step (e.g., Assembly, Welding, Testing).
- Step: Finer-grained operations within a process.
- Transition: Logic for moving from one process to another (e.g., if Pass -> Next, if Fail -> Repair).
3. Engine Architecture
3.1 State Machine
The engine uses a finite state machine (FSM) to manage product states.
Created->InProductionInProduction->WaitingForStation->Processing->CompletedProcessing->Paused/Exception
3.2 Execution Context
ProcessContext contains all information required for the current execution:
- Product Information
- Current Route Node
- Collection Data
- Variable Table
4. Extension Mechanisms
The engine supports extension via Action Hooks:
OnProcessStart: Triggered before a process starts (e.g., check machine status).OnProcessEnd: Triggered after a process ends (e.g., upload data).OnRouteComplete: Triggered when the entire route is finished.
5. Database Design
T_PE_Route: Route definitions.T_PE_RouteNode: Nodes in a route.T_PE_Instance: Running process instances.T_PE_Token: Current position tokens for instances.
6. Usage Example
// Start a new process instance
var instance = await _processEngine.StartAsync(routeId, productId);
// Move to next step
await _processEngine.SignalAsync(instanceId, "CompleteStep", data);