Skip to content

Commit 000eb44

Browse files
committed
Automatic merge of T1.6-rc2-41-gacd714487 and 10 pull requests
- Pull request #1104 at 03ccdc6: Handle simple adhesion within the axle module - Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 2391bc0: Automatic speed control - Pull request #1107 at f5eb3dc: Fix DPMode when last remote is moved to front. - Pull request #1110 at 387388e: Fix Activity Runner persists after loading exception - Pull request #1114 at 9a4a873: Fix color of DB in DrivingInfo when in setup with DPU fenced. - Pull request #1115 at 01c0838: Do not activate ETS switch if no suitable cars are attached - Pull request #1116 at 721d118: Fix Potential Hang in AnimatedPart.SetFrameWrap - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification
12 parents ebcd9c9 + acd7144 + 03ccdc6 + e10390b + 2391bc0 + f5eb3dc + 387388e + 9a4a873 + 01c0838 + 721d118 + 5845a1a + 689494b commit 000eb44

File tree

3 files changed

+52
-52
lines changed

3 files changed

+52
-52
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,11 +1683,11 @@ public override void Initialize()
16831683
{
16841684
if (axle.DriveType != AxleDriveType.NotDriven)
16851685
{
1686-
InductionMotor motor = new InductionMotor(axle, this);
1687-
TractionMotors.Add(motor);
1686+
InductionMotor motor = new InductionMotor(axle, this);
1687+
TractionMotors.Add(motor);
1688+
}
16881689
}
16891690
}
1690-
}
16911691
SlipControlActive = new bool[LocomotiveAxles.Count];
16921692
if (SlipControlSystem == SlipControlType.Unknown)
16931693
{
@@ -3744,9 +3744,9 @@ public void StartThrottleDecrease()
37443744
var mpc = MultiPositionControllers.Where(x => x.controllerBinding == ControllerBinding.Throttle).FirstOrDefault();
37453745
if (mpc != null)
37463746
{
3747-
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedMaxAccelerationPercent != 0
3748-
&& CruiseControl.HasIndependentThrottleDynamicBrakeLever)
3749-
return;
3747+
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedMaxAccelerationPercent != 0
3748+
&& CruiseControl.HasIndependentThrottleDynamicBrakeLever)
3749+
return;
37503750
if (!mpc.StateChanged)
37513751
{
37523752
mpc.StateChanged = true;
@@ -3920,8 +3920,8 @@ public void AdjustNotchedThrottle(bool increase)
39203920
}
39213921
else
39223922
{
3923-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.Throttle, ThrottleController.CurrentValue * 100);
3924-
}
3923+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.Throttle, ThrottleController.CurrentValue * 100);
3924+
}
39253925
}
39263926

39273927
public void SetThrottleValue(float value)
@@ -3953,17 +3953,17 @@ public void SetThrottleValue(float value)
39533953
}
39543954
else
39553955
{
3956-
Simulator.Confirmer.UpdateWithPerCent(
3957-
this is MSTSSteamLocomotive ? CabControl.Regulator : CabControl.Throttle,
3958-
oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease,
3959-
controller.CurrentValue * 100);
3960-
}
3956+
Simulator.Confirmer.UpdateWithPerCent(
3957+
this is MSTSSteamLocomotive ? CabControl.Regulator : CabControl.Throttle,
3958+
oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease,
3959+
controller.CurrentValue * 100);
3960+
}
39613961
}
39623962
}
39633963

39643964
public void SetThrottlePercent(float percent)
39653965
{
3966-
ThrottleController.SetPercent(percent);
3966+
ThrottleController.SetPercent(percent);
39673967
}
39683968

39693969
public void SetThrottlePercentWithSound(float percent)
@@ -4061,7 +4061,7 @@ public float GetCombinedHandleValue(bool intermediateValue)
40614061
var brakesValue = intermediateValue ? TrainBrakeController?.IntermediateValue : TrainBrakeController?.CurrentValue;
40624062

