Signal

class Signal @JvmOverloads constructor(parent: ModelElement, name: String? = null, discipline: Queue.Discipline = Queue.Discipline.FIFO) : ModelElement(source)

The purpose of this class is to hold entities that are waiting for a signal while executing a KSLProcess. A reference to this class can be used to signal specific, any, or all the entities waiting to proceed within their process.

For a broadcast to agent statecharts, which has no suspended entities and cannot be waited on with waitFor, see ksl.modeling.agent.AgentSignal.

Parameters

parent

the parent (containing) model element

name

the name of this signal

discipline

the queue discipline for the internal queue that holds the waiting entities

Constructors

Link copied to clipboard
constructor(parent: ModelElement, name: String? = null, discipline: Queue.Discipline = Queue.Discipline.FIFO)

Properties

Link copied to clipboard

Functions

Link copied to clipboard

An immutable list representation of the holding queue. While the list is read-only, the elements can be changed. Thus, some care may be needed to understand the effects of such changes. This view is mainly to provide the abilities available in the Kotlin collection classes to working with the waiting entities, which may be used to determine which entities to signal.

Link copied to clipboard
protected open override fun initialize()

This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called

Link copied to clipboard
fun signal(predicate: Predicate<ProcessModel.Entity>, resumePriority: Int = ProcessModel.RESUME_PRIORITY)

Signals the entities that match the predicate to resume their processes if they are waiting for the signal.

fun signal(rank: Int = 0, resumePriority: Int = ProcessModel.RESUME_PRIORITY)

The entity removes itself from the waiting condition. If there are no entities, or the rank is out of range, then nothing happens (no signal)

fun signal(entities: List<ProcessModel.Entity>, resumePriority: Int = ProcessModel.RESUME_PRIORITY)

Signals the entities in the list to resume their processes if they are waiting for the signal.

fun signal(range: IntRange, resumePriority: Int = ProcessModel.RESUME_PRIORITY)

The entities remove themselves from the waiting condition.

fun signal(entity: ProcessModel.Entity, resumePriority: Int = ProcessModel.RESUME_PRIORITY)

Use this to signal a specific entity to move in its process. The entity removes itself from the waiting condition. Once the replication's events have ended (a signal sent from replicationEnded()), nothing can be resumed, and the signal does nothing.

Link copied to clipboard
fun signalAll(resumePriority: Int = ProcessModel.RESUME_PRIORITY)

All the entities are signaled to proceed in their process. The entities remove themselves from the waiting condition.

Link copied to clipboard
fun signalFirst(resumePriority: Int = ProcessModel.RESUME_PRIORITY)

If the queue is not empty, the first entity in the queue is signaled to proceed.

Link copied to clipboard
fun signalLast(resumePriority: Int = ProcessModel.RESUME_PRIORITY)

If the queue is not empty, the last entity in the queue is signaled to proceed.

Link copied to clipboard
fun trigger(waitPriority: Int? = null, waitStats: Boolean = true): WaitTrigger<Unit>

A trigger for this signal, for use in a wait for the first of several things (waitForFirst). The trigger fires when the waiting entity is signalled while the wait is open; it never fires at once. While the wait is open, the entity waits in this signal's queue as an entity in waitFor(signal) does, so it is counted, ranked and signalled in the same way. A wait may include at most one signal trigger, because an entity can wait in only one queue.