How to Use Parent and Child Rules

From TrainzOnline
Revision as of 21:46, 17 May 2018 by Pware (Talk | contribs)

Jump to: navigation, search

Parent and Child Rules

1. Parent Rules:

  • Rules that act as Parent Rules can have one or more sub-rules or Child Rules under them.
  • Only certain rules can be Parent Rules.

2. Child Rules:

  • Rules that act as Child Rules are indented under a Parent Rule.
  • Several levels of indent are allowed.
  • Any rule can be a Child Rule.
  • Child Rules are only executed if the Parent Rule returns a True result from the condition or test it is examining.

3. 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 Rule is indented under the Wait Rule so it is a Child of that rule.

You can think of this as a family tree.

Trigger Check Rule
  • Parent of Simultaneous List Rule
  • Grand Parent of Message Popup Rule
  • Grand Parent of Wait Rule
  • Great Grand Parent of Close Message Rule
Simultaneous Check Rule
  • Child of Trigger Check Rule
  • Parent of Message Popup Rule
  • Parent of Wait Rule
  • Grand parent of Close Message Rule
Message Popup Rule
  • Child of Simultaneous List Rule
  • Sibling of Wait Rule
  • Grand Child of Trigger Check Rule
Wait Rule
  • Child of Simultaneous List Rule
  • Sibling of Message Popup Rule
  • Parent of Close Message Rule
  • Grand Child of Trigger Check Rule
Close Message Rule
  • Child of Wait Rule
  • Grand Child of Simultaneous Rule
  • Great Grand Child of Trigger Check Rule

4. The sequence of events:

  • When the consist identified in the Trigger Check Rule reaches the set trigger, then the Trigger Event is activated and its child rules are executed.
    • The Simultaneous List Rule (which has no conditional test) is then executed. It executes all its child rules simultaneously.
      • The Message Popup Rule is executed. This waits until its message window is closed. At the same time ...
      • The Wait Rule is executed. This is set to force a 20 second wait, after which ...
        • The Close Message Rule is executed. This closes the Message window created by the Message Popup Rule and terminates the Simultaneous List Rule and the Trigger Check 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).

1. Ordered Lists:

NavClearSets.JPG
  • Ordered Lists are shown with numbered icons on each Child Rule which indicates the order in which they will be executed.
  • Each Child Rule in the sequence must be completed before the next Child Rule can be executed. 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 at the end of an ordered list.

2. Simultaneous Lists:

NavSetsChoose.JPG
  • Simultaneous Lists are shown with equality ("=") icons on each Child Rule which indicates that they will be executed at the same time.
  • 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

1. Progressive Lists:

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 second third Child Rule is executed, etc.

2. Random Lists:

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

3. Reset Lists:

A Reset List will execute continuously, it will never terminate. Each time through the list all the Child Rules will be reset.

Personal tools