Skip to content

Commit 37dbd8e

Browse files
committed
Start to add power supply to control car
1 parent 4861181 commit 37dbd8e

File tree

5 files changed

+146
-2
lines changed

5 files changed

+146
-2
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//// COPYRIGHT 2021 by the Open Rails project.
2+
//
3+
// This file is part of Open Rails.
4+
//
5+
// Open Rails is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Open Rails is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
17+
18+
using System;
19+
20+
namespace ORTS.Scripting.Api
21+
{
22+
/// <summary>
23+
/// Power supply for control cars
24+
/// </summary>
25+
public abstract class ControlCarPowerSupply : LocomotivePowerSupply
26+
{
27+
28+
29+
30+
31+
32+
33+
}
34+
35+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public enum PowerSupplyType
153153
[GetParticularString("PowerSupply", "DieselElectric")] DieselElectric,
154154
[GetParticularString("PowerSupply", "Electric")] Electric,
155155
[GetParticularString("PowerSupply", "DualMode")] DualMode,
156+
[GetParticularString("PowerSupply", "ControlCar")] ControlCar,
156157
}
157158

158159
public enum PowerSupplyState

Source/Orts.Simulation/Orts.Simulation.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<Compile Include="Common\Scripting\BrakeController.cs" />
6666
<Compile Include="Common\Scripting\Commands.cs" />
6767
<Compile Include="Common\Scripting\Common.cs" />
68+
<Compile Include="Common\Scripting\PowerSupply\ControlCarPowerSupply.cs" />
6869
<Compile Include="Common\Scripting\PowerSupply\DualModePowerSupply.cs" />
6970
<Compile Include="Common\Scripting\PowerSupply\LocomotivePowerSupply.cs" />
7071
<Compile Include="Common\Scripting\PowerSupply\PassengerCarPowerSupply.cs" />
@@ -120,6 +121,7 @@
120121
<Compile Include="Simulation\RollingStocks\SubSystems\Controllers\MSTSBrakeController.cs" />
121122
<Compile Include="Simulation\RollingStocks\SubSystems\Controllers\MSTSNotchController.cs" />
122123
<Compile Include="Simulation\RollingStocks\SubSystems\FreightAnimations.cs" />
124+
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\ControlCarPowerSupply.cs" />
123125
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\ElectricTrainSupplySwitch.cs" />
124126
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\BatterySwitch.cs" />
125127
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\DualModePowerSupply.cs" />

Source/Orts.Simulation/Simulation/RollingStocks/MSTSControlTrailerCar.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545

4646
namespace Orts.Simulation.RollingStocks
4747
{
48-
class MSTSControlTrailerCar : MSTSLocomotive
48+
public class MSTSControlTrailerCar : MSTSLocomotive
4949
{
5050

5151
public MSTSControlTrailerCar(Simulator simulator, string wagFile)
5252
: base(simulator, wagFile)
5353
{
5454

55-
// PowerSupply = new ScriptedDieselPowerSupply(this);
55+
PowerSupply = new ScriptedControlCarPowerSupply(this);
5656

5757
}
5858

@@ -74,6 +74,34 @@ public override void Initialize()
7474
}
7575

7676

77+
/// <summary>
78+
/// Parse the wag file parameters required for the simulator and viewer classes
79+
/// </summary>
80+
public override void Parse(string lowercasetoken, STFReader stf)
81+
{
82+
switch (lowercasetoken)
83+
{
84+
case "engine(ortspowerondelay":
85+
case "engine(ortsauxpowerondelay":
86+
case "engine(ortspowersupply":
87+
case "engine(ortstractioncutoffrelay":
88+
case "engine(ortstractioncutoffrelayclosingdelay":
89+
case "engine(ortsbattery(mode":
90+
case "engine(ortsbattery(delay":
91+
case "engine(ortsmasterkey(mode":
92+
case "engine(ortsmasterkey(delayoff":
93+
case "engine(ortsmasterkey(headlightcontrol":
94+
case "engine(ortselectrictrainsupply(mode":
95+
case "engine(ortselectrictrainsupply(dieselengineminrpm":
96+
LocomotivePowerSupply.Parse(lowercasetoken, stf);
97+
break;
98+
99+
default:
100+
base.Parse(lowercasetoken, stf); break;
101+
}
102+
103+
}
104+
77105
/// <summary>
78106
/// Set starting conditions when initial speed > 0
79107
///
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// COPYRIGHT 2020 by the Open Rails project.
2+
//
3+
// This file is part of Open Rails.
4+
//
5+
// Open Rails is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Open Rails is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
17+
18+
using Orts.Common;
19+
using Orts.Parsers.Msts;
20+
using ORTS.Scripting.Api;
21+
using System.IO;
22+
23+
namespace Orts.Simulation.RollingStocks.SubSystems.PowerSupplies
24+
{
25+
26+
public class ScriptedControlCarPowerSupply : ScriptedLocomotivePowerSupply, ISubSystem<ScriptedControlCarPowerSupply>
27+
{
28+
public MSTSControlTrailerCar ContolTrailer => Locomotive as MSTSControlTrailerCar;
29+
30+
public override PowerSupplyType Type => PowerSupplyType.ControlCar;
31+
32+
public bool Activated = false;
33+
private ControlCarPowerSupply Script => AbstractScript as ControlCarPowerSupply;
34+
35+
// public ScriptedTractionCutOffRelay TractionCutOffRelay { get; protected set; }
36+
37+
public ScriptedControlCarPowerSupply(MSTSControlTrailerCar controlcar) :
38+
base(controlcar)
39+
{
40+
// ControlTrailer = controlcar;
41+
// TractionCutOffRelay = new ScriptedTractionCutOffRelay(this);
42+
}
43+
44+
45+
public void Copy(ScriptedControlCarPowerSupply other)
46+
{
47+
base.Copy(other);
48+
49+
50+
}
51+
52+
public override void Initialize()
53+
{
54+
base.Initialize();
55+
56+
57+
}
58+
59+
//================================================================================================//
60+
/// <summary>
61+
/// Initialization when simulation starts with moving train
62+
/// <\summary>
63+
public override void InitializeMoving()
64+
{
65+
base.InitializeMoving();
66+
67+
68+
}
69+
70+
public override void Update(float elapsedClockSeconds)
71+
{
72+
base.Update(elapsedClockSeconds);
73+
74+
// Script?.Update(elapsedClockSeconds);
75+
}
76+
77+
}
78+
}

0 commit comments

Comments
 (0)