Skip to content

Commit f88b8b9

Browse files
authored
Merge pull request #961 from cesarBLG/powersupply-scripts
Improvements for Power Supplies
2 parents f342440 + ffccb2e commit f88b8b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3720
-716
lines changed

Source/Documentation/Manual/cabs.rst

+45-5
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,25 @@ The following DMI size variants are available: FullSize (displays the whole DMI)
6161
The information displayed in the DMI is controlled via the TCS script. For more details,
6262
see :ref:`C# engine scripting - Train Control System <features-scripting-tcs>`.
6363

64-
.. _cabs-battery-switch:
64+
.. _cabs-battery:
6565

66-
Battery switch
67-
--------------
66+
Battery
67+
-------
6868

6969
.. index::
7070
single: ORTS_BATTERY_SWITCH_COMMAND_SWITCH
7171
single: ORTS_BATTERY_SWITCH_COMMAND_BUTTON_CLOSE
7272
single: ORTS_BATTERY_SWITCH_ON
73+
single: ORTS_BATTERY_VOLTAGE
7374

74-
The :ref:`battery switch <physics-battery-switch>` controls the low voltage power supply of the locomotive.
75+
The :ref:`battery subsystem <physics-battery>` controls the low voltage power supply of the locomotive.
7576

7677
The following controls are available for the cabview:
7778

78-
- ``ORTS_BATTERY_SWITCH_COMMAND_SWITCH`` can be used if the switch is directly controlled from the cab
79+
- ``ORTS_BATTERY_SWITCH_COMMAND_SWITCH`` can be used if the battery switch is directly controlled from the cab
7980
- ``ORTS_BATTERY_SWITCH_COMMAND_BUTTON_CLOSE`` and ``ORTS_BATTERY_SWITCH_COMMAND_BUTTON_OPEN`` can be used if the switch is controlled with two pushbuttons (one to close the switch and the other to open it)
8081
- ``ORTS_BATTERY_SWITCH_ON`` can be used to control a light on the cab showing the state of the battery switch
82+
- ``ORTS_BATTERY_VOLTAGE`` monitors the battery voltage
8183

8284
Other controls can be disabled if the low voltage power supply is not available using the following parameter::
8385

@@ -166,6 +168,44 @@ The following controls are available for the cabview:
166168
- ``ORTS_ELECTRIC_TRAIN_SUPPLY_COMMAND_SWITCH`` can be used to control the electric train supply switch
167169
- ``ORTS_ELECTRIC_TRAIN_SUPPLY_ON`` can be used to indicate that the electric train supply line is powered on
168170

171+
.. _cabs-voltmeters:
172+
173+
Voltmeters
174+
----------
175+
176+
.. index::
177+
single: LINE_VOLTAGE
178+
single: ORTS_PANTOGRAPH_VOLTAGE_AC
179+
single: ORTS_PANTOGRAPH_VOLTAGE_DC
180+
single: ORTS_BATTERY_VOLTAGE
181+
182+
The following voltmeters are available for the cabview:
183+
184+
- ``LINE_VOLTAGE`` indicates the line voltage
185+
- ``ORTS_PANTOGRAPH_VOLTAGE_AC`` indicates the line voltage when operating on AC lines
186+
- ``ORTS_PANTOGRAPH_VOLTAGE_DC`` indicates the line voltage when operating on DC lines
187+
- ``ORTS_BATTERY_VOLTAGE`` indicates the vehicle's battery voltage
188+
189+
.. _cabs-electricselectors:
190+
191+
.. index::
192+
single: ORTS_PANTOGRAPH_SELECTOR
193+
single: ORTS_POWER_LIMITATION_SELECTOR
194+
single: ORTS_VOLTAGE_SELECTOR
195+
196+
There :ref:`pantograph selector <physics-pantograph-selector>`,
197+
:ref:`voltage selector <physics-voltage-selector>` and
198+
:ref:`power limitation selector <physics-power-limitation-selector>` can be used
199+
to switch the traction system for locomotives operating at different voltages.
200+
201+
They can be included in the cabview as follows:
202+
203+
- ``ORTS_PANTOGRAPH_SELECTOR`` allows selecting pre-defined pantograph arrangements
204+
(requires a custom script).
205+
- ``ORTS_VOLTAGE_SELECTOR`` configures the power supply for the voltage of the line
206+
(requires a custom script to raise the right pantograph).
207+
- ``ORTS_POWER_LIMITATION_SELECTOR`` limits the maximum power that the locomotive can draw.
208+
169209
.. _cabs-dieselenginesonoff:
170210

