Service


Seizes a given number of resource units, delays the agent, and releases the seized units. Is equivalent to a sequence Seize, Delay, Release and should be used if the agent does not need to do anything but execute a delay between seize and release. Most of parameters and extension points of these objects are exposed by Service

There are several ways to define resource pools and units the agent has to seize for the Service block:

Please note that when the agent finishes the delay, it will release exactly those units that were seized before the delay. 

The capacity of the embedded delay is set to maximum possible (as it naturally is limited with the resource pool capacity).

Parameters

Seize
Define the seize mode: (Alternative) resource sets or Units of the same pool.
Please refer to the details above.
Syntax: boolean seizeFromOnePool
Resource sets (alternatives) [dynamic]
[Visible if Seize is set to (Alternative) resource sets] Here you can define several alternative resource sets (add new list by clicking the Add list button). The resource set is chosen based on the availability of units. 
Please refer to the details above.
Local variable: agent - the agent
Resource pool [dynamic]
[Visible if Seize resources is set to Units of the same pool] ResourcePool block from where the resources are requested.
Please refer to the details above.
Local variable: agent - the agent.
Number of units [dynamic]
[Visible if Seize resources is set to Units of the same pool] Expression evaluated to obtain the required number of resource units for the agent.
Value type: int
Local variable: agent - the agent
Default value: 1
Queue capacity
[Visible if Maximum capacity is not chosen] The capacity of the embedded queue.
Syntax: int queueCapacity
Default value: 100
Maximum queue capacity
If the option is selected (true), the capacity of the embedded queue is maximum possible (limited to Integer.MAX_VALUE).
Syntax: boolean maximumCapacity
Default value: false
Delay time [dynamic]
Expression evaluated to obtain the delay time for the agent.
Value type: double
Local variable: agent - the current agent.
Default value: triangular( 0.5, 1, 1.5 ) second
Send seized resources [dynamic]
If selected (true), the seized resources will be sent to the specified location.
Value type: boolean
Default value: false
Local variables: agent - the agent
                          Agent unit - the resource unit
Destination is
[Visible if Send seized resources is selected]
Defines where the resources will be sent. The resources can be sent to:
Agent - resources are sent to the curent agent location.
Network node - resources are sent to the specified network node.
Attractor
- resources are sent to the specified attractor.
Get value: destinationType
Default value: Agent (Service.DEST_ENTITY)
Valid values: self.DEST_ENTITY
           self.DEST_NODE
           self.DEST_ATTRACTOR
Node [dynamic]
[Visible if Destination is the Network node] Network node where the seized resources will be sent.
Valid value: Node
Local variables: agent - the agent
                          Agent unit - the resource unit
