Skip to content

Commit 575996f

Browse files
committed
Automatic merge of T1.6-59-g2eb7441b0 and 11 pull requests
- Pull request #1156 at c1f443e: 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 #1104 at 7919243: Handle simple adhesion within the axle module - 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 #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1128 at 1d7643d: Particle Emitter Overhaul
13 parents c847769 + 2eb7441 + c1f443e + d8d61eb + e813c42 + 7919243 + 270f22f + ba3c47f + 91d2d26 + e241a0d + 39cd994 + 5845a1a + 1d7643d commit 575996f

File tree

12 files changed

+349
-393
lines changed

12 files changed

+349
-393
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected override void SetCurrentMainPowerSupplyState(PowerSupplyState state) {
4949
protected override void SetCurrentAuxiliaryPowerSupplyState(PowerSupplyState state) {}
5050
protected override void SetCurrentElectricTrainSupplyState(PowerSupplyState state) {}
5151
protected override void SetCurrentDynamicBrakeAvailability(bool avail) {}
52+
public override PowerSupplyState GetPowerStatus() => PowerSupplyState.Unavailable;
5253
public void SignalEventToControlActiveLocomotive(PowerSupplyEvent evt)
5354
{
5455
ControlActiveLocomotive?.LocomotivePowerSupply.HandleEvent(evt);

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,27 @@ public float DieselEngineMinRpm
9090
/// Closing authorization of the traction cut-off relay
9191
/// </summary>
9292
public bool TractionCutOffRelayClosingAuthorization() => TractionCutOffRelay.ClosingAuthorization;
93-
93+
94+
public override PowerSupplyState GetPowerStatus()
95+
{
96+
var status = base.GetPowerStatus();
97+
PowerSupplyState engineStatus;
98+
switch (CurrentDieselEnginesState())
99+
{
100+
case DieselEngineState.Running:
101+
engineStatus = PowerSupplyState.PowerOn;
102+
break;
103+
case DieselEngineState.Starting:
104+
engineStatus = PowerSupplyState.PowerOnOngoing;
105+
break;
106+
default:
107+
engineStatus = PowerSupplyState.PowerOff;
108+
break;
109+
}
110+
if (status == engineStatus) return status;
111+
return PowerSupplyState.PowerOnOngoing;
112+
}
113+
94114
/// <summary>
95115
/// Sends an event to all diesel engines
96116
/// </summary>

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,34 @@ protected float PantographVoltageVDC
128128
/// </summary>
129129
protected void SetFilterVoltageV(float voltage) => EpsHost.FilterVoltageV = voltage;
130130

131+
public override PowerSupplyState GetPowerStatus()
132+
{
133+
var status = base.GetPowerStatus();
134+
PowerSupplyState electricStatus;
135+
switch (CurrentPantographState())
136+
{
137+
case PantographState.Up:
138+
switch (CurrentCircuitBreakerState())
139+
{
140+
case CircuitBreakerState.Closed:
141+
electricStatus = PowerSupplyState.PowerOn;
142+
break;
143+
default:
144+
electricStatus = PowerSupplyState.PowerOnOngoing;
145+
break;
146+
}
147+
break;
148+
case PantographState.Raising:
149+
electricStatus = PowerSupplyState.PowerOnOngoing;
150+
break;
151+
default:
152+
electricStatus = PowerSupplyState.PowerOff;
153+
break;
154+
}
155+
if (status == electricStatus) return status;
156+
return PowerSupplyState.PowerOnOngoing;
157+
}
158+
131159
/// <summary>
132160
/// Sends an event to the circuit breaker
133161
/// </summary>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,20 @@ protected void SetCustomizedCabviewControlName(int index, string name)
312312
/// </summary>
313313
protected virtual void SetCurrentDynamicBrakeAvailability(bool avail) => LpsHost.DynamicBrakeAvailable = avail;
314314

315+
/// <summary>
316+
/// Called by other subsystems to determine whether the locomotive is powered
317+
/// </summary>
318+
/// <returns>
319+
/// PowerSupplyState.PowerOff if the locomotive is unpowered
320+
/// PowerSupplyState.PowerOnOngoing if the locomotive is in a power on sequence, but not all subsystems are ready
321+
/// PowerSupplyState.PowerOn if the locomotive is ready for service (all necessary subystems are connected)
322+
/// </returns>
323+
public virtual PowerSupplyState GetPowerStatus()
324+
{
325+
if (LpsHost.MainPowerSupplyState == LpsHost.AuxiliaryPowerSupplyState) return LpsHost.MainPowerSupplyState;
326+
return PowerSupplyState.PowerOnOngoing;
327+
}
328+
315329
/// <summary>
316330
/// Sends an event to the master switch
317331
/// </summary>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public interface ILocomotivePowerSupply : IPowerSupply
4747
bool ServiceRetentionCancellationButton { get; set; }
4848
bool ServiceRetentionActive { get; set; }
4949

50+
PowerSupplyState GetPowerStatus();
51+
5052
void HandleEventFromTcs(PowerSupplyEvent evt);
5153
void HandleEventFromTcs(PowerSupplyEvent evt, int id);
5254
void HandleEventFromTcs(PowerSupplyEvent evt, string message);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ public virtual void Update(float elapsedClockSeconds)
266266
ElectricTrainSupplySwitch.Update(elapsedClockSeconds);
267267
}
268268

269+
public PowerSupplyState GetPowerStatus() => AbstractScript?.GetPowerStatus() ?? PowerSupplyState.Unavailable;
270+
269271
public void HandleEvent(PowerSupplyEvent evt)
270272
{
271273
AbstractScript?.HandleEvent(evt);

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,15 +1840,14 @@ public void UncoupleBehind(TrainCar car, bool keepFront)
18401840
train.activityClearingDistanceM = train.Cars.Count < Train.standardTrainMinCarNo ? Train.shortClearingDistanceM : Train.standardClearingDistanceM;
18411841
train2.activityClearingDistanceM = train2.Cars.Count < Train.standardTrainMinCarNo ? Train.shortClearingDistanceM : Train.standardClearingDistanceM;
18421842

1843+
18431844
train.UncoupledFrom = train2;
18441845
train2.UncoupledFrom = train;
18451846

18461847
train2.SpeedMpS = train.SpeedMpS;
18471848

1848-
train.Cars[0].BrakeSystem.FrontBrakeHoseConnected = false;
18491849
train.Cars[train.Cars.Count - 1].BrakeSystem.RearBrakeHoseConnected = false;
18501850
train2.Cars[0].BrakeSystem.FrontBrakeHoseConnected = false;
1851-
train2.Cars[train2.Cars.Count - 1].BrakeSystem.RearBrakeHoseConnected = false;
18521851

18531852
train2.AITrainDirectionForward = train.AITrainDirectionForward;
18541853

8.01 KB
Loading

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,24 +1083,8 @@ protected override void OnActivate(bool sameCamera)
10831083
isVisibleTrainCarViewerOrWebpage = (Viewer.TrainCarOperationsWindow.Visible && !Viewer.TrainCarOperationsViewerWindow.Visible) || Viewer.TrainCarOperationsViewerWindow.Visible || (Viewer.TrainCarOperationsWebpage?.Connections > 0 && Viewer.TrainCarOperationsWebpage.TrainCarSelected);
10841084
}
10851085

1086-
if (isVisibleTrainCarViewerOrWebpage)
1087-
{
1088-
// Update the camera view
1089-
oldCarPosition = oldCarPosition == 0 && carPosition == 0 ? -1 : oldCarPosition;
1090-
}
1091-
1092-
if (attachedCar != null && !isVisibleTrainCarViewerOrWebpage)
1093-
{ // Reset behaviour of camera 2 and camera 3, after closing F9-window and F9-web.
1094-
var attachedCarPosition = attachedCar.Train.Cars.TakeWhile(x => x.CarID != attachedCar.CarID).Count();
1095-
if (Front && attachedCarPosition == carPosition)
1096-
{
1097-
attachedCar = trainCars.First();
1098-
}
1099-
if (!Front && attachedCarPosition == carPosition)
1100-
{
1101-
attachedCar = trainCars.Last();
1102-
}
1103-
}
1086+
// Update the camera view
1087+
oldCarPosition = oldCarPosition == 0 && carPosition == 0 ? -1 : oldCarPosition;
11041088

11051089
if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition)
11061090
{

0 commit comments

Comments
 (0)