pt
Faça login

← Voltar à referência da API

Block A block

A stretch of track with a detector, as in the diagram: a track in a station, a stretch of open line. It knows whether it is occupied and which station it belongs to, and tells when it becomes occupied or free and which train enters or leaves it.

Para quê: For anything tied to a place on the layout: a level crossing, a signal, a light, counting the trains that pass. onOccupied and onFree come from the detector (anything that runs); onEntered and onLeft give the train.

blocks.B7.onOccupied {
   output(30).green()
}
if (blocks.B3.occupied) { log "B3 is occupied" }

Propriedades

name → String

Its name.

The block's name in the diagram.

log blocks.B3.name

occupied → boolean

Whether it is occupied now.

Whether the block is occupied now according to its detector(s). Asked live at every read.

if (!blocks.B3.occupied) {
   route(blocks.B1, blocks.B3).set()
}

place → Place

The station or yard it belongs to, or null.

The station or yard the block belongs to, or null for a block on the open line.

blocks.B3.onEntered { Train t ->
   log "${t.name} in ${blocks.B3.place?.name ?: "the open line"}"
}

Eventos

onOccupied → Block

When it becomes occupied.

Fires when the detector reports the block occupied, by anything at all. Needs no parameter; the closure may take the Block.

blocks.B7.onOccupied {
   output(30).green()
}

onFree → Block

When it becomes free.

Fires when the detector reports the block free.

blocks.B7.onFree {
   output(30).red()
}

onEntered → Train

When a train's front comes into it.

Fires when a train's front enters the block, as TRAX Control follows trains. Gives the Train. Only for trains placed on the layout.

blocks.B3.onEntered { Train train ->
   log "${train.name} enters B3"
}

onLeft → Train

When a train has left it altogether.

Fires when a train has left the block altogether. Gives the Train.

blocks.B3.onLeft { Train train ->
   log "${train.name} out of B3"
}