Skip to content

Commit 757410a

Browse files
authored
Merge pull request #504 from openrails/release/1.4
Merge pull request #502 from peternewell/air-compressor#1
2 parents 1ac9e37 + c12c5ed commit 757410a

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
23112311
{
23122312

23132313
if (CompressorIsMechanical && (EngineType == EngineTypes.Control || EngineType == EngineTypes.Diesel))
2314-
{
2314+
{
23152315
// For a mechanical compressor (typically fitted to a diesel locomotive) the charging rate will be related to the RpM of the diesel engine, and therefore
23162316
// derated by an amount equivalent to the diesel RpM.
23172317
// All other locomotive types it will be the full charging rate for the reservoir
@@ -2325,17 +2325,37 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
23252325
if (ControlActiveLocomotive != null)
23262326
{
23272327
var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive;
2328+
2329+
// Compressors only operate when the diesel engine is running, otherwise they are off
2330+
if (activeloco.DieselEngines[0].State == DieselEngineState.Running && !CompressorIsOn)
2331+
SignalEvent(Event.CompressorOn);
2332+
else if (activeloco.DieselEngines[0].State != DieselEngineState.Running && CompressorIsOn)
2333+
SignalEvent(Event.CompressorOff);
2334+
2335+
// Set charging rate depending upon compressor rpm
23282336
reservoirChargingRate = (activeloco.DieselEngines[0].RealRPM / activeloco.DieselEngines[0].MaxRPM) * MainResChargingRatePSIpS;
23292337
}
23302338
}
23312339
else
23322340
{
23332341
// Powered locomotive use thereselves
23342342
var mstsDieselLocomotive = this as MSTSDieselLocomotive;
2343+
2344+
// Compressors only operate when the diesel engine is running, otherwise they are off
2345+
if (mstsDieselLocomotive.DieselEngines[0].State == DieselEngineState.Running && !CompressorIsOn)
2346+
SignalEvent(Event.CompressorOn);
2347+
else if (mstsDieselLocomotive.DieselEngines[0].State != DieselEngineState.Running && CompressorIsOn)
2348+
SignalEvent(Event.CompressorOff);
2349+
2350+
// Set charging rate depending upon compressor rpm
23352351
reservoirChargingRate = (mstsDieselLocomotive.DieselEngines[0].RealRPM / mstsDieselLocomotive.DieselEngines[0].MaxRPM) * MainResChargingRatePSIpS;
23362352
}
23372353

2338-
MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate;
2354+
// Only change reservoir pressure if compressor is running
2355+
if (CompressorIsOn)
2356+
{
2357+
MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate;
2358+
}
23392359

23402360
// Compressor runs continuously, and excess air pressure is exhausted to atmosphere once max pressure is reached.
23412361
MainResPressurePSI = MathHelper.Clamp(MainResPressurePSI, 0.0f, MaxMainResPressurePSI);

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -848,17 +848,6 @@ void TextPageBrakeInfo(TableData table)
848848
car.CarID
849849
));
850850
}
851-
else if ((car as MSTSLocomotive).CompressorIsMechanical)
852-
{
853-
// Mechanical compressor run continuously so no point having on and off indication.
854-
TableAddLines(table, String.Format("{0}\t{1}\t{2}\t\t{3}",
855-
Viewer.Catalog.GetString("Loco"),
856-
car.CarID,
857-
858-
Viewer.Catalog.GetString("Main reservoir"),
859-
FormatStrings.FormatPressure((car as MSTSLocomotive).MainResPressurePSI, PressureUnit.PSI, (car as MSTSLocomotive).BrakeSystemPressureUnits[BrakeSystemComponent.MainReservoir], true)));
860-
861-
}
862851
else
863852
{
864853
TableAddLines(table, String.Format("{0}\t{1}\t{2}\t\t{3}\t{4}\t\t{5}",

0 commit comments

Comments
 (0)