Service


Service element is an integral part of the  Service with Lines and Service with Area markup elements. The queue choice policy that you define for the Service with Lines or Service with Area elements is applied uniformly to all Service elements contained in them. Each individual Service element, however, allows you to select a different queue choice policy, which will override the policy set for the parent element.

There are two types of services:

 To change the type of service for the markup element
  1. Select the Service with Lines or Service with Area markup element with a single click.
  2. Choose the necessary Type of service option (Point or Linear) in the markup element properties.

Properties

General

Name – The name of the service. The name is used to identify and access the service from code.

Show name – If selected, the service name is displayed in the graphical editor.

Visible on upper level – If selected, the service is also visible on the upper level where this agent lives.

Override queue choice policy – The selection overrides the policy defined for the Service with Lines or Service with Area markup element. It defines the queue from which the service will serve pedestrians. When the service becomes vacant, it chooses the queue anew according to the selected option. The following alternative options define the queue to be selected:
Longest queue
- the queue containing the maximum number of pedestrians.
Closest queue (strict)
- the queue that is closest to the service, no matter whether it is empty or not.
Closest not empty queue -
the non-empty queue that is closest to the service.
Next queue (round robin) - the queues are selected sequentially in circular order.
Priority queue - the queue with the highest priority is selected (according to the expression provided in the Queue priority field below),
Other
queue - the queue is returned by the expression specified in the Queue field below.

Queue priority – [Visible if Serve pedestrians from is set to Priority queue] Here you can enter Java expression that returns the queue priority. The greater value corresponds to the higher priority. The expression is dynamically reevaluated for each nonempty queue. Based on the results of recalculations the queue with the highest priority will be chosen. You can refer to the service's queues in the expression using the local variable queue.

Queue – [Visible if Serve pedestrians from is set to Other] Here you can enter Java expression that returns the selected queue. Typically you place the call of your custom Java function here.

Position and size

X – X-coordinate of the service point (if service type is Point) or the service line's start point (if service type is Linear).

Y – Y-coordinate of the service point (if service type is Point) or the service line's start point (if service type is Linear).

Pedestrian orientation – [Visible if service type is Point]. The option defines the rotation angle set for the 2D / 3D model of the pedestrian and allows to make the agent face the certain direction at the service point.

dX – [Visible if service type is Linear] X-coordinate of the service line's end point.

dY – [Visible if service type is Linear] Y-coordinate of the service line's end point.

Functions

getLongestQueue() - Returns the queue containing the maximum number of pedestrians..

getClosestQueue() - Returns the queue that is closest to the service, no matter whether it is empty or not.

getClosestQueueNotEmpty() - Returns the non-empty queue that is closest to the service element.

int queuePriority(queue) - This method should be overridden to return the queue priority in Priority queue choice policy.
Parameter: queue - the local variable available for the service element.

customSelectQueue() - This method should be overridden to return a queue in Custom queue choice policy.

boolean isSuspended() - Returns true if the service element is in suspended state; returns false otherwise. A suspended element is inactive and does not accept pedestrians.

setSuspended(boolean suspended) - Sets the service element to suspended state if suspended value is true; sets the service element to active state otherwise.

Color getColor() - Returns the color of the service element.

setColor(Color color) - Sets the color of the service element.
Parameter: color - the color of the service element. It is defined with a color constant, or the new Color(<red>, <green>, <blue>) constructor.


Related topics

Services

Service with lines

 Service with area

Service with a "serpentine" queue

 API reference: ServiceUnit class