Skip to content

Commit 45c3a4a

Browse files
committed
Further refinements to cruise control
1 parent 5553e93 commit 45c3a4a

File tree

3 files changed

+105
-85
lines changed

3 files changed

+105
-85
lines changed

Source/Orts.Simulation/Common/Scripting/TrainControlSystem.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,15 @@ internal void AttachToHost(ScriptedTrainControlSystem host)
356356
/// Set dynamic brake controller to position in range [0-1].
357357
/// </summary>
358358
public Action<float> SetDynamicBrakeController;
359+
/// <summary>
360+
/// Sets the target speed of the automatic traction/braking system
361+
/// Gets the current speed enforced by the automatic traction/braking system
362+
/// </summary>
359363
public float? SetSpeedMpS
360364
{
361365
get
362366
{
363-
if (Locomotive?.CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto) return Locomotive.CruiseControl.SetSpeedMpS;
367+
if (Locomotive.CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto) return Locomotive.CruiseControl.SetSpeedMpS;
364368
return null;
365369
}
366370
set
@@ -369,6 +373,20 @@ public float? SetSpeedMpS
369373
}
370374
}
371375
/// <summary>
376+
/// Controls the target acceleration of the automatic traction/braking system when a braking curve is active
377+
/// </summary>
378+
public float SetSpeedAccelerationMpSS
379+
{
380+
get
381+
{
382+
return Locomotive?.CruiseControl.ATOAccelerationMpSS ?? 0;
383+
}
384+
set
385+
{
386+
if (Locomotive.CruiseControl != null) Locomotive.CruiseControl.ATOAccelerationMpSS = value;
387+
}
388+
}
389+
/// <summary>
372390
/// Cut power by pull all pantographs down.
373391
/// </summary>
374392
public Action SetPantographsDown;

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ public override void Update(float elapsedClockSeconds)
17731773
}
17741774
else
17751775
{
1776-
var dynforce = loco.DynamicBrakeForceCurves.Get(1.0f, loco.AbsSpeedMpS);
1776+
var dynforce = loco.GetAvailableDynamicBrakeForceN(1.0f);
17771777
if ((loco.MaxDynamicBrakeForceN == 0 && dynforce > 0) || dynforce > loco.MaxDynamicBrakeForceN * 0.6)
17781778
{
17791779
demandedPressurePSI = 0;

0 commit comments

Comments
 (0)