AgentSignal

class AgentSignal(val name: String = "AgentSignal")(source)

A broadcast trigger that statecharts can listen for. Unlike AgentMessage (point-to-point) and onCondition (a predicate tested in the C-phase), a signal is an explicit notification fired by user code — typically at the end of a transition, a phase change, or an externally-driven schedule event.

A signal is a POJO: not a ModelElement, no automatic lifecycle. Create one wherever it's convenient (typically as a property of the AgentModel), share it across as many states and statecharts as needed, and call fire when the event occurs.

Subscriptions are managed automatically by the statechart runtime: states with onSignal(s) { ... } subscribe when entered and unsubscribe on exit (including via stop() at end-of-replication). Users do not interact with the subscriber list directly.

Differences from KSL's ksl.modeling.entity.Signal:

  • That one is a ModelElement that holds suspended entities and resumes them. It's a process-view primitive.

  • This one is a statechart broadcast — observers, not coroutines.

Parameters

name

optional display name for diagnostics

Constructors

Link copied to clipboard
constructor(name: String = "AgentSignal")

Properties

Link copied to clipboard
Link copied to clipboard

Number of currently-subscribed handlers (for diagnostics).

Functions

Link copied to clipboard
fun fire()

Fire the signal. All currently-subscribed handlers run synchronously in the order they subscribed. If a handler triggers a transition that unsubscribes (or subscribes a different handler), only handlers active at the start of fire are invoked for this call.