Scripts
The
entire AOCC is built under JMRI/Java using the Jython scripting
language.
A
typical script is written to accomplish a given action.
Such actions include running a train from one location to
another, monitoring a train's location, changing the position
of a turnout, activating and deactivating special effects
including sound, lighting and animation, starting another
script, reporting current activity on the system log or
on the TOS display, and so on.
There
are several different types of scripts roughly divided into
the following groups:
Initialization:
These scripts set up the initial operating state of the
layout and include such things as defining global variables,
initial train locations and direction, initial turnout positions,
initial power status, initial sensor status and the like.
When other scripts are started, they have access to a record
of the layout status including the location of all trains,
the position of all turnouts, the status of all sensors
and the like.
Engine
Initial Location: At the beginning of an automated operating
session, scripts are initialized to set conditions as required.
One of the many conditions is the initial location of each
train on the layout, its direction of travel, its engine
number, top speed, wait times at intermediate stops, textual
description and so on.
Routes:
Another important component of the AOCC is the concept of
Routes. In effect, a route defines a train and all the factors
required in order to operate that train on the layout. Such
factors as engine number, top speed, wait times for intermediate
stops, scheduled running time, text description, and many
other items are needed to operate a train on the layout.
If
an engine or train is replaced by a different engine or
train, the Engine Location table must be updated and the
Routes table will be automatically updated to reflect the
new equipment. If the new equipment (engine) is not known
to the Routes table, it must be added but this is quite
rare since most common trains have been run on the layout
at one time or another and have an entry in the Routes table.
Routes
can invoke other scripts to do many other things like reporting
a train's location, operating the sound system in the engine
(if it has one), turning on and off crossing lights and
bells, activating special effects (the platform lights come
on as a train approaches and turn off after it leaves),
and so on.
Routes
also check a number of things, for example the path the
train is going to take around the layout must be clear of
other trains before the current train can begin its run.
Routes
in this context should not be confused with the term used
by some DCC systems to denote a particular alignment of
a group of turnouts. That kind of route is not needed because
all turnout management is handled by the AOCC.
Buttons:
These scripts place a button on the main JMRI screen. Each
button may be clicked on to perform a described action,
for example run a script, set the value of a global variable,
report the current status of something, and so on.
Sensors:
These scripts monitor the state of all the sensors on the
layout and may initiate certain actions when a sensor state
changes. For example, after the sensors are defined, a set
of scripts may be run that sounds the horn on a special
locomotive so that each detector location and each individual
element of that location may be tested to confirm that the
hardware is working properly.
A
typical action when a sensor is activated is simply to report
(and display) the location of a train at a location. Another
type of action could be to start another script. Thus, when
one train gets to a certain location, another train can
be started. This is often used to ensure the first train
has cleared enough track to enable the next train to begin
its route.
PCS:
These "Personal Computer Sound" scripts manage
the playing of computer sound. Such sounds can be used at
a given place on the layout to play any sound that can be
recorded and converted to a .wav format. Wolves howling
in the mountains is a static sound played from one location
only. Musical songs being played as a train traverses the
layout use stereo sound so that the sound seems to follow
the train around the layout (for the RHJ Rail
Christmas Holiday Train, historic steam excursion train,
and so on).
TOS:
"Track Occupancy Status" system scripts are typically
called from other scripts to report changes to the current
status of the layout.
These
scripts display information on the TOS system schematic
diagram to show the location of every train on the layout.
In
addition, the TOS system reports other important information
such as which turnouts are in the "thrown" position
at any time, which scripts are to be run when running under
a Master Script (see below), and a number of other important
variables which affect the smooth operation of the layout.
TMS:
The "Turnout Management System" scripts keep track
of the status of every turnout on the layout and displays
those turnouts that have a state of "thrown" on
the TOS system schematic diagram on a computer screen.
This
system has the ability to set all the turnouts required
for a train to run on any route on the layout and to return
those turnouts to normal (typically "closed")
status upon completion of the run. This functionality applies
to both automatic and manually operated routes.
When
turnouts are changed by a script, the script records the
new status (thrown or closed) of the turnout so this can
be displayed on the computer console and so that other scripts
can determine each turnout's position when required.
Accessories:
This type of script can be invoked manually by a button
on the main JMRI computer window or from another script.
These
scripts include all the special effects on the layout, which
are mentioned elsewhere, and they keep changing as more
are added. A few examples include a helicopter dropping
in for donuts at Tim Hortons, a children's playground in
a station park, a fire alarm with flashing emergency lights,
traffic lights and siren sounds, a "Santa Car"
on which Santa and an elf operate a hand-car back and forth
as the car goes around the layout, a skating rink with music
and lights in the winter corner of the layout and many others.
Master
Scripts: Simply put, a Master Script is a script that
accepts a list of other scripts to be run and the conditions
under which they are to operate. More details can be found
on Technical
- Page 7
Telegraph:
This is really a special effect accessory but deserves to
be in a category by itself since it has so many special
components and it can be operated separately from the rest
of the layout.
Features
of this RHJ Rail sub-system include the ability
to encode specific messages and set the speed (words per
minute) and other factors in the messages sent. For ease
of understanding, these have been set relatively slow.
And
just for fun, there is an actual antique telegraph device
attached to the system which can be used to receive messages.
However, the volume on this is somewhat louder than that
in the HO stations
The
whole system is controlled by the RHJ Rail
Automated Operations Control Centre (AOCC) using
a Windows computer, JMRI, Digitrax DCC, and a number of
custom-designed gizmos, many of which are based on mobile
decoders.
In
fact, the Morse Code dots and dashes are generated by flashing
a lighting function on and off using a Digitrax decoder.
It is unlikely that this could be done using a handheld
throttle because the response speed is just too slow. It
turns out that computer-generated commands can be sent over
Loconet quicker than commands sent from a throttle.
Other
aspects of scripts are discussed on Technical
-page 7 but you would have to be really interested
to go there!
continued
on Technical
- Page 5