@@ -132,6 +132,7 @@ public enum SoundState
132132 public float UnloadingSpeedMpS ;
133133 public float MainResPressurePSI = 130 ;
134134 public bool CompressorIsOn ;
135+ public bool CompressorIsMechanical = false ;
135136 public float AverageForceN ;
136137 public float PowerOnDelayS ;
137138 public bool CabLightOn ;
@@ -837,6 +838,12 @@ public override void Parse(string lowercasetoken, STFReader stf)
837838 case "engine(airbrakesmainmaxairpressure" : MainResPressurePSI = MaxMainResPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
838839 case "engine(airbrakescompressorrestartpressure" : CompressorRestartPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
839840 case "engine(airbrakesaircompressorpowerrating" : CompressorChargingRateM3pS = Me3 . FromFt3 ( stf . ReadFloatBlock ( STFReader . UNITS . VolumeDefaultFT3 , null ) ) ; break ;
841+ case "engine(airbrakesiscompressorelectricormechanical" : var compressorMechanical = stf . ReadIntBlock ( null ) ;
842+ if ( compressorMechanical == 1 )
843+ {
844+ CompressorIsMechanical = true ;
845+ }
846+ break ;
840847 case "engine(trainpipeleakrate" : TrainBrakePipeLeakPSIorInHgpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , null ) ; break ;
841848 case "engine(vacuumbrakesvacuumpumpresistance" : VacuumPumpResistanceN = stf . ReadFloatBlock ( STFReader . UNITS . Force , null ) ; break ;
842849
@@ -1016,6 +1023,7 @@ public override void Copy(MSTSWagon copy)
10161023
10171024 WheelslipCausesThrottleDown = locoCopy . WheelslipCausesThrottleDown ;
10181025
1026+ CompressorIsMechanical = locoCopy . CompressorIsMechanical ;
10191027 CompressorRestartPressurePSI = locoCopy . CompressorRestartPressurePSI ;
10201028 TrainBrakePipeLeakPSIorInHgpS = locoCopy . TrainBrakePipeLeakPSIorInHgpS ;
10211029 MaxMainResPressurePSI = locoCopy . MaxMainResPressurePSI ;
@@ -2286,8 +2294,32 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
22862294 else if ( ( MainResPressurePSI > MaxMainResPressurePSI || LocomotivePowerSupply . AuxiliaryPowerSupplyState != PowerSupplyState . PowerOn ) && CompressorIsOn )
22872295 SignalEvent ( Event . CompressorOff ) ;
22882296
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 ;
2301+
2302+ if ( CompressorIsMechanical && ( EngineType == EngineTypes . Control || EngineType == EngineTypes . Diesel ) )
2303+ {
2304+ if ( EngineType == EngineTypes . Control )
2305+ {
2306+ FindControlActiveLocomotive ( ) ;
2307+
2308+ if ( ControlActiveLocomotive != null )
2309+ {
2310+ var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive ;
2311+ reservoirChargingRate = ( activeloco . DieselEngines [ 0 ] . RealRPM / activeloco . DieselEngines [ 0 ] . MaxRPM ) * MainResChargingRatePSIpS ;
2312+ }
2313+ }
2314+ else
2315+ {
2316+ var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
2317+ reservoirChargingRate = ( mstsDieselLocomotive . DieselEngines [ 0 ] . RealRPM / mstsDieselLocomotive . DieselEngines [ 0 ] . MaxRPM ) * MainResChargingRatePSIpS ;
2318+ }
2319+ }
2320+
22892321 if ( CompressorIsOn )
2290- MainResPressurePSI += elapsedClockSeconds * MainResChargingRatePSIpS ;
2322+ MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate ;
22912323 }
22922324
22932325 /// <summary>
0 commit comments