Skip to content

Commit

Permalink
Merge branch 'master' into webserver2-trackmonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
cjakeman committed Jul 27, 2020
2 parents 26983e9 + 8bc130b commit 41c2b39
Show file tree
Hide file tree
Showing 31 changed files with 3,124 additions and 591 deletions.
6 changes: 6 additions & 0 deletions Source/Documentation/Manual/sound.rst
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ Trigger Function
200 GearPosition0
201 GearPosition1
202 GearPosition2
203 GearPosition3
204 GearPosition4
205 GearPosition5
206 GearPosition6
207 GearPosition7
208 GearPosition8
========= =====================================

Variable Triggers
Expand Down
28 changes: 18 additions & 10 deletions Source/ORTS.Menu/Consists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,33 @@ internal Locomotive(string filePath)
}
else if (File.Exists(filePath))
{
var showInList = true;
EngineFile engFile;
try
{
var engFile = new EngineFile(filePath);
showInList = !string.IsNullOrEmpty(engFile.CabViewFile);
Name = engFile.Name.Trim();
Description = engFile.Description.Trim();
engFile = new EngineFile(filePath);
}
catch
{
Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
Name = $"<{catalog.GetString("load error:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";
engFile = null;
}
if (engFile != null)
{
bool showInList = !string.IsNullOrEmpty(engFile.CabViewFile);
if (!showInList)
throw new InvalidDataException(catalog.GetStringFmt("Locomotive '{0}' is excluded.", filePath));

string name = (engFile.Name ?? "").Trim();
Name = name != "" ? name : $"<{catalog.GetString("unnamed:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";

string description = (engFile.Description ?? "").Trim();
if (description != "")
Description = description;
}
if (!showInList) throw new InvalidDataException(catalog.GetStringFmt("Locomotive '{0}' is excluded.", filePath));
if (string.IsNullOrEmpty(Name)) Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
if (string.IsNullOrEmpty(Description)) Description = null;
}
else
{
Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
Name = $"<{catalog.GetString("missing:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";
}
FilePath = filePath;
}
Expand Down
14 changes: 14 additions & 0 deletions Source/Orts.Simulation/Common/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ public enum Event
GearPosition0,
GearPosition1,
GearPosition2,
GearPosition3,
GearPosition4,
GearPosition5,
GearPosition6,
GearPosition7,
GearPosition8,


}

public static class Events
Expand Down Expand Up @@ -395,6 +403,12 @@ public static Event From(bool mstsBinEnabled, Source source, int eventID)
case 200: return Event.GearPosition0;
case 201: return Event.GearPosition1;
case 202: return Event.GearPosition2;
case 203: return Event.GearPosition3;
case 204: return Event.GearPosition4;
case 205: return Event.GearPosition5;
case 206: return Event.GearPosition6;
case 207: return Event.GearPosition7;
case 208: return Event.GearPosition8;

default: return 0;
}
Expand Down
907 changes: 794 additions & 113 deletions Source/Orts.Simulation/Simulation/Physics/Train.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ public override void Save(BinaryWriter outf)
base.Save(outf);

TrainControlSystem.Save(outf);
LocomotiveAxle.Save(outf);
}

/// <summary>
Expand Down Expand Up @@ -1070,6 +1071,7 @@ public override void Restore(BinaryReader inf)
base.Restore(inf);

TrainControlSystem.Restore(inf);
LocomotiveAxle = new Axle(inf);
}

