Skip to content

Commit ff5f18d

Browse files
CsantuccicesarBLG
authored andcommitted
Generalized controls to set CC speed
1 parent d053947 commit ff5f18d

File tree

4 files changed

+38
-470
lines changed

4 files changed

+38
-470
lines changed

Source/Documentation/Manual/cruisecontrol.rst

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,17 @@ MPC is connected. Controllers linked may be either "Throttle" or
296296
The boolean parameter *CanControlTrainBrake*, which is false by
297297
default, is optional.
298298

299+
.. _cruisecontrol-cabviewcontrolstable:
300+
299301
Cruise Control Cabview Controls
300302
===============================
301303

302304
The list of the available cabview controls may be found in the
303305
table here below.
304306

305-
.. _cruisecontrol-cabviewcontrolstable:
306-
307307
.. csv-table:: Cabview Controls
308308
:header: "Control Name", "Description", "UoM", "Mouse activated"
309-
:widths: 60, 40, 10, 10
309+
:widths: 58, 38, 9, 9
310310

311311
"ORTS_SELECTED_SPEED", "Used to display the selected speed, e.g. as a digital value", "km/h or MpH",
312312
"ORTS_SELECTED_SPEED_DISPLAY", "As above, but displays the speed in km/h divided by 10", "km/h",
@@ -318,49 +318,32 @@ table here below.
318318
"ORTS_NUMBER_OF_AXES_DISPLAY_TENS", "See above", "",
319319
"ORTS_NUMBER_OF_AXES_DISPLAY_HUNDREDS", "See above", "",
320320
"ORTS_TRAIN_LENGTH_METERS", "Displays the train length", "meters",
321-
"ORTS_REMAINING_TRAIN_LENGHT_SPEED_RESTRICTED", "When the restricted speed zone flag is activated, displays the remaining train lenght that hasn't yet arrived at the end of the restricted speed zone. Else shows 0", "meters",
321+
"ORTS_REMAINING_TRAIN_LENGHT_SPEED _RESTRICTED", "When the restricted speed zone flag is activated, displays the remaining train lenght that hasn't yet arrived at the end of the restricted speed zone. Else shows 0", "meters",
322322
"ORTS_REMAINING_TRAIN_LENGTH_PERCENT", "When the restricted speed zone flag is activated, displays the remaining train lenght percent that hasn't yet arrived at the end of the restricted speed zone. Else shows 0", "",
323+
"ORTS_ACCELERATION_IN_TIME", "Value of AccelerationBits; some cabs can show 'Arrows' pointing up or down according to speed change", "",
324+
325+
326+
.. csv-table:: Cabview Controls (continued)
327+
:header: "Control Name", "Description", "UoM", "Mouse activated"
328+
:widths: 58, 38, 9, 9
329+
330+
331+
"ORTS_ODOMETER", "Displays the odometer value since last odometer reset", "meters or Km",
332+
"ORTS_FORCE_IN_PERCENT_THROTTLE_AN D_DYNAMIC_BRAKE", "Displays the actual throttle percent or the negated dynamic brake percent when in manual mode; displays the actual CC force percent or the negated dynamic brake percent when in auto mode", "",
333+
"ORTS_MAXIMUM_FORCE", "Displays the preset maximum force of the locomotive", "Newton",
323334
"ORTS_MOTIVE_FORCE", "Displays the actual motive force of the locomotive", "Newton",
324335
"ORTS_MOTIVE_FORCE_KILONEWTON", "Displays the actual tractive or electric braking force of the locomotive", "KN",
325-
"ORTS_MAXIMUM_FORCE", "Displays the preset maximum force of the locomotive", "Newton",
326-
"ORTS_FORCE_IN_PERCENT_THROTTLE_AND_DYNAMIC_BRAKE", "Displays the actual throttle percent or the negated dynamic brake percent when in manual mode; displays the actual CC force percent or the negated dynamic brake percent when in auto mode", "",
327336
"ORTS_TRAIN_TYPE_PAX_OR_CARGO", "Displays whether the selected tran type is passenger or freight. Can be toggled with a keyboard command", "",
328337
"ORTS_CONTROLLER_VOLTAGE", "Displays the controller volts as set by the CC (may vary from 0 to 100).. Controller volts control the motive force of the locomotive", "",
329338
"ORTS_AMPERS_BY_CONTROLLER_VOLTAGE", "Displays the current used for the motive force of the locomotive", "Amperes",
330-
"ORTS_ACCELERATION_IN_TIME", "Value of AccelerationBits; some cabs can show 'Arrows' pointing up or down according to speed change", "",
331-
"ORTS_ODOMETER", "Displays the odometer value since last odometer reset", "meters or Km",
332-
"ORTS_CC_SELECT_SPEED", "Sets speed to value of second ScaleRange parameter (KpH or MpH depending from eng parameter SpeedIsMpH)", "", "Y"
339+
"ORTS_CC_SELECTED_SPEED", "Sets speed to value of ORTSParameter1 (KpH or MpH depending from eng parameter SpeedIsMpH)", "", "Y"
333340
"ORTS_NUMBER_OF_AXES_INCREASE", "Increases the number of axles of the train, when mouse pressed", "", "Y"
334341
"ORTS_NUMBER_OF_AXES_DECREASE", "Decreases the number of axles of the train, when mouse pressed", "", "Y"
335342
"ORTS_MULTI_POSITION_CONTROLLER", "Displays and sets the position of the MPC", "", "Y"
336343
"ORTS_CC_SPEED_0", "Displays and sets the selected speed at 0", "", "Y"
337-
"ORTS_CC_SPEED_10", "Same as above, but with selected speed at 10 (KpH or MpH depending from eng parameter SpeedIsMpH)", "", "Y"
338-
"ORTS_CC_SPEED_20", "As above, but speed as shown in control name", "", "Y"
339-
"ORTS_CC_SPEED_30", "As above, but speed as shown in control name", "", "Y"
340-
"ORTS_CC_SPEED_40", "As above, but speed as shown in control name", "", "Y"
341-
"ORTS_CC_SPEED_50", "As above, but speed as shown in control name", "", "Y"
342-
"ORTS_CC_SPEED_60", "As above, but speed as shown in control name", "", "Y"
343-
"ORTS_CC_SPEED_70", "As above, but speed as shown in control name", "", "Y"
344-
"ORTS_CC_SPEED_80", "As above, but speed as shown in control name", "", "Y"
345-
"ORTS_CC_SPEED_90", "As above, but speed as shown in control name", "", "Y"
346-
"ORTS_CC_SPEED_100", "As above, but speed as shown in control name", "", "Y"
347-
"ORTS_CC_SPEED_110", "As above, but speed as shown in control name", "", "Y"
348-
"ORTS_CC_SPEED_120", "As above, but speed as shown in control name", "", "Y"
349-
"ORTS_CC_SPEED_130", "As above, but speed as shown in control name", "", "Y"
350-
"ORTS_CC_SPEED_140", "As above, but speed as shown in control name", "", "Y"
351-
"ORTS_CC_SPEED_150", "As above, but speed as shown in control name", "", "Y"
352-
"ORTS_CC_SPEED_160", "As above, but speed as shown in control name", "", "Y"
353-
"ORTS_CC_SPEED_170", "As above, but speed as shown in control name", "", "Y"
354-
"ORTS_CC_SPEED_180", "As above, but speed as shown in control name", "", "Y"
355-
"ORTS_CC_SPEED_190", "As above, but speed as shown in control name", "", "Y"
356-
"ORTS_CC_SPEED_200", "As above, but speed as shown in control name", "", "Y"
357-
"ORTS_CC_SPEED_PLUS5", "As above, but speed incremented by 5", "", "Y"
358-
"ORTS_CC_SPEED_MINUS5", "As above, but speed decremented by 5", "", "Y"
359-
"ORTS_CC_SPEED_PLUS1", "As above, but speed incremented by 1", "", "Y"
360-
"ORTS_CC_SPEED_MINUS1", "As above, but speed decremented by 1", "", "Y"
344+
"ORTS_CC_SPEED_DELTA", "Increases or decreases the selected speed by the value of ORTSParameter1 (KpH or MpH depending from eng parameter SpeedIsMpH)", "", "Y"
361345
"ORTS_SELECTED_SPEED_SELECTOR", "Speed selection done by independent lever ranging from 0 to max speed; UoM may be KpH or MpH.", "", "Y"
362346

