Skip to content

Commit 69b8ccc

Browse files
committed
Adjustments to power displays for DM
1 parent 05af358 commit 69b8ccc

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,10 @@ public string GetStatus()
419419

420420
if (Locomotive.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
421421
{
422-
result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), Simulator.Catalog.GetString(" "));
422+
result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), Simulator.Catalog.GetString(" ")); // Leave maximum power out
423423
foreach (var eng in DEList)
424424
{
425-
// Power(Watts) = Torque(Nm) * rpm / 9.54.
426-
var tempPowerDisplay = eng.GearBox.torqueCurveMultiplier * eng.DieselTorqueTab[eng.RealRPM] * eng.RealRPM / 9.54f;
427-
tempPowerDisplay = MathHelper.Clamp(tempPowerDisplay, 0, MaxOutputPowerW); // Clamp throttle setting within bounds
428-
result.AppendFormat("\t{0}", FormatStrings.FormatPower(tempPowerDisplay, Locomotive.IsMetric, false, false));
425+
result.AppendFormat("\t{0}", FormatStrings.FormatPower(eng.CurrentDieselOutputPowerW, Locomotive.IsMetric, false, false));
429426
}
430427
}
431428
else
@@ -923,14 +920,7 @@ public float LoadPercent
923920
{
924921
get
925922
{
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-
}
923+
return CurrentDieselOutputPowerW <= 0f ? 0f : ((OutputPowerW + (Locomotive.DieselEngines.NumOfActiveEngines > 0 ? Locomotive.LocomotivePowerSupply.ElectricTrainSupplyPowerW / Locomotive.DieselEngines.NumOfActiveEngines : 0f)) * 100f / CurrentDieselOutputPowerW);
934924
}
935925
}
936926
/// <summary>
@@ -1440,7 +1430,9 @@ public void Update(float elapsedClockSeconds)
14401430
// so set output power based upon throttle demanded power
14411431
if (HasGearBox && Locomotive.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
14421432
{
1443-
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
14441436
}
14451437

14461438
if (Locomotive.DieselEngines.NumOfActiveEngines > 0)

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,20 +310,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime, bo
310310
LocomotiveGraphsThrottle.AddSample(loco.ThrottlePercent * 0.01f);
311311
if (locoD != null)
312312
{
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;
319313
LocomotiveGraphsInputPower.AddSample(locoD.DieselEngines.MaxOutputPowerW / locoD.DieselEngines.MaxPowerW);
320314
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-
}
327315
}
328316
if (locoE != null)
329317
{

0 commit comments

Comments
 (0)