Skip to content

Commit 05af358

Browse files
committed
Adjust HuD to display relevant parameters for DM locomotive
1 parent 68f4736 commit 05af358

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,9 @@ 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(" "));
425423
foreach (var eng in DEList)
426424
{
427425
// Power(Watts) = Torque(Nm) * rpm / 9.54.
@@ -432,6 +430,7 @@ public string GetStatus()
432430
}
433431
else
434432
{
433+
result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), FormatStrings.FormatPower(MaxOutputPowerW, Locomotive.IsMetric, false, false));
435434
foreach (var eng in DEList)
436435
result.AppendFormat("\t{0}", FormatStrings.FormatPower(eng.CurrentDieselOutputPowerW, Locomotive.IsMetric, false, false));
437436
}
@@ -924,7 +923,14 @@ public float LoadPercent
924923
{
925924
get
926925
{
927-
return CurrentDieselOutputPowerW <= 0f ? 0f : ((OutputPowerW + (Locomotive.DieselEngines.NumOfActiveEngines > 0 ? Locomotive.LocomotivePowerSupply.ElectricTrainSupplyPowerW / Locomotive.DieselEngines.NumOfActiveEngines : 0f)) * 100f / CurrentDieselOutputPowerW);
926+
if (Locomotive.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
927+
{
928+
return CurrentDieselOutputPowerW <= 0f ? 0f : (((Locomotive.MotiveForceN * Locomotive.SpeedMpS) + (Locomotive.DieselEngines.NumOfActiveEngines > 0 ? Locomotive.LocomotivePowerSupply.ElectricTrainSupplyPowerW / Locomotive.DieselEngines.NumOfActiveEngines : 0f)) * 100f / CurrentDieselOutputPowerW);
929+
}
930+
else
931+
{
932+
return CurrentDieselOutputPowerW <= 0f ? 0f : ((OutputPowerW + (Locomotive.DieselEngines.NumOfActiveEngines > 0 ? Locomotive.LocomotivePowerSupply.ElectricTrainSupplyPowerW / Locomotive.DieselEngines.NumOfActiveEngines : 0f)) * 100f / CurrentDieselOutputPowerW);
933+
}
928934
}
929935
}
930936
/// <summary>

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,20 @@ 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+
if (locoD.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
314+
{
315+
// Power for a DM is different to a DE, the following adjusts the display accordingly.
316+
// If multiple diesel engines then this code may not work
317+
// Power(Watts) = Torque(Nm) * rpm / 9.54.
318+
var tempPowerDisplay = locoD.DieselEngines[0].GearBox.torqueCurveMultiplier * locoD.DieselEngines[0].DieselTorqueTab[locoD.DieselEngines[0].RealRPM] * locoD.DieselEngines[0].RealRPM / 9.54f;
319+
LocomotiveGraphsInputPower.AddSample(locoD.DieselEngines.MaxOutputPowerW / locoD.DieselEngines.MaxPowerW);
320+
LocomotiveGraphsOutputPower.AddSample(locoD.DieselEngines.PowerW / locoD.DieselEngines.MaxPowerW);
321+
}
322+
else
323+
{
324+
LocomotiveGraphsInputPower.AddSample(locoD.DieselEngines.MaxOutputPowerW / locoD.DieselEngines.MaxPowerW);
325+
LocomotiveGraphsOutputPower.AddSample(locoD.DieselEngines.PowerW / locoD.DieselEngines.MaxPowerW);
326+
}
315327
}
316328
if (locoE != null)
317329
{

0 commit comments

Comments
 (0)