363-
364347
Restricted Speed Zone
365348
---------------------
366349

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -287,35 +287,13 @@ public enum CABViewControlTypes
287287
ORTS_CONTROLLER_VOLTAGE,
288288
ORTS_AMPERS_BY_CONTROLLER_VOLTAGE,
289289
ORTS_ACCELERATION_IN_TIME,
290-
ORTS_CC_SELECT_SPEED,
290+
ORTS_CC_SELECTED_SPEED,
291291
ORTS_NUMBER_OF_AXES_INCREASE,
292292
ORTS_NUMBER_OF_AXES_DECREASE,
293293
ORTS_MULTI_POSITION_CONTROLLER,
294294
ORTS_CC_SPEED_0,
295-
ORTS_CC_SPEED_10,
296-
ORTS_CC_SPEED_20,
297-
ORTS_CC_SPEED_30,
298-
ORTS_CC_SPEED_40,
299-
ORTS_CC_SPEED_50,
300-
ORTS_CC_SPEED_60,
301-
ORTS_CC_SPEED_70,
302-
ORTS_CC_SPEED_80,
303-
ORTS_CC_SPEED_90,
304-
ORTS_CC_SPEED_100,
305-
ORTS_CC_SPEED_110,
306-
ORTS_CC_SPEED_120,
307-
ORTS_CC_SPEED_130,
308-
ORTS_CC_SPEED_140,
309-
ORTS_CC_SPEED_150,
310-
ORTS_CC_SPEED_160,
311-
ORTS_CC_SPEED_170,
312-
ORTS_CC_SPEED_180,
313-
ORTS_CC_SPEED_190,
314-
ORTS_CC_SPEED_200,
315-
ORTS_CC_SPEED_PLUS5,
316-
ORTS_CC_SPEED_MINUS5,
317-
ORTS_CC_SPEED_PLUS1,
318-
ORTS_CC_SPEED_MINUS1,
295+
296+
ORTS_CC_SPEED_DELTA,
319297

