KSLProcessBuilder

KSLProcessBuilder provides the functionality for describing a process. A process is an instance of a coroutine that can be suspended and resumed. The methods of the KSLProcessBuilder are the suspending methods that are allowed within the process modeling paradigm of the KSL. The various suspend methods have an optional string name parameter to identify the name of the suspension point. While not required for basic modeling, identifying the suspension point can be useful for more advanced modeling involving the cancellation or interrupting of a process. The name can be used to determine which suspension point is suspending the process when the process has many suspension points.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open suspend fun convey(conveyor: Conveyor, entryLocation: IdentityIfc, destination: IdentityIfc, numCellsNeeded: Int = 1, requestPriority: Int = PRIORITY, requestResumePriority: Int = PRIORITY, suspensionName: String? = null): ConveyorRequestIfc
open suspend fun convey(conveyor: Conveyor, entryLocation: IdentityIfc, loadingTime: Double = 0.0, destination: IdentityIfc, unloadingTime: Double = 0.0, numCellsNeeded: Int = 1, requestPriority: Int = PRIORITY, requestResumePriority: Int = PRIORITY, suspensionName: String? = null): ConveyorRequestIfc

This suspending function combines requestConveyor(), rideConveyor(), and exit() into one suspending function.

open suspend fun convey(conveyor: Conveyor, entryLocation: IdentityIfc, loadingTime: GetValueIfc = ConstantRV.ZERO, destination: IdentityIfc, unloadingTime: GetValueIfc = ConstantRV.ZERO, numCellsNeeded: Int = 1, requestPriority: Int = PRIORITY, requestResumePriority: Int = PRIORITY, suspensionName: String? = null): ConveyorRequestIfc

This suspending function combines access(), ride(), and exit() into one suspending function.

Link copied to clipboard
abstract suspend fun delay(delayDuration: Double, delayPriority: Int = PRIORITY, suspensionName: String? = null)

Causes the process to delay (suspend execution) for the specified amount of time.

open suspend fun delay(delayDuration: GetValueIfc, delayPriority: Int = PRIORITY, suspensionName: String? = null)
Link copied to clipboard
open suspend fun exitConveyor(exitPriority: Int = PRIORITY, suspensionName: String? = null)
abstract suspend fun exitConveyor(conveyorRequest: ConveyorRequestIfc, exitPriority: Int = PRIORITY, suspensionName: String? = null)

This suspending function causes the item associated with the allocated cells to exit the conveyor. If there is no item associated with the allocated cells, the cells are immediately released without a time delay. If there is an item occupying the associated cells there will be a delay while the item moves through the deallocated cells and then the cells are deallocated. After exiting the conveyor, the cell allocation is deallocated and cannot be used for further interaction with the conveyor.

Link copied to clipboard
abstract suspend fun hold(queue: HoldQueue, priority: Int = PRIORITY, suspensionName: String? = null)

Causes the process to hold indefinitely within the supplied queue. Some other process or event is responsible for removing the entities and causing them to proceed with their processes NOTE: The entity is not signaled to resume its process unless you signal it. The entity cannot remove itself. Some other construct must do the removal and resumption.

Link copied to clipboard
abstract suspend fun interruptDelay(process: KSLProcess, delayName: String, interruptTime: Double, interruptPriority: Int = PRIORITY, postInterruptDelayTime: Double)
open suspend fun interruptDelay(process: KSLProcess, delayName: String, interruptTime: GetValueIfc, interruptPriority: Int = PRIORITY, postInterruptDelayTime: GetValueIfc)

This method allows a process to interrupt another process while that process is experiencing a delay. If the supplied process is not currently experiencing the named delay, then nothing happens. That is, the interrupt is ignored and the method just returns at the current time without suspending. If the supplied process is experiencing the named delay, then its delay is interrupted for the specified interrupt time. After the interruption time has elapsed, the process experiencing the original delay continues a delay for the specified post interruption delay time.

Link copied to clipboard
abstract suspend fun interruptDelayAndContinue(process: KSLProcess, delayName: String, interruptTime: Double, interruptPriority: Int)
open suspend fun interruptDelayAndContinue(process: KSLProcess, delayName: String, interruptTime: GetValueIfc, interruptPriority: Int)

This method allows a process to interrupt another process while that process is experiencing a delay. If the supplied process is not currently experiencing the named delay, then nothing happens. That is, the interrupt is ignored and the method just returns at the current time without suspending. If the supplied process is experiencing the named delay, then its delay is interrupted for the specified interrupt time. After the interruption time has elapsed, the process experiencing the original delay continues with the post interruption time being equal to the time remaining on the original delay at the time of the interruption

