Author: Daniel Bergqvist
Keywords: jmri LogixNG reference action items

# LogixNG Reference - Chapter 5

## Action Descriptions

The action descriptions are grouped by the socket type and category.

- Digital action
  - Item
  - Common
  - Display
  - LocoNet
  - Other
- Digital boolean action
  - Common
- Analog action
  - Item
  - Common
- String action
  - Item
  - Common

### Action dialogs

When the category and type has been selected, the detail action dialog will be displayed. The content of the dialog will vary depending on the category and type. The typical digital action item dialog is described below.

The dialog for adding and editing digital action items consists of an upper part that contains the item and the actions for that item. The lower part is common to all actions.

For some actions, for example Signal head, you need to first select the item and then you can select the action to do on that item. For example, for Signal head, you first select the signal head to act on and then you can select the appearence to set for that signal head.

The Edit screen is the same except for the title, the Create button and the current content will be in the fields.

The left section is normally used to select the item, such as a turnout or a sensor. The right section is the action to be performed. The default mode will be to use the Direct tabs.

See Reference, Local Variable and Formula for details about the other tabs.

The lower section contains a standard set of items

Error Handling
  If Use default is selected, the value in Preferences will be used. For other options see error handling.
Catch "Abort execution"
  If the error handling (see previous) for any child node is set to Abort execution, a parent node should have this option checked. This lets the parent node handle the error.
Edit comment
  Each action can have a comment. The comment dialog has a multiline text area. Click OK to save the comment.
Formula functions
  These are explained in the Formula chapter.
Cancel
  Close the dialog without applying any changes.
Create/OK
  Save the new action or the changes to an existing action.

### Digital action :: Item

##### Audio

Control the selected Audio item.

- Play
- Play toggle
- Pause
- Pause toggle
- Resume
- Stop
- Fade in
- Fade out
- Rewind
- Reset position

##### Block

- Block Sensor Active: Set the sensor that provides occupancy to active.
- Block Sensor Inactive: Set the sensor that provides occupancy to inactive.
- Alternate Color On: Enable alternate color for the related layout block.
- Alternate Color Off: Disable alternate color for the related layout block.
- Empty (null): Set the block value to the null value.
- Value: Set the block value to a string or via a reference such as from a memory variable.

##### Clock

- Set Fast Clock: Sets the time on the fast clock to the entered time. The time is entered as hh:mm where hh is hours and mm is minutes on a 24-hour clock. This action sets the fast clock to the specified time regardless of whether the fast clock is running or stopped.
- Start Fast Clock: Starts the JMRI fast clock running. If the fast clock is already running, this action has no effect.
- Stop Fast Clock: Pauses the JMRI fast clock. If the fast clock is not running, this action has no effect.

##### Dispatcher

A Dispatcher train only exists from the time it is created until it is terminated. LogixNG uses the Dispatcher TrainInfo file to refer to a potential Dispatcher train. See the Saving and Retrieving Active Train Information section at Activate New Train. If the related train does not exist when the LogixNG action occurs, the action will be ignored. There will be no notification.

- Load train from train info file: Create a new Dispatcher train using the selected train info file.
- Terminate train: Terminate a Dispatcher train that was previously started using LogixNG.
- Set train priority: Change the priority of a train. The default is 5. The allowed range is 0 to 100.
- Set Reset when Done: Enable or disable the Reset when Done option.
- Set Terminate when Done Enable or disable the Terminate when Done option.

##### Enable/Disable Logix

- Enable: Enables the specified logix. Specify the logix to enable by selecting its name.
- Disable: Disables the specified logix. Specify the logix to disable by selecting its name.

##### Entry/Exit

- Set NX Pair Enabled: Enables the specified Entry/Exit Pair. Specify the Entry/Exit Pair to enable by selecting its name.
- Set NX Pair Disabled: Disables the specified Entry/Exit Pair. Specify the Entry/Exit Pair to disable by selecting its name.
- Set NX Pair Segment Active / Inactive Request that the route segment for the specified Entry/Exit Pair be activated if not active or deactivated if active. Specify the Entry/Exit Pair to enable by selecting its name.

##### Light

