How to Use Parent and Child Rules

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m
m (replaced <font> and <u> tags with <span style=...> tags, removed all image hyperlinks, added graphic to BuilderBob's edit)
Line 2: Line 2:
  
 
__TOC__
 
__TOC__
 +
 
='''What Are Parent and Child Rules?'''=
 
='''What Are Parent and Child Rules?'''=
 
Session rules are arranged in a hierarchical fashion. A '''Parent Rule''' can be used to group a set of rules at a lower level in the hierarchy.  The rules that are grouped under a '''Parent Rule''' are '''Child Rules'''.  These '''Child Rules''' can also be '''Parent Rules''', thus creating multiple levels in the hierarchy.
 
 
Most '''Parent Rules''' are used as "decision makers" in Trainz Sessions: they provide a result which determines if or when other rules (the '''Child Rules''') will be executed. Other parent rules have predefined conditions which control how their '''Child Rules''' are executed.
 
  
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top>
 
<tr valign="top>
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
<td>'''Rules that act as ''Parent Rules'' can have one or more sub-rules or ''Child Rules'' indented under them.'''</td>
+
<td>'''Rules that act as ''Parent Rules'' can have one or more sub-rules or ''Child Rules'' under them.'''</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
 
<br>
 
<br>
 +
Most '''Parent Rules''' are used as "decision makers" in TANE/TRS19 Sessions. They decide if or when other rules, the '''Child Rules''', will be executed. Some '''Parent Rules''' control how those '''Child Rules''' are executed.<br>
 +
 +
<table>
 +
<tr valign="top">
 +
<td>[[file:Parent_Child.PNG|link=]]</td>
 +
<td>Session rules can be arranged in a hierarchical fashion, in a series of levels as shown in the example on the left. A '''Parent Rule''' can be used to group together a set of rules at a lower level in the hierarchy. The rules that are grouped together under a '''Parent Rule''' are the '''Child Rules'''.<br><br>
 +
 +
'''Child Rules''' can also be '''Parent Rules''' that group together other rules at an even lower level. This creates multiple levels in the hierarchy.<br><br>
 +
 +
The '''Parent Rule''' at the head of each level in the hierarchy acts as a ''switch'' that directs the Trainz session to either ignore (skip over) or obey (execute) the '''Child Rules''' under its control.</td>
 +
</tr>
 +
</table>
 +
 
<table cellpadding="4" bgcolor=#ffffb0>
 
<table cellpadding="4" bgcolor=#ffffb0>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:NotePad.PNG]]</td>
+
<td>[[file:NotePad.PNG|link=]]</td>
<td><font size="3">'''Notes:'''</font><br>
+
<td><span style="font-size: 17px;">'''Notes:'''</span><br>
*Only certain rules can be Parent Rules. See the Trainz Wiki page [[file:WikiLink.PNG]] '''[[Parent Rule List|List of Parent Rules]]''' for details.
+
*Only certain rules can be Parent Rules. See the Trainz Wiki page [[file:WikiLink.PNG|link=]] '''[[Parent Rule List|List of Parent Rules]]''' for details.
 
*Most Parent Rules will ''either'' wait for a specific event or perform a test or a comparison. They will execute the child rules when the event occurs or the test/comparison is ''true''.
 
*Most Parent Rules will ''either'' wait for a specific event or perform a test or a comparison. They will execute the child rules when the event occurs or the test/comparison is ''true''.
 
*Any rule can be a Child Rule.</td>
 
*Any rule can be a Child Rule.</td>
Line 27: Line 37:
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top>
 
<tr valign="top>
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>'''Rules that act as ''Child Rules'' are indented under a ''Parent Rule''.'''</td>
 
<td>'''Rules that act as ''Child Rules'' are indented under a ''Parent Rule''.'''</td>
 
</tr>
 
</tr>
Line 42: Line 52:
 
</tr>
 
</tr>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:Steps.PNG]]</td>
+
<td>[[file:Steps.PNG|link=]]</td>
<td><font size="3">'''Steps:'''</font><br>
+
<td><span style="font-size: 17px;">'''Steps:'''</span><br>
 
