How to Use Parent and Child Rules

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m
m (Parent/Child Rule Example)
 
(5 intermediate revisions by one user not shown)
Line 125: Line 125:
 
<tr valign="top">
 
<tr valign="top">
 
<td width=25>[[image:DotPoint1.JPG|link=]]</td>
 
<td width=25>[[image:DotPoint1.JPG|link=]]</td>
<td>select (<span style="font-weight: 700; font-size: 15px; background-color: lightcyan;">Right Click</span>) the rule to be indented</td>
+
<td>select (<span style="font-weight: 700; font-size: 15px; background-color: lightcyan;">Left Click</span>) the rule to be indented</td>
 
</tr>
 
</tr>
 
<tr valign="top">
 
<tr valign="top">
Line 139: Line 139:
 
</table>
 
</table>
 
==Parent/Child Rule Example==
 
==Parent/Child Rule Example==
<table>
+
In the following example, a '''Trigger Check Rule''' is acting as the ''switch'' that decides whether or not its child rules will be executed. If the Trigger is activated, for example by a particular train passing over its track trigger, then its child rules will be executed. Otherwise the '''Trigger Check Rule''' will wait indefinitely until that event occurs, or the session is terminated.
<tr>
+
<td>[[image:Message_Popup.jpg|link=]]</td>
+
</tr>
+
</table>
+
  
 
<table width=1000>
 
<table width=1000>
 
<tr valign="top">
 
<tr valign="top">
<td>In the screenshot above, the
+
<td width=600>[[image:Message_Popup.jpg|600px|link=]]</td>
<table>
+
<td>
 +
<table bgcolor=#000000 cellpadding=2>
 
<tr valign="top">
 
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
+
<td>
<td>'''Trigger Check Rule''' is a Parent Rule. It has rules indented below it
+
<table bgcolor=#ffffff cellpadding=2>
<table>
+
 
<tr valign="top">
 
<tr valign="top">
 
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
 
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''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
+
<td>the cause of the trigger event is set in the properties of the '''Trigger Check Rule''' </td>
<table>
+
<tr valign="top">
+
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
+
<td>'''Message Popup Rule''' is indented under the '''Simultaneous List Rule''' so it is a Child of that rule</td>
+
 
</tr>
 
</tr>
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[image:DotPoint.JPG|10px|link=]]</td>
 
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''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
+
<td>the message shown is set in the properties of the '''Message Popup Rule''' </td>
<table>
+
</tr>
 
<tr valign="top">
 
<tr valign="top">
 
<td>[[image:DotPoint.JPG|10px|link=]]</td>
 
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''Close Message Popup Rule''' is indented under the '''Wait Rule''' so it is a Child of that rule</td>
+
<td>the duration of the wait is set in the properties of the '''Wait Rule''' </td>
 
</tr>
 
</tr>
 
</table>
 
</table>
Line 176: Line 168:
 
</tr>
 
</tr>
 
</table>
 
</table>
</td>
+
 
 +
<table width=1000>
 +
<tr valign="top">
 +
<td>In the screenshot above, the
 +
<table>
 +
<tr valign="top">
 +
<td>'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;1&#160;</span>''': Trigger Check Rule''' is a Parent Rule. It has rules indented below it which are its Child Rules:-</td>
 +
</tr>
 +
<tr valign="top">
 +
<td>
 +
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;2&#160;</span>''': Simultaneous List Rule''' is indented under the '''Trigger Check Rule''' so it is a Child of that rule. It is also a Parent Rule and it has its own Child Rules indented below it:-</td>
 +
</tr>
 +
<tr valign="top">
 +
<td>
 +
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;3&#160;</span>''': Message Popup Rule''' is indented under the '''Simultaneous List Rule''' so it is a Child of that rule</td>
 +
</tr>
 +
<tr valign="top">
 +
<td>
 +
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;4&#160;</span>''': 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</td>
 +
</tr>
 +
<tr valign="top">
 +
<td>
 +
:::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;5&#160;</span>''': Close Message Popup Rule''' is indented under the '''Wait Rule''' so it is a Child of that rule</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
Line 756: Line 770:
 
</tr>
 
</tr>
 
</table> <!-- END Nav Buttons Table -->
 
</table> <!-- END Nav Buttons Table -->
='''Related Links'''=
+
<br>
 
