Skeleton script

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

import jarray
import jmri

class <em><strong>&lt;class_name&gt;</strong></em>(jmri.jmrit.automat.AbstractAutomaton) :

def init(self):
# init() is called exactly once at the beginning to do
# any necessary configuration.
# set up sensors
self.<em><strong>&lt;sensor_name&gt;</strong></em> = sensors.provideSensor("<em><strong>&lt;sensor_table_name&gt;</strong></em>")
# -ditto- as required

# get loco address. For long address change "False" to "True"
self.<em><strong>&lt;throttle_name&gt;</strong></em> = self.getThrottle(<em><strong>&lt;loco_address&gt;</strong></em>, <em><strong>True|False</strong></em>)

# create a sound object
<em><strong>&lt;sound_object_name&gt;</strong></em> = jmri.jmrit.Sound("<em><strong>&lt;location_of_.wav_file&gt;</strong></em>")

return

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

# the programme starts here
# self.waitMsec(<em><strong>&lt;millisecond_wait&gt;</strong></em>)
# turnouts.provideTurnout("<em><strong>&lt;turnout_table_mame&gt;</strong></em>").setState(<em><strong>CLOSED|THROWN</strong></em>)
# self.<em><strong>&lt;throttle_name&gt;</strong></em>.setIsForward(<em><strong>True|False</strong></em>)
# self.<em><strong>&lt;throttle_name&gt;</strong></em>.setSpeedSetting(0.7)
# self.waitSensorActive(self.<em><strong>&lt;sensor_name&gt;</strong></em>)
# self.<em><strong>&lt;throttle_name&gt;</strong></em>.setF1(<em><strong>True|False</strong></em>)
# <em><strong>&lt;sound_object_name&gt;</strong></em> = jmri.jmrit.Sound("&lt;sound_file_location&gt;") # .wav file, location relative to JMRI root
# <em><strong>&lt;sound_object_name&gt;</strong></em>.play() # play sound once
# <em><strong>&lt;sound_object_name&gt;</strong></em>.loop() # play sound continuously
# <em><strong>&lt;sound_object_name&gt;</strong></em>.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
<em><strong>&lt;class_name&gt;</strong></em>().start()
[/code]