Skip to content

Commit ba578cd

Browse files
authored
Merge pull request #550 from peternewell/diesel-fuel
Adjust diesel fuel consumption
2 parents 30f7ec8 + 52eab21 commit ba578cd

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

Lines changed: 15 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,21 @@ 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+
DieselFlowLps = DieselEngines.DieselFlowLps;
656+
partialFuelConsumption += DieselEngines.DieselFlowLps * elapsedClockSeconds;
657+
if (partialFuelConsumption >= 0.1)
658+
{
659+
DieselLevelL -= partialFuelConsumption;
660+
partialFuelConsumption = 0;
661+
}
662+
// stall engine if fuel runs out
663+
if (DieselLevelL <= 0.0f)
664+
{
665+
SignalEvent(Event.EnginePowerOff);
666+
DieselEngines.HandleEvent(PowerSupplyEvent.StopEngine);
667+
}
665668
}
666669

667670
/// <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)