Skip to content

Commit 2329220

Browse files
committed
Automatic merge of T1.6-89-ga2a9bbcc8 and 11 pull requests
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window - Pull request #1086 at d8d61eb: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at e813c42: Automatic speed control - Pull request #1115 at 270f22f: Do not activate ETS switch if no suitable cars are attached - Pull request #1120 at ba3c47f: Automatically Calculate Friction Values if Missing - Pull request #1121 at 91d2d26: Manually Override Articulation - Pull request #1124 at e241a0d: Built-in PBL2 brake controller - Pull request #1157 at 39cd994: Dynamic brake authorization by TCS - Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1128 at 1d7643d: Particle Emitter Overhaul
13 parents 6e049f4 + a2a9bbc + f46d5f2 + d8d61eb + e813c42 + 270f22f + ba3c47f + 91d2d26 + e241a0d + 39cd994 + 48c9a63 + 5845a1a + 1d7643d commit 2329220

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,11 +1687,11 @@ public override void Initialize()
16871687
{
16881688
if (axle.DriveType != AxleDriveType.NotDriven)
16891689
{
1690-
InductionMotor motor = new InductionMotor(axle, this);
1691-
TractionMotors.Add(motor);
1690+
InductionMotor motor = new InductionMotor(axle, this);
1691+
TractionMotors.Add(motor);
1692+
}
16921693
}
16931694
}
1694-
}
16951695
SlipControlActive = new bool[LocomotiveAxles.Count];
16961696
if (SlipControlSystem == SlipControlType.Unknown)
16971697
{
@@ -3788,9 +3788,9 @@ public void StartThrottleDecrease()
37883788
var mpc = MultiPositionControllers.Where(x => x.controllerBinding == ControllerBinding.Throttle).FirstOrDefault();
37893789
if (mpc != null)
37903790
{
3791-
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedMaxAccelerationPercent != 0
3792-
&& CruiseControl.HasIndependentThrottleDynamicBrakeLever)
3793-
return;
3791+
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedMaxAccelerationPercent != 0
3792+
&& CruiseControl.HasIndependentThrottleDynamicBrakeLever)
3793+
return;
37943794
if (!mpc.StateChanged)
37953795
{
37963796
mpc.StateChanged = true;
@@ -3964,8 +3964,8 @@ public void AdjustNotchedThrottle(bool increase)
39643964
}
39653965
else
39663966
{
3967-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.Throttle, ThrottleController.CurrentValue * 100);
3968-
}
3967+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.Throttle, ThrottleController.CurrentValue * 100);
3968+
}
39693969
}
39703970

39713971
public void SetThrottleValue(float value)
@@ -3997,17 +3997,17 @@ public void SetThrottleValue(float value)
39973997
}
39983998
else
39993999
{
4000-
Simulator.Confirmer.UpdateWithPerCent(
4001-
this is MSTSSteamLocomotive ? CabControl.Regulator : CabControl.Throttle,
4002-
oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease,
4003-
controller.CurrentValue * 100);
4004-
}
4000+
Simulator.Confirmer.UpdateWithPerCent(
4001+
this is MSTSSteamLocomotive ? CabControl.Regulator : CabControl.Throttle,
4002+
oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease,
4003+
controller.CurrentValue * 100);
4004+
}
40054005
}
40064006
}
40074007

40084008
public void SetThrottlePercent(float percent)
40094009
{
4010-
ThrottleController.SetPercent(percent);
4010+
ThrottleController.SetPercent(percent);
40114011
}
40124012

40134013
public void SetThrottlePercentWithSound(float percent)
@@ -4105,7 +4105,7 @@ public float GetCombinedHandleValue(bool intermediateValue)
41054105
var brakesValue = intermediateValue ? TrainBrakeController?.IntermediateValue : TrainBrakeController?.CurrentValue;
41064106

