Skip to content

Commit

Permalink
Automatic merge of T1.5.1-413-g1daa6a7c6 and 20 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 7d81e0a: 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
  • Loading branch information
openrails-bot committed May 30, 2023
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 133 deletions.
54 changes: 14 additions & 40 deletions Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs
Expand Up @@ -1149,6 +1149,19 @@ public virtual void Parse(string lowercasetoken, STFReader stf)
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 "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 @@ -1476,6 +1489,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 @@ -3984,46 +3998,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,24 @@ 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.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,24 @@ 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.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 +397,4 @@ public override void PropagateBrakePressure(float elapsedClockSeconds)


}
}
}
Expand Up @@ -158,14 +158,17 @@ 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.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,33 @@ 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.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 +416,4 @@ public override string[] GetDebugStatus(Dictionary<BrakeSystemComponent, Pressur
}

}
}
}
Expand Up @@ -562,32 +562,34 @@ public override void Update(float elapsedClockSeconds)
}

float vrp = VacResPressureAdjPSIA();
float f;

if (!Car.BrakesStuck)
{
// depending upon whether steam brake fitted or not, calculate brake force to be applied
if (LocomotiveSteamBrakeFitted && (Car.WagonType == MSTSWagon.WagonTypes.Engine || Car.WagonType == MSTSWagon.WagonTypes.Tender))
{
var leadLocomotiveMaxBoilerPressurePSI = lead == null ? 200.0f : (lead.MaxBoilerPressurePSI);
f = Car.MaxBrakeForceN * Math.Min(SteamBrakeCylinderPressurePSI / leadLocomotiveMaxBoilerPressurePSI, 1);
Car.BrakeShoeForceN = Car.MaxBrakeForceN * Math.Min(SteamBrakeCylinderPressurePSI / leadLocomotiveMaxBoilerPressurePSI, 1);
}
else
{
f = CylPressurePSIA <= vrp ? 0 : Car.MaxBrakeForceN * Math.Min((CylPressurePSIA - vrp) / MaxForcePressurePSI, 1);
Car.BrakeShoeForceN = CylPressurePSIA <= vrp ? 0 : Car.MaxBrakeForceN * Math.Min((CylPressurePSIA - vrp) / MaxForcePressurePSI, 1);
}
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);
else 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.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 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

0 comments on commit 0435b15

Please sign in to comment.