+
<table cellpadding=4 bgcolor=#ffffff>
+
<tr valign="top">
+
<td>[[image:LinkWiki.PNG|link=]]</td>
+
<td>
+
*'''[[How to Use Message Popup Rule|Using Message Popups]]'''
+
*'''[[How to Use Navigation Point Rules|Using Navigation Points]]'''
+
*'''[[How to Use Session Editor|Using the Session Editor]]'''
+
</td>
+
</tr>
+
</table>
+
 
+
 
<table> <!-- BEGIN Nav Buttons Table -->
 
<table> <!-- BEGIN Nav Buttons Table -->
 
<tr valign="top">
 
<tr valign="top">
Line 776: Line 778:
 
----
 
----
 
----
 
----
 
 
='''Trainz Wiki'''=
 
='''Trainz Wiki'''=
<table cellpadding=4 bgcolor=#ffffff>
+
<table width=1000>
 
<tr valign="top">
 
<tr valign="top">
<td>[[image:TrainzWiki.png|link=]]</td>
+
<td>
 +
<table width=500 cellpadding=2 bgcolor=#ffffff>
 +
<tr valign="top">
 +
<td width=80>[[image:TrainzWiki.png|link=]]</td>
 
<td>
 
<td>
 
<span style="font-size: 17px;">'''More Tutorials and Guides to Using Trainz'''</span><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="plain;s">[http://online.ts2009.com/mediaWiki/index.php/HowTo How to Guides]</span>'''
 
*'''[[Driver Commands List]]'''
 
*'''[[Driver Commands List]]'''
 
*'''[[Session Rule List with Parameters|Session Rules List (Alphabetical) with Parameters]]'''
 
*'''[[Session Rule List with Parameters|Session Rules List (Alphabetical) with Parameters]]'''
 
*'''[[Session Rules By Categories With Properties|Session Rules List (Categories) With Parameters]]'''
 
*'''[[Session Rules By Categories With Properties|Session Rules List (Categories) With Parameters]]'''
 +
</td>
 +
</tr>
 +
</table>
 +
</td>
 +
<td>
 +
<table width=500 cellpadding=4 bgcolor="aquamarine">
 +
<tr valign="top">
 +
<td width=50>[[image:LinkWiki.PNG|link=]]</td>
 +
<td>
 +
<span style="font-size: 17px;">'''Related Links'''</span><br>
 +
*'''[[How to Use Message Popup Rule|How to Use the Message Popup Rule]]'''
 +
*'''[[How to Use Navigation Point Rules|How to Use Navigation Point Rules]]'''
 +
*'''[[How to Use Session Editor|How to Use the Session Editor]]'''
 +
*'''[[Parent and Child Rules|Parent and Child Rules]]'''
 +
</td>
 +
</tr>
 +
</table>
 
</td>
 
</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
 
----
 
----
This page was created by Trainz user '''<span class="plainlinks">[http://online.ts2009.com/mediaWiki/index.php/User:Pware pware]</span>''' in May 2018 and was last updated as shown below.
+
This page was created by Trainz user '''<span class="plain;s">[http://online.ts2009.com/mediaWiki/index.php/User:Pware pware]</span>''' in May 2018 and was last updated as shown below.
 
----
 
----
 
[[Category:How-to guides]][[Category:Rules]]
 
[[Category:How-to guides]][[Category:Rules]]

Latest revision as of 09:35, 1 August 2024

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

Contents

BlueDot10x10.png Session Rules are the "programming tools" for constructing interactive sessions
BlueDot10x10.png Parent Rules are the decision makers amongst the Session Rules
  Top   Next Down Bottom

[edit] What Are Parent and Child Rules?

BlueDot10x10.png Rules that act as Parent Rules can have one or more sub-rules or Child Rules under them
BlueDot10x10.png 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.
NotePad.PNG Notes:
DotPoint.JPG Only certain rules can be Parent Rules. See the Trainz Wiki page WikiLink.PNG List of Parent Rules for details
DotPoint.JPG Most Parent Rules will either wait for a specific event or perform a test or a comparison. They will execute their Child Rules when the event occurs or the test/comparison is true
DotPoint.JPG Any rule can be a Child Rule including other Parent Rules


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.


BlueDot10x10.png Rules that act as Child Rules are indented under a Parent Rule


SessionRuleIndent.JPG
Steps: To indent a rule:-
DotPoint1.JPG select (Left Click) the rule to be indented
DotPoint2.JPG Left Click the Right Arrow Indent tool at the bottom of the Session Editor
SessionRuleIndented.JPG

[edit] Parent/Child Rule Example

In the following example, a Trigger Check Rule is acting as the switch that decides whether or not its child rules will be executed. If the Trigger is activated, for example by a particular train passing over its track trigger, then its child rules will be executed. Otherwise the Trigger Check Rule will wait indefinitely until that event occurs, or the session is terminated.

Message Popup.jpg
DotPoint.JPG the cause of the trigger event is set in the properties of the Trigger Check Rule
DotPoint.JPG the message shown is set in the properties of the Message Popup Rule
DotPoint.JPG the duration of the wait is set in the properties of the Wait Rule
In the screenshot above, the
Line  1 : Trigger Check Rule is a Parent Rule. It has rules indented below it which are its Child Rules:-
Line  2 : Simultaneous List Rule is indented under the Trigger Check Rule so it is a Child of that rule. It is also a Parent Rule and it has its own Child Rules indented below it:-
Line  3 : Message Popup Rule is indented under the Simultaneous List Rule so it is a Child of that rule
Line  4 : 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
Line  5 : Close Message Popup Rule is indented under the Wait Rule so it is a Child of that rule


Sequence of Events
DotPoint1.JPG 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
DotPoint2.JPG The Simultaneous List Rule, a Parent Rule, is then executed. It executes all its Child Rules immediately and simultaneously
Simultaneously...
DotPoint3.JPG The Message Popup Rule is executed
DotPoint3.JPG The Wait Rule is executed. This is set to force a 20 second wait, then ...
DotPoint4.JPG The Close Message Popup Rule is executed. This closes the Message window created by the Message Popup Rule
DotPoint5.JPG 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 the Wait Parent Rule
DotPoint6.JPG Since it is also the last child rule under the Simultaneous List Rule it will terminate that Parent Rule
DotPoint7.JPG 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

[edit] 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).

