1
- // COPYRIGHT 2014 by the Open Rails project.
1
+ // COPYRIGHT 2014 by the Open Rails project.
2
2
//
3
3
// This file is part of Open Rails.
4
4
//
17
17
18
18
// This code processes the Timetable definition and converts it into playable train information
19
19
//
20
- // #DEBUG_POOLINFO
20
+ // #define DEBUG_POOLINFO
21
21
//
22
22
23
23
using System ;
@@ -940,8 +940,17 @@ public int GetPoolExitIndex(TTTrain train)
940
940
941
941
#if DEBUG_POOLINFO
942
942
var sob = new StringBuilder ( ) ;
943
- sob . AppendFormat ( "Pool {0} : error : train {1} ({2}) allready stored in pool \n " , PoolName , train . Number , train . Name ) ;
944
- sob . AppendFormat ( " stored units : {0}" , thisStorage . StoredUnits . Count ) ;
943
+ DateTime baseDT = new DateTime ( ) ;
944
+ DateTime actTime = baseDT . AddSeconds ( train . AI . clockTime ) ;
945
+
946
+ sob . AppendFormat ( "{0} : Pool {1} : error : train {2} ({3}) allready stored in pool \n " , actTime . ToString ( "HH:mm:ss" ) , PoolName , train . Number , train . Name ) ;
947
+
948
+ int totalno = 0 ;
949
+ foreach ( PoolDetails selStorage in StoragePool )
950
+ {
951
+ totalno += selStorage . StoredUnits . Count ;
952
+ }
953
+ sob . AppendFormat ( " stored units {0} : {1} (total {2})" , PoolName , thisStorage . StoredUnits . Count , totalno ) ;
945
954
File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
946
955
#endif
947
956
}
@@ -1023,8 +1032,18 @@ public void AddUnit(TTTrain train, bool claimOnly)
1023
1032
1024
1033
#if DEBUG_POOLINFO
1025
1034
var sob = new StringBuilder ( ) ;
1026
- sob . AppendFormat ( "Pool {0} : train {1} ({2}) added\n " , PoolName , train . Number , train . Name ) ;
1027
- sob . AppendFormat ( " stored units : {0}\n " , thisPool . StoredUnits . Count ) ;
1035
+ DateTime baseDT = new DateTime ( ) ;
1036
+ DateTime actTime = baseDT . AddSeconds ( train . AI . clockTime ) ;
1037
+
1038
+ sob . AppendFormat ( "{0} : Pool {1} : train {2} ({3}) added\n " , actTime . ToString ( "HH:mm:ss" ) , PoolName , train . Number , train . Name ) ;
1039
+
1040
+ int totalno = 0 ;
1041
+ foreach ( PoolDetails selStorage in StoragePool )
1042
+ {
1043
+ totalno += selStorage . StoredUnits . Count ;
1044
+ }
1045
+
1046
+ sob . AppendFormat ( " stored units {0} : {1} (total {2})" , PoolName , thisPool . StoredUnits . Count , totalno ) ;
1028
1047
File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
1029
1048
#endif
1030
1049
@@ -1124,7 +1143,10 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
1124
1143
{
1125
1144
#if DEBUG_POOLINFO
1126
1145
var sob = new StringBuilder ( ) ;
1127
- sob . AppendFormat ( "Pool {0} : request for train {1} ({2})" , PoolName , train . Number , train . Name ) ;
1146
+ DateTime baseDT = new DateTime ( ) ;
1147
+ DateTime actTime = baseDT . AddSeconds ( train . AI . clockTime ) ;
1148
+
1149
+ sob . AppendFormat ( "{0} : Pool {1} : request for train {2} ({3})" , actTime . ToString ( "HH:mm:ss" ) , PoolName , train . Number , train . Name ) ;
1128
1150
File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
1129
1151
#endif
1130
1152
// check if any engines available
@@ -1155,6 +1177,9 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
1155
1177
{
1156
1178
#if DEBUG_TRACEINFO
1157
1179
Trace . TraceInformation ( "Pool {0} : train {1} : delayed through claimed access\n " , PoolName , train . Name ) ;
1180
+ #endif
1181
+ #if DEBUG_POOLINFO
1182
+ Trace . TraceInformation ( "Pool {0} : train {1} : delayed through claimed access\n " , PoolName , train . Name ) ;
1158
1183
#endif
1159
1184
return ( TrainFromPool . Delayed ) ;
1160
1185
}
@@ -1259,7 +1284,13 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
1259
1284
#if DEBUG_POOLINFO
1260
1285
sob = new StringBuilder ( ) ;
1261
1286
sob . AppendFormat ( "Pool {0} : train {1} ({2}) waiting for incoming train {3} ({4})\n " , PoolName , train . Number , train . Name , otherTTTrain . Number , otherTTTrain . Name ) ;
1262
- sob . AppendFormat ( " stored units : {0}" , reqStorage . StoredUnits . Count ) ;
1287
+
1288
+ int totalno1 = 0 ;
1289
+ foreach ( PoolDetails selStorage in StoragePool )
1290
+ {
1291
+ totalno1 += selStorage . StoredUnits . Count ;
1292
+ }
1293
+ sob . AppendFormat ( " stored units {0} : {1} (total {2})" , PoolName , reqStorage . StoredUnits . Count , totalno1 ) ;
1263
1294
File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
1264
1295
#endif
1265
1296
break ;
@@ -1284,8 +1315,15 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
1284
1315
{
1285
1316
#if DEBUG_POOLINFO
1286
1317
sob = new StringBuilder ( ) ;
1287
- sob . AppendFormat ( "Pool {0} : cannot find train {1} for {2} ({3}) \n " , PoolName , selectedTrainNumber , train . Number , train . Name ) ;
1288
- sob . AppendFormat ( " stored units : {0}" , reqStorage . StoredUnits . Count ) ;
1318
+
1319
+ sob . AppendFormat ( "Pool {1} : cannot find train {2} for {3} ({4}) \n " , PoolName , selectedTrainNumber , train . Number , train . Name ) ;
1320
+
1321
+ int totalno2 = 0 ;
1322
+ foreach ( PoolDetails selStorage in StoragePool )
1323
+ {
1324
+ totalno2 += selStorage . StoredUnits . Count ;
1325
+ }
1326
+ sob . AppendFormat ( " stored units {0} : {1} (total {2})" , PoolName , reqStorage . StoredUnits . Count , totalno2 ) ;
1289
1327
File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
1290
1328
#endif
1291
1329
return ( TrainFromPool . Delayed ) ;
@@ -1301,8 +1339,15 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
1301
1339
1302
1340
#if DEBUG_POOLINFO
1303
1341
sob = new StringBuilder ( ) ;
1342
+
1304
1343
sob . AppendFormat ( "Pool {0} : train {1} ({2}) extracted as {3} ({4}) \n " , PoolName , selectedTrain . Number , selectedTrain . Name , train . Number , train . Name ) ;
1305
- sob . AppendFormat ( " stored units : {0}" , reqStorage . StoredUnits . Count ) ;
1344
+
1345
+ int totalno = 0 ;
1346
+ foreach ( PoolDetails selStorage in StoragePool )
1347
+ {
1348
+ totalno += selStorage . StoredUnits . Count ;
1349
+ }
1350
+ sob . AppendFormat ( " stored units {0} : {1} (total {2})" , PoolName , reqStorage . StoredUnits . Count , totalno ) ;
1306
1351
File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
1307
1352
#endif
1308
1353
@@ -1444,6 +1489,9 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
1444
1489
{
1445
1490
#if DEBUG_TRACEINFO
1446
1491
Trace . TraceWarning ( "Failed to extract required train " + train . Name + " from pool " + PoolName + "\n " ) ;
1492
+ #endif
1493
+ #if DEBUG_POOLINFO
1494
+ Trace . TraceWarning ( "Failed to extract required train " + train . Name + " from pool " + PoolName + "\n " ) ;
1447
1495
#endif
1448
1496
return ( TrainFromPool . Failed ) ;
1449
1497
}
0 commit comments