-
Notifications
You must be signed in to change notification settings - Fork 331
/
Programmer.shtml
398 lines (319 loc) · 15.8 KB
/
Programmer.shtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.17), see www.w3.org">
<!-- Copyright Bob Jacobsen 2008 -->
<title>JMRI: DecoderPro - Create a Custom DecoderPro
Programmer</title><!-- Style -->
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii">
<link rel="stylesheet" type="text/css" href="/css/default.css"
media="screen">
<link rel="stylesheet" type="text/css" href="/css/print.css"
media="print">
<link rel="icon" href="/images/jmri.ico" type="image/png">
<link rel="home" title="Home" href="/"><!-- /Style -->
</head>
<body>
<!--#include virtual="/Header" -->
<div id="mBody">
<!--#include virtual="Sidebar" -->
<div id="mainContent">
<h1>JMRI: DecoderPro User Guide</h1>
<h2>Create a Custom Programmer</h2>
<p>How do I create my own custom programmer?</p>
<p>The answer starts with the creation of an xml file in the
"programmers" subdirectory of the JMRI distribution. The
contents of the file are described here.</p>
<p>After some initial parts (which you can just copy from an
existing file), the rest of the file is a series of "pane"
definition elements. Each one become a pane in the DecoderPro
window.</p>
<p>The panes in the programmer file appear when you select
that programmer in DecoderPro. Note that panes can also be
defined in the decoder definition, in which case those panes
appear after the ones in the programmer definitions.</p>
<ul>
<li>There is an option to present/hide panes from the
decoder file. If you're writing a very basic programmer,
you might want to hide them to keep the interface
simple.</li>
<li>If a pane is defined in the decoder file and programmer
file with the same name, the one from the decoder file (the
more specific one) appears.</li>
</ul>
<dl>
<dt class="left">Specifying items to display</dt>
<dd class="first">
<p>The basic element of a programmer pane is a "display".
This tells the programmer to present a single variable.
The attributes are:</p>
<ul>
<li><dfn>name</dfn> - (Required) This is the "standard
name" of the variable to be presented.</li>
<li><dfn>label</dfn> - If present, this will be used to
label the variable on the pane instead of the name or
standard name of the variable.</li>
<li><dfn>layout</dfn> - Where to locate the label with
respect to the editable field, e.g. the text box.
Possible values are "left", "above", "below", "right"
with a default of "right".</li>
<li>
<dfn>format</dfn> -
<p>How the variable should be presented. Numeric
variables can be presented as</p>
<ul>
<li>an editable text field, which is the default if
nothing is specified</li>
<li><dfn>hslider</dfn> - a horizontal slider</li>
<li><dfn>vslider</dfn> - a vertical slider</li>
</ul>
<p>Enum variables can be presented as</p>
<ul>
<li>a selection box, which is the default if
nothing is specified</li>
<li><dfn>radiobuttons</dfn> - Each possible value
is presented as an individual button</li>
<li><dfn>checkbox</dfn> - An enum with only two
states can also be presented as a checkbox</li>
<li><dfn>offradiobutton</dfn> - A single button
that sets the 0 choice for the variable when
selected</li>
<li><dfn>onradiobutton</dfn> - A single button that
sets the 1 choice for the variable when
selected</li>
</ul>
<p>These last two can be useful for indicating which
parts of a configuration are active; see the "Speed
Table" pane of Comprehensive.xml for an example.</p>
</li>
<li><dfn>tooltip</dfn> - Allows you to specify a default
tooltip to be presented when the cursor is left over
the variable. This tooltip will be overridden by any
tooltip defined in the decoder file.
(Note: This behaviour differs from
<a href="#display">the behaviour of the label attribute</a>.)</li>
</ul><a name="display" id="display"></a>
<p>Which name to display is controlled by the pane's
'nameFmt' attribute, and the 'label' attribute on each
display element (variable).</p>
<p>The choices are:</p>
<ul>
<li>If a label is specified, it will be used. Use a
label if you want absolute control over what a variable
should be called, regardless of what the decoder file
calls it, and you don't like the standard name.</li>
<li>The pane's nameFmt attribute is "item", in which
case the item name will be used regardless of what the
decoder file calls the variable. Use this is you want a
uniform appearance for the pane for all decoders. But
be aware that some standard names are really so generic
as to be useless.</li>
<li>If the pane's nameFmt attribute is allowed to
default, or contains "mfg", the decoder definition
file's name will be used. This is the normal form, as
it allows a manufacturer to specify in some detail what
a variable defines.</li>
</ul>
</dd>
<dt class="left">Formatting</dt>
<dd>
<p>Each pane of the programmer consists of (nested) rows
and/or columns. Columns lay out variables from top to
bottom. Rows lay out variables from left to right. You
can nest these to achieve various effects; for an example
of this, see the "Speed Table" pane of the
Comprehensive.xml file. It has two columns, the left of
each uses a row to put some sliders from left to
right.</p>
</dd>
<dt class="left">Special Elements</dt>
<dd>
There are a number of elements you can use to get the
programmer formatted exactly the way you want:
<ul>
<li><dfn>grid</dfn> - Create a grid for laying out
elements in aligned rows and columns. See the <a href=
"#grid">Grid Layout</a> section below.</li>
<li><dfn>label</dfn> - Add text to a pane.</li>
<li><dfn>soundlabel</dfn> - Add a soundlabel (from the
decoder definition file) to a pane. It has a one
attribute:</li>
<li style="list-style: none">
<ul>
<li><dfn>num</dfn> - (Required) This is the number
of the sound label to be presented.</li>
</ul>
</li>
<li><dfn>separator</dfn> - Add a separator line to a
pane. If included in a column, this will be a
horizontal separator line. If included in a row, it
will be a vertical line.</li>
<li><dfn>cvtable</dfn> - Insert a table of CV values
onto the pane. To get the spacing right you should
probably not combine this with other variables on the
same pane.</li>
<li><dfn>fnmapping</dfn> - Show a function mapping
grid. This requires variables with specific names,
which are described on a <a href=
"FnMapping.shtml">separate page</a>.</li>
<li><dfn>dccaddress</dfn> - Show a combined variable
for the DCC address. This consists of a checkbox that
selects use of short vs long address, and a single text
field for entering the address. Depending on how the
checkbox is set, the text field will configure the CV1
short address or the CV17/18 long address.</li>
</ul>
</dd>
<dd><a id="grid" name="grid"></a></dd>
<dt class="left">Formatting with the Grid Layout</dt>
<dd>
The "row" and "column" elements allow you to align
elements in rows or columns, but if you have multiple
columns within a row element (or vice versa) it is not
possible to ensure that rows in adjacent columns (or vice
versa) stay aligned.
<br>
The Grid Layout allows you to align elements in rows
and columns, maintaining alignment even if a particular
element is absent. There are two elements:
<ul>
<li><dfn>grid</dfn> - Create a grid layout (within a
"row" or "column" element):</li>
<li style="list-style: none">
<ul>
<li>It may have one or more optional
attributes.</li>
<li>The only allowed sub-element is "griditem" and
there must be at least one of these.</li>
</ul>
</li>
<li><dfn>griditem</dfn> - Create a grid item (within a
"grid" element):</li>
<li style="list-style: none">
<ul>
<li>It should have "gridx" and "gridy"
attributes.</li>
<li>It may also have one or more optional
attributes.</li>
<li>It must contain one or more elements, which can
be any combination of any of the other elements
listed above, including "row", "column", or even
another "grid".</li>
</ul>
</li>
</ul>
<p>The "gridx" and "gridy" attributes of a grid item
specify the location of that item within the grid. A
value of gridx="0" puts the item in the lefmost column. A
value of gridy="0" puts the item in the topmost row.
Other attributes to control the format of the grid items
are available and are documented in the <a href=
"http://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html"
target="_blank">Java® GridBagLayout Tutorial</a>.</p>
<ul>
<li>Attributes of "grid" apply to all items in the
table.</li>
<li>Attributes of "griditem" apply to only that item
and override any equivalent attribute of "grid".</li>
<li>Both numeric and named constant values (as
specified by the <a href=
"http://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html"
target="_blank">documentation</a>) can be used.</li>
<li>Two extra named constant values are available for
"gridx" and "gridy":</li>
<li style="list-style: none">
<ul>
<li>"CURRENT" is the value from the last added
"griditem" (i.e. the same row or column).</li>
<li>"NEXT" is one more than the value from the last
added "griditem" (i.e. the next row or column).<br>
("NEXT" is actually a synonym for
"RELATIVE".)</li>
</ul>
</li>
<li>The "insets" attribute is specified as
insets="top,left,bottom,right" where "top" etc. are
integers.</li>
<li>A "griditem" can span more than one grid cell.
Attributes "gridwidth" and "gridheight" control
this.</li>
<li>By default grid items clump together in the centre
of a container. Attribute "weightx" can override this
and left/right justify.</li>
<li>It is possible in some circumstances to omit either
or both of "gridx" and "gridy" from a "griditem" and
specify a default value in "grid". See <a href=
"https://github.com/JMRI/JMRI/blob/master/jmri/xml/decoders/esu/v4fnOutPane.xml"
target="_blank">xml/decoders/esu/v4fnOutPane.xml</a>
for an example of this usage to generate a simple
single-column right-aligned grid. (However if you are
not careful with use of this technique and/or the
"RELATIVE" constant, results can be bizarre.)</li>
<li>Unfortunately "ipadx", "ipady" and "insets"
allocate space even if the enclosed display variable(s)
fail qualification. A workaround is to qualify the
whole "griditem" enclosing the variable (if that is
appropriate to the situation).</li>
</ul>
<p>For an example of Grid Layout use (with some
explanations of attributes used), see <a href=
"https://github.com/JMRI/JMRI/blob/master/jmri/xml/decoders/esu/v4soundPane.xml"
target="_blank">xml/decoders/esu/v4soundPane.xml</a>. The
LokSound Select (and V4) definitions use this file.</p>
</dd>
<dt class="left">Installing your new programmer</dt>
<dd>
<p>All of the .xml files in the "programmers"
subdirectory will appear in the selection box when you
create a new programmer in Decoder Pro. To use your new
file, just put it in the "programmers" subdirectory of
the "prefs" directory and select it. You don't have to
restart the program, as the list is remade each time you
open a new programmer window.</p>
</dd>
</dl><a name="id" id="id"></a>
<h3>How variables in a decoder file match up with the
programmer file</h3>Each decoder file defines <a href=
"CreateDecoder.shtml#variable">variables</a> that describe
specific controls within the decoder. The programmer file
then describes how to place those on panes so that the user
can find and manipulate them.
<p>Each "display" element in the programmer file defines one
thing to show. But which one? That's controlled by the "name"
attribute of the "display" element. DecoderPro takes that
"name" and looks through the decoder definition for a
"variable" element that has either the same "item" or "label"
attribute.</p>
<p>This has some nice effects:</p>
<ol>
<li>The "name" in the "display" element is effectively a
"standard name", that can be used in decoder definition
files from many different manufacturers. Since this is
separate from the "label" on the decoder variable, it's
possible to have a generic programmer file that works for
many types of different decoders, while still displaying
specific variable names. For more on this, please <a href=
"#display">see above</a>.</li>
<li>It lets you use very generic names to control where
somewhat different things go. For example, different sound
decoders provide different controls. One might have
"Airpump", while another doesn't have that at all, and
instead has "Brake Squeal". We don't want to have the
programmer files contain zillions of "display" elements to
handle every possible option. Instead, we use elements with
more generic names, like "Sound Option 1", for the display
name.
<p>The decoder definition then has a "label" of "Airpump"
or whatever, and an "item" of "Sound Option 1".
Everything matches up properly, and "Airpump" appears on
the computer's screen.</p>
</li>
</ol>
<!--#include virtual="/Footer" -->
</div><!-- close #mainContent -->
</div><!-- close #mBody -->
</body>
</html>