40634063
if (CombinedControlType == CombinedControl.ThrottleDynamic && throttleValue <= 0 && dynamicsValue > 0)
4064-
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (dynamicsValue ?? 0);
4064+
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (dynamicsValue ?? 0);
40654065
else if (CombinedControlType == CombinedControl.ThrottleAir && throttleValue <= 0 && brakesValue > 0)
40664066
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (brakesValue ?? 0);
40674067
else
@@ -5060,7 +5060,7 @@ public virtual float GetDataOf(CabViewControl cvc)
50605060
{
50615061
case CABViewControlTypes.SPEEDOMETER:
50625062
{
5063-
data = WheelSpeedMpS;
5063+
data = WheelSpeedMpS;
50645064

50655065
if (cvc.Units == CABViewControlUnits.KM_PER_HOUR)
50665066
data *= 3.6f;

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6662,8 +6662,8 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds)
66626662
IndicatedHorsePowerHP += engine.IndicatedHorsePowerHP;
66636663
IndicatedHorsePowerHP = MathHelper.Clamp(IndicatedHorsePowerHP, 0, IndicatedHorsePowerHP);
66646664
}
6665-
//TODO - identify the maximum value for display??
6666-
PistonSpeedFtpMin = SteamEngines[0].PistonSpeedFtpMin;
6665+
//TODO - identify the maximum value for display??
6666+
PistonSpeedFtpMin = SteamEngines[0].PistonSpeedFtpMin;
66676667

66686668
// Find the maximum TE for debug i.e. @ start and full throttle
66696669
if (AbsTractionSpeedMpS < 1.0)
@@ -6770,9 +6770,9 @@ private float NormalisedCrankAngle(int enginenumber, int cylinderNumber, float c
67706770

67716771

67726772
protected override void UpdateAxles(float elapsedClockSeconds)
6773-
{
6774-
foreach (var engine in SteamEngines)
6775-
{
6773+
{
6774+
foreach (var engine in SteamEngines)
6775+
{
67766776
var axle = engine.AttachedAxle;
67776777
if (SteamEngineType == SteamEngineTypes.Geared || engine.AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster)
67786778
// geared locomotive or booster locomotive
@@ -6786,7 +6786,7 @@ protected override void UpdateAxles(float elapsedClockSeconds)
67866786
float TotalWheelMomentofInertia = WheelMomentInertia + AxleMomentInertia; // Total MoI for generic wheelset
67876787
float TotalMomentInertia = TotalWheelMomentofInertia;
67886788
axle.InertiaKgm2 = TotalMomentInertia;
6789-
6789+
67906790
// Calculate internal resistance - IR = 3.8 * diameter of cylinder^2 * stroke * dia of drivers (all in inches) - This should reduce wheel force
67916791
axle.FrictionN = N.FromLbf(3.8f * Me.ToIn(engine.CylindersDiameterM) * Me.ToIn(engine.CylindersDiameterM) * Me.ToIn(engine.CylindersStrokeM) / (Me.ToIn(axle.WheelRadiusM * 2.0f)));
67926792
}
@@ -6805,7 +6805,7 @@ protected override void UpdateAxles(float elapsedClockSeconds)
68056805
float WheelMomentInertia = (wheelMassKG * axle.WheelRadiusM * axle.WheelRadiusM) / 2.0f;
68066806
float AxleMomentInertia = (AxleMassKG * AxleRadiusM * AxleRadiusM) / 2.0f;
68076807
float TotalWheelMomentofInertia = WheelMomentInertia + AxleMomentInertia; // Total MoI for generic wheelset
6808-
6808+
68096809
// The moment of inertia needs to be increased by the number of wheels in each set
68106810
TotalWheelMomentofInertia *= engine.AttachedAxle.NumWheelsetAxles;
68116811

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/CruiseControl.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public void Initialize()
503503

504504
if (SpeedDeltaFunctionMode == SpeedDeltaMode.Sqrt) StartReducingSpeedDeltaDownwards /= 3;
505505

506-
if (StartInAutoMode) SpeedRegMode = SpeedRegulatorMode.Auto;
506+
if (StartInAutoMode) SpeedRegMode = SpeedRegulatorMode.Auto;
507507

508508
if (UseThrottleAsForceSelector)
509509
{
@@ -761,7 +761,7 @@ public void Update(float elapsedClockSeconds)
761761
}
762762
else
763763
{
764-
CCThrottleOrDynBrakePercent = 0;
764+
CCThrottleOrDynBrakePercent = 0;
765765
TrainBrakePercent = 0;
766766
ThrottlePID.Active = false;
767767
DynamicBrakePID.Active = false;
@@ -778,7 +778,7 @@ public void Update(float elapsedClockSeconds)
778778
EngineBrakePercent = ParkingBrakePercent;
779779
}
780780
else
781-
{
781+
{
782782
EngineBrakePercent = 0;
783783
}
784784
}
@@ -1052,15 +1052,15 @@ public void SpeedRegulatorMaxForceChangeByMouse(float value)
10521052
var oldValue = controller.IntermediateValue;
10531053
var change = controller.SetValue(value);
10541054
if (change != 0)
1055-
{
1056-
Locomotive.SignalEvent(Common.Event.CruiseControlMaxForce);
1057-
}
1055+
{
1056+
Locomotive.SignalEvent(Common.Event.CruiseControlMaxForce);
1057+
}
10581058
if (oldValue != controller.IntermediateValue)
10591059
Simulator.Confirmer.UpdateWithPerCent(
10601060
CabControl.MaxAcceleration,
10611061
oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease,
10621062
controller.CurrentValue * 100);
1063-
}
1063+
}
10641064
public void SpeedRegulatorSelectedSpeedStartIncrease()
10651065
{
10661066
var mpc = Locomotive.MultiPositionControllers.Where(x =>
@@ -1079,9 +1079,9 @@ public void SpeedRegulatorSelectedSpeedStartIncrease()
10791079
return;
10801080
}
10811081
if (SpeedSelectorController.CurrentValue == 0)
1082-
{
1083-
Locomotive.SignalEvent(Common.Event.LeverFromZero);
1084-
}
1082+
{
1083+
Locomotive.SignalEvent(Common.Event.LeverFromZero);
1084+
}
10851085
if (UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || (UseThrottleAsForceSelector && mpc == null ))
10861086
SpeedSelectorController.StartIncrease();
10871087
else
@@ -1261,30 +1261,30 @@ public void UpdateRequiredForce(float elapsedClockSeconds, bool tractionAllowed)
12611261
// da/dv = -srsd / 2 / sqrt((vset-v) * srsd) which diverges when v = vset
12621262
if (SpeedDeltaFunctionMode == SpeedDeltaMode.Sqrt)
12631263
demandedAccelerationMpSS = (float)-Math.Sqrt(-demandedAccelerationMpSS);
1264-
}
1264+
}
12651265
else if (deltaSpeedMpS > SpeedDeltaToStartAcceleratingMpS || (deltaSpeedMpS > SpeedDeltaToStopAcceleratingMpS && prevDemandedAccelerationMpSS > 0))
12661266
{
12671267
demandedAccelerationMpSS = (deltaSpeedMpS - SpeedDeltaAcceleratingOffsetMpS) * StartReducingSpeedDelta;
12681268
if (SpeedDeltaFunctionMode == SpeedDeltaMode.Sqrt)
12691269
demandedAccelerationMpSS = (float)Math.Sqrt(demandedAccelerationMpSS);
1270-
}
1270+
}
12711271
prevDemandedAccelerationMpSS = demandedAccelerationMpSS;
12721272
if (ASCAccelerationMpSS > 0)
12731273
demandedAccelerationMpSS = MathHelper.Clamp(demandedAccelerationMpSS + ASCAccelerationMpSS, -MaxDecelerationMpSS, MaxAccelerationMpSS + ASCAccelerationMpSS);
1274-
else
1274+
else
12751275
demandedAccelerationMpSS = MathHelper.Clamp(demandedAccelerationMpSS + ASCAccelerationMpSS, -MaxDecelerationMpSS + ASCAccelerationMpSS, MaxAccelerationMpSS);
12761276