171211
Controls to switch on and off diesel engines

Source/Documentation/Manual/features-rollingstock.rst

+93-5
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ block!
149149
.. index::
150150
single: Conditions(ORTSBattery
151151

152-
Battery Switch
153-
''''''''''''''
152+
Battery
153+
'''''''
154154

155155
The light condition ``ORTSBattery`` allows a light to respond to the state of
156-
the :ref:`battery switch subsystem <physics-battery-switch>`. The valid settings
156+
the :ref:`battery subsystem <physics-battery>`. The valid settings
157157
and associated conditions for the light to turn *on* are as follows:
158158

159159
- ``ORTSBattery ( 0 )`` Battery state is ignored (default)
@@ -1921,6 +1921,9 @@ Scripts will run if referenced by OR-specific fields in the .eng file.
19211921
single: ORTSEngineBrakeController
19221922
single: ORTSCircuitBreaker
19231923
single: ORTSTractionCutOffRelay
1924+
single: ORTSPantographSelector
1925+
single: ORTSVoltageSelector
1926+
single: ORTSPowerLimitationSelector
19241927
single: ORTSPowerSupply
19251928
single: ORTSTrainControlSystem
19261929

@@ -1952,6 +1955,15 @@ Scripts will run if referenced by OR-specific fields in the .eng file.
19521955
* - Passenger car power supply
19531956
- ``ORTS.Scripting.Api.PassengerCarPowerSupply``
19541957
- ``Wagon ( ORTSPowerSupply ( "DemoPower.cs" ) )``
1958+
* - Pantograph selector
1959+
- ``ORTS.Scripting.Api.PantographSelector``
1960+
- ``Engine ( ORTSPantographSelector ( Script ( "DemoPantographSelector.cs" ) ) )``
1961+
* - Voltage selector
1962+
- ``ORTS.Scripting.Api.VoltageSelector``
1963+
- ``Engine ( ORTSVoltageSelector ( Script ( "DemoVoltageSelector.cs" ) ) )``
1964+
* - Power limitation selector
1965+
- ``ORTS.Scripting.Api.PowerLimitationSelector``
1966+
- ``Engine ( ORTSPantographSelector ( Script ( "DemoPowerLimitator.cs" ) ) )``
19551967
* - Train Control System
19561968
- ``ORTS.Scripting.Api.TrainControlSystem``
19571969
- ``Engine ( ORTSTrainControlSystem ( "DemoTCS.cs" ) )``
@@ -2134,14 +2146,66 @@ Use the following .eng parameter to load a traction cut-off relay script::
21342146
)
21352147

21362148
``ORTSTractionCutOffRelay`` refers to the traction cut-off relay script in the engine's ``Script``
2137-
subfolder. For this field, the .cs extension is optional. "Automatic" and "Manual" load the generic OR
2138-
traction cut-off relay implementation, so do `not` use these names for your own script.
2149+
subfolder. For this field, the .cs extension is optional. Alternatively, there are several
2150+
built-in OR traction cut-off relay implementations:
2151+
2152+
- "Automatic": no driver intervention required, circuit breaker is closed when conditions are met.
2153+
- "Manual": a traction cut-off switch with open and closed positions.
2154+
- "PushButtons": a traction cut-off relay with dedicated open and close buttons.
2155+
2156+
Please do `not` use these names for your own script, since the generic implementation will
2157+
be loaded instead.
21392158

21402159
``ORTSTractionCutOffRelayClosingDelay`` refers to the delay between the closing command of the traction cut-off relay
21412160
and the effective closing of the relay.
21422161