[edit] Ordered Lists

BlueDot10x10.png Details for this rule can be found at WikiLink.PNG Ordered List Rule
BlueDot10x10.png Ordered Lists are shown with numbered icons on each Child Rule which indicates the order in which they will be executed


OrderedListRule.JPG
NotePad.PNG Notes:

DotPoint.JPG an Ordered List can be set to repeat a set number of times
DotPoint.JPG each Child Rule in the sequence must be completed before the next Child Rule can be executed
DotPoint.JPG an Ordered List is completed when the last Child Rule is completed


PencilTips.PNG Because some rules will wait for an event (such as a mouse click, a set time or a time period, a trigger, etc) before they are completed, it is possible for the Ordered List to hang indefinitely waiting for the event to occur. This will stop that particular Child Rule from being completed and any following Child Rules from being started. So, if possible, place Child Rules that are event dependent at the end of an ordered list.


 Setting the Options 

The rule settings allow you to control how many times an Ordered List will run.

Steps: To set the repeat options for an Ordered List:-
DotPoint1.JPG select (Left Click on) the Ordered List in the Session Editor
DotPoint2.JPG select (Left Click on) the  Edit  button at the bottom of the Session Editor to open the Ordered List properties window
DotPoint3.JPG Select an Option Button:-
BlueDot10x10.png This process will repeat 1 time(s)
BlueDot10x10.png This process will repeat forever
DotPoint4.JPG to change the number of repeats to any required number Left Click on the 1 and enter a new value. Click the Link= to accept the change
DotPoint5.JPG to accept the new rule settings Left Click on the Link= or the  Save Changes  button (depending on your version of Trainz) in the rule properties window
RuleRepeatsSetting.png

RuleRepeatsEntry.png


NotePad.PNG Notes:

DotPoint.JPG the minimum number is 1 which means that the Ordered List will execute once only
DotPoint.JPG the "repeat forever" option will force the list to restart again endlessly


[edit] Simultaneous Lists

BlueDot10x10.png Details for this rule can be found at WikiLink.PNG Simultaneous List Rule
BlueDot10x10.png Simultaneous Lists are shown with equality (=) icons on each Child Rule which indicates that they will all be executed at the same time


SimultaneousListRule.JPG
NotePad.PNG Notes:

DotPoint.JPG a Simultaneous List can be set to complete when all the Child Rules have been completed, or when any one of the Child Rules has been completed
DotPoint.JPG while all Child Rules in a Simultaneous List will start at the same time, some will take longer to complete than others and some may wait for a particular event before they can complete


 Setting the Options 

The rule settings allow you to control how a Simultaneous List will be terminated.