41074107
if (CombinedControlType == CombinedControl.ThrottleDynamic && throttleValue <= 0 && dynamicsValue > 0)
4108-
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (dynamicsValue ?? 0);
4108+
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (dynamicsValue ?? 0);
41094109
else if (CombinedControlType == CombinedControl.ThrottleAir && throttleValue <= 0 && brakesValue > 0)
41104110
return CombinedControlSplitPosition + (1 - CombinedControlSplitPosition) * (brakesValue ?? 0);
41114111
else
@@ -5104,7 +5104,7 @@ public virtual float GetDataOf(CabViewControl cvc)
51045104
{
51055105
case CABViewControlTypes.SPEEDOMETER:
51065106
{
5107-
data = WheelSpeedMpS;
5107+
data = WheelSpeedMpS;
51085108

51095109
if (cvc.Units == CABViewControlUnits.KM_PER_HOUR)
51105110
data *= 3.6f;

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

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

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

505-
if (StartInAutoMode) SpeedRegMode = SpeedRegulatorMode.Auto;
505+
if (StartInAutoMode) SpeedRegMode = SpeedRegulatorMode.Auto;
506506

507507
if (UseThrottleAsForceSelector)
508508
{
@@ -760,7 +760,7 @@ public void Update(float elapsedClockSeconds)
760760
}
761761
else
762762
{
763-
CCThrottleOrDynBrakePercent = 0;
763+
CCThrottleOrDynBrakePercent = 0;
764764
TrainBrakePercent = null;
765765
ThrottlePID.Active = false;
766766
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
}
@@ -1057,15 +1057,15 @@ public void SpeedRegulatorMaxForceChangeByMouse(float value)
10571057
var oldValue = controller.IntermediateValue;
10581058
var change = controller.SetValue(value);
10591059
if (change != 0)
1060-
{
1061-
Locomotive.SignalEvent(Common.Event.CruiseControlMaxForce);
1062-
}
1060+
{
1061+
Locomotive.SignalEvent(Common.Event.CruiseControlMaxForce);
1062+
}
10631063
if (oldValue != controller.IntermediateValue)
10641064
Simulator.Confirmer.UpdateWithPerCent(
10651065
CabControl.MaxAcceleration,
10661066
oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease,
10671067
controller.CurrentValue * 100);
1068-
}
1068+
}
10691069
public void SpeedRegulatorSelectedSpeedStartIncrease()
10701070
{
10711071
var mpc = Locomotive.MultiPositionControllers.Where(x =>
@@ -1084,9 +1084,9 @@ public void SpeedRegulatorSelectedSpeedStartIncrease()
10841084
return;
10851085
}
10861086
if (SpeedSelectorController.CurrentValue == 0)
1087-
{
1088-
Locomotive.SignalEvent(Common.Event.LeverFromZero);
1089-
}
1087+
{
1088+
Locomotive.SignalEvent(Common.Event.LeverFromZero);
1089+
}
10901090
if (UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || (UseThrottleAsForceSelector && mpc == null ))
10911091
SpeedSelectorController.StartIncrease();
10921092
else
@@ -1266,30 +1266,30 @@ public void UpdateRequiredForce(float elapsedClockSeconds, bool tractionAllowed)
12661266
// da/dv = -srsd / 2 / sqrt((vset-v) * srsd) which diverges when v = vset
12671267
if (SpeedDeltaFunctionMode == SpeedDeltaMode.Sqrt)
12681268
demandedAccelerationMpSS = (float)-Math.Sqrt(-demandedAccelerationMpSS);
1269-
}
1269+
}
12701270
else if (deltaSpeedMpS > SpeedDeltaToStartAcceleratingMpS || (deltaSpeedMpS > SpeedDeltaToStopAcceleratingMpS && prevDemandedAccelerationMpSS > 0))
12711271
{
12721272
demandedAccelerationMpSS = (deltaSpeedMpS - SpeedDeltaAcceleratingOffsetMpS) * StartReducingSpeedDelta;
12731273
if (SpeedDeltaFunctionMode == SpeedDeltaMode.Sqrt)
12741274
demandedAccelerationMpSS = (float)Math.Sqrt(demandedAccelerationMpSS);
1275-
}
1275+
}
12761276
prevDemandedAccelerationMpSS = demandedAccelerationMpSS;
12771277
if (ASCAccelerationMpSS > 0)
12781278
demandedAccelerationMpSS = MathHelper.Clamp(demandedAccelerationMpSS + ASCAccelerationMpSS, -MaxDecelerationMpSS, MaxAccelerationMpSS + ASCAccelerationMpSS);
1279-
else
1279+
else
12801280
demandedAccelerationMpSS = MathHelper.Clamp(demandedAccelerationMpSS + ASCAccelerationMpSS, -MaxDecelerationMpSS + ASCAccelerationMpSS, MaxAccelerationMpSS);
12811281

