From 2a7fb17ee171ec3b70a86d0b7efaeecc1fffbbc1 Mon Sep 17 00:00:00 2001 From: peternewell Date: Mon, 2 Oct 2023 19:21:04 +1100 Subject: [PATCH] Improve Advanced Adhesion HuD detail --- Source/ORTS.Common/Conversions.cs | 9 +++++++++ .../RollingStocks/SubSystems/PowerTransmissions/Axle.cs | 4 +++- Source/RunActivity/Viewer3D/Popups/HUDWindow.cs | 8 ++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/ORTS.Common/Conversions.cs b/Source/ORTS.Common/Conversions.cs index f8f4711903..5bb46f4035 100644 --- a/Source/ORTS.Common/Conversions.cs +++ b/Source/ORTS.Common/Conversions.cs @@ -595,6 +595,15 @@ public static string FormatSpeedDisplay(float speed, bool isMetric) "{0:F1} {1}", MpS.FromMpS(speed, isMetric), isMetric ? kmph : mph); } + /// + /// Formatted localized speed string, used to display tracking speed, with 2 decimal precision + /// + public static string FormatVeryLowSpeedDisplay(float speed, bool isMetric) + { + return String.Format(CultureInfo.CurrentCulture, + "{0:F2} {1}", MpS.FromMpS(speed, isMetric), isMetric ? kmph : mph); + } + /// /// Formatted localized speed string, used to display speed limits, with 0 decimal precision /// diff --git a/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs b/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs index 4ec3dab792..426cad2544 100644 --- a/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs +++ b/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs @@ -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)) @@ -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; diff --git a/Source/RunActivity/Viewer3D/Popups/HUDWindow.cs b/Source/RunActivity/Viewer3D/Popups/HUDWindow.cs index 6ada2f75c5..022795c18e 100644 --- a/Source/RunActivity/Viewer3D/Popups/HUDWindow.cs +++ b/Source/RunActivity/Viewer3D/Popups/HUDWindow.cs @@ -1080,7 +1080,7 @@ 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")); @@ -1088,12 +1088,12 @@ void TextPageForceInfo(TableData table) 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)); @@ -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);