Skip to content

Commit

Permalink
Improve Advanced Adhesion HuD detail
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewell committed Oct 2, 2023
1 parent 0b44e34 commit 2a7fb17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Source/ORTS.Common/Conversions.cs
Expand Up @@ -595,6 +595,15 @@ public static string FormatSpeedDisplay(float speed, bool isMetric)
"{0:F1} {1}", MpS.FromMpS(speed, isMetric), isMetric ? kmph : mph);
}

/// <summary>
/// Formatted localized speed string, used to display tracking speed, with 2 decimal precision
/// </summary>
public static string FormatVeryLowSpeedDisplay(float speed, bool isMetric)
{
return String.Format(CultureInfo.CurrentCulture,
"{0:F2} {1}", MpS.FromMpS(speed, isMetric), isMetric ? kmph : mph);
}

/// <summary>
/// Formatted localized speed string, used to display speed limits, with 0 decimal precision
/// </summary>
Expand Down
Expand Up @@ -571,7 +571,7 @@ public void ComputeWheelSlipThresholdMpS()
if (fa * fb > 0)
{
// If sign does not change, bisection fails
WheelSlipThresholdMpS = MpS.FromKpH(0.2f);
WheelSlipThresholdMpS = MpS.FromKpH(0.05f);
return;
}
while (Math.Abs(b - a) > MpS.FromKpH(0.05f))
Expand Down Expand Up @@ -874,6 +874,8 @@ public virtual void Update(float timeSpan)
axleStaticForceN = AxleWeightN * SlipCharacteristics(0);
ComputeWheelSlipThresholdMpS();

// Trace.TraceInformation("Threshold - Threshold {0} SlipSpeed {1} Speed {2}", WheelSlipThresholdMpS, SlipSpeedMpS, TrainSpeedMpS);

if (count < 6 && count++ == 5)
{
TrainSpeedMpS = 10 / 3.6f;
Expand Down
8 changes: 4 additions & 4 deletions Source/RunActivity/Viewer3D/Popups/HUDWindow.cs
Expand Up @@ -1080,20 +1080,20 @@ void TextPageForceInfo(TableData table)
{
TableAddLine(table, Viewer.Catalog.GetString("(Advanced adhesion model)"));
int row0 = table.CurrentRow;
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Wheel slip"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Wheel slip (Thres)"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Conditions"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Axle drive force"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Axle brake force"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Number of substeps"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Wheel Adhesion"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Axle out force"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Comp Axle out force"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Wheel speed"));
TableSetCell(table, table.CurrentRow++, table.CurrentLabelColumn, Viewer.Catalog.GetString("Wheel speed (Slip)"));
for (int i = 0; i < mstsLocomotive.LocomotiveAxles.Count; i++)
{
table.CurrentRow = row0;
var axle = mstsLocomotive.LocomotiveAxles[i];
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}% ({1})", axle.SlipSpeedPercent, FormatStrings.FormatSpeedDisplay((float)axle.WheelSlipThresholdMpS, true));
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}% ({1})", axle.SlipSpeedPercent, FormatStrings.FormatVeryLowSpeedDisplay((float)axle.WheelSlipThresholdMpS, mstsLocomotive.IsMetric));
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}%", mstsLocomotive.AdhesionConditions * 100.0f);
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0} ({1})", FormatStrings.FormatForce(axle.DriveForceN, mstsLocomotive.IsMetric), FormatStrings.FormatPower(axle.DriveForceN * mstsLocomotive.AbsTractionSpeedMpS, mstsLocomotive.IsMetric, false, false));
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0}", FormatStrings.FormatForce(axle.BrakeRetardForceN, mstsLocomotive.IsMetric));
Expand All @@ -1104,7 +1104,7 @@ void TextPageForceInfo(TableData table)
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0} ({1})",
FormatStrings.FormatForce(axle.CompensatedAxleForceN, mstsLocomotive.IsMetric),
FormatStrings.FormatPower(axle.CompensatedAxleForceN * mstsLocomotive.AbsTractionSpeedMpS, mstsLocomotive.IsMetric, false, false));
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0} ({1})", FormatStrings.FormatSpeedDisplay((float)axle.AxleSpeedMpS, mstsLocomotive.IsMetric), FormatStrings.FormatSpeedDisplay(axle.SlipSpeedMpS, mstsLocomotive.IsMetric));
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0} ({1})", FormatStrings.FormatSpeedDisplay((float)axle.AxleSpeedMpS, mstsLocomotive.IsMetric), FormatStrings.FormatVeryLowSpeedDisplay(axle.SlipSpeedMpS, mstsLocomotive.IsMetric));
}
if (HUDEngineType == TrainCar.EngineTypes.Steam && (HUDSteamEngineType == TrainCar.SteamEngineTypes.Compound || HUDSteamEngineType == TrainCar.SteamEngineTypes.Simple || HUDSteamEngineType == TrainCar.SteamEngineTypes.Unknown)) TableAddLabelValue(table, Viewer.Catalog.GetString("Wheel ang. pos."), "{0}º", (int)(mstsLocomotive.LocomotiveAxles[0].AxlePositionRad * 180 / Math.PI + 180));
TableAddLabelValue(table, Viewer.Catalog.GetString("Loco Adhesion"), "{0:F0}%", mstsLocomotive.LocomotiveCoefficientFrictionHUD * 100.0f);
Expand Down

0 comments on commit 2a7fb17

Please sign in to comment.