Model Train-related Notes Blog -- these are personal notes and musings on the subject of model train control, automation, electronics, or whatever I find interesting. I also have more posts in a blog dedicated to the maintenance of the Randall Museum Model Railroad.

2022-01-22 - Conductor 2: Startup corrective behavior

Category Rtac

One of the potential benefits of route management in Conductor 2 is being able to fix the invalid start behavior. In conductor 1, we simply cannot start the mainline automation if the trains are not at the startup point. For the branch line, I do have some self correction.

The current approach is to not even try to activate the mainline if blocks are not occupied as expected. Instead we should move that check into each route activation handler.

One possibility when activating a route is to scan its expected blocks. If there's only one occupied, could it be our train?

Another possibility is to remember each route current block on shutdown and restore it at the next startup of the program. On first opening, the trains should be either at their last recorded point or at the expected startup point. If the last recorded point is not the startup one, we try to recover.

To do that we also need to remember the last active route. Make that persistent too.

To recover, we don't need to hardcode the behavior in the manager. Instead we create an OnRecover event handler:

Route Passenger-Route {

        OnRecover → {

                AM Reverse

        }

}

We need to align all turnouts and simply start moving the engine. There is the issue of computing the currently active block. To do that we can traverse our block graph from the end till we get to the currently occupied block. We would still run the error rules described above, with only one block active and time limits to change blocks. That one becomes critical here; if the train is stalled or can't move, this will abort the recovery.


 Generated on 2022-10-03 by Rig4j 0.1-Exp-666f4a7