Attractor [dynamic]
[Visible if Destination is AttractorAttractor where the seized resources will be sent.
Valid value: Attractor
Local variables: agent - the agent
                          Agent unit - the resource unit
On finish, moving resources [dynamic]
Defines, whether moving resources should Return to home location (if they are not immediately seized by another agent) or Stay where they are after being released.
Valid value: boolean
Default value: Return to home location (true)
Local variables: agent - the agent
                          Agent unit - the resource unit
Agent location (queue)
Space markup shape (node or path) where the agents are located while being in the embedded Queue object.
Syntax: AnimationStaticLocationProvider entityLocationQueue
Agent location (delay)
Space markup shape (node or path) where the agents are located while being in the embedded Delay object.
Syntax: AnimationStaticLocationProvider entityLocationDelay
Priorities / preemption
Task priority [dynamic]
The priority of the task for the incoming agent (the larger the higher).
Valid value: double
Default value: 0
Local variable: agent - the agent
Task may preempt [dynamic]
If selected, task may preempt the currently performed task (if allowed in the task properties & the task priority is lower).
Valid value: boolean
Default value: true
Local variable: agent - the agent
Task preemption policy [dynamic]
Here you can choose what is done when some other task incomes for the resource unit(s) currently busy.
No preemption
- the current task continues executing.
Wait for original resource - the task is interrupted and waits for the same resource unit to finish it.
Terminate serving - the task is interrupted and never continued.
Seize any resource - the task is interrupted and tries to seize any resource of the specified type.
Continue without resource - the task is finished without resources assistance.
Default value: No preemption (Service.PP_NO_PREEMPTION)
Local variable: agent - the agent
Auto suspend/resume agents
[Visible if Task preemption policy is set to Wait for original resource or Seize any resource] This parameter defines whether the agent whose task is suspended should be automatically suspended in its current flowchart block and automatically resumed at the time there are available resources.
Syntax: boolean suspendResumeEntities
Default value: true
Enter for terminated agents [dynamic]
[Visible if Task preemption policy is set to Terminate serving] Enter block for agents which lose all units obtained in this Service block because of Terminate serving preemption policy, when one of units in the resource set (defined in this Service) gets grabbed by another task with higher priority.
Local variables: agent - the agent
                          Agent unit - the unit which has originated termination
Return home [dynamic]
[Visible, if On finish, moving resources: Return to home location] Select whether resources should return home each time, if no other tasks or select custom and specify the priority and preemption parameters below.
Local variables: agent - the agent
                          Agent unit - the resource unit 
'Wrap up' priority [dynamic]
[Visible, if Return home: custom] Here you can set up the priority for the 'return home' task. 
Valid value: double
Local variables: agent - the agent
                          Agent unit - the resource unit 
'Wrap up' preeemption policy [dynamic]
[Visible, if Return home: custom] Specifies the policy for the 'return home' task's preemption:
No preemption - 'return home' task cannot be preempted
Terminate - 'return home' task will be preempted by other incoming task and terminated
Local variables: agent - the agent
                          Agent unit - the resource unit 
Advanced
Customize resource choice
If the option is selected, you can choose some specific resource units for the operation (using the Resource choice condition below.) 
Syntax: boolean customizeResourceChoice
Default value: false
Resource choice condition [dynamic]
[Visible if Customize resource choice is selected] Here you can specify boolean expression that will be checked to find the specific resource unit(s) that may perform the operation. If none currently available resource unit(s) satisfy the specified condition (the condition returns false), Service will wait for the first resource unit that matches the condition.
Usually you define some field inside the agent type (say, myAssistant), store there the reference to the resource unit when it starts working with this agent (agent.myAssistant=unit), and then specify here the condition agent.myAssistant==unit enabling only this particular unit to continue working with this particular agent.
Valid value: boolean
Default value: true
Local variables: agent - the agent
                          Agent unit - the unit
                          ResourcePool pool - the resource pool
Queue: exit on timeout
If the option is selected (true), the timeout option for the queue is on. After spending the specified time in the queue, the agent will leave the object through the outTimeout port.
Syntax: boolean enableTimeout
Default value: false
Timeout [dynamic]
[Visible if Queue: exit on timeout is selected] Expression evaluated to obtain the timeout time for the agent.
Valid value: double
Local variable: agent - the agent
Default value: +infinity
Queue: enable preemption
If the option is selected (true), the agents are placed in the queue according to theoir priorities and may be preempted by higher priority ones. 
Syntax: boolean enablePreemption
Default value: false
Restore agent location on exit
If the option is selected, after being animated in the Agent location shape, the agents will return to their original location (node or path) where they were before entering this Service block.
Syntax: boolean restoreEntityLocationOnExit
Force statistics collection
If selected (true), statistics are collected for this and embedded objects, otherwise statistics collection is configured by PMLSettings block (where the default is true).
Syntax: boolean forceStatisticsCollection
Default value: false
'Return home' usage is [dynamic]
Choose whether in the block's usage statistics the 'return home' task should be counted as 'busy' time, or counted as 'idle' time, or  the statistics for this task is not collected at all.
Default value: counted as 'busy'
Valid values: Service.USAGE_BUSY, Service.USAGE_IDLE, Service.USAGE_NOT_COUNTED
Local variables: agent - the agent
                          Agent unit - the unit
Actions
On enter [code]
Code executed when the agent enters the object.
Local variable: agent - the agent 
On exit (timeout) [code]
[Visible if Queue: exit on timeout is enabled] Code executed when the agent exits via outTimeout port as a result of timeout event.
Local variable: agent - the agent
On exit (preempted) [code]
[Visible if Queue: enable preemption is enabled] Code executed when the agent exits via outPreempted port as a result of preemption.
Local variable: agent - the agent
On seize unit [code]
Code executed when the new unit is seized.
Local variables: agent - the agent
                          Agent unit - the unit
On enter delay [code]
Code executed when the agent enters the delay.
Local variables:  T agent - the agent
                           double delayTime - the delay time evaluated for the agent
On at exit [code]
Code executed when agent has finished its delay and ready to leave this block.
Local variable: agent - the agent
On exit [code]
Code executed when the agent exits the object via out port (in the normal way).
Local variable: agent - the agent
On task suspended [code]
[Visible if Task preemption policy is set to Wait for original resource or Seize any resource] Code executed when agent task is suspended because of Wait for original resource and Seize any resource preemption policy, when its unit gets grabbed by another task with higher priority. 
Local variables: agent - the agent
                          Agent unit - the unit
On task resumed [code]
[Visible if Task preemption policy is set to Wait for original resource or Seize any resource] Code executed when agent resumes processing after it has been suspended because of Seize any resource and Wait for original resource preemption policy.
Local variables: agent - the agent
                          Agent unit - the unit
On task terminated [code]
[Visible if Task preemption policy is set to Terminate serving] Code executed when agent loses all units obtained in this Seize block because of Terminate serving preemption policy, when one of units in the resource set (defined in this Seize) gets grabbed by another task with higher priority.
Local variables: agent - the agent
                          Agent unit - the unit which has originated termination.
On remove [code]
Code executed when the agent is intentionally removed from this block by calling the agent's  function remove(). This code is automatically executed after the remove() function call.
Local variable: agent - the agent

Functions

int queueSize() - returns the number of agents in the embedded Queue

T queueGet( int index ) -  returns the agent from the position at the specified index (0 is at the exit).

T queueRemove(Agent agent) - removes agent from the embedded Queue object and returns it.

int delaySize() - returns the number of agents in the embedded Delay object.

T delayGet(int index) - returns the agent at the index position in the Delay (the oldest agent is at the position 0)

T delayRemove(Agent agent) - removes the given agent from the embedded Delay object and returns it.

T remove(Agent agent) - removes the given agent from the block and returns it. If the agent was not contained in the block, returns null.

int size() - returns the number of agents in the block.

T resume(Agent agent) - resumes previously suspended Delay (if was not suspended, throws error).

T suspend(Agent agent) - suspends this delay for the given timeout dt.

double utilization() - Returns the mean utilization of this block. The returned value is the average (collected over time) of number of agents being serviced.

<U extends Agent> List<U> getResourceUnits(agent) - returns resource units servicing the given agent in this block.

Embedded objects

Seize seize
Seizes resource units. This object, in turn, embeds a Queue object where agents wait for the resource.
Delay delay
Delays the agent.
Release release
Releases the seized resource units.

Ports

in
The input port.
outTimeout
The output port for agents leaving the object as a result of timeout
outPreempted
The output port for agents leaving the object as a result of preemption.
out
The output port.