Skip to content

Commit 48ef78a

Browse files
committed
Automatic merge of T1.5.1-1072-g3c01d62002 and 23 pull requests
- Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 8f695a4: Blueprint/train car operations UI window - Pull request #885 at e267870: feat: Add notifications to Menu - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #900 at c27f32d: DMI updates - Pull request #903 at 3e390b8: Downloading route content (Github, zip) - Pull request #922 at a3bc9e7: Autopilot for timetable mode - Pull request #946 at 91a03af: Advanced track sounds - Pull request #952 at 8347095: Investigation - Pulsing graphics - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at 84c2f4b: Add Support for Multiple Track Profiles - Pull request #959 at 2452cb0: Fix TrackViewer crash on big zoom value - Pull request #962 at 46d0472: Fix pantographs on unpowered cars - Pull request #963 at 2d5a67d: Fix dynamic brake force indicator - Pull request #964 at b11c894: fix: Warning CA1417: Do not use the 'OutAttribute' for string parameter - Pull request #965 at 7554f02: style: Renormalize line endings - Pull request #966 at 6353e03: fix: Warning CS0618: 'string.Copy(string)' is obsolete - Pull request #967 at a799e20: Fix AI Lights After Reversing Points - Pull request #968 at 415aec7: Initial build of adding track section identifier for rack railway
25 parents a0cc9fd + 3c01d62 + dfc715e + d00beb9 + f92de76 + 8f695a4 + e267870 + 9a1d6b2 + 1f5ba4c + 5866028 + c27f32d + 3e390b8 + a3bc9e7 + 91a03af + 8347095 + a519452 + 84c2f4b + 2452cb0 + 46d0472 + 2d5a67d + b11c894 + 7554f02 + 6353e03 + a799e20 + 415aec7 commit 48ef78a

File tree

5 files changed

+108
-14
lines changed

5 files changed

+108
-14
lines changed

Source/Orts.Formats.Msts/TrackSectionsFile.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public TrackShape(STFReader stf)
206206
new STFReader.TokenProcessor("sectionidx", ()=>{ SectionIdxs[nextPath++] = new SectionIdx(stf); }),
207207
new STFReader.TokenProcessor("tunnelshape", ()=>{ TunnelShape = stf.ReadBoolBlock(true); }),
208208
new STFReader.TokenProcessor("roadshape", ()=>{ RoadShape = stf.ReadBoolBlock(true); }),
209+
new STFReader.TokenProcessor("ortsrackshape", ()=>{ RackShape = stf.ReadBoolBlock(true); }),
209210
});
210211
// TODO - this was removed since TrackShape( 183 ) is blank
211212
//if( FileName == null ) throw( new STFError( stf, "Missing FileName" ) );
@@ -220,7 +221,7 @@ public TrackShape(STFReader stf)
220221
public SectionIdx[] SectionIdxs;
221222
public bool TunnelShape;
222223
public bool RoadShape;
223-
224+
public bool RackShape;
224225
}
225226

226227
public class TrackShapes: Dictionary<uint, TrackShape>

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
using System.Diagnostics;
6565
using System.IO;
6666
using System.Linq;
67+
using static Orts.Simulation.RollingStocks.MSTSSteamLocomotive;
6768
using Event = Orts.Common.Event;
6869

6970
namespace Orts.Simulation.RollingStocks
@@ -104,6 +105,15 @@ public enum SoundState
104105
ContinuousSound
105106
}
106107

108+
public enum LocomotiveRailDriveTypes
109+
{
110+
Unknown,
111+
Rack,
112+
Adhesion, // defaults to adhesion
113+
}
114+
115+
public LocomotiveRailDriveTypes LocomotiveRailDriveType;
116+
107117
// simulation parameters
108118
public bool ManualHorn = false;
109119
public bool TCSHorn = false;
@@ -1199,6 +1209,19 @@ public override void Parse(string lowercasetoken, STFReader stf)
11991209
break;
12001210
case "engine(ortscruisecontrol": SetUpCruiseControl(stf); break;
12011211
case "engine(ortsmultipositioncontroller": SetUpMPC(stf); break;
1212+
case "engine(ortslocomotiveraildrivetype":
1213+
stf.MustMatch("(");
1214+
var locomotiveDriveType = stf.ReadString();
1215+
try
1216+
{
1217+
LocomotiveRailDriveType = (LocomotiveRailDriveTypes)Enum.Parse(typeof(LocomotiveRailDriveTypes), locomotiveDriveType);
1218+
}
1219+
catch
1220+
{
1221+
if (Simulator.Settings.VerboseConfigurationMessages)
1222+
STFException.TraceWarning(stf, "Assumed unknown fuel type " + locomotiveDriveType);
1223+
}
1224+
break;
12021225
default:
12031226
base.Parse(lowercasetoken, stf);
12041227
break;
@@ -1354,6 +1377,7 @@ public override void Copy(MSTSWagon copy)
13541377
MultiPositionControllers = locoCopy.CloneMPC(this);
13551378
OnLineCabRadio = locoCopy.OnLineCabRadio;
13561379
OnLineCabRadioURL = locoCopy.OnLineCabRadioURL;
1380+
LocomotiveRailDriveType = locoCopy.LocomotiveRailDriveType;
13571381
}
13581382

