Asynchronous Architecture

Updated: 2026-05-28

The Train vs. Conveyor and Road: The Obligation to Report

It is crucial to understand the paradigm shift introduced by the railway environment compared with the Conveyor (Conveyor Belts) and Road (Roads) algorithms:

The train behaves as it did in the previous conveyor and road algorithms, following a fire & forget approach, since its itinerary, state, and permissions provide it with everything needed to determine its movement vector.

However, the radical difference from the other two algorithms is that here the train must report its state to the system. While a car or a package is passively carried along by the local physical laws of its lane or conveyor belt, the train acts as an active distributed agent. Each train is responsible for transmitting its telemetry; if the train does not report that it has crossed a boundary, the CTC cannot release the infrastructure and the model becomes blocked.

Communications:

Once the scope has been limited to the operator (Dispatcher), we must address the design of the algorithm. To understand it, it is essential to distinguish between the theoretical description of communications (the language they use to communicate with one another) and the theoretical description of computation (how each entity thinks independently).

The system is based on a Master-Slave model consisting of two distinct thinking entities that work collaboratively and asynchronously:

┌────────────────────────────────────────────────┐
│ CTC (Master - Agent)                            │
│ Remains static. Manages the global matrix.      │ 
└──────────────────────────────▲────┬─────────────┘ 
                               │    │
            Telemetry          ▲    ▼
                               │    │  Permissions     
                               ▲    ▼
                               │    │
┌──────────────────────────────┴────▼─────────────┐ 
│ TRAINS (Slaves - Physical Entities)             │
│ Move across the map. Change their kinematics and position. │ 
└────────────────────────────────────────────────┘

1. The CTC (The Static Master)

It is represented by a control transaction that is always active "mentally" but has no physical representation on the tracks. Its sole mission is to evaluate the state of the network whenever an event occurs. Its lifecycle is an infinite listening loop:

while (1==1)
    advance 1000
endwhile

2. The Trains (The Physical Slaves)

They are entities with a representation in the simulator. They exist inside their own infinite loop, but unlike the CTC, they perform physical and kinematic work. Their internal engine is a state machine that is continuously updated:

while (1==1)
   assign state, P$stateNext
   ...
   ...
endwhile

3. Communications: The Exchange Protocol

With both minds operating in parallel, the simulation's overall logic is reduced to a constant ping-pong exchange of messages distributed across four strict steps:

  1. Train ──> CTC (Telemetry): The train reaches a control point and sends a packet containing its current situation and future intentions.

  2. CTC ──> Train (Dispatch): The CTC receives the message, queries the global block-section database, and dispatches the necessary permissions if they are available.

  3. Train ──> Action: The train receives the command, changes its local state machine, and adjusts its speed and position accordingly.

  4. Train ──> CTC: After completing its physical action, the train sends telemetry again, restarting the cycle.

 

The Train's State Machine

While the CTC has no states of its own (the CTC is an administrator that safeguards and manages the global permission matrix for all block sections), the train responds strictly to three kinematic commands (states):

  • State 0 (STOP): Permission denied. The train calculates its braking ramp to come to a complete stop before entering the next block section.

  • State 1 (START MOVING): Permission granted while stopped. The train applies its acceleration rate to overcome inertia and leave the current block section.

  • State 2 (CONTINUE MOVING): Permission granted while in motion. The train maintains its cruising speed regime and moves smoothly toward the next block section.

 

The CTC does not have a state of its own; instead, it retains and manages the permissions for all block sections.