Skip to content

Activity Queries

Activity queries read the state of an activity right now: how full it is, how long its line is, and whether it can take work at all. Name the activity in quotes, then the value you want.

QueryWhat it returns
Activity("X").ContentsEntities currently inside the activity.
Activity("X").CapIts capacity (0 means unlimited).
Activity("X").FreeCapFree capacity remaining.
Activity("X").QueueLengthEntities waiting in its input queue.
Activity("X").QueueTimeAverage time entities wait there.
Activity("X").ThroughputHow many have passed through.
Activity("X").BatchCountBatches waiting to form, at a batching activity.
Activity("X").IsNotBlocked1 if it can take and pass on work, 0 if it is off shift, on a break, or cannot hand off downstream.

The input and output queues have their own capacity readings: CapInq, FreeCapInq, CapOutq, and FreeCapOutq.

Each line below is a complete piece of action logic, with a // note saying what it does.

How full the activity is, and how much room is left:

// Entities inside Paint at this moment
SET v_InPaint TO Activity("Paint").Contents
// The capacity Paint was given; 0 means unlimited
SET v_PaintCap TO Activity("Paint").Cap
// Hold the entity here until Paint has a free slot
WAIT UNTIL Activity("Paint").FreeCap > 0

How long the line in front of it is, and how long it has been moving:

// Entities waiting in the input queue; warn when the line gets long
IF Activity("Paint").QueueLength > 10 THEN DISPLAY "Paint is backing up" ENDIF
// Average wait so far in front of Paint, in minutes
SET v_PaintWait TO Activity("Paint").QueueTime
// Entities Paint has finished since the run began
SET v_PaintDone TO Activity("Paint").Throughput

At a batching activity, how many batches are waiting to form:

// Release only once five batches are queued
WAIT UNTIL Activity("Pack").BatchCount >= 5

Whether the activity can take work at all. IsNotBlocked is 0 while an activity is off shift, on a break, or holding a finished entity that cannot move downstream:

// Skip the primary desk while it is closed or cannot hand off
IF Activity("Primary").IsNotBlocked = 1 THEN ROUTE 1 ELSE ROUTE 2 ENDIF

This is the natural check to put in an availability route custom expression, to pass an activity by rather than queue in front of one that is not moving. An activity name that does not exist reads as 1, so a typo quietly lets work through rather than holding it back.

The input and output queues, read the same way:

// Total room in the input queue, then wait for a place in it
SET v_InqSize TO Activity("Paint").CapInq
WAIT UNTIL Activity("Paint").FreeCapInq > 0
// Total room in the output queue, and a warning when it fills
SET v_OutqSize TO Activity("Paint").CapOutq
IF Activity("Paint").FreeCapOutq = 0 THEN DISPLAY "Paint cannot hand off" ENDIF

Send work to whichever line is emptier:

// Compare the two lines and route to the shorter one
IF Activity("Line1").Contents < Activity("Line2").Contents THEN ROUTE 1 ELSE ROUTE 2 ENDIF
LegacyHow this worked in the previous version

Returns the total number of entities at an activity. Use CONTENTS(name of activity) to make decisions based on how busy an activity is. Using CONTENTS() to keep track of the number of entities at an activity requires fewer steps and allows more flexibility than using variables to count the number of entities that enter and exit an activity. For example, the second syntax does in one statement what would require several statements without the CONTENTS() function.

Example

A car wash has an activity called Wash that often gets too busy for one operator to handle so the supervisor then comes to help. The logic below models this situation with an IF…THEN statement and the CONTENTS() function. As long as the activity contains fewer than three cars, the worker processes any arriving car. However, if the contents of the activity are greater than three, the Supervisor may also be used.

SUYgQ09OVEVOVFMoV2FzaCkKCXsKCUdFVCBXb3JrZXIKCX0KRUxTRQoJewoJR0VUIFdvcmtlciBPUiBTdXBlcnZpc29yCgl9

[

Functions

](/help/functions/)

Returns the available capacity of an activity (an integer).

Example

Suppose an entity can be routed to one of two identical ovens for a curing process. However, you would like to ensure the ovens are loaded as evenly as possible at all times. The following logic could be used to set an attribute (called a_Router) to a 1 or a 2 based on the available capacity of the ovens. Conditional routings would then be used to route to the appropriate oven:

SUYgRlJFRUNBUChPdmVuMSkgPiBGUkVFQ0FQKE92ZW4yKSBUSEVOCgl7CglhX1JvdXRlcj0xCgl9CkVMU0UKCXsKCWFfUm91dGVyPTIKCX0=

Functions

](/help/functions/)