Skip to content

Commit

Permalink
Automatic merge of T1.5.1-413-g1daa6a7c6 and 21 pull requests
Browse files Browse the repository at this point in the history
- Pull request #570 at de7a14f: Experimental glTF 2.0 support with PBR lighting
- Pull request #757 at d9d75f4: Unify RailDriver code implementations
- Pull request #799 at dc03850: Consolidated wind simulation
- Pull request #802 at 4d198e4: Added support for activity location events to the TrackViewer
- Pull request #803 at 7157e08: Various adjustments to steam adhesion
- Pull request #813 at 7fdad38: Refactored garbage generators
- Pull request #815 at a5cc165: chore: Add GitHub automatic release notes configuration
- Pull request #818 at 23f3488: Allow independent drive axles for locomotives
- Pull request #821 at e0fa5a8: Adds suppression of safety valves
- Pull request #823 at 5e1c03b: Select track sound volume percent retained in .eng and .wag files
- Pull request #824 at f16ebed: Update Readme.md
- Pull request #825 at 29ed427: 2D Cabview controls for side viewpoints https://blueprints.launchpad.net/or/+spec/2dcabview-controls-for-side-views
- Pull request #829 at 434af02: Improvements for air brakes #3 - Emergency valves
- Pull request #830 at ceeaba7: Electric locomotive hot start
- Pull request #831 at c8927a4: preliminary version switchpanel on tablet
- Pull request #833 at 01aaca7: Implement brake relay valve
- Pull request #834 at 7a98eca: Replaces email service with FormSpark
- Pull request #835 at 70a32d8: Correct Brake Shoe Force Calculation
- Pull request #836 at 62e6d02: Adds policy on crashes and derailments
- Pull request #837 at 0497316: copies website policies to repo
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
  • Loading branch information
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 133 deletions.
110 changes: 63 additions & 47 deletions Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs
Expand Up @@ -87,7 +87,6 @@ public class MSTSWagon : TrainCar
public bool GenericItem1;
public bool GenericItem2;

Interpolator BrakeShoeFrictionFactor; // Factor of friction for wagon brake shoes
const float WaterLBpUKG = 10.0f; // lbs of water in 1 gal (uk)
float TempMassDiffRatio;

Expand Down Expand Up @@ -597,8 +596,38 @@ public virtual void LoadFromWagFile(string wagFilePath)

// Initialise key wagon parameters
MassKG = InitialMassKG;

MaxHandbrakeForceN = InitialMaxHandbrakeForceN;
if (MaxBrakeShoeForceN != 0 && BrakeShoeType != BrakeShoeTypes.Unknown)
{
MaxBrakeForceN = MaxBrakeShoeForceN;

if (Simulator.Settings.VerboseConfigurationMessages)
{
Trace.TraceInformation("BrakeShoeType set to {0}, with a MaxBrakeShoeForce of {1}", BrakeShoeType, FormatStrings.FormatForce(MaxBrakeForceN, IsMetric));
}

}
else
{
MaxBrakeForceN = InitialMaxBrakeForceN;

if (Simulator.Settings.VerboseConfigurationMessages)
{
Trace.TraceInformation("BrakeShoeType set to {0}, with a MaxBrakeForce of {1}", BrakeShoeType, FormatStrings.FormatForce(MaxBrakeForceN, IsMetric));
}
}

// Initialise number of brake shoes per wagon
if (NumberCarBrakeShoes == 0 && WagonType == WagonTypes.Engine)
{
NumberCarBrakeShoes = LocoNumDrvAxles * 4.0f; // Assume 4 brake shoes per axle
}
else if (NumberCarBrakeShoes == 0)
{
NumberCarBrakeShoes = WagonNumAxles * 4.0f; // Assume 4 brake shoes per axle
}

CentreOfGravityM = InitialCentreOfGravityM;

if (FreightAnimations != null)
Expand Down Expand Up @@ -670,7 +699,11 @@ public virtual void LoadFromWagFile(string wagFilePath)
LoadEmptyWagonFrontalAreaM2 = WagonFrontalAreaM2;
}