To '''indent''' a rule,
 
To '''indent''' a rule,
 
#highlight (select) it
 
#highlight (select) it
Line 60: Line 70:
 
<table>
 
<table>
 
<tr>
 
<tr>
<td>[[file:Message_Popup.jpg]]</td>
+
<td>[[file:Message_Popup.jpg|link=]]</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
Line 71: Line 81:
 
****'''Close Message Popup Rule''' is indented under the '''Wait Rule''' so it is a Child of that rule.  
 
****'''Close Message Popup Rule''' is indented under the '''Wait Rule''' so it is a Child of that rule.  
 
<br>
 
<br>
<font size="3">'''Sequence of Events'''</font>
+
<span style="font-size: 17px;">'''Sequence of Events'''</span>
 
<br>
 
<br>
 
*When the consist identified in the '''Trigger Check Rule''', a Parent Rule, reaches the set trigger, the Trigger Event is activated and its Child Rules are executed.
 
*When the consist identified in the '''Trigger Check Rule''', a Parent Rule, reaches the set trigger, the Trigger Event is activated and its Child Rules are executed.
Line 79: Line 89:
 
****The '''Close Message Popup Rule''' is executed. This closes the Message window created by the '''Message Popup Rule'''. Since it is the last rule under the '''Simultaneous List Rule''' it terminates that Parent Rule. Since it is the last rule under the '''Trigger Check Rule''', it also terminates that Parent Rule.
 
****The '''Close Message Popup Rule''' is executed. This closes the Message window created by the '''Message Popup Rule'''. Since it is the last rule under the '''Simultaneous List Rule''' it terminates that Parent Rule. Since it is the last rule under the '''Trigger Check Rule''', it also terminates that Parent Rule.
 
<br>
 
<br>
 
 
='''Ordered Lists vs Simultaneous Lists'''=
 
='''Ordered Lists vs Simultaneous Lists'''=
  
Line 85: Line 94:
  
 
==Ordered Lists==
 
==Ordered Lists==
'''Rule details can be found at [[file:WikiLink.PNG]] [[Session_Rule_List_with_Parameters#Ordered_List_Rule|Ordered List Rule]]'''
+
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[Session_Rule_List_with_Parameters#Ordered_List_Rule|Ordered List Rule]]'''
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>'''Ordered Lists are shown with numbered icons on each Child Rule which indicates the order in which they will be executed.'''</td>
 
<td>'''Ordered Lists are shown with numbered icons on each Child Rule which indicates the order in which they will be executed.'''</td>
 
</tr>
 
</tr>
Line 95: Line 104:
 
<table>
 
<table>
 
<tr>
 
<tr>
<td>[[file:OrderedListRule.JPG]]</td>
+
<td>[[file:OrderedListRule.JPG|link=]]</td>
 
<td>
 
<td>
 
<table cellpadding="4" bgcolor=#eeeeee>
 
<table cellpadding="4" bgcolor=#eeeeee>
Line 103: Line 112:
 
</tr>
 
</tr>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:Gears.PNG]]</td>
+
<td>[[file:Gears.PNG|link=]]</td>
<td><font size="3">'''Settings:'''</font><br>
+
<td><span style="font-size: 17px;">'''Settings:'''</span><br>
 
An Ordered List can be set to run:-
 
An Ordered List can be set to run:-
 
*a set number of times, OR
 
*a set number of times, OR
Line 119: Line 128:
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>'''Each Child Rule in the sequence must be completed before the next Child Rule can be executed.'''</td>
 
<td>'''Each Child Rule in the sequence must be completed before the next Child Rule can be executed.'''</td>
 
</tr>
 
</tr>
Line 126: Line 135:
 
<table cellpadding="4" bgcolor=#ffffb0>
 
<table cellpadding="4" bgcolor=#ffffb0>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:NotePad.PNG]]</td>
+
<td>[[file:NotePad.PNG|link=]]</td>
<td><font size="3">'''Notes:'''</font><br>
+
<td><span style="font-size: 17px;">'''Notes:'''</span><br>
 
