Gate Events
A gate’s Events tab holds four small hooks. Each one runs a few commands at a moment in the gate’s life, so a model can count openings, log a closure, stamp a release time, or flip another gate.
The four hooks
Section titled “The four hooks”| Hook | Fires |
|---|---|
| On Open | When the gate goes from closed to open, once per opening |
| On Close | When the gate goes from open or releasing to closed |
| On Release | Once for every entity the gate releases |
| On Block | When an entity is blocked at the gate |
On Open and On Close are hidden on a gate running as Pull or as a Kanban control, because those gates are always open and neither event can ever happen. On Release and On Block are always available, and they do fire under kanban.
These hooks are not full action logic
Section titled “These hooks are not full action logic”This is the part to read before writing anything. A gate hook is a short command list, not the action logic language. Write one command per line, or separate them with semicolons. Do not write a section header: there are no sections here, and a header line is not an error, it is simply ignored.
The commands a hook understands:
| Command | Does |
|---|---|
INC | Increase a variable |
DEC | Decrease a variable |
SET | Assign a value |
LOG | Write a line to the run log |
OpenGate, CloseGate, ToggleGate | Change the state of a gate, this one or another |
ProcessTable | Run a process table |
Anything else is silently treated as increasing a variable of that name. A statement that works perfectly well elsewhere in the model, written here, will not report an error and will not do what you meant. Keep hooks to the list above and put real work in the action logic of the surrounding activities and routes.
TIME and WAIT UNTIL are the exception to the silence: both are refused outright, because a gate event is a moment in time and cannot pause.
Opening a gate from a hook takes over the gate
Section titled “Opening a gate from a hook takes over the gate”OpenGate and ToggleGate do more than change the state once. From that moment the gate is under logic control for the rest of the run, and its schedule and its conditions stop governing it. That is useful when logic is meant to take charge, and a trap when it is not. Mixing an imperative call with a declarative schedule almost never ends up doing what was intended, so pick one.
Worked example
Section titled “Worked example”Counting is what these hooks are best at. Put this in On Open:
INC v_GateOpeningsand this in On Release:
INC v_ReleasedBoth variables then appear in the report with their own statistics, giving you the number of openings and the number of entities let through.