if (FreightAnimations.EmptyMaxBrakeForceN > 0)
if (FreightAnimations.EmptyMaxBrakeShoeForceN > 0)
{
LoadEmptyMaxBrakeForceN = FreightAnimations.EmptyMaxBrakeShoeForceN;
}
else if (FreightAnimations.EmptyMaxBrakeForceN > 0)
{
LoadEmptyMaxBrakeForceN = FreightAnimations.EmptyMaxBrakeForceN;
}
Expand Down Expand Up @@ -746,8 +779,11 @@ public virtual void LoadFromWagFile(string wagFilePath)
LoadFullWagonFrontalAreaM2 = WagonFrontalAreaM2;
}


if (FreightAnimations.FullPhysicsStaticOne.FullStaticMaxBrakeForceN > 0)
if (FreightAnimations.FullPhysicsStaticOne.FullStaticMaxBrakeShoeForceN > 0)
{
LoadFullMaxBrakeForceN = FreightAnimations.FullPhysicsStaticOne.FullStaticMaxBrakeShoeForceN;
}
else if (FreightAnimations.FullPhysicsStaticOne.FullStaticMaxBrakeForceN > 0)
{
LoadFullMaxBrakeForceN = FreightAnimations.FullPhysicsStaticOne.FullStaticMaxBrakeForceN;
}
Expand Down Expand Up @@ -833,8 +869,11 @@ public virtual void LoadFromWagFile(string wagFilePath)
LoadFullWagonFrontalAreaM2 = WagonFrontalAreaM2;
}


if (FreightAnimations.FullPhysicsContinuousOne.FullMaxBrakeForceN > 0)
if (FreightAnimations.FullPhysicsContinuousOne.FullMaxBrakeShoeForceN > 0)
{
LoadFullMaxBrakeForceN = FreightAnimations.FullPhysicsContinuousOne.FullMaxBrakeShoeForceN;
}
else if (FreightAnimations.FullPhysicsContinuousOne.FullMaxBrakeForceN > 0)
{
LoadFullMaxBrakeForceN = FreightAnimations.FullPhysicsContinuousOne.FullMaxBrakeForceN;
}
Expand Down Expand Up @@ -954,7 +993,6 @@ public virtual void LoadFromWagFile(string wagFilePath)
Trace.TraceInformation("Empty Values = Brake {0} Handbrake {1} DavisA {2} DavisB {3} DavisC {4} CoGY {5}", LoadEmptyMaxBrakeForceN, LoadEmptyMaxHandbrakeForceN, LoadEmptyORTSDavis_A, LoadEmptyORTSDavis_B, LoadEmptyORTSDavis_C, LoadEmptyCentreOfGravityM_Y);
Trace.TraceInformation("Full Values = Brake {0} Handbrake {1} DavisA {2} DavisB {3} DavisC {4} CoGY {5}", LoadFullMaxBrakeForceN, LoadFullMaxHandbrakeForceN, LoadFullORTSDavis_A, LoadFullORTSDavis_B, LoadFullORTSDavis_C, LoadFullCentreOfGravityM_Y);
#endif

}

// Determine whether or not to use the Davis friction model. Must come after freight animations are initialized.
Expand Down Expand Up @@ -1131,6 +1169,21 @@ public virtual void Parse(string lowercasetoken, STFReader stf)
case "wagon(ortsbrakeshoefriction": BrakeShoeFrictionFactor = new Interpolator(stf); break;
case "wagon(maxhandbrakeforce": InitialMaxHandbrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, null); break;
case "wagon(maxbrakeforce": InitialMaxBrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, null); break;
case "wagon(ortsmaxbrakeshoeforce": MaxBrakeShoeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, null); break;
case "engine(ortsnumbercarbrakeshoes": NumberCarBrakeShoes = stf.ReadIntBlock(null); break;
case "wagon(ortsbrakeshoetype":
stf.MustMatch("(");
var brakeShoeType = stf.ReadString();
try
{
BrakeShoeType = (BrakeShoeTypes)Enum.Parse(typeof(BrakeShoeTypes), brakeShoeType);
}
catch
{
STFException.TraceWarning(stf, "Assumed unknown brake shoe type " + brakeShoeType);
}
break;

