Skip to content

Commit c78746b

Browse files
authored
Merge pull request #1170 from rwf-rr/bugfix-command-log-time-zero
Fix Command Log Time for Commands that had it at 0 (zero).
2 parents 84be72c + 83a049e commit c78746b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,9 +3796,17 @@ public void StartThrottleIncrease()
37963796
}
37973797

37983798
if (CombinedControlType == CombinedControl.ThrottleDynamic && DynamicBrakeController.CurrentValue > 0)
3799+
{
37993800
StartDynamicBrakeDecrease(null);
3801+
if (DynamicBrakeController != null)
3802+
DynamicBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
3803+
}
38003804
else if (CombinedControlType == CombinedControl.ThrottleAir && TrainBrakeController.CurrentValue > 0)
3805+
{
38013806
StartTrainBrakeDecrease(null);
3807+
if (TrainBrakeController != null)
3808+
TrainBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
3809+
}
38023810
else
38033811
StartThrottleIncrease(ThrottleController.SmoothMax());
38043812
}
@@ -3866,6 +3874,7 @@ public void StartThrottleDecrease(float? target)
38663874
}
38673875

38683876
protected bool speedSelectorModeDecreasing = false;
3877+
38693878
public void StartThrottleDecrease()
38703879
{
38713880
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedMaxAccelerationPercent != 0
@@ -3914,9 +3923,17 @@ public void StartThrottleDecrease()
39143923
ThrottleController.CurrentValue = 1;
39153924
}
39163925
if (CombinedControlType == CombinedControl.ThrottleDynamic && ThrottleController.CurrentValue <= 0)
3926+
{
39173927
StartDynamicBrakeIncrease(null);
3928+
if (DynamicBrakeController != null)
3929+
DynamicBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
3930+
}
39183931
else if (CombinedControlType == CombinedControl.ThrottleAir && ThrottleController.CurrentValue <= 0)
3932+
{
39193933
StartTrainBrakeIncrease(null);
3934+
if (TrainBrakeController != null)
3935+
TrainBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
3936+
}
39203937
else
39213938
StartThrottleDecrease(ThrottleController.SmoothMin());
39223939
}
@@ -3961,9 +3978,19 @@ public void StopThrottleDecrease()
39613978
ThrottleController.StopDecrease();
39623979

39633980
if (CombinedControlType == CombinedControl.ThrottleDynamic)
3981+
{
3982+
// sometimes called without a corresponding start
3983+
if (DynamicBrakeController != null && DynamicBrakeController.CommandStartTime < CommandStartTime)
3984+
DynamicBrakeController.CommandStartTime = CommandStartTime;
39643985
StopDynamicBrakeIncrease();
3986+
}
39653987
else if (CombinedControlType == CombinedControl.ThrottleAir)
3988+
{
3989+
// sometimes called without a corresponding start
3990+
if (TrainBrakeController != null && TrainBrakeController.CommandStartTime < CommandStartTime)
3991+
TrainBrakeController.CommandStartTime = CommandStartTime;
39663992
StopTrainBrakeIncrease();
3993+
}
39673994
if (ThrottleController.SmoothMin() != null)
39683995
new ContinuousThrottleCommand(Simulator.Log, false, ThrottleController.CurrentValue, CommandStartTime);
39693996
}
@@ -4660,6 +4687,7 @@ public void StartEngineBrakeIncrease(float? target)
46604687

46614688
//if (CruiseControl != null) CruiseControl.EngineBrakePriority = true;
46624689
EngineBrakeController.StartIncrease(target);
4690+
EngineBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
46634691
Simulator.Confirmer.Confirm(CabControl.EngineBrake, CabSetting.Increase, GetEngineBrakeStatus());
46644692
SignalEvent(Event.EngineBrakeChange);
46654693
}
@@ -4791,6 +4819,7 @@ public void StartBrakemanBrakeIncrease(float? target)
47914819
return;
47924820

47934821
BrakemanBrakeController.StartIncrease(target);
4822+
BrakemanBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
47944823
Simulator.Confirmer.Confirm(CabControl.BrakemanBrake, CabSetting.Increase, GetBrakemanBrakeStatus());
47954824
// SignalEvent(Event.EngineBrakeChange);
47964825
}
@@ -4905,6 +4934,7 @@ public void StartDynamicBrakeIncrease(float? target)
49054934
float prevValue = DynamicBrakeController.CurrentValue;
49064935

49074936
DynamicBrakeController.StartIncrease(target);
4937+
DynamicBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
49084938

49094939
AlerterReset(TCSEvent.DynamicBrakeChanged);
49104940
SignalEvent(Event.DynamicBrakeChange);
@@ -4939,6 +4969,7 @@ public void StartDynamicBrakeDecrease(float? target)
49394969
if (DynamicBrakeController?.CurrentValue > 0)
49404970
{
49414971
DynamicBrakeController.StartDecrease(target);
4972+
DynamicBrakeController.CommandStartTime = Simulator.ClockTime; // Remember when the command was issued
49424973

49434974
AlerterReset(TCSEvent.DynamicBrakeChanged);
49444975
SignalEvent(Event.DynamicBrakeChange);

0 commit comments

Comments
 (0)