public bool IsLeadLocomotive()
Expand Down Expand Up @@ -3101,9 +3103,27 @@ private void SignalGearBoxChangeEvents()
case 1:
SignalEvent(Event.GearPosition1);
break;
default:
case 2:
SignalEvent(Event.GearPosition2);
break;
case 3:
SignalEvent(Event.GearPosition3);
break;
case 4:
SignalEvent(Event.GearPosition4);
break;
case 5:
SignalEvent(Event.GearPosition5);
break;
case 6:
SignalEvent(Event.GearPosition6);
break;
case 7:
SignalEvent(Event.GearPosition7);
break;
default:
SignalEvent(Event.GearPosition8);
break;
}
PreviousGearBoxNotch = GearBoxController.CurrentNotch; // Update previous value for next time around
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ public class MSTSSteamLocomotive : MSTSLocomotive
bool FullBoilerHeat = false; // Boiler heat has exceeded max possible heat in boiler (max operating steam pressure)
bool FullMaxPressBoilerHeat = false; // Boiler heat has exceed the max total possible heat in boiler (max safety valve pressure)
bool ShovelAnyway = false; // Predicts when the AI fireman should be increasing the fire burn rate despite the heat in the boiler
bool IsGrateLimit = false; // Grate limit of locomotive exceeded
/// <summary>
/// Grate limit of locomotive exceedeed?
/// </summary>
public bool IsGrateLimit { get; protected set; } = false;
bool HasSuperheater = false; // Flag to indicate whether locomotive is superheated steam type
bool IsSuperSet = false; // Flag to indicate whether superheating is reducing cylinder condenstation
bool IsSaturated = false; // Flag to indicate locomotive is saturated steam type
Expand Down Expand Up @@ -222,9 +225,15 @@ public class MSTSSteamLocomotive : MSTSLocomotive
float IdealFireMassKG; // Target fire mass
float MaxFireMassKG; // Max possible fire mass
float MaxFiringRateKGpS; // Max rate at which fireman or stoker can can feed coal into fire
float GrateLimitLBpFt2 = 150.0f; // Max combustion rate of the grate, once this is reached, no more steam is produced.
/// <summary>
/// Max combustion rate of the grate; once this is reached, no more steam is produced.
/// </summary>
public float GrateLimitLBpFt2 { get; protected set; } = 150.0f;
float MaxFuelBurnGrateKGpS; // Maximum rate of fuel burnt depending upon grate limit
float GrateCombustionRateLBpFt2; // Grate combustion rate, ie how many lbs coal burnt per sq ft grate area.
/// <summary>
/// Grate combustion rate, i.e. how many lbs coal burnt per sq ft grate area.
/// </summary>
public float GrateCombustionRateLBpFt2 { get; protected set; }
float ORTSMaxFiringRateKGpS; // OR equivalent of above
float DisplayMaxFiringRateKGpS; // Display value of MaxFiringRate
public float SafetyValveUsageLBpS;
Expand Down Expand Up @@ -395,14 +404,17 @@ public class MSTSSteamLocomotive : MSTSLocomotive
float BkW_Diff; // Net Energy into boiler after steam loads taken.
float WaterVolL; // Actual volume of water in bolier (litres)
float BoilerHeatOutBTUpS = 0.0f;// heat out of boiler in BTU
float BoilerHeatInBTUpS = 0.0f; // heat into boiler in BTU
/// <summary>
/// Heat into boiler in BTU
/// </summary>
public float BoilerHeatInBTUpS { get; protected set; } = 0.0f;
float BoilerHeatExcess; // Vlaue of excess boiler heat
float InjCylEquivSizeIN; // Calculate the equivalent cylinder size for purpose of sizing the injector.
float InjectorSize; // size of injector installed on boiler

// Values from previous iteration to use in UpdateFiring() and show in HUD
float PreviousBoilerHeatOutBTUpS = 0.0f;
public float PreviousTotalSteamUsageLBpS;
public float PreviousBoilerHeatOutBTUpS { get; protected set; } = 0.0f;
public float PreviousTotalSteamUsageLBpS { get; protected set; }
float Injector1WaterDelTempF = 65f; // Injector 1 water delivery temperature - F
float Injector2WaterDelTempF = 65f; // Injector 1 water delivery temperature - F
float Injector1TempFraction; // Find the fraction above the min temp of water delivery
Expand Down Expand Up @@ -5441,10 +5453,8 @@ private void UpdateFiring(float absSpeedMpS)
Injector1Fraction = 0.0f;
Injector2IsOn = false;
Injector2Fraction = 0.0f;
SignalEvent(Event.WaterInjector1Off);
SignalEvent(Event.WaterInjector2Off);
Injector1SoundIsOn = false;
Injector2SoundIsOn = false;
StopInjector1Sound();
StopInjector2Sound();
}
else if (WaterGlassLevelIN <= 7.0 && WaterGlassLevelIN > 6.875 && !InjectorLockedOut) // turn injector 1 on 20% if water level in boiler drops below 7.0
{
Expand Down Expand Up @@ -5690,6 +5700,31 @@ private void PlayInjector2SoundIfStarting()
}
}

/// <summary>
/// Turn off the injector 1 sound only when the injector stops.
/// </summary>
private void StopInjector1Sound()
{
if (Injector1SoundIsOn)
{
Injector1SoundIsOn = false;
SignalEvent(Event.WaterInjector1Off);
}
}

/// <summary>
/// Turn off the injector 2 sound only when the injector stops.
/// </summary>
private void StopInjector2Sound()
{
if (Injector2SoundIsOn)
{
Injector2SoundIsOn = false;
SignalEvent(Event.WaterInjector2Off);
}
}


protected override void UpdateCarSteamHeat(float elapsedClockSeconds)
{
// Update Steam Heating System
Expand Down

0 comments on commit 41c2b39

Please sign in to comment.