Skip to content

Commit d053947

Browse files
CsantuccicesarBLG
authored andcommitted
Add two-state controls to increment and decrement selected speed by fixed value. By Paolo
1 parent d205337 commit d053947

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

Source/Documentation/Manual/cruisecontrol.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ table here below.
329329
"ORTS_AMPERS_BY_CONTROLLER_VOLTAGE", "Displays the current used for the motive force of the locomotive", "Amperes",
330330
"ORTS_ACCELERATION_IN_TIME", "Value of AccelerationBits; some cabs can show 'Arrows' pointing up or down according to speed change", "",
331331
"ORTS_ODOMETER", "Displays the odometer value since last odometer reset", "meters or Km",
332-
"ORTS_CC_SELECT_SPEED", "obsolete (maybe)", "",
332+
"ORTS_CC_SELECT_SPEED", "Sets speed to value of second ScaleRange parameter (KpH or MpH depending from eng parameter SpeedIsMpH)", "", "Y"
333333
"ORTS_NUMBER_OF_AXES_INCREASE", "Increases the number of axles of the train, when mouse pressed", "", "Y"
334334
"ORTS_NUMBER_OF_AXES_DECREASE", "Decreases the number of axles of the train, when mouse pressed", "", "Y"
335335
"ORTS_MULTI_POSITION_CONTROLLER", "Displays and sets the position of the MPC", "", "Y"
@@ -354,6 +354,10 @@ table here below.
354354
"ORTS_CC_SPEED_180", "As above, but speed as shown in control name", "", "Y"
355355
"ORTS_CC_SPEED_190", "As above, but speed as shown in control name", "", "Y"
356356
"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"
357361
"ORTS_SELECTED_SPEED_SELECTOR", "Speed selection done by independent lever ranging from 0 to max speed; UoM may be KpH or MpH.", "", "Y"
358362

359363

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ public enum CABViewControlTypes
312312
ORTS_CC_SPEED_180,
313313
ORTS_CC_SPEED_190,
314314
ORTS_CC_SPEED_200,
315-
315+
ORTS_CC_SPEED_PLUS5,
316+
ORTS_CC_SPEED_MINUS5,
317+
ORTS_CC_SPEED_PLUS1,
318+
ORTS_CC_SPEED_MINUS1,
319+
316320
ORTS_ODOMETER,
317321
ORTS_ODOMETER_RESET,
318322
ORTS_ODOMETER_DIRECTION,

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public float SetSpeedMpS
7171
return selected;
7272
}
7373
}
74+
public float SetSpeedKpHOrMpH
75+
{
76+
get
77+
{
78+
return SpeedIsMph ? MpS.ToMpH(SetSpeedMpS) : MpS.ToKpH(SetSpeedMpS);
79+
}
80+
}
7481
public int SelectedNumberOfAxles = 0;
7582
public float SpeedRegulatorNominalSpeedStepMpS = 0;
7683
public float SpeedRegulatorNominalSpeedStepKpHOrMpH = 0;
@@ -173,7 +180,8 @@ public enum SpeedSelectorMode { Parking, Neutral, On, Start }
173180
public bool Speed0Pressed, Speed10Pressed, Speed20Pressed, Speed30Pressed, Speed40Pressed, Speed50Pressed
174181
, Speed60Pressed, Speed70Pressed, Speed80Pressed, Speed90Pressed, Speed100Pressed
175182
, Speed110Pressed, Speed120Pressed, Speed130Pressed, Speed140Pressed, Speed150Pressed
176-
, Speed160Pressed, Speed170Pressed, Speed180Pressed, Speed190Pressed, Speed200Pressed;
183+
, Speed160Pressed, Speed170Pressed, Speed180Pressed, Speed190Pressed, Speed200Pressed, SpeedPlus5Pressed, SpeedMinus5Pressed
184+
, SpeedPlus1Pressed, SpeedMinus1Pressed;
177185

