# 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 JD Power Plant(jmri.jmrit.automat.AbstractAutomaton) : def init(self): loco1 = 5574 loco2 = 6722 print "JD Power Plant: 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 "JD Power Plant 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 "JD Power Plant: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 "JD Power Plant: runs West to East from JDMineShip to HarrrisburgTower" print "JD Power Plant: Coal drag to HBIC for ConEd" #print "JD Power Plant: Set Speed 10%" self.throttle.setSpeedSetting(0.15) # 15% of throttle #print "JD Power Plant: wait for sensor LS196 to become Active" self.LS196 = sensors.provideSensor("196") #print "JD Power Plant: Waiting for Sensor LS196" self.waitSensorActive(self.LS196) #print "JD Power Plant: slow the lead loco" self.throttle.setSpeedSetting(0.05) #print "JD Power Plant: turn on the bell" self.throttle2.setF1(True) # turn on bell #print "JD Power Plant: time slowing the lead loco" self.waitMsec(20000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: stop the lead loco and wait" self.throttle.setSpeedSetting(0) # stop the loco self.waitMsec(5000) self.throttle.setIsForward(False) #print "JD Power Plant: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.05) #print "JD Power Plant: turn on the horn" self.throttle2.setF2(True) # turn on horn #print "JD Power Plant: slowly start the lead loco" self.throttle.setSpeedSetting(0.05) #print "JD Power Plant: time slowly starting the lead loco" self.waitMsec(20000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: wait for sensor LS196 to become Inactive" self.waitSensorInactive(self.LS196) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS13 to become Active" self.LS13 = sensors.provideSensor("13") #print "JD Power Plant: Waiting for Sensor LS13" self.waitSensorActive(self.LS13) #print "Wait for Turnout LT98 to be CLOSED" self.LT98 = turnouts.getTurnout("LT98") if self.LT98.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT98.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS13 to become Inactive" self.waitSensorInactive(self.LS13) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS16 to become Active" self.LS16 = sensors.provideSensor("16") #print "JD Power Plant: Waiting for Sensor LS16" self.waitSensorActive(self.LS16) #print "Wait for Turnout LT99 to be THROWN" self.LT99 = turnouts.getTurnout("LT99") if self.LT99.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT99.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS16 to become Inactive" self.waitSensorInactive(self.LS16) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS284 to become Active" self.LS284 = sensors.provideSensor("284") #print "JD Power Plant: Waiting for Sensor LS284" self.waitSensorActive(self.LS284) #print "JD Power Plant: slow the lead loco" self.throttle.setSpeedSetting(0.15) #print "JD Power Plant: turn on the bell" self.throttle2.setF1(True) # turn on bell #print "JD Power Plant: time slowing the lead loco" self.waitMsec(12000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: stop the lead loco and wait" self.throttle.setSpeedSetting(0) # stop the loco self.waitMsec(5000) self.throttle.setIsForward(True) #print "JD Power Plant: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.15) #print "Wait for Turnout LT99 to be CLOSED" self.LT99 = turnouts.getTurnout("LT99") if self.LT99.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT99.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: turn on the horn" self.throttle2.setF2(True) # turn on horn #print "JD Power Plant: slowly start the lead loco" self.throttle.setSpeedSetting(0.15) #print "JD Power Plant: time slowly starting the lead loco" self.waitMsec(5000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: wait for sensor LS284 to become Inactive" self.waitSensorInactive(self.LS284) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS283 to become Active" self.LS283 = sensors.provideSensor("283") #print "JD Power Plant: Waiting for Sensor LS283" self.waitSensorActive(self.LS283) #print "Wait for Turnout LT135 to be CLOSED" self.LT135 = turnouts.getTurnout("LT135") if self.LT135.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT135.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS283 to become Inactive" self.waitSensorInactive(self.LS283) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS282 to become Active" self.LS282 = sensors.provideSensor("282") #print "JD Power Plant: Waiting for Sensor LS282" self.waitSensorActive(self.LS282) #print "JD Power Plant: wait for sensor LS282 to become Inactive" self.waitSensorInactive(self.LS282) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS282 to become Active" self.LS282 = sensors.provideSensor("282") #print "JD Power Plant: 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 "JD Power Plant: wait while East to West signal LH339 is RED!" while self.LH339.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS282 to become Inactive" self.waitSensorInactive(self.LS282) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS278 to become Active" self.LS278 = sensors.provideSensor("278") #print "JD Power Plant: 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 "JD Power Plant: wait while East to West signal LH359 is RED!" while self.LH359.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS278 to become Inactive" self.waitSensorInactive(self.LS278) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS276 to become Active" self.LS276 = sensors.provideSensor("276") #print "JD Power Plant: 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 "JD Power Plant: wait while East to West signal LH425 is RED!" while self.LH425.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS276 to become Inactive" self.waitSensorInactive(self.LS276) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS274 to become Active" self.LS274 = sensors.provideSensor("274") #print "JD Power Plant: 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 "JD Power Plant: wait while East to West signal LH445 is RED!" while self.LH445.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS274 to become Inactive" self.waitSensorInactive(self.LS274) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS285 to become Active" self.LS285 = sensors.provideSensor("285") #print "JD Power Plant: 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 "JD Power Plant: wait while East to West signal LH375 is RED!" while self.LH375.getAppearance() == RED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS285 to become Inactive" self.waitSensorInactive(self.LS285) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS268 to become Active" self.LS268 = sensors.provideSensor("268") #print "JD Power Plant: 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 "JD Power Plant: wait for sensor LS268 to become Inactive" self.waitSensorInactive(self.LS268) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS264 to become Active" self.LS264 = sensors.provideSensor("264") #print "JD Power Plant: Waiting for Sensor LS264" self.waitSensorActive(self.LS264) #print "Wait for Turnout LT180 to be THROWN" self.LT180 = turnouts.getTurnout("LT180") if self.LT180.getCommandedState() <> THROWN : self.throttle.setSpeedSetting(0) #stop the train! while self.LT180.getCommandedState() <> THROWN : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS264 to become Inactive" self.waitSensorInactive(self.LS264) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS261 to become Active" self.LS261 = sensors.provideSensor("261") #print "JD Power Plant: Waiting for Sensor LS261" self.waitSensorActive(self.LS261) #print "Wait for Turnout LT178 to be CLOSED" self.LT178 = turnouts.getTurnout("LT178") if self.LT178.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT178.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS261 to become Inactive" self.waitSensorInactive(self.LS261) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS259 to become Active" self.LS259 = sensors.provideSensor("259") #print "JD Power Plant: Waiting for Sensor LS259" self.waitSensorActive(self.LS259) #print "JD Power Plant: slow the lead loco" self.throttle.setSpeedSetting(0.25) #print "JD Power Plant: turn on the bell" self.throttle2.setF1(True) # turn on bell #print "JD Power Plant: time slowing the lead loco" self.waitMsec(20000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: stop the lead loco and wait" self.throttle.setSpeedSetting(0) # stop the loco self.waitMsec(5000) self.throttle.setIsForward(True) #print "JD Power Plant: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.15) #print "Wait for Turnout LT178 to be CLOSED" self.LT178 = turnouts.getTurnout("LT178") if self.LT178.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT178.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: turn on the horn" self.throttle2.setF2(True) # turn on horn #print "JD Power Plant: slowly start the lead loco" self.throttle.setSpeedSetting(0.25) #print "JD Power Plant: time slowly starting the lead loco" self.waitMsec(5000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: wait for sensor LS259 to become Inactive" self.waitSensorInactive(self.LS259) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: wait for sensor LS6 to become Active" self.LS6 = sensors.provideSensor("6") #print "JD Power Plant: Waiting for Sensor LS6" self.waitSensorActive(self.LS6) #print "JD Power Plant: slow the lead loco" self.throttle.setSpeedSetting(0.25) #print "JD Power Plant: turn on the bell" self.throttle2.setF1(True) # turn on bell #print "JD Power Plant: time slowing the lead loco" self.waitMsec(20000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: stop the lead loco and wait" self.throttle.setSpeedSetting(0) # stop the loco self.waitMsec(5000) self.throttle.setIsForward(True) #print "JD Power Plant: depart stop; start the lead loco" self.throttle.setSpeedSetting(0.15) #print "Wait for Turnout LT178 to be CLOSED" self.LT178 = turnouts.getTurnout("LT178") if self.LT178.getCommandedState() <> CLOSED : self.throttle.setSpeedSetting(0) #stop the train! while self.LT178.getCommandedState() <> CLOSED : self.waitMsec(2500) self.throttle.setSpeedSetting(0.35) #print "JD Power Plant: turn on the horn" self.throttle2.setF2(True) # turn on horn #print "JD Power Plant: slowly start the lead loco" self.throttle.setSpeedSetting(0.25) #print "JD Power Plant: time slowly starting the lead loco" self.waitMsec(5000) self.throttle2.setF1(False) # turn off bell self.throttle2.setF2(False) # turn off horn #print "JD Power Plant: wait for sensor LS6 to become Inactive" self.waitSensorInactive(self.LS6) self.throttle.setSpeedSetting(0.35) self.locoLeaving() #dispose/release locos print "JD Power Plant script has completed!" return 0 # to stop - causes routine to NOT be called again # end of class definition