292 lines
12 KiB
Plaintext
292 lines
12 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy for HTML5 for Apple macOS version 5.8.0">
|
|
<title>LogixNG Reference - Chapter 1</title>
|
|
<meta name="author" content="Daniel Bergqvist">
|
|
<meta name="author" content="Dave Sand">
|
|
<meta name="keywords" content="jmri LogixNG reference getting started">
|
|
<!--#include virtual="/help/en/parts/Style.shtml" -->
|
|
</head>
|
|
<body>
|
|
<!--#include virtual="/help/en/parts/Header.shtml" -->
|
|
|
|
<div id="mBody">
|
|
<div id="mainContent" class="no-sidebar">
|
|
<h1>LogixNG Reference - Chapter 1</h1>
|
|
|
|
<h2>LogixNG - What is it?</h2>
|
|
|
|
<p>LogixNG is similar to Logix. It's a way to define rules, like <em>"If sensor IS1 is
|
|
Active, then set turnout IT2 to Thrown"</em>. It borrows some concepts from Logix, but it's a
|
|
complete new design and it can work side by side with Logix.</p>
|
|
|
|
<h2>Setting up a LogixNG and a ConditionalNG</h2>
|
|
|
|
<p>First, we create a LogixNG. We start <strong>PanelPro</strong> and select
|
|
<strong>Tools</strong> ⇒ <strong>Tables</strong> ⇒ <strong>LogixNG</strong> ⇒
|
|
<strong>LogixNG</strong> to open the table with the LogixNGs.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_logixng_1.png"><img src=
|
|
"images/chapter1/create_logixng_1.png" alt="Chapter 1-L1"></a>
|
|
</div>
|
|
|
|
<p>Click the <strong>Add...</strong> button to add a new LogixNG.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_logixng_2.png"><img src=
|
|
"images/chapter1/create_logixng_2.png" alt="Chapter 1-L2"></a>
|
|
</div>
|
|
|
|
<p>By default, the checkbox <strong>Automatically generate System Name</strong> is checked
|
|
for all items in LogixNG.</p>
|
|
|
|
<p>Click the <strong>Create</strong> button to create a LogixNG. The LogixNG ConditionalNG
|
|
list will be opened automatically.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_logixng_3.png"><img src=
|
|
"images/chapter1/create_logixng_3.png" alt="Chapter 1-L2"></a>
|
|
</div>
|
|
|
|
<p>Click the <strong>New ConditionalNG</strong> button to add a new ConditionalNG.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_1.png"><img src=
|
|
"images/chapter1/create_conditionalng_1.png" alt="Chapter 1-1"></a>
|
|
</div>
|
|
|
|
<p>Click the <strong>Create</strong> button to create it. The ConditionalNG editor will
|
|
open.</p>
|
|
|
|
<h2>The ConditionalNG editor</h2>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_2.png"><img src=
|
|
"images/chapter1/create_conditionalng_2.png" alt="Chapter 1-2"></a>
|
|
</div>
|
|
|
|
<p>A ConditionalNG is a tree of actions and expressions. When the ConditionalNG is created,
|
|
the tree consist only of a single female socket, "! A". The exclamation mark indicates that
|
|
this is a digital action socket, so you can connect digital actions to it.</p>
|
|
|
|
<p>Right-click on any row to show the context menu for that row.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_3.png"><img class="image-border" src=
|
|
"images/chapter1/create_conditionalng_3.png" alt="Chapter 1-3"></a>
|
|
</div>
|
|
|
|
<p>The common context menu items also have shortcut key combinations. If <strong>Highlight
|
|
row in ConditionalNG editor</strong> is enabled in LogixNG preferences, the shortcut keys are
|
|
also available without displaying the context menu. See <a href="../LogixNG.shtml#preferences">
|
|
LogixNG Preferences</a>.</p>
|
|
|
|
<h3>Create an Action</h3>
|
|
|
|
<p class="noted">The process to add a row to the ConditionalNG tree was changed as of JMRI
|
|
release 5.1.4. The old process is available at <a href="original_add.shtml">Orignal Add Process</a>.</p>
|
|
|
|
<p>To create a new action, we right-click with the mouse on the female socket <code>!
|
|
A</code> and then select <strong>Add</strong> in the popup menu. The data selection is
|
|
presented in a series of sub-menus.</p>
|
|
|
|
<p>The first sub-menu provides a list of <strong>categories</strong>. Instead of a very long
|
|
list of actions and expressions, they are grouped in categories.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/action_categories.png"><img class="image-border" src=
|
|
"images/chapter1/action_categories.png" alt="action categories"></a>
|
|
</div>
|
|
|
|
<p>When a category has been selected, a list of <strong>types</strong> will be displayed. In
|
|
this example, the types are from the <strong>Item</strong> category.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/action_item_types.png"><img class="image-border" src=
|
|
"images/chapter1/action_item_types.png" alt="action item types"></a>
|
|
</div>
|
|
|
|
<p>Let's start with a turnout item. Click on the Turnout item in the sub-menu.</p>
|
|
|
|
<p>We now get a dialog box there we can select the turnout to control. And what to do with
|
|
this turnout.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_8.png"><img src=
|
|
"images/chapter1/create_conditionalng_8.png" alt="Chapter 1-8"></a>
|
|
</div>
|
|
|
|
<p>In this example, we select "IT_1_1" and we tell the action to throw the turnout when the
|
|
action is triggered.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_9.png"><img src=
|
|
"images/chapter1/create_conditionalng_9.png" alt="Chapter 1-9"></a>
|
|
</div>
|
|
|
|
<p>Click the <strong>Create</strong> button to create this action.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_10.png"><img src=
|
|
"images/chapter1/create_conditionalng_10.png" alt="Chapter 1-10"></a>
|
|
</div>
|
|
|
|
<p>The action is now created and each time this ConditionalNG is executed, the turnout
|
|
"IT_1_1" is thrown.</p>
|
|
|
|
<h3>Create an Expression</h3>
|
|
|
|
<p>Having a single turnout action in the ConditionalNG will not do much good. Lets change the
|
|
ConditionalNG so that it reads sensor "IS_1_1" and if it's active, the turnout is thrown.</p>
|
|
|
|
<p>To do this, we need to temporarily remove the Set turnout action and instead add an
|
|
<strong>If Then Else</strong> action. LogixNG has a clipboard that allows us to cut and paste
|
|
actions and expressions. So lets use it to temporarily move the Set turnout action to the
|
|
clipboard.</p>
|
|
|
|
<p>Right-click with the mouse on the Set turnout action and then select "Cut" in the popup
|
|
menu.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_11.png"><img class="image-border" src=
|
|
"images/chapter1/create_conditionalng_11.png" alt="Chapter 1-11"></a>
|
|
</div>
|
|
|
|
<p>The action is now moved to the clipboard and the ConditionalNG is empty.</p>
|
|
|
|
<p>We will not look at the clipboard for now, but as a side note, you can open the clipboard
|
|
by selecting <strong>Tools ⇒ Clipboard</strong> in the ConditionalNG editor.</p>
|
|
|
|
<p>Right click on <code>! A</code> and select <strong>Add</strong>. This time select the
|
|
<strong>Flow Control</strong> category and the <strong>If Then Else</strong> type.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_12.png"><img src=
|
|
"images/chapter1/create_conditionalng_12.png" alt="Chapter 1-12"></a>
|
|
</div>
|
|
|
|
<p>Click on the <strong>Create</strong> button.</p>
|
|
|
|
<p>The <strong>If Then Else</strong> item has two options. The default is <strong>Execute on
|
|
change</strong>. The <strong>Then</strong> and <strong>Else</strong> actions will execute
|
|
when the <strong>If</strong> expression has changed between true and false. When the
|
|
<strong>Always execute</strong> option is selected, the actions will execute even though the
|
|
<strong>If</strong> expression is still true or false.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_13.png"><img src=
|
|
"images/chapter1/create_conditionalng_13.png" alt="Chapter 1-13"></a>
|
|
</div>
|
|
|
|
<p>Click on the <strong>Create</strong> button.</p>
|
|
|
|
<p>We now have a ConditionalNG with the If Then Else action.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_14.png"><img src=
|
|
"images/chapter1/create_conditionalng_14.png" alt="Chapter 1-14"></a>
|
|
</div>
|
|
|
|
<p>Right-click with the mouse on the <strong>Then</strong> socket and select
|
|
<strong>Paste</strong> in the popup menu to paste the "Set turnout" action.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_15.png"><img class="image-border" src=
|
|
"images/chapter1/create_conditionalng_15.png" alt="Chapter 1-15"></a>
|
|
</div>
|
|
|
|
<p>We now have the <strong>If Then Else</strong> action with the Set turnout action.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_16.png"><img src=
|
|
"images/chapter1/create_conditionalng_16.png" alt="Chapter 1-16"></a>
|
|
</div>
|
|
|
|
<p>Right-click with the mouse on the <strong>If</strong> socket and select
|
|
<strong>Add ⇒ Item ⇒ Sensor</strong> in the popup menu to add a new expression.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_17.png"><img src=
|
|
"images/chapter1/create_conditionalng_17.png" alt="Chapter 1-17"></a>
|
|
</div>
|
|
|
|
<p>Select the "IS_1_1" sensor and select "Active". Note also the dropdown box <strong>is / is
|
|
not</strong> in the middle.</p>
|
|
|
|
<p>Normally, any change to an expression item should trigger the true/false evaluation.
|
|
Sometimes an expression item should participate in the evaluation but not trigger it. The
|
|
Listen checkbox is used to control the trigger state.</p>
|
|
|
|
<p>Click on the <strong>Create</strong> button.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_19.png"><img src=
|
|
"images/chapter1/create_conditionalng_19.png" alt="Chapter 1-19"></a>
|
|
</div>
|
|
|
|
<p>We now have a ConditionalNG which will be executed every time the sensor "IS_1_1" changes
|
|
its state. And if "IS_1_1" changes to Active, then turnout "T_1_1" will be thrown.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/create_conditionalng_20.png"><img src=
|
|
"images/chapter1/create_conditionalng_20.png" alt="Chapter 1-20"></a>
|
|
</div>
|
|
|
|
<h2>Additional Example</h2>
|
|
|
|
<ul>
|
|
<li>To create a compound <strong>if</strong> expression, add an operator such as
|
|
<strong>And</strong> or <strong>Or</strong> before adding the expressions. These are
|
|
located in the Common category.</li>
|
|
|
|
<li>To create multiple actions, add the <strong>Many</strong> operator before adding the
|
|
actions. This and others are in the Common category.</li>
|
|
|
|
<li>To create a delayed action, use the <strong>Execute delay</strong> action in Common and
|
|
then add the action to the delay.</li>
|
|
|
|
<li>When adding or editing an expression or action, a comment can be edited using the
|
|
<strong>Edit comment</strong> button on the detail dialog.</li>
|
|
</ul>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter1/conditionalng_example_1.png"><img src=
|
|
"images/chapter1/conditionalng_example_1.png" alt="Chapter 1 Example 1"></a>
|
|
</div>
|
|
|
|
<h2>Another example: Stop the power during lunch</h2>
|
|
|
|
<p>Logix support reading the fast clock. LogixNG also supports reading the system clock. Lets
|
|
assume you want to cut power to the layout during the lunch. This can easily be done by the
|
|
following ConditionalNG:</p>
|
|
|
|
<pre>
|
|
* IfThenElse
|
|
* If: And
|
|
* E1: System clock is between 12:00 and 13:00
|
|
* E2: Power is On
|
|
* Then: Set power Off
|
|
* Else:
|
|
</pre>
|
|
|
|
<hr>
|
|
|
|
<p><a href="chapter1_1.shtml">Chapter 1.1 - Map Logix features to LogixNG</a>
|
|
</p>
|
|
|
|
<p><a href="chapter2.shtml">Chapter 2 - The clipboard</a>
|
|
</p>
|
|
|
|
<p><a href="index.shtml">Return to the Reference TOC</a>
|
|
</p>
|
|
<!--#include virtual="/help/en/parts/Footer.shtml" -->
|
|
</div>
|
|
<!-- closes #mainContent-->
|
|
</div>
|
|
<!-- closes #mBody-->
|
|
<script src="/js/help.js"></script>
|
|
</body>
|
|
</html>
|