Skip to content

Commit

Permalink
Automatic merge of T1.4-44-gf92b5fa09 and 8 pull requests
Browse files Browse the repository at this point in the history
- Pull request #480 at 7815b89: Blueprint https://blueprints.launchpad.net/or/+spec/digital-alignment-in-3dcabs
- Pull request #510 at f25fe0c: Add performance monitoring for diesel mechanic locomotives and new parameters
- Pull request #519 at 94c4637: Website changes for Release v1.4
- Pull request #522 at 78c046c: Correct issue with tender water mass
- Pull request #525 at 41d74e4: Add SignalTypeName and DrawStateName to SignalFeatures
- Pull request #526 at 2bfe684: Bug fix for https://bugs.launchpad.net/or/+bug/1949292 AI train disappears after coupling and reversing
- Pull request #527 at c786144: Brake cuts power refactor and new parameters
- Pull request #528 at 212eba1: Updated link to Siskiyou Route site
  • Loading branch information
openrails-bot committed Nov 2, 2021
10 parents 456d2f2 + f92b5fa + 7815b89 + f25fe0c + 94c4637 + 78c046c + 41d74e4 + 2bfe684 + c786144 + 212eba1 commit 23eeaf8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,10 @@ public override void ChangeGearUp()
DieselEngines[0].GearBox.AutoGearUp();
GearBoxController.SetValue((float)DieselEngines[0].GearBox.NextGearIndex);
}
else if (DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Manual)
{
DieselEngines[0].GearBox.ManualGearUp = true;
}
}
}

Expand All @@ -771,6 +775,11 @@ public override void ChangeGearDown()
DieselEngines[0].GearBox.AutoGearDown();
GearBoxController.SetValue((float)DieselEngines[0].GearBox.NextGearIndex);
}
else if (DieselEngines[0].GearBox.GearBoxOperation == GearBoxOperation.Manual)
{
DieselEngines[0].GearBox.ManualGearDown = true;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public bool LargeEjectorSoundOn
// Set values for display in HUD
public float WagonCoefficientFrictionHUD;
public float LocomotiveCoefficientFrictionHUD;
public float HuDGearMaximumTractiveForce;

public PressureUnit MainPressureUnit = PressureUnit.None;
public Dictionary<BrakeSystemComponent, PressureUnit> BrakeSystemPressureUnits = new Dictionary<BrakeSystemComponent, PressureUnit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,22 @@ public void Update(float elapsedClockSeconds)
}
else // for gear box type 2 & 3
{
// When a manual gear change is initiated, then reduce motive to zero (done in gear box class) whilst gear change is occurring, allow time delay for gears to change
if (GearBox.ManualGearChange && !GearBox.ManualGearBoxChangeOn) // Initially set gear change
{
GearBox.ManualGearBoxChangeOn = true;
}
else if (GearBox.ManualGearBoxChangeOn && GearBox.ManualGearTimerS < GearBox.ManualGearTimerResetS)
{
GearBox.ManualGearTimerS += elapsedClockSeconds; // Increment timer
}
else if (GearBox.ManualGearBoxChangeOn && GearBox.ManualGearTimerS > GearBox.ManualGearTimerResetS)
{
GearBox.ManualGearBoxChangeOn = false;
GearBox.ManualGearTimerS = 0; // Reset timer
}


if (RealRPM > 0)
GearBox.ClutchPercent = (RealRPM - GearBox.ShaftRPM) / RealRPM * 100f;
else
Expand All @@ -1013,8 +1029,10 @@ public void Update(float elapsedClockSeconds)
}
}

