# This Jython script created by MRRM software from MTS Associates # Copyright 2004 # using a dispatcher; no autostart; no transponder # no debug statements; stop at end of script; Sound is used import jarray import jmri class Blue Loop Reverse(jmri.jmrit.automat.AbstractAutomaton) : def init(self): loco1 = 5574 loco2 = 6722 print "Blue Loop Reverse: lead loco is "5574" has entered this automaton. loco2 is "6722" If zero, there is no 2nd sound loco. Sound is in primary loco. " if loco1 > 127 : self.slong1 = 1 #Long address else : self.slong1 = 0 #Short address self.throttle = self.getThrottle(loco1, self.slong1) #get throttle for loco1 self.throttle.setF0(True) # turn on headlight self.throttle.setIsForward(True) # Forward direction print "Blue Loop Reverse Sound is controlled through loco2!" if loco2 > 127 : self.slong2=1 #Long address else : self.slong2=0 #Short address self.throttle2 = self.getThrottle(loco2, self.slong2)#get throttle for loco2 self.throttle2.setF0(True) # turn on headlight self.throttle2.setIsForward(True) # Forward direction def locoLeaving(self): self.waitMsec(10000) #continue on for 10 seconds #This code is invoked as handle script completes print "Blue Loop Reverse:Stop locos then dispatch" self.throttle.setSpeedSetting(0) # stop loco self.throttle.dispatch() # dispatch/release loco1 self.throttle2.dispatch() # dispatch/release loco2 def handle(self): #Handle is main routine for this class #This code will run exactly one time, in an independent thread, when invoked print "Blue Loop Reverse: runs West to East from LA Yard East Throat to LA Yard West Throat" print "Blue Loop Reverse: go eastward around Blue loop" #print "Blue Loop Reverse: Set Speed 10%" self.throttle.setSpeedSetting(0.15) # 15% of throttle #print "Blue Loop Reverse: wait for sensor LS265 to become Active" self.LS265 = sensors.provideSensor("265") #print "Blue Loop Reverse: Waiting for Sensor LS265" self.waitSensorActive(self.LS265) self.throttle.setIsForward(False) #print "Blue Loop Reverse: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.35) #print "Wait for Turnout LT181 to be THROWN" self.LT181 = turnouts.getTurnout("LT181") if self.LT181.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT181.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH299 to be NOT RED" self.LH299 = signals.getBySystemName("LH299") if self.LH299.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH299 is RED!" while self.LH299.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS265 to become Inactive" self.waitSensorInactive(self.LS265) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS267 to become Active" self.LS267 = sensors.provideSensor("267") #print "Blue Loop Reverse: Waiting for Sensor LS267" self.waitSensorActive(self.LS267) #print "Wait for Turnout LT182 to be CLOSED" self.LT182 = turnouts.getTurnout("LT182") if self.LT182.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT182.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS267 to become Inactive" self.waitSensorInactive(self.LS267) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS267 to become Active" self.LS267 = sensors.provideSensor("267") #print "Blue Loop Reverse: Waiting for Sensor LS267" self.waitSensorActive(self.LS267) #print "Wait for Turnout LT15 to be CLOSED" self.LT15 = turnouts.getTurnout("LT15") if self.LT15.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT15.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS267 to become Inactive" self.waitSensorInactive(self.LS267) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS287 to become Active" self.LS287 = sensors.provideSensor("287") #print "Blue Loop Reverse: Waiting for Sensor LS287" self.waitSensorActive(self.LS287) #print "Wait for Turnout LT135 to be THROWN" self.LT135 = turnouts.getTurnout("LT135") if self.LT135.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT135.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS287 to become Inactive" self.waitSensorInactive(self.LS287) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS282 to become Active" self.LS282 = sensors.provideSensor("282") #print "Blue Loop Reverse: Waiting for Sensor LS282" self.waitSensorActive(self.LS282) #print "Blue Loop Reverse: wait for sensor LS282 to become Inactive" self.waitSensorInactive(self.LS282) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS282 to become Active" self.LS282 = sensors.provideSensor("282") #print "Blue Loop Reverse: Waiting for Sensor LS282" self.waitSensorActive(self.LS282) #print "Wait for Turnout LT11 to be CLOSED" self.LT11 = turnouts.getTurnout("LT11") if self.LT11.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT11.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH339 to be NOT RED" self.LH339 = signals.getBySystemName("LH339") if self.LH339.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH339 is RED!" while self.LH339.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS282 to become Inactive" self.waitSensorInactive(self.LS282) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS278 to become Active" self.LS278 = sensors.provideSensor("278") #print "Blue Loop Reverse: Waiting for Sensor LS278" self.waitSensorActive(self.LS278) #print "Wait for Turnout LT9 to be CLOSED" self.LT9 = turnouts.getTurnout("LT9") if self.LT9.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT9.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH359 to be NOT RED" self.LH359 = signals.getBySystemName("LH359") if self.LH359.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH359 is RED!" while self.LH359.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS278 to become Inactive" self.waitSensorInactive(self.LS278) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS276 to become Active" self.LS276 = sensors.provideSensor("276") #print "Blue Loop Reverse: Waiting for Sensor LS276" self.waitSensorActive(self.LS276) #print "Wait for Turnout LT154 to be CLOSED" self.LT154 = turnouts.getTurnout("LT154") if self.LT154.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT154.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH425 to be NOT RED" self.LH425 = signals.getBySystemName("LH425") if self.LH425.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH425 is RED!" while self.LH425.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS276 to become Inactive" self.waitSensorInactive(self.LS276) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS274 to become Active" self.LS274 = sensors.provideSensor("274") #print "Blue Loop Reverse: Waiting for Sensor LS274" self.waitSensorActive(self.LS274) #print "Wait for Turnout LT153 to be CLOSED" self.LT153 = turnouts.getTurnout("LT153") if self.LT153.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT153.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH445 to be NOT RED" self.LH445 = signals.getBySystemName("LH445") if self.LH445.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH445 is RED!" while self.LH445.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS274 to become Inactive" self.waitSensorInactive(self.LS274) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS285 to become Active" self.LS285 = sensors.provideSensor("285") #print "Blue Loop Reverse: Waiting for Sensor LS285" self.waitSensorActive(self.LS285) #print "Wait for Turnout LT97 to be CLOSED" self.LT97 = turnouts.getTurnout("LT97") if self.LT97.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT97.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH375 to be NOT RED" self.LH375 = signals.getBySystemName("LH375") if self.LH375.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH375 is RED!" while self.LH375.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS285 to become Inactive" self.waitSensorInactive(self.LS285) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS268 to become Active" self.LS268 = sensors.provideSensor("268") #print "Blue Loop Reverse: Waiting for Sensor LS268" self.waitSensorActive(self.LS268) #print "Wait for Turnout LT183 to be CLOSED" self.LT183 = turnouts.getTurnout("LT183") if self.LT183.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT183.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS268 to become Inactive" self.waitSensorInactive(self.LS268) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS264 to become Active" self.LS264 = sensors.provideSensor("264") #print "Blue Loop Reverse: Waiting for Sensor LS264" self.waitSensorActive(self.LS264) #print "Wait for Turnout LT180 to be CLOSED" self.LT180 = turnouts.getTurnout("LT180") if self.LT180.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT180.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH311 to be NOT RED" self.LH311 = signals.getBySystemName("LH311") if self.LH311.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH311 is RED!" while self.LH311.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS264 to become Inactive" self.waitSensorInactive(self.LS264) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS262 to become Active" self.LS262 = sensors.provideSensor("262") #print "Blue Loop Reverse: Waiting for Sensor LS262" self.waitSensorActive(self.LS262) #print "Wait for Turnout LT177 to be CLOSED" self.LT177 = turnouts.getTurnout("LT177") if self.LT177.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT177.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH313 to be NOT RED" self.LH313 = signals.getBySystemName("LH313") if self.LH313.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH313 is RED!" while self.LH313.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS262 to become Inactive" self.waitSensorInactive(self.LS262) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS272 to become Active" self.LS272 = sensors.provideSensor("272") #print "Blue Loop Reverse: Waiting for Sensor LS272" self.waitSensorActive(self.LS272) #print "Wait for Turnout LT8 to be CLOSED" self.LT8 = turnouts.getTurnout("LT8") if self.LT8.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT8.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS272 to become Inactive" self.waitSensorInactive(self.LS272) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS260 to become Active" self.LS260 = sensors.provideSensor("260") #print "Blue Loop Reverse: Waiting for Sensor LS260" self.waitSensorActive(self.LS260) #print "Wait for Turnout LT7 to be CLOSED" self.LT7 = turnouts.getTurnout("LT7") if self.LT7.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT7.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS260 to become Inactive" self.waitSensorInactive(self.LS260) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS260 to become Active" self.LS260 = sensors.provideSensor("260") #print "Blue Loop Reverse: Waiting for Sensor LS260" self.waitSensorActive(self.LS260) #print "Wait for Turnout LT6 to be CLOSED" self.LT6 = turnouts.getTurnout("LT6") if self.LT6.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT6.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH273 to be NOT RED" self.LH273 = signals.getBySystemName("LH273") if self.LH273.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH273 is RED!" while self.LH273.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS260 to become Inactive" self.waitSensorInactive(self.LS260) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS257 to become Active" self.LS257 = sensors.provideSensor("257") #print "Blue Loop Reverse: Waiting for Sensor LS257" self.waitSensorActive(self.LS257) #print "Wait for Turnout LT5 to be CLOSED" self.LT5 = turnouts.getTurnout("LT5") if self.LT5.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT5.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH269 to be NOT RED" self.LH269 = signals.getBySystemName("LH269") if self.LH269.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH269 is RED!" while self.LH269.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS257 to become Inactive" self.waitSensorInactive(self.LS257) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS270 to become Active" self.LS270 = sensors.provideSensor("270") #print "Blue Loop Reverse: Waiting for Sensor LS270" self.waitSensorActive(self.LS270) #print "Wait for Turnout LT4 to be THROWN" self.LT4 = turnouts.getTurnout("LT4") if self.LT4.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT4.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Wait for signal LH257 to be NOT RED" self.LH257 = signals.getBySystemName("LH257") if self.LH257.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Reverse: wait while West to East signal LH257 is RED!" while self.LH257.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS270 to become Inactive" self.waitSensorInactive(self.LS270) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS269 to become Active" self.LS269 = sensors.provideSensor("269") #print "Blue Loop Reverse: Waiting for Sensor LS269" self.waitSensorActive(self.LS269) self.throttle.setIsForward(False) #print "Blue Loop Reverse: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.35) #print "Wait for Turnout LT4 to be THROWN" self.LT4 = turnouts.getTurnout("LT4") if self.LT4.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT4.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Reverse: wait for sensor LS269 to become Inactive" self.waitSensorInactive(self.LS269) self.throttle.setSpeedSetting(0.35) self.locoLeaving() #dispose/release locos print "Blue Loop Reverse script has completed!" return 0 # to stop - causes routine to NOT be called again # end of class definition