Steps: To set the "completion" options for a Simultaneous List:-
DotPoint1.JPG select (Left Click on) the Simultaneous List in the Session Editor
DotPoint2.JPG select (Left Click on) the  Edit  button at the bottom of the Session Editor to open the Simultaneous List properties window
Depending on your version of Trainz 2 or 3 options are presented by cycling ("clicking") through the underlined text.
DotPoint3.JPG Select an option:-
BlueDot10x10.png all child rules have reached a completed state
BlueDot10x10.png all child rules have reached a 'was completed' state
BlueDot10x10.png one of the child rules has completed
DotPoint4.JPG to accept the new rule settings Left Click on the Link= or the  Save Changes  button (depending on your version of Trainz) in the rule properties window
RuleAllCompletedSetting.png

RuleWasCompletedSetting.png

RuleOneCompletedSetting.png


NotePad.PNG Notes:

DotPoint.JPG the first option, "all child rules have reached a completed state", means that the Simultaneous List will wait until ALL child rules have been completed before terminating. Some child rules may wait for an event, such as a trigger or a set time, before they terminate
DotPoint.JPG the second option, "all child rules have reached a 'was completed' state", is needed for the UDS feature in TRS19 Platinium and later versions that allows you to switch between Driver and Surveyor. If you make the switch back to Driver when some rules have been completed but others have not, then the completed child rules will not be restarted and the Simultaneous Rule will wait until all the child rules reach the was completed state before it terminates
DotPoint.JPG the third option, "one of the child rules has completed" will terminate the Simultaneous Rule, and any child rules that have not yet completed, as soon as one child rule completes


  Top Next Up Next Down Bottom

[edit] Other Types of Lists

[edit] Progressive Lists

BlueDot10x10.png Details for this rule can be found at WikiLink.PNG Progressive List Rule
BlueDot10x10.png Progressive Lists are shown with numbered icons on each Child Rule which indicates the progressive order in which they will be executed on each cycle of the list


ProgressiveListRules.JPG
NotePad.PNG Notes:

DotPoint.JPG a Progressive List executes only a single child rule each time it runs
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. Until all the child rules have been executed


 Setting the Options 

The rule settings allow you to control what happens after the last child rule in a Progressive List has been completed.

Steps: To set the "completion" options for a Progressive List:-
DotPoint1.JPG select (Left Click on) the Progressive List in the Session Editor
DotPoint2.JPG select (Left Click on) the  Edit  button at the bottom of the Session Editor to open the Progressive List properties window
You can select from 3 options by cycling ("clicking") through the underlined text.
DotPoint3.JPG Select an option:-
BlueDot10x10.png ... successive runs will do nothing - after the last child rule has been completed the Progressive Rule will terminate
BlueDot10x10.png ... last child .... will be used for all successive runs - after the last child rule has been completed the Progressive Rule will repeat that child rule on all further runs
BlueDot10x10.png ... the first child is chosen again - after the last child rule has been completed the Progressive Rule will start with the first child rule again and it will repeat the sequence
DotPoint4.JPG to accept the new rule settings Left Click on the Link= or the  Save Changes  button (depending on your version of Trainz) in the rule properties window
RuleProgressiveNoneSetting.png

RuleProgressiveLastSetting.png

RuleProgressiveNoneSetting.png


[edit] Random Lists

BlueDot10x10.png Details for this rule can be found at WikiLink.PNG Random List Rule
BlueDot10x10.png Random Lists are shown with "dot" icons on each Child Rule which indicates that ONE of them will be selected at random


RandomListRules.JPG
NotePad.PNG Notes:

DotPoint.JPG a Random List will run ONCE ONLY
DotPoint.JPG a child rule will be selected at random and once that child rule has been completed, the Random List will terminate
DotPoint.JPG there are no control options for a Random List


[edit] Reset Lists

BlueDot10x10.png Details for this rule can be found at WikiLink.PNG Reset List Rule
BlueDot10x10.png Reset Lists are shown with equality (=) icons on each Child Rule which indicates that they will all be executed at the same time


ResetListRules.JPG
NotePad.PNG Notes:

DotPoint.JPG a Reset List will never terminate. It will run continuously
DotPoint.JPG after the last child rule has been completed, all the child rules will be reset and executed again
DotPoint.JPG there are no control options for a Reset List


  Top Next Up    


 


[edit] Trainz Wiki

TrainzWiki.png

More Tutorials and Guides to Using Trainz

LinkWiki.PNG

Related Links


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


Personal tools