G'day Kris94,
...elegant though the answers proffered so far are, the reality is that neither of them are 'relevant'. You have asked for a specific requirement in your question which neither answer has addressed...
..the answer to your question, unfortunately will depend upon a number of variables which you have not provided in your description. These being, the Operating Rules under which the system you are running 'work' and the sigbnalling system being used by the railway (because the rules used by different railway companies vary considerably and because the specific circumstances of the "installation" will be different, world wide). Until we know these, specifics, answers to your question cannot be provided...
...if you would be so kind...
Jerker {

}