Now looking at my code in details I would have some more questions regarding the signalling.
roeter, on 30 January 2014 - 01:45 AM, said:
For these systems, you should not take speeds directly from signals or speedposts, but use these train variables :
public float AllowedMaxSpeedMpS; // Max speed as allowed
public float allowedMaxSpeedSignalMpS; // Max speed as set by signal
public float allowedMaxSpeedLimitMpS; // Max speed as set by limit
These are updated according to the position of the complete train with regards to all speed indicators (signals and speedposts) along the way.
For overspeed detection you only should check against AllowedMaxSpeedMpS, which is properly updated according to the train position.
The script functions are delegated currently as follows:
Script.TrainSpeedLimitMpS = () => Locomotive.Train.TrainMaxSpeedMpS;
Script.CurrentSignalSpeedLimitMpS = () => Locomotive.Train.allowedMaxSpeedSignalMpS;
I should set up one more function to query the "CurrentPostSpeedLimitMpS", which should point to Locomotive.Train.allowedMaxSpeedLimitMpS. (Is it right?)
Is that also right, that if the minimum of the above three will be calculated, then it will be the same as your AllowedMaxSpeedMpS variable? (I'm afraid that one cannot be used, because the different speed limits need to be passed to TCS separately, because any of them might also be needed for various things there. Some systems, mostly the older ones, don't know about speed posts, some others can only consider signals, etc...)
roeter, on 30 January 2014 - 01:45 AM, said:
Another point is that speed limits set by signals never overrule line speed limits as set by speedposts. The method you use, this_signal_speed, gives the allowed speed as set in sigcfg.dat for that signal, regardless of line speed limits.
Therefor, you should not use the this_signal_speed method to determine the speed. Instead, you should use the variable actual_speed of the first signal-entry in SignalObjectItems, which is set according to the line speed limit.
So you say I should remove the test
if (Locomotive.Train.IndexNextSignal >= 0 && Locomotive.Train.ControlMode == Train.TRAIN_CONTROL.AUTO_SIGNAL)
from my function UpdateNextSignalFunctions(), and in all cases use the
Script.NextSignalSpeedLimitMpS = () => Locomotive.Train.SignalObjectItems[Locomotive.Train.IndexNextSignal].actual_speed;
delegation? It would simplify things greatly! (But if I recall correctly, there were problems with it, and that's why the alternative method was introduced in the past. But now I will remove it, and will see. :good2: )