13591383
/// <summary>
@@ -1560,6 +1584,15 @@ public override void Initialize()
15601584
IsSteamHeatFitted = true;
15611585
}
15621586

1587+
// Type of rail drive selected
1588+
if (LocomotiveRailDriveType == LocomotiveRailDriveTypes.Unknown)
1589+
{
1590+
LocomotiveRailDriveType = LocomotiveRailDriveTypes.Adhesion;
1591+
1592+
if (Simulator.Settings.VerboseConfigurationMessages)
1593+
Trace.TraceInformation("LocomotiveRailDriveType set to Default value of {0}", LocomotiveRailDriveType);
1594+
}
1595+
15631596
SteamHeatPressureToTemperaturePSItoF = SteamTable.SteamHeatPressureToTemperatureInterpolatorPSItoF();
15641597
SteamDensityPSItoLBpFT3 = SteamTable.SteamDensityInterpolatorPSItoLBpFT3();
15651598
SteamHeatPSItoBTUpLB = SteamTable.SteamHeatInterpolatorPSItoBTUpLB();
@@ -2019,6 +2052,16 @@ public override void Update(float elapsedClockSeconds)
20192052
}
20202053
}
20212054

2055+
// determine if this is an adhesion or rack locomotive
2056+
if (LocomotiveRailDriveType == LocomotiveRailDriveTypes.Rack)
2057+
{
2058+
foreach (var axle in LocomotiveAxles)
2059+
{
2060+
axle.CogWheelFitted = true;
2061+
}
2062+
}
2063+
2064+
20222065
var gearloco = this as MSTSDieselLocomotive;
20232066

20242067
// Pass Gearbox commands

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,11 @@
2020

2121
using System;
2222
using System.IO;
23-
using System.Collections;
2423
using System.Collections.Generic;
2524
using System.Diagnostics;
2625
using Microsoft.Xna.Framework;
2726
using ORTS.Common;
2827
using Orts.Parsers.Msts;
29-
using Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions;
30-
using SharpDX.Direct2D1;
31-
using SharpDX.Direct3D9;
32-
using Orts.Formats.OR;
33-
using static Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions.Axle;
3428

