Skip to content

Commit 71ab3cd

Browse files
committed
Automatic merge of T1.5.1-963-g375f79869 and 15 pull requests
- Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 3ca0eb1: Blueprint/train car operations UI window - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #900 at c27f32d: DMI updates - Pull request #903 at 7af1f91: Downloading route content (Github, zip) - Pull request #912 at 5f5f1f5: New Triple Valve Features Vol. 2 - Pull request #919 at 26cc6a8: Added mouse wheel support for controls which can be moved by pressing t… - Pull request #922 at abe2e52: Autopilot for timetable mode - Pull request #923 at 4c27204: Add curve squeal to route - Pull request #939 at 15ba46b: Add KM/HOUR/MIN to Cabview Units + Custom Units - Pull request #940 at f8b5b15: Browser HUD column alignment improvements
17 parents c8ce4be + 375f798 + dfc715e + d00beb9 + f92de76 + 3ca0eb1 + 9a1d6b2 + 1f5ba4c + 5866028 + c27f32d + 7af1f91 + 5f5f1f5 + 26cc6a8 + abe2e52 + 4c27204 + 15ba46b + f8b5b15 commit 71ab3cd

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -791,15 +791,22 @@ Custom Display Units
791791

792792
Due to the wide variety of railroad equipment across the world, Open Rails may not
793793
provide the units of measure needed for a cabview control. In this case, the tokens
794-
`ORTSUnitsScaleFactor` and `ORTSUnitsOffset` can be added to the control block in
795-
the .cvf file to create the units of measure required for the cab view.
796-
797-
- ORTSUnitsScaleFactor ( x ): Multiplies the value shown by the cab view control
798-
by a factor of x, allowing for arbitrary conversion of units of measure. For
799-
example, a cab view control displaying MILES_PER_HOUR with ORTSUnitsScaleFactor ( 1.467 )
800-
would instead display a value equivalent to feet per second.
801-
- ORTSUnitsOffset ( x ): After applying the scale factor, adds x to the value shown
802-
by the cab view control. To subtract from the shown value, set x to a negative number.
794+
`ORTSUnitsExponent`, `ORTSUnitsScaleFactor`, and `ORTSUnitsOffset` can be added
795+
to the control block in the .cvf file to create the units of measure required for
796+
the cab view.
797+
798+
- ORTSUnitsExponent ( x ): Raises the value shown by the cab view control to the
799+
power of x, which may be used to calibrate nonlinear gauges or complete nonlinear
800+
conversions. Fractional and negative values are allowed. For example, an accelerometer
801+
gauge with ORTSUnitsExponent ( 0.5 ) would change the accelerometer to be more sensitive
802+
to small accelerations, but less sensitive to large acceleration. (However, the values
803+
shown would not be in any meaningful units.)
804+
- ORTSUnitsScaleFactor ( y ): After accounting for any exponent, multiplies the value
805+
shown by the cab view control by a factor of y, allowing for arbitrary conversion of
806+
units of measure. For example, a cab view control displaying MILES_PER_HOUR with
807+
ORTSUnitsScaleFactor ( 1.467 ) would instead display a value equivalent to feet per second.
808+
- ORTSUnitsOffset ( z ): After applying the scale factor, adds z to the value shown
809+
by the cab view control. To subtract from the shown value, set z to a negative number.
803810
For example, a cab view control with units of BAR and ORTSUnitsOffset ( 0.987 ) would show
804811
pressure as absolute pressure, rather than gauge pressure.
805812

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ public class CabViewControl
470470
public CABViewControlStyles ControlStyle = CABViewControlStyles.NONE;
471471
public CABViewControlUnits Units = CABViewControlUnits.NONE;
472472

473+
public double UnitsExponent = 1.0f;
473474
public float UnitsScale = 1.0f;
474475
public float UnitsOffset;
475476

@@ -690,6 +691,7 @@ public CVCDial(STFReader stf, string basepath)
690691
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
691692
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
692693
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
694+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
693695
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
694696
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
695697
});
@@ -788,6 +790,7 @@ public CVCGauge(STFReader stf, string basepath)
788790
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
789791
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
790792
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
793+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
791794
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
792795
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
793796
});
@@ -932,6 +935,7 @@ public CVCDigital(STFReader stf, string basepath)
932935
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
933936
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
934937
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
938+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
935939
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
936940
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
937941
});
@@ -1190,6 +1194,7 @@ public CVCDiscrete(STFReader stf, string basepath, DiscreteStates discreteState)
11901194
new STFReader.TokenProcessor("ortsnewscreenpage", () => {ParseNewScreen(stf); }),
11911195
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
11921196
new STFReader.TokenProcessor("ortsparameter1", ()=>{ Parameter1 = stf.ReadFloatBlock(STFReader.UNITS.Any, 0); }),
1197+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
11931198
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
11941199
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
11951200
});
@@ -1438,6 +1443,7 @@ public CVCMultiStateDisplay(STFReader stf, string basepath)
14381443
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
14391444
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
14401445
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
1446+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
14411447
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
14421448
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
14431449
});
@@ -1490,6 +1496,7 @@ public CVCAnimatedDisplay(STFReader stf, string basepath)
14901496
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
14911497
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
14921498
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
1499+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
14931500
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
14941501
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
14951502
});
@@ -1533,6 +1540,7 @@ public CVCScreen(STFReader stf, string basepath)
15331540
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
15341541
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
15351542
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
1543+
new STFReader.TokenProcessor("ortsunitsexponent", ()=>{ UnitsExponent = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
15361544
new STFReader.TokenProcessor("ortsunitsscalefactor", ()=>{ UnitsScale = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
15371545
new STFReader.TokenProcessor("ortsunitsoffset", ()=>{ UnitsOffset = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
15381546
});

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6136,7 +6136,10 @@ public virtual float GetDataOf(CabViewControl cvc)
61366136
data = Train.EOT.GetDataOf(cvc);
61376137
break;
61386138
}
6139-
6139+
// Don't waste time calculating exponents if one isn't set
6140+
// To avoid potential imaginary numbers, use data's absolute value
6141+
if (cvc.UnitsExponent != 1.0f)
6142+
data = Math.Sign(data)*(float)Math.Pow(Math.Abs(data), cvc.UnitsExponent);
61406143
data = cvc.UnitsOffset + (data * cvc.UnitsScale);
61416144

61426145
return data;

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ public virtual int GetDrawIndex()
22352235
{
22362236
if (Locomotive.CruiseControl != null)
22372237
{
2238-
if (Locomotive.CruiseControl.SpeedRegMode == Simulation.RollingStocks.SubSystems.CruiseControl.SpeedRegulatorMode.Auto && !Locomotive.CruiseControl.DynamicBrakePriority)
2238+
if ((Locomotive.CruiseControl.SpeedRegMode == Simulation.RollingStocks.SubSystems.CruiseControl.SpeedRegulatorMode.Auto && !Locomotive.CruiseControl.DynamicBrakePriority) || Locomotive.DynamicBrakeIntervention > 0)
22392239
{
22402240
index = 0;
22412241
}

0 commit comments

Comments
 (0)