/
SteamEngine.cs
1010 lines (817 loc) · 35.4 KB
/
SteamEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// COPYRIGHT 2013, 2014 by the Open Rails project.
//
// This file is part of Open Rails.
//
// Open Rails is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Open Rails is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
using Orts.Parsers.Msts;
using Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions;
using Orts.Simulation.RollingStocks.SubSystems;
using Orts.Simulation.RollingStocks;
using ORTS.Scripting.Api;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using static Orts.Simulation.RollingStocks.TrainCar;
using ORTS.Common;
namespace Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies
{
public class SteamEngines : ISubSystem<SteamEngines>
{
/// <summary>
/// A list of auxiliaries
/// </summary>
public List<SteamEngine> SEList = new List<SteamEngine>();
/// <summary>
/// Number of Auxiliaries on the list
/// </summary>
public int Count { get { return SEList.Count; } }
/// <summary>
/// Reference to the locomotive carrying the auxiliaries
/// </summary>
protected readonly MSTSSteamLocomotive Locomotive;
/// <summary>
/// Creates a set of auxiliaries connected to the locomotive
/// </summary>
/// <param name="loco">Host locomotive</param>
public SteamEngines(MSTSSteamLocomotive loco)
{
Locomotive = loco;
}
public SteamEngine this[int i]
{
get { return SEList[i]; }
set { SEList[i] = value; }
}
public void Add()
{
SEList.Add(new SteamEngine(Locomotive));
}
public void Add(SteamEngine se)
{
SEList.Add(se);
}
/// <summary>
/// Parses all the parameters within the ENG file
/// </summary>
/// <param name="stf">reference to the ENG file reader</param>
public void Parse(string lowercasetoken, STFReader stf)
{
switch (lowercasetoken)
{
case "engine(ortssteamengines":
stf.MustMatch("(");
int count = stf.ReadInt(0);
for (int i = 0; i < count; i++)
{
string setting = stf.ReadString().ToLower();
if (setting == "steam")
{
SEList.Add(new SteamEngine(Locomotive));
SEList[i].Parse(stf);
SEList[i].Initialize();
// sets flag to indicate that a steam eng prime mover code block has been defined by user, otherwise OR will define one through the next code section using "MSTS" values
SEList[i].SteamEngineConfigured = true;
}
if ((!SEList[i].IsInitialized))
{
STFException.TraceWarning(stf, "Steam engine model has some errors - loading MSTS format");
SEList[i].InitFromMSTS();
SEList[i].Initialize();
}
}
break;
}
}
public void Copy(SteamEngines other)
{
SEList = new List<SteamEngine>();
foreach (SteamEngine se in other.SEList)
{
SteamEngine steamEngine = new SteamEngine(Locomotive);
steamEngine.Copy(se);
SEList.Add(steamEngine);
}
}
public void Initialize()
{
foreach (SteamEngine se in SEList)
{
se.Initialize();
}
}
public void InitializeMoving()
{
foreach (SteamEngine se in SEList)
{
se.InitializeMoving();
}
}
/// <summary>
/// Saves status of each auxiliary on the list
/// </summary>
/// <param name="outf"></param>
public void Save(BinaryWriter outf)
{
outf.Write(SEList.Count);
foreach (SteamEngine se in SEList)
{
se.Save(outf);
}
}
/// <summary>
/// Restores status of each auxiliary on the list
/// </summary>
/// <param name="inf"></param>
public void Restore(BinaryReader inf)
{
int count = inf.ReadInt32();
if (SEList.Count == 0)
{
for (int i = 0; i < count; i++)
{
SEList.Add(new SteamEngine(Locomotive));
SEList[i].InitFromMSTS();
SEList[i].Initialize();
}
}
foreach (SteamEngine se in SEList)
se.Restore(inf);
}
/// <summary>
/// Updates each auxiliary on the list
/// </summary>
/// <param name="elapsedClockSeconds">Time span within the simulation cycle</param>
public void Update(float elapsedClockSeconds)
{
foreach (SteamEngine de in SEList)
{
de.Update(elapsedClockSeconds);
}
}
public void HandleEvent(PowerSupplyEvent evt)
{
foreach (SteamEngine de in SEList)
{
de.HandleEvent(evt);
}
}
public void HandleEvent(PowerSupplyEvent evt, int id)
{
if (id >= 0 && id < SEList.Count)
{
SEList[id].HandleEvent(evt);
}
}
public List<SteamEngine>.Enumerator GetEnumerator()
{
return SEList.GetEnumerator();
}
public static string SetDebugLabels()
{
var labels = new StringBuilder();
var tabs = "\t";
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetString("Status"), tabs);
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), tabs);
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetString("Load"), tabs);
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetString("RPM"), tabs);
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetString("Flow"), tabs);
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetString("Temperature"), tabs);
labels.AppendFormat("{0}{1}", Simulator.Catalog.GetString("Oil Pressure"), tabs);
return labels.ToString();
}
public string GetStatus()
{
var result = new StringBuilder();
result.AppendFormat(Simulator.Catalog.GetString("Status"));
return result.ToString();
}
public string GetDPStatus()
{
var result = new StringBuilder();
var eng = SEList[0];
return result.ToString();
}
}
public class SteamEnum : IEnumerator
{
public SteamEngine[] seList;
// Enumerators are positioned before the first element
// until the first MoveNext() call.
int position = -1;
public SteamEnum(SteamEngine[] list)
{
seList = list;
}
public bool MoveNext()
{
position++;
return (position < seList.Length);
}
public void Reset()
{
position = -1;
}
object IEnumerator.Current
{
get
{
return Current;
}
}
public SteamEngine Current
{
get
{
try
{
return seList[position];
}
catch (IndexOutOfRangeException)
{
throw new InvalidOperationException();
}
}
}
}
public class SteamEngine : ISubSystem<SteamEngine>
{
/// <summary>
/// Number of Steam Cylinders
/// </summary>
public int NumberCylinders;
/// <summary>
/// Diameter of Steam Cylinders
/// </summary>
public float CylindersDiameterM;
/// <summary>
/// Steam Cylinders stroke
/// </summary>
public float CylindersStrokeM;
/// <summary>
/// Number of LP Steam Cylinders
/// </summary>
public int LPNumberCylinders;
/// <summary>
/// Diameter of LP Steam Cylinders
/// </summary>
public float LPCylindersDiameterM;
/// <summary>
/// LP Steam Cylinders stroke
/// </summary>
public float LPCylindersStrokeM;
public enum AuxiliarySteamEngineTypes
{
Unknown,
Booster,
}
public AuxiliarySteamEngineTypes AuxiliarySteamEngineType;
/// <summary>
/// Booster Cutoff - cutoff for booster cylinder
/// </summary>
public float BoosterCutoff;
/// <summary>
/// Booster Throttle cutoff position based upon the postion of the main engine reverser
/// </summary>
public float BoosterThrottleCutoff;
/// <summary>
/// Booster Gear Ratio
/// </summary>
public float BoosterGearRatio;
/// <summary>
/// Steam Engine real tractive force - this value may go above the average "calculated" TF value as the wheel rotates.
/// </summary>
public float RealTractiveForceN;
/// <summary>
/// Steam Engine average tractive force
/// </summary>
public float AverageTractiveForceN;
/// <summary>
/// Steam Engine display tractive force
/// </summary>
public float DisplayTractiveForceN;
/// <summary>
/// Steam Engine maximum indicated horsepower
/// </summary>
public float MaxIndicatedHorsePowerHP;
/// <summary>
/// Steam Engine unbalanced mass on wheels - per side.
/// </summary>
public float ExcessWheelBalanceLbs;
/// <summary>
/// Steam Engine unbalanced wheel warning.
/// </summary>
public bool IsWheelHammerForceWarning;
/// <summary>
/// Steam Engine unbalanced large overload.
/// </summary>
public bool IsWheelHammerForce;
/// <summary>
/// Steam Engine hammer force per wheel - excessive values of this could cause track deformities.
/// </summary>
public float HammerForceLbs;
/// <summary>
/// Steam Engine drive wheel rev per second
/// </summary>
public float DriveWheelRevRpS;
/// <summary>
/// HuD
/// </summary>
public float LogSteamChestPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogInitialPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogLPInitialPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogCutoffPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogLPCutoffPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogReleasePressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogLPReleasePressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogBackPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogLPBackPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogPreAdmissionPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float LogPreCompressionPressurePSI;
/// <summary>
/// HuD
/// </summary>
public float HPCylinderMEPPSI;
/// <summary>
/// HuD
/// </summary>
public float LPCylinderMEPPSI;
/// <summary>
/// Initial Pressure to HP cylinder @ start if stroke
/// </summary>
public float HPCompPressure_a_AtmPSI;
/// <summary>
/// Pressure at HP cylinder cutoff
/// </summary>
public float HPCompPressure_b_AtmPSI;
/// <summary>
/// Pressure in HP cylinder when steam completely released from the cylinder
/// </summary>
public float HPCompPressure_f_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float Pressure_e_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float Pressure_d_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float Pressure_f_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float LPCompPressure_g_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float LPCompPressure_h_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float LPCompPressure_l_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float LPCompPressure_m_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float LPCompPressure_n_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float LPCompPressure_q_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float Pressure_a_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float Pressure_b_AtmPSI;
/// <summary>
/// Cylinder Pressures
/// </summary>
public float Pressure_c_AtmPSI;
/// <summary>
/// Initial Pressure to LP cylinder @ start if stroke
/// </summary>
public float LPPressure_a_AtmPSI;
/// <summary>
/// Pressure in combined HP & LP Cylinder pre-cutoff
/// </summary>
public float LPPressure_b_AtmPSI;
/// <summary>
/// Pressure in LP cylinder when steam release valve opens
/// </summary>
public float LPPressure_c_AtmPSI;
/// <summary>
/// Back pressure on LP cylinder
/// </summary>
public float LPPressure_d_AtmPSI;
/// <summary>
/// Pressure in LP cylinder when exhaust valve closes, and compression commences
/// </summary>
public float LPPressure_e_AtmPSI;
/// <summary>
/// Pressure in LP cylinder after compression occurs and steam admission starts
/// </summary>
public float LPPressure_f_AtmPSI;
/// <summary>
/// Mean Effective Pressure
/// </summary>
public float MeanEffectivePressurePSI;
/// <summary>
/// Steam usage per steam engine
/// </summary>
public float CylinderSteamUsageLBpS;
/// <summary>
/// Steam usage per steam engine steam cocks
/// </summary>
public float CylCockSteamUsageLBpS;
/// <summary>
/// Cylinder steam cocks atmospheric pressure usage per steam engine steam cocks
/// </summary>
public float CylinderCocksPressureAtmPSI;
/// <summary>
/// Indicated HP Horse Power for Compound
/// </summary>
public float HPIndicatedHorsePowerHP;
/// <summary>
/// Indicated LP Horse Power for Compound
/// </summary>
public float LPIndicatedHorsePowerHP;
/// <summary>
/// Indicated Horse Power for single expansion
/// </summary>
public float IndicatedHorsePowerHP;
/// <summary>
/// Speed of Piston
/// </summary>
public float PistonSpeedFtpMin;
/// <summary>
/// Calculated Factor of Adhesion
/// </summary>
public float CalculatedFactorOfAdhesion;
/// <summary>
/// Maximum Tractice Effort
/// </summary>
public float MaxTractiveEffortLbf;
/// <summary>
/// Static wheel force for engine
/// </summary>
public float SteamStaticWheelForce;
public enum SettingsFlags
{
NumberCylindersF = 0x0001,
CylindersDiameterF = 0x0002,
CylinderStrokeF = 0x0003,
LPNumberCylindersF = 0x0004,
LPCylindersDiameterF = 0x0005,
LPCylinderStrokeF = 0x0006,
AttachedAxleIdF = 0x0007,
BoosterCutoffF = 0x0009,
BoosterThrottleCutoffF = 0x0009,
BoosterGearRatioF = 0x0010,
}
public int Id
{
get
{
return Locomotive.SteamEngines.SEList.IndexOf(this) + 1;
}
}
/// <summary>
/// Parent locomotive
/// </summary>
public readonly MSTSSteamLocomotive Locomotive;
protected Simulator Simulator => Locomotive.Simulator;
protected int AttachedAxleId;
public Axle AttachedAxle => Locomotive.LocomotiveAxles[AttachedAxleId];
SettingsFlags initLevel; //level of initialization
/// <summary>
/// Initialization flag - is true when sufficient number of parameters is read succesfully
/// </summary>
public bool IsInitialized
{
get
{
var initCheck = false;
if (AuxiliarySteamEngineType == AuxiliarySteamEngineTypes.Booster)
{
// Checks to see if a Booster engine has been correctly configured
if (initLevel == (SettingsFlags.NumberCylindersF | SettingsFlags.CylindersDiameterF | SettingsFlags.CylinderStrokeF | SettingsFlags.AttachedAxleIdF | SettingsFlags.BoosterCutoffF | SettingsFlags.BoosterGearRatioF | SettingsFlags.BoosterThrottleCutoffF))
{
initCheck = true;
}
}
else if (AuxiliarySteamEngineType != AuxiliarySteamEngineTypes.Booster)
{
// Checks to see if a non-booster engine has been correctly defined
if (initLevel == (SettingsFlags.NumberCylindersF | SettingsFlags.CylindersDiameterF | SettingsFlags.CylinderStrokeF | SettingsFlags.AttachedAxleIdF))
{
initCheck = true;
}
}
else
initCheck = false;
return initCheck;
}
}
public SteamEngine(MSTSSteamLocomotive locomotive)
{
Locomotive = locomotive;
}
public bool SteamEngineConfigured = false; // flag to indicate that the user has configured a steam engine prime mover code block in the ENG file
/// <summary>
/// Parses parameters from the stf reader
/// </summary>
/// <param name="stf">Reference to the stf reader</param>
/// <param name="loco">Reference to the locomotive</param>
public virtual void Parse(STFReader stf)
{
stf.MustMatch("(");
bool end = false;
while (!end)
{
string lowercasetoken = stf.ReadItem().ToLower();
switch (lowercasetoken)
{
case "numcylinders": NumberCylinders = stf.ReadIntBlock(null); initLevel |= SettingsFlags.NumberCylindersF; break;
case "cylinderstroke": CylindersStrokeM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); initLevel |= SettingsFlags.CylinderStrokeF; break;
case "cylinderdiameter": CylindersDiameterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); initLevel |= SettingsFlags.CylindersDiameterF; break;
case "lpnumcylinders": LPNumberCylinders = stf.ReadIntBlock(null); initLevel |= SettingsFlags.LPNumberCylindersF; break;
case "lpcylinderstroke": LPCylindersStrokeM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); initLevel |= SettingsFlags.LPCylinderStrokeF; break;
case "lpcylinderdiameter": LPCylindersDiameterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); initLevel |= SettingsFlags.LPCylindersDiameterF; break;
case "boostercutoff": BoosterCutoff = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterCutoffF; break;
case "boosterthrottlecutoff": BoosterThrottleCutoff = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterThrottleCutoffF; break;
case "boostergearratio": BoosterGearRatio = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterGearRatioF; break;
case "attachedaxle": AttachedAxleId = stf.ReadIntBlock(null); initLevel |= SettingsFlags.AttachedAxleIdF; break;
case "maxindicatedhorsepower":
MaxIndicatedHorsePowerHP = stf.ReadFloatBlock(STFReader.UNITS.Power, null);
MaxIndicatedHorsePowerHP = W.ToHp(MaxIndicatedHorsePowerHP); // Convert input to HP for use internally in this module
break;
case "excesswheelbalance":
var excess = stf.ReadFloatBlock(STFReader.UNITS.Mass, null);
ExcessWheelBalanceLbs = Kg.ToLb(excess); // Convert input to lbs for use internally in this module
break;
case "auxiliarysteamenginetype":
stf.MustMatch("(");
var auxiliarysteamengineType = stf.ReadString();
try
{
AuxiliarySteamEngineType = (AuxiliarySteamEngineTypes)Enum.Parse(typeof(AuxiliarySteamEngineTypes), auxiliarysteamengineType);
}
catch
{
STFException.TraceWarning(stf, "Assumed unknown engine type " + auxiliarysteamengineType);
}
break;
default:
end = true;
break;
}
}
}
public void Copy(SteamEngine other)
{
NumberCylinders = other.NumberCylinders;
CylindersStrokeM = other.CylindersStrokeM;
CylindersDiameterM = other.CylindersDiameterM;
LPNumberCylinders = other.LPNumberCylinders;
LPCylindersStrokeM = other.LPCylindersStrokeM;
LPCylindersDiameterM = other.LPCylindersDiameterM;
BoosterCutoff = other.BoosterCutoff;
MaxIndicatedHorsePowerHP = other.MaxIndicatedHorsePowerHP;
ExcessWheelBalanceLbs = other.ExcessWheelBalanceLbs;
BoosterThrottleCutoff = other.BoosterThrottleCutoff;
BoosterGearRatio = other.BoosterGearRatio;
AttachedAxleId = other.AttachedAxleId;
}
public void Initialize()
{
}
public void InitializeMoving()
{
}
public void Update(float elapsedClockSeconds)
{
}
public void HandleEvent(PowerSupplyEvent evt)
{
}
public void Restore(BinaryReader inf)
{
}
public void Save(BinaryWriter outf)
{
}
/// <summary>
/// Fix or define a steam engine code block. If the user has not defned a steam engine in the ENG file, then OR will use this section to create one.
/// If the user has left a parameter out of the code, then OR uses this section to try and set the missing values to a default value.
/// Error code has been provided that will provide the user with an indication if a parameter has been left out.
/// </summary>
public void InitFromMSTS()
{
if ((initLevel & SettingsFlags.NumberCylindersF) == 0)
{
if (SteamEngineConfigured && Locomotive.MSTSNumCylinders != 0) // Advanced conf - Steam Eng block defined but no NumCylinders present
{
NumberCylinders = Locomotive.MSTSNumCylinders;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Number of Cylinders: not found in Steam Engine Configuration (ADVANCED Config): set to default value = {0}", NumberCylinders);
}
else if (NumberCylinders == 0 && Locomotive.MSTSNumCylinders != 0) // Basic conf - No ENG block defined, use the default "MSTS" value
{
NumberCylinders = Locomotive.MSTSNumCylinders;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Number of Cylinders: set at MSTS default value (BASIC Config) = {0}", NumberCylinders);
}
else if (Locomotive.MSTSNumCylinders == 0) // No default "MSTS" value present, set to arbitary value
{
NumberCylinders = 2;
Locomotive.MSTSNumCylinders = NumberCylinders;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Number of Cylinders: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", NumberCylinders);
}
}
if ((initLevel & SettingsFlags.CylindersDiameterF) == 0)
{
if (SteamEngineConfigured && Locomotive.MSTSCylinderDiameterM != 0) // Advanced conf - Steam Eng block defined but no CylinderDiameter present
{
CylindersDiameterM = Locomotive.MSTSCylinderDiameterM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Cylinder Diameter: not found in Steam Engine Configuration (ADVANCED Config): set to default value = {0}", CylindersDiameterM);
}
else if (CylindersDiameterM == 0 && Locomotive.MSTSCylinderDiameterM != 0) // Basic conf - No steam ENG block defined, use the default "MSTS" value
{
CylindersDiameterM = Locomotive.MSTSCylinderDiameterM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Cylinder Diameter: set at MSTS default value (BASIC Config) = {0}", CylindersDiameterM);
}
else if (Locomotive.MSTSCylinderDiameterM == 0) // No default "MSTS" value present, set to arbitary value
{
CylindersDiameterM = 1;
Locomotive.MSTSCylinderDiameterM = CylindersDiameterM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Cylinder Diameter: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", CylindersDiameterM);
}
}
if ((initLevel & SettingsFlags.CylinderStrokeF) == 0)
{
if (SteamEngineConfigured && Locomotive.MSTSCylinderStrokeM != 0) // Advanced conf - Steam Eng block defined but no CylinderStroke present
{
CylindersStrokeM = Locomotive.MSTSCylinderStrokeM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Cylinder Stroke: not found in Steam Engine Configuration (ADVANCED Config): set to default value = {0}", CylindersStrokeM);
}
else if (CylindersStrokeM == 0 && Locomotive.MSTSCylinderStrokeM != 0) // Basic conf - No steam ENG block defined, use the default "MSTS" value
{
CylindersStrokeM = Locomotive.MSTSCylinderStrokeM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Cylinder Stroke: set at MSTS default value (BASIC Config) = {0}", CylindersStrokeM);
}
else if (Locomotive.MSTSCylinderStrokeM == 0) // No default "MSTS" value present, set to arbitary value
{
CylindersStrokeM = 1;
Locomotive.MSTSCylinderStrokeM = CylindersStrokeM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Cylinder Stroke: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", CylindersStrokeM);
}
}
if ((initLevel & SettingsFlags.LPNumberCylindersF) == 0)
{
if (SteamEngineConfigured && Locomotive.MSTSLPNumCylinders != 0) // Advanced conf - Steam Eng block defined but no NumCylinders present
{
LPNumberCylinders = Locomotive.MSTSLPNumCylinders;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Number of LP Cylinders: not found in Steam Engine Configuration (ADVANCED Config): set to default value = {0}", LPNumberCylinders);
}
else if (LPNumberCylinders == 0 && Locomotive.MSTSLPNumCylinders != 0) // Basic conf - No ENG block defined, use the default "MSTS" value
{
LPNumberCylinders = Locomotive.MSTSLPNumCylinders;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Number of LP Cylinders: set at MSTS default value (BASIC Config) = {0}", LPNumberCylinders);
}
else if (Locomotive.MSTSLPNumCylinders == 0) // No default "MSTS" value present, set to arbitary value
{
LPNumberCylinders = 2;
Locomotive.MSTSLPNumCylinders = LPNumberCylinders;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Number of LP Cylinders: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", LPNumberCylinders);
}
}
if ((initLevel & SettingsFlags.LPCylindersDiameterF) == 0)
{
if (SteamEngineConfigured && Locomotive.MSTSLPCylinderDiameterM != 0) // Advanced conf - Steam Eng block defined but no CylinderDiameter present
{
LPCylindersDiameterM = Locomotive.MSTSLPCylinderDiameterM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("LP Cylinder Diameter: not found in Steam Engine Configuration (ADVANCED Config): set to default value = {0}", LPCylindersDiameterM);
}
else if (LPCylindersDiameterM == 0 && Locomotive.MSTSLPCylinderDiameterM != 0) // Basic conf - No steam ENG block defined, use the default "MSTS" value
{
LPCylindersDiameterM = Locomotive.MSTSLPCylinderDiameterM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("LP Cylinder Diameter: set at MSTS default value (BASIC Config) = {0}", LPCylindersDiameterM);
}
else if (Locomotive.MSTSLPCylinderDiameterM == 0) // No default "MSTS" value present, set to arbitary value
{
LPCylindersDiameterM = 1;
Locomotive.MSTSLPCylinderDiameterM = LPCylindersDiameterM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("LP Cylinder Diameter: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", LPCylindersDiameterM);
}
}
if ((initLevel & SettingsFlags.LPCylinderStrokeF) == 0)
{
if (SteamEngineConfigured && Locomotive.MSTSLPCylinderStrokeM != 0) // Advanced conf - Steam Eng block defined but no CylinderStroke present
{
LPCylindersStrokeM = Locomotive.MSTSLPCylinderStrokeM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("LP Cylinder Stroke: not found in Steam Engine Configuration (ADVANCED Config): set to default value = {0}", LPCylindersStrokeM);
}
else if (LPCylindersStrokeM == 0 && Locomotive.MSTSLPCylinderStrokeM != 0) // Basic conf - No steam ENG block defined, use the default "MSTS" value
{
LPCylindersStrokeM = Locomotive.MSTSLPCylinderStrokeM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("LP Cylinder Stroke: set at MSTS default value (BASIC Config) = {0}", LPCylindersStrokeM);
}
else if (Locomotive.MSTSLPNumCylinders == 0) // No default "MSTS" value present, set to arbitary value
{
LPCylindersStrokeM = 1;
Locomotive.MSTSCylinderStrokeM = LPCylindersStrokeM;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("LP Cylinder Stroke: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", LPCylindersStrokeM);
}
}
if ((initLevel & SettingsFlags.BoosterCutoffF) == 0)
{
BoosterCutoff = 0.3f;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Booster Cutoff: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", BoosterCutoff);
}
if ((initLevel & SettingsFlags.BoosterThrottleCutoffF) == 0)
{
BoosterThrottleCutoff = 0.3f;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Booster Throttle Cutoff: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", BoosterCutoff);
}
if ((initLevel & SettingsFlags.BoosterGearRatioF) == 0)
{
BoosterGearRatio = 1.0f;
if (Locomotive.Simulator.Settings.VerboseConfigurationMessages)
Trace.TraceInformation("Booster Gear Ratio: not found in Steam Engine Configuration (BASIC Config): set at arbitary value = {0}", BoosterGearRatio);
}