*Because some rules will wait for an event (such as a mouse click, timer, consist trigger, load trigger, etc) before they are completed, it is possible for the Ordered List to ''hang'' indefinitely waiting for the event.
 
*Because some rules will wait for an event (such as a mouse click, timer, consist trigger, load trigger, etc) before they are completed, it is possible for the Ordered List to ''hang'' indefinitely waiting for the event.
 
*An Ordered List is completed when the last Child Rule is completed.
 
*An Ordered List is completed when the last Child Rule is completed.
Line 135: Line 144:
  
 
==Simultaneous Lists==
 
==Simultaneous Lists==
'''Rule details can be found at [[file:WikiLink.PNG]] [[Session_Rule_List_with_Parameters#Simultaneous_List_Rule|Simultaneous List Rule]]'''
+
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[Session_Rule_List_with_Parameters#Simultaneous_List_Rule|Simultaneous List Rule]]'''
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>'''Simultaneous Lists are shown with equality ("=") icons on each Child Rule which indicates that they will be executed at the same time.'''</td>
 
<td>'''Simultaneous Lists are shown with equality ("=") icons on each Child Rule which indicates that they will be executed at the same time.'''</td>
 
</tr>
 
</tr>
Line 145: Line 154:
 
<table>
 
<table>
 
<tr>
 
<tr>
<td>[[file:SimultaneousListRule.JPG]]</td>
+
<td>[[file:SimultaneousListRule.JPG|link=]]</td>
 
<td>
 
<td>
 
<table cellpadding="4" bgcolor=#eeeeee>
 
<table cellpadding="4" bgcolor=#eeeeee>
Line 153: Line 162:
 
</tr>
 
</tr>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:Gears.PNG]]</td>
+
<td>[[file:Gears.PNG|link=]]</td>
<td><font size="3">'''Settings:'''</font><br>
+
<td><span style="font-size: 17px;">'''Settings:'''</span><br>
 
A Simultaneous List can be set to complete when:-
 
A Simultaneous List can be set to complete when:-
 
*all the Child Rules are completed, OR
 
*all the Child Rules are completed, OR
Line 167: Line 176:
 
</table>
 
</table>
 
<br>
 
<br>
 
 
='''Other Types of Lists'''=
 
='''Other Types of Lists'''=
  
 
==Progressive Lists==
 
==Progressive Lists==
'''Rule details can be found at [[file:WikiLink.PNG]] [[Session_Rule_List_with_Parameters#Progressive_List_Rule|Progressive List Rule]]'''
+
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[Session_Rule_List_with_Parameters#Progressive_List_Rule|Progressive List Rule]]'''
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>'''On the first run of a Progressive List, only the first Child Rule is executed. On the second run, the second Child Rule is executed, on the third run the third Child Rule is executed, etc.'''</td>
 
<td>'''On the first run of a Progressive List, only the first Child Rule is executed. On the second run, the second Child Rule is executed, on the third run the third Child Rule is executed, etc.'''</td>
 
</tr>
 
</tr>
Line 181: Line 189:
 
<table>
 
<table>
 
<tr>
 
<tr>
<td>[[file:ProgressiveListRules.JPG]]</td>
+
<td>[[file:ProgressiveListRules.JPG|link=]]</td>
 
<td>
 
<td>
 
<table cellpadding="4" bgcolor=#eeeeee>
 
<table cellpadding="4" bgcolor=#eeeeee>
Line 189: Line 197:
 
</tr>
 
</tr>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:Gears.PNG]]</td>
+
<td>[[file:Gears.PNG|link=]]</td>
<td><font size="3">'''Settings:'''</font><br>
+
<td><span style="font-size: 17px;">'''Settings:'''</span><br>
 
A '''Progressive List''' can be set to:-
 
A '''Progressive List''' can be set to:-
 
*repeat the sequence after the last child rule has been executed, OR
 
*repeat the sequence after the last child rule has been executed, OR
Line 205: Line 213:
  
 
==Random Lists==
 