Link copied to clipboard
abstract suspend fun interruptDelayAndRestart(process: KSLProcess, delayName: String, interruptTime: Double, interruptPriority: Int)
open suspend fun interruptDelayAndRestart(process: KSLProcess, delayName: String, interruptTime: GetValueIfc, interruptPriority: Int)

This method allows a process to interrupt another process while that process is experiencing a delay. If the supplied process is not currently experiencing the named delay, then nothing happens. That is, the interrupt is ignored and the method just returns at the current time without suspending. If the supplied process is experiencing the named delay, then its delay is interrupted for the specified interrupt time. After the interruption time has elapsed, the process experiencing the original delay continues a delay using its original delay time. That is, it restarts its original delay.

Link copied to clipboard
abstract suspend fun interruptDelayWithProcess(process: KSLProcess, delayName: String, interruptingProcess: KSLProcess, interruptPriority: Int = PRIORITY, postInterruptDelayTime: Double)
open suspend fun interruptDelayWithProcess(process: KSLProcess, delayName: String, interruptingProcess: KSLProcess, interruptPriority: Int = PRIORITY, postInterruptDelayTime: GetValueIfc)

This method allows a process to interrupt another process while that process is experiencing a delay. If the supplied process is not currently experiencing the named delay, then nothing happens. That is, the interrupt is ignored and the method just returns at the current time without suspending. If the supplied process is experiencing the named delay, then its delay is interrupted while the interrupting process executes to completion. After the interruption process has completed, the process experiencing the original delay continues a delay for the specified post interruption delay time. Note that this functionality requires three processes 1) to have the interruptDelay() call, 2) the process being interrupted, and 3) the process that is used as the interruption.

Link copied to clipboard
abstract suspend fun interruptDelayWithProcessAndContinue(process: KSLProcess, delayName: String, interruptingProcess: KSLProcess, interruptPriority: Int = PRIORITY)

This method allows a process to interrupt another process while that process is experiencing a delay. If the supplied process is not currently experiencing the named delay, then nothing happens. That is, the interrupt is ignored and the method just returns at the current time without suspending. If the supplied process is experiencing the named delay, then its delay is interrupted while the interrupting process executes to completion. After the interruption process has completed, the process experiencing the original delay continues a delay for time remaining on its original delay. Note that this functionality requires three processes 1) to have the interruptDelay() call, 2) the process being interrupted, and 3) the process that is used as the interruption.

Link copied to clipboard
abstract suspend fun interruptDelayWithProcessAndRestart(process: KSLProcess, delayName: String, interruptingProcess: KSLProcess, interruptPriority: Int = PRIORITY)

This method allows a process to interrupt another process while that process is experiencing a delay. If the supplied process is not currently experiencing the named delay, then nothing happens. That is, the interrupt is ignored and the method just returns at the current time without suspending. If the supplied process is experiencing the named delay, then its delay is interrupted while the interrupting process executes to completion. After the interruption process has completed, the process experiencing the original delay continues a delay for the full original delay time. Note that this functionality requires three processes 1) to have the interruptDelay() call, 2) the process being interrupted, and 3) the process that is used as the interruption.

