@@ -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 ) ;
0 commit comments