Skip to content

Commit 26bd936

Browse files
committed
Distributed power: cabview display and controls
1 parent e198ab3 commit 26bd936

File tree

6 files changed

+694
-0
lines changed

6 files changed

+694
-0
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,59 @@ Here is an example of use of the odometer control blocks within a .cvf file::
403403
Units ( FEET )
404404
)
405405

406+
.. _cabs-distributed-power:
407+
408+
Distributed Power
409+
-----------------
410+
411+
The principles of Distributed Power are described :ref:`here <distributed-power>` .
412+
413+
Distributed Power data can be displayed using control ORTS_DISTRIBUTED_POWER. Here
414+
an example of use::
415+
416+
ScreenDisplay (
417+
Type ( ORTS_DISTRIBUTED_POWER SCREEN_DISPLAY )
418+
Position ( 164.4 286.5 136 52 )
419+
Parameters (
420+
FullTable True
421+
)
422+
Units ( KM_PER_HOUR )
423+
ORTSDisplay ( 1 )
424+
ORTSScreenPage ( "2300-0" )
425+
)
426+
427+
Here below an example of the output of the above control.
428+
429+
.. image:: images/cabs-distributed-power.png
430+
431+
When parameter FullTable is set to False, only the first 6 lines
432+
are displayed.
433+
434+
For every keyboard command related to Distributed Power, also a cabview control
435+
is available. Here a list of the self-explaining controls::
436+
437+
- ORTS_DP_MOVE_TO_FRONT
438+
- ORTS_DP_MOVE_TO_BACK
439+
- ORTS_DP_IDLE
440+
- ORTS_DP_TRACTION
441+
- ORTS_DP_BRAKE
442+
- ORTS_DP_MORE
443+
- ORTS_DP_LESS
444+
445+
Here an example of use of one of the controls::
446+
447+
TwoState (
448+
Type ( ORTS_DP_MOVE_TO_FRONT TWO_STATE )
449+
Position ( 163.2 378.4 13.75 10 )
450+
Graphic ( "..\\..\\Common.Cab\\ES44v3\\softkey1trans.ace" )
451+
NumFrames ( 2 2 1 )
452+
Style ( WHILE_PRESSED )
453+
MouseControl ( 1 )
454+
ORTSDisplay ( 1 )
455+
ORTSScreenPage ( "2300-0" )
456+
)
457+
458+
406459
Animated 2D Wipers
407460
------------------
408461

Source/Documentation/Manual/physics.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,8 @@ unit) signals for braking and throttle position, etc. The
20402040
player-controlled locomotive generates the MU signals which are passed
20412041
along to every unit in the train.
20422042

2043+
.. _distributed-power:
2044+
20432045
Distributed Power
20442046
-----------------
20452047

@@ -2114,6 +2116,9 @@ The actual set value of traction or dynamic brake of *async* group is shown in
21142116
lines *Throttle* and *Dynamic Brake*, respectively, in brackets, e.g.:
21152117
Throttle: 0% (50%).
21162118

2119+
Distributed power info and commands can also be displayed and operated through
2120+
cabview controls, as explained :ref:`here <cabs-distributed-power>`
2121+
21172122
The complete distributed power configuration is displayed in the
21182123
Distributed Power Info extended HUD page, where the state of all locomotives
21192124
in the train are shown, as well as in the *Train DPU Info* window, which is

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,18 @@ public enum CABViewControlTypes
257257
ORTS_TCS47,
258258
ORTS_TCS48,
259259
ORTS_ETCS,
260+
260261
ORTS_ODOMETER,
261262
ORTS_ODOMETER_RESET,
262263
ORTS_ODOMETER_DIRECTION,
264+
ORTS_DISTRIBUTED_POWER,
265+
ORTS_DP_MOVE_TO_FRONT,
266+
ORTS_DP_MOVE_TO_BACK,
267+
ORTS_DP_IDLE,
268+
ORTS_DP_TRACTION,
269+
ORTS_DP_BRAKE,
270+
ORTS_DP_MORE,
271+
ORTS_DP_LESS,
263272

264273
// Further CabViewControlTypes must be added above this line, to avoid their malfunction in 3DCabs
265274
EXTERNALWIPERS,

