Skeleton script

[code language=”Java”]# Title: ########
# Purpose: ########
# Author: ########
# Date: ########
# Modified: ########
# Modified by: ########

import jarray
import jmri

class <class_name>(jmri.jmrit.automat.AbstractAutomaton) :

def init(self):
# init() is called exactly once at the beginning to do
# any necessary configuration.
# set up sensors
self.<sensor_name> = sensors.provideSensor(“<sensor_table_name>“)
# -ditto- as required

# get loco address. For long address change “False” to “True”
self.<throttle_name> = self.getThrottle(<loco_address>, True|False)

# create a sound object
<sound_object_name> = jmri.jmrit.Sound(“<location_of_.wav_file>“)

return

def handle(self):
# handle() is called repeatedly until it returns false.

# the programme starts here
# self.waitMsec(<millisecond_wait>)
# turnouts.provideTurnout(“<turnout_table_mame>“).setState(CLOSED|THROWN)
# self.<throttle_name>.setIsForward(True|False)
# self.<throttle_name>.setSpeedSetting(0.7)
# self.waitSensorActive(self.<sensor_name>)
# self.<throttle_name>.setF1(True|False)
# <sound_object_name> = jmri.jmrit.Sound(“<sound_file_location>”) # .wav file, location relative to JMRI root
# <sound_object_name>.play() # play sound once
# <sound_object_name>.loop() # play sound continuously
# <sound_object_name>.stop() # stop playing sound

# end of programme loop
return 1
# (requires JMRI to be terminated to stop – caution
# doing so could leave loco running if not careful)

# end of class definition

# start it up
<class_name>().start()
[/code]