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
@@ -1239,7 +1242,7 @@ public bool PostInit(bool activateTrain)
1239
1242
1240
1243
File.AppendAllText(@"C:\temp\checktrain.txt", "--------\n");
1241
1244
File.AppendAllText(@"C:\temp\checktrain.txt", "PostInit at " + actTime.ToString("HH:mm:ss") + "\n");
1242
- File.AppendAllText(@"C:\temp\checktrain.txt", "Train : " + Number.ToString() + "\n");
1245
+ File.AppendAllText(@"C:\temp\checktrain.txt", "Train : " + Number.ToString() + " ( AI : " + OrgAINumber.ToString() + " ) \n");
1243
1246
File.AppendAllText(@"C:\temp\checktrain.txt", "Name : " + Name + "\n");
1244
1247
File.AppendAllText(@"C:\temp\checktrain.txt", "Frght : " + IsFreight.ToString() + "\n");
1245
1248
File.AppendAllText(@"C:\temp\checktrain.txt", "Length: " + Length.ToString() + "\n");
@@ -4037,6 +4040,11 @@ public override void UpdateStationState(float elapsedClockSeconds, int presentTi
4037
4040
}
4038
4041
#endif
4039
4042
4043
+ #if DEBUG_DELAYS
4044
+ if (Delay.HasValue && Delay.Value.TotalMinutes > 5)
4045
+ Trace.TraceInformation("{0} at {1} : + {2}", Name, thisStation.PlatformItem.Name, Delay.Value.ToString());
4046
+ #endif
4047
+
4040
4048
if (CheckTrain)
4041
4049
{
4042
4050
DateTime baseDTdCT = new DateTime();
@@ -8156,6 +8164,13 @@ public void FinalizeTimetableCommands()
8156
8164
#if DEBUG_TRACEINFO
8157
8165
Trace.TraceInformation("Train : " + Name);
8158
8166
Trace.TraceInformation("WAIT : Search for : {0} - found {1}", reqWait.referencedTrainName, otherTrain == null ? -1 : otherTrain.Number);
8167
+ #endif
8168
+ #if DEBUG_DELAYS
8169
+ if (otherTrain == null)
8170
+ {
8171
+ Trace.TraceInformation("Train : " + Name);
8172
+ Trace.TraceInformation("WAIT : Search for : {0} - not found", reqWait.referencedTrainName);
8173
+ }
8159
8174
#endif
8160
8175
if (otherTrain != null)
8161
8176
{
@@ -8170,6 +8185,13 @@ public void FinalizeTimetableCommands()
8170
8185
#if DEBUG_TRACEINFO
8171
8186
Trace.TraceInformation("Train : " + Name);
8172
8187
Trace.TraceInformation("FOLLOW : Search for : {0} - found {1}", reqWait.referencedTrainName, otherTrain == null ? -1 : otherTrain.Number);
8188
+ #endif
8189
+ #if DEBUG_DELAYS
8190
+ if (otherTrain == null)
8191
+ {
8192
+ Trace.TraceInformation("Train : " + Name);
8193
+ Trace.TraceInformation("FOLLOW : Search for : {0} - not found", reqWait.referencedTrainName);
8194
+ }
8173
8195
#endif
8174
8196
if (otherTrain != null)
8175
8197
{
@@ -8185,6 +8207,14 @@ public void FinalizeTimetableCommands()
8185
8207
Trace.TraceInformation("Train : " + Name);
8186
8208
Trace.TraceInformation("CONNECT : Search for : {0} - found {1}", reqWait.referencedTrainName, otherTrain == null ? -1 : otherTrain.Number);
8187
8209
#endif
8210
+ #if DEBUG_DELAYS
8211
+ if (otherTrain == null)
8212
+ {
8213
+ Trace.TraceInformation("Train : " + Name);
8214
+ Trace.TraceInformation("CONNECT : Search for : {0} - not found", reqWait.referencedTrainName);
8215
+ }
8216
+ #endif
8217
+
8188
8218
if (otherTrain != null)
8189
8219
{
8190
8220
ProcessConnectRequest(reqWait, otherTrain, ref newWaitItems);
@@ -9593,6 +9623,7 @@ public bool CheckEndOfRoutePositionTT()
9593
9623
MovementState = AI_MOVEMENT_STATE.TURNTABLE;
9594
9624
if (CheckTrain)
9595
9625
{
9626
+ File.AppendAllText(@"C:\temp\checktrain.txt", "TURNTABLE : Pool : " + thisTurntablePool.PoolName + " : Table state set to " + ActiveTurntable.MovingTableState.ToString() + "\n");
9596
9627
File.AppendAllText(@"C:\temp\checktrain.txt", "Moving table access ; Movement State : " + MovementState + "\n");
9597
9628
}
9598
9629
return (endOfRoute);
@@ -11508,6 +11539,11 @@ public int GetUnitsToDetach(DetachInfo.DetachUnitsInfo detachUnits, int numberOf
11508
11539
11509
11540
default:
11510
11541
iunits = numberOfUnits;
11542
+ if (iunits > Cars.Count - 1)
11543
+ {
11544
+ Trace.TraceInformation("Train {0} : no. of units to detach ({1}) : value too large, only {2} units on train\n", Name, iunits, Cars.Count);
11545
+ iunits = Cars.Count - 1;
11546
+ }
11511
11547
frontpos = detachUnits == DetachInfo.DetachUnitsInfo.unitsAtFront;
11512
11548
break;
11513
11549
}
@@ -12659,12 +12695,13 @@ public void TTAnalysisUpdateStationState1(int presentTime, StationStop thisStati
12659
12695
{
12660
12696
12661
12697
DateTime baseDTA = new DateTime();
12698
+ DateTime presentDTA = baseDTA.AddSeconds(AI.clockTime);
12662
12699
DateTime arrTimeA = baseDTA.AddSeconds(presentTime);
12663
12700
DateTime depTimeA = baseDTA.AddSeconds(thisStation.ActualDepart);
12664
12701
12665
12702
var sob = new StringBuilder();
12666
12703
sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}",
12667
- Number, AI.clockTime , Name, Delay, thisStation.PlatformItem.Name, thisStation.arrivalDT.ToString("HH:mm:ss"), thisStation.departureDT.ToString("HH:mm:ss"),
12704
+ Number, presentDTA.ToString("HH:mm:ss") , Name, Delay, thisStation.PlatformItem.Name, thisStation.arrivalDT.ToString("HH:mm:ss"), thisStation.departureDT.ToString("HH:mm:ss"),
12668
12705
arrTimeA.ToString("HH:mm:ss"), depTimeA.ToString("HH:mm:ss"), "", "", "", "");
12669
12706
File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12670
12707
}
@@ -12721,9 +12758,16 @@ public void TTAnalysisUpdateStationState2()
12721
12758
DateTime baseDT = new DateTime();
12722
12759
DateTime stopTime = baseDT.AddSeconds(AI.clockTime);
12723
12760
12724
- var sob = new StringBuilder();
12725
- 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());
12726
- File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12761
+ // output string only if different from last output
12762
+
12763
+ if (waitforstring.ToString() != ttanalysisreport)
12764
+ {
12765
+ ttanalysisreport = waitforstring.ToString();
12766
+
12767
+ var sob = new StringBuilder();
12768
+ 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());
12769
+ File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12770
+ }
12727
12771
}
12728
12772
12729
12773
public void TTAnalysisUpdateBrakingState1()
@@ -12780,9 +12824,14 @@ public void TTAnalysisUpdateBrakingState1()
12780
12824
DateTime baseDT = new DateTime();
12781
12825
DateTime stopTime = baseDT.AddSeconds(AI.clockTime);
12782
12826
12783
- var sob = new StringBuilder();
12784
- 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());
12785
- File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12827
+ if (waitforstring.ToString() != ttanalysisreport)
12828
+ {
12829
+ ttanalysisreport = waitforstring.ToString();
12830
+
12831
+ var sob = new StringBuilder();
12832
+ 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());
12833
+ File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12834
+ }
12786
12835
}
12787
12836
}
12788
12837
@@ -12846,9 +12895,14 @@ public void TTAnalysisUpdateBrakingState2()
12846
12895
DateTime baseDT = new DateTime();
12847
12896
DateTime stopTime = baseDT.AddSeconds(AI.clockTime);
12848
12897
12849
- var sob = new StringBuilder();
12850
- 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());
12851
- File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12898
+ if (waitforstring.ToString() != ttanalysisreport)
12899
+ {
12900
+ ttanalysisreport = waitforstring.ToString();
12901
+
12902
+ var sob = new StringBuilder();
12903
+ 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());
12904
+ File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12905
+ }
12852
12906
}
12853
12907
12854
12908
public void TTAnalysisStartMoving(String info)
@@ -12858,8 +12912,9 @@ public void TTAnalysisStartMoving(String info)
12858
12912
12859
12913
var sob = new StringBuilder();
12860
12914
sob.AppendFormat("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}",
12861
- Number, AI.clockTime , Name, Delay, "", "", "", "", "", moveTimeA.ToString("HH:mm:ss"), "", "", info);
12915
+ Number, moveTimeA.ToString("HH:mm:ss") , Name, Delay, "", "", "", "", "", moveTimeA.ToString("HH:mm:ss"), "", "", info);
12862
12916
File.AppendAllText(@"C:\temp\TTAnalysis.csv", sob.ToString() + "\n");
12917
+ ttanalysisreport = String.Empty;
12863
12918
}
12864
12919
}
12865
12920
@@ -13310,6 +13365,13 @@ public DetachInfo(TTTrain thisTrain, TTTrainCommands commandInfo, bool atActivat
13310
13365
bool portionDefined = false;
13311
13366
bool formedTrainDefined = false;
13312
13367
13368
+ if (commandInfo.CommandQualifiers == null || commandInfo.CommandQualifiers.Count < 1)
13369
+ {
13370
+ Trace.TraceInformation("Train {0} : missing detach command qualifiers", thisTrain.Name);
13371
+ Valid = false;
13372
+ return;
13373
+ }
13374
+
13313
13375
foreach (TTTrainCommands.TTTrainComQualifiers Qualifier in commandInfo.CommandQualifiers)
13314
13376
{
13315
13377
switch (Qualifier.QualifierName.Trim().ToLower())
0 commit comments