Skip to content

Commit adc9bd7

Browse files
committed
Adjust wheel slip notification
1 parent 5e3fe31 commit adc9bd7

File tree

6 files changed

+74
-14
lines changed

6 files changed

+74
-14
lines changed

Source/Orts.Simulation/Simulation/Physics/Train.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ public TrainCar LastCar
155155

156156
public bool IsWheelSlipWarninq;
157157
public bool IsWheelSlip;
158+
public bool HuDIsWheelSlipWarninq;
159+
public bool HuDIsWheelSlip;
158160
public bool IsBrakeSkid;
159161

160162
public bool HotBoxSetOnTrain = false;
@@ -1953,6 +1955,8 @@ public virtual void physicsUpdate(float elapsedClockSeconds)
19531955

19541956
bool whlslp = false;
19551957
bool whlslpwrn = false;
1958+
bool hudwhlslp = false;
1959+
bool hudwhlslpwrn = false;
19561960
bool whlskd = false;
19571961

19581962
TrainCar uncoupleBehindCar = null;
@@ -1979,6 +1983,12 @@ public virtual void physicsUpdate(float elapsedClockSeconds)
19791983
whlslp = true;
19801984
if (car.WheelSlipWarning)
19811985
whlslpwrn = true;
1986+
1987+
if (car.HuDIsWheelSlip)
1988+
hudwhlslp = true;
1989+
if (car.HuDIsWheelSlipWarninq)
1990+
hudwhlslpwrn = true;
1991+
19821992
if (car.BrakeSkid)
19831993
{
19841994
whlskd = true;
@@ -2011,6 +2021,10 @@ public virtual void physicsUpdate(float elapsedClockSeconds)
20112021

20122022
IsWheelSlip = whlslp;
20132023
IsWheelSlipWarninq = whlslpwrn;
2024+
2025+
HuDIsWheelSlip = hudwhlslp;
2026+
HuDIsWheelSlipWarninq = hudwhlslpwrn;
2027+
20142028
IsBrakeSkid = whlskd;
20152029

20162030
// Coupler breaker

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,17 +2503,18 @@ public void ConfirmWheelslip(float elapsedClockSeconds)
25032503
if (AdvancedAdhesionModel)
25042504
{
25052505
// Wheelslip
2506-
if (WheelSlip)
2506+
if (HuDIsWheelSlip)
25072507
{
25082508
if (WheelslipState != Wheelslip.Occurring)
25092509
{
25102510
WheelslipState = Wheelslip.Occurring;
25112511
Simulator.Confirmer.Warning(CabControl.Wheelslip, CabSetting.On);
2512+
Trace.TraceInformation("Display Wheelslip#1 - CarID {0} WheelSlip {1}", CarID, HuDIsWheelSlip);
25122513
}
25132514
}
25142515
else
25152516
{
2516-
if (WheelSlipWarning)
2517+
if (HuDIsWheelSlipWarninq)
25172518
{
25182519
if (WheelslipState != Wheelslip.Warning)
25192520
{
@@ -2537,6 +2538,7 @@ public void ConfirmWheelslip(float elapsedClockSeconds)
25372538
{
25382539
WheelslipState = Wheelslip.Occurring;
25392540
Simulator.Confirmer.Warning(CabControl.Wheelslip, CabSetting.On);
2541+
Trace.TraceInformation("Display Wheelslip#2");
25402542
}
25412543
if ((!WheelSlip) && (WheelslipState != Wheelslip.None))
25422544
{
@@ -2797,6 +2799,8 @@ public virtual void AdvancedAdhesion(float elapsedClockSeconds)
27972799
{
27982800
WheelSlip = LocomotiveAxles.IsWheelSlip;
27992801
WheelSlipWarning = LocomotiveAxles.IsWheelSlipWarning;
2802+
HuDIsWheelSlip = LocomotiveAxles.HuDIsWheelSlip;
2803+
HuDIsWheelSlipWarninq = LocomotiveAxles.HuDIsWheelSlipWarning;
28002804
}
28012805

28022806
WheelSpeedMpS = (float)LocomotiveAxles[0].AxleSpeedMpS;
@@ -5572,19 +5576,19 @@ public virtual float GetDataOf(CabViewControl cvc)
55725576
if (activeloco.DieselEngines[0] != null)
55735577
{
55745578
if (activeloco.AdvancedAdhesionModel && Train.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
5575-
data = activeloco.WheelSlipWarning ? 1 : 0;
5579+
data = activeloco.HuDIsWheelSlipWarninq ? 1 : 0;
55765580
else
5577-
data = activeloco.WheelSlip ? 1 : 0;
5581+
data = activeloco.HuDIsWheelSlip ? 1 : 0;
55785582

55795583
}
55805584
}
55815585
}
55825586
else
55835587
{
55845588
if (AdvancedAdhesionModel && Train.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
5585-
data = WheelSlipWarning ? 1 : 0;
5589+
data = HuDIsWheelSlipWarninq ? 1 : 0;
55865590
else
5587-
data = WheelSlip ? 1 : 0;
5591+
data = HuDIsWheelSlip ? 1 : 0;
55885592
}
55895593
break;
55905594
}

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6455,6 +6455,8 @@ public override void AdvancedAdhesion(float elapsedClockSeconds)
64556455
{
64566456
WheelSlip = LocomotiveAxles.IsWheelSlip;
64576457
WheelSlipWarning = LocomotiveAxles.IsWheelSlipWarning;
6458+
HuDIsWheelSlip = LocomotiveAxles.HuDIsWheelSlip;
6459+
HuDIsWheelSlipWarninq = LocomotiveAxles.HuDIsWheelSlipWarning;
64586460
}
64596461

64606462
// This enables steam locomotives to have different speeds for driven and non-driven wheels.
@@ -7968,7 +7970,7 @@ public override string GetDebugStatus()
79687970
Simulator.Catalog.GetString("Coeff"),
79697971
Train.LocomotiveCoefficientFriction,
79707972
Simulator.Catalog.GetString("Slip"),
7971-
SteamEngines[i].AttachedAxle.IsWheelSlip ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
7973+
SteamEngines[i].AttachedAxle.HuDIsWheelSlip ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
79727974
Simulator.Catalog.GetString("WheelM"),
79737975
FormatStrings.FormatMass(SteamEngines[i].AttachedAxle.WheelWeightKg, IsMetric),
79747976
Simulator.Catalog.GetString("FoA"),

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

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,33 @@ public bool IsWheelSlipWarning
124124
return false;
125125
}
126126
}
127+
128+
/// <summary>
129+
/// Get wheel slip status for the whole engine, ie whenever one axle is in slip
130+
/// </summary>
131+
public bool HuDIsWheelSlip
132+
{
133+
get
134+
{
135+
foreach (var axle in AxleList)
136+
{
137+
if (axle.HuDIsWheelSlip) return true;
138+
}
139+
return false;
140+
}
141+
}
142+
public bool HuDIsWheelSlipWarning
143+
{
144+
get
145+
{
146+
foreach (var axle in AxleList)
147+
{
148+
if (axle.HuDIsWheelSlipWarning) return true;
149+
}
150+
return false;
151+
}
152+
}
153+
127154
public int NumOfSubstepsPS
128155
{
129156
get
@@ -245,7 +272,7 @@ public void Initialize()
245272
// Because of the irregular force around the wheel for a steam engine during a revolution, "response" time for warnings needs to be lower
246273
if (locomotive.EngineType == TrainCar.EngineTypes.Steam)
247274
{
248-
axle.WheelSlipThresholdTimeS = 0.1f;
275+
axle.WheelSlipThresholdTimeS = 1;
249276
axle.WheelSlipWarningThresholdTimeS = axle.WheelSlipThresholdTimeS * 0.75f;
250277
}
251278
else // diesel and electric locomotives
@@ -609,6 +636,7 @@ public float TransmissionEfficiency
609636
/// Wheel slip indicator
610637
/// - is true when absolute value of SlipSpeedMpS is greater than WheelSlipThresholdMpS, otherwise is false
611638
/// </summary>
639+
public bool HuDIsWheelSlip { get; private set; }
612640
public bool IsWheelSlip { get; private set; }
613641
float WheelSlipTimeS;
614642
public float WheelSlipThresholdTimeS = 1;
@@ -671,6 +699,7 @@ public void ComputeWheelSlipThresholdMpS()
671699
/// SlipSpeedPercent is greater than SlipWarningThresholdPercent in both directions,
672700
/// otherwise is false
673701
/// </summary>
702+
public bool HuDIsWheelSlipWarning { get; private set; }
674703
public bool IsWheelSlipWarning { get; private set; }
675704
float WheelSlipWarningTimeS;
676705
public float WheelSlipWarningThresholdTimeS = 1;
@@ -1112,22 +1141,31 @@ public virtual void Update(float elapsedSeconds)
11121141

11131142
if (Math.Abs(SlipSpeedMpS) > WheelSlipThresholdMpS)
11141143
{
1115-
// Wait some time before indicating wheelslip to avoid false triggers
1144+
// Wheel slip internally happens instantaneously, but may correct itself in a short period, so HuD indication has a small time delay to eliminate "false" indications
1145+
IsWheelSlip = IsWheelSlipWarning = true;
1146+
1147+
// Wait some time before indicating the HuD wheelslip to avoid false triggers
11161148
if (WheelSlipTimeS > WheelSlipThresholdTimeS)
11171149
{
1118-
IsWheelSlip = IsWheelSlipWarning = true;
1150+
HuDIsWheelSlip = HuDIsWheelSlipWarning = true;
11191151
}
11201152
WheelSlipTimeS += elapsedSeconds;
11211153
}
11221154
else if (Math.Abs(SlipSpeedPercent) > SlipWarningTresholdPercent)
11231155
{
1124-
// Wait some time before indicating wheelslip to avoid false triggers
1125-
if (WheelSlipWarningTimeS > WheelSlipWarningThresholdTimeS) IsWheelSlipWarning = true;
1156+
// Wheel slip internally happens instantaneously, but may correct itself in a short period, so HuD indication has a small time delay to eliminate "false" indications
1157+
IsWheelSlipWarning = true;
11261158
IsWheelSlip = false;
1159+
1160+
// Wait some time before indicating wheelslip to avoid false triggers
1161+
if (WheelSlipWarningTimeS > WheelSlipWarningThresholdTimeS) HuDIsWheelSlipWarning = true;
1162+
HuDIsWheelSlip = false;
11271163
WheelSlipWarningTimeS += elapsedSeconds;
11281164
}
11291165
else
11301166
{
1167+
HuDIsWheelSlipWarning = false;
1168+
HuDIsWheelSlip = false;
11311169
IsWheelSlipWarning = false;
11321170
IsWheelSlip = false;
11331171
WheelSlipWarningTimeS = WheelSlipTimeS = 0;

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ public float ConvectionFactor
315315

316316
public bool WheelSlip; // true if locomotive wheels slipping
317317
public bool WheelSlipWarning;
318+
public bool HuDIsWheelSlipWarninq;
319+
public bool HuDIsWheelSlip;
318320
public bool WheelSkid; // True if wagon wheels lock up.
319321
public float _AccelerationMpSS;
320322
protected IIRFilter AccelerationFilter = new IIRFilter(IIRFilter.FilterTypes.Butterworth, 1, 1.0f, 0.1f);

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ void TextPageCommon(TableData table)
479479
if (Viewer.PlayerLocomotive.Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING)
480480
TableAddLine(table, Viewer.Catalog.GetString("Autopilot") + "???");
481481

482-
if (Viewer.PlayerTrain.IsWheelSlip)
482+
if (Viewer.PlayerTrain.HuDIsWheelSlip)
483483
TableAddLine(table, Viewer.Catalog.GetString("Wheel slip") + "!!!");
484-
else if (Viewer.PlayerTrain.IsWheelSlipWarninq)
484+
else if (Viewer.PlayerTrain.HuDIsWheelSlipWarninq)
485485
TableAddLine(table, Viewer.Catalog.GetString("Wheel slip warning") + "???");
486486

487487
if (Viewer.PlayerTrain.IsBrakeSkid )

0 commit comments

Comments
 (0)