SResource Animation Emitter
class SResourceAnimationEmitter(resource: SResource) : ModelElementObserver, ResourceFailureListenerIfc(source)
Emits an AnimationEvent.ResourceStateChanged whenever the station-package SResource changes state. This is the station counterpart to ksl.animation.emitters.ResourceAnimationEmitter (Phase 2.2): SResource is a different type that does not fire AllocationListenerIfc, so it needs its own emitter.
It observes the resource's busy-count response — incremented on seize, decremented on release — so every busy/idle transition produces an event; and it listens for failures via ResourceFailureListenerIfc so the failed state is captured too. Register with both:
val emitter = SResourceAnimationEmitter(resource)
(resource.numBusyUnits as ModelElement).attachModelElementObserver(emitter)
resource.attachResourceFailureListener(emitter)Content copied to clipboard
The reported state is one of "Failed", "Busy", "Idle", or "Inactive"; busy units are capacity - numAvailableUnits. The resource is unchanged.
Parameters
resource
the station resource to animate