Skip to content

Commit a18cc49

Browse files
committed
Further adjustments to mechanical compressors
1 parent f3b85a6 commit a18cc49

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,18 +2289,15 @@ protected virtual void UpdateVacuumExhauster(float elapsedClockSeconds)
22892289
/// </summary>
22902290
protected virtual void UpdateCompressor(float elapsedClockSeconds)
22912291
{
2292-
if (MainResPressurePSI < CompressorRestartPressurePSI && LocomotivePowerSupply.AuxiliaryPowerSupplyState == PowerSupplyState.PowerOn && !CompressorIsOn)
2293-
SignalEvent(Event.CompressorOn);
2294-
else if ((MainResPressurePSI > MaxMainResPressurePSI || LocomotivePowerSupply.AuxiliaryPowerSupplyState != PowerSupplyState.PowerOn) && CompressorIsOn)
2295-
SignalEvent(Event.CompressorOff);
2296-
2297-
// 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
2298-
// derated by an amount equivalent to the diesel RpM.
2299-
// All other locomotive types it will be the full charging rate for the reservoir
2300-
var reservoirChargingRate = MainResChargingRatePSIpS;
23012292

23022293
if (CompressorIsMechanical && (EngineType == EngineTypes.Control || EngineType == EngineTypes.Diesel))
2303-
{
2294+
{
2295+
// 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
2296+
// derated by an amount equivalent to the diesel RpM.
2297+
// All other locomotive types it will be the full charging rate for the reservoir
2298+
var reservoirChargingRate = MainResChargingRatePSIpS;
2299+
2300+
// Control car uses the attached active locomotive
23042301
if (EngineType == EngineTypes.Control)
23052302
{
23062303
FindControlActiveLocomotive();
@@ -2313,13 +2310,27 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
23132310
}
23142311
else
23152312
{
2313+
// Powered locomotive use thereselves
23162314
var mstsDieselLocomotive = this as MSTSDieselLocomotive;
23172315
reservoirChargingRate = (mstsDieselLocomotive.DieselEngines[0].RealRPM / mstsDieselLocomotive.DieselEngines[0].MaxRPM) * MainResChargingRatePSIpS;
23182316
}
2319-
}
23202317

2321-
if (CompressorIsOn)
23222318
MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate;
2319+
2320+
// Compressor runs continuously, and excess air pressure is exhausted to atmosphere once max pressure is reached.
2321+
MainResPressurePSI = MathHelper.Clamp(MainResPressurePSI, 0.0f, MaxMainResPressurePSI);
2322+
2323+
}
2324+
else // Non-mechanical compressors
2325+
{
2326+
if (MainResPressurePSI < CompressorRestartPressurePSI && LocomotivePowerSupply.AuxiliaryPowerSupplyState == PowerSupplyState.PowerOn && !CompressorIsOn)
2327+
SignalEvent(Event.CompressorOn);
2328+
else if ((MainResPressurePSI > MaxMainResPressurePSI || LocomotivePowerSupply.AuxiliaryPowerSupplyState != PowerSupplyState.PowerOn) && CompressorIsOn)
2329+
SignalEvent(Event.CompressorOff);
2330+
2331+
if (CompressorIsOn)
2332+
MainResPressurePSI += elapsedClockSeconds * MainResChargingRatePSIpS;
2333+
}
23232334
}
23242335

23252336
/// <summary>

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@ void TextPageBrakeInfo(TableData table)
840840
var car = train.Cars[i];
841841
if (car is MSTSLocomotive && car != Viewer.PlayerLocomotive)
842842
{
843-
844843
if ((car as MSTSLocomotive).EngineType == TrainCar.EngineTypes.Control)
845844
{
846845
// Control cars typically don't have reservoirs
@@ -849,6 +848,17 @@ void TextPageBrakeInfo(TableData table)
849848
car.CarID
850849
));
851850
}
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+
}
852862
else
853863
{
854864
TableAddLines(table, String.Format("{0}\t{1}\t{2}\t\t{3}\t{4}\t\t{5}",
@@ -858,9 +868,7 @@ void TextPageBrakeInfo(TableData table)
858868
Viewer.Catalog.GetString("Main reservoir"),
859869
FormatStrings.FormatPressure((car as MSTSLocomotive).MainResPressurePSI, PressureUnit.PSI, (car as MSTSLocomotive).BrakeSystemPressureUnits[BrakeSystemComponent.MainReservoir], true),
860870
Viewer.Catalog.GetString("Compressor"),
861-
(car as MSTSLocomotive).CompressorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off")));
862-
863-
871+
(car as MSTSLocomotive).CompressorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off")));
864872
}
865873
}
866874
}

0 commit comments

Comments
 (0)