Skip to content

Commit dfe18e6

Browse files
committed
Demand reduced throttle by power supply
1 parent 705ec65 commit dfe18e6

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

Source/Orts.Simulation/Common/Scripting/PowerSupply/LocomotivePowerSupply.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ protected float MaxThrottlePercent
151151
}
152152
}
153153

154+
/// <summary>
155+
/// Reduction of throttle percent enforced by power supply
156+
/// </summary>
157+
protected float ThrottleReductionPercent
158+
{
159+
get
160+
{
161+
return LpsHost.ThrottleReductionPercent;
162+
}
163+
set
164+
{
165+
LpsHost.ThrottleReductionPercent = Math.Max(Math.Min(value, 100), 0);
166+
}
167+
}
168+
154169
/// <summary>
155170
/// Current throttle percentage
156171
/// </summary>

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/ILocomotivePowerSupply.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public interface ILocomotivePowerSupply : IPowerSupply
3535
float PowerSupplyDynamicBrakePercent { get; set; }
3636
float MaximumDynamicBrakePowerW { get; set; }
3737
float MaxThrottlePercent { get; set; }
38+
float ThrottleReductionPercent { get; set; }
3839

3940
PowerSupplyState AuxiliaryPowerSupplyState { get; set; }
4041
bool AuxiliaryPowerSupplyOn { get; }

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/LocomotivePowerSupply.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public abstract class ScriptedLocomotivePowerSupply : ILocomotivePowerSupply
5353
public float PowerSupplyDynamicBrakePercent { get; set; } = -1;
5454
public float MaximumDynamicBrakePowerW { get; set; } = 0;
5555
public float MaxThrottlePercent { get; set; } = 100;
56+
public float ThrottleReductionPercent { get; set; } = 0;
5657

5758
public PowerSupplyState AuxiliaryPowerSupplyState { get; set; } = PowerSupplyState.PowerOff;
5859
public bool AuxiliaryPowerSupplyOn => AuxiliaryPowerSupplyState == PowerSupplyState.PowerOn;

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/SteamPowerSupply.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public bool DynamicBrakeAvailable
5858
public float PowerSupplyDynamicBrakePercent { get; set; } = -1;
5959
public float MaximumDynamicBrakePowerW { get; set; } = 0;
6060
public float MaxThrottlePercent { get; set; } = 100;
61+
public float ThrottleReductionPercent { get; set; } = 0;
6162

6263
public PowerSupplyState AuxiliaryPowerSupplyState
6364
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public float ThrottlePercent
458458
}
459459
if (this is MSTSLocomotive loco)
460460
{
461+
if (loco.LocomotivePowerSupply.ThrottleReductionPercent > 0) percent *= 1-loco.LocomotivePowerSupply.ThrottleReductionPercent/100;
461462
if (loco.LocomotivePowerSupply.MaxThrottlePercent < percent) percent = Math.Max(loco.LocomotivePowerSupply.MaxThrottlePercent, 0);
462463
}
463464
return percent;

0 commit comments

Comments
 (0)