Table of Contents

Implementation: new-ks branch

Please refer to the source code for implementation details and API documentation. This information is provided here. The filenames provided below are relative to /advtrains_interlocking.

The changes break a few minor things:

It is planned to merge the newly introduced signal aspect cache with its counterpart in the routesetting system.

Please refer to the source code (listed above) for details.

Proposal: Distant signaling (second draft)

This draft has been superseded. Please refer to the actual implementation (mentioned above).

This draft is mainly written to address the issues that appeared in the first draft. In particular, it addresses a request to implement route signaling.

Distant signal assignment

Manual signal assignment

Distant signals may be assigned to any signal. These distant signals are automatically set with the signals they are assigned to.

Automatic signal assignment

With automatic distant signal assignment, the user needs to assign distant signals to TCBs. A TCB may have multiple distant signals assigned to it. For combined main/distant signals, however, the main and distant aspects may not be assigned separately.

These distant signals are then assigned to main signals when needed and unassigned when the aspect of the distant signal become irrelevant to rail operation. Specifically:

Setting distant signals

API Changes

The functions are given as indices of the advtrains.interlocking table.

Signal aspect table

Distant signal assignment

Setting signal aspect

Alternative signal aspect table

The alternative signal aspect table is mainly intended for route signaling.

Supported aspects

The table of supported aspects should include the following fields:

When registering, the signal should provide the following fields:

Each main aspect entry should contain the following fields:

The last entry in the list of supported aspects should have the main field set to 0 (i.e. stop). The nth entry in the list (which is not the first or last entry) indicates that the next signal has the same aspect defined by the n+1th entry in the list. The first entry in the list indicates that the next signal has the same aspect of the first or the second entry in the list.

Signal aspect translation

Proposal: Distant signaling (first draft)

This draft has been superseded.

In this proposal, error situations do not need to be detected unless it is explicitly stated that the error is signaled.

Setup

Edit: I think I should allow having only one distant signal assigned to a TCB side at a time. This is likely easier to implement; alternatively, it should be possible to assign a distant signal to reflect the signal aspect of a main signal or a distant signal (e.g. for a distant signal repeater). — ywang 2022-01-01 03:00

Signal handling

Setting distant signals

The distant signals of a main signal is only set when the route to the main signal is set and goes through the distant signals. The interlocking system can do so by traversing through the route to the main signal and setting the distant signals on its way. The first distant signal is treated as a regular distant signal, and the rest are treated as distant signal repeaters. A list of distant signals assigned to the main signal should be kept to make sure that the distant signals are updated as the aspect of the main signal changes.

It should be selectable whether a signal on the route should be treated as distant signal and which not. At least the user shoud be able to set which is the first intermediate signal on the route that should serve as distant signal. The reason for this is that there may be a very long block (the route start signal should not pre-display any distant aspect here) and there is a dedicated distant-only signal before the next main signal. — orwell 2021-12-31 17:22

What I thought about was that you need to explicitly set a signal as a distant signal by assigning it to a TCB (separately from the main signal - if you have e.g. a Ks signal you need to assign it twice) or by assigning it to an existing signal. — ywang 2022-01-01 03:00

I thought about this again: the main and distant aspects, when both assigned, should be assigned to the same TCB. It does not make much sense otherwise. — ywang 2022-02-10 17:49

Distant signals without TCB?

orwell 2021-12-31 17:22 The above approach requires that each distant signal (even if it is a pure distant signal without main signal function) is assigned to a TCB (correct?).

I propose a separate mode where the distant signal is not assigned to a TCB, but instead shows the distant aspect of one (user-selected) main signal at all times, irregardless of route settings. Of course this only makes sense for pure-distant signals.

We can use this for simple distant signals before mainline main signals when we don't want to add another TCB (and thus make the block section 2 track sections instead of just one).

Makes sense. I have appended it to the previous section. — ywang 2022-01-01 03:00

Unsetting distant signals

The procedure of setting the aspect of distant signals must be done in a way that the distant signal(s) showing the aspect of the main signal can be found. Distant signals are unset (i.e. set to nil) when the main signal and/or the distant signal becomes irrelevant for any train, such as when the distant signal is a combined signal showing the Hp 0 aspect.

Example

In the following case:

^
|
+---- Main signal H1
|
|  ^
|  |
|  +- Main signal H2
|  |
|\/|
|/\|
|  |
|  +- Combined signal H4 (main)/V2 (distant)
|  |
|  V
|
+---- Combined signal H3 (main)/V1 (distant)
|
V

If both routes H4→H2 and H3→H1 are set, then

If the route H3→H2 is set, then

Representation in Signal Aspect Table

orwell 2021-12-31 17:22 IMO the easiest way to provide clean distant signal support is via extending the “Signal Aspect” table. Proposal:

asp = {
  ... other fields as usual ...
  dst_pos = <position vector>,
  dst = nil, -- 'dst' field is not provided directly

Then, within advtrains.interlocking.signal_set_aspect(pos, asp), the dst_pos field is looked up and the dst field is set accordingly before the set_aspect() of the node definition is called.

2 things need to be taken care of:

  1. the signal API somehow needs to keep track of the aspects the signals are supposed show - not only for the TCB-assigned signals but for all signals
  2. the signal API needs to remember a reverse lookup of signals that have dst_pos set on a signal, to trigger aspect updates accordingly.

With this implementation, the distant signals feature can also easily be used from LuaATC-controlled signals. The route mechanism can just plug into that and set the position of the route end signal as dst_pos.

Whether signal is a distant signal repeater would then be another field in the aspect definition (dst_repeater = <boolean>)

Also, there is this “Verkürzter Bremswegabstand” light in Ks signals - dst_short = <boolean>?

In an earlier implementation I simply put the distant signal information (position of the main signal or the distant signal) in the signal table itself instead of the aspect table. That made it possible to keep track of what is assigned to what. I would prefer having the signal aspect table as a fallback when the source of the train is unknown. The “verkürzter Bemswegabstand” feature might be a bit complicated when you have a distant signal that can be assigned to multiple main signals (e.g. at a turnout), and I would prefer a method that computationally figures out whether the braking distance is reduced, which is beyond my abilities at the moment. — ywang 2022-01-01 03:00