Skip to content

Commit

Permalink
Merge pull request #507 from peternewell/brake-fix#1
Browse files Browse the repository at this point in the history
Correct an issue with independent brake not working
  • Loading branch information
twpol authored Oct 3, 2021
2 parents 41d3f0c + 80b98a3 commit 4cb974f
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,7 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra
int last = -1;
train.FindLeadLocomotives(ref first, ref last);
float sumpv = 0;
float summainrespv = 0;
float sumv = 0;
float summainresv = 0;
int continuousFromInclusive = 0;
int continuousToExclusive = train.Cars.Count;
for (int i = 0; i < train.Cars.Count; i++)
Expand Down Expand Up @@ -857,21 +855,11 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra
sumv += brakeSystem.BrakePipeVolumeM3;
sumpv += brakeSystem.BrakePipeVolumeM3 * brakeSystem.BrakeLine2PressurePSI;

summainresv += brakeSystem.BrakePipeVolumeM3;

if (lead != null)
{
summainrespv += brakeSystem.BrakePipeVolumeM3 * lead.MainResPressurePSI;
}

var eng = train.Cars[i] as MSTSLocomotive;
if (eng != null)
{
sumv += eng.MainResVolumeM3;
sumpv += eng.MainResVolumeM3 * eng.MainResPressurePSI;

summainresv += eng.MainResVolumeM3;
summainrespv += eng.MainResVolumeM3 * eng.MainResPressurePSI;
}
}

Expand Down Expand Up @@ -922,14 +910,12 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra
if (sumv > 0)
{
sumpv /= sumv;
summainrespv /= summainresv;
}

if (!train.Cars[continuousFromInclusive].BrakeSystem.FrontBrakeHoseConnected && train.Cars[continuousFromInclusive].BrakeSystem.AngleCockAOpen
|| (continuousToExclusive == train.Cars.Count || !train.Cars[continuousToExclusive].BrakeSystem.FrontBrakeHoseConnected) && train.Cars[continuousToExclusive - 1].BrakeSystem.AngleCockBOpen)
{
sumpv = 0;
summainrespv = 0;
}

// Propagate main reservoir pipe (2) data
Expand All @@ -946,7 +932,8 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra

train.Cars[i].BrakeSystem.BrakeLine2PressurePSI = sumpv;
if (sumpv != 0 && train.Cars[i] is MSTSLocomotive)
(train.Cars[i] as MSTSLocomotive).MainResPressurePSI = summainrespv;
(train.Cars[i] as MSTSLocomotive).MainResPressurePSI = sumpv;

}
else
{
Expand Down

0 comments on commit 4cb974f

Please sign in to comment.