Skip to content

Commit 6908fa6

Browse files
authored
Merge pull request #619 from peternewell/diesel-mechanic#3
Adjust HuD to display relevant parameters for DM locomotive
2 parents 897fb9e + ea10bfc commit 6908fa6

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSDieselLocomotive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
712712
else
713713
{
714714

715-
if (DieselEngines.HasGearBox)
715+
if (DieselEngines.HasGearBox && DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
716716
{
717717
TractiveForceN = DieselEngines.TractiveForceN;
718718
}

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselEngine.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,21 +417,17 @@ public string GetStatus()
417417
foreach (var eng in DEList)
418418
result.AppendFormat("\t{0}", Simulator.Catalog.GetParticularString("Engine", GetStringAttribute.GetPrettyName(eng.State)));
419419

420-
result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), FormatStrings.FormatPower(MaxOutputPowerW, Locomotive.IsMetric, false, false));
421-
422420
if (Locomotive.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
423421
{
424-
422+
result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), Simulator.Catalog.GetString(" ")); // Leave maximum power out
425423
foreach (var eng in DEList)
426424
{
427-
// Power(Watts) = Torque(Nm) * rpm / 9.54.
428-
var tempPowerDisplay = eng.GearBox.torqueCurveMultiplier * eng.DieselTorqueTab[eng.RealRPM] * eng.RealRPM / 9.54f;
429-
tempPowerDisplay = MathHelper.Clamp(tempPowerDisplay, 0, MaxOutputPowerW); // Clamp throttle setting within bounds
430-
result.AppendFormat("\t{0}", FormatStrings.FormatPower(tempPowerDisplay, Locomotive.IsMetric, false, false));
425+
result.AppendFormat("\t{0}", FormatStrings.FormatPower(eng.CurrentDieselOutputPowerW, Locomotive.IsMetric, false, false));
431426
}
432427
}
433428
else
434429
{
430+
result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), FormatStrings.FormatPower(MaxOutputPowerW, Locomotive.IsMetric, false, false));
435431
foreach (var eng in DEList)
436432
result.AppendFormat("\t{0}", FormatStrings.FormatPower(eng.CurrentDieselOutputPowerW, Locomotive.IsMetric, false, false));
437433
}
@@ -1434,7 +1430,9 @@ public void Update(float elapsedClockSeconds)
14341430
// so set output power based upon throttle demanded power
14351431
if (HasGearBox && Locomotive.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
14361432
{
1437-
CurrentDieselOutputPowerW = (ThrottleRPMTab[demandedThrottlePercent] - IdleRPM) / (MaxRPM - IdleRPM) * MaximumDieselPowerW * (1 - Locomotive.PowerReduction);
1433+
// Power(Watts) = Torque(Nm) * rpm / 9.54.
1434+
CurrentDieselOutputPowerW = GearBox.torqueCurveMultiplier * DieselTorqueTab[RealRPM] * RealRPM / 9.54f;
1435+
CurrentDieselOutputPowerW = MathHelper.Clamp(CurrentDieselOutputPowerW, 0, MaximumDieselPowerW); // Clamp throttle setting within bounds
14381436
}
14391437

14401438
if (Locomotive.DieselEngines.NumOfActiveEngines > 0)

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime, bo
310310
LocomotiveGraphsThrottle.AddSample(loco.ThrottlePercent * 0.01f);
311311
if (locoD != null)
312312
{
313-
LocomotiveGraphsInputPower.AddSample(locoD.DieselEngines.MaxOutputPowerW / locoD.DieselEngines.MaxPowerW);
314-
LocomotiveGraphsOutputPower.AddSample(locoD.DieselEngines.PowerW / locoD.DieselEngines.MaxPowerW);
313+
LocomotiveGraphsInputPower.AddSample(locoD.DieselEngines.MaxOutputPowerW / locoD.DieselEngines.MaxPowerW);
314+
LocomotiveGraphsOutputPower.AddSample(locoD.DieselEngines.PowerW / locoD.DieselEngines.MaxPowerW);
315315
}
316316
if (locoE != null)
317317
{

0 commit comments

Comments
 (0)