How to Use Parent and Child Rules

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (Simultaneous Lists)
m
Line 13: Line 13:
 
='''What Are Parent and Child Rules?'''=
 
='''What Are Parent and Child Rules?'''=
  
<table cellpadding="4" bgcolor=#c1e7e7>
+
<table cellpadding=4 bgcolor=#c1e7e7>
 
<tr valign="top>
 
<tr valign="top>
 
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 24: Line 24:
 
</table>
 
</table>
 
<br>
 
<br>
<table cellpadding="4" bgcolor="Aquamarine">
+
<table cellpadding=4 bgcolor="Aquamarine">
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[file:LinkWiki.PNG|link=]]</td>
 
<td>[[file:LinkWiki.PNG|link=]]</td>
Line 45: Line 45:
 
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.<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.<br>
  
<table bgcolor="black" cellpadding=2>
+
<table bgcolor=#000000 cellpadding=2>
 
<tr valign="top">
 
<tr valign="top">
 
<td>
 
<td>
Line 65: Line 65:
 
</tr>
 
</tr>
 
</table>
 
</table>
 +
 
<br>
 
<br>
<table cellpadding="4" bgcolor=#c1e7e7>
+
<table cellpadding=4 bgcolor=#c1e7e7>
 
<tr valign="top>
 
<tr valign="top>
 
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 77: Line 78:
 
<td valign="top">[[file:SessionRuleIndent.JPG|480px]]</td>
 
<td valign="top">[[file:SessionRuleIndent.JPG|480px]]</td>
 
<td valign="top">
 
<td valign="top">
<table cellpadding="4" bgcolor=#ffffff>
+
<table cellpadding=4 bgcolor=#ffffff>
 
<tr>
 
<tr>
 
<td colspan="2">
 
<td colspan="2">
Line 139: Line 140:
 
==Ordered Lists==
 
==Ordered Lists==
 
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[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|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 150: Line 151:
 
<td>[[file:OrderedListRule.JPG|link=]]</td>
 
<td>[[file:OrderedListRule.JPG|link=]]</td>
 
<td>
 
<td>
<table cellpadding="4" bgcolor=#eeeeee>
+
<table cellpadding=4 bgcolor=#eeeeee>
 
<tr>
 
<tr>
 
<td colspan="2">
 
<td colspan="2">
Line 170: Line 171:
 
</table>
 
</table>
  
<table cellpadding="4" bgcolor=#c1e7e7>
+
<table cellpadding=4 bgcolor=#c1e7e7>
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[file:DotPoint.JPG|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 177: Line 178:
 
</table>
 
</table>
 
<br>
 
<br>
<table cellpadding="4" bgcolor=#ffffb0>
+
<table bgcolor=#000000 width=900>
 +
<tr valign="top">
 +
<td>
 +
<table bgcolor=#ffffb0>
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[file:NotePad.PNG|link=]]</td>
 
<td>[[file:NotePad.PNG|link=]]</td>
Line 184: Line 188:
 
*An '''Ordered List''' is completed when the '''last''' Child Rule is completed.
 
*An '''Ordered List''' is completed when the '''last''' Child Rule is completed.
 
*Because some rules will wait for an event (such as a mouse click, a set time or a time period, a consist trigger, a load trigger, etc) before they are completed, it is possible for the Ordered List to ''hang'' indefinitely waiting for the event to occur so that a rule can be completed and any following rules can then be executed.
 
*Because some rules will wait for an event (such as a mouse click, a set time or a time period, a consist trigger, a load trigger, etc) before they are completed, it is possible for the Ordered List to ''hang'' indefinitely waiting for the event to occur so that a rule can be completed and any following rules can then be executed.
*If possible, place Child Rules that are event dependent at the end of an ordered list.</td>
+
*If possible, place Child Rules that are event dependent at the end of an ordered list.
 +
</td>
 +
</tr>
 +
</table>
 +
</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
Line 190: Line 198:
 
==Simultaneous Lists==
 
==Simultaneous Lists==
 
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[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|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 218: Line 226:
 
</tr>
 
</tr>
 
</table>
 
</table>
<table bgcolor="black" width=360>
+
<table bgcolor=#000000 width=360>
 
<tr valign="top">
 
<tr valign="top">
 
<td>
 
<td>
Line 252: Line 260:
 
==Progressive Lists==
 
==Progressive Lists==
 
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[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|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 263: Line 271:
 
<td>[[file:ProgressiveListRules.JPG|link=]]</td>
 
<td>[[file:ProgressiveListRules.JPG|link=]]</td>
 
<td>
 
<td>
<table cellpadding="4" bgcolor=#eeeeee>
+
<table cellpadding=4 bgcolor=#eeeeee>
 
<tr>
 
<tr>
 
<td colspan="2">
 
<td colspan="2">
Line 286: Line 294:
 
==Random Lists==
 
==Random Lists==
 
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[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|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 301: Line 309:
 
==Reset Lists==
 
==Reset Lists==
 
'''Rule details can be found at [[file:WikiLink.PNG|link=]] [[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|link=]]</td>
 
<td>[[file:DotPoint.JPG|link=]]</td>
Line 325: Line 333:
 
='''Related Links'''=
 
='''Related Links'''=
  
<table cellpadding="4" bgcolor=#ffffff>
+
<table cellpadding=4 bgcolor=#ffffff>
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[file:LinkWiki.PNG|link=]]</td>
 
<td>[[file:LinkWiki.PNG|link=]]</td>
Line 345: Line 353:
  
 
='''Trainz Wiki'''=
 
='''Trainz Wiki'''=
<table cellpadding="4" bgcolor=#ffffff>
+
<table cellpadding=4 bgcolor=#ffffff>
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[file:TrainzWiki.png|link=]]</td>
 
<td>[[file:TrainzWiki.png|link=]]</td>

Revision as of 07:26, 8 March 2022

The information in this Wiki Page applies to TANE, TRS19 and Trainz Plus.

Contents

  Top   Next Down Bottom

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
DotPoint.JPG Rules are edited and managed by the Session Editor in Surveyor


LinkWiki.PNG

More information on the Session Editor can be found on the Trainz Wiki Page at:-


Most Parent Rules are used as "decision makers" in Trainz 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 the Close Message Popup Rule is the last child rule under the Wait Rule, when it has completed its task (closing the message popup) it will terminate that Parent Rule.
          • Since it is also the last child rule under the Simultaneous List Rule it will terminate that Parent Rule.
          • Finally, since it is the last child rule under the Trigger Check Rule, it also terminates that Parent Rule.
  Top Next Up Next Down Bottom

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:

  • An Ordered List is completed when the last Child Rule is completed.
  • Because some rules will wait for an event (such as a mouse click, a set time or a time period, a consist trigger, a load trigger, etc) before they are completed, it is possible for the Ordered List to hang indefinitely waiting for the event to occur so that a rule can be completed and any following rules can then be executed.
  • If possible, place Child Rules that are event dependent 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

NotePad.PNG Notes:

While all child rules in a Simultaneous List will start at the same time, some will take longer to complete than others.


  Top Next Up Next Down Bottom

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
  Top Next Up    

Related Links

LinkWiki.PNG
 


Trainz Wiki

TrainzWiki.png

More Tutorials and Guides to Using Trainz


This page was created by Trainz user pware in May 2018 and was last updated as shown below.


Personal tools