12771277
float totalTractionN = 0;
12781278
float totalDynamicBrakeN = 0;
12791279
float totalTrainBrakeN = 0;
12801280
float totalMassKg = 0;
12811281
foreach (var car in Locomotive.Train.Cars)
1282-
{
1282+
{
12831283
if (car is MSTSLocomotive locomotive)
1284-
{
1284+
{
12851285
totalTractionN += locomotive.GetAvailableTractionForceN(1);
12861286
totalDynamicBrakeN += locomotive.GetAvailableDynamicBrakeForceN(1);
1287-
}
1287+
}
12881288
totalTrainBrakeN += car.FrictionBrakeBlendingMaxForceN; // TODO: consider changes with speed
12891289
totalMassKg += car.MassKG;
12901290
}
@@ -1293,16 +1293,16 @@ public void UpdateRequiredForce(float elapsedClockSeconds, bool tractionAllowed)
12931293
MaxTrainBrakeDecelerationMpSS = totalTrainBrakeN / totalMassKg;
12941294
float maxThrottleAccelerationMpSS = MaxThrottleAccelerationMpSS;
12951295
if (maxThrottleAccelerationMpSS < 0.01f)
1296-
{
1296+
{
12971297
float coeff = Math.Max(MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph) / 100 * 1.2f, 1);
12981298
maxThrottleAccelerationMpSS = 1.5f / coeff;
1299-
}
1299+
}
13001300
float maxDynamicBrakeDecelerationMpSS = MaxDynamicBrakeDecelerationMpSS;
13011301
if (maxDynamicBrakeDecelerationMpSS < 0.01f)
13021302
{
13031303
float coeff = Math.Max(MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph) / 100 * 1.2f, 1);
13041304
maxDynamicBrakeDecelerationMpSS = 1.5f / coeff;
1305-
}
1305+
}
13061306
float maxTrainBrakeDecelerationMpSS = MaxTrainBrakeDecelerationMpSS;
13071307
if (MaxTrainBrakeDecelerationMpSS < 0.01f)
13081308
{
@@ -1317,36 +1317,36 @@ public void UpdateRequiredForce(float elapsedClockSeconds, bool tractionAllowed)
13171317
{
13181318
float a = AccelerationTable[SelectedMaxAccelerationStep - 1];
13191319
if (a > 0 && a < targetThrottleAccelerationMpSS) targetThrottleAccelerationMpSS = a;
1320-
}
1320+
}
13211321
float maxThrottlePercent = 0;
13221322
if (tractionAllowed && Locomotive.TrainControlSystem.TractionAuthorization && DynamicBrakePID.Percent <= 0 && TrainBrakePID.Percent <= 0 && (demandedAccelerationMpSS > 0 || ThrottlePID.Percent > 0))
1323-
{
1323+
{
13241324
// Max throttle percent is determined by the force selector
13251325
maxThrottlePercent = SelectedMaxAccelerationStep > 0 && ForceStepsThrottleTable.Count >= SelectedMaxAccelerationStep && !SpeedRegulatorMaxForcePercentUnits ? ForceStepsThrottleTable[SelectedMaxAccelerationStep - 1] : SelectedMaxAccelerationPercent;
1326-
if (MaxPowerThreshold > 0)
1327-
{
1326+
if (MaxPowerThreshold > 0)
1327+
{
13281328
// Linearly increase max throttle percent until max force is available when speed reaches MaxPowerThreshold
1329-
float currentSpeed = MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph);
1329+
float currentSpeed = MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph);
13301330
float overridePercent = (100 * currentSpeed) / MaxPowerThreshold;
13311331
maxThrottlePercent = Math.Max(Math.Min(overridePercent, 100), maxThrottlePercent);
1332-
}
1332+
}
13331333
if (reducingForce) maxThrottlePercent = Math.Min(maxThrottlePercent, PowerReductionValue);
13341334
}
13351335
ThrottlePID.Update(elapsedClockSeconds, targetThrottleAccelerationMpSS, RelativeAccelerationMpSS, 0, maxThrottlePercent);
13361336

