242 lines
10 KiB
Plaintext
242 lines
10 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 7</title>
|
|
<meta name="author" content="Daniel Bergqvist">
|
|
<meta name="author" content="Dave Sand">
|
|
<meta name="keywords" content="jmri LogixNG reference references">
|
|
<!--#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 7</h1>
|
|
|
|
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
|
|
|
|
<h2>References</h2>
|
|
|
|
<p>The following discussion refers to {name}. This can be either a JMRI memory variable or a
|
|
LogixNG Local Variable.</p>
|
|
|
|
<p>LogixNG can use references to access layout items like turnouts in an indirect way. It's
|
|
done by entering the system name or user name in curly brackets. If a turnout action has the
|
|
turnout IT1, it will access that turnout directly. But if the turnout action has the turnout
|
|
{IM2}, it will read that memory and if that memory has a string as a value, it will use that
|
|
string value to find the turnout. So if the memory IM2 has the value IT5, and the turnout
|
|
action has the turnout {IM2}, the turnout action will read the memory IM2 and find out that
|
|
it points to the turnout IT5 and therefore do it's action on turnout IT5. The benefit of this
|
|
is that the Memory can be changed during execution and therefore the same turnout action can
|
|
be used to access different turnouts at different times.</p>
|
|
|
|
<p>It's possible to use indirect access recursive. If a turnout action has the turnout {IM5},
|
|
and that Memory has the value {IM14}, and that the Memory IM14 has the value IT3, the turnout
|
|
action will access IT3. The turnout action has an indirect turnout IM5 so it will read that
|
|
Memory. And since that memory has the value {IM14} which also is an indirect access, it will
|
|
read the memory IM14 and find out that it has the value IT3, and therefore use IT3. This is
|
|
also true for tables. If the cell IQT1[5,3] has the value '{IM3}', and the memory IM3 has the
|
|
value 'IT5', the cell IQT1[5,3] will point to IT5.</p>
|
|
|
|
<p>When the Reference tab is selected, the appropriate values are entered into the text
|
|
field. References are the name of a local variable, memory or table cell, enclosed in curly
|
|
brackets.</p>
|
|
|
|
<div style="margin-left: 2em;">
|
|
<a href="images/chapter7/reference_tab.png"><img src="images/chapter7/reference_tab.png"
|
|
alt="Chapter 7 reference tab" width="393" height="85"></a>
|
|
</div>
|
|
|
|
<p>Some examples:</p>
|
|
|
|
<div style="margin-left: 2em;">
|
|
<table>
|
|
<tr>
|
|
<th>Reference</th>
|
|
<th>Description</th>
|
|
<th>Note</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{MyLocalVariable}</td>
|
|
<td>The value of the local variable <em>MyLocalVariable</em></td>
|
|
<td>The name is in the symbol table</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{My memory}</td>
|
|
<td>The value of the memory <em>My memory</em></td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{{My other memory}}</td>
|
|
<td>Double reference, the value of the value</td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{My table[North yard, Left turnout]}</td>
|
|
<td>The value of the cell at the intersection of the row name and column name</td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{My table[{Yard}, Left turnout]}</td>
|
|
<td>Same as above except the row name comes from a reference</td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{My table[North yard, {Turnout selection}]}</td>
|
|
<td>Same as above except the column name comes from a reference</td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{{TableName}[North yard, Left turnout]}</td>
|
|
<td>The table name comes from a reference, which becomes a reference</td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>{{TableName}[{Yard}, {Turnout selection}]}</td>
|
|
<td>Everything comes from a reference, which becomes a reference</td>
|
|
<td>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<p>Local variables are described in <a href="chapter8.shtml">Chapter 8 - Local
|
|
variables</a>.</p>
|
|
|
|
<p>Tables are described in <a href="chapter11.shtml">Chapter 11 - Tables</a>.</p>
|
|
|
|
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
|
|
|
|
<h2 id="indirect_accessing">Indirect addressing of NamedBeans</h2>
|
|
|
|
<p>In some cases, it may be useful to use indirect addressing of NamedBeans.</p>
|
|
|
|
<p>This can be done in two ways:</p>
|
|
|
|
<ul>
|
|
<li>Using a Memory that has the name of the NamedBean</li>
|
|
|
|
<li>Using a Table to lookup the name of the NamedBean</li>
|
|
</ul>
|
|
|
|
<p>Using a Memory that has the name of the NamedBean</p>
|
|
|
|
<p>Lets say we have a Turnout action that should throw a particular turnout. But we want to
|
|
be able to select which turnout to throw at a later time. We can solve that by storing the
|
|
system name or user name in a Memory. We then tell the Turnout action to read the Memory and
|
|
lookup the turnout on the fly.</p>
|
|
|
|
<p>Since LogixNG fully supports string manipulation and calculations of both integers and
|
|
floating point values, where are plenty of possibilities here.</p>
|
|
|
|
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
|
|
|
|
<h2 id="indirect_enums">Indirect addressing of Enums</h2>
|
|
|
|
<p>Sometimes the <strong>Direct</strong> tab of an action or expression contains a drop-down
|
|
list. These are normally created using a Java Enum. For indirect references, the actual enum
|
|
<strong>name</strong> is used instead of the displayed name. The also applies to other
|
|
indirect references such as memories, local variables, formulas and tables. Note: The
|
|
displayed name might be a translation.</p>
|
|
|
|
<p>When an enum is used, a <strong>Show valid values</strong> button is added to panel. Note:
|
|
The button is not added to the table panel, but is available on the other indirect panels.</p>
|
|
|
|
<div style="margin-left: 2em;">
|
|
<a href="images/chapter7/show-valid-turnout.png">
|
|
<img src="images/chapter7/show-valid-turnout.png"
|
|
alt="Chapter 7 show valid turnout"></a>
|
|
</div>
|
|
|
|
<p>Clicking on the button will display a list of the enum values for the current object type.</p>
|
|
|
|
<div style="margin-left: 2em;">
|
|
<a href="images/chapter7/show-valid-values.png">
|
|
<img src="images/chapter7/show-valid-values.png"
|
|
alt="Chapter 7 show valid values"></a>
|
|
</div>
|
|
|
|
<p>This is a reference list. It is not used to select values. That process will depend on the
|
|
type of indirect reference.</p>
|
|
|
|
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
|
|
|
|
<h3 id="ListenOnBeans">Listen on beans</h3>
|
|
|
|
<p>There is one major drawback with this. Since LogixNG doesn't know in advance which
|
|
NamedBeans (turnouts, sensors, etc.) will be accessed indirectly, it's not possible for
|
|
LogixNG to automatically register listeners to the named beans that should trigger on change.
|
|
For example, a Turnout expression registers a listener on the turnout, if the name of the
|
|
turnout is given, but if the Turnout expression is using indirect addressing of the turnout,
|
|
it's not able to do that.</p>
|
|
|
|
<p>The solution is to use the <strong>Listen on beans</strong> action and tell this action
|
|
which beans to listen on. Any time any property of any of the named beans this action listens
|
|
to changes, the ConditionalNG will be executed.</p>
|
|
|
|
<div style="margin-left: 2em">
|
|
<a href="images/chapter7/listen_on_beans_dialog.png"><img src=
|
|
"images/chapter7/listen_on_beans_dialog.png" alt="LogixNG listen on beans dialog"
|
|
width="612" height="495"></a>
|
|
</div>
|
|
|
|
<p>The <strong>Add reference</strong> button is used to add beans to the the list. For each
|
|
bean select the bean type, the bean name from the drop down list and whether the standard
|
|
events for the selected bean should be monitored or if all of the events are monitored.</p>
|
|
|
|
<p>There are three optional fields for specifying local variables that will contain the name
|
|
of the bean, the event type and the new value. For example, a sensor has a <strong>KnownState
|
|
</strong> event with the new value being 2 (Active) or 4 (Inactive).</p>
|
|
|
|
<p class="noted">If the optional local variables are used and the <strong>Listen On Beans</strong>
|
|
action is part of a copy/cut/paste, the local variable names will be included in the paste
|
|
action. If the same names have not been defined in the target ConditionalNG, a LogixNG
|
|
exception will occur. Make sure the paste destination has those local variables defined.</p>
|
|
|
|
<p>Example:</p>
|
|
|
|
<p>A ConditionalNG is using turnouts IT1, IT2, IT3, IT4 and IT5 in it's expressions and wants
|
|
each of them to trigger on change. Turnouts IT1 and IT3 and IT4 are directly accessed in
|
|
expressions and IT2 and IT5 are indirect accessed.</p>
|
|
|
|
<p>Each turnout that is directly addressed in an expression will have the ConditionalNG
|
|
listen to automatically, so IT1, IT3 and IT4 will be listend to. But in order to listen on
|
|
turnouts IT2 and IT5, the <strong>Listen on beans</strong> action needs to be used.</p>
|
|
|
|
<p>The <strong>Listen on beans</strong> action can be placed anywhere in the ConditionalNG
|
|
tree, as long as it and its parents are enabled. If you disable this action, or any of its
|
|
parent actions, the <strong>Listen on beans</strong> action will not listen on its named
|
|
beans.</p>
|
|
|
|
<hr>
|
|
|
|
<p><a href="chapter8.shtml">Chapter 8 - Local Variables</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>
|