Gate, Signal, and Inventory Queries
These queries read the state of a gate, a signal, or an inventory location. Each names its object in quotes.
| Query | What it returns |
|---|---|
Gate("X").IsOpen | 1 if the gate is open, 0 if closed. |
Gate("X").QueueLength | How many entities are waiting at the gate now. 0 if the model has no gate of that name. |
Signal("X").Active | 1 if the signal is currently on, 0 if off. |
Inventory("X").Qty("Item") | The quantity of a named item held at an inventory location. |
Inventory("X").OnOrder("Item") | The quantity of that item already on order and still to arrive. |
Inventory("X").Value("Item") | The value of the stock held: quantity times unit cost. |
The three inventory queries take two names: the first is the inventory location, the second is the item held there.
An example of each
Section titled “An example of each”Each example below is a complete piece of action logic, with a // note saying what it does.
The gate and the signal:
// Send work down the main path only while the inbound gate is openIF Gate("Inbound").IsOpen = 1 THEN ROUTE TO MainPathELSE ROUTE TO OverflowENDIF
// Hold the entity here until the Go signal is turned onWAIT UNTIL Signal("Go").Active
// Send work to the overflow path when ten or more are waiting at the dockIF Gate("Dock").QueueLength >= 10 THEN ROUTE TO OverflowENDIFA gate’s own Open Condition and Close Condition can read its own queue length too, so a gate can open on volume. See Gate Conditions.
The inventory:
// Raise a reorder flag when the store runs low on widgetsIF Inventory("Store").Qty("Widget") < 20 THEN SET a_Reorder TO 1ENDIF
// Stock already ordered and still in transitSET a_Incoming TO Inventory("Store").OnOrder("Widget")
// Value tied up in widgets at this locationSET v_TiedUp TO Inventory("Store").Value("Widget")Qty and OnOrder together give the inventory position, which is what a reorder decision should be made against. Counting stock on hand alone reorders the same item again and again while the first order is still on its way:
// Stock on hand plus stock on order, then flag a reorder against that figureSET a_Position TO Inventory("Store").Qty("Widget") + Inventory("Store").OnOrder("Widget")IF a_Position < 20 THEN SET a_Reorder TO 1ENDIFAn item’s automatic replenishment policy already makes this comparison for you. Reach for these queries when you want to make the decision yourself, or to report on it.