if (RealRPM < 0.8f * IdleRPM && ThrottlePercent > 0)
// Simulate stalled engine if RpM decreases too far, by stopping engine
if (RealRPM < 0.9f * IdleRPM)
{
Trace.TraceInformation("Diesel Engine has stalled");
HandleEvent(PowerSupplyEvent.StopEngine);
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Diesel Engine has stalled."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ public class GearBox : ISubSystem<GearBox>
protected MSTSGearBoxParams GearBoxParams => Locomotive.DieselEngines.MSTSGearBoxParams;
public List<Gear> Gears = new List<Gear>();

public float ManualGearTimerResetS = 1; // Allow gear change to take 1 seconds
public float ManualGearTimerS; // Time for gears to change
public bool ManualGearBoxChangeOn = false;
public bool ManualGearUp = false;
public bool ManualGearDown = false;

public Gear CurrentGear
{
get
Expand Down Expand Up @@ -409,14 +415,25 @@ public float TractiveForceN
}
float tractiveForceN = DieselEngine.DieselTorqueTab[dieselRpM] / DieselEngine.DieselTorqueTab.MaxY() * CurrentGear.MaxTractiveForceN;

Locomotive.HuDGearMaximumTractiveForce = CurrentGear.MaxTractiveForceN;

// Limit tractive force if engine is governed, ie speed cannot exceed the governed speed
if (DieselEngine.RealRPM >= DieselEngine.GovenorRPM && ShaftRPM > DieselEngine.GovenorRPM)
// Limit tractive force if engine is governed, ie speed cannot exceed the governed speed or the throttled speed

if ((DieselEngine.RealRPM >= DieselEngine.GovenorRPM && ShaftRPM > DieselEngine.GovenorRPM) || (DieselEngine.RealRPM < DieselEngine.GovenorRPM && DieselEngine.RealRPM > DieselEngine.ThrottleRPMTab[DieselEngine.DemandedThrottlePercent]))
{
// use decay function to decrease tractive effort if RpM exceeds governed RpM value.
// y = original amount ( 1 - decay rate)^length of prediction
float decayRpM = 0;

var decayRpM = ShaftRPM - DieselEngine.GovenorRPM;
if (DieselEngine.RealRPM < DieselEngine.GovenorRPM && DieselEngine.RealRPM > DieselEngine.ThrottleRPMTab[DieselEngine.DemandedThrottlePercent])
{
decayRpM = ShaftRPM - DieselEngine.ThrottleRPMTab[DieselEngine.DemandedThrottlePercent];
}
else
{
decayRpM = ShaftRPM - DieselEngine.GovenorRPM;
}

var teDecline = Math.Pow((1.0f - 0.05f), decayRpM);

tractiveForceN = (float)Math.Abs(CurrentGear.MaxTractiveForceN * teDecline);
Expand All @@ -434,8 +451,8 @@ public float TractiveForceN

}

// When a manual gear change is initiated, then reduce motive to zero whilst gear change is occurring
if (ManualGearChange)
// Set TE to zero if gear change happening
if (ManualGearBoxChangeOn)
{
tractiveForceN = 0;
}
Expand Down Expand Up @@ -573,20 +590,44 @@ public void InitializeMoving()

public void Update(float elapsedClockSeconds)
{
if ((clutch <= 0.05) || (clutch >= 1f))
if (GearBoxOperation == GearBoxOperation.Automatic || GearBoxOperation == GearBoxOperation.Semiautomatic)
{
if (currentGearIndex < nextGearIndex)
if ((clutch <= 0.05) || (clutch >= 1f))
{
DieselEngine.Locomotive.SignalEvent(Event.GearUp);
currentGearIndex = nextGearIndex;
if (currentGearIndex < nextGearIndex)
{
DieselEngine.Locomotive.SignalEvent(Event.GearUp);
currentGearIndex = nextGearIndex;
}
}
if ((clutch <= 0.05) || (clutch >= 0.5f))
{
if (currentGearIndex > nextGearIndex)
{
DieselEngine.Locomotive.SignalEvent(Event.GearDown);
currentGearIndex = nextGearIndex;
}
}
}
if ((clutch <= 0.05) || (clutch >= 0.5f))
else if (GearBoxOperation == GearBoxOperation.Manual)
{
if (currentGearIndex > nextGearIndex)
if (ManualGearUp)
{
DieselEngine.Locomotive.SignalEvent(Event.GearDown);
currentGearIndex = nextGearIndex;
if (currentGearIndex < nextGearIndex)
{
DieselEngine.Locomotive.SignalEvent(Event.GearUp);
currentGearIndex = nextGearIndex;
ManualGearUp = false;
}
}
if (ManualGearDown)
{
if (currentGearIndex > nextGearIndex)
{
DieselEngine.Locomotive.SignalEvent(Event.GearDown);
currentGearIndex = nextGearIndex;
ManualGearDown = false;
}
}
}

Expand Down
23 changes: 21 additions & 2 deletions Source/RunActivity/Viewer3D/Popups/HUDWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,27 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime, bo
if (Visible && TextPages[TextPage] == TextPageForceInfo)
{
var loco = Viewer.PlayerLocomotive as MSTSLocomotive;
ForceGraphMotiveForce.AddSample(loco.MotiveForceN / loco.MaxForceN);
ForceGraphDynamicForce.AddSample(-loco.MotiveForceN / loco.MaxForceN);
var locoD = Viewer.PlayerLocomotive as MSTSDieselLocomotive;

// For geared locomotives the Max Force base value needs to change for each gear.
if (locoD != null && locoD.DieselEngines.HasGearBox)
{
ForceGraphMotiveForce.AddSample(loco.MotiveForceN / loco.HuDGearMaximumTractiveForce);
}
else
{
ForceGraphMotiveForce.AddSample(loco.MotiveForceN / loco.MaxForceN);
}

if (locoD != null && locoD.DieselEngines.HasGearBox)
{
ForceGraphDynamicForce.AddSample(-loco.MotiveForceN / loco.HuDGearMaximumTractiveForce);
}
else
{
ForceGraphDynamicForce.AddSample(-loco.MotiveForceN / loco.MaxForceN);
}

ForceGraphNumOfSubsteps.AddSample((float)loco.LocomotiveAxle.AxleRevolutionsInt.NumOfSubstepsPS / (float)loco.LocomotiveAxle.AxleRevolutionsInt.MaxSubsteps);

ForceGraphs.PrepareFrame(frame);
Expand Down

0 comments on commit 23eeaf8

Please sign in to comment.