Entity

An entity is something that can experience processes and as such may wait in queue. It is a subclass of QObject. The general approach is to use the process() function to define a process that a subclass of Entity can follow. Entity instances may use resources, signals, hold queues, etc. as shared mutable state. Entities may follow a process sequence if defined.

Parameters

aName

an optional name for the entity

Inheritors

Constructors

Link copied to clipboard
constructor(aName: String? = null)

Types

Link copied to clipboard
inner class Blockage(name: String? = null) : IdentityIfc

A blockage is like a semaphore or lock. A blockage can be used to block (suspend) other entities while they wait for the blockage to be cleared. The user can mark process code with the start of a blockage and a subsequent end of the blockage. While the entity that creates the blockage is within the blocking code, other entities can be made to wait until the blockage is cleared. Only the entity that creates the blockage can start and clear it. A started blockage must be cleared before the end of the process routine that contains it; otherwise, an exception will occur. Thus, blockages that are started must always be cleared. The primary purpose of this construct is to facilitate process interaction between entities. Using blockages should be preferred over raw suspend/resume usage and even the use of Suspension instances.

Link copied to clipboard
open inner class BlockingActivity(val activityTime: GetValueIfc, val activityPriority: Int = DELAY_PRIORITY, name: String? = null) : ProcessModel.Entity.BlockingTask

A BlockingActivity is an activity that may block other entities as they wait for the activity's delay to complete.

Link copied to clipboard
inner class BlockingMovement(val fromLoc: LocationIfc, val toLoc: LocationIfc, val velocity: GetValueIfc = this@Entity.velocity, val movePriority: Int = MOVE_PRIORITY, name: String? = null) : ProcessModel.Entity.BlockingTask

Represents the movement of the entity from the specified location to the specified location at the supplied velocity. This wraps the movement within a blockage which will cause entities that are waiting for the movement to complete to block (suspend) until the movement is completed.

Link copied to clipboard
inner class BlockingResourcePoolUsage(val resourcePool: ResourcePool, val amountNeeded: Int = 1, val seizePriority: Int = SEIZE_PRIORITY, delayDuration: Double, delayPriority: Int = DELAY_PRIORITY, val queue: RequestQ, name: String? = null) : ProcessModel.Entity.BlockingActivity

A BlockingResourcePoolUsage represents the usage of a pool of resources that may block other entities while the usage occurs. Equivalent to: seize(), delay(), release()

Link copied to clipboard
inner class BlockingResourceUsage(val resource: Resource, val amountNeeded: Int = 1, val seizePriority: Int = SEIZE_PRIORITY, delayDuration: Double, delayPriority: Int = DELAY_PRIORITY, val queue: RequestQ, name: String? = null) : ProcessModel.Entity.BlockingActivity

A BlockingResourceUsage represents the usage of a resource that may block other entities while its usage occurs. Equivalent to: seize(), delay(), release()

Link copied to clipboard
abstract inner class BlockingTask(name: String? = null) : IdentityIfc

A BlockingTask is a task that takes time to complete and will block the process of an entity that will wait for it to complete.

Link copied to clipboard
abstract inner class Request : ModelElement.QObject

Represents some amount of units needed from 1 or more resources

Link copied to clipboard
Link copied to clipboard
inner class Suspension(name: String? = null, val type: SuspendType = SuspendType.SUSPEND) : IdentityIfc

An abstraction that represents a general suspension point within a process. Suspensions are one-shot. That is, once resumed they cannot be used again unless passed through the suspend(suspension: Suspension) function for a KSLProcess.

Properties

Link copied to clipboard

Controls whether the entity goes through the function dispose() of its containing ProcessModel. The default is true.

Link copied to clipboard

If an entity is using a conveyor (has requested and received cells) this returns the request. If null, then the entity should not be using a conveyor. This is set via the requestConveyor() suspending function to the request and to null when the entity exits the conveyor.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

If supplied, this process will be the process activated by an EntityGenerator that creates and activates the entity.

Link copied to clipboard

Indicates if the entity has active (started) blockages within a process. A blockage is considered active if it has been started within a process routine. If no blockages have been created or started, this will return false.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

True if a process has been scheduled to activate

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

If not null, the name of the process scheduled to activate

Link copied to clipboard
Link copied to clipboard

Provides access to the entity's processes by name

Link copied to clipboard
Link copied to clipboard

Provides a list of processes for the entity to follow before being disposed

Link copied to clipboard

An iterator over the entity's current process sequence. If a process sequence is supplied and the property useProcessSequence is true then the iterator is used to determine the next process for the entity to execute.

Link copied to clipboard

Controls whether the entity uses an assigned process sequence via the processSequence property at the end of successfully completing a process to determine the next process to experience. The default is false.

Link copied to clipboard
open override var velocity: GetValueIfc

The default velocity for the entity's movement within the spatial model of its ProcessModel

Functions

Link copied to clipboard
protected open fun afterRunningProcess(completedProcess: KSLProcess)

Can be used by subclasses to perform some logic when (after) the current process is completed, but before deciding to execute the next process (if there is one). Called right before determineNextProcess()

