Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/ORTS.Settings/InputSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ static void InitializeCommands(UserCommandInput[] Commands)
Commands[(int)UserCommand.ControlSpeedRegulatorMaxAccelerationDecrease] = new UserCommandKeyInput(0x1E, KeyModifiers.Control | KeyModifiers.Shift);
Commands[(int)UserCommand.ControlSpeedRegulatorSelectedSpeedIncrease] = new UserCommandKeyInput(0x20, KeyModifiers.Shift);
Commands[(int)UserCommand.ControlSpeedRegulatorSelectedSpeedDecrease] = new UserCommandKeyInput(0x1E, KeyModifiers.Shift);
Commands[(int)UserCommand.ControlNumberOfAxlesIncrease] = new UserCommandKeyInput(0x48, KeyModifiers.Shift);
Commands[(int)UserCommand.ControlNumberOfAxlesDecrease] = new UserCommandKeyInput(0x50, KeyModifiers.Shift);
Commands[(int)UserCommand.ControlNumberOfAxlesIncrease] = new UserCommandKeyInput(0x48, KeyModifiers.Control | KeyModifiers.Shift);
Commands[(int)UserCommand.ControlNumberOfAxlesDecrease] = new UserCommandKeyInput(0x50, KeyModifiers.Control | KeyModifiers.Shift);
Commands[(int)UserCommand.ControlRestrictedSpeedZoneActive] = new UserCommandKeyInput(0x13, KeyModifiers.Control | KeyModifiers.Shift);
Commands[(int)UserCommand.ControlCruiseControlModeDecrease] = new UserCommandKeyInput(0x1E, KeyModifiers.Control);
Commands[(int)UserCommand.ControlCruiseControlModeIncrease] = new UserCommandKeyInput(0x20, KeyModifiers.Control);
Expand Down
83 changes: 68 additions & 15 deletions Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,15 +1685,25 @@ public override void Update(float elapsedClockSeconds)
//UpdateMotiveForce(elapsedClockSeconds, t, AbsSpeedMpS, AbsWheelSpeedMpS);
CheckAccelerationBits(elapsedClockSeconds, AbsWheelSpeedMpS);

if (CruiseControl != null)
if (CruiseControl != null && !TrainBrakeController.TCSEmergencyBraking)
{
if (!IsPlayerTrain || CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Manual || CruiseControl.UseThrottle)
{
CruiseControl.WasForceReset = false;
UpdateMotiveForce(elapsedClockSeconds, t, AbsSpeedMpS, AbsWheelSpeedMpS);
else
}
else if (CruiseControl.SelectedSpeedMpS > 0)
CruiseControl.Update(elapsedClockSeconds, AbsWheelSpeedMpS);
else
UpdateMotiveForce(elapsedClockSeconds, t, AbsSpeedMpS, AbsWheelSpeedMpS);

}
else
{
if (CruiseControl != null && (TrainBrakeController.TCSEmergencyBraking || TrainBrakeController.TCSFullServiceBraking))
CruiseControl.WasBraking = true;
UpdateMotiveForce(elapsedClockSeconds, t, AbsSpeedMpS, AbsWheelSpeedMpS);
}

if (MultiPositionControllers != null)
{
Expand Down Expand Up @@ -2078,6 +2088,10 @@ protected virtual void UpdateMotiveForce(float elapsedClockSeconds, float t, flo
{
// Method to set force and power info
// An alternative method in the steam locomotive will override this and input force and power info for it.

if (IsAPartOfPlayerTrain) t = ThrottleOverriden;
if (t > 1)
t = 1;
if (PowerOn && Direction != Direction.N)
{
if (TractiveForceCurves == null)
Expand Down Expand Up @@ -2985,9 +2999,16 @@ public virtual void StartReverseDecrease(float? target)
#region ThrottleController
public void StartThrottleIncrease(float? target)
{
if (CruiseControl != null && target != null)
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector)
{
CruiseControl.SpeedRegulatorSelectedSpeedStartIncrease();
return;
}
}
if (ThrottleController.CurrentValue >= ThrottleController.MaximumValue)
return;

if (target != null) ThrottleController.StartIncrease(target);
else new NotchedThrottleCommand(Simulator.Log, true);

Expand All @@ -3013,7 +3034,7 @@ public void StartThrottleIncrease()
}
}
}
if (CruiseControl != null)
if (CruiseControl != null && CombinedControlType == CombinedControl.None)
{
if (CruiseControl.UseThrottleAsForceSelector && CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
{
Expand All @@ -3024,12 +3045,20 @@ public void StartThrottleIncrease()
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
{
return;
if (!CruiseControl.UseThrottleAsSpeedSelector)
return;
}
}
}

if (DynamicBrakeController != null && DynamicBrakeController.CurrentValue >= 0 && (DynamicBrakePercent >= 0 || !(DynamicBrakePercent == -1 && !DynamicBrake || DynamicBrakePercent >= 0 && DynamicBrake)))
bool checkBraking = true;
if (CruiseControl != null)
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector)
{
checkBraking = false;
}
}
if (DynamicBrakeController != null && DynamicBrakeController.CurrentValue >= 0 && (DynamicBrakePercent >= 0 || !(DynamicBrakePercent == -1 && !DynamicBrake || DynamicBrakePercent >= 0 && DynamicBrake)) && checkBraking)
{
if (!(CombinedControlType == CombinedControl.ThrottleDynamic
|| CombinedControlType == CombinedControl.ThrottleAir && TrainBrakeController.CurrentValue > 0))
Expand Down Expand Up @@ -3073,8 +3102,9 @@ public void StopThrottleIncrease()
}
else
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector && CruiseControl.SelectedSpeedMpS > 0)
{
CruiseControl.SpeedRegulatorSelectedSpeedStopIncrease();
return;
}
}
Expand All @@ -3092,6 +3122,15 @@ public void StopThrottleIncrease()