==Random Lists==
'''Rule details can be found at [[file:WikiLink.PNG]] [[Session_Rule_List_with_Parameters#Random_List_Rule|Random List Rule]]'''
+
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[Session_Rule_List_with_Parameters#Random_List_Rule|Random List Rule]]'''
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
<td>'''A Random List will run <font color="red">ONLY ONCE</font> and will randomly select a single Child Rule to execute.'''</td>
+
<td>'''A Random List will run <span style="color: red;">ONLY ONCE</span> and will randomly select a single Child Rule to execute.'''</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
Line 215: Line 223:
 
<table>
 
<table>
 
<tr>
 
<tr>
<td>[[file:RandomListRules.JPG]]</td>
+
<td>[[file:RandomListRules.JPG|link=]]</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
  
 
==Reset Lists==
 
==Reset Lists==
'''Rule details can be found at [[file:WikiLink.PNG]] [[Session_Rule_List_with_Parameters#Reset_List_Rule|Reset List Rule]]'''
+
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[Session_Rule_List_with_Parameters#Reset_List_Rule|Reset List Rule]]'''
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<table cellpadding="4" bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:DotPoint.JPG]]</td>
+
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>'''A Reset List will execute continuously, it will never terminate. Each time through the list all the Child Rules will be reset and executed again.'''</td>
 
<td>'''A Reset List will execute continuously, it will never terminate. Each time through the list all the Child Rules will be reset and executed again.'''</td>
 
</tr>
 
</tr>
Line 230: Line 238:
 
<table>
 
<table>
 
<tr>
 
<tr>
<td>[[file:ResetListRules.JPG]]</td>
+
<td>[[file:ResetListRules.JPG|link=]]</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
Line 236: Line 244:
 
----
 
----
 
<br>
 
<br>
 
 
='''Trainz Wiki'''=
 
='''Trainz Wiki'''=
 
<table cellpadding="4" bgcolor=#ffffff>
 
<table cellpadding="4" bgcolor=#ffffff>
 
<tr valign="top">
 
<tr valign="top">
<td>[[file:TrainzWiki.png]]</td>
+
<td>[[file:TrainzWiki.png|link=]]</td>
 
<td>
 
<td>
<font size="3">'''More Tutorials and Guides to Using Trainz'''</font><br>
+
<span style="font-size: 17px;">'''More Tutorials and Guides to Using Trainz'''</span><br>
 
*'''<span class="plainlinks">[http://online.ts2009.com/mediaWiki/index.php/HowTo How to Guides]</span>'''
 
*'''<span class="plainlinks">[http://online.ts2009.com/mediaWiki/index.php/HowTo How to Guides]</span>'''
 
*'''[[Driver Commands List]]'''
 
*'''[[Driver Commands List]]'''

Revision as of 19:01, 7 September 2019

The information in this Wiki Page applies to both TANE and TRS19.

Contents


What Are Parent and Child Rules?

DotPoint.JPG Rules that act as Parent Rules can have one or more sub-rules or Child Rules under them.


Most Parent Rules are used as "decision makers" in TANE/TRS19 Sessions. They decide if or when other rules, the Child Rules, will be executed. Some Parent Rules control how those Child Rules are executed.

Parent Child.PNG Session rules can be arranged in a hierarchical fashion, in a series of levels as shown in the example on the left. A Parent Rule can be used to group together a set of rules at a lower level in the hierarchy. The rules that are grouped together under a Parent Rule are the Child Rules.

Child Rules can also be Parent Rules that group together other rules at an even lower level. This creates multiple levels in the hierarchy.

The Parent Rule at the head of each level in the hierarchy acts as a switch that directs the Trainz session to either ignore (skip over) or obey (execute) the Child Rules under its control.
NotePad.PNG Notes:
  • Only certain rules can be Parent Rules. See the Trainz Wiki page WikiLink.PNG List of Parent Rules for details.
  • Most Parent Rules will either wait for a specific event or perform a test or a comparison. They will execute the child rules when the event occurs or the test/comparison is true.
  • Any rule can be a Child Rule.


DotPoint.JPG Rules that act as Child Rules are indented under a Parent Rule.


