The expression descriptions are grouped by the socket type and category.
since 5.1.3The Call Module expression has been moved from the Other category to the Flow Control category.
When the category and type has been selected, the detail expression dialog will be displayed. The content of the dialog will vary depending on the category and type. The typical digital expression item dialog is described below.
The dialog for adding and editing expressions consists of an upper part that contains the item and the states for that item. The lower part is common to all expresssions.
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 state to be checked. The center section will normally have a is / is not combo box. 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
Returns true if the selected audio object has the indicated state. The drop-down list contains the defined audio listeners and audio sources.
The Check only on change option is used to change the logic of the expression evaluation. When the option is not enabled, the normal evaluation occurs: Does the current state match the indicated state. When the option is enabled, the evaluation becomes: Has the current state changed to the indicated state since the last check.
If the conditional named is used in more than one Logix, the results are unpredictable.
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. The train is started using the LogixNG Dispatcher Load train from train info file Action. If the related train does not exist when the expression is evaluated, the result will be false. That means a false result is either actually false or the train does not exist.
Train Mode:
Train Status:
Evaluate if an Entry/Exit pair has a specified state.
Compares the value of the specified local variable to either a string, a memory variable, another local variable or a table cell. See Simplified Table Cell Reference for details on defining the table cell. Evaluates to true if the comparison is true.
The Type indicates the how the comparison process works.
For information about regular expressions, see: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Compares the value of the specified memory variable to either a string, another memory, variable, a local variable or a table cell. See Simplified Table Cell Reference for details on defining the table cell. Evaluates to true if the comparison is true.
The Type indicates the how the comparison process works.
For information about regular expressions, see: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
The Ignore unknown state option is used to bypass the the unknown state. This can occur when transitioning between the on and off states.
If there is a possibility that a reference will refer to an item that does not exist or it is the wrong item type, the Reference expression can test that case and return true or false.
An example would be a table that has optional cells. A table for a staging yard ladder will have a variable number of turnouts based on the selected track.
Enter the reference to be checked and specify the type.
Compare the content of one of the three Reporter data fields to a string, a memory variable or a local variable. See the Memory description for a list of the comparisons.
Note: The meaning of the reports and the state number are defined by originating hardware.
A script expression calls a Jython or ECMAScript script. The script context contains a
result boolean object. When the script is done, it does a
result.setValue(x)
where x is, or evaluates to, True or False.
The Register listener and Unregister listener options are used if the script is to run based on some other JMRI event. For example, the following register command will cause the script to be run every fast minute.
memories.getMemory('IMCURRENTTIME').addPropertyChangeListener('value', self)
Select the type of script. The supported script types are Jython Files and ECMAScript Files.
For details on accessing LogixNG objects from a script see Chapter 13 - Jython Scripting Support.
Returns True if the state of the sensor goes from one predefined state to another, for example from "Active" to "Inactive".
If the option Only true on the first occurrence is selected, the expression will only return True once and there after return False. This is useful if you want the expression to return True only the first time it is evaluated.
And evaluates the child expressions and if all of them returns true, the And expression returns true as well.
The Antecedent expression is mainly included to make import from Logix to LogixNG simple. It works exactly as Antecedent in Logix. It has a number of child expressions and an antecedent that defines how the evaluation of the expressions should be done. Each child expression is referenced in the antecedent by R1, R2, R3, ..., there R1 is the first child expression, R2 is the second child expression, and so on. Note that this differs from other expressions in LogixNG. Other LogixNG expressions use the socket name, but since the Antecedent expression is included to work as Antecedent works in Logix, the antecedent has been kept from Logix Antecedent as well. Note: Antecedent is included for compability with Logix but it's recommended to use Formula instead. Formula is much more powerful, uses the socket names and also works with numbers and strings.
Formula is the next generation of Antecedent. It supports many operators, like ==, !=, <=, >=, <, >, +, -, *, / and %. It supports local variables, memories and functions. It supports all the types of expressions, digital, analog and string expressions. See Generic expression for details on the result of merging the other expressions.
The Not expression has one child expression and answers true if the child expression answers false, and false if the child expression answers true.
Or evaluates the child expressions and if at least one of them returns true, the Or expression returns true as well.
The Timer expression returns False until some time has passed. It then returns True once and the timer starts again. This expression is intended to be used together with the Sequence action. This makes it possible to have sequence steps based on time durations.
Call a module and and return its true/false response. See Chapter 10 - Modules
Evaluate the LocoNet slot usage.
The Linux upower command line tool is used to determine if external power is active. For example, if the external power is removed, then this tool can be used to do a graceful shutdown before the battery dies.
The expression runs the upower command line tool every five seconds. If it detects a change, it triggers the execution of the ConditionalNG.
When the expression is added, the upower command is checked to make sure it is present and working. A warning message will be displayed if there is an issue.
The False expression always answers false.
The True expression always answers true. This expression is commonly used as a child to the Trigger Once expression.
The Connection name expression returns true if the selected manufacturer and connection type match a connection in Preferences ⇒ Connections.
This can be used to determine whether JMRI is using a real layout connection or a simulated connection. For example, a startup LogixNG can set an internal sensor that indicates the simulation state. Other LogixNG defintions can then check the state to determine what actions are appropriate. A good example is whether the Simulate turnout feedback action should be used.
The connection name is selected by choosing the manufacturer and then a connection name from the connection list.
The File as flag expression checks for the existence of a file. If the
file exists, the expression returns true, otherwise it returns false
. When the file is found, it can be kept or deleted. Normally the file will be
created by some process that needs to notify JMRI about an event. For Linux and macOS,
touch filename
works from the command line or a script.
The are several options for Windows, such as
copy nul filename
,
type nul > filename
, or
echo > filename
.
The file selector is used to create the path to the file and file name. The default path is the user files location. If the file does not currently exist, select a different file and then replace the file name with the planned file name before creating the expression.
The default file action when the file is found is Keep file. The Delete file action can be selected which would be useful for repetitive external events.
Example
The LogixNG Timer action is used to run the File as flag expresson every 5 seconds. When the file exists, an internal sensor is set Active. The file is deleted and the timer loop resumes running File as flag. The sensor is used to trigger another process which handles the event. For simple actions, Then could be used to do the work.
Configure the Timer action.
Create the LogixNG.
The Hold expression has two child expressions, one trigger expression and one hold expression. For this expression to become true, both the trigger expression and the hold expression must answer true. But then it stays true as long as the hold expression stays true.
Each digital expression retains its most recent true/false state. This can be checked if the expression has a user name. See Chapter 3. Select the user name from the combo box.
The Log data expresson works the same as the Log data action. See Log data action for details.
Since this is an expression, it must return true or false. The window for creating the expression version includes a combo box for selecting True or False
True is recommended for And expressions and False for Or expressions.
The TriggerOnce expression answers true one single time and then false until its child expression becomes False and then True again.
Most often, the TriggerOnce expression will have the expression Always true as its child and it will then answers true one single time and then false until JMRI is restarted.
Return a constant as an analog value.
AnalogIO reads the value of an AnalogIO and returns its value. There is currently two items that can be used with AnalogIO:
Some connections supports meters, for example current and/or voltage meters. This depends on the hardware connected to JMRI. An example is the Roco Z21 that has a current and voltage meter that JMRI can listen to.
Return value of a local variable as an analog value.
Return value of a memory variable as an analog value.
Return the number of minutes since midnight using either the fast clock or the system clock.
Return the result of a formula as an analog value.
Return value of a memory variable as a string value.
Return a constant as an string value.
Return the result of a formula as a string value.
The Digital Formula expression can use any of the other expressions. This means the lists from the other sockets and categories are combined.
The combined Item list:
The combined Common list:
The Flow Control, LocoNet and Other lists are the same as Digital expression.
Thanks and congratulations to all who contributed! Contact us via the JMRI users Groups.io group.
Copyright © 1997 - 2024 JMRI Community. JMRI®, DecoderPro®, PanelPro™, DispatcherPro™, OperationsPro™, SignalPro™, SoundPro™, TrainPro™, Logix™, LogixNG™ and associated logos are our trademarks. Additional information on copyright, trademarks and licenses is linked here.
View the