WindowedAnimationSink

class WindowedAnimationSink(delegate: AnimationSink, startTime: Double, endTime: Double, currentTime: () -> Double) : AnimationSink(source)

A filtering AnimationSink that forwards events to delegate only while the simulated clock lies within the closed time window [startTime, endTime].

This is a decorator: it wraps another sink and adds time filtering without that sink knowing anything about windows. It exists so a modeler can animate a bounded horizon of a long run (e.g. [500.0, 600.0] of a 10,000-hour run) while paying essentially nothing for the rest of the run — because every emission site checks isActive before constructing an event, and isActive is false outside the window, no event objects are created outside the window.

Note on the opening frame: filtering raw events to the window does not, by itself, reproduce the model's state at startTime (entities already queued, resources already busy, moves already in flight). A correct opening frame requires a state snapshot emitted at the window boundary; that snapshot is produced later by the animation controller and its emitters (it is not this decorator's responsibility).

Parameters

delegate

the downstream sink that actually records in-window events

startTime

inclusive lower bound of the capture window (>= 0)

endTime

inclusive upper bound of the capture window (>= startTime)

currentTime

supplies the model's current simulated time when queried

Constructors

Link copied to clipboard
constructor(delegate: AnimationSink, startTime: Double, endTime: Double, currentTime: () -> Double)

Properties

Link copied to clipboard
open override val isActive: Boolean

Whether this sink is collecting events. Emission sites must check this before building and emitting an event. A false value must be a cheap, branch-predictable constant.

Functions

Link copied to clipboard
open override fun emit(event: AnimationEvent)

Records event. Called only when isActive is true. Must not throw on the simulation thread; implementations should fail soft (e.g. drop and log) rather than disrupt the run.

Link copied to clipboard
open override fun onExperimentEnd()

Called once after the final replication of the experiment.

Link copied to clipboard
open override fun onReplicationEnd(replicationNumber: Int)

Called at the end of replication replicationNumber (1-based).

Link copied to clipboard
open override fun onReplicationStart(replicationNumber: Int)

Called at the start of replication replicationNumber (1-based).