Place A station or yard
A station, shunting yard, staging yard, siding or depot: a named group of tracks (blocks). You find them in places, and separately in stations, yards and staging.
用途: To hear trains arrive and leave without knowing which they are (a station announcement), to see which tracks are free, and to step in when an agent waits for a track here.
stations.South.onArrival { Train train ->
announce "The ${train.name} is arriving"
}
log "${stations.South.freeTracks.size()} tracks free"プロパティ
name → String
Its name.
The place's name.
log stations.South.namekind → String
station, yard, staging, siding, industrialSiding or depot.
The kind, as text: station, yard, staging, siding, industrialSiding or depot.
if (places.Depot.kind == "depot") {
log "a depot"
}blocks → List<Block>
Its tracks.
The place's tracks, as a list of Block. Empty when the place covers no blocks in the diagram.
stations.South.blocks.each { Block track ->
log "${track.name}: ${track.occupied ? "occupied" : "free"}"
}freeTracks → List<Block>
Its tracks that are free now.
The tracks free now: blocks filtered on not occupied. Asked live.
if (stations.South.freeTracks.empty) {
say "South is full"
}イベント
onWaiting → Waiting
When a train's agent waits for its way here: at once and every half minute.
Fires when a train's agent waits for its route to this place: at once, and every half minute. Gives a Waiting.
stations.South.onWaiting { Waiting w ->
log "${w.train.name} waits ${w.seconds} s for South"
}onTrackChosen → TrackChoice
When a train's agent chose its track here.
Fires when a train's agent chose a track here. Gives a TrackChoice with train, track and place.
stations.South.onTrackChosen { TrackChoice c ->
announce "The ${c.train.name} arrives on track ${c.block.name}"
}onArrival → Train
When a train comes into it.
Fires when a train comes into the place. Gives the Train.
stations.South.onArrival { Train train ->
announce "The ${train.name} is arriving"
}onDeparture → Train
When a train has left it altogether.
Fires when a train has left the place altogether. Gives the Train.
stations.South.onDeparture { Train train ->
log "${train.name} has left"
}