public void StartThrottleDecrease(float? target)
{
if (CruiseControl != null)
{
if (CruiseControl.UseThrottleAsSpeedSelector && CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedSpeedMpS > 0)
{
CruiseControl.SpeedRegulatorSelectedSpeedStartDecrease();
return;
}
}

if (ThrottleController.CurrentValue <= ThrottleController.MinimumValue)
return;

Expand Down Expand Up @@ -3121,7 +3160,7 @@ public void StartThrottleDecrease()
}
}
}
if (CruiseControl != null)
if (CruiseControl != null && CombinedControlType == CombinedControl.None)
{
if (CruiseControl.UseThrottleAsForceSelector && CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
{
Expand All @@ -3130,12 +3169,19 @@ public void StartThrottleDecrease()
}
else
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && !CruiseControl.UseThrottleAsSpeedSelector)
{
return;
}
}
}
if (CruiseControl != null)
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector && CruiseControl.SelectedSpeedMpS > 0)
{
ThrottleController.CurrentValue = 1;
}
}
if (CombinedControlType == CombinedControl.ThrottleDynamic && ThrottleController.CurrentValue <= 0)
StartDynamicBrakeIncrease(null);
else if (CombinedControlType == CombinedControl.ThrottleAir && ThrottleController.CurrentValue <= 0)
Expand Down Expand Up @@ -3163,17 +3209,16 @@ public void StopThrottleDecrease()
}
if (CruiseControl != null)
{
if (CruiseControl.UseThrottleAsForceSelector && CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
if (CruiseControl.UseThrottleAsSpeedSelector && CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedSpeedMpS > 0)
{
CruiseControl.SpeedRegulatorMaxForceStopDecrease();
CruiseControl.SpeedRegulatorSelectedSpeedStopDecrease();
return;
}
else
{
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)
if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedSpeedMpS > 0)
{
speedSelectorModeDecreasing = false;
return;
}
}
}
Expand Down Expand Up @@ -3428,8 +3473,12 @@ public float GetCombinedHandleValue(bool intermediateValue)
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (intermediateValue ? DynamicBrakeController.IntermediateValue : DynamicBrakeController.CurrentValue);
else if (CombinedControlType == CombinedControl.ThrottleAir && TrainBrakeController.CurrentValue > 0)
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (intermediateValue ? TrainBrakeController.IntermediateValue : TrainBrakeController.CurrentValue);
else
else if (CruiseControl == null)
return CombinedControlSplitPosition * (1 - (intermediateValue ? ThrottleController.IntermediateValue : ThrottleController.CurrentValue));
else if (CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Manual)
return CombinedControlSplitPosition * (1 - (intermediateValue ? ThrottleController.IntermediateValue : ThrottleController.CurrentValue));
else
return CombinedControlSplitPosition * (1 - (CruiseControl.SelectedSpeedMpS / MaxSpeedMpS));
}
#endregion

Expand Down Expand Up @@ -3551,6 +3600,10 @@ public void StartTrainBrakeIncrease(float? target)
AlerterReset(TCSEvent.TrainBrakeChanged);
TrainBrakeController.StartIncrease(target);
TrainBrakeController.CommandStartTime = Simulator.ClockTime;
if (CruiseControl != null)
{
CruiseControl.TrainBrakePriority = true;
}
Simulator.Confirmer.Confirm(CabControl.TrainBrake, CabSetting.Increase, GetTrainBrakeStatus());
SignalEvent(Event.TrainBrakeChange);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public void Update(float elapsedClockSeconds)
{
emergencyBrake = false;
}
if (Locomotive.TrainBrakeController.TCSEmergencyBraking)
Locomotive.TrainBrakeController.TCSEmergencyBraking = false;
/* if (Locomotive.TrainBrakeController.TCSEmergencyBraking)
Locomotive.TrainBrakeController.TCSEmergencyBraking = false; */
elapsedSecondsFromLastChange += elapsedClockSeconds;
// Simulator.Confirmer.MSG(currentPosition.ToString());
if (checkNeutral)
Expand Down
Loading