flowchart TD
ERP["ERP order"] -->|sync| WO
MAN["Manual entry
/production/work-orders/new/"] --> WO
WO["Work order
status: draft"] -->|Release| STEPS
STEPS["Steps
from the routing / process spec,
or added by hand"] --> Q
Q{"Operator terminal
job list for a work centre"} -->|"pick step + machine"| RUN
RUN["Run on one machine"] -->|"start / pause / end"| REC
REC["Quantities + events recorded"] --> TEL
TEL["Telemetry stitched to the run
by time window"] --> RPT["Reports & certificates"]
stateDiagram-v2
[*] --> draft: created (ERP or manual)
draft --> released: Release
draft --> cancelled: Cancel
released --> in_progress: first run starts
released --> cancelled: Cancel
in_progress --> completed: all steps done
in_progress --> cancelled: Cancel (no active run)
completed --> closed
cancelled --> released: Reopen
cancelled --> [*]
closed --> [*]
sequenceDiagram
participant T as Terminal
participant WS as Workstation (work centre HT)
participant D as Dispatch
participant R as Run
T->>WS: bind station (once per terminal)
T->>T: operator identifies (badge / PIN)
WS->>D: ready/active steps for work centre HT
D-->>T: job list + the HT machines
T->>R: pick a step, pick a machine, Start
R->>R: telemetry from that machine is now scoped to this run
T->>R: report good / scrap, End
flowchart LR
subgraph core ["Core"]
EQ["Equipment + Tags"] -->|on save| SIG["post_save signal"]
SIG -->|debounced| TASK["Celery task
bump config revision"]
TASK -->|"retained MQTT: config/<connector>"| BROKER
end
subgraph edge ["Connector process"]
BROKER[("Mosquitto")] --> SUB["config subscriber"]
SUB -->|higher revision| RESTART["restart driver tasks"]
RESTART --> POLL["poll device
Modbus / OPC-UA / S7"]
end
DEV["PLC or simulator"] --> POLL
POLL -->|"MQTT: telemetry/<area>/<equip>/<tag>"| BROKER
BROKER --> CONS["core MQTT consumer"]
CONS --> TS[("TagSample
Timescale hypertable")]
TS --> DASH["Dashboards / AI Analyze / charts"]