InterpolatedMovement

class InterpolatedMovement @JvmOverloads constructor(parent: ModelElement, path: MovePathIfc, var stepSize: Double, velocityOf: () -> Double, onJourneyEnded: () -> Unit? = null, name: String? = null) : ModelElement(source)

The clockwork of a journey: plan a step, wait for it, advance, plan the next.

Below every substrate, because every substrate needs it. A guide path discretises a journey at zone boundaries, which its geometry fixes; a continuous projection and a free path discretise it at interpolation steps, which the modeller chooses. The second and third are the same clockwork over different geometry, and this is that clockwork, in the package both of them are already above.

It is driven by events the vehicle owns, not by the traveller's process. That is what VehicleMovementIfc requires and why it could not be built on a suspending integration loop: a fleet's control loop has to be able to command a vehicle from somewhere other than that vehicle's process, and the two ends of a wait must not disagree about where the wake will come from. So beginTravelTo commands and returns a queue, and whoever is waiting is resumed from it.

A step is planned before it is waited for. The direction and the distance are fixed when the event is scheduled and applied when it fires, so the vehicle covers the ground the elapsed time paid for. A redirection arriving mid-step therefore costs the step it interrupts rather than being free, and is observed at most stepSize/velocity later -- the same latency a guide path has at its next boundary, and for the same reason: something between two places cannot stop and turn.

Parameters

parent

the vehicle this belongs to. A model element of its own so that it can schedule its own steps and be reset between replications without the vehicle remembering to

path

the geometry to move through

stepSize

how far apart the decision points are, in the geometry's own distance units. Ignored where the geometry cannot interpolate, since there the whole leg is one step

velocityOf

how fast the vehicle is going, asked once per step so that a vehicle whose speed depends on what it is carrying answers for itself

onJourneyEnded

told whenever a journey stops, by arrival or by halt, and told before whoever was waiting is woken. For a vehicle that keeps its own flags about whether it is moving

Constructors

Link copied to clipboard
constructor(parent: ModelElement, path: MovePathIfc, stepSize: Double, velocityOf: () -> Double, onJourneyEnded: () -> Unit? = null, name: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A veto asked at every step boundary: may the vehicle go on past this one?

Link copied to clipboard

Where the journey in progress is going, or null when there is none.

Link copied to clipboard

How far the vehicle has travelled this replication. Never decreases.

Link copied to clipboard

True while the vehicle is stopped short of where it was going, with nothing scheduled.

Link copied to clipboard

True while a journey is under way, whether or not it is halted.

Link copied to clipboard

How long it has spent travelling this replication. Never decreases.

Link copied to clipboard
Link copied to clipboard

Where whoever is waiting for this vehicle waits. Reports nothing; it is plumbing.

Functions

Link copied to clipboard

Sends the vehicle to to and hands back the queue to wait in.

Link copied to clipboard
fun halt()

Stops the vehicle where it stands and wakes whoever was waiting for it.

Link copied to clipboard
protected open override fun initialize()

Forgets any journey and zeroes the odometers, at the start of every replication.

Link copied to clipboard
fun recordExternalMove(distance: Double, duration: Double)

Records a journey this machinery did not make.

Link copied to clipboard

Starts a halted vehicle again from where it stopped. Harmless on one that is not halted.