User Tools

Site Tools


usage:interlocking:ars

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
usage:interlocking:ars [2023-12-12 03:59]
blockhead fix title
usage:interlocking:ars [2025-05-06 22:18] (current)
orwell update ars instructions for 2.6.0
Line 29: Line 29:
 </code> </code>
  
-You will notice that the "E" line disappears if you exit and return to the same formspecThis is a potential source of confusion - if you haven't gotten the syntax right, the lines will just disappear without feedback about your error.+Invalid lines, which cannot be parsed as ARS rules, will be automatically converted to comments with a question mark prepended. For example, the E above will become "# ? E"When this happens, you made a syntax error.
  
-There is also ! operator for negation of the rule, applicable only the LN and RC rules (there's no ''!*'' rule). If you start a line with a !, it only matches trains that do NOT have that LN or RC. Here's the rules for a passenger stop that doesn't allow trains with RC Freight and also doesn't allow line 2 trains to stop.+There is also ! operator for negation of the rule, applicable only the LN and RC rules (there's no ''!*'' rule). If you start a line with a !, it only matches trains that do NOT have that LN or RC. Here's the rules for a passenger stop that doesn't allow trains with RC FREIGHT.
 <code> <code>
 !RC FREIGHT !RC FREIGHT
-#2 Runs express 
-!LN 2 
 </code> </code>
  
Line 44: Line 42:
  
 *but station codes on the Station/Stop track need to be; thankfully there is an owner system for those that was introduced to stop people just putting anything in that overlaps and overwriting other peoples' station names unless you have ''train_admin'' (I digress, that's a topic for another wiki edit or forum post). *but station codes on the Station/Stop track need to be; thankfully there is an owner system for those that was introduced to stop people just putting anything in that overlaps and overwriting other peoples' station names unless you have ''train_admin'' (I digress, that's a topic for another wiki edit or forum post).
 +
 +===== Multi ARS / Load Balancing =====
 +
 +This feature has been newly introduced in 2.6.0.
 +
 +ARS rules can now include a priority number. Specifying a priority for a rule enables the Multi-ARS mode. If the ARS rules of multiple routes match a given train (and all of these rules have a priority set), then all the matching routes will be requested simultaneously, and the first one that can be set without conflicts is being set.
 +
 +Example:
 +<code>
 +Route 1 has rule:
 +  2 RC abc
 +Route 2 has rule:
 +  1 RC abc
 +</code>
 +The number (here 1 or 2) in the beginning is the priority, it can be any positive whole number. A train with routingcode abc will match both of these routes.
 +
 +The signal will now attempt to set Route 2, and if unsuccessful Route 1. Route 2 is tried first because its priority number is smaller (it's like a ranking - 1st, 2nd, 3rd etc). If none of the routes can be set, the signal waits until any of them becomes available (just like in the single-route case) and set it.
 +
 +Multi-ARS also works with the default route:
 +<code>
 +Route 1 has rule:
 +  RC def
 +Route 2 has rule:
 +  1 *
 +Route 3 has rule:
 +  2 *
 +</code>
 +
 +Trains with routingcode def will go to Route 1. Any other train will go to either Route 2 or Route 3, whichever is available first.
 +
 +Priorities are useless for station/stop rails and have no effect there.
 +
 +===== Logical And =====
 +
 +ARS rules normally are or-combined, that is, any of the rules need to match the train. However sometimes two or more conditions need to be fulfilled.
 +
 +Consider this example for a stop rail:
 +  * only passenger trains should stop (freight trains have RC FREIGHT)
 +  * Line 2 trains should not stop, because they are an express service
 +
 +Below rules are wrong:
 +<code>
 +!RC FREIGHT
 +!LN 2
 +</code>
 +This is because a line 2 train, although it doesn't match the "!LN 2" rule, nevertheless is not a freight train so it matches the !RC FREIGHT rule and stops anyway. The other way round, freight trains will also stop because they are not of line 2.
 +
 +The correct rules are:
 +<code>
 +!RC FREIGHT
 +& !LN 2
 +</code>
 +The & symbol on the second line indicates that both conditions need to be fulfilled for the rule to match. Now only trains that are not freight trains AND are not of line 2 will stop.
 +
 +Regarding the syntax, note that the & !LN 2 part must be on a new line. Also, there cannot be comments between a rule and its attached & clauses. This is a limitation of the ARS rule parser.
 +
 +Conditions can also be attached to the default route this way, although this is probably only needed in special situations and should be avoided:
 +<code>
 +*
 +& !LN 2
 +</code>
 +A route marked like this will be used for any train that doesn't match explicit rules, EXCEPT if its line is 2.
 +
 +===== Precedence in route selection =====
 +
 +Rules are considered in this order:
 +  * Explicit rules: a rule of the form LN x, RC x, !LN x or !RC x (and its following & clauses) matches the train
 +  - The first matching route, if any rule has no priority
 +  - All matching routes (Multi-ARS), if all matching rules have a priority (in order of that priority)
 +  * Default routes: if none of the explicit rules matched, the routes set as default routes (*) (except if the following & clauses did not match the train)
 +  - The (only) default route, if there is a default route without priority
 +  - All default routes, if multiple exist and all of them have priority set
 +
 +Rules without priority always take precendence over rules with priority. For simplicity, avoid mixing rules with and without priority.
 +
usage/interlocking/ars.txt · Last modified: 2025-05-06 22:18 by orwell