Skip to content

Commit b96d6fa

Browse files
committed
Also show dynamic brake force for engines.
Dynamic brake force is show in the same blue color that is used to indicate engines.
1 parent de91cc4 commit b96d6fa

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
107 Bytes
Loading

Source/RunActivity/Viewer3D/Popups/TrainForcesWindow.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,14 @@ private void UpdateWheelForceImage(TrainCar car, int carPosition)
414414
private void UpdateBrakeForceImage(TrainCar car, int carPosition)
415415
{
416416
var idx = 0; // neutral
417-
var absForceN = car.BrakeForceN;
417+
bool isDynamicBrakes = false;
418+
419+
var absForceN = Math.Abs(car.BrakeForceN); // using Math.Abs() for safety and consistency
420+
if (car.WagonType == TrainCar.WagonTypes.Engine && Math.Abs(car.DynamicBrakeForceN) > absForceN)
421+
{
422+
absForceN = Math.Abs(car.DynamicBrakeForceN);
423+
isDynamicBrakes = true;
424+
}
418425

419426
if (absForceN > 1000f && BrakeForceScaleN > 1000f) // exclude improbabl values
420427
{
@@ -425,8 +432,12 @@ private void UpdateBrakeForceImage(TrainCar car, int carPosition)
425432
if (idx < 0) { idx = 0; } else if (idx > 9) { idx = 9; }
426433
}
427434

428-
if (car.WagonType == TrainCar.WagonTypes.Engine) { BrakeForceBarGraph[carPosition].Source = new Rectangle(1 + idx * BarWidth, BarHight * 2, BarWidth, HalfBarHight); }
429-
else { BrakeForceBarGraph[carPosition].Source = new Rectangle(1 + idx * BarWidth, BarHight * 2 + HalfBarHight, BarWidth, HalfBarHight); }
435+
if (car.WagonType == TrainCar.WagonTypes.Engine)
436+
{
437+
if (isDynamicBrakes) { BrakeForceBarGraph[carPosition].Source = new Rectangle(1 + idx * BarWidth, BarHight * 2, BarWidth, HalfBarHight); }
438+
else { BrakeForceBarGraph[carPosition].Source = new Rectangle(1 + idx * BarWidth, BarHight * 2 + HalfBarHight, BarWidth, HalfBarHight); }
439+
}
440+
else { BrakeForceBarGraph[carPosition].Source = new Rectangle(1 + idx * BarWidth, BarHight * 2 + HalfBarHight * 2, BarWidth, HalfBarHight); }
430441
}
431442
}
432443
}

0 commit comments

Comments
 (0)