Skip to content

Commit 607b9c6

Browse files
committed
MPC and CC with non-proportional notched speeds
1 parent b78bcce commit 607b9c6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/CruiseControl.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,12 @@ public void SpeedSelectorIncreaseStep()
11761176
if (time >= selectedSpeedLeverHoldTime && time < selectedSpeedLeverHoldTime + SpeedSelectorStepTimeSeconds) return;
11771177
selectedSpeedLeverHoldTime = time;
11781178

1179-
if (SpeedSelectorController.CurrentValue > 0 || MinimumSpeedForCCEffectMpS == 0)
1179+
if (SpeedSelectorIsDiscrete)
1180+
{
1181+
SpeedSelectorController.StartIncrease();
1182+
SpeedSelectorController.StopIncrease();
1183+
}
1184+
else if (SpeedSelectorController.CurrentValue > 0 || MinimumSpeedForCCEffectMpS == 0)
11801185
{
11811186
float speed = ControllerValueToSelectedSpeedMpS(SpeedSelectorController.CurrentValue) + SpeedRegulatorNominalSpeedStepMpS;
11821187
SelectedSpeedMpS = Math.Min(speed, Locomotive.MaxSpeedMpS);
@@ -1195,7 +1200,12 @@ public void SpeedSelectorDecreaseStep()
11951200
selectedSpeedLeverHoldTime = time;
11961201

11971202
float speed = ControllerValueToSelectedSpeedMpS(SpeedSelectorController.CurrentValue) - SpeedRegulatorNominalSpeedStepMpS;
1198-
if (speed < MinimumSpeedForCCEffectMpS)
1203+
if (SpeedSelectorIsDiscrete)
1204+
{
1205+
SpeedSelectorController.StartDecrease();
1206+
SpeedSelectorController.StopDecrease();
1207+
}
1208+
else if (speed < MinimumSpeedForCCEffectMpS)
11991209
{
12001210
SelectedSpeedMpS = 0;
12011211
}

0 commit comments

Comments
 (0)