# 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 AnthEl_LAyard(jmri.jmrit.automat.AbstractAutomaton) : def init(self): loco1 = 5574 loco2 = 6722 print "AnthEl_LAyard: 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 "AnthEl_LAyard 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 "AnthEl_LAyard: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 "AnthEl_LAyard: runs West to East from AnthonyvilleStation to LA Yard West Throat" print "AnthEl_LAyard: Shuttle from Anthonyville El station to LA yard West throat" #print "AnthEl_LAyard: Set Speed 10%" self.throttle.setSpeedSetting(0.15) # 15% of throttle #print "AnthEl_LAyard: wait for sensor LS262 to become Active" self.LS262 = sensors.provideSensor("262") #print "AnthEl_LAyard: Waiting for Sensor LS262" self.waitSensorActive(self.LS262) #print "AnthEl_LAyard: stop the lead loco and wait" self.throttle.setSpeedSetting(0) # stop the loco self.waitMsec(15000) self.throttle.setIsForward(True) #print "AnthEl_LAyard: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.05) #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 "AnthEl_LAyard: wait while West to East signal LH313 is RED!" while self.LH313.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: turn on the bell" self.throttle2.setF1(True) # turn on bell #print "AnthEl_LAyard: turn on the horn" self.throttle2.setF2(True) # turn on horn #print "AnthEl_LAyard: slowly start the lead loco" self.throttle.setSpeedSetting(0.00) #print "AnthEl_LAyard: time slowly starting the lead loco" self.waitMsec(20000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "AnthEl_LAyard: wait for sensor LS262 to become Inactive" self.waitSensorInactive(self.LS262) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS272 to become Active" self.LS272 = sensors.provideSensor("272") #print "AnthEl_LAyard: 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 "AnthEl_LAyard: wait for sensor LS272 to become Inactive" self.waitSensorInactive(self.LS272) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS260 to become Active" self.LS260 = sensors.provideSensor("260") #print "AnthEl_LAyard: 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 "AnthEl_LAyard: wait for sensor LS260 to become Inactive" self.waitSensorInactive(self.LS260) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS260 to become Active" self.LS260 = sensors.provideSensor("260") #print "AnthEl_LAyard: 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 "AnthEl_LAyard: wait while West to East signal LH273 is RED!" while self.LH273.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS260 to become Inactive" self.waitSensorInactive(self.LS260) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS257 to become Active" self.LS257 = sensors.provideSensor("257") #print "AnthEl_LAyard: 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 "AnthEl_LAyard: wait while West to East signal LH269 is RED!" while self.LH269.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS257 to become Inactive" self.waitSensorInactive(self.LS257) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS270 to become Active" self.LS270 = sensors.provideSensor("270") #print "AnthEl_LAyard: 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 "AnthEl_LAyard: wait while West to East signal LH257 is RED!" while self.LH257.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS270 to become Inactive" self.waitSensorInactive(self.LS270) self.throttle.setSpeedSetting(0.35) #print "AnthEl_LAyard: wait for sensor LS269 to become Active" self.LS269 = sensors.provideSensor("269") #print "AnthEl_LAyard: Waiting for Sensor LS269" self.waitSensorActive(self.LS269) #print "AnthEl_LAyard: slow the lead loco" self.throttle.setSpeedSetting(0.05) #print "AnthEl_LAyard: turn on the bell" self.throttle2.setF1(True) # turn on bell self.throttle2.setF2(True) # turn on horn #print "AnthEl_LAyard: time slowing the lead loco" self.waitMsec(20000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "AnthEl_LAyard: stop the lead loco and wait" self.throttle.setSpeedSetting(0) # stop the loco self.waitMsec(15000) self.throttle.setIsForward(True) #print "AnthEl_LAyard: 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 "AnthEl_LAyard: wait for sensor LS269 to become Inactive" self.waitSensorInactive(self.LS269) self.throttle.setSpeedSetting(0.35) self.locoLeaving() #dispose/release locos print "AnthEl_LAyard script has completed!" return 0 # to stop - causes routine to NOT be called again # end of class definition