320298
ORTS_ODOMETER,
321299
ORTS_ODOMETER_RESET,
@@ -467,6 +445,7 @@ public class CabViewControl
467445
public string ACEFile = "";
468446
public string Label = "";
469447
public int ControlId = 0;
448+
public float Parameter1; // Generic parameter, individually interpreted by the controls using it
470449

471450
public int Display;
472451
public List<string> Screens;
@@ -1152,6 +1131,7 @@ public CVCDiscrete(STFReader stf, string basepath, DiscreteStates discreteState)
11521131
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
11531132
new STFReader.TokenProcessor("ortsnewscreenpage", () => {ParseNewScreen(stf); }),
11541133
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
1134+
new STFReader.TokenProcessor("ortsparameter1", ()=>{ Parameter1 = stf.ReadFloatBlock(STFReader.UNITS.Any, 0); }),
11551135
});
11561136

11571137
// If no ACE, just don't need any fixup

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/CruiseControl.cs

Lines changed: 6 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,10 @@ public enum SpeedSelectorMode { Parking, Neutral, On, Start }
174174
public bool WasForceReset = true;
175175

176176

177-
public bool SelectingSpeedPressed = false;
177+
public bool SelectedSpeedPressed = false;
178178
public bool EngineBrakePriority = false;
179179
public int AccelerationBits = 0;
180-
public bool Speed0Pressed, Speed10Pressed, Speed20Pressed, Speed30Pressed, Speed40Pressed, Speed50Pressed
181-
, Speed60Pressed, Speed70Pressed, Speed80Pressed, Speed90Pressed, Speed100Pressed
182-
, Speed110Pressed, Speed120Pressed, Speed130Pressed, Speed140Pressed, Speed150Pressed
183-
, Speed160Pressed, Speed170Pressed, Speed180Pressed, Speed190Pressed, Speed200Pressed, SpeedPlus5Pressed, SpeedMinus5Pressed
184-
, SpeedPlus1Pressed, SpeedMinus1Pressed;
180+
public bool Speed0Pressed, SpeedDeltaPressed;
185181

