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.
| Query | What it returns |
|---|---|
Activity("X").Contents | Entities currently inside the activity. |
Activity("X").Cap | Its capacity (0 means unlimited). |
Activity("X").FreeCap | Free capacity remaining. |
Activity("X").QueueLength | Entities waiting in its input queue. |
Activity("X").QueueTime | Average time entities wait there. |
Activity("X").Throughput | How many have passed through. |
Activity("X").BatchCount | Batches waiting to form, at a batching activity. |
Activity("X").IsNotBlocked | 1 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.
An example of each
Section titled “An example of each”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 momentSET v_InPaint TO Activity("Paint").Contents
// The capacity Paint was given; 0 means unlimitedSET v_PaintCap TO Activity("Paint").Cap
// Hold the entity here until Paint has a free slotWAIT UNTIL Activity("Paint").FreeCap > 0How 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 longIF Activity("Paint").QueueLength > 10 THEN DISPLAY "Paint is backing up" ENDIF
// Average wait so far in front of Paint, in minutesSET v_PaintWait TO Activity("Paint").QueueTime
// Entities Paint has finished since the run beganSET v_PaintDone TO Activity("Paint").ThroughputAt a batching activity, how many batches are waiting to form:
// Release only once five batches are queuedWAIT UNTIL Activity("Pack").BatchCount >= 5Whether 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 offIF Activity("Primary").IsNotBlocked = 1 THEN ROUTE 1 ELSE ROUTE 2 ENDIFThis 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 itSET v_InqSize TO Activity("Paint").CapInqWAIT UNTIL Activity("Paint").FreeCapInq > 0
// Total room in the output queue, and a warning when it fillsSET v_OutqSize TO Activity("Paint").CapOutqIF Activity("Paint").FreeCapOutq = 0 THEN DISPLAY "Paint cannot hand off" ENDIFPutting two together
Section titled “Putting two together”Send work to whichever line is emptier:
// Compare the two lines and route to the shorter oneIF Activity("Line1").Contents < Activity("Line2").Contents THEN ROUTE 1 ELSE ROUTE 2 ENDIFLegacyHow this worked in the previous version
Contents() function
Section titled “Contents() function”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/)
FreeCap() function
Section titled “FreeCap() function”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/)