Link copied to clipboard
abstract suspend fun move(fromLoc: LocationIfc, toLoc: LocationIfc, velocity: Double = entity.velocity.value, movePriority: Int = PRIORITY, suspensionName: String? = null)
open suspend fun move(fromLoc: LocationIfc, toLoc: LocationIfc, velocity: GetValueIfc = entity.velocity, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the entity from the specified location to the specified location at the supplied velocity. If the entity is not currently at fromLoc then its current location is quietly set to fromLoc, without movement before the move commences. To move directly from the current location, use moveTo().

open suspend fun move(movableResource: MovableResource, toLoc: LocationIfc, velocity: Double = movableResource.velocity.value, movePriority: Int = PRIORITY, suspensionName: String? = null)
open suspend fun move(movableResourceWithQ: MovableResourceWithQ, toLoc: LocationIfc, velocity: Double = movableResourceWithQ.velocity.value, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the movable resource from its current location to the specified location at the supplied velocity.

abstract suspend fun move(spatialElement: SpatialElementIfc, toLoc: LocationIfc, velocity: Double, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the spatial element from its current location to the specified location at the supplied velocity.

Link copied to clipboard
open suspend fun moveTo(toLoc: LocationIfc, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the entity from its current location to the specified location using the entity's default velocity.

open suspend fun moveTo(toLoc: LocationIfc, velocity: Double, movePriority: Int = PRIORITY, suspensionName: String? = null)
open suspend fun moveTo(toLoc: LocationIfc, velocity: GetValueIfc = entity.velocity, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the entity from its current location to the specified location at the supplied velocity.

Link copied to clipboard
abstract suspend fun moveWith(movableResource: MovableResource, toLoc: LocationIfc, velocity: Double = movableResource.velocity.value, movePriority: Int = PRIORITY, suspensionName: String? = null)
abstract suspend fun moveWith(movableResourceWithQ: MovableResourceWithQ, toLoc: LocationIfc, velocity: Double = movableResourceWithQ.velocity.value, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the entity and the movable resource from the current location to the specified location at the supplied velocity. The entity and the movable resource must be at the same location to start the movement. If not specified, the default velocity of the spatial element is used for the movement.

abstract suspend fun moveWith(spatialElement: SpatialElementIfc, toLoc: LocationIfc, velocity: Double, movePriority: Int = PRIORITY, suspensionName: String? = null)

Causes movement of the entity and the spatial element from the current location to the specified location at the supplied velocity. The entity and the spatial element must be at the same location to start the movement. If not specified, the default velocity of the spatial element is used for the movement.

Link copied to clipboard
abstract fun release(allocation: Allocation, releasePriority: Int = PRIORITY)

Releases the allocation of the resource

abstract fun release(resource: Resource, releasePriority: Int = PRIORITY)

Releases ANY(ALL) allocations related to the resource that are allocated to the entity currently executing this process

abstract fun release(pooledAllocation: ResourcePoolAllocation, releasePriority: Int = PRIORITY)

Releases the allocations associated with using a ResourcePool

Link copied to clipboard
abstract fun releaseAllResources(releasePriority: Int = PRIORITY)

Releases ALL the resources that the entity has currently allocated to it

Link copied to clipboard
abstract suspend fun requestConveyor(conveyor: Conveyor, entryLocation: IdentityIfc, numCellsNeeded: Int = 1, requestPriority: Int = PRIORITY, requestResumePriority: Int = PRIORITY, suspensionName: String? = null): ConveyorRequestIfc

This suspending function requests the number of cells indicated at the entry location of the conveyor. If the number of cells are not immediately available the process is suspended until the number of cells can be allocated (in full). The request for the cells will wait for the allocation in the queue associated with the start of the segment associated with the entry location of the conveyor. After this suspending function returns, the entity holds the cells in the returned cell allocation, but the entity is not on the conveyor. The entity can then decide to ride on the conveyor using the cell allocation or release the cell allocation by exiting the conveyor without riding. The behavior of the conveyor during access is governed by the type of conveyor. A blockage occurs at the entry point of the segment while the entity has the allocated cells and before exiting or riding.

Link copied to clipboard
open suspend fun rideConveyor(destination: IdentityIfc, ridePriority: Int = PRIORITY, suspensionName: String? = null): Double

This suspending function causes the entity to be associated with an item that occupies the allocated cells on the conveyor. The item will move on the conveyor until it reaches the supplied destination. After this suspending function returns, the item associated with the entity will be occupying the cells it requires at the exit location of the segment associated with the destination. The item will remain on the conveyor until the entity indicates that the cells are to be released by using the exit function. The behavior of the conveyor during the ride and when the item reaches its destination is governed by the type of conveyor. A blockage occurs at the destination location of the segment while the entity occupies the final cells before exiting or riding again. If the destination implements the LocationIfc then the current location property of the entity will be updated to this value at the completion of the ride.

abstract suspend fun rideConveyor(conveyorRequest: ConveyorRequestIfc, destination: IdentityIfc, ridePriority: Int = PRIORITY, suspensionName: String? = null): Double

This suspending function causes the entity to be associated with an item that occupies the allocated cells on the conveyor. The item will move on the conveyor until it reaches the supplied destination. After this suspending function returns, the item associated with the entity will be occupying the cells it requires at the exit location of the segment associated with the destination. The item will remain on the conveyor until the entity indicates that the cells are to be released by using the exit function. The behavior of the conveyor during the ride and when the item reaches its destination is governed by the type of conveyor. A blockage occurs at the destination location of the segment while the entity occupies the final cells before exiting or riding again. If the destination implements the LocationIfc then the current location property of the entity will be updated to this value at the completion of the ride.

Link copied to clipboard
open suspend fun seize(resource: MovableResourceWithQ, seizePriority: Int = PRIORITY, suspensionName: String? = null): Allocation
open suspend fun seize(resource: MovableResource, seizePriority: Int = PRIORITY, queue: RequestQ, suspensionName: String? = null): Allocation

Requests a number of units of the indicated movable resource.

open suspend fun seize(resourcePool: ResourcePoolWithQ, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, suspensionName: String? = null): ResourcePoolAllocation

Requests a number of units from the indicated pool of resources The queue that will hold the entity is internal to the resource pool. If the queue is priority based (i.e. uses a ranked queue discipline) the user should set the entity's priority attribute for use in ranking the queue prior to the calling seize.

open suspend fun seize(resource: ResourceWithQ, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, suspensionName: String? = null): Allocation

Requests a number of units of the indicated resource. The queue that will hold the entity is internal to the resource. If the queue is priority based (i.e. uses a ranked queue discipline) the user should set the entity's priority attribute for use in ranking the queue prior to the calling seize.

abstract suspend fun seize(resource: Resource, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, queue: RequestQ, suspensionName: String? = null): Allocation

Requests a number of units of the indicated resource.

abstract suspend fun seize(resourcePool: ResourcePool, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, queue: RequestQ, suspensionName: String? = null): ResourcePoolAllocation

Requests a number of units from the indicated pool of resources

Link copied to clipboard
open suspend fun <T : ModelElement.QObject> BlockingQueue<T>.send(item: T, blockingPriority: Int = PRIORITY, suspensionName: String? = null)

Permits simpler calling syntax when using a blocking queue within a KSLProcess This method will block (suspend) if the blocking queue is full. That is, if the blocking queue has reached its capacity. When space for the item becomes available, then the item is placed within the blocking queue.

abstract suspend fun <T : ModelElement.QObject> send(item: T, blockingQ: BlockingQueue<T>, blockingPriority: Int = PRIORITY, suspensionName: String? = null)

This method will block (suspend) if the blocking queue is full. That is, if the blocking queue has reached its capacity. When space for the item becomes available, then the item is placed within the blocking queue.

Link copied to clipboard
open suspend fun <T : ModelElement.QObject> sendItems(collection: Collection<T>, blockingQ: BlockingQueue<T>, blockingPriority: Int = PRIORITY, suspensionName: String? = null)

This method will block (suspend) if the blocking queue is full. That is, if the blocking queue has reached its capacity. When space for the item becomes available, then the item is placed within the blocking queue.

Link copied to clipboard
abstract suspend fun suspend(suspensionObserver: SuspensionObserver, suspensionName: String?)

Suspends the execution of the process. Since the process cannot resume itself, the client must provide an object that will resume the process. Most required functionality is provided via the other methods in this interface. The method suspend() might be considered for implementing higher level functionality.

Link copied to clipboard
open suspend fun transportWith(fleet: MovableResourcePoolWithQ, toLoc: LocationIfc, emptyVelocity: Double = fleet.velocity.value, transportVelocity: Double = fleet.velocity.value, loadingDelay: GetValueIfc = ConstantRV.ZERO, unLoadingDelay: GetValueIfc = ConstantRV.ZERO, requestPriority: Int = PRIORITY, emptyMovePriority: Int = PRIORITY, loadingPriority: Int = PRIORITY, transportPriority: Int = PRIORITY, unLoadingPriority: Int = PRIORITY)
open suspend fun transportWith(fleet: MovableResourcePool, toLoc: LocationIfc, emptyVelocity: Double = fleet.velocity.value, transportVelocity: Double = fleet.velocity.value, transportQ: RequestQ, loadingDelay: GetValueIfc = ConstantRV.ZERO, unLoadingDelay: GetValueIfc = ConstantRV.ZERO, requestPriority: Int = PRIORITY, emptyMovePriority: Int = PRIORITY, loadingPriority: Int = PRIORITY, transportPriority: Int = PRIORITY, unLoadingPriority: Int = PRIORITY)

Causes transport of the entity via a movable resource within the fleet from the entity's current location to the specified location at the supplied velocities. If not specified, the default velocity of the movable resource is used for the movement.

open suspend fun transportWith(movableResourceWithQ: MovableResourceWithQ, toLoc: LocationIfc, emptyVelocity: Double = movableResourceWithQ.velocity.value, transportVelocity: Double = movableResourceWithQ.velocity.value, loadingDelay: GetValueIfc = ConstantRV.ZERO, unLoadingDelay: GetValueIfc = ConstantRV.ZERO, requestPriority: Int = PRIORITY, emptyMovePriority: Int = PRIORITY, loadingPriority: Int = PRIORITY, transportPriority: Int = PRIORITY, unLoadingPriority: Int = PRIORITY)
open suspend fun transportWith(movableResource: MovableResource, toLoc: LocationIfc, emptyVelocity: Double = movableResource.velocity.value, transportVelocity: Double = movableResource.velocity.value, transportQ: RequestQ, loadingDelay: GetValueIfc = ConstantRV.ZERO, unLoadingDelay: GetValueIfc = ConstantRV.ZERO, requestPriority: Int = PRIORITY, emptyMovePriority: Int = PRIORITY, loadingPriority: Int = PRIORITY, transportPriority: Int = PRIORITY, unLoadingPriority: Int = PRIORITY)

Causes transport of the entity via the movable resource from the entity's current location to the specified location at the supplied velocities. If not specified, the default velocity of the movable resource is used for the movement.

Link copied to clipboard
open suspend fun use(resourcePool: ResourcePoolWithQ, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: Double, delayPriority: Int = PRIORITY)
open suspend fun use(resourcePool: ResourcePoolWithQ, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: GetValueIfc, delayPriority: Int = PRIORITY)

Uses the resource with the amount of units for the delay and then releases it. Equivalent to: seize(), delay(), release() The queue that will hold the entity is internal to the resource pool. If the queue is priority based (i.e. uses a ranked queue discipline) the user should set the entity's priority attribute for use in ranking the queue prior to the calling use.

open suspend fun use(resource: ResourceWithQ, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: Double, delayPriority: Int = PRIORITY)
open suspend fun use(resource: ResourceWithQ, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: GetValueIfc, delayPriority: Int = PRIORITY)

Uses the resource with the amount of units for the delay and then releases it. Equivalent to: seize(), delay(), release() The queue that will hold the entity is internal to the resource. If the queue is priority based (i.e. uses a ranked queue discipline) the user should set the entity's priority attribute for use in ranking the queue prior to the calling use.

open suspend fun use(resource: Resource, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: Double, delayPriority: Int = PRIORITY, queue: RequestQ)
open suspend fun use(resource: Resource, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: GetValueIfc, delayPriority: Int = PRIORITY, queue: RequestQ)
open suspend fun use(resourcePool: ResourcePool, amountNeeded: Int = 1, seizePriority: Int = PRIORITY, delayDuration: Double, delayPriority: Int = PRIORITY, queue: RequestQ)

Uses the resource with the amount of units for the delay and then releases it. Equivalent to: seize(), delay(), release()

Link copied to clipboard
abstract suspend fun waitFor(process: KSLProcess, timeUntilActivation: Double = 0.0, priority: Int = PRIORITY, suspensionName: String? = null)

Causes the current process to suspend until the specified process has run to completion. This is like run blocking. It activates the specified process and then waits for it to complete before proceeding.

abstract suspend fun waitFor(signal: Signal, waitPriority: Int = PRIORITY, waitStats: Boolean = true, suspensionName: String? = null)

Causes the process to halt, waiting for the signal to be announced. Some other process/event is necessary to cause the signal. The entities stop waiting for the signal and resume their processes when signaled.

open suspend fun <T : ModelElement.QObject> BlockingQueue<T>.waitFor(amount: Int = 1, predicate: (T) -> Boolean = alwaysTrue, blockingPriority: Int = PRIORITY, suspensionName: String? = null): List<T>

Permits simpler calling syntax when using a blocking queue within a KSLProcess This method will block (suspend) until the required number of items that meet the criteria become available within the blocking queue.

Link copied to clipboard
open suspend fun <T : ModelElement.QObject> BlockingQueue<T>.waitForAny(predicate: (T) -> Boolean, blockingPriority: Int = PRIORITY, suspensionName: String? = null): List<T>

Permits simpler calling syntax when using a blocking queue within a KSLProcess This method will block (suspend) until at least 1 item that meets the criteria is available within the blocking queue. If more than one is available, all items meeting the criteria will be returned.

Link copied to clipboard
abstract suspend fun <T : ModelElement.QObject> waitForAnyItems(blockingQ: BlockingQueue<T>, predicate: (T) -> Boolean, blockingPriority: Int = PRIORITY, suspensionName: String? = null): List<T>

This method will block (suspend) until at least 1 item that meets the criteria is available within the blocking queue. If more than one is available, all items meeting the criteria will be returned.

Link copied to clipboard
abstract suspend fun <T : ModelElement.QObject> waitForItems(blockingQ: BlockingQueue<T>, amount: Int = 1, predicate: (T) -> Boolean = alwaysTrue, blockingPriority: Int = PRIORITY, suspensionName: String? = null): List<T>

This method will block (suspend) until the required number of items that meet the criteria become available within the blocking queue.