12821282
float totalTractionN = 0;
12831283
float totalDynamicBrakeN = 0;
12841284
float totalTrainBrakeN = 0;
12851285
float totalMassKg = 0;
12861286
foreach (var car in Locomotive.Train.Cars)
1287-
{
1287+
{
12881288
if (car is MSTSLocomotive locomotive)
1289-
{
1289+
{
12901290
totalTractionN += locomotive.GetAvailableTractionForceN(1);
12911291
totalDynamicBrakeN += locomotive.GetAvailableDynamicBrakeForceN(1);
1292-
}
1292+
}
12931293
totalTrainBrakeN += car.FrictionBrakeBlendingMaxForceN; // TODO: consider changes with speed
12941294
totalMassKg += car.MassKG;
12951295
}
@@ -1298,16 +1298,16 @@ public void UpdateRequiredForce(float elapsedClockSeconds, bool tractionAllowed)
12981298
MaxTrainBrakeDecelerationMpSS = totalTrainBrakeN / totalMassKg;
12991299
float maxThrottleAccelerationMpSS = MaxThrottleAccelerationMpSS;
13001300
if (maxThrottleAccelerationMpSS < 0.01f)
1301-
{
1301+
{
13021302
float coeff = Math.Max(MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph) / 100 * 1.2f, 1);
13031303
maxThrottleAccelerationMpSS = 1.5f / coeff;
1304-
}
1304+
}
13051305
float maxDynamicBrakeDecelerationMpSS = MaxDynamicBrakeDecelerationMpSS;
13061306
if (maxDynamicBrakeDecelerationMpSS < 0.01f)
13071307
{
13081308
float coeff = Math.Max(MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph) / 100 * 1.2f, 1);
13091309
maxDynamicBrakeDecelerationMpSS = 1.5f / coeff;
1310-
}
1310+
}
13111311
float maxTrainBrakeDecelerationMpSS = MaxTrainBrakeDecelerationMpSS;
13121312
if (MaxTrainBrakeDecelerationMpSS < 0.01f)
13131313
{
@@ -1322,36 +1322,36 @@ public void UpdateRequiredForce(float elapsedClockSeconds, bool tractionAllowed)
13221322
{
13231323
float a = AccelerationTable[SelectedMaxAccelerationStep - 1];
13241324
if (a > 0 && a < targetThrottleAccelerationMpSS) targetThrottleAccelerationMpSS = a;
1325-
}
1325+
}
13261326
float maxThrottlePercent = 0;
13271327
if (tractionAllowed && Locomotive.TrainControlSystem.TractionAuthorization && DynamicBrakePID.Percent <= 0 && TrainBrakePID.Percent <= 0 && (demandedAccelerationMpSS > 0 || ThrottlePID.Percent > 0))
1328-
{
1328+
{
13291329
// Max throttle percent is determined by the force selector
13301330
maxThrottlePercent = SelectedMaxAccelerationStep > 0 && ForceStepsThrottleTable.Count >= SelectedMaxAccelerationStep && !SpeedRegulatorMaxForcePercentUnits ? ForceStepsThrottleTable[SelectedMaxAccelerationStep - 1] : SelectedMaxAccelerationPercent;
1331-
if (MaxPowerThreshold > 0)
1332-
{
1331+
if (MaxPowerThreshold > 0)
1332+
{
13331333
// Linearly increase max throttle percent until max force is available when speed reaches MaxPowerThreshold
1334-
float currentSpeed = MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph);
1334+
float currentSpeed = MpS.FromMpS(AbsWheelSpeedMpS, !SpeedIsMph);
13351335
float overridePercent = (100 * currentSpeed) / MaxPowerThreshold;
13361336
maxThrottlePercent = Math.Max(Math.Min(overridePercent, 100), maxThrottlePercent);
1337-
}
1337+
}
13381338
if (reducingForce) maxThrottlePercent = Math.Min(maxThrottlePercent, PowerReductionValue);
13391339
}
13401340
ThrottlePID.Update(elapsedClockSeconds, targetThrottleAccelerationMpSS, RelativeAccelerationMpSS, 0, maxThrottlePercent);
13411341

13421342
float minDynamicBrakePercent = 0;
13431343
float maxDynamicBrakePercent = 0;
13441344
if (Locomotive.DynamicBrakeAvailable && UseDynBrake && ThrottlePID.Percent <= 0 && (demandedAccelerationMpSS < 0 || DynamicBrakePID.Percent > 0))
1345-
{
1345+
{
13461346
// If train brake is active, we force dynamic brakes to stay active to give preference to brake release
13471347
minDynamicBrakePercent = CCIsUsingTrainBrake ? MinDynamicBrakePercentWhileUsingTrainBrake : 0;
13481348
maxDynamicBrakePercent = DynamicBrakeIsSelectedForceDependant ? SelectedMaxAccelerationPercent : 100;
1349-
}
1349+
}
13501350
DynamicBrakePID.Update(elapsedClockSeconds, -demandedAccelerationMpSS, AbsWheelSpeedMpS > 0 ? -RelativeAccelerationMpSS : -demandedAccelerationMpSS, minDynamicBrakePercent, maxDynamicBrakePercent);
13511351
float target = ThrottlePID.Percent - DynamicBrakePID.Percent;
1352-
if (target > CCThrottleOrDynBrakePercent)
1352+
if (target > CCThrottleOrDynBrakePercent)
13531353
IncreaseForce(ref CCThrottleOrDynBrakePercent, elapsedClockSeconds, target);
1354-
else if (target < CCThrottleOrDynBrakePercent)
1354+
else if (target < CCThrottleOrDynBrakePercent)
13551355
DecreaseForce(ref CCThrottleOrDynBrakePercent, elapsedClockSeconds, target);
13561356
UpdateTrainBrakePercent(elapsedClockSeconds, demandedAccelerationMpSS);
13571357
}

0 commit comments

Comments
 (0)