# 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 Test(jmri.jmrit.automat.AbstractAutomaton) : def init(self): loco1 = 5574 loco2 = 6722 print "Blue Loop Test: 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 Test 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 Test: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 Test: runs East to West from LA Yard West Throat to LA Yard East Throat" print "Blue Loop Test: lv yard west,all around blue and back to east yard" #print "Blue Loop Test: Set Speed 10%" self.throttle.setSpeedSetting(0.15) # 15% of throttle #print "Blue Loop Test: wait for sensor LS269 to become Active" self.LS269 = sensors.provideSensor("269") #print "Blue Loop Test: Waiting for Sensor LS269" self.waitSensorActive(self.LS269) self.throttle.setIsForward(False) #print "Blue Loop Test: 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 "Wait for signal LH263 to be NOT RED" self.LH263 = signals.getBySystemName("LH263") if self.LH263.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH263 is RED!" while self.LH263.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS269 to become Inactive" self.waitSensorInactive(self.LS269) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS270 to become Active" self.LS270 = sensors.provideSensor("270") #print "Blue Loop Test: Waiting for Sensor LS270" self.waitSensorActive(self.LS270) #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 LH265 to be NOT RED" self.LH265 = signals.getBySystemName("LH265") if self.LH265.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH265 is RED!" while self.LH265.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS270 to become Inactive" self.waitSensorInactive(self.LS270) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS257 to become Active" self.LS257 = sensors.provideSensor("257") #print "Blue Loop Test: Waiting for Sensor LS257" self.waitSensorActive(self.LS257) #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 LH279 to be NOT RED" self.LH279 = signals.getBySystemName("LH279") if self.LH279.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH279 is RED!" while self.LH279.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS257 to become Inactive" self.waitSensorInactive(self.LS257) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS260 to become Active" self.LS260 = sensors.provideSensor("260") #print "Blue Loop Test: 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 Test: wait for sensor LS260 to become Inactive" self.waitSensorInactive(self.LS260) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS260 to become Active" self.LS260 = sensors.provideSensor("260") #print "Blue Loop Test: Waiting for Sensor LS260" self.waitSensorActive(self.LS260) #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 "Wait for signal LH287 to be NOT RED" self.LH287 = signals.getBySystemName("LH287") if self.LH287.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH287 is RED!" while self.LH287.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS260 to become Inactive" self.waitSensorInactive(self.LS260) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS272 to become Active" self.LS272 = sensors.provideSensor("272") #print "Blue Loop Test: Waiting for Sensor LS272" self.waitSensorActive(self.LS272) #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 LH319 to be NOT RED" self.LH319 = signals.getBySystemName("LH319") if self.LH319.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH319 is RED!" while self.LH319.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS272 to become Inactive" self.waitSensorInactive(self.LS272) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS262 to become Active" self.LS262 = sensors.provideSensor("262") #print "Blue Loop Test: Waiting for Sensor LS262" self.waitSensorActive(self.LS262) #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 LH305 to be NOT RED" self.LH305 = signals.getBySystemName("LH305") if self.LH305.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH305 is RED!" while self.LH305.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS262 to become Inactive" self.waitSensorInactive(self.LS262) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS264 to become Active" self.LS264 = sensors.provideSensor("264") #print "Blue Loop Test: Waiting for Sensor LS264" self.waitSensorActive(self.LS264) #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 Test: wait for sensor LS264 to become Inactive" self.waitSensorInactive(self.LS264) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS268 to become Active" self.LS268 = sensors.provideSensor("268") #print "Blue Loop Test: Waiting for Sensor LS268" self.waitSensorActive(self.LS268) #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 LH369 to be NOT RED" self.LH369 = signals.getBySystemName("LH369") if self.LH369.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH369 is RED!" while self.LH369.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS268 to become Inactive" self.waitSensorInactive(self.LS268) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS273 to become Active" self.LS273 = sensors.provideSensor("273") #print "Blue Loop Test: Waiting for Sensor LS273" self.waitSensorActive(self.LS273) #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 LH441 to be NOT RED" self.LH441 = signals.getBySystemName("LH441") if self.LH441.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH441 is RED!" while self.LH441.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS273 to become Inactive" self.waitSensorInactive(self.LS273) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS274 to become Active" self.LS274 = sensors.provideSensor("274") #print "Blue Loop Test: Waiting for Sensor LS274" self.waitSensorActive(self.LS274) #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 LH431 to be NOT RED" self.LH431 = signals.getBySystemName("LH431") if self.LH431.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH431 is RED!" while self.LH431.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS274 to become Inactive" self.waitSensorInactive(self.LS274) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS276 to become Active" self.LS276 = sensors.provideSensor("276") #print "Blue Loop Test: Waiting for Sensor LS276" self.waitSensorActive(self.LS276) #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 LH345 to be NOT RED" self.LH345 = signals.getBySystemName("LH345") if self.LH345.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH345 is RED!" while self.LH345.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS276 to become Inactive" self.waitSensorInactive(self.LS276) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS278 to become Active" self.LS278 = sensors.provideSensor("278") #print "Blue Loop Test: Waiting for Sensor LS278" self.waitSensorActive(self.LS278) #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 "Blue Loop Test: wait for sensor LS278 to become Inactive" self.waitSensorInactive(self.LS278) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS282 to become Active" self.LS282 = sensors.provideSensor("282") #print "Blue Loop Test: Waiting for Sensor LS282" self.waitSensorActive(self.LS282) #print "Blue Loop Test: wait for sensor LS282 to become Inactive" self.waitSensorInactive(self.LS282) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS282 to become Active" self.LS282 = sensors.provideSensor("282") #print "Blue Loop Test: Waiting for Sensor LS282" self.waitSensorActive(self.LS282) #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 "Wait for signal LH325 to be NOT RED" self.LH325 = signals.getBySystemName("LH325") if self.LH325.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH325 is RED!" while self.LH325.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS282 to become Inactive" self.waitSensorInactive(self.LS282) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS287 to become Active" self.LS287 = sensors.provideSensor("287") #print "Blue Loop Test: Waiting for Sensor LS287" self.waitSensorActive(self.LS287) #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 "Wait for signal LH321 to be NOT RED" self.LH321 = signals.getBySystemName("LH321") if self.LH321.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH321 is RED!" while self.LH321.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS287 to become Inactive" self.waitSensorInactive(self.LS287) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS267 to become Active" self.LS267 = sensors.provideSensor("267") #print "Blue Loop Test: 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 Test: wait for sensor LS267 to become Inactive" self.waitSensorInactive(self.LS267) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS267 to become Active" self.LS267 = sensors.provideSensor("267") #print "Blue Loop Test: Waiting for Sensor LS267" self.waitSensorActive(self.LS267) #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 LH303 to be NOT RED" self.LH303 = signals.getBySystemName("LH303") if self.LH303.getAppearance() == RED : self.throttle.setSpeedSetting(0) #print "Blue Loop Test: wait while East to West signal LH303 is RED!" while self.LH303.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS267 to become Inactive" self.waitSensorInactive(self.LS267) self.throttle.setSpeedSetting(0.35) #print "Blue Loop Test: wait for sensor LS265 to become Active" self.LS265 = sensors.provideSensor("265") #print "Blue Loop Test: Waiting for Sensor LS265" self.waitSensorActive(self.LS265) self.throttle.setIsForward(False) #print "Blue Loop Test: 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 "Blue Loop Test: wait for sensor LS265 to become Inactive" self.waitSensorInactive(self.LS265) self.throttle.setSpeedSetting(0.35) self.locoLeaving() #dispose/release locos print "Blue Loop Test script has completed!" return 0 # to stop - causes routine to NOT be called again # end of class definition