1- // COPYRIGHT 2014 by the Open Rails project.
1+ // COPYRIGHT 2014 by the Open Rails project.
22//
33// This file is part of Open Rails.
44//
1717
1818// This code processes the Timetable definition and converts it into playable train information
1919//
20- // #DEBUG_POOLINFO
20+ // #define DEBUG_POOLINFO
2121//
2222
2323using System ;
@@ -940,8 +940,17 @@ public int GetPoolExitIndex(TTTrain train)
940940
941941#if DEBUG_POOLINFO
942942 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 ) ;
945954 File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
946955#endif
947956 }
@@ -1023,8 +1032,18 @@ public void AddUnit(TTTrain train, bool claimOnly)
10231032
10241033#if DEBUG_POOLINFO
10251034 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 ) ;
10281047 File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
10291048#endif
10301049
@@ -1124,7 +1143,10 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
11241143 {
11251144#if DEBUG_POOLINFO
11261145 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 ) ;
11281150 File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
11291151#endif
11301152 // check if any engines available
@@ -1155,6 +1177,9 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
11551177 {
11561178#if DEBUG_TRACEINFO
11571179 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 ) ;
11581183#endif
11591184 return ( TrainFromPool . Delayed ) ;
11601185 }
@@ -1259,7 +1284,13 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
12591284#if DEBUG_POOLINFO
12601285 sob = new StringBuilder ( ) ;
12611286 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 ) ;
12631294 File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
12641295#endif
12651296 break ;
@@ -1284,8 +1315,15 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
12841315 {
12851316#if DEBUG_POOLINFO
12861317 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 ) ;
12891327 File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
12901328#endif
12911329 return ( TrainFromPool . Delayed ) ;
@@ -1301,8 +1339,15 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
13011339
13021340#if DEBUG_POOLINFO
13031341 sob = new StringBuilder ( ) ;
1342+
13041343 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 ) ;
13061351 File . AppendAllText ( @"C:\temp\PoolAnal.csv" , sob . ToString ( ) + "\n " ) ;
13071352#endif
13081353
@@ -1444,6 +1489,9 @@ virtual public TrainFromPool ExtractTrain(ref TTTrain train, int presentTime)
14441489 {
14451490#if DEBUG_TRACEINFO
14461491 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 " ) ;
14471495#endif
14481496 return ( TrainFromPool . Failed ) ;
14491497 }
0 commit comments