Skip to content

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.

HookFires
On OpenWhen the gate goes from closed to open, once per opening
On CloseWhen the gate goes from open or releasing to closed
On ReleaseOnce for every entity the gate releases
On BlockWhen 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.

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:

CommandDoes
INCIncrease a variable
DECDecrease a variable
SETAssign a value
LOGWrite a line to the run log
OpenGate, CloseGate, ToggleGateChange the state of a gate, this one or another
ProcessTableRun 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.

Counting is what these hooks are best at. Put this in On Open:

INC v_GateOpenings

and this in On Release:

INC v_Released

Both variables then appear in the report with their own statistics, giving you the number of openings and the number of entities let through.