13371337
float minDynamicBrakePercent = 0;
13381338
float maxDynamicBrakePercent = 0;
13391339
if (Locomotive.DynamicBrakeAvailable && UseDynBrake && ThrottlePID.Percent <= 0 && (demandedAccelerationMpSS < 0 || DynamicBrakePID.Percent > 0))
1340-
{
1340+
{
13411341
// If train brake is active, we force dynamic brakes to stay active to give preference to brake release
13421342
minDynamicBrakePercent = CCIsUsingTrainBrake ? MinDynamicBrakePercentWhileUsingTrainBrake : 0;
13431343
maxDynamicBrakePercent = DynamicBrakeIsSelectedForceDependant ? SelectedMaxAccelerationPercent : 100;
1344-
}
1344+
}
13451345
DynamicBrakePID.Update(elapsedClockSeconds, -demandedAccelerationMpSS, AbsWheelSpeedMpS > 0 ? -RelativeAccelerationMpSS : -demandedAccelerationMpSS, minDynamicBrakePercent, maxDynamicBrakePercent);
13461346
float target = ThrottlePID.Percent - DynamicBrakePID.Percent;
1347-
if (target > CCThrottleOrDynBrakePercent)
1347+
if (target > CCThrottleOrDynBrakePercent)
13481348
IncreaseForce(ref CCThrottleOrDynBrakePercent, elapsedClockSeconds, target);
1349-
else if (target < CCThrottleOrDynBrakePercent)
1349+
else if (target < CCThrottleOrDynBrakePercent)
13501350
DecreaseForce(ref CCThrottleOrDynBrakePercent, elapsedClockSeconds, target);
13511351
UpdateTrainBrakePercent(elapsedClockSeconds, demandedAccelerationMpSS);
13521352
}

0 commit comments

Comments
 (0)