case "wagon(ortswheelbrakeslideprotection":
// stf.MustMatch("(");
var brakeslideprotection = stf.ReadFloatBlock(STFReader.UNITS.None, null);
Expand Down Expand Up @@ -1458,6 +1511,7 @@ public virtual void Copy(MSTSWagon copy)
HasPassengerCapacity = copy.HasPassengerCapacity;
WagonType = copy.WagonType;
WagonSpecialType = copy.WagonSpecialType;
BrakeShoeType = copy.BrakeShoeType;
FreightShapeFileName = copy.FreightShapeFileName;
FreightAnimMaxLevelM = copy.FreightAnimMaxLevelM;
FreightAnimMinLevelM = copy.FreightAnimMinLevelM;
Expand Down Expand Up @@ -1500,6 +1554,8 @@ public virtual void Copy(MSTSWagon copy)
InitialMaxBrakeForceN = copy.InitialMaxBrakeForceN;
InitialMaxHandbrakeForceN = copy.InitialMaxHandbrakeForceN;
MaxBrakeForceN = copy.MaxBrakeForceN;
MaxBrakeShoeForceN = copy.MaxBrakeShoeForceN;
NumberCarBrakeShoes = copy.NumberCarBrakeShoes;
MaxHandbrakeForceN = copy.MaxHandbrakeForceN;
WindowDeratingFactor = copy.WindowDeratingFactor;
DesiredCompartmentTempSetpointC = copy.DesiredCompartmentTempSetpointC;
Expand Down Expand Up @@ -3965,46 +4021,6 @@ public override float GetFilledFraction(uint pickupType)
return fraction;
}

/// <summary>
/// Returns the Brake shoe coefficient.
/// </summary>

public override float GetUserBrakeShoeFrictionFactor()
{
var frictionfraction = 0.0f;
if ( BrakeShoeFrictionFactor == null)
{
frictionfraction = 0.0f;
}
else
{
frictionfraction = BrakeShoeFrictionFactor[MpS.ToKpH(AbsSpeedMpS)];
}

return frictionfraction;
}

/// <summary>
/// Returns the Brake shoe coefficient at zero speed.
/// </summary>

public override float GetZeroUserBrakeShoeFrictionFactor()
{
var frictionfraction = 0.0f;
if (BrakeShoeFrictionFactor == null)
{
frictionfraction = 0.0f;
}
else
{
frictionfraction = BrakeShoeFrictionFactor[0.0f];
}

return frictionfraction;
}



/// <summary>
/// Starts a continuous increase in controlled value.
/// </summary>
Expand Down
Expand Up @@ -789,22 +789,25 @@ public override void Update(float elapsedClockSeconds)
Car.Train.HUDWagonBrakeCylinderPSI = CylPressurePSI;
}

float f;
if (!Car.BrakesStuck)
{
f = Car.MaxBrakeForceN * Math.Min(CylPressurePSI / MaxCylPressurePSI, 1);
if (f < Car.MaxHandbrakeForceN * HandbrakePercent / 100)
f = Car.MaxHandbrakeForceN * HandbrakePercent / 100;
Car.BrakeShoeForceN = Car.MaxBrakeForceN * Math.Min(CylPressurePSI / MaxCylPressurePSI, 1);
if (Car.BrakeShoeForceN < Car.MaxHandbrakeForceN * HandbrakePercent / 100)
Car.BrakeShoeForceN = Car.MaxHandbrakeForceN * HandbrakePercent / 100;
}
else f = Math.Max(Car.MaxBrakeForceN, Car.MaxHandbrakeForceN / 2);
Car.BrakeRetardForceN = f * Car.BrakeShoeRetardCoefficientFrictionAdjFactor; // calculates value of force applied to wheel, independent of wheel skid
else Car.BrakeShoeForceN = Math.Max(Car.MaxBrakeForceN, Car.MaxHandbrakeForceN / 2);