3529
namespace Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions
3630
{
@@ -709,6 +703,9 @@ public float TransmissionEfficiency
709703
/// </summary>
710704
public float TrainSpeedMpS;
711705

706+
public bool CogWheelFitted;
707+
public bool IsRackRailway;
708+
712709
/// <summary>
713710
/// Wheel slip indicator
714711
/// - is true when absolute value of SlipSpeedMpS is greater than WheelSlipThresholdMpS, otherwise is false
@@ -906,6 +903,10 @@ public void Parse(STFReader stf)
906903
WheelWeightKg = stf.ReadFloatBlock(STFReader.UNITS.Mass, null);
907904
AxleWeightN = 9.81f * WheelWeightKg;
908905
break;
906+
case "cogwheel":
907+
CogWheelFitted = stf.ReadBoolBlock(false);
908+
Trace.TraceInformation("CogWheel - {0}", CogWheelFitted);
909+
break;
909910
case "animatedparts":
910911
foreach (var part in stf.ReadStringBlock("").ToUpper().Replace(" ", "").Split(','))
911912
{
@@ -926,6 +927,7 @@ public void Copy(Axle other)
926927
InertiaKgm2 = other.InertiaKgm2;
927928
WheelWeightKg = other.WheelWeightKg;
928929
AxleWeightN = other.AxleWeightN;
930+
CogWheelFitted = other.CogWheelFitted;
929931
AnimatedParts.Clear();
930932
AnimatedParts.AddRange(other.AnimatedParts);
931933
}
@@ -1144,6 +1146,34 @@ void Integrate(float elapsedClockSeconds)
11441146
/// <param name="elapsedSeconds"></param>
11451147
public virtual void Update(float elapsedSeconds)
11461148
{
1149+
if (CogWheelFitted && IsRackRailway)
1150+
{
1151+
AxleSpeedMpS = TrainSpeedMpS;
1152+
1153+
motor?.Update(elapsedSeconds);
1154+
1155+
double axleInForceN = 0;
1156+
if (DriveType == AxleDriveType.ForceDriven)
1157+
axleInForceN = DriveForceN * transmissionEfficiency;
1158+
else if (DriveType == AxleDriveType.MotorDriven)
1159+
axleInForceN = motor.GetDevelopedTorqueNm(AxleSpeedMpS * transmissionRatio / WheelRadiusM) * transmissionEfficiency / WheelRadiusM;
1160+
1161+
double motionForceN = axleInForceN - dampingNs * (AxleSpeedMpS - TrainSpeedMpS); // Drive force + heat losses
1162+
double frictionForceN = BrakeRetardForceN + frictionN; // Dissipative forces: they will never increase wheel speed
1163+
double totalAxleForceN = motionForceN - Math.Sign(AxleSpeedMpS) * frictionForceN;
1164+
1165+
AxleForceN = (float)totalAxleForceN;
1166+
CompensatedAxleForceN = (float)motionForceN;
1167+
1168+
IsWheelSlip = IsWheelSlipWarning = HuDIsWheelSlip = HuDIsWheelSlipWarning = false;
1169+
WheelSlipWarningTimeS = 0;
1170+
slipDerivationMpSS = 0;
1171+
previousSlipSpeedMpS = 0;
1172+
slipDerivationPercentpS = 0;
1173+
previousSlipPercent = 0;
1174+
return;
1175+
}
1176+
11471177
if (Axles.UsePolachAdhesion)
11481178
{
11491179
forceToAccelerationFactor = WheelRadiusM * WheelRadiusM / totalInertiaKgm2;
@@ -1202,18 +1232,18 @@ public virtual void Update(float elapsedSeconds)
12021232
// And thus there is a duplication of the braking effect in OR. To compensate for this, after the slip characteristics have been calculated, the output of the axle
12031233
// module has the brake force "added" back in to give the appropriate motive force output for the locomotive. Braking force is handled separately.
12041234
// Hence CompensatedAxleForce is the actual output force on the axle. Similarly friction is also handled separately so it is also discounted from the CompensatedForce.
1205-
1235+
12061236
// Make sure that compensated value never exceeds the "output" force, otherwise resulting value will be overcompensated
1207-
var CompensationVariation = BrakeRetardForceN + FrictionN;
1237+
var compensationVariation = BrakeRetardForceN + FrictionN;
12081238

1209-
if (CompensationVariation > Math.Abs(AxleForceN))
1239+
if (compensationVariation > Math.Abs(AxleForceN))
12101240
{
1211-
CompensationVariation = Math.Abs(AxleForceN); ;
1241+
compensationVariation = Math.Abs(AxleForceN); ;
12121242
}
12131243

12141244
if (Math.Abs(TrainSpeedMpS) < 0.001f && AxleForceN == 0) CompensatedAxleForceN = 0;
1215-
else if (TrainSpeedMpS < 0) CompensatedAxleForceN = AxleForceN - CompensationVariation;
1216-
else CompensatedAxleForceN = AxleForceN + CompensationVariation;
1245+
else if (TrainSpeedMpS < 0) CompensatedAxleForceN = AxleForceN - compensationVariation;
1246+
else CompensatedAxleForceN = AxleForceN + compensationVariation;
12171247

12181248
if (Math.Abs(SlipSpeedMpS) > WheelSlipThresholdMpS)
12191249
{

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,6 +2986,25 @@ internal void UpdatedTraveler(Traveller traveler, float elapsedTimeS, float dist
29862986
CurrentCurveRadiusM = traveler.GetCurveRadius();
29872987
UpdateVibrationAndTilting(traveler, elapsedTimeS, distanceM, speedMpS);
29882988
UpdateSuperElevation(traveler, elapsedTimeS);
2989+
2990+
if (this is MSTSWagon wagon)
2991+
{
2992+
bool isRackRailway = false;
2993+
var thisSection = traveler.GetCurrentSection();
2994+
2995+
if (thisSection != null && Simulator.TSectionDat.TrackShapes.ContainsKey(thisSection.ShapeIndex))
2996+
{
2997+
TrackShape thisShape = Simulator.TSectionDat.TrackShapes[thisSection.ShapeIndex];
2998+
isRackRailway |= thisShape.RackShape;
2999+
}
3000+
3001+
foreach (var axle in wagon.LocomotiveAxles)
3002+
{
3003+
axle.IsRackRailway = isRackRailway;
3004+
3005+
// Trace.TraceInformation("IsRackRailway {0} CarID {1}", axle.IsRackRailway, CarID);
3006+
}
3007+
}
29893008
}
29903009
#endregion
29913010

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,8 @@ void TextPageForceInfo(TableData table)
11771177
table.CurrentRow = row0;
11781178
var axle = mstsLocomotive.LocomotiveAxles[i];
11791179
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}% ({1})", axle.SlipSpeedPercent, FormatStrings.FormatVeryLowSpeedDisplay((float)axle.WheelSlipThresholdMpS, mstsLocomotive.IsMetric));
1180-
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}%", mstsLocomotive.AdhesionConditions * 100.0f);
1180+
if (axle.IsRackRailway) TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, Viewer.Catalog.GetString("rack"));
1181+
else TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}%", mstsLocomotive.AdhesionConditions * 100.0f);
11811182
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));
11821183
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0}", FormatStrings.FormatForce(axle.BrakeRetardForceN, mstsLocomotive.IsMetric));
11831184
TableSetCell(table, table.CurrentRow++, table.CurrentValueColumn + 2 * i, "{0:F0}", axle.NumOfSubstepsPS);

0 commit comments

Comments
 (0)