Skip to content

Commit c6d7941

Browse files
committed
Initial Diesel Mechanic Locomotive Simulation
1 parent 8b269d8 commit c6d7941

File tree

8 files changed

+1294
-138
lines changed

8 files changed

+1294
-138
lines changed

Source/Orts.Simulation/Common/Scripting/PowerSupply/PowerSupply.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public enum PowerSupplyEvent
145145
ServiceRetentionCancellationButtonReleased,
146146
SwitchOnElectricTrainSupply,
147147
SwitchOffElectricTrainSupply,
148+
StallEngine,
148149
}
149150

150151
public enum PowerSupplyType

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

Lines changed: 125 additions & 27 deletions
Large diffs are not rendered by default.

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

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ public bool LargeEjectorSoundOn
298298
// Set values for display in HUD
299299
public float WagonCoefficientFrictionHUD;
300300
public float LocomotiveCoefficientFrictionHUD;
301+
public float HuDGearMaximumTractiveForce;
301302

302303
public PressureUnit MainPressureUnit = PressureUnit.None;
303304
public Dictionary<BrakeSystemComponent, PressureUnit> BrakeSystemPressureUnits = new Dictionary<BrakeSystemComponent, PressureUnit>
@@ -3473,10 +3474,37 @@ public virtual void StartGearBoxIncrease()
34733474
{
34743475
if (GearBoxController != null)
34753476
{
3476-
GearBoxController.StartIncrease();
3477-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
3478-
AlerterReset(TCSEvent.GearBoxChanged);
3479-
SignalGearBoxChangeEvents();
3477+
if (this is MSTSDieselLocomotive)
3478+
{
3479+
var dieselloco = this as MSTSDieselLocomotive;
3480+
3481+
if (dieselloco.DieselEngines[0].GearBox.GearBoxType != TypesGearBox.C)
3482+
{
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;
3489+
3490+
}
3491+
else if (dieselloco.DieselEngines[0].GearBox.GearBoxType == TypesGearBox.C)
3492+
{
3493+
3494+
if (ThrottlePercent == 0)
3495+
{
3496+
GearBoxController.StartIncrease();
3497+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
3498+
AlerterReset(TCSEvent.GearBoxChanged);
3499+
SignalGearBoxChangeEvents();
3500+
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3501+
}
3502+
else
3503+
{
3504+
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Throttle must be reduced to Idle before gear change can happen."));
3505+
}
3506+
}
3507+
}
34803508
}
34813509

34823510
ChangeGearUp();
@@ -3498,10 +3526,35 @@ public virtual void StartGearBoxDecrease()
34983526
{
34993527
if (GearBoxController != null)
35003528
{
3501-
GearBoxController.StartDecrease();
3502-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
3503-
AlerterReset(TCSEvent.GearBoxChanged);
3504-
SignalGearBoxChangeEvents();
3529+
if (this is MSTSDieselLocomotive)
3530+
{
3531+
var dieselloco = this as MSTSDieselLocomotive;
3532+
3533+
if (dieselloco.DieselEngines[0].GearBox.GearBoxType != TypesGearBox.C)
3534+
{
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)
3545+
{
3546+
GearBoxController.StartDecrease();
3547+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
3548+
AlerterReset(TCSEvent.GearBoxChanged);
3549+
SignalGearBoxChangeEvents();
3550+
dieselloco.DieselEngines[0].GearBox.clutchOn = false;
3551+
}
3552+
else
3553+
{
3554+
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Throttle must be reduced to Idle before gear change can happen."));
3555+
}
3556+
}
3557+
}
35053558
}
35063559

35073560
ChangeGearDown();
@@ -3557,19 +3610,32 @@ private void SignalGearBoxChangeEvents()
35573610
}
35583611
}
35593612

3560-
public void SetGearBoxValue(float value)
3613+
public void SetGearBoxValue(float value) // control for cabview
35613614
{
35623615
var controller = GearBoxController;
35633616
var oldValue = controller.CurrentValue;
35643617
var change = controller.SetValue(value);
3618+
var dieselloco = this as MSTSDieselLocomotive;
35653619
if (change != 0)
35663620
{
35673621
//new GarBoxCommand(Simulator.Log, change > 0, controller.CurrentValue, Simulator.ClockTime);
35683622
SignalEvent(change > 0 ? Event.GearUp : Event.GearDown);
35693623
AlerterReset(TCSEvent.GearBoxChanged);
35703624
}
3571-
if (oldValue != controller.CurrentValue)
3625+
3626+
if (controller.CurrentValue > oldValue)
3627+
{
3628+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, GearBoxController.CurrentNotch);
3629+
if (dieselloco != null)
3630+
dieselloco.DieselEngines[0].GearBox.ManualGearUp = true;
3631+
3632+
}
3633+
else if (controller.CurrentValue < oldValue)
3634+
{
35723635
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, GearBoxController.CurrentNotch);
3636+
if (dieselloco != null)
3637+
dieselloco.DieselEngines[0].GearBox.ManualGearDown = true;
3638+
}
35733639
}
35743640
#endregion
35753641

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6828,7 +6828,7 @@ public void SteamStartGearBoxDecrease()
68286828
if (SteamGearPosition > 0.0f) // Gear number can't go below zero
68296829
{
68306830
SteamGearPosition -= 1.0f;
6831-
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, SteamGearPosition);
6831+
Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Decrease, SteamGearPosition);
68326832
if (SteamGearPosition == 1.0)
68336833
{
68346834

0 commit comments

Comments
 (0)