178186
public CruiseControl(MSTSLocomotive locomotive)
179187
{
@@ -1583,6 +1591,26 @@ public float GetDataOf(CabViewControl cvc)
15831591
{
15841592
data = Speed200Pressed ? 1 : 0;
15851593
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;
1613+
break;
15861614
}
15871615
default:
15881616
data = 0;

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,10 @@ public virtual int GetDrawIndex()
23142314
case CABViewControlTypes.ORTS_CC_SELECT_SPEED:
23152315
case CABViewControlTypes.ORTS_MULTI_POSITION_CONTROLLER:
23162316
case CABViewControlTypes.ORTS_ACCELERATION_IN_TIME:
2317+
case CABViewControlTypes.ORTS_CC_SPEED_PLUS5:
2318+
case CABViewControlTypes.ORTS_CC_SPEED_MINUS5:
2319+
case CABViewControlTypes.ORTS_CC_SPEED_PLUS1:
2320+
case CABViewControlTypes.ORTS_CC_SPEED_MINUS1:
23172321
case CABViewControlTypes.ORTS_CC_SPEED_0:
23182322
case CABViewControlTypes.ORTS_CC_SPEED_10:
23192323
case CABViewControlTypes.ORTS_CC_SPEED_20:
@@ -2988,6 +2992,50 @@ public void HandleUserInput()
29882992
}
29892993
else if (p == 0) Locomotive.CruiseControl.Speed200Pressed = false;
29902994
break;
2995+
}
2996+
case CABViewControlTypes.ORTS_CC_SPEED_PLUS5:
2997+
{
2998+
p = ChangedValue(0);
2999+
if (p == 1)
3000+
{
3001+
Locomotive.CruiseControl.SetSpeed(Locomotive.CruiseControl.SetSpeedKpHOrMpH + 5);
3002+
Locomotive.CruiseControl.SpeedPlus5Pressed = true;
3003+
}
3004+
else if (p == 0) Locomotive.CruiseControl.SpeedPlus5Pressed = false;
3005+
break;
3006+
}
3007+
case CABViewControlTypes.ORTS_CC_SPEED_MINUS5:
3008+
{
3009+
p = ChangedValue(0);
3010+
if (p == 1)
3011+
{
3012+
Locomotive.CruiseControl.SetSpeed(Locomotive.CruiseControl.SetSpeedKpHOrMpH- 5);
3013+
Locomotive.CruiseControl.SpeedMinus5Pressed = true;
3014+
}
3015+
else if (p == 0) Locomotive.CruiseControl.SpeedMinus5Pressed = false;
3016+
break;
3017+
}
3018+
case CABViewControlTypes.ORTS_CC_SPEED_PLUS1:
3019+
{
3020+
p = ChangedValue(0);
3021+
if (p == 1)
3022+
{
3023+
Locomotive.CruiseControl.SetSpeed(Locomotive.CruiseControl.SetSpeedKpHOrMpH + 1);
3024+
Locomotive.CruiseControl.SpeedPlus1Pressed = true;
3025+
}
3026+
else if (p == 0) Locomotive.CruiseControl.SpeedPlus1Pressed = false;
3027+
break;
3028+
}
3029+
case CABViewControlTypes.ORTS_CC_SPEED_MINUS1:
3030+
{
3031+
p = ChangedValue(0);
3032+
if (p == 1)
3033+
{
3034+
Locomotive.CruiseControl.SetSpeed(Locomotive.CruiseControl.SetSpeedKpHOrMpH - 1);
3035+
Locomotive.CruiseControl.SpeedMinus1Pressed = true;
3036+
}
3037+
else if (p == 0) Locomotive.CruiseControl.SpeedMinus1Pressed = false;
3038+
break;
29913039
}
29923040
case CABViewControlTypes.ORTS_DP_MOVE_TO_FRONT:
29933041
buttonState = ChangedValue(ButtonState ? 1 : 0) > 0;

0 commit comments

Comments
 (0)