27
27
// #define DEBUG_EXTRAINFO
28
28
// #define DEBUG_TRACEINFO
29
29
// #define DEBUG_TTANALYSIS
30
+ // #define DEBUG_DELAYS
30
31
// DEBUG flag for debug prints
31
32
32
33
using System;
@@ -70,6 +71,8 @@ public class TTTrain : AITrain
70
71
// required direction on leaving pool (if applicable)
71
72
public string ForcedConsistName = String.Empty; // forced consist name for extraction from pool
72
73
74
+ public string ttanalysisreport = String.Empty; // string holding last analysis report, to avoid continouos output of same string
75
+
73
76
// Timetable Commands info
74
77
public List<WaitInfo> WaitList = null; //used when in timetable mode for wait instructions
75
78
public Dictionary<int, List<WaitInfo>> WaitAnyList = null; //used when in timetable mode for waitany instructions
@@ -4112,6 +4115,11 @@ public override void UpdateStationState(float elapsedClockSeconds, int presentTi
4112
4115
}
4113
4116
#endif
4114
4117
4118
+ #if DEBUG_DELAYS
4119
+ if (Delay.HasValue && Delay.Value.TotalMinutes > 5)
4120
+ Trace.TraceInformation("{0} at {1} : + {2}", Name, thisStation.PlatformItem.Name, Delay.Value.ToString());
4121
+ #endif
4122
+
4115
4123
if (CheckTrain)
4116
4124
{
4117
4125
DateTime baseDTdCT = new DateTime();
@@ -8230,6 +8238,13 @@ public void FinalizeTimetableCommands()
8230
8238
#if DEBUG_TRACEINFO
8231
8239
Trace.TraceInformation("Train : " + Name);
8232
8240
Trace.TraceInformation("WAIT : Search for : {0} - found {1}", reqWait.referencedTrainName, otherTrain == null ? -1 : otherTrain.Number);
8241
+ #endif
8242
+ #if DEBUG_DELAYS
8243
+ if (otherTrain == null)
8244
+ {
8245
+ Trace.TraceInformation("Train : " + Name);
8246
+ Trace.TraceInformation("WAIT : Search for : {0} - not found", reqWait.referencedTrainName);
8247
+ }
8233
8248
#endif
8234
8249
if (otherTrain != null)
8235
8250
{
@@ -8244,6 +8259,13 @@ public void FinalizeTimetableCommands()
8244
8259
#if DEBUG_TRACEINFO
8245
8260
Trace.TraceInformation("Train : " + Name);
8246
8261
Trace.TraceInformation("FOLLOW : Search for : {0} - found {1}", reqWait.referencedTrainName, otherTrain == null ? -1 : otherTrain.Number);
8262
+ #endif
8263
+ #if DEBUG_DELAYS
8264
+ if (otherTrain == null)
8265
+ {
8266
+ Trace.TraceInformation("Train : " + Name);
8267
+ Trace.TraceInformation("FOLLOW : Search for : {0} - not found", reqWait.referencedTrainName);
8268
+ }
8247
8269
#endif
8248
8270
if (otherTrain != null)
8249
8271
{
@@ -8259,6 +8281,14 @@ public void FinalizeTimetableCommands()
8259
8281
Trace.TraceInformation("Train : " + Name);
8260
8282
Trace.TraceInformation("CONNECT : Search for : {0} - found {1}", reqWait.referencedTrainName, otherTrain == null ? -1 : otherTrain.Number);
8261
8283
#endif
8284
+ #if DEBUG_DELAYS
8285
+ if (otherTrain == null)
8286
+ {
8287
+ Trace.TraceInformation("Train : " + Name);
8288
+ Trace.TraceInformation("CONNECT : Search for : {0} - not found", reqWait.referencedTrainName);
8289
+ }
8290
+ #endif
8291
+
8262
8292
if (otherTrain != null)
8263
8293
{
8264
8294
ProcessConnectRequest(reqWait, otherTrain, ref newWaitItems);
@@ -9671,6 +9701,7 @@ public bool CheckEndOfRoutePositionTT()
9671
9701
MovementState = AI_MOVEMENT_STATE.TURNTABLE;
9672
9702
if (CheckTrain)
9673
9703
{
9704
+ File.AppendAllText(@"C:\temp\checktrain.txt", "TURNTABLE : Pool : " + thisTurntablePool.PoolName + " : Table state set to " + ActiveTurntable.MovingTableState.ToString() + "\n");
9674
9705
File.AppendAllText(@"C:\temp\checktrain.txt", "Moving table access ; Movement State : " + MovementState + "\n");
9675
9706
}
9676
9707
return (endOfRoute);
@@ -11573,6 +11604,11 @@ public int GetUnitsToDetach(DetachInfo.DetachUnitsInfo detachUnits, int numberOf
11573
11604
11574
11605
default:
11575
11606
iunits = numberOfUnits;
11607
+ if (iunits > Cars.Count - 1)
11608
+ {
11609
+ Trace.TraceInformation("Train {0} : no. of units to detach ({1}) : value too large, only {2} units on train\n", Name, iunits, Cars.Count);
11610
+ iunits = Cars.Count - 1;
11611
+ }
11576
11612
frontpos = detachUnits == DetachInfo.DetachUnitsInfo.unitsAtFront;
11577
11613
break;
11578
11614
}
@@ -12727,12 +12763,13 @@ public void TTAnalysisUpdateStationState1(int presentTime, StationStop thisStati
12727
12763
{
12728
12764
12729
12765
DateTime baseDTA = new DateTime();
12766
+ DateTime presentDTA = baseDTA.AddSeconds(AI.clockTime);
12730
12767
DateTime arrTimeA = baseDTA.AddSeconds(presentTime);
12731
12768
DateTime depTimeA = baseDTA.AddSeconds(thisStation.ActualDepart);
12732
12769
12733
12770
var sob = new StringBuilder();
12734
12771
sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}",
12735
- Number, AI.clockTime , Name, Delay, thisStation.PlatformItem.Name, thisStation.arrivalDT.ToString("HH:mm:ss"), thisStation.departureDT.ToString("HH:mm:ss"),
12772
+ Number, presentDTA.ToString("HH:mm:ss") , Name, Delay, thisStation.PlatformItem.Name, thisStation.arrivalDT.ToString("HH:mm:ss"), thisStation.departureDT.ToString("HH:mm:ss"),
12736
12773
arrTimeA.ToString("HH:mm:ss"), depTimeA.ToString("HH:mm:ss"), "", "", "", "");
12737
12774
File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12738
12775
}
@@ -12789,9 +12826,16 @@ public void TTAnalysisUpdateStationState2()
12789
12826
DateTime baseDT = new DateTime();
12790
12827
DateTime stopTime = baseDT.AddSeconds(AI.clockTime);
12791
12828
12792
- var sob = new StringBuilder();
12793
- sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}", Number, AI.clockTime, Name, Delay, "", "", "", "", "", "", stopTime.ToString("HH:mm:ss"), signalstring.ToString(), waitforstring.ToString());
12794
- File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12829
+ // output string only if different from last output
12830
+
12831
+ if (waitforstring.ToString() != ttanalysisreport)
12832
+ {
12833
+ ttanalysisreport = waitforstring.ToString();
12834
+
12835
+ var sob = new StringBuilder();
12836
+ sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}", Number, stopTime.ToString("HH:mm:ss"), Name, Delay, "", "", "", "", "", "", stopTime.ToString("HH:mm:ss"), signalstring.ToString(), waitforstring.ToString());
12837
+ File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12838
+ }
12795
12839
}
12796
12840
12797
12841
public void TTAnalysisUpdateBrakingState1()
@@ -12848,9 +12892,14 @@ public void TTAnalysisUpdateBrakingState1()
12848
12892
DateTime baseDT = new DateTime();
12849
12893
DateTime stopTime = baseDT.AddSeconds(AI.clockTime);
12850
12894
12851
- var sob = new StringBuilder();
12852
- sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}", Number, AI.clockTime, Name, Delay, "", "", "", "", "", "", stopTime.ToString("HH:mm:ss"), signalstring.ToString(), waitforstring.ToString());
12853
- File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12895
+ if (waitforstring.ToString() != ttanalysisreport)
12896
+ {
12897
+ ttanalysisreport = waitforstring.ToString();
12898
+
12899
+ var sob = new StringBuilder();
12900
+ sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}", Number, stopTime.ToString("HH:mm:ss"), Name, Delay, "", "", "", "", "", "", stopTime.ToString("HH:mm:ss"), signalstring.ToString(), waitforstring.ToString());
12901
+ File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12902
+ }
12854
12903
}
12855
12904
}
12856
12905
@@ -12914,9 +12963,14 @@ public void TTAnalysisUpdateBrakingState2()
12914
12963
DateTime baseDT = new DateTime();
12915
12964
DateTime stopTime = baseDT.AddSeconds(AI.clockTime);
12916
12965
12917
- var sob = new StringBuilder();
12918
- sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}", Number, AI.clockTime, Name, Delay, "", "", "", "", "", "", stopTime.ToString("HH:mm:ss"), signalstring.ToString(), waitforstring.ToString());
12919
- File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12966
+ if (waitforstring.ToString() != ttanalysisreport)
12967
+ {
12968
+ ttanalysisreport = waitforstring.ToString();
12969
+
12970
+ var sob = new StringBuilder();
12971
+ sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}", Number, stopTime.ToString("HH:mm:ss"), Name, Delay, "", "", "", "", "", "", stopTime.ToString("HH:mm:ss"), signalstring.ToString(), waitforstring.ToString());
12972
+ File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12973
+ }
12920
12974
}
12921
12975
12922
12976
public void TTAnalysisStartMoving(String info)
@@ -12926,8 +12980,9 @@ public void TTAnalysisStartMoving(String info)
12926
12980
12927
12981
var sob = new StringBuilder();
12928
12982
sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}",
12929
- Number, AI.clockTime , Name, Delay, "", "", "", "", "", moveTimeA.ToString("HH:mm:ss"), "", "", info);
12983
+ Number, moveTimeA.ToString("HH:mm:ss") , Name, Delay, "", "", "", "", "", moveTimeA.ToString("HH:mm:ss"), "", "", info);
12930
12984
File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12985
+ ttanalysisreport = String.Empty;
12931
12986
}
12932
12987
}
12933
12988
@@ -13378,6 +13433,13 @@ public DetachInfo(TTTrain thisTrain, TTTrainCommands commandInfo, bool atActivat
13378
13433
bool portionDefined = false;
13379
13434
bool formedTrainDefined = false;
13380
13435
13436
+ if (commandInfo.CommandQualifiers == null || commandInfo.CommandQualifiers.Count < 1)
13437
+ {
13438
+ Trace.TraceInformation("Train {0} : missing detach command qualifiers", thisTrain.Name);
13439
+ Valid = false;
13440
+ return;
13441
+ }
13442
+
13381
13443
foreach (TTTrainCommands.TTTrainComQualifiers Qualifier in commandInfo.CommandQualifiers)
13382
13444
{
13383
13445
switch (Qualifier.QualifierName.Trim().ToLower())
0 commit comments