Files
JIMRI/help/en/html/tools/logixng/reference/chapter10.shtml
T
2026-06-17 14:00:51 +02:00

182 lines
7.9 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 10</title>
<meta name="author" content="Daniel Bergqvist">
<meta name="author" content="Dave Sand">
<meta name="keywords" content="jmri LogixNG reference modules">
<!--#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 10</h1>
<h2>Modules</h2>
<p>A module is a special ConditionalNG which is invoked from regular ConditionalNGs or other
Modules. In programing terms it is a sub-routine, method, def, etc. It can use zero or more
inputs and return zero or more outputs. It does not respond to expression changes.</p>
<p>A common use would be to return the state of a set of expressions that can be called by
various ConditionalNGs rather than listing each expressions in each ConditionalNG. Another
exmaple is setting a common group of actions.</p>
<p>When combined with <a href="chapter11.shtml">tables</a>, a module could be passed the name
of a table row. It would then perform the actions based on the table row data.</p>
<p>The <a href="../../../../package/jmri/jmrit/beantable/LogixNGModuleTable.shtml">Module
Table</a> provides the details on creating a module.</p>
<p>This is a digital expression socket. It can have inputs and outputs as well as returning
<strong>true</strong> or <strong>false</strong> based on the
<strong><em>current</em></strong> state of the expression list.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/digital_expression_root.png"><img src=
"images/chapter10/digital_expression_root.png" alt="Chapter 10 digital expression root"></a>
</div>
<p>This is a digital action socket. This can be used to create an action only module or
complex modules with any combination of expressions and actions, such as <strong>if then
else</strong> structures. These can have inputs and outputs.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/digital_action_root.png"><img src=
"images/chapter10/digital_action_root.png" alt="Chapter 10 digital action root"></a>
</div>
<h3>Inputs and Outputs</h3>
<p>The input and outputs are defined by doing a right click and edit on the first line of the
tree. In the module, the inputs and outputs are defined as local variables.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/parameters_dialog.png"><img src=
"images/chapter10/parameters_dialog.png" alt="Chapter 10 parameters dialog"></a>
</div>
<p>Click on the <strong>Add parameters</strong> button. Enter a name and select whether it is
for <strong>input</strong>, <strong>output</strong> or both. The <strong>Select</strong>
option is used to delete the row or move it up or down.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/parameters_sample.png"><img src=
"images/chapter10/parameters_sample.png" alt="Chapter 10 parameters sample"></a>
</div>
<p>The first row is updated to show the inputs and outputs.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/definitions.png"><img class="image-border"
src="images/chapter10/definitions.png" alt="Chapter 10 module definitions"></a>
</div>
<a id="DigitalExpressionModule"></a>
<h3>Calling a Digital Expression Module</h3>
<p>Expression modules are called from ConditionalNG expressions and return
<strong>true</strong> or <strong>false</strong>.</p>
<p>Use the <strong>Call module</strong> type in the <strong>Flow Control</strong> category.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/add_expression_call.png"><img class="image-border" src=
"images/chapter10/add_expression_call.png" alt="Chapter 10 add expression call"></a>
</div>
<p>After clicking Create, the Module detail window will open. Select the module from the
list. It only shows expresson modules. Click <strong>OK</strong> to add to the tree.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/expression_list.png"><img class="image-border" src=
"images/chapter10/expression_list.png" alt="Chapter 10 call expression list"></a>
</div>
<p>If there are parameters that need configuration, edit the newly added row and the
parameter list will be displayed. If necessary, configure the input and return variables as
described in the next section.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/call_expression_module.png"><img class="image-border" src=
"images/chapter10/call_expression_module.png" alt="Chapter 10 call expression module"></a>
</div>
<a id="DigitalActionModule"></a>
<h3>Calling a Digital Action Module</h3>
<p>Use the <strong>Call module</strong> type in the <strong>Flow Control</strong> category.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/add_action_call.png"><img class="image-border" src=
"images/chapter10/add_action_call.png" alt="Chapter 10 add action call"></a>
</div>
<p>After clicking Create, the Module detail window will open. Select the module from the
list. It only shows action modules. Click <strong>OK</strong> to add to the tree.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/action_list.png"><img class="image-border"
src="images/chapter10/action_list.png" alt="Chapter 10 call action list"></a>
</div>
<p>If there are parameters that need configuration, edit the newly added row and the
parameter list will be displayed. If necessary, configure the input variables</p>
<h4>Configure Call Parameters</h4>
<p>When Edit is selected on the row, the parameters window will open.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/parameters_window.png"><img src=
"images/chapter10/parameters_window.png" alt="Chapter 10 parameters window"></a>
</div>
<p>For <strong>Input types</strong> there are a variety of sources. They range from literals
to various type of references. The <strong>Input data</strong> field has the literal value or
the reference name.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/input_types.png"><img src="images/chapter10/input_types.png" alt=
"Chapter 10 input types"></a>
</div>
<p>For <strong>Output types</strong> there are two choices. The <strong>Output data</strong>
field contains the name of the choice.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/output_types.png"><img src="images/chapter10/output_types.png"
alt="Chapter 10 output types"></a>
</div>
<p>The selections in this example are local variables.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/call_parameters.png"><img src=
"images/chapter10/call_parameters.png" alt="Chapter 10 call parameters"></a>
</div>
<p>The resulting ConditionalNG with the local variables and a comment on the module call.</p>
<div style="margin-left: 2em;">
<a href="images/chapter10/call_action_module.png"><img src=
"images/chapter10/call_action_module.png" alt="Chapter 10 call action module"></a>
</div>
<hr>
<p><a href="chapter11.shtml">Chapter 11 - Tables</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>