JMRI Sensor Setting

As part of my attempt to get my head round the workings of JMRI I have put together several simple layouts on which to test the working of sensors, turnouts etc.. I often need to set all the sensors to the INACTIVE state at startup and have found a simple way of doing just that using a Jython script.

[code language=”Java”]
”’
Start of Day Routine
~~~~~~~~~~~~~~~~~~~~
Sets all sensors to INACTIVE
”’

import jarray
import jmri

class SoD(jmri.jmrit.automat.AbstractAutomaton) :
def init(self):
self.sen = sensors.getSystemNameList()

def handle(self):
print "Setting sensors INACTIVE"
for s in self.sen:
print s
sensors.provideSensor(s).setState(INACTIVE)
return 0 # one shot, do not loop

SoD().start()
[/code]

Leave a Reply