Skip to content

Commit 98da648

Browse files
authored
Merge pull request #449 from peternewell/control-trailer
Provides functionality for unpowered control car https://blueprints.launchpad.net/or/+spec/unpowered-control-car
2 parents c7c7e93 + a18cc49 commit 98da648

File tree

13 files changed

+609
-90
lines changed

13 files changed

+609
-90
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Engine -- Classes of Motive Power
336336
=================================
337337

338338
Open Rails software provides for different classes of engines: diesel,
339-
electric, steam and default. If needed, additional classes can be created
339+
electric, steam, control and default. If needed, additional classes can be created
340340
with unique performance characteristics.
341341

342342
Diesel Locomotives
@@ -1990,6 +1990,23 @@ When the auxiliary tender is coupled to the locomotive the *tender* line in the
19901990

19911991
To allow the auxiliary tender to be filled at a water fuelling point, a water freight animation will be need to be added to the WAG file as well. (Refer to *Freight Animations* for more details).
19921992

1993+
Unpowered Control Car
1994+
---------------------
1995+
1996+
This module simulates the control cab of a DMU set of cars. The cab typically would be located in an unpowered
1997+
trailer car which is attached to a powered car for the provision of its motive force to drive the train forward.
1998+
1999+
Apart from producing motive force the car (and cabin controls) should behave exactly the same as a locomotive.
2000+
2001+
To set a control car up it is necessary to produce an ENG file which has the ``Type ( Control )`` parameter set in
2002+
the engine section of the ENG file.
2003+
2004+
The Control car uses most of the same parameters for its configuration as a powered locomotive. The major items that
2005+
can be left out are those parameters associated with power, motive force, diesel engines, some braking items, such
2006+
as the compressor and main air reservoir, and some of the diesel effects (as it has no diesel engine).
2007+
2008+
Some of the cab monitoring gauges provide visibility of what is happening on the powered car. To do this OR searches for
2009+
the "closest" powered car near the Control car and uses its infromation.
19932010

19942011

19952012
Engines -- Multiple Units in Same Consist or AI Engines

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public enum CABViewControlTypes
137137
STEAMHEAT_PRESSURE,
138138
FIREBOX,
139139
RPM,
140+
RPM_2,
140141
FIREHOLE,
141142
CUTOFF,
142143
VACUUM_RESERVOIR_PRESSURE,
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: 3 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" />
@@ -98,6 +99,7 @@
9899
<Compile Include="Simulation\LevelCrossing.cs" />
99100
<Compile Include="Simulation\Physics\Train.cs" />
100101
<Compile Include="Simulation\RollingStocks\LocomotiveAttributes.cs" />
102+
<Compile Include="Simulation\RollingStocks\MSTSControlTrailerCar.cs" />
101103
<Compile Include="Simulation\RollingStocks\MSTSDieselLocomotive.cs" />
102104
<Compile Include="Simulation\RollingStocks\MSTSElectricLocomotive.cs" />
103105
<Compile Include="Simulation\RollingStocks\MSTSLocomotive.cs" />
@@ -119,6 +121,7 @@
119121
<Compile Include="Simulation\RollingStocks\SubSystems\Controllers\MSTSBrakeController.cs" />
120122
<Compile Include="Simulation\RollingStocks\SubSystems\Controllers\MSTSNotchController.cs" />
121123
<Compile Include="Simulation\RollingStocks\SubSystems\FreightAnimations.cs" />
124+
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\ControlCarPowerSupply.cs" />
122125
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\ElectricTrainSupplySwitch.cs" />
123126
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\BatterySwitch.cs" />
124127
<Compile Include="Simulation\RollingStocks\SubSystems\PowerSupplies\DualModePowerSupply.cs" />
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// COPYRIGHT 2009, 2010, 2011, 2012, 2013 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+
/* DIESEL LOCOMOTIVE CLASSES
19+
*
20+
* The Locomotive is represented by two classes:
21+
* MSTSDieselLocomotiveSimulator - defines the behaviour, ie physics, motion, power generated etc
22+
* MSTSDieselLocomotiveViewer - defines the appearance in a 3D viewer. The viewer doesn't
23+
* get attached to the car until it comes into viewing range.
24+
*
25+
* Both these classes derive from corresponding classes for a basic locomotive
26+
* LocomotiveSimulator - provides for movement, basic controls etc
27+
* LocomotiveViewer - provides basic animation for running gear, wipers, etc
28+
*
29+
*/
30+
31+
using Microsoft.Xna.Framework;
32+
using Orts.Formats.Msts;
33+
using Orts.Parsers.Msts;
34+
using Orts.Simulation.Physics;
35+
using Orts.Simulation.RollingStocks.SubSystems.Controllers;
36+
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
37+
using Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions;
38+
using ORTS.Common;
39+
using System.Diagnostics;
40+
using System;
41+
using System.IO;
42+
using System.Text;
43+
using Event = Orts.Common.Event;
44+
using ORTS.Scripting.Api;
45+
46+
namespace Orts.Simulation.RollingStocks
47+
{
48+
public class MSTSControlTrailerCar : MSTSLocomotive
49+
{
50+
51+
public MSTSControlTrailerCar(Simulator simulator, string wagFile)
52+
: base(simulator, wagFile)
53+
{
54+
55+
PowerSupply = new ScriptedControlCarPowerSupply(this);
56+
57+
}
58+
59+
public override void LoadFromWagFile(string wagFilePath)
60+
{
61+
base.LoadFromWagFile(wagFilePath);
62+
63+
Trace.TraceInformation("Control Trailer");
64+
65+
}
66+
67+
68+
public override void Initialize()
69+
{
70+
71+
base.Initialize();
72+
73+
74+
}
75+
76+
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+
105+
/// <summary>
106+
/// Set starting conditions when initial speed > 0
107+
///
108+
109+
public override void InitializeMoving()
110+
{
111+
base.InitializeMoving();
112+
WheelSpeedMpS = SpeedMpS;
113+
114+
ThrottleController.SetValue(Train.MUThrottlePercent / 100);
115+
}
116+
117+
/// <summary>
118+
/// This function updates periodically the states and physical variables of the locomotive's subsystems.
119+
/// </summary>
120+
public override void Update(float elapsedClockSeconds)
121+
{
122+
base.Update(elapsedClockSeconds);
123+
124+
}
125+
126+
/// <summary>
127+
/// This function updates periodically the locomotive's motive force.
128+
/// </summary>
129+
protected override void UpdateTractiveForce(float elapsedClockSeconds, float t, float AbsSpeedMpS, float AbsWheelSpeedMpS)
130+
{
131+
132+
133+
134+
135+
}
136+
137+
138+
/// <summary>
139+
/// This function updates periodically the locomotive's sound variables.
140+
/// </summary>
141+
protected override void UpdateSoundVariables(float elapsedClockSeconds)
142+
{
143+
144+
145+
146+
}
147+
148+
149+
150+
151+
152+
153+
154+
}
155+
}

0 commit comments

Comments
 (0)