Skip to content

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.

QueryWhat it returns
Gate("X").IsOpen1 if the gate is open, 0 if closed.
Gate("X").QueueLengthHow many entities are waiting at the gate now. 0 if the model has no gate of that name.
Signal("X").Active1 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.

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 open
IF Gate("Inbound").IsOpen = 1 THEN
ROUTE TO MainPath
ELSE
ROUTE TO Overflow
ENDIF
// Hold the entity here until the Go signal is turned on
WAIT UNTIL Signal("Go").Active
// Send work to the overflow path when ten or more are waiting at the dock
IF Gate("Dock").QueueLength >= 10 THEN
ROUTE TO Overflow
ENDIF

A 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 widgets
IF Inventory("Store").Qty("Widget") < 20 THEN
SET a_Reorder TO 1
ENDIF
// Stock already ordered and still in transit
SET a_Incoming TO Inventory("Store").OnOrder("Widget")
// Value tied up in widgets at this location
SET 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 figure
SET a_Position TO Inventory("Store").Qty("Widget") + Inventory("Store").OnOrder("Widget")
IF a_Position < 20 THEN
SET a_Reorder TO 1
ENDIF

An 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.