@@ -1644,7 +1644,8 @@ public override void Initialize()
16441644 // for airtwinpipe system, make sure that a value is set for it
16451645 if ( MaximumMainReservoirPipePressurePSI == 0 )
16461646 {
1647- MaximumMainReservoirPipePressurePSI = MaxMainResPressurePSI ;
1647+ // Add 5 psi to account for main res overcharging that might happen
1648+ MaximumMainReservoirPipePressurePSI = MaxMainResPressurePSI + 5.0f ;
16481649 if ( Simulator . Settings . VerboseConfigurationMessages )
16491650 {
16501651 Trace . TraceInformation ( "AirBrakeMaxMainResPipePressure not set in ENG file, set to default pressure of {0}." , FormatStrings . FormatPressure ( MaximumMainReservoirPipePressurePSI , PressureUnit . PSI , MainPressureUnit , true ) ) ;
@@ -2694,31 +2695,37 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
26942695 }
26952696 }
26962697
2697- // Turn compressor on and off
2698- if ( MainResPressurePSI < CompressorRestartPressurePSI && LocomotivePowerSupply . AuxiliaryPowerSupplyState == PowerSupplyState . PowerOn && ! CompressorIsOn )
2698+ // Determine compressor synchronization
2699+ bool syncCompressor = false ;
2700+
2701+ // Compressor synchronization is ignored if 5 psi above the high setpoint
2702+ if ( MainResPressurePSI < MaxMainResPressurePSI + 5.0f && LocomotivePowerSupply . AuxiliaryPowerSupplyState == PowerSupplyState . PowerOn )
26992703 {
2700- SignalEvent ( Event . CompressorOn ) ;
27012704 foreach ( List < TrainCar > locoGroup in Train . LocoGroups )
27022705 {
2703- // Synchronize compressor between coupled locomotives
2704- if ( locoGroup . Contains ( this as TrainCar ) )
2706+ // Only synchronize in a group of locomotives directly connected
2707+ // or synchronize between any two locomotives with MU controlled mode
2708+ foreach ( TrainCar locoCar in locoGroup )
27052709 {
2706- foreach ( TrainCar locoCar in locoGroup )
2707- if ( locoCar is MSTSLocomotive loco && loco . LocomotivePowerSupply . AuxiliaryPowerSupplyOn && ! loco . CompressorIsOn )
2708- loco . SignalEvent ( Event . CompressorOn ) ;
2709- }
2710- else if ( CompressorIsMUControlled ) // Synchronize compressor between remote groups if configured to do so
2711- {
2712- foreach ( TrainCar remoteLocoCar in locoGroup )
2713- if ( remoteLocoCar is MSTSLocomotive remoteLoco && remoteLoco . LocomotivePowerSupply . AuxiliaryPowerSupplyOn && ! remoteLoco . CompressorIsOn && remoteLoco . CompressorIsMUControlled )
2714- remoteLoco . SignalEvent ( Event . CompressorOn ) ;
2710+ if ( locoCar is MSTSLocomotive loco )
2711+ syncCompressor |= ( locoGroup . Contains ( this as TrainCar ) || CompressorIsMUControlled && loco . CompressorIsMUControlled )
2712+ && loco . CompressorIsOn && loco . MainResPressurePSI < loco . MaxMainResPressurePSI ;
2713+
2714+ // No need to check repeatedly if we already know to sync compressors
2715+ if ( syncCompressor )
2716+ break ;
27152717 }
2718+ if ( syncCompressor )
2719+ break ;
27162720 }
27172721 }
2718- else if ( ( MainResPressurePSI >= MaxMainResPressurePSI || LocomotivePowerSupply . AuxiliaryPowerSupplyState != PowerSupplyState . PowerOn ) && CompressorIsOn )
2719- {
2722+
2723+ if ( ( MainResPressurePSI < CompressorRestartPressurePSI || ( syncCompressor && MainResPressurePSI < MaxMainResPressurePSI ) )
2724+ && LocomotivePowerSupply . AuxiliaryPowerSupplyState == PowerSupplyState . PowerOn && ! CompressorIsOn )
2725+ SignalEvent ( Event . CompressorOn ) ;
2726+ else if ( ( ( MainResPressurePSI >= MaxMainResPressurePSI && ! syncCompressor )
2727+ || LocomotivePowerSupply . AuxiliaryPowerSupplyState != PowerSupplyState . PowerOn ) && CompressorIsOn )
27202728 SignalEvent ( Event . CompressorOff ) ;
2721- }
27222729
27232730 if ( CompressorIsOn )
27242731 MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate ;
0 commit comments