float brakeShoeFriction = Car.GetBrakeShoeFrictionFactor();
Car.HuDBrakeShoeFriction = Car.GetBrakeShoeFrictionCoefficientHuD();

Car.BrakeRetardForceN = Car.BrakeShoeForceN * brakeShoeFriction; // calculates value of force applied to wheel, independent of wheel skid
if (Car.BrakeSkid) // Test to see if wheels are skiding to excessive brake force
{
Car.BrakeForceN = f * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
Car.BrakeForceN = Car.BrakeShoeForceN * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
}
else
{
Car.BrakeForceN = f * Car.BrakeShoeCoefficientFrictionAdjFactor; // In advanced adhesion model brake shoe coefficient varies with speed, in simple model constant force applied as per value in WAG file, will vary with wheel skid.
Car.BrakeForceN = Car.BrakeShoeForceN * brakeShoeFriction; // In advanced adhesion model brake shoe coefficient varies with speed, in simple model constant force applied as per value in WAG file, will vary with wheel skid.
}

// sound trigger checking runs every half second, to avoid the problems caused by the jumping BrakeLine1PressurePSI value, and also saves cpu time :)
Expand Down
Expand Up @@ -206,22 +206,30 @@ public override void Update(float elapsedClockSeconds)
}
}

float f;
if (!Car.BrakesStuck)
{
f = Car.MaxBrakeForceN * Math.Min(BrakeForceFraction, 1);
if (f < Car.MaxHandbrakeForceN * HandbrakePercent / 100)
f = Car.MaxHandbrakeForceN * HandbrakePercent / 100;
Car.BrakeShoeForceN = Car.MaxBrakeForceN * Math.Min(BrakeForceFraction, 1);
if (Car.BrakeShoeForceN < Car.MaxHandbrakeForceN * HandbrakePercent / 100)
{
Car.BrakeShoeForceN = Car.MaxHandbrakeForceN * HandbrakePercent / 100;
}
}
else f = Math.Max(Car.MaxBrakeForceN, Car.MaxHandbrakeForceN / 2);
Car.BrakeRetardForceN = f * Car.BrakeShoeRetardCoefficientFrictionAdjFactor; // calculates value of force applied to wheel, independent of wheel skid
else
{
Car.BrakeShoeForceN = Math.Max(Car.MaxBrakeForceN, Car.MaxHandbrakeForceN / 2);
}

float brakeShoeFriction = Car.GetBrakeShoeFrictionFactor();
Car.HuDBrakeShoeFriction = Car.GetBrakeShoeFrictionCoefficientHuD();

Car.BrakeRetardForceN = Car.BrakeShoeForceN * brakeShoeFriction; // calculates value of force applied to wheel, independent of wheel skid
if (Car.BrakeSkid) // Test to see if wheels are skiding to excessive brake force
{
Car.BrakeForceN = f * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
Car.BrakeForceN = Car.BrakeShoeForceN * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
}
else
{
Car.BrakeForceN = f * Car.BrakeShoeCoefficientFrictionAdjFactor; // In advanced adhesion model brake shoe coefficient varies with speed, in simple model constant force applied as per value in WAG file, will vary with wheel skid.
Car.BrakeForceN = Car.BrakeShoeForceN * brakeShoeFriction; // In advanced adhesion model brake shoe coefficient varies with speed, in simple model constant force applied as per value in WAG file, will vary with wheel skid.
}

}
Expand Down Expand Up @@ -395,4 +403,4 @@ public override void PropagateBrakePressure(float elapsedClockSeconds)


}
}
}
Expand Up @@ -158,14 +158,18 @@ public override float GetVacResPressurePSI()
public override void Update(float elapsedClockSeconds)
{
BleedOffValveOpen = false;
Car.BrakeRetardForceN = ( Car.MaxHandbrakeForceN * HandbrakePercent / 100) * Car.BrakeShoeRetardCoefficientFrictionAdjFactor; // calculates value of force applied to wheel, independent of wheel skid

float brakeShoeFriction = Car.GetBrakeShoeFrictionFactor();
Car.HuDBrakeShoeFriction = Car.GetBrakeShoeFrictionCoefficientHuD();

Car.BrakeRetardForceN = ( Car.MaxHandbrakeForceN * HandbrakePercent / 100) * brakeShoeFriction; // calculates value of force applied to wheel, independent of wheel skid
if (Car.BrakeSkid) // Test to see if wheels are skiding to excessive brake force
{
Car.BrakeForceN = (Car.MaxHandbrakeForceN * HandbrakePercent / 100) * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
}
else
{
Car.BrakeForceN = (Car.MaxHandbrakeForceN * HandbrakePercent / 100) * Car.BrakeShoeCoefficientFrictionAdjFactor; // In advanced adhesion model brake shoe coefficient varies with speed, in simple model constant force applied as per value in WAG file, will vary with wheel skid.
Car.BrakeForceN = (Car.MaxHandbrakeForceN * HandbrakePercent / 100) * brakeShoeFriction; // In advanced adhesion model brake shoe coefficient varies with speed, in simple model constant force applied as per value in WAG file, will vary with wheel skid.
}

}
Expand Down
Expand Up @@ -128,30 +128,34 @@ public override void Update(float elapsedClockSeconds)
}

