@@ -2311,7 +2311,7 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
2311
2311
{
2312
2312
2313
2313
if ( CompressorIsMechanical && ( EngineType == EngineTypes . Control || EngineType == EngineTypes . Diesel ) )
2314
- {
2314
+ {
2315
2315
// 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
2316
2316
// derated by an amount equivalent to the diesel RpM.
2317
2317
// All other locomotive types it will be the full charging rate for the reservoir
@@ -2325,17 +2325,37 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
2325
2325
if ( ControlActiveLocomotive != null )
2326
2326
{
2327
2327
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
2328
2336
reservoirChargingRate = ( activeloco . DieselEngines [ 0 ] . RealRPM / activeloco . DieselEngines [ 0 ] . MaxRPM ) * MainResChargingRatePSIpS ;
2329
2337
}
2330
2338
}
2331
2339
else
2332
2340
{
2333
2341
// Powered locomotive use thereselves
2334
2342
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
2335
2351
reservoirChargingRate = ( mstsDieselLocomotive . DieselEngines [ 0 ] . RealRPM / mstsDieselLocomotive . DieselEngines [ 0 ] . MaxRPM ) * MainResChargingRatePSIpS ;
2336
2352
}
2337
2353
2338
- MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate ;
2354
+ // Only change reservoir pressure if compressor is running
2355
+ if ( CompressorIsOn )
2356
+ {
2357
+ MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate ;
2358
+ }
2339
2359
2340
2360
// Compressor runs continuously, and excess air pressure is exhausted to atmosphere once max pressure is reached.
2341
2361
MainResPressurePSI = MathHelper . Clamp ( MainResPressurePSI , 0.0f , MaxMainResPressurePSI ) ;
0 commit comments