Skip to content

Commit d0208cd

Browse files
committed
Initial work to add curve squeal to route
1 parent af8fb30 commit d0208cd

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

Source/Orts.Formats.Msts/RouteFile.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public Tr_RouteFile(STFReader stf)
121121
// sms file number in Ttype.dat when train over switch
122122
new STFReader.TokenProcessor("ortsswitchsmsnumber", ()=>{ SwitchSMSNumber = stf.ReadIntBlock(null); }),
123123
new STFReader.TokenProcessor("ortscurvesmsnumber", ()=>{ CurveSMSNumber = stf.ReadIntBlock(null); }),
124+
new STFReader.TokenProcessor("ortscurvesquealsmsnumber", ()=>{ CurveSquealSMSNumber = stf.ReadIntBlock(null); }),
124125
new STFReader.TokenProcessor("ortscurveswitchsmsnumber", ()=>{ CurveSwitchSMSNumber = stf.ReadIntBlock(null); }),
125126
new STFReader.TokenProcessor("ortsopendoorsinaitrains", ()=>{ OpenDoorsInAITrains = stf.ReadBoolBlock(false); }),
126127

@@ -175,9 +176,10 @@ public Tr_RouteFile(STFReader stf)
175176
public string DefaultTurntableSMS;
176177
public bool ? OpenDoorsInAITrains; // true if option active
177178

178-
public int SwitchSMSNumber = -1; // defines the number of the switch SMS files in file ttypedat
179+
public int SwitchSMSNumber = -1; // defines the number of the switch SMS files in file ttype.dat
179180
public int CurveSMSNumber = -1; // defines the number of the curve SMS files in file ttype.dat
180181
public int CurveSwitchSMSNumber = -1; // defines the number of the curve-switch SMS files in file ttype.dat
182+
public int CurveSquealSMSNumber = -1; // defines the number of the curve squeal SMS files in file ttype.dat
181183

182184
}
183185

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ public override void Save(BinaryWriter outf)
18621862

18631863
outf.Write(WheelBrakeSlideProtectionActive);
18641864
outf.Write(WheelBrakeSlideProtectionTimerS);
1865-
outf.Write(AngleOfAttackRad);
1865+
outf.Write(AngleOfAttackmRad);
18661866
outf.Write(DerailClimbDistanceM);
18671867
outf.Write(DerailPossible);
18681868
outf.Write(DerailExpected);
@@ -1925,7 +1925,7 @@ public override void Restore(BinaryReader inf)
19251925

19261926
WheelBrakeSlideProtectionActive = inf.ReadBoolean();
19271927
WheelBrakeSlideProtectionTimerS = inf.ReadInt32();
1928-
AngleOfAttackRad = inf.ReadSingle();
1928+
AngleOfAttackmRad = inf.ReadSingle();
19291929
DerailClimbDistanceM = inf.ReadSingle();
19301930
DerailPossible = inf.ReadBoolean();
19311931
DerailExpected = inf.ReadBoolean();

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public static Interpolator SteamHeatBoilerFuelUsageGalukpH()
204204
public bool DerailmentCoefficientEnabled = true;
205205
public float MaximumWheelFlangeAngleRad;
206206
public float WheelFlangeLengthM;
207-
public float AngleOfAttackRad;
207+
public float AngleOfAttackmRad;
208208
public float DerailClimbDistanceM;
209209
public bool DerailPossible = false;
210210
public bool DerailExpected = false;
@@ -968,6 +968,8 @@ public virtual void Update(float elapsedClockSeconds)
968968
CurrentElevationPercent = -CurrentElevationPercent;
969969
}
970970

971+
AngleOfAttackmRad = GetAngleofAttackmRad();
972+
971973
UpdateCurveSpeedLimit(); // call this first as it will provide inputs for the curve force.
972974
UpdateCurveForce(elapsedClockSeconds);
973975
UpdateTunnelForce();
@@ -1681,10 +1683,6 @@ public void UpdateTrainDerailmentRisk(float elapsedClockSeconds)
16811683
// Calculate Nadal derailment coefficient limit
16821684
NadalDerailmentCoefficient = ((float) Math.Tan(MaximumWheelFlangeAngleRad) - wagonAdhesion) / (1f + wagonAdhesion * (float) Math.Tan(MaximumWheelFlangeAngleRad));
16831685

