← Torna al riferimento dell'API
ModelClock The model clock
Your layout's clock, which can run faster than real time and can stand still; the timetable runs on it. You find it as clock.
A cosa serve: For anything that has to happen at a time on the layout: lights on at dusk, a train starting at seven. For real time use at and between without clock.
clock.at("19:30") {
output(40).green()
}
if (clock.between("22:00", "06:00")) { log "night" }Proprietà
time → LocalTime
The time of day on the layout now.
The time on the model clock, as a java.time.LocalTime. Compare with isAfter/isBefore; between is usually handier.
log "it is ${clock.time.hour}:${String.format("%02d", clock.time.minute)} on the layout"running → boolean
Whether it runs.
Whether the model clock runs. After TRAX Control restarts it stands still until started.
if (!clock.running) log "the model clock stands still"rate → double
How many times as fast as real time.
How many times as fast as real time the model clock runs (1 to 60).
log "model clock at ${clock.rate}x"Metodi
at
Every model day at this time.
A timer on the model clock: the closure runs every model day at that time, only while the clock runs. When the clock is set forward by more than ten minutes at once, the times skipped do not fire.
clock.at("06:00") {
say "Good morning: the first trains are starting"
}between → boolean
Whether the model time is between two times.
Whether the model time is between two times; over midnight when the first is later.
if (clock.between("20:00", "06:00")) output(40).green()