Skip to content

Commit 72ec4b1

Browse files
committed
Correct some issues identified
1 parent aa73f61 commit 72ec4b1

File tree

5 files changed

+67
-40
lines changed

5 files changed

+67
-40
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSDieselLocomotive.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ public override void ChangeGearUp()
800800
{
801801
if (DieselEngines[0].GearBox != null)
802802
{
803-
if (DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Semiautomatic || DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Automatic)
803+
if (DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Semiautomatic)
804804
{
805805
DieselEngines[0].GearBox.AutoGearUp();
806806
GearBoxController.SetValue((float)DieselEngines[0].GearBox.NextGearIndex);
@@ -817,7 +817,7 @@ public override void ChangeGearDown()
817817

818818
if (DieselEngines[0].GearBox != null)
819819
{
820-
if (DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Semiautomatic || DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Automatic)
820+
if (DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Semiautomatic)
821821
{
822822
DieselEngines[0].GearBox.AutoGearDown();
823823
GearBoxController.SetValue((float)DieselEngines[0].GearBox.NextGearIndex);
@@ -948,13 +948,14 @@ public override string GetDebugStatus()
948948
{
949949
var status = new StringBuilder(base.GetDebugStatus());
950950

951-
if (DieselEngines.HasGearBox)
951+
if (DieselEngines.HasGearBox && DieselTransmissionType == DieselTransmissionTypes.Mechanic)
952952
{
953953
status.AppendFormat("\t{0} {1}-{2}", Simulator.Catalog.GetString("Gear"), DieselEngines[0].GearBox.CurrentGearIndex < 0 ? Simulator.Catalog.GetString("N") : (DieselEngines[0].GearBox.CurrentGearIndex + 1).ToString(), DieselEngines[0].GearBox.GearBoxType);
954+
}
954955
status.AppendFormat("\t{0} {1}\t\t{2}\n",
955956
Simulator.Catalog.GetString("Fuel"),
956957
FormatStrings.FormatFuelVolume(DieselLevelL, IsMetric, IsUK), DieselEngines.GetStatus());
957-
}
958+
958959

959960
if (IsSteamHeatFitted && Train.PassengerCarsNumber > 0 && this.IsLeadLocomotive() && Train.CarSteamHeatOn)
960961
{

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

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,32 +3478,43 @@ public virtual void StartGearBoxIncrease()
34783478
{
34793479
var dieselloco = this as MSTSDieselLocomotive;
34803480

3481-
if (dieselloco.DieselEngines[0].GearBox.GearBoxType != TypesGearBox.C)
3481+
if (dieselloco.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
34823482
{
3483-
GearBoxController.StartIncrease();
3484-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
3485-
AlerterReset(TCSEvent.GearBoxChanged);
3486-
SignalGearBoxChangeEvents();
3487-
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3488-
dieselloco.DieselEngines[0].GearBox.ManualGearChange = true;
34893483

3490-
}
3491-
else if (dieselloco.DieselEngines[0].GearBox.GearBoxType == TypesGearBox.C)
3492-
{
3493-
3494-
if (ThrottlePercent == 0)
3484+
if (dieselloco.DieselEngines[0].GearBox.GearBoxType != TypesGearBox.C)
34953485
{
34963486
GearBoxController.StartIncrease();
34973487
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
34983488
AlerterReset(TCSEvent.GearBoxChanged);
34993489
SignalGearBoxChangeEvents();
35003490
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3491+
dieselloco.DieselEngines[0].GearBox.ManualGearChange = true;
3492+
35013493
}
3502-
else
3494+
else if (dieselloco.DieselEngines[0].GearBox.GearBoxType == TypesGearBox.C)
35033495
{
3504-
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Throttle must be reduced to Idle before gear change can happen."));
3496+
3497+
if (ThrottlePercent == 0)
3498+
{
3499+
GearBoxController.StartIncrease();
3500+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
3501+
AlerterReset(TCSEvent.GearBoxChanged);
3502+
SignalGearBoxChangeEvents();
3503+
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3504+
}
3505+
else
3506+
{
3507+
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Throttle must be reduced to Idle before gear change can happen."));
3508+
}
35053509
}
35063510
}
3511+
else // Legacy operation
3512+
{
3513+
GearBoxController.StartIncrease();
3514+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
3515+
AlerterReset(TCSEvent.GearBoxChanged);
3516+
SignalGearBoxChangeEvents();
3517+
}
35073518
}
35083519
}
35093520

@@ -3530,30 +3541,42 @@ public virtual void StartGearBoxDecrease()
35303541
{
35313542
var dieselloco = this as MSTSDieselLocomotive;
35323543

3533-
if (dieselloco.DieselEngines[0].GearBox.GearBoxType != TypesGearBox.C)
3544+
if (dieselloco.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
35343545
{
3535-
GearBoxController.StartDecrease();
3536-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
3537-
AlerterReset(TCSEvent.GearBoxChanged);
3538-
SignalGearBoxChangeEvents();
3539-
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3540-
dieselloco.DieselEngines[0].GearBox.ManualGearChange = true;
3541-
}
3542-
else if (dieselloco.DieselEngines[0].GearBox.GearBoxType == TypesGearBox.C)
3543-
{
3544-
if (ThrottlePercent == 0)
3546+
3547+
if (dieselloco.DieselEngines[0].GearBox.GearBoxType != TypesGearBox.C)
35453548
{
35463549
GearBoxController.StartDecrease();
35473550
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
35483551
AlerterReset(TCSEvent.GearBoxChanged);
35493552
SignalGearBoxChangeEvents();
35503553
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3554+
dieselloco.DieselEngines[0].GearBox.ManualGearChange = true;
35513555
}
3552-
else
3556+
else if (dieselloco.DieselEngines[0].GearBox.GearBoxType == TypesGearBox.C)
35533557
{
3554-
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Throttle must be reduced to Idle before gear change can happen."));
3558+
if (ThrottlePercent == 0)
3559+
{
3560+
GearBoxController.StartDecrease();
3561+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
3562+
AlerterReset(TCSEvent.GearBoxChanged);
3563+
SignalGearBoxChangeEvents();
3564+
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3565+
}
3566+
else
3567+
{
3568+
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Throttle must be reduced to Idle before gear change can happen."));
3569+
}
35553570
}
35563571
}
3572+
else // Legacy operation
3573+
{
3574+
GearBoxController.StartDecrease();
3575+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
3576+
AlerterReset(TCSEvent.GearBoxChanged);
3577+
SignalGearBoxChangeEvents();
3578+
3579+
}
35573580
}
35583581
}
35593582

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselEngine.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ public void Update(float elapsedClockSeconds)
12911291

12921292
if (GearBox.CurrentGear != null)
12931293
{
1294+
// Maintain Shaft RpM and Engine RpM equasl when clutch is on
12941295
if (GearBox.IsClutchOn)
12951296
DemandedRPM = GearBox.ShaftRPM;
12961297
}
@@ -1646,7 +1647,7 @@ public void InitFromMSTS()
16461647

16471648
if (MaximumRailOutputPowerW == 0 && Locomotive.MaxPowerW != 0)
16481649
{
1649-
MaximumRailOutputPowerW = Locomotive.MaxPowerW; // set rail power to a default value on the basis that of the value specified in the MaxPowrW parameter
1650+
MaximumRailOutputPowerW = Locomotive.MaxPowerW; // set rail power to a default value on the basis that of the value specified in the MaxPowerW parameter
16501651
}
16511652
else
16521653
{

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/GearBox.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public class MSTSGearBoxParams
3333
public int GearBoxNumberOfGears = 1;
3434
public int GearBoxDirectDriveGear = 1;
3535
public bool FreeWheelFitted = false;
36-
public TypesGearBox GearBoxType = TypesGearBox.A;
36+
public TypesGearBox GearBoxType = TypesGearBox.Unknown;
3737
// GearboxType ( A ) - power is continuous during gear changes (and throttle does not need to be adjusted)
3838
// GearboxType ( B ) - power is interrupted during gear changes - but the throttle does not need to be adjusted when changing gear
3939
// GearboxType ( C ) - power is interrupted and if GearboxOperation is Manual throttle must be closed when changing gear
4040
// GearboxType ( D ) - power is interrupted and if GearboxOperation is Manual throttle must be closed when changing gear, clutch will remain engaged, and can stall engine
4141

42-
public TypesClutch ClutchType = TypesClutch.Friction;
42+
public TypesClutch ClutchType = TypesClutch.Unknown;
4343

4444

4545
public GearBoxOperation GearBoxOperation = GearBoxOperation.Manual;
@@ -52,7 +52,7 @@ public class MSTSGearBoxParams
5252
public float GearBoxOverspeedPercentageForFailure = 150f;
5353
public float GearBoxBackLoadForceN = 1000;
5454
public float GearBoxCoastingForceN = 500;
55-
public float GearBoxUpGearProportion = 1.0f;
55+
public float GearBoxUpGearProportion = 0.85f;
5656
public float GearBoxDownGearProportion = 0.35f;
5757

5858
int initLevel;
@@ -493,7 +493,7 @@ public float ShaftRPM
493493
}
494494

495495
}
496-
else
496+
else // Legacy operation
497497
{
498498

499499
if (CurrentGear == null)
@@ -532,8 +532,8 @@ public bool IsOverspeedWarning
532532

533533
public bool AutoClutch = true;
534534

535-
public TypesClutch ClutchType = TypesClutch.Friction;
536-
public TypesGearBox GearBoxType = TypesGearBox.A;
535+
public TypesClutch ClutchType = TypesClutch.Unknown;
536+
public TypesGearBox GearBoxType = TypesGearBox.Unknown;
537537
public GearBoxOperation GearBoxOperation = GearBoxOperation.Manual;
538538
public GearBoxOperation OriginalGearBoxOperation = GearBoxOperation.Manual;
539539

@@ -881,7 +881,7 @@ public void Update(float elapsedClockSeconds)
881881
}
882882

883883
}
884-
else
884+
else // Legacy operation
885885
{
886886
if ((clutch <= 0.05) || (clutch >= 1f))
887887
{
@@ -981,13 +981,15 @@ public void Update(float elapsedClockSeconds)
981981

982982
public enum TypesClutch
983983
{
984+
Unknown,
984985
Friction,
985986
Fluid,
986987
Scoop
987988
}
988989

989990
public enum TypesGearBox
990991
{
992+
Unknown,
991993
A,
992994
B,
993995
C,

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ public virtual string GetDebugStatus()
21752175
}
21762176

21772177
var loco = this as MSTSDieselLocomotive;
2178-
if (loco != null && loco.DieselEngines.HasGearBox)
2178+
if (loco != null && loco.DieselEngines.HasGearBox && loco.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
21792179
{
21802180
return String.Format("{0}\t{1}\t{2}\t{3}\t{4:F0}%\t{5} - {6:F0} rpm\t\t{7}\t{8}\t{9}\t",
21812181
CarID,

0 commit comments

Comments
 (0)