Resource functions

The resources seized by an agent can be acessed via the unmodifiable LinkedList<Agent> resourceUnits collection of the agent.
 
All resources operating in Process Modeling Library flowcharts provide the following functions:

Resource info

ResourcePool resourcePool()Returns the ResourcePool block this unit belongs to.

ResourceType getResourceType()Returns the type of resource (RESOURCE_STATIC, RESOURCE_MOVING, RESOURCE_PORTABLE).

State

boolean isBusy() - Tests if the resource unit is currently busy: seized, moving to usage location or home location. Returns true if the unit is busy, otherwise false.

boolean isIdle() - Tests if the resource unit is currently idle and ready to be used. Returns true if the unit is idle, otherwise false.

boolean isReserved() - Returns true if this unit is reserved by some request (note that it may be idle - this means that request isn't completed - or it may be busy with other task, which will be interrupted and preempted when request is completed).

Agent getReservedBy() Returns the agent which reserved this unit or null (if this unit is not currently reserved,  see isReserved()).

Agent getServicedEntity() Returns the agent which currently possesses this resource unit. Returns null if this unit is either idle or is busy with some not agent-related task (e.g. resource maintenance).

Utilization statistics

double getUtilization() - Returns the unit utilization: the fraction of time the unit was busy. The returned unit utilization value lies in the range [0..1]. If the availability of the resource unit is defined in the ResourcePool block by a schedule, utilization will be calculated only for the operating hours of the resource unit.  

double timeInState(ResourceUsageState state) - Returns the time the unit has spent in the given "usage state" so far.
     Parameter: state - the state (ResourceUsageState.USAGE_IDLE or ResourceUsageState.USAGE_BUSY)

double timeInState(ResourceUsageState state, TimeUnits units) - Returns the time the unit has spent in the given "usage state" so far (in the specified time units).
     Parameters: state - the state (ResourceUsageState.USAGE_IDLE or ResourceUsageState.USAGE_BUSY)
                        units - a constant defining time units
   
void resetStats() - Resets the unit utilization statistics.

Attachment

void setAttached( boolean attached ) Attaches or detaches a resource unit to/from an agent that possesses it. May be called only for units that are seized by agents, otherwise an error will be thrown.
     Parameterattached - pass true value to attach; false - to detach

boolean isAttached() Tests if the resource unit is attached to the agent. Returns true if the unit is attached, otherwise returns false.

Task

ResourceTaskType currentTaskType() Returns the type of current task, or null if the unit is idle.

ResourceUnitTask currentTask() Returns current task of this unit, or null if the unit is idle. Please note that there is a special task when unit's shift ends.

Home location

void setHomeLocation( INode home ) - Sets the home location for a resource unit.
     Parameterhome - the home node

INode getHomeLocation() - Returns a network node that is set as the home location for this resource unit.

void setHomePosition( double x, double y ) - Sets the coordinates of the resource unit's home position.
     Parametersx - the X-coordinate
                        y - the Y-coordinate

void setHomePosition( double x, double y, double z ) - Sets the coordinates of the resource unit's home position.
     Parametersx - the X-coordinate
                        y - the Y-coordinate                         
                        z - the Z-coordinate

double getHomeX() - Returns the X-coordinate of the resource unit's home position.    

double getHomeY() - Returns the Y-coordinate of the resource unit's home position.    

double getHomeZ() - Returns the Z-coordinate of the resource unit's home position.    

double getHomeRotation() - Returns the rotation angle of the resource unit's home position.