Skip to content

Commit fff05e6

Browse files
authored
Merge pull request #721 from cesarBLG/fix-wheelslip-alarm
Do not trigger wheelslip alarm until some time passes
2 parents f49c269 + 0eec308 commit fff05e6

File tree

1 file changed

+29
-19
lines changed
  • Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions

1 file changed

+29
-19
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,11 @@ public float TransmissionEfficiency
259259
public float TrainSpeedMpS;
260260

261261
/// <summary>
262-
/// Read only wheel slip indicator
262+
/// Wheel slip indicator
263263
/// - is true when absolute value of SlipSpeedMpS is greater than WheelSlipThresholdMpS, otherwise is false
264264
/// </summary>
265-
public bool IsWheelSlip
266-
{
267-
get
268-
{
269-
if (Math.Abs(SlipSpeedMpS) > WheelSlipThresholdMpS)
270-
return true;
271-
else
272-
return false;
273-
}
274-
}
265+
public bool IsWheelSlip { get; private set; }
266+
float WheelSlipTimeS;
275267

276268
/// <summary>
277269
/// Read only wheelslip threshold value used to indicate maximal effective slip
@@ -290,18 +282,13 @@ public float WheelSlipThresholdMpS
290282
}
291283

292284
/// <summary>
293-
/// Read only wheelslip warning indication
285+
/// Wheelslip warning indication
294286
/// - is true when SlipSpeedMpS is greater than zero and
295287
/// SlipSpeedPercent is greater than SlipWarningThresholdPercent in both directions,
296288
/// otherwise is false
297289
/// </summary>
298-
public bool IsWheelSlipWarning
299-
{
300-
get
301-
{
302-
return Math.Abs(SlipSpeedPercent) > SlipWarningTresholdPercent;
303-
}
304-
}
290+
public bool IsWheelSlipWarning { get; private set; }
291+
float WheelSlipWarningTimeS;
305292

306293
/// <summary>
307294
/// Read only slip speed value in metric meters per second
@@ -553,6 +540,29 @@ public virtual void Update(float timeSpan)
553540
CompensatedAxleForceN = AxleForceN + Math.Sign(TrainSpeedMpS) * BrakeRetardForceN;
554541
if (AxleForceN == 0) CompensatedAxleForceN = 0;
555542

543+
if (Math.Abs(SlipSpeedMpS) > WheelSlipThresholdMpS)
544+
{
545+
// Wait some time before indicating wheelslip to avoid false triggers
546+
if (WheelSlipTimeS > 0.1f)
547+
{
548+
IsWheelSlip = IsWheelSlipWarning = true;
549+
}
550+
WheelSlipTimeS += timeSpan;
551+
}
552+
else if (Math.Abs(SlipSpeedPercent) > SlipWarningTresholdPercent)
553+
{
554+
// Wait some time before indicating wheelslip to avoid false triggers
555+
if (WheelSlipWarningTimeS > 0.1f) IsWheelSlipWarning = true;
556+
IsWheelSlip = false;
557+
WheelSlipWarningTimeS += timeSpan;
558+
}
559+
else
560+
{
561+
IsWheelSlipWarning = false;
562+
IsWheelSlip = false;
563+
WheelSlipWarningTimeS = WheelSlipTimeS = 0;
564+
}
565+
556566
if (timeSpan > 0.0f)
557567
{
558568
slipDerivationMpSS = (SlipSpeedMpS - previousSlipSpeedMpS) / timeSpan;

0 commit comments

Comments
 (0)