# 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 Stack Mtn Loop E(jmri.jmrit.automat.AbstractAutomaton) : def init(self): loco1 = 5574 loco2 = 6722 print "Stack Mtn Loop E: 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 "Stack Mtn Loop E 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 "Stack Mtn Loop E: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 "Stack Mtn Loop E: runs West to East from Stack Mtn West Entry to Stack Mtn West Entry" print "Stack Mtn Loop E: loop starting at West entry" #print "Stack Mtn Loop E: Set Speed 10%" self.throttle.setSpeedSetting(0.15) # 15% of throttle #print "Stack Mtn Loop E: wait for sensor LS13 to become Active" self.LS13 = sensors.provideSensor("13") #print "Stack Mtn Loop E: Waiting for Sensor LS13" self.waitSensorActive(self.LS13) self.throttle.setIsForward(False) #print "Stack Mtn Loop E: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS13 to become Inactive" self.waitSensorInactive(self.LS13) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS12 to become Active" self.LS12 = sensors.provideSensor("12") #print "Stack Mtn Loop E: Waiting for Sensor LS12" self.waitSensorActive(self.LS12) #print "Wait for Turnout LT100 to be THROWN" self.LT100 = turnouts.getTurnout("LT100") if self.LT100.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT100.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS12 to become Inactive" self.waitSensorInactive(self.LS12) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS11 to become Active" self.LS11 = sensors.provideSensor("11") #print "Stack Mtn Loop E: Waiting for Sensor LS11" self.waitSensorActive(self.LS11) #print "Wait for Turnout LT11 to be THROWN" self.LT11 = turnouts.getTurnout("LT11") if self.LT11.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT11.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS11 to become Inactive" self.waitSensorInactive(self.LS11) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS14 to become Active" self.LS14 = sensors.provideSensor("14") #print "Stack Mtn Loop E: Waiting for Sensor LS14" self.waitSensorActive(self.LS14) #print "Stack Mtn Loop E: wait for sensor LS14 to become Inactive" self.waitSensorInactive(self.LS14) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS14 to become Active" self.LS14 = sensors.provideSensor("14") #print "Stack Mtn Loop E: Waiting for Sensor LS14" self.waitSensorActive(self.LS14) #print "Stack Mtn Loop E: wait for sensor LS14 to become Inactive" self.waitSensorInactive(self.LS14) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS14 to become Active" self.LS14 = sensors.provideSensor("14") #print "Stack Mtn Loop E: Waiting for Sensor LS14" self.waitSensorActive(self.LS14) #print "Wait for Turnout LT98 to be THROWN" self.LT98 = turnouts.getTurnout("LT98") if self.LT98.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT98.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS14 to become Inactive" self.waitSensorInactive(self.LS14) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS13 to become Active" self.LS13 = sensors.provideSensor("13") #print "Stack Mtn Loop E: Waiting for Sensor LS13" self.waitSensorActive(self.LS13) self.throttle.setIsForward(False) #print "Stack Mtn Loop E: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.35) #print "Wait for Turnout LT98 to be THROWN" self.LT98 = turnouts.getTurnout("LT98") if self.LT98.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT98.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "Stack Mtn Loop E: wait for sensor LS13 to become Inactive" self.waitSensorInactive(self.LS13) self.throttle.setSpeedSetting(0.35) self.locoLeaving() #dispose/release locos print "Stack Mtn Loop E script has completed!" return 0 # to stop - causes routine to NOT be called again # end of class definition