Skip to content

Commit f9691cf

Browse files
committed
Reimplement legacy anti slip but using tractive force instead of physical throttle
1 parent f40920a commit f9691cf

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

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

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ public enum SlipControlType
250250
public float SteamStaticWheelForce;
251251
public float SteamTangentialWheelForce;
252252
public float SteamDrvWheelWeightLbs; // Weight on each drive axle
253-
public float PreviousThrottleSetting = 0.0f; // Holds the value of the previous throttle setting for calculating the correct antislip speed
254253
float DebugTimer; // Used for debugging adhesion coefficient
255254
bool DebugSpeedReached = false; // Used for debugging adhesion coefficient
256255
float DebugSpeedIncrement = 1; // Used for debugging adhesion coefficient
@@ -2264,24 +2263,6 @@ public override void Update(float elapsedClockSeconds)
22642263
UpdateAxles(elapsedClockSeconds);
22652264

22662265
UpdateTrackSander(elapsedClockSeconds);
2267-
2268-
if (this is MSTSDieselLocomotive || this is MSTSElectricLocomotive) // Antislip and throttle down should only work on diesel or electric locomotives.
2269-
{
2270-
2271-
// If wheel slip waring activated, and antislip is set in ENG file then reduce throttle setting to a value below warning power
2272-
if (WheelSlipWarning && AntiSlip)
2273-
{
2274-
ThrottleController.SetValue(PreviousThrottleSetting);
2275-
}
2276-
2277-
2278-
PreviousThrottleSetting = (ThrottlePercent / 100.0f) - 0.005f;
2279-
PreviousThrottleSetting = MathHelper.Clamp(PreviousThrottleSetting, 0.0f, 1.0f); // Prevents parameter going outside of bounds
2280-
2281-
// If wheels slip and WheelslipCausesThrottleDown is set in engine file reduce throttle to 0 setting
2282-
if (WheelslipCausesThrottleDown && WheelSlip)
2283-
ThrottleController.SetValue(0.0f);
2284-
}
22852266
break;
22862267
default:
22872268
break;
@@ -2742,18 +2723,34 @@ protected virtual void UpdateTractiveForce(float elapsedClockSeconds)
27422723
{
27432724
if (axle.DriveType == AxleDriveType.ForceDriven)
27442725
{
2726+
float prevForceN = axle.DriveForceN;
27452727
axle.DriveForceN = TractiveForceN * axle.TractiveForceFraction;
27462728
if (SlipControlSystem == SlipControlType.Full)
27472729
{
27482730
// Simple slip control
27492731
// Motive force is reduced to the maximum adhesive force
27502732
// In wheelslip situations, motive force is set to zero
27512733
float adhesionLimit;
2752-
if (axle.SlipSpeedPercent > 115) adhesionLimit = 0;
2753-
else if (axle.SlipSpeedPercent > 95) adhesionLimit = axle.MaximumWheelAdhesion * (115 - axle.SlipSpeedPercent) / 20;
2734+
if (axle.SlipPercent > 115) adhesionLimit = 0;
2735+
else if (axle.SlipPercent > 95) adhesionLimit = axle.MaximumWheelAdhesion * (115 - axle.SlipSpeedPercent) / 20;
27542736
else adhesionLimit = axle.MaximumWheelAdhesion;
27552737
axle.DriveForceN = Math.Sign(axle.DriveForceN) * Math.Min(adhesionLimit * axle.AxleWeightN, Math.Abs(axle.DriveForceN));
27562738
}
2739+
else if (TractionForceN > 0) // only for traction (not for dynamic brake)
2740+
{
2741+
if (WheelslipCausesThrottleDown && WheelSlip)
2742+
{
2743+
// Disable traction in the axle if slipping
2744+
axle.DriveForceN = 0;
2745+
}
2746+
else if (AntiSlip && AdvancedAdhesionModel && WheelSlipWarning)
2747+
{
2748+
// Reduce tractive force to 0 in 3 seconds until wheel slip warning ends
2749+
float newForceN = Math.Max(Math.Abs(prevForceN) - TractiveForceN * axle.TractiveForceFraction * elapsedClockSeconds / 3, 0);
2750+
if (axle.DriveForceN > 0 && prevForceN >= 0) axle.DriveForceN = newForceN;
2751+
else if (axle.DriveForceN < 0 && prevForceN <= 0) axle.DriveForceN = -newForceN;
2752+
}
2753+
}
27572754
}
27582755
}
27592756
}

0 commit comments

Comments
 (0)