The DataBeaver's Domain

Model railway - Software

Designing and operating a large model railway setup would be near impossible without some sort of help to see where each turnout is. Being a programmer inside and out, I have written my own software suite for these tasks. The first part of it allows me to build a railway layout with an unlimited amount of track pieces, and is (rather unimaginatively) called "designer". Track snapping and copying allow complex layouts to be built quickly. Turnout and sensor IDs of tracks can be indicated for use in the engineer program.

[Image]

The second large part of the software suite is the "engineer" (named after locomotive engineer, i.e. the driver of a locomotive). It loads a layout made with the designer and allows controlling of turnouts and trains. Basic collision prevention and speed measuring is also implemented. Some planned future features are predefined circuits, a go-to function and timetable-based automatic operation.

[Image]

In addition to these, I also have a small utility program that compares a layout to my current inventory of tracks and produces a shopping list.

Traffic control

The traffic control system follows that of real railways and uses absolute block signaling. The layout is automatically split into blocks based on sensor tracks. Turnouts can't have sensors, so the controller has to deal with sensorless runs of track as well.

When a train starts moving, it tries to reserve blocks in front of it up to two sensor blocks. If it can get those, it starts moving at the full requested speed. If it was only able to get one sensor block, a low speed limit is enforced to make sure it can stop at the next sensor. No free blocks means that the train is not allowed to move. Non-sensored blocks are never kept at the tail of the reservation list to prevent the train from blocking another one by holding a turnout it won't enter (it's assumed that when a train stops from the low speed, it will not roll over the sensor).

As the train advances and triggers the next sensor, that block and any reserved non-sensored blocks ahead of it are moved to the list of current blocks. The reservation is then invoked again and speed adjusted if necessary. Similarly, when a sensor is released, all blocks up to it are freed. Because the software can't "see" non-sensored blocks, it handles them conservatively and keeps them reserved when a train occupies an adjacent sensor block.

Source code

All of the software is open source under the GNU Public License. SVN access is available at http://svn.tdb.fi/marklin. There are no releases currently, nor will there be in the foreseeable future.