A magnet under the train operates reed switches positioned on the track.
The first reed switch changes the signal to red as the train passes, then further
along the track a second reed switch changes the signal back to green ready for
the next train. The isolated section of track just in front of the signal is
switched off by the relay when the signal is red so a train will stop
automatically at the red signal.