Railway signaling simulator

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,303
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
A while ago I asked for some help with passing references in C#. I mentioned that it was a project outside of Orbiter. This is it. For about 3 or so years, I've been working on and off (mostly off) on a railroad signaling simulator. I am pleased to say that I am releasing version 1 to the wild. Now this isn't a train simulator, or even a dispatching simulator. It only simulates the progression of train signals as trains operate along a section of track. This is primarily written from a north American perspective. Basic worldwide signaling should be possible, however some systems have some key signaling features that are not included in this such as approach-release.

I primarily wrote this as an eventual means of improving model railroad signaling. Every signaling scheme I could find almost requires programming each and every signal individually, and using lots of if-else logic. As a programmer, that made my hair hurt so I set out to find a better way. Essentially, I use arrays and numerical signal indications to run the logic. So rather than something like:
Code:
if(next_indication == 30 && !block_occupied) //receive clear signal, display clear signal
  indication = 30;
elseif(next_indication == 20 && !block_occupied) //receive approach signal, display clear signal
 indication = 30;
elseif(next_indication == 0 && !block_occupied) //receive stop signal, display approach signal
 indication = 20;

I do something like this:
Code:
indication = indications[next_indication];

Additionally, signaling is defined in a set of signal rules that is much more user-friendly, and able to be reused by any similar signals (i.e. all intermediate signals will have the same reactions, on a certain line all passing siding signals will have the same reactions, etc.).

So, here it is. If there's any questions or comments, please let me know!

https://drive.google.com/open?id=0B9HD0Z2rxF2hYnZHX19yaC1TLVE
 
I would have done it in OOP, but that is my kind of insanity. :)
 
I would have done it in OOP, but that is my kind of insanity. :)
I'm guessing you mean object-oriented programming? I actually did. The core simulator is written in C++ with classes for blocks, signals, trains and ports (entrance/exit of blocks).
No Google account here. Any chance to still get it?
Hmm, I have the sharing settings enabled for no sign-in required. Can you try again?
Sounds like a textbook case for a state machine! :)
Exactly.

Like

Code:
signal_state = signal_state.next[block_state];
That's pretty much it. The entire thing is basically event-driven. Also unlike most of the existing model railroad solutions that stuck that big example if-else logic into a giant while loop, the while loop in mine just runs the trains which enter and exit the blocks which is what sets up the signal actions.
 
Whatever that means. Still no luck, though:

Strange. I followed the link (on my phone) and I'm looking right at the files, as well as a Sign In button suggesting I'm not yet logged in.

Might be some weird thing about US-to-EU?
 
Last edited:
Strange. I followed the link (on my phone) and I'm looking right at the files, as well as a Sign In button suggesting I'm not yet logged in.

Might be some weird thing about US-to-EU?

Worked for me, but the download button was well hidden.
 
Worked for me too, even after I took the time to sign out of google... ?

That's pretty much it. The entire thing is basically event-driven.

Yes, that sounds like the most reasonable apporach to a problem like that.
 
Last edited:
Back
Top