- Off: Set the selected light off.
- On: Set the selected light on.
- Toggle: Toggle the selected light.
- Set Intensity: Sets the intensity of a specified variable intensity light to the entered intensity value. Specify the light to set by selecting its name. Specify the intensity by entering the percent intensity as an integer in the range 0 to 100. If the specified light is not a variable light, or if the intensity value entered is not an integer in the required range, an error message is displayed.
- Set Transition Time: Sets the transition time of a specified variable intensity light to the entered time. Specify the light to set by selecting its name. Specify the transition time by entering the number of fast clock minutes needed to move from 0% intensity to 100% intensity. If the specified light is not a variable light, or if a positive integer is not entered for the number of fast clock minutes, an error message results.

##### Light intensity

The Light intensity action is an alternate method to set the Variable Light Intensity value. The standard method sets the value directly from the action using any of the standard input methods.

This action creates a child analog expression called Intensity. Analog expressions are normally used to create a dynamic values, such as random numbers. Using the `sin()` function along with the Minutes since midnight analog expression, it is possible to change light intensity based on the time of the day using the fast clock or the system clock.

Here is an example using the sin() function.

##### Local variable

Local variables are described in Chapter 8 - Local Variables.

Instead of specific actions, local variables use tabs to select the action.

- Null: Select the Null tab to set the selected local variable to the null value.
- Constant: Select the Constant tab and enter a string value for the selected local variable.
- Memory: Select the Memory tab and select the memory which will provide the value for the selected local variable.
- Table: Enter the table name, row name and column name that contains the data that will be copied to the selected local variable. For example, table name[row name, column name]. Having curly brackets around the table reference is OK, such as when using the copy to clipboard table feature. See Chapter 11 - Tables for details about tables.

##### Memory

Instead of specific actions, memory uses tabs to select the action.

- Null: Select the Null tab to set the selected memory to the null value.
- Constant: Select the Constant tab and enter a string value for the selected memory.
- Memory: Select the Memory tab and select the memory which will provide the value for the selected memory.
- Table: Enter the table name, row name and column name that contains the data that will be copied to the selected memory variable. For example, table name[row name, column name]. Having curly brackets around the table reference is OK, such as when using the copy to clipboard table feature. See Chapter 11 - Tables for details about tables.

##### OBlock

- Deallocate Block: Deallocates an Occupancy block. Specify the OBlock by selecting its name.
- Set Block Value: Set a value for the selected block.
- Set Block Error: Set the selected block status to "block error".
- Clear Block Error: Remove the "block error" status for the selected block
- Set Block OutOfService: Sets the status of an Occupancy block to Out-Of-Service. Specify the OBlock by selecting its name.
- Clear Block OutOfService: Sets the status of an Occupancy Block to the current normal status. Specify the OBlock by selecting its name.

##### Power

- Off: Turn track power off.
- On: Turn track power on.

##### Reporter

The Reporter action is used to copy the report content to a memory variable or a LogixNG local variable. There are three kinds of information.

- Current Report: The current value unless the hardware says there is nothing to report. In that case the value will be null.
- Last Report: Normally the current report and last report are the same. If the current report is null, this will be most recent valid report. If no report has ever been received, this will be null.
- State: A number that represents the last report.

Note: The meaning of the reports and the state number are defined by originating hardware.

##### Route

- Trigger route: Triggers the specified route. Specify the route by selecting its name.

##### Script

- Run script: Starts the specified script. Specify the script to start by entering its name in the field provided or use the "..." file selector.
- Jython command: Enter the command in the Script field

##### Sensor

The delayed options are handled by Execute Delayed.

- Inactive: Set the selected sensor to inactive.
- Active: Set the selected sensor to active.
- Toggle: Toggle the state of the selected sensor.

##### Signal head

- appearance: Sets the specified signal head to the selected appearance. Specify the signal head to set by selecting its name. Select the appearance Appearance list.
- lit: Sets the specified signal head to lit. Specify the signal head by selecting its name.
- not lit: Sets the specified signal head to not lit. Specify the signal head by selecting its name.
- held: Sets the specified signal head to hold. Specify the signal head to hold by selecting its name.
- not held: Clears the hold on the specified signal head. Specify the signal head by selecting its name.

##### Signal mast