// Adjust braking force as brake cylinder pressure varies.
float f;

if (!Car.BrakesStuck)
{

float brakecylinderfraction = ((OneAtmospherePSI - CylPressurePSIA) / MaxForcePressurePSI);
brakecylinderfraction = MathHelper.Clamp(brakecylinderfraction, 0, 1);

f = Car.MaxBrakeForceN * brakecylinderfraction;
Car.BrakeShoeForceN = Car.MaxBrakeForceN * brakecylinderfraction;

if (f < Car.MaxHandbrakeForceN * HandbrakePercent / 100)
f = Car.MaxHandbrakeForceN * HandbrakePercent / 100;
if (Car.BrakeShoeForceN < Car.MaxHandbrakeForceN * HandbrakePercent / 100)
Car.BrakeShoeForceN = Car.MaxHandbrakeForceN * HandbrakePercent / 100;
}
else
{
f = Math.Max(Car.MaxBrakeForceN, Car.MaxHandbrakeForceN / 2);
Car.BrakeShoeForceN = Math.Max(Car.MaxBrakeForceN, Car.MaxHandbrakeForceN / 2);
}
Car.BrakeRetardForceN = f * Car.BrakeShoeRetardCoefficientFrictionAdjFactor; // calculates value of force applied to wheel, independent of wheel skid

float brakeShoeFriction = Car.GetBrakeShoeFrictionFactor();
Car.HuDBrakeShoeFriction = Car.GetBrakeShoeFrictionCoefficientHuD();

Car.BrakeRetardForceN = Car.BrakeShoeForceN * brakeShoeFriction; // calculates value of force applied to wheel, independent of wheel skid
if (Car.BrakeSkid) // Test to see if wheels are skiding due to excessive brake force
{
Car.BrakeForceN = f * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
Car.BrakeForceN = Car.BrakeShoeForceN * Car.SkidFriction; // if excessive brakeforce, wheel skids, and loses adhesion
}
else
{
Car.BrakeForceN = f * Car.BrakeShoeCoefficientFrictionAdjFactor; // In advanced adhesion model brake shoe coefficient varies with speed, in simple odel constant force applied as per value in WAG file, will vary with wheel skid.
Car.BrakeForceN = Car.BrakeShoeForceN * brakeShoeFriction; // In advanced adhesion model brake shoe coefficient varies with speed, in simple odel constant force applied as per value in WAG file, will vary with wheel skid.
}

// If wagons are not attached to the locomotive, then set wagon BC pressure to same as locomotive in the Train brake line
Expand Down Expand Up @@ -413,4 +417,4 @@ public override string[] GetDebugStatus(Dictionary<BrakeSystemComponent, Pressur
}

}
}
}

0 comments on commit b6268e6

Please sign in to comment.