Skip to content

Commit 2c8deab

Browse files
committed
Add RPM gauge for second diesel engine
1 parent fe7fa44 commit 2c8deab

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public enum CABViewControlTypes
136136
STEAMHEAT_PRESSURE,
137137
FIREBOX,
138138
RPM,
139+
RPM_2,
139140
FIREHOLE,
140141
CUTOFF,
141142
VACUUM_RESERVOIR_PRESSURE,

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4453,18 +4453,19 @@ public virtual float GetDataOf(CabViewControl cvc)
44534453
data = ConvertFromPSI(cvc, BrakeSystem.GetVacResPressurePSI());
44544454
break;
44554455
}
4456+
44564457
case CABViewControlTypes.RPM:
44574458
{
4459+
44584460
if (EngineType == EngineTypes.Control)
44594461
{
44604462
FindControlActiveLocomotive();
4463+
44614464
if (ControlActiveLocomotive != null)
44624465
{
44634466
var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive;
44644467
if (activeloco.DieselEngines[0] != null)
44654468
data = activeloco.DieselEngines[0].RealRPM;
4466-
// Trace.TraceInformation("Data#1 CarID {0} RPM {1}", CarID, data);
4467-
44684469
}
44694470

44704471
}
@@ -4473,11 +4474,35 @@ public virtual float GetDataOf(CabViewControl cvc)
44734474
var mstsDieselLocomotive = this as MSTSDieselLocomotive;
44744475
if (mstsDieselLocomotive.DieselEngines[0] != null)
44754476
data = mstsDieselLocomotive.DieselEngines[0].RealRPM;
4477+
}
4478+
break;
4479+
}
4480+
4481+
case CABViewControlTypes.RPM_2:
4482+
{
44764483

4477-
// Trace.TraceInformation("Data#2 CarID {0} RPM {1}", CarID, data);
4484+
FindControlActiveLocomotive();
4485+
4486+
if (ControlActiveLocomotive != null)
4487+
{
4488+
var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive;
4489+
var mstsDieselLocomotive = this as MSTSDieselLocomotive;
4490+
4491+
if (EngineType == EngineTypes.Control && activeloco.DieselEngines.NumOfActiveEngines > 1)
4492+
{
4493+
4494+
if (activeloco.DieselEngines[1] != null)
4495+
data = activeloco.DieselEngines[1].RealRPM;
4496+
}
4497+
else if (EngineType == EngineTypes.Diesel && mstsDieselLocomotive.DieselEngines.NumOfActiveEngines > 1)
4498+
{
4499+
if (mstsDieselLocomotive.DieselEngines[1] != null)
4500+
data = mstsDieselLocomotive.DieselEngines[1].RealRPM;
4501+
}
44784502
}
44794503
break;
44804504
}
4505+
44814506
case CABViewControlTypes.ORTS_DIESEL_TEMPERATURE:
44824507
{
44834508
var mstsDieselLocomotive = this as MSTSDieselLocomotive;

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,30 +3284,33 @@ public void FindControlActiveLocomotive()
32843284
ControlActiveLocomotive = null;
32853285
return;
32863286
}
3287-
32883287
var controlIndex = 0;
32893288
var activeIndex = 0;
32903289
bool controlCar = false;
32913290
bool activeLocomotive = false;
32923291

32933292
// Check to see if this car is an active locomotive, if so then set linkage to relevant control car.
3293+
// Note this only checks the "closest" locomotive to the control car. Hence it could be "fooled" if there is another locomotive besides the two DMU locomotives.
3294+
32943295
for (var i = 0; i < Train.Cars.Count; i++)
32953296
{
3296-
if (Train.Cars[i] == this && activeIndex == 0 && Train.Cars[i].EngineType == TrainCar.EngineTypes.Diesel)
3297+
3298+
if (activeIndex == 0 && Train.Cars[i].EngineType == TrainCar.EngineTypes.Diesel)
32973299
{
32983300
activeIndex = i;
32993301
activeLocomotive = true;
33003302
}
33013303

3302-
if (Train.Cars[i] == this && controlIndex == 0 && Train.Cars[i].EngineType == TrainCar.EngineTypes.Control)
3304+
if (controlIndex == 0 && Train.Cars[i].EngineType == TrainCar.EngineTypes.Control)
33033305
{
33043306
controlIndex = i;
33053307
controlCar = true;
33063308
}
33073309

3310+
// As soon as the control and active locomotive have been identified, then stop loop.
33083311
if (activeLocomotive && controlCar)
33093312
{
3310-
ControlActiveLocomotive = Train.Cars[activeIndex] as MSTSDieselLocomotive;
3313+
ControlActiveLocomotive = Train.Cars[activeIndex] as MSTSDieselLocomotive;
33113314
return;
33123315
}
33133316
}

0 commit comments

Comments
 (0)