|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Layer: L7 Application ยท Build flags: PC_ENABLE_PACKML
PackML (OMAC / ISA-88) is the state model packaging and process machines expose so a line controller - usually over OPC UA - can command and observe any machine the same way. It is defined by ISA-TR88.00.02 ("Machine and Unit States: An Implementation Example of ISA-88", ISBN 978-1-64331-224-8). services/packml is a pure, fixed-BSS implementation of it: a state engine plus an owned PackTags service. This sketch runs it as a simulated machine and serves it over HTTP.
The machine lives in one of 17 states. Seven are stable wait states (the machine waits for a command or condition): Stopped(2), Idle(4), Execute(6), Held(11), Suspended(5), Complete(17), Aborted(9). Ten are transient acting states that auto-advance when their action finishes: Resetting, Starting, Holding, Unholding, Suspending, Unsuspending, Completing, Stopping, Aborting, Clearing. The numbers are the ISA-TR88.00.02 StateCurrent wire values, so a PackTags Status.StateCurrent needs no translation.
Commands drive the transitions. Stop and Abort are near-universal (Abort from any state into the fault branch; Stop into the shutdown branch); the rest are state-specific:
(SC = State-Complete: the machine signals it finished the acting state's action.) The pure engine is three functions plus a couple of predicates:
On top, the owned service (pc_packml_svc_*) carries the PackTags a real machine reports: the current state + unit mode, MachSpeedActual, the ProdProcessedCount / ProdDefectiveCount production counters, and the StateCurrentTime / AccTimeSinceReset timers - so the sketch just drives commands and reads a status snapshot.
No hardware beyond the ESP32 - the "machine" is simulated in loop() (acting states complete after a short dwell; a unit is produced each second while executing). Endpoints:
Flash, then drive it:
An illegal command in the current state answers 409 with "accepted":false and leaves the state put (e.g. start while Stopped).
The complete sketch is PackML.ino. The state engine + service are in src/services/machine_tool/packml/packml.h; the 17-state model, the StateCurrent numbers, the command set, and the transitions follow ISA-TR88.00.02. Pure codec, host-tested (native_packml, 16 cases). The real deployment surfaces the same PackTags over OPC UA; here they ride the library's HTTP server. Pairs with the Umati, HaasMdc, and Fanuc FOCAS machine-tool examples.