Skip to content

Commit c10a065

Browse files
committed
Initialise control locomotive compressor elements
1 parent a0ed396 commit c10a065

File tree

1 file changed

+28
-36
lines changed

1 file changed

+28
-36
lines changed

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

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ public float OdometerM
366366
public float CombinedControlSplitPosition;
367367
public bool HasSmoothStruc;
368368

369+
bool controlTrailerBrakeSystemSet = false;
370+
369371
public float MaxContinuousForceN;
370372
public float SpeedOfMaxContinuousForceMpS; // Speed where maximum tractive effort occurs
371373
public float MSTSSpeedOfMaxContinuousForceMpS; // Speed where maximum tractive effort occurs - MSTS parameter if used
@@ -1308,48 +1310,14 @@ public override void Initialize()
13081310

13091311
if (MaxMainResPressurePSI == 0)
13101312
{
1311-
if (EngineType == EngineTypes.Control)
1312-
{
1313-
FindControlActiveLocomotive();
1314-
1315-
if( ControlActiveLocomotive != null)
1316-
{
1317-
MaxMainResPressurePSI = ControlActiveLocomotive.MaxMainResPressurePSI; // Set maximum reservoir pressure from active locomotive
1318-
}
1319-
else
1320-
{
1321-
MaxMainResPressurePSI = 130;
1322-
}
1323-
}
1324-
else
1325-
{
1326-
MaxMainResPressurePSI = 130;
1327-
}
1328-
1313+
MaxMainResPressurePSI = 130;
13291314
}
13301315

13311316
MainResPressurePSI = MaxMainResPressurePSI;
13321317

13331318
if (MainResVolumeM3 == 0)
13341319
{
1335-
if (EngineType == EngineTypes.Control)
1336-
{
1337-
FindControlActiveLocomotive();
1338-
1339-
if (ControlActiveLocomotive != null)
1340-
{
1341-
MainResVolumeM3 = ControlActiveLocomotive.MainResVolumeM3;
1342-
}
1343-
else
1344-
{
1345-
MainResVolumeM3 = 0.3f;
1346-
}
1347-
}
1348-
else
1349-
{
1350-
MainResVolumeM3 = 0.3f;
1351-
}
1352-
1320+
MainResVolumeM3 = 0.3f;
13531321
}
13541322

13551323
// Initialise Brake Pipe Charging Rate
@@ -1631,6 +1599,30 @@ public void DynamicBrakeBlending(float elapsedClockSeconds)
16311599
/// </summary>
16321600
public override void Update(float elapsedClockSeconds)
16331601
{
1602+
// A control car typically doesn't have its own compressor and relies on the attached power car. However OR uses the lead locomotive as the reference car for compressor calculations.
1603+
// Hence whilst users are encouraged to leave these parameters out of the ENG file, they need to be setup for OR to work correctly.
1604+
// Some parameters need to be split across the unpowered and powered car for correct timing and volume calculations.
1605+
// This setup loop is only processed the first time that update is run.
1606+
if (EngineType == EngineTypes.Control && !controlTrailerBrakeSystemSet)
1607+
{
1608+
FindControlActiveLocomotive();
1609+
1610+
if (ControlActiveLocomotive != null)
1611+
{
1612+
// Split reservoir volume across the power car and the active locomotive
1613+
MainResVolumeM3 = ControlActiveLocomotive.MainResVolumeM3 / 2;
1614+
ControlActiveLocomotive.MainResVolumeM3 = MainResVolumeM3;
1615+
1616+
MaxMainResPressurePSI = ControlActiveLocomotive.MaxMainResPressurePSI;
1617+
MainResPressurePSI = MaxMainResPressurePSI;
1618+
ControlActiveLocomotive.MainResPressurePSI = MainResPressurePSI;
1619+
controlTrailerBrakeSystemSet = true;
1620+
CompressorRestartPressurePSI = ControlActiveLocomotive.CompressorRestartPressurePSI;
1621+
MainResChargingRatePSIpS = ControlActiveLocomotive.MainResChargingRatePSIpS;
1622+
}
1623+
}
1624+
1625+
16341626
TrainControlSystem.Update(elapsedClockSeconds);
16351627

16361628
LocomotivePowerSupply?.Update(elapsedClockSeconds);

0 commit comments

Comments
 (0)