Hold


Can block the agent flow along a particular connection. Is used, for example, when the succeeding flowchart block can accept agents, but you (temporarily) do not want the agents to proceed there, or when you wish to block an output of a particular flowchart block that merges with outputs of other blocks.

The state of the block is controlled programmatically by calling setBlocked() function.

Hold does not hold agents inside (even for zero time), and can be treated as an extension to an input or an output port (or ports).

Demo model: Hold

Parameters

Mode
Here you can choose the block/unblock mode for this Hold block. There are three modes supported:
Manual (use block(), unblock() methods) - the block will be blocked on its block() method call, and unblocked on unblock() invocation.
Block automatically after N agents (use unblock() method) - the block will be blocked automatically right after the specified number of agents arrives at its input port. The block will be unblocked by the call of the block's method unblock()
Conditional (custom decision for each agent) - the block will make the decision whether to block the input, or not, depending on the result of the Blocking condition being evaluated for each incoming agent.
Get value: mode
Valid values: Manual (use block(), unblock() methods) - Hold.MANUAL
Block automatically after N agents (use unblock()) - Hold.BLOCK_AFTER_N_ENTITIES
Conditional (custom decision for each agent) - Hold.CONDITIONAL
N agents for self-block
[Visible if Mode is Block automatically after N agents ] The number of agents that should arrive in the block's input port to block the Hold.
Syntax: int nEntitiesForSelfBlock
Blocking condition [dynamic]
[Visible if Mode is Conditional (custom decision for each agent) ] Here you can specify the condition that will be re-evaluated for each agent. If the condition evaluates to true, this Hold block is blocked. You can change the condition dynamically, in this case you have to call the block's function recalculateConditions() that tells the Hold block to recalculate blocking conditions for all agents which are currently held by this block.
Value type: boolean
Local variable: agent - the agent
Initially blocked
If the option is selected (true), the block is initially put into blocked state.
Syntax: boolean initiallyBlocked
Default value: false
Actions
On enter [code]
Code executed when the agent enters the block.
Local variable: agent - the agent

Functions

void setBlocked(boolean blocked) - Blocks the input port if true is passed as the argument, and unblocks it otherwise.

boolean isBlocked() - Returns true if the input is blocked, otherwise false.

void block() - blocks the input port. Does nothing if port is already blocked.

void unblock() - unblocks the input port. Does nothing if port isn't blocked.

boolean toggleBlock() - changes 'blocked' state and returns the new state (blocked = true).

void recalculateConditions() - use this function to tell the Hold block to recalculate blocking conditions for all agents which are currently held by this block.

Ports

in
The input port.
out
The output port.