1684-
// Calculate Angle of Attack - AOA = sin-1(2 * bogie wheel base / curve radius)
1685-
AngleOfAttackRad = (float)Math.Asin(2 * RigidWheelBaseM / CurrentCurveRadiusM);
1686-
var angleofAttackmRad = AngleOfAttackRad * 1000f; // Convert to micro radians
1687-
16881686
// Calculate the derail climb distance - uses the general form equation 2.4 from the above publication
16891687
var parameterA_1 = ((100 / (-1.9128f * MathHelper.ToDegrees(MaximumWheelFlangeAngleRad) + 146.56f)) + 3.1f) * Me.ToIn(WheelFlangeLengthM);
16901688

@@ -1698,7 +1696,7 @@ public void UpdateTrainDerailmentRisk(float elapsedClockSeconds)
16981696

16991697
var parameterB = parameterB_1 + parameterB_2;
17001698

1701-
DerailClimbDistanceM = Me.FromFt( (float)((parameterA * parameterB * Me.ToIn(WheelFlangeLengthM)) / ((angleofAttackmRad + (parameterB * Me.ToIn(WheelFlangeLengthM))))) );
1699+
DerailClimbDistanceM = Me.FromFt( (float)((parameterA * parameterB * Me.ToIn(WheelFlangeLengthM)) / ((AngleOfAttackmRad + (parameterB * Me.ToIn(WheelFlangeLengthM))))) );
17021700

17031701
// calculate the time taken to travel the derail climb distance
17041702
var derailTimeS = DerailClimbDistanceM / AbsSpeedMpS;
@@ -1769,6 +1767,26 @@ public void UpdateTrainDerailmentRisk(float elapsedClockSeconds)
17691767

17701768
#endregion
17711769

1770+
/// <summary>
1771+
/// Get the Angle of attack for a car as it goes through a curve
1772+
/// </summary>
1773+
/// <returns>angle in micro radians</returns>
1774+
///
1775+
public float GetAngleofAttackmRad ()
1776+
{
1777+
if (CurrentCurveRadiusM > 0)
1778+
{
1779+
// Calculate Angle of Attack - AOA = sin-1(2 * bogie wheel base / curve radius)
1780+
var angleofAttackmRad = (float)Math.Asin(2 * RigidWheelBaseM / CurrentCurveRadiusM) * 1000f; // Convert to micro radians
1781+
return angleofAttackmRad;
1782+
}
1783+
else
1784+
{
1785+
return 0;
1786+
}
1787+
}
1788+
1789+
17721790
/// <summary>
17731791
/// Get the current direction that curve is heading relative to the train.
17741792
/// </summary>

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,9 @@ void TextPageForceInfo(TableData table)
12361236
Viewer.Catalog.GetString("Brk Slide"),
12371237
Viewer.Catalog.GetString("Bear Temp"),
12381238
Viewer.Catalog.GetString(" "),
1239-
Viewer.Catalog.GetString("DerailCoeff")
1240-
1239+
Viewer.Catalog.GetString("DrailCof"),
1240+
Viewer.Catalog.GetString("AoA")
1241+
12411242
);
12421243
TableAddLine(table);
12431244

@@ -1266,6 +1267,7 @@ void TextPageForceInfo(TableData table)
12661267
TableSetCell(table, 17, "{0} {1}", FormatStrings.FormatTemperature(car.WheelBearingTemperatureDegC, car.IsMetric, false), car.DisplayWheelBearingTemperatureStatus);
12671268
TableSetCell(table, 18, car.Flipped ? Viewer.Catalog.GetString("Flipped") : "");
12681269
TableSetCell(table, 19, "{0:F2}{1}", car.DerailmentCoefficient, car.DerailExpected ? "!!!" : car.DerailPossible ? "???" : "");
1270+
TableSetCell(table, 20, "{0:F2}", car.AngleOfAttackmRad);
12691271
TableAddLine(table);
12701272

12711273
}

0 commit comments

Comments
 (0)