186182
public CruiseControl(MSTSLocomotive locomotive)
187183
{
@@ -1484,132 +1480,17 @@ public float GetDataOf(CabViewControl cvc)
14841480
data = AccelerationBits;
14851481
break;
14861482
}
1487-
case CABViewControlTypes.ORTS_CC_SELECT_SPEED:
1488-
data = SelectingSpeedPressed ? 1 : 0;
1483+
case CABViewControlTypes.ORTS_CC_SELECTED_SPEED:
1484+
data = SelectedSpeedPressed ? 1 : 0;
14891485
break;
14901486
case CABViewControlTypes.ORTS_CC_SPEED_0:
14911487
{
14921488
data = Speed0Pressed ? 1 : 0;
14931489
break;
14941490
}
1495-
case CABViewControlTypes.ORTS_CC_SPEED_10:
1491+
case CABViewControlTypes.ORTS_CC_SPEED_DELTA:
14961492
{
1497-
data = Speed10Pressed ? 1 : 0;
1498-
break;
1499-
}
1500-
case CABViewControlTypes.ORTS_CC_SPEED_20:
1501-
{
1502-
data = Speed20Pressed ? 1 : 0;
1503-
break;
1504-
}
1505-
case CABViewControlTypes.ORTS_CC_SPEED_30:
1506-
{
1507-
data = Speed30Pressed ? 1 : 0;
1508-
break;
1509-
}
1510-
case CABViewControlTypes.ORTS_CC_SPEED_40:
1511-
{
1512-
data = Speed40Pressed ? 1 : 0;
1513-
break;
1514-
}
1515-
case CABViewControlTypes.ORTS_CC_SPEED_50:
1516-
{
1517-
data = Speed50Pressed ? 1 : 0;
1518-
break;
1519-
}
1520-
case CABViewControlTypes.ORTS_CC_SPEED_60:
1521-
{
1522-
data = Speed60Pressed ? 1 : 0;
1523-
break;
1524-
}
1525-
case CABViewControlTypes.ORTS_CC_SPEED_70:
1526-
{
1527-
data = Speed70Pressed ? 1 : 0;
1528-
break;
1529-
}
1530-
case CABViewControlTypes.ORTS_CC_SPEED_80:
1531-
{
1532-
data = Speed80Pressed ? 1 : 0;
1533-
break;
1534-
}
1535-
case CABViewControlTypes.ORTS_CC_SPEED_90:
1536-
{
1537-
data = Speed90Pressed ? 1 : 0;
1538-
break;
1539-
}
1540-
case CABViewControlTypes.ORTS_CC_SPEED_100:
1541-
{
1542-
data = Speed100Pressed ? 1 : 0;
1543-
break;
1544-
}
1545-
case CABViewControlTypes.ORTS_CC_SPEED_110:
1546-
{
1547-
data = Speed110Pressed ? 1 : 0;
1548-
break;
1549-
}
1550-
case CABViewControlTypes.ORTS_CC_SPEED_120:
1551-
{
1552-
data = Speed120Pressed ? 1 : 0;
1553-
break;
1554-
}
1555-
case CABViewControlTypes.ORTS_CC_SPEED_130:
1556-
{
1557-
data = Speed130Pressed ? 1 : 0;
1558-
break;
1559-
}
1560-
case CABViewControlTypes.ORTS_CC_SPEED_140:
1561-
{
1562-
data = Speed140Pressed ? 1 : 0;
1563-
break;
1564-
}
1565-
case CABViewControlTypes.ORTS_CC_SPEED_150:
1566-
{
1567-
data = Speed150Pressed ? 1 : 0;
1568-
break;
1569-
}
1570-
case CABViewControlTypes.ORTS_CC_SPEED_160:
1571-
{
1572-
data = Speed160Pressed ? 1 : 0;
1573-
break;
1574-
}
1575-
case CABViewControlTypes.ORTS_CC_SPEED_170:
1576-
{
1577-
data = Speed170Pressed ? 1 : 0;
1578-
break;
1579-
}
1580-
case CABViewControlTypes.ORTS_CC_SPEED_180:
1581-
{
1582-
data = Speed180Pressed ? 1 : 0;
1583-
break;
1584-
}
1585-
case CABViewControlTypes.ORTS_CC_SPEED_190:
1586-
{
1587-
data = Speed190Pressed ? 1 : 0;
1588-
break;
1589-
}
1590-
case CABViewControlTypes.ORTS_CC_SPEED_200:
1591-
{
1592-
data = Speed200Pressed ? 1 : 0;
1593-
break;
1594-
}
1595-
case CABViewControlTypes.ORTS_CC_SPEED_PLUS5:
1596-
{
1597-
data = SpeedPlus5Pressed ? 1 : 0;
1598-
break;
1599-
}
1600-
case CABViewControlTypes.ORTS_CC_SPEED_MINUS5:
1601-
{
1602-
data = SpeedMinus5Pressed ? 1 : 0;
1603-
break;
1604-
}
1605-
case CABViewControlTypes.ORTS_CC_SPEED_PLUS1:
1606-
{
1607-
data = SpeedPlus1Pressed ? 1 : 0;
1608-
break;
1609-
}
1610-
case CABViewControlTypes.ORTS_CC_SPEED_MINUS1:
1611-
{
1612-
data = SpeedMinus1Pressed ? 1 : 0;
1493+
data = SpeedDeltaPressed ? 1 : 0;
16131494
break;
16141495
}
16151496
default:

0 commit comments

Comments
 (0)