Link copied to clipboard

A string representation of the allocations held by the entity. Useful for printing and diagnostics.

Link copied to clipboard
protected open fun beforeRunningProcess(process: KSLProcess)

Subclasses can override this method and provide logic for the supplied process that will be executed right before the process runs to is first suspension point. For example, this method could be used to make assignments to the entity before the entity starts running the process. By default, this method does nothing.

Link copied to clipboard

A string representation of the active blockages for the entity. Useful for printing and diagnostics.

Link copied to clipboard
protected open fun determineNextProcess(completedProcess: KSLProcess): KSLProcess?

If the useProcessSequence property is true, this method automatically uses the current processSequenceIterator. If the iterator has a next element it is returned, else null is returned. Subclasses may override this implementation to provide a more general approach to determining the next process to run.

Link copied to clipboard
protected open fun dispose(completedProcess: KSLProcess)

This function is called if there are no more processes to run for the entity after successfully completing a process. This method provides subclasses the ability to release any allocations or do clean up before the entity is passed to its EntityType for handling. By default, this method does nothing.

Link copied to clipboard
protected open fun handleTerminatedProcess(terminatedProcess: KSLProcess)

Subclasses of Entity can use this method to clean up after a process is terminated for the entity. Currently, it does nothing.

Link copied to clipboard

If the entity is in a HoldQueue return the queue

Link copied to clipboard
fun isUsing(resource: Resource): Boolean

Checks if the entity is using (has allocated units) the specified resource.

Link copied to clipboard
protected fun moveRequestToMovableResourcePool(request: ProcessModel.Entity.MovableResourcePoolRequest, currentQueue: RequestQ, pool: MovableResourcePoolWithQ, resourceSelectionRule: MovableResourceSelectionRuleIfc, resumePriority: Int, waitStats: Boolean = false)

A request, in a request queue, is there because it's entity is suspended. This function will remove the supplied request from the specified queue and place it in the queue associated with the specified movable resource pool. If the movable resource pool has a unit of capacity available to satisfy the request, then the entity is resumed to allow the unit to be allocated. If the movable resource pool does not have a unit to satisfy the request, the entity stays suspended within the movable resource pool's queue and will be processed as a normal request for the movable resource pool.

Link copied to clipboard
protected fun moveRequestToResource(request: ProcessModel.Entity.ResourceRequest, currentQueue: RequestQ, resource: ResourceWithQ, resumePriority: Int, waitStats: Boolean = false)

A request, in a request queue, is there because it's entity is suspended. This function will remove the supplied request from the specified queue and place it in the queue associated with the specified resource. If the resource has units of capacity available to satisfy the request, then the entity is resumed to allow the units to be allocated. If the resource does not have sufficient units to satisfy the request, the entity stays suspended within the resource's queue and will be processed as a normal request for the resource.

Link copied to clipboard
protected fun moveRequestToResourcePool(request: ProcessModel.Entity.ResourcePoolRequest, currentQueue: RequestQ, pool: ResourcePoolWithQ, resourceSelectionRule: ResourceSelectionRuleIfc, resumePriority: Int, waitStats: Boolean = false)

A request, in a request queue, is there because it's entity is suspended. This function will remove the supplied request from the specified queue and place it in the queue associated with the specified resource pool. If the resource pool has units of capacity available to satisfy the request, then the entity is resumed to allow the units to be allocated. If the resource pool does not have sufficient units to satisfy the request, the entity stays suspended within the resource pool's queue and will be processed as a normal request for the resource pool.

Link copied to clipboard

Computes the number of different allocations of the resource held by the entity.

Link copied to clipboard
protected fun process(processName: String? = null, isDefaultProcess: Boolean = false, block: suspend KSLProcessBuilder.() -> Unit): KSLProcess

This function is used to define via a builder for a process for the entity.

Subclasses of entity can override this method to provide behavior if a request associated with the entity has its requested resource become inactive while its request was waiting in the request queue. This is not a trivial thing to do since the entity will be suspended after seizing a resource. If the entity wants to stop waiting, then the process will have to be terminated and the termination logic will need to handle what to do after the termination. However, if the entity can wait for a different resource, it is possible to remove the request from its current queue and place the request in a different queue that supports a different (active) resource.

Link copied to clipboard
fun resumeProcess(timeUntilResumption: Double = 0.0, priority: Int = RESUME_PRIORITY)

If the entity is executing a process and the process is suspended, then the process is scheduled to resume at the specified simulation time. This schedules an event that eventually resumes the process.

Link copied to clipboard
fun terminateProcess(afterTermination: (entity: ProcessModel.Entity) -> Unit? = null)

If the entity is executing a process and the process is suspended, then the process routine is terminated. This causes the currently suspended process to exit, essentially with an error condition. No further processing within the process will execute. The process ends (is terminated). All resources that the entity has allocated will be deallocated. If the entity was waiting in a queue, the entity is removed from the queue and no statistics are collected on its queueing. If the entity is experiencing a delay, then the event associated with the delay is cancelled.

Link copied to clipboard

Computes the total number of units of the specified resource that are allocated to the entity.