JMRI: Conditional Tree Editor
Author: Dave Sand
Keywords: JMRI help Logix Conditional Add Edit

# Conditional Tree Editor

The tree based Conditional Editor uses a single window to display and edit all of the conditionals for the selected Logix.

The window is divided into 4 sections.

- The top section contains the Logix system and user names. The user name can be changed. Enter the name and press Enter.
- The left pane of the center section contains the tree structure for all of the conditionals for the currently selected Logix. The tree can expand and collapse to control the amount of detail being displayed.
- The right pane of the center section contains the detail information, if any, about the currently selected tree row.
- The right side of bottom section contains the Done button which closes the editor window. The left side contains the Action buttons. These buttons vary depending on the selected tree row.

The workflow for the tree editor is dynamic. As each change is made, it is applied to the Conditional tables. As long as the panel xml file has not been updated, it is still possible to recover.

The tree structure makes it very easy to move around. The only restriction is that a different tree node cannot be selected if there is an active edit. To make an active edit apparent, the detail Cancel and Update buttons become active and the action bar buttons become inactive. Clicking on any field in the detail pane changes the pane from Display mode to Edit mode

The first level of the tree contains the Conditionals that belong to the current Logix. The second level contains the Antecedent field, the Logic Type and Trigger Mode fields along with a Variables and Actions node. The third level contains the detail rows for Variables and Actions.

### Action Bar Button Matrix

| Level | Add | Check State | Delete | Move | Toggle | Help
--- | --- | --- | --- | --- | --- | --- | ---
Conditional | 1 | Y | Y | Y | 1 |  |
Antecedent | 2 |  |  |  |  |  | Y
Variables | 2 | Y | Y |  |  |  |
Variable | 3 | Y |  | Y | 1, 2 |  |
Logic Type | 2 |  |  |  |  |  |
Trigger Mode | 2 |  |  |  |  | Y |
Actions | 2 | Y |  |  |  |  |
Action | 3 | Y |  | Y | 1 |  |

1 — Move is actually an Up button and a Down button.
2 — Move is disabled for Variables if the Logic Type is set to Mixed.

## The Edit Process

When the tree editor is started, the conditionals for the selected Logix are displayed. Each row contains the system name, the user name, and the current state in brackets. Select a row to change the user name using the detail pane. When the change is done, press Update . The user name may not be the same as the user name of another Conditional in this Logix, but may be the same as the user name of a Conditional in a different Logix.

To change the order of the Conditionals, select a Conditional row and use the Up and Down buttons to move the row. Note that the order that Conditionals are listed in the Logix does not determine the order in which they're evaluated, nor does it force evaluation of one Conditional when an earlier or later one is evaluated. For more on this, see the discussion on the Logix main page.

Conditionals are statements of the form:

`if (logical expression) then (action)`

When a Conditional row is expanded, five rows are displayed. The Antecedent, Variables and Logix Type rows are used to build the Logical Expression. The Trigger Mode and Actions rows are used to build the Action.

## Logical Expression

Expand the Variables row to see the individual Variable rows. Each row starts with a row number (Rn) which is used to create manual logic when the Logic Type has been set to Mixed. A description of the statement follows. The trigger setting and the last calculated state are in bold at the end.

When a Variable row is selected, the information will be displayed in the detail section. The first 4 detail rows are common to all Variable types. The first row is the selected type. The second one will be set to AND or OR. This is set automatically by the Logic Type or manually when using MIXED. The third row can be set to NOT. If set, that will invert the test. The fourth row is the Trigger Calculation checkbox. For those cases where a change in a specific entity (sensor, turnout, etc.) should not trigger a calculation result, you should uncheck the checkbox by clicking on it. Unchecking the checkbox tells the program to monitor that entity for state changes and calculate the state of the Conditional, but take no action on the result of the calculation.

The remaining fields in the detail section will vary depending on selected Variable Type. If you don't know what needs to be entered in a data field, hover your cursor over the label, and a hint message will appear. For details, see State Variables.

The Logic Type can be set to AND, OR or MIXED. If AND or OR, the descriptive portion of the Variable will display all AND or all OR. If set to MIXED, each line can have its own value. See below.

The default Logic Type is "AND". In this case the Conditional will test if all variable tests are true, after taking the "NOT" negations into account. Using the Logic Type row, you can change that to "OR" or "Mixed". "OR" means the conditional will be true if any one of the variable tests are true, after accounting for the negations.

Selecting "Mixed" will enable the Antecedent row. Select this row to display the antecedent field in the detail pane. This will let you enter a logical expression using AND's, 'OR's and NOT's and the row numbers. In this expression, each variable is referred to by number, e.g. R1, R2, R3 for the first three variables, you can use the operators "and", "or" and "not" in addition to parentheses. Some examples:

`R1 and R2
R1 or (R2 and R3)
(R2 and R3) or (R3 and R1)`

### Adding a New State Variable

Press the Add button when either the Variables row or a Variable row is selected to add a state variable. The detail pane will display a choice box for the user to select a state variable type. Available state variables are documented at State Variables. When a type is chosen, additional fields will be added to the detail pane. The text field for the name must contain an existing entity (sensor, turnout, light, etc.). The actual format for entering names will depend on the conditional name selection method setting. See Conditional Name Selection Method.

For Conditional Variables, the text input field is replaced by two drop down combo boxes. The first box is used to select the Logix, the second box is used to select a Conditional that belongs to the selected Logix. since 4.7.4

After the name is entered, select the required state from the Variable State drop down box. Depending on the selected variable type and state, additional fields may be displayed.

After you have completed your updates, you can select the Variables row and use the Check State button to evaluate the state variables. When this button is pressed, the checking and evaluation proceeds until the check completes successfully, or an error is detected. If an error is detected, the checking stops for the user to correct the error and click Check State again.

Select Update to save the changes or Cancel to discard the changes.

## Action

Expand the Actions row to see the individual Action rows. Each row starts with a phrase that indicates under what conditions it will be invoked. A description of the Action follows.

Actions are evaluated in the order listed. To change that order, select an Action row and use the Up and Down buttons to move the row.

Select an Action row to display the details in the detail pane. Click on a field to enter edit mode. To create a new Action, select Add from either the Actions or Action button list.

If a new Action is being created, only the Action Group will be displayed. Once a choice has been made, other fields will be displayed based on the selected type. Available Action types are documented at Actions.

When a type is chosen, the Edit Action window displays a text field for the name of the entity to be used for the Action. When a name (either system name or user name) is entered, it must correspond to an existing entity (sensor, turnout, light, etc.). The actual method for entering names will depend on the conditional name selection method setting. See Conditional Name Selection Method.

The data items needed to completely specify the action will appear in the detail pane. If you don't know what needs to be entered in a data field, hover your cursor over the label, and a hint message will appear.

For each action, three options are available for when to trigger the action:

- On Change to True
- On Change to False
- On Change

These refer to the calculated state of the Conditional, which is equal to the value of the logical expression as specified in the state variable table. One of these options must be selected.

If the Trigger Mode: row has been changed to Execute Action whenever triggered, then the options are:

- When Triggered True
- When Triggered False
- Whenever Triggered

Select Update to save the changes or Cancel to discard the changes.

For more information, consult the main Logix documentation.

## Logix Documentation Pages Logically Listed