PART 3
5 Implementation Principles5.1 GeneralRule 1: The main idea is to use “actions”, with the trigger of each action containing condition(s) or not.
5.2 Action definitionThe 1st step is to define 3 actions (
action definition in Rocrail vocabulary):
- acAsEntStaRed, which sets to red asEntSta
- acAsEntStaYellow, which sets to yellow asEntSta
- acAsEntStaGreen, which sets to green asEntSta
5.3 Action controlNow, let's identify the object(s) which will trigger these actions (
action control in Rocrail vocabulary). The obvious idea, if we apply the rule “an advanced signal reflects the color of the main signal ahead” is to select the main signal associated to the
next block
chosen.
Does this idea apply to all actions ? True for
acAsEntStaYellow and
acAsEntStaGreen, but not so obvious for
acAsEntStaRed.
Why not for
acAsEntStaRed ? If you look at Fig 5, you see that
sUp1 = red (which would trigger
acAsEntStaRed) only occurs at step 4, which may be extremely late depending on the track length to run through. Remember that as soon as step 3 is reached, block
bEntSta may hold a new train ready to start to an other destination. As a result,
sEntSta may switch to a non-red value, and display an
inaccurate value on
asEntSta.
If you remember
constraint1, as soon as
sEntSta becomes red, any value of
asEntSta is not shown. So the new idea coming is to select
sEntSta (when red) to be the object triggering
acAsEntStaRed. In other words, as soon as
sEntSta becomes red,
asEntSta is reset to red (but invisible).
Rule 2:
acAsEntStaYellow and
acAsEntStaGreen are triggered by the main signal associated to the
next block
chosen by the automatic mode, when this main signal is
resp. yellow or green.
Rule 3:
acAsEntStaRed is triggered by
sEntSta, when
sEntSta is red.
5.4 Action conditionsAre conditions needed ? Oh yes ! Many experiments have shown that without conditions, it will fail in most cases with significant traffic.
For
acAsEntStaYellow and
acAsEntStaGreen, the idea is to select the most restrictive condition(s) that reflect the setting of a path: The one I've found is the state “
locked” of the
route involved.
Rule 4: The
route, leading to the block associated to the signal triggering the action
acAsEntStaYellow or
acAsEntStaGreen, must have the state
locked.
Now, what about conditions on the object triggering
acAsEntStaRed ? Here, things become complicated...
Once again, many experiments have led to the conclusion that conditions on route, block or signal don't fit. Are we stuck ?
Fortunately, no. The main idea now is to explore the creation of a new “state” which reflects the goal stated at the beginning, i.e. “establish a link between
asEntSta and
a forward main signal”.
With this new state, let's call it
linkAsEntSta, we can easily define additional conditions which can be evaluated when necessary.
This state is a simple state with two values, either “true” or “false”.
When the value of this state is set ? If
sEntSta is green or yellow, the state is “true”. If
sEntSta is red, the state is “false”.
Do we need a different state for each 5 possible destinations available at
bEntSta ? No, because successive trains passing through block
bEntSta is done one after each other, and only after
sEntSta has been reset to red. One state does the job.
How to implement the state
linkAsEntSta and use it in action conditions ? By using a special class of objects, called Variables. See
http://wiki.rocrail.net/doku.php?id=variable-enSo, by defining a Variable object
linkAsEntSta, 2 new actions setting either this variable to “true” or “false”, then later evaluating the value of this variable in the various action conditions, we have all the necessary “equipment” !
The
Rule 4 is now supplemented by a new rule:
Rule 4.2: …
AND linkAsEntSta must have the state “true”
There is no action condition to add on object
sEntSta triggering
acAsEntStaRed, but new action definition and control must be done to manage the object
linkAsEntSta implemented with a variable.
5.5 Action definition for variable linkAsEntStaVariables can't hold boolean values as “true” or “false”. A numeric value of 1 is used for “true” and 0 for “false”.
2 new actions are defined:
- acSetLinkAsEntSta, which sets the value of the variable linkAsEntSta to 1
- acResetLinkAsEntSta, which sets the value of the variable linkAsEntSta to 0
5.6 Action control for action definitions on variable linkAsEntStaThe object by which these 2 actions are triggered is
sEntSta:
- Rule 5: acSetLinkAsEntSta is triggered unconditionally by state yellow or green of this signal
- Rule 6: acResetLinkAsEntSta is triggered unconditionally by the state red of this signal
That's it

! (but it's enough

).
END OF PART 3
PART 4:
6 - Variable definition, 7 - Action definition, 8 - Action control & condition (mainly screenshots)
Edited by user 29 May 2015 20:52:51(UTC)
| Reason: Not specified