- aspect: Sets the specified signal mast to the selected aspect. Specify the signal mast to set by selecting its name. Select the aspect from the Aspect list.
- lit: Sets the specified signal mast to not lit. Specify the signal mast by selecting its name.
- not lit: Sets the specified signal mast to not lit. Specify the signal mast by selecting its name.
- held: Sets the specified signal mast to held. Specify the signal mast to hold by selecting its name.
- not held: Clears the hold on the specified signal mast. Specify the signal mast by selecting its name.
- permissive sml disabled: Disable permissive SML for the selected signal mast.
- permissive sml not disabled: Enable permissive SML for the selected signal mast.

##### Sound

Plays the specified sound file. Specify the sound file to play by entering its name in the field provided. Click the file selection button to bring up a file selection dialog to aid in finding the file. Navigate to your sound file, then click your sound file's name in the dialog and the name will be copied to the field.

##### Throttle

The Throttle action controls a throttle. It has child expressions for loco address, loco speed and loco direction. For now, an analog memory expression or an analog constant expression can be used to control the loco address and the loco speed, but once JMRI has support for AnalogIO devices, an AnalogIO may be used to control loco address and/or loco speed.

##### Turnout

The delayed options are handled by Execute Delayed.

- Closed: Set the selected turnout closed.
- Thrown: Set the selected turnout thrown.
- Toggle: Toggle the state of the selected turnout.

##### Turnout, lock

Locks or unlocks a turnout. Select the name for the turnout, and choose the operation from the popup menu. Note: To control the type of turnout lock go to the Turnout Table and select the Lock Mode.

- Lock: Lock the selected turnout.
- Unlock: Unlock the selected turnout.
- Toggle: Toggle the lock state for the selected turnout.

##### Warrant

- Allocate Warrant Route: Allocates (reserves) the OBlocks comprising the route of the warrant for use by the warrant. Specify the warrant by selecting its name.
- Deallocate Warrant: Deallocates the OBlocks comprising the route of the warrant so they may be allocated to other warrants. Specify the warrant by selecting its name.
- Set Route Turnouts: Sets all the turnouts comprising the route of the warrant. Specify the warrant by selecting its name.
- Auto Run Train: Starts playback of the recorded script for the train specified in the warrant. Specify the warrant by selecting its name.
- Manually Run Train: Serves a "clearance" to an operator that a humanly run train has running rights for the extent of the warrant's route. Specify the warrant by selecting its name.
- Control Auto Train: Issues the specified command to an auto run train. Specify the warrant of the train by selecting its name. The Commands are:
  - Halt
  - Resume
  - Abort
- Set Train ID: Set the train ID from the roster or the DCC address. When a DCC address is used, also specify Long or Short. Example: 1234(L) or 10(S).
- Set Train Name: Set the train Name for the selected Warrant.

### Digital action :: Common

##### Execute delayed

Delay the execution of the following action for a specified amount of time. This is the same as the Logix Delayed Set .... The main difference is that this can be used with any action, such as signals. The time delay units are milliseconds, seconds, minutes and hours.

##### For

For is a for-loop. It has four children.

- Init - this action is executed only one time. It's used to initialize the loop, for example setting a Memory to a particular value.
- While - this expression decides if the loop should run one lap more. The loop will continue to run until this condition will be false.
- AfterEach - this action is executed at the end of the loop. It can for example be used to increment a counter in a Memory.
- Do - this action is executed in each loop. It does the main work.

When For is executed, the Init action is run once. After that, the While expression is evaluated. If the While returns true, the Do action is executed and at last the AfterEach action is executed. Then the process is repeated, except that the Init action is only executed once.

##### If Then Else

Reads a digital child expression and if the answer is true it executes the then child action, else it executes the else child action.

There are two options:

- Execute on change: Executes the Then or the Else action only when the If expression has changed from True to False, or from False to True.
- Always execute: Executes the Then or the Else action every time the If Then Else action is executed..

##### Many

The Many action executes many child actions.

##### Read analog and set analog

Read an analog child expression and execute an analog child action.

##### Read string and set string

Read a string child expression and execute a string child action.

##### Sequence

The Sequence action executes a series of action/expression pairs. For each pair, the action will be performed and then the expression will wait until it becomes true. When it is true, the next action/expression pair will be started. The sequence will repeat forever or until stopped.

- Start: When the start expression is true, the sequence will start with the first action/expression pair.
- Stop: When the stop expression is true, the sequence will stop running.
- Reset: When the reset expression is true, the sequence will be interrupted and return to the first action/expresson pair.