SessionRuleIndent.JPG

Steps.PNG Steps:

To indent a rule,

  1. highlight (select) it
  2. click the Right Arrow Indent tool at the bottom of the Session Editor

SessionRuleIndented.JPG

Parent/Child Rule Example

Message Popup.jpg

In the screenshot above, the

  • Trigger Check Rule is a Parent Rule. It has rules indented below it.
    • Simultaneous List Rule is indented under the Trigger Check Rule so it is a Child of that rule. It is also a Parent Rule as it has rules indented below it
      • Message Popup Rule is indented under the Simultaneous List Rule so it is a Child of that rule.
      • Wait Rule is indented under the Simultaneous List Rule so it is a Child of that rule. It is also a Parent Rule as it has rules indented below it
        • Close Message Popup Rule is indented under the Wait Rule so it is a Child of that rule.


Sequence of Events

  • When the consist identified in the Trigger Check Rule, a Parent Rule, reaches the set trigger, the Trigger Event is activated and its Child Rules are executed.
    • The Simultaneous List Rule, a Parent Rule, is then executed. It executes all its Child Rules immediately and simultaneously.
      • The Message Popup Rule is executed. At the same time ...
      • The Wait Rule is executed. This is set to force a 20 second wait, after which its Child Rule ...
        • The Close Message Popup Rule is executed. This closes the Message window created by the Message Popup Rule. Since it is the last rule under the Simultaneous List Rule it terminates that Parent Rule. Since it is the last rule under the Trigger Check Rule, it also terminates that Parent Rule.


Ordered Lists vs Simultaneous Lists

The majority of sibling Child Rules, rules that are at the same indent level under a Parent Rule, will be executed in order (an Ordered List) or simultaneously (a Simultaneous List).

Ordered Lists

Rule details can be found at WikiLink.PNG Ordered List Rule

DotPoint.JPG Ordered Lists are shown with numbered icons on each Child Rule which indicates the order in which they will be executed.
OrderedListRule.JPG

Gears.PNG Settings:

An Ordered List can be set to run:-

  • a set number of times, OR
  • once only

DotPoint.JPG Each Child Rule in the sequence must be completed before the next Child Rule can be executed.


NotePad.PNG Notes:
  • Because some rules will wait for an event (such as a mouse click, timer, consist trigger, load trigger, etc) before they are completed, it is possible for the Ordered List to hang indefinitely waiting for the event.
  • An Ordered List is completed when the last Child Rule is completed.
  • If possible, place Child Rules that are event dependent (such as the Message Popup Rule) at the end of an ordered list.

Simultaneous Lists

Rule details can be found at WikiLink.PNG Simultaneous List Rule

DotPoint.JPG Simultaneous Lists are shown with equality ("=") icons on each Child Rule which indicates that they will be executed at the same time.
SimultaneousListRule.JPG

Gears.PNG Settings:

A Simultaneous List can be set to complete when:-

  • all the Child Rules are completed, OR
  • any one of the Child Rules has been completed


Other Types of Lists

Progressive Lists

Rule details can be found at WikiLink.PNG Progressive List Rule

DotPoint.JPG On the first run of a Progressive List, only the first Child Rule is executed. On the second run, the second Child Rule is executed, on the third run the third Child Rule is executed, etc.
ProgressiveListRules.JPG

Gears.PNG Settings:

A Progressive List can be set to:-

  • repeat the sequence after the last child rule has been executed, OR
  • terminate (no further repeats) after the last child rule has been executed


Random Lists

Rule details can be found at WikiLink.PNG Random List Rule

DotPoint.JPG A Random List will run ONLY ONCE and will randomly select a single Child Rule to execute.
RandomListRules.JPG

Reset Lists

Rule details can be found at WikiLink.PNG Reset List Rule

DotPoint.JPG A Reset List will execute continuously, it will never terminate. Each time through the list all the Child Rules will be reset and executed again.
ResetListRules.JPG



Trainz Wiki

TrainzWiki.png

More Tutorials and Guides to Using Trainz

Personal tools