JMRI: Memory Variables DocumentationA JMRI memory variable can hold any type of object. It's really up to user code what to put in them, and how to manipulate them.
The Memory Variable TableThe Memory Table lets you see what Memories have been defined, and what value they currently contain. The table will ask the contents of each Memory to display itself, so an image or icon will show as a picture in the table; most other things will show as a string. You can type a new string value into a Memory.
Memory Table controls
- Below the Memory Table you'll find the Add... button to add new Memories.
Using Memories with LogixA Logix can test a memory for particular contents, and set the contents of a Memory to whatever string is needed. This lets you use a Memory as a status indicator, counter or just about anything else you can imagine. Because of their user interface, Logix generally only put string values into Memory Variables.
Displaying a Memory Variable on a PanelThe contents of a Memory can be displayed on a panel. Usually, the Memory will try to display its contents directly. If the contents are an icon, image or string, the contents will be shown directly. As a special case, if the contents of the Memory are "null" (the memory contains no object), a red X icon is displayed. This lets you see and position the memory icon on the panel. If the Memory contains the zero-length string "", that's an object, and it will be displayed as blank space; a little hard to spot.
You can customize the appearance of text in the Memory icon via its pop-up menu.
You can also define a series of icons to be displayed in place of the Memory's own contents if you'd like. For an example of how this is done, please see the sample XML file. Use your browser's "view source" command, or download that file to see how it's done. Basically, the XML browser file has a "memoryicon" element that carries various information about where to put the icon, whether it can be selected, etc. Within that element, you can define "memorystate" elements that define what icon to show when the memory has a specific value:
<memoryicon memory="IM20" defaulticon="program:resources/icons/misc/Question-black.gif"> <memorystate value="9" icon="program:resources/icons/misc/Nixie/M9B.gif" /> <memorystate value="8" icon="program:resources/icons/misc/Nixie/M8B.gif" /> </memoryicon>
(That example has been simplified by omitting some stuff from the memoryicon element) In the example, the two memorystate elements ensure that if the Memory contains "9" or "8", certain images will be shown, otherwise a default black question mark icon will be shown.
Unfortunately, JMRI doesn't have a nice GUI tool for defining the icons displayed when using a memory icon this way. You have to edit the XML file by hand, following one of the examples.
Saving Memories to disk
Memories are is kept in your layout configuration, along with Turnouts, Sensors, Signal Heads, etc. To store this information on disk, allowing to reload it next time you run JMRI, use Store Configuration... in the File menu at the top of the Memory Variable Table (or other tables from the Tools menu), or select Store Panel... in the Panel menu.