Source/RunActivity/RunActivity.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<Compile Include="Viewer3D\RollingStock\MSTSLocomotiveViewer.cs" />
172172
<Compile Include="Viewer3D\RollingStock\MSTSSteamLocomotiveViewer.cs" />
173173
<Compile Include="Viewer3D\RollingStock\MSTSWagonViewer.cs" />
174+
<Compile Include="Viewer3D\RollingStock\SubSystems\DistributedPowerInterface.cs" />
174175
<Compile Include="Viewer3D\RollingStock\SubSystems\ETCS\DataEntry.cs" />
175176
<Compile Include="Viewer3D\RollingStock\SubSystems\ETCS\Menus.cs" />
176177
<Compile Include="Viewer3D\RollingStock\SubSystems\ETCS\TextMessages.cs" />

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using Orts.Simulation.RollingStocks.SubSystems.Controllers;
3333
using Orts.Viewer3D.Common;
3434
using Orts.Viewer3D.Popups;
35+
using Orts.Viewer3D.RollingStock.Subsystems;
3536
using Orts.Viewer3D.RollingStock.Subsystems.ETCS;
3637
using ORTS.Common;
3738
using ORTS.Common.Input;
@@ -1211,6 +1212,15 @@ public CabRenderer(Viewer viewer, MSTSLocomotive car)
12111212
count[(int)cvc.ControlType]++;
12121213
continue;
12131214
}
1215+
else if (screen.ControlType == CABViewControlTypes.ORTS_DISTRIBUTED_POWER)
1216+
{
1217+
var cvr = new DistributedPowerInterfaceRenderer(viewer, car, screen, _Shader);
1218+
cvr.SortIndex = controlSortIndex;
1219+
CabViewControlRenderersList[i].Add(cvr);
1220+
if (!ControlMap.ContainsKey(key)) ControlMap.Add(key, cvr);
1221+
count[(int)cvc.ControlType]++;
1222+
continue;
1223+
}
12141224
}
12151225
}
12161226
}
@@ -1323,6 +1333,15 @@ public CabRenderer(Viewer viewer, MSTSLocomotive car, CabViewFile CVFFile) //use
13231333
count[(int)cvc.ControlType]++;
13241334
continue;
13251335
}
1336+
else if (screen.ControlType == CABViewControlTypes.ORTS_DISTRIBUTED_POWER)
1337+
{
1338+
var cvr = new DistributedPowerInterfaceRenderer(viewer, car, screen, _Shader);
1339+
cvr.SortIndex = controlSortIndex;
1340+
CabViewControlRenderersList[i].Add(cvr);
1341+
if (!ControlMap.ContainsKey(key)) ControlMap.Add(key, cvr);
1342+
count[(int)cvc.ControlType]++;
1343+
continue;
1344+
}
13261345
}
13271346
}
13281347
#endregion
@@ -2100,6 +2119,13 @@ public int GetDrawIndex()
21002119
index = (int)data;
21012120
break;
21022121
case CABViewControlTypes.ORTS_SCREEN_SELECT:
2122+
case CABViewControlTypes.ORTS_DP_MOVE_TO_BACK:
2123+
case CABViewControlTypes.ORTS_DP_MOVE_TO_FRONT:
2124+
case CABViewControlTypes.ORTS_DP_TRACTION:
2125+
case CABViewControlTypes.ORTS_DP_IDLE:
2126+
case CABViewControlTypes.ORTS_DP_BRAKE:
2127+
case CABViewControlTypes.ORTS_DP_MORE:
2128+
case CABViewControlTypes.ORTS_DP_LESS:
21032129
index = ButtonState ? 1 : 0;
21042130
break;
21052131
case CABViewControlTypes.ORTS_STATIC_DISPLAY:
@@ -2420,6 +2446,49 @@ public void HandleUserInput()
24202446
new TCSButtonCommand(Viewer.Log, !Locomotive.TrainControlSystem.TCSCommandButtonDown[commandIndex], commandIndex);
24212447
new TCSSwitchCommand(Viewer.Log, ChangedValue(Locomotive.TrainControlSystem.TCSCommandSwitchOn[commandIndex] ? 1 : 0) > 0, commandIndex);
24222448
break;
2449+
2450+
case CABViewControlTypes.ORTS_DP_MOVE_TO_FRONT:
2451+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2452+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2453+
new DPMoveToFrontCommand(Viewer.Log);
2454+
ButtonState = buttonState;
2455+
break;
2456+
case CABViewControlTypes.ORTS_DP_MOVE_TO_BACK:
2457+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2458+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2459+
new DPMoveToBackCommand(Viewer.Log);
2460+
ButtonState = buttonState;
2461+
break;
2462+
case CABViewControlTypes.ORTS_DP_IDLE:
2463+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2464+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2465+
new DPIdleCommand(Viewer.Log);
2466+
ButtonState = buttonState;
2467+
break;
2468+
case CABViewControlTypes.ORTS_DP_TRACTION:
2469+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2470+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2471+
new DPTractionCommand(Viewer.Log);
2472+
ButtonState = buttonState;
2473+
break;
2474+
case CABViewControlTypes.ORTS_DP_BRAKE:
2475+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2476+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2477+
new DPDynamicBrakeCommand(Viewer.Log);
2478+
ButtonState = buttonState;
2479+
break;
2480+
case CABViewControlTypes.ORTS_DP_MORE:
2481+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2482+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2483+
new DPMoreCommand(Viewer.Log);
2484+
ButtonState = buttonState;
2485+
break;
2486+
case CABViewControlTypes.ORTS_DP_LESS:
2487+
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;
2488+
if (!ButtonState && (ButtonState ? 1 : 0) != ChangedValue(ButtonState ? 1 : 0))
2489+
new DPLessCommand(Viewer.Log);
2490+
ButtonState = buttonState;
2491+
break;
24232492
}
24242493

24252494
}

0 commit comments

Comments
 (0)