Before the machines of a new automated line are ordered, someone has to decide how they will talk: to each other, to the supervision and to the MES. If that is left to each supplier, the plant ends up with as many tag conventions, state models and handshakes as it has machines. This project mocks up those decisions for a three-unit cell (loading robot, machining centre, inspection station) and tests them in software:
- An exchange standard, written as data: one tag tree for every unit, the PackML state model, JSON Schemas for orders, part results and alarms, and the handshakes between them (communication standard).
- A virtual PLC behind a real OPC UA server, and a minimal MES client that sends orders and commands and collects results, so the exchanges can be tried end to end.
- Supervision screens and a historian: synoptic, PackML states, OEE, order progress, part genealogy, alarms, in Streamlit over a SQL database.
- A cell model (discrete-event simulation) driven through the same state model, to size the cell and compare improvement actions before anything is built.
- The paperwork of a feasibility trial: a protocol benchmark and a trial specification with measurable acceptance criteria.
Everything runs on one laptop. No real machine, plant or supplier data is used; cycle times and failure rates
are assumptions written in cellmock/cell.py.
-
A result handshake needs two things to lose nothing and count nothing twice: sequence numbers and an outbox kept on disk. 20 × 1,000 parts reported with 5% of messages lost, 5% of acknowledgements lost and one controller restart per 100 parts:
How the cell reports Lost Stored twice Losses the MES can see Writes each result once 1,173 0 0 Repeats until acknowledged, outbox in memory 185 1,003 0 Repeats until acknowledged, outbox on disk 0 1,025 0 Sequence numbers, outbox in memory 214 0 214 Sequence numbers, outbox on disk 0 0 0 Repeating without sequence numbers turns lost acknowledgements into double counts; sequence numbers without a persistent outbox still lose results at a restart, but the MES at least sees every gap. The same protocol runs over a real OPC UA connection in the tests: with 30% of acknowledgements deliberately dropped by the MES, 11 results out of 11 are stored once each, in order.
-
One state model gives the time breakdown for free. Because every unit reports PackML states, the historian splits each unit's shift without any extra signal. Over 100 simulated shifts, the machining centre runs 83% of the time, waits for the robot or the buffer 5%, changes tools 3% and is broken down or restarting 9%. The inspection station waits 45% of the shift.
-
A unit that waits half the time can still cost output. On 100 paired shifts (same random draws for every option), halving the repair time of the inspection station gives 4.0% more good parts, almost as much as halving the repair time of the machining centre (4.4%), even though inspection is idle half the shift: while it is down, the two-place buffer fills and blocks the machining centre. A buffer of 4 places gives 1.8%, halving the tool change time (SMED) 1.5%, a faster inspection 1.1%; a buffer of 1 place costs 1.3%.
-
One shift says little. With exactly the same settings, the OEE of the machining centre over a shift ranges from 60% to 94% (mean 79%) across the 100 simulated shifts, only because breakdowns fall at different times. A trial or an acceptance test judged on one shift can reach either conclusion.
These numbers come from assumed durations; what carries over to a real cell is the method (state model, historian, paired comparisons), not the percentages.
- Tags:
Cell01.<Unit>.<Command|Status|Admin>.<Name>, 14 per unit and 5 for the MES interface, generated from one template (cellmock/tags.py) and checked by rules (naming, types, who may write). The same list builds the OPC UA address space, the HMI and the CSV for integrators (results/tag_dictionary.csv). - States: PackML (ANSI/ISA-TR88.00.02) with the PackTags numbers. Suspended means waiting for another
unit, Held a planned stop, Aborted a breakdown. A command is checked against the state model and refused
visibly (
Status.LastCmdResult). - MES interface:
LoadOrdermethod for work orders; part results offered one at a time with a sequence number and acknowledged by the MES; heartbeat. - Messages: JSON Schemas in
spec/schemas/, validated on both sides.
pip install -r requirements.txt python experiments/run_all.py # every result in results/ (about a minute) python experiments/plot_results.py # figures pytest -q # 15 tests, including an OPC UA round trip streamlit run app/hmi.py # supervision screens python -m cellmock.opcua_server # OPC UA server on opc.tcp://0.0.0.0:4840/cellmock/ (browse it with UaExpert)
The screens: synoptic with a time slider, PackML state timeline and OEE, orders and part genealogy, alarms, sizing results, the exchange standard (tag list, PackML command table, schema check of any pasted message), and link faults with adjustable failure rates.
cellmock/
packml.py PackML states, commands and transitions
tags.py tag template, naming rules, CSV export
messages.py JSON Schema validation of orders, results and alarms
handshake.py result reporting over a failing link, three protocols compared
cell.py discrete-event model of the cell (SimPy), every unit driven through PackML
historian.py SQLite historian, time breakdown, OEE, genealogy
vplc.py virtual PLC: command handshake, order execution, result outbox
opcua_server.py OPC UA server built from the tag list (asyncua)
mes_client.py MES side: orders, commands, results by subscription, acknowledgements
sql/schema.sql historian tables and views
spec/schemas/ WorkOrder, PartResult, Alarm
app/hmi.py supervision screens (Streamlit)
docs/ communication standard, protocol benchmark, feasibility trial
experiments/ run_all.py, plot_results.py
results/ tables, demo historian database, figures, summary.json
- No real controller. The virtual PLC follows the standard by construction; a real trial has to show that a supplier's controller does. The trial specification lists the tests.
- Security is off in the mock-up (anonymous, no encryption). The settings a production server needs are in section 6 of the standard.
- Assumed parameters. Cycle times, breakdowns and defect rates are invented; the sizing results show the method, not a real cell.
- No 3D simulation. Robot reach, collisions and layout belong in a 3D tool (robot simulation software, or Gazebo); the model here only covers flows and times.
- SQLite keeps the project self-contained; the schema uses plain SQL and would move to a server database.
MIT.





