TODO
This page walks you through creating a simple control panel for your own layout. This example is based on the Lickdale panel for Nick Kulp's Cornwall Railroad, but you should be able to create a panel for your own layout by following these instructions. More information is available on how to you can run Nick Kulp's Cornwall RR Program to see what it's like, and on how his program was written.
If you want to follow along here, download that picture (right click on the picture
and "Save As...") as "Lickdale.gif".
Step 2: Creating the initial panel
To turn this picture into a control panel, you have JMRI create a
panel that displays this as a background.
You then place "icons" in front of it that are redisplayed as the layout status
changes.
To create the control panel:
Note that storing the panel layout saves all the control panels visible
at that moment, even if you have more than one.
Step 3: Have the panel show when the program starts
Rather than manually loading the panel via the menu each time you
start the program, you can have it loaded automatically.
and unlit
red LED indicators. By displaying a red LED when
a particular block is occupied (sensor active), and a gray one when the
block is unoccupied (sensor inactive), you get an occupancy indication on the
panel.
You'll need to know the JMRI names for your block sensors. You can figure these out from the wiring (see the JMRI naming pages for info) but it's usually easier to have the program do it if you're connected to your layout.
Once you've found the system name for a block sensor (for example, "CS21"), you can add an indicator to the panel that follows that sensor:
If you don't like the default icons, you can change them.
If you have lots of icons to place, this can become unwieldy. The panel
definition is stored in a human-readable form in an XML file, which you
can directly edit. Each icon on the screen in one line on the screen, with
some extra stuff at the top and bottom of the file. The format is almost
self-explanatory. x="12", for example, means draw the icon at an x coordinate
of 12 pixels; the top left corner is 0,0 (x, y), with y growing down the screen.
You can duplicate and
edit lines with your favorite editor. For example, if you want to have
to icons line up on a horizontal line, you might find it easier to position the
first item perfectly by hand, and then edit the rest of the lines to have the
same y= coordinates.
Step 5: Add turnout controls
Next, we add the turnout controls. These send a message to the
layout hardware when clicked, which changes the position of the
associated turnout. The icons
show two different images depending on whether the turnout has been commanded
to be "Closed/Normal"
or "Thrown/Reversed"
.
First, find the turnout number that controls the desired turnout. One way to do this:
The turnout number over the switch plate was added as part of the background picture. You could also add text via the panel editor to do this. (There is a popup menu on text added this way that lets you set it's size and color)
At this point, you've got a functional panel.
Congratulations!
The rest of this page discusses various ways to include additional
neat features such as turnout sensing from the layout and signal
indicators.
Step 6 (optional): Add turnout sensing
Nick also wanted the turnout controls to look like they had small indicator
lamps over each side to show the actual status of the turnout. This was done
by adding two sensor icons there. The one on the left would show
if the turnout was closed, and
if it was thrown. The icon on the right
would do the reverse, showing
if the turnout was closed, and
if it was thrown. These were attached to inputs
on the C/MRI system, so that the actual position of the turnouts on the
layout was read back. This way the indicators on the panel showed the
real position of the turnout, not just what command had been sent to the motor.
To add these, go back to the panel editor for your panel. Click "Edit Icons..." next to "Add sensor", and select the images you want to display. (Nick's small lights are in "Icons : smallschematics : LEDS"). Then enter the name of the sensor for the first turnout, and click "Add sensor" to put it on the screen. Drag-click it to move it into position near the turnout control. Repeat that for all of the rest of the indicators on the thrown side of the turnout levers, providing the right sensor number each time. Then change the icons to the 2nd set, and go back and add sensors to the other side of each lever.
A similar technique is used for the turnouts on the schematic. The indicators
on the schematic are meant to show the actual positions of the turnouts, not
just the last status sent by the DCC system, so they respond to the C/MRI sensors
using two icons:
and
.
These are positioned over the turnouts on the track schematic background.
They cover (with the little back blob) a bit of track on either the normal
or diverging route, so that the screen displays only one line as complete.
In this case, these icons were made by clipping a few pixels from the
background drawing.
(Details...)
There are "left" and "right" sets for the two basic types
of turnouts used; they can be rotated via the popup menu to work with the various
turnout orientations on the schematic.
To define the signals to the program, you use the "Signal Table" from the tools
menu.
The program can't detect what signals you have installed on your layout,
so you have to define them individually. To do this, start by opening the
Signal Table, and then click the "Add..." button. A new window will open.
PanelPro knows about several different types of signals. Each has different information needed to specify it, so on the "Add" panel you first select the type of signal you have, and then provide additional information:
You can check your work by clicking on the buttons in the table. With each
click, the signal will work its way through the sequence of available aspects:
Red, Yellow, Flashing Yellow, Green. (The available aspects and the order they
are presented will vary from one type of signal to another) The signals
on the layout should follow along.
Prototype railroads would not usually display every signal head on
a panel, but just summary information near signal levers. But there are
advantages to having all your signals displayed on the panel:
To put these on the panel, you use a similar procedure to what you've
already done with sensors and turnouts using the panel editor window.
If the default icons are fine,
just put the signal name in the box next to "Add signal" and click the
button. A signal icon will appear on the panel, which you can drag to
the desired spot. You can rotate it to another orientation using its popup
menu.
The Cornwall panel was setup to
use small graphics to avoid making it too busy:
red
If you prefer to use other signal icons, use the "Edit icons..." button to select them.
There
are several sets available with different backgrounds, different sizes, etc.
You can also create your own icons using a paint program, and then use them.
If you do that, please email them in so that we can add them to the program!
The "Simple Signal Logic Tool" can provide logic for the most common
cases. It works particularly well for sidings and single-track blocks.
A detailed example of it is
available on another page.
To use this, open the tool from the "Tools" menu. You should get a
new window that looks like this:
To define what you want done, you just enter values on this form.
If you'd like to give additional warning, click the "with flashing
yellow" checkbox. In that case, the signal before a red will show
flashing yellow, and the signal before that flashing yellow will
show a steady yellow.
Don't forget to save your work!
You can test this logic by changing the sensors, turnouts and signals
using either the various tables, or by clicking on a panel. The signals
on the layout and the signal icons on the panel should respond appropriately.
Before you try to code and debug a script, you should get a clear understanding
of what you want to do. Try to write it down in words, like "If sensor 21 is active,
and sensor 22 is not active, then signal 19 should be yellow". There
are two approaches to how to do this:
This is the way prototype signal engineering is usually done, but it often
results in a lot more conditions to write down.
This is not so prototypical, and can sometimes lead to the signal
being green when it isn't safe (if you missed something in your logic).
But it's often easier to figure out.
In the case of Nick's railroad, the logic for each signal had
already been worked out for his old BASIC program. It was helpful to
have that working code when figuring out what the new logic should do.
Next, we'll walk through creating a script to implement this logic.
You'll do this once for each separate signal; don't try to combine
Note that although prototype signals use logic that "starts with red, and see
if you can find a reason to turn it green", the existing Cornwall logic was
written the other way around. Rather than change that, we wanted to get that
same logic into the new program with as little change as possible.
JMRI makes it very easy to debug this logic, as the program doesn't
have to be connected to the layout to let you test it. You can change the
state of an occupancy detector or turnout sensor on the display (though clearly not
on the layout itself!) by clicking on it, and then see whether the signals
respond appropriately. Even complicated interlocking logic can be
checked out quickly using this.
Step 8 (Optional): Adding signals to your panel
Like input sensors and turnouts, JMRI can display signal icons on the screen
that follow the appearance of a signal head.
,
yellow
,
flashing yellow
,
green
.
Step 9:Adding signal logic
At this point, you have signals defined, and can change their appearance
by clicking on them. But they don't change appearance automatically
in response to changes on the layout. You need to have the right "logic"
driving the signals.
Step 10:Adding signal scripts
If the "Simple Signal Logic" tool is too simple, you'll have to
write either a script or Java code to drive your signals.
PanelPro provides a couple of ways to do that.
The simplest, which is covered here, is to write a script file
for each signal that you need to control. Once started, that script
will continue to run, controlling the signal each time the conditions
change.
Below here is not revised yet!
To actually drive the signal aspects from the turnout and occupancy status,
Java code was written based on JMRI's
automation classes.
Each of the 45 signals is driven by its own code snippet.
Since Nick already had a QBASIC program to use as an example,
the CrrSection class was created that would let the Java signal logic
code look very similar. For example, this is the logic for
signal 13B:
int value = GREEN;
if ( !tu7 || bo15 || tu8 )
value = RED;
else if (!tu9 && bo22)
value = RED;
else if (tu9 && bo23)
value = RED;
if (value == GREEN && !tu9 && si87)
value = YELLOW;
else if (value == GREEN && tu9 && si90)
value = YELLOW;
Summary
The process to create the Cornwall signaling and dispatcher panel was
straightforward, if a little long.
Many people
have contributed to this effort, and we thank
all of them.
Site hosted by: