On Main Leg of Trailing-Point Turnout
This signal is along the main route through a turnout, which is
defined as the direction taken by trains when the turnout is closed.
It's protecting the frog of the turnout so that trains will stop before
running through a turnout set against them.
void doTrailingMain() {
int appearance = SignalHead.GREEN;
int oldAppearance = ((SignalHead)outputs[0]).getAppearance();
// check for yellow, flashing yellow overriding green
if (watchedSignal1!=null && protectWithFlashing && watchedSignal1.getAppearance()==SignalHead.YELLOW)
appearance = SignalHead.FLASHYELLOW;
if (watchedSignal1!=null && watchedSignal1.getAppearance()==SignalHead.RED)
appearance = SignalHead.YELLOW;
// check for red overriding yellow or green
if (watchSensor1!=null && watchSensor1.getKnownState() != Sensor.INACTIVE) appearance = SignalHead.RED;
if (watchSensor2!=null && watchSensor2.getKnownState() != Sensor.INACTIVE) appearance = SignalHead.RED;
if (watchSensor3!=null && watchSensor3.getKnownState() != Sensor.INACTIVE) appearance = SignalHead.RED;
if (watchSensor4!=null && watchSensor4.getKnownState() != Sensor.INACTIVE) appearance = SignalHead.RED;
if (watchTurnout!=null && watchTurnout.getKnownState() != Turnout.CLOSED)
appearance = SignalHead.RED;
// show result if changed
if (appearance != oldAppearance)
((SignalHead)outputs[0]).setAppearance(appearance);
}