Skip to content

Commit a116284

Browse files
committed
Adjust fuel consumption so that it will operate whilever the diesel engine is running
1 parent 55f3ff8 commit a116284

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -636,18 +636,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
636636
TractiveForceN = 0;
637637
}
638638

639-
DieselFlowLps = DieselEngines.DieselFlowLps;
640-
partialFuelConsumption += DieselEngines.DieselFlowLps * elapsedClockSeconds;
641-
if (partialFuelConsumption >= 0.1)
642-
{
643-
DieselLevelL -= partialFuelConsumption;
644-
partialFuelConsumption = 0;
645-
}
646-
if (DieselLevelL <= 0.0f)
647-
{
648-
SignalEvent(Event.EnginePowerOff);
649-
DieselEngines.HandleEvent(PowerSupplyEvent.StopEngine);
650-
}
651639
}
652640
else
653641
{
@@ -662,6 +650,24 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
662650
w = 0;
663651
AverageForceN = w * AverageForceN + (1 - w) * TractiveForceN;
664652
}
653+
654+
// Calculate fuel consumption will occur unless diesel engine is stopped
655+
if (LocomotivePowerSupply.MainPowerSupplyOn)
656+
{
657+
DieselFlowLps = DieselEngines.DieselFlowLps;
658+
partialFuelConsumption += DieselEngines.DieselFlowLps * elapsedClockSeconds;
659+
if (partialFuelConsumption >= 0.1)
660+
{
661+
DieselLevelL -= partialFuelConsumption;
662+
partialFuelConsumption = 0;
663+
}
664+
// stall engine if fuel runs out
665+
if (DieselLevelL <= 0.0f)
666+
{
667+
SignalEvent(Event.EnginePowerOff);
668+
DieselEngines.HandleEvent(PowerSupplyEvent.StopEngine);
669+
}
670+
}
665671
}
666672

667673
/// <summary>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,8 @@ public void Update(float elapsedClockSeconds)
10851085
if ((State != DieselEngineState.Starting) && (RealRPM == 0f))
10861086
State = DieselEngineState.Stopped;
10871087

1088-
if ((State == DieselEngineState.Stopped) || (State == DieselEngineState.Stopping) || ((State == DieselEngineState.Starting) && (RealRPM < StartingRPM)))
1088+
// fuel consumption will occur when engine is running above the starting rpm
1089+
if ((State == DieselEngineState.Stopped) || ((State == DieselEngineState.Stopping) && (RealRPM < StartingRPM)) || ((State == DieselEngineState.Starting) && (RealRPM < StartingRPM)))
10891090
{
10901091
ExhaustParticles = 0;
10911092
DieselFlowLps = 0;

0 commit comments

Comments
 (0)