@@ -259,19 +259,11 @@ public float TransmissionEfficiency
259
259
public float TrainSpeedMpS ;
260
260
261
261
/// <summary>
262
- /// Read only wheel slip indicator
262
+ /// Wheel slip indicator
263
263
/// - is true when absolute value of SlipSpeedMpS is greater than WheelSlipThresholdMpS, otherwise is false
264
264
/// </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 ;
275
267
276
268
/// <summary>
277
269
/// Read only wheelslip threshold value used to indicate maximal effective slip
@@ -290,18 +282,13 @@ public float WheelSlipThresholdMpS
290
282
}
291
283
292
284
/// <summary>
293
- /// Read only wheelslip warning indication
285
+ /// Wheelslip warning indication
294
286
/// - is true when SlipSpeedMpS is greater than zero and
295
287
/// SlipSpeedPercent is greater than SlipWarningThresholdPercent in both directions,
296
288
/// otherwise is false
297
289
/// </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 ;
305
292
306
293
/// <summary>
307
294
/// Read only slip speed value in metric meters per second
@@ -553,6 +540,29 @@ public virtual void Update(float timeSpan)
553
540
CompensatedAxleForceN = AxleForceN + Math . Sign ( TrainSpeedMpS ) * BrakeRetardForceN ;
554
541
if ( AxleForceN == 0 ) CompensatedAxleForceN = 0 ;
555
542
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
+
556
566
if ( timeSpan > 0.0f )
557
567
{
558
568
slipDerivationMpSS = ( SlipSpeedMpS - previousSlipSpeedMpS ) / timeSpan ;
0 commit comments