NRF SDK 0.9

Creating a mod

Read three signalling mod decisions

AB Signalisation lumineuse excerpts illustrate the separation between observation, decision, appearance and driving.

An observed approach, a chosen opening

Prerequisite: familiarity with signalModel and rules. These fragments come from AB Signalisation lumineuse; CarreAspect, CarreReason and CarreDecision belong to that mod. They explain a mechanism without constituting a standalone project.

Carré Avertissement model declaration
observeApproach(blocks = 2)
End of the rule, after its other checks
if (!context.trainApproaching)
    return closed(CarreReason.AwaitingApproach)
return CarreDecision(CarreAspect.Warning, CarreReason.ApproachConfirmed)

The SDK supplies the approach observation; the mod decides whether it permits opening. Settings, freshness, failure, forced stop and downstream occupancy are handled before these lines. Any tolerance for unknown downstream state belongs to the specific model, not every signal.

Prepare a reusable animation

Animation description in BalTextures
private val redFlash = blink(
    on = "imgs/ca/sem_bal/tex09.svg",
    off = "imgs/ca/sem_bal/tex10.svg",
    everyMs = 500
)
Model animation selection
appearance { BalTextures.forAspect(it.aspect) }

The mod prepares descriptions once and chooses the one for the current aspect. The SDK uses simulated time to determine phase. The callback should not alternate images itself using real time. A static model can simply declare images.

Connect an instruction to the closure reason

BAL driving calculation branch
BalAspect.S ->
    if (decision.reason == BalReason.BlockOccupied)
        AutomaticDriving.restrictedUntilNextSignal(
            entrySpeedMps = 0.0,
            maximumSpeedMps = ON_SIGHT_SPEED,
            stopFirst = true
        )
    else AutomaticDriving.stop()

For closure caused by occupancy, AB Signalisation lumineuse requests a stop before restricted movement until the next signal. Other reasons request a stop without that permission. ON_SIGHT_SPEED is a speed chosen by the mod, in m/s. This excerpt does not establish a universal railway rule.