2162+
.. _features-scripting-powerselectors
2163+
2164+
Pantograph, voltage and power limitation selectors
2165+
--------------------------------------------------
2166+
2167+
Available for electric locomotives only. The scripts control
2168+
the behavior of the locomotive's
2169+
:ref:`pantograph selector <physics-pantograph-selector>`,
2170+
:ref:`voltage selector <physics-voltage-selector>` and
2171+
:ref:`power limitation selector <physics-power-limitation-selector>` respectively.
2172+
2173+
.. index::
2174+
single: ORTSPantographSelector
2175+
single: ORTSVoltageSelector
2176+
single: ORTSPowerLimitationSelector
2177+
2178+
Use the following .eng parameters to load power selector scripts::
2179+
2180+
Engine (
2181+
ORTSPantographSelector (
2182+
Script ( "YourPSScript.cs" )
2183+
SelectorPositions ( ... )
2184+
)
2185+
ORTSVoltageSelector (
2186+
Script ( "YourVSScript.cs" )
2187+
SelectorPositions ( ... )
2188+
)
2189+
ORTSPowerLimitationSelector (
2190+
Script ( "YourPLSScript.cs" )
2191+
SelectorPositions ( ... )
2192+
)
2193+
)
2194+
2195+
``Script`` refers to the circuit breaker script in the engine's ``Script``
2196+
subfolder. For this field, the .cs extension is optional. Alternatively, there are several
2197+
built-in OR selector implementations which can be used if custom features such as interlocking
2198+
with other devices are not required:
2199+
2200+
- "Default": a selector with sequential positions.
2201+
- "Circular": same as above, but the first position follows again after the last one.
2202+
2203+
Please do `not` use these names for your own script, since the generic implementation will
2204+
be loaded instead.
2205+
21432206
.. _features-scripting-powersupply:
21442207

2208+
21452209
Diesel and electric power supply
21462210
--------------------------------
21472211

@@ -2161,6 +2225,7 @@ Use the following .eng parameter to load a power supply script::
21612225

21622226
Engine (
21632227
ORTSPowerSupply ( "YourEPS.cs" )
2228+
ORTSPowerSupplyParameters ( "YourEPS.ini" )
21642229
ORTSPowerOnDelay ( 5s )
21652230
ORTSAuxPowerOnDelay ( 10s )
21662231
)
@@ -2169,6 +2234,12 @@ Use the following .eng parameter to load a power supply script::
21692234
subfolder. For this field, the .cs extension is optional. "Default" will load the generic OR power supply
21702235
implementation, so do `not` use this name for your own script.
21712236

2237+
``ORTSPowerSupplyParameters``, an optional field, refers to an .ini file,
2238+
also in the ``Script`` subfolder, whose parameters will be made available to the
2239+
power supply script through the ``GetBoolParameter()``, ``GetIntParameter()``,
2240+
``GetFloatParameter()``, and ``GetStringParameter()`` methods. This .ini file provides for easy customization of
2241+
the behavior of the power supply script by end users.
2242+
21722243
``ORTSPowerOnDelay`` refers to the delay between the closing of the circuit breaker or the traction cut-off relay
21732244
and the availability of the power for traction.
21742245

@@ -2550,6 +2621,23 @@ which may be used this way within the script:
25502621
25512622
so that, instead of ORTS_TCSnn the related mnemonic string is displayed.
25522623

2624+
Generic cabview controls are also available for the Power Supply subsystem. They are named ORTS_POWER_SUPPLY1, ORTS_POWER_SUPPLY2
2625+
and so on in the cabview file. Their usage is the same as for the TCS controls.
2626+
2627+
Events related to power supply controls are made available to power supply scripts via ``TCSEvent.GenericTCSButtonPressed``,
2628+
``TCSEvent.GenericTCSButtonReleased``, ``TCSEvent.GenericTCSSwitchOff`` and ``TCSEvent.GenericTCSSwitchOn`` events,
2629+
received asynchronously by script through the method:
2630+
2631+
.. code-block:: csharp
2632+
2633+
public override void HandleEvent(PowerSupplyEvent evt, string message)
2634+
2635+
As for the TCS buttons, message is a string representing the control number with zero-base indexing
2636+
(e.g. "5" corresponds to ORTS_POWER_SUPPLY6).
2637+
2638+
SetCabDisplayControl and SetCustomizedCabviewControlName methods, which work in the same
2639+
way as their TCS counterparts, are accessible from all power supply scripts.
2640+
25532641
Helper classes
25542642
--------------
25552643
3 helper classes are available in the ``Orts.Scripting.Api`` namespace:

0 commit comments

Comments
 (0)