##### Table: For each

See Chapter 11 - Table Actions for details on table actions.

##### Timer

Timer has a number of actions, each executed after a period of time. The time to wait can be 0, which means the related action is executed immediately. The Timer can be configured to only execute the actions once or continuously. The Timer can also be configured to start when the xml data file is loaded or only start when the "Start" expression returns True. The Timer stops when the "Stop" expression returns True. The time unit is selected from the combo box.

If all times to wait are zero, the timer will automatically stop after executing all the actions once, even if it is set to run continuously. This is a safety feature to avoid locking up JMRI.

To add a socket for the Timer action, edit the Timer and click the Add timer button and a new socket will be added to the end. To remove a socket for the Timer action, edit the Timer and click the Remove timer button and the last socket will be removed. The socket can only be removed if there is no action connected to it.

This example shows using the Timer to implement a traffic light. Note: This example shows renaming the A1, A2, etc. sockets to meaningful names.

Another example is using a Timer to blink a light. Create a Timer with a single socket and a Light action that toggles the light on/off. If you want different times for on and off, create a Timer with two sockets where the first socket turns the light on and the second socket turns the light off.

### Digital action :: Display

##### Icon/Label on panel

Disable/Enable/Hide/Show an icon or label on a specific panel.

### Digital action :: LocoNet

##### Clear loconet slots

This action clears the slot status in the command station if you are using LocoNet.

##### Update loconet slots

This action forces an update of the LocoNet slot status in JMRI.

### Digital action :: Other

##### Call module

See Chapter 10 - Modules for details.

##### Listen on beans

See Chapter 7 - Listen on beans for details.

##### Listen on beans - Table

See Chapter 11 - Table Actions for details.

##### Log data

While developing a ConditionalNG, it can be helpful to see field content, make note of the location within the tree, etc. Adding the Log data type in the Other category will display a dialog to configure the Log data options.

Select either or both Log options

- Log to the log: Help ⇒ System Console.
- Log to the Script Output: Scripting ⇒ Script Output.

There are three format types.

- Only text: The text typed into the Format box will be displayed on the log. The data in the table is ignored.
- Comma separated list: The values for the items in the table will be displayed separated by commas. The content in the format field is ignored.
- String.format: Use the format string to format the data in the table. See the java method String.format() for the syntax of the format string. Note: The format is similar `sprintf`.

The table lists the data sources for the comma separated and and string format options.

Click on the Add button to add an entry to the table. Select the source type and add the name or a reference in the Data field.

This example uses the string.format option to combine text with the contents of two memory variables.

##### Log local variables

See Chapter 8 - Debugging local variables for details.

##### Logix

LogixNG has an action called Logix that emulates how JMRI Logix works. The action Logix has one expression and a number of boolean actions. A boolean action is an action that takes a boolean value (true/false) and then decides what to do. The action Logix was added mainly to support import of JMRI Logix to LogixNG.

##### Shutdown

The ShutdownComputer action can either shutdown or restart the computer, or shutdown or restart JMRI.

##### Web browser

The web browser action opens a web page in the web browser.

### Digital boolean action :: Common

To make import from Logix to LogixNG easier, LogixNG has a special action, Logix, that works similar to a Conditional in Logix. The LogixNG Logix action has a digital expression socket and a digital boolean action socket. The usual setup in LogixNG is a Logix action with a Many child with a number of OnChange children.

##### Many

The Many action is used together with the Logix action to let the Logix action have more than one action child.

##### On change

This action is used together with the LogixNG Logix action and gives you the option to decide if the child action should be executed. The options are:

- On change to true
- On change to false
- On change

### Analog action :: Item

##### Light intensity

Sets the intensity of the selected variable light to an analog value.

##### Memory

Sets a memory to an analog value.

### Analog action :: Common

##### Many

Sets the value of many analog actions.

### String action :: Item

##### Memory

Sets a memory to a string value.

##### StringIO

The StringIO sets the string of a StringIO. There is currently one StringIO that can be used with this action: The LocoNet "LCThrottles" StringIO that sends a message to the LocoNet throttles.

### String action :: Common

##### Many

Sets the value of many string actions.

Chapter 6 - Expression Descriptions

Return to the Reference TOC