Tuesday, 28 March 2017

TrafficControl: Debugging Train::move Method (part 1)

The bug is that the trains seems not to follow their Travel Plans. A Travel Plan is a list of adjacent stations that the train shall visit before the train stops.

For the network file "Network_LundSuburb-ThreeTrains", the program seems to work. The three trains follow their travel plans.
  • Hedy_Lamarr shall start in Hjärup -> Lund -> Gunnesbo -> Lund -> Stangby (STOP)
  • Ada_Lovelace shall start in Gunnesbo->Lund -> Stångby (STOP)
  • Marie_Curie shall start in Lund -> Gunnesbo -> Lund (STOP)
Time Hedy_Lamarr Ada_Lovelace Marie_Curie Comment
0 Hjärup Gunnesbo Lund
1 HjaLunN GunLunS LunGunN
2 HjaLunN Lund Gunnesbo
3 HjaLunN LunStaN GunLunS
4 Lund LunStaN GunLunS
5 LunGunN LunStaN LunGunS
6 LunGunN LunStaN Lund (Stop)
7 Gunnesbo LunStaN Lund (Stop)
8 LunGunS Stangby (Stop) Lund (Stop)
9 Lund Stangby (Stop) Lund (Stop)
10 LunStaN Stangby (Stop) Lund (Stop)
11 Stangby (Stop) Stangby (Stop) Lund (Stop) Expected behavior


When using a network file with tracks in both directions, (Lund_Coordinates.txt), the program warns that it can't add tracs to Travel Plans:

INFO : Adding track to trainroute << Need to print what station to add. The first station (LundC) was added!
INFO : "Hedy_Lamarr" has 100 seats. 0 are taken.
: Train is at station "Hjaerup"
: TrainRoute, index: 0 :
2 : "Lund_C"
^ Current ^
ERROR : Train::addTrackToTrainRoute Error: negative number specified. <<Why wasn't the program able to addGunnesbo?

INFO : "Hedy_Lamarr" has 100 seats. 0 are taken.
: Train is at station "Hjaerup"
: TrainRoute, index: 0 :
2 : "Lund_C"
^ Current ^
INFO : Adding track to trainroute <<This time, LundC was added to travelPlan. The program isn't designed to handle two consecutive entries of the same station in TravelPlan
INFO : "Hedy_Lamarr" has 100 seats. 0 are taken.
: Train is at station "Hjaerup"
: TrainRoute, index: 0 :
2 : "Lund_C"
^ Current ^
2 : "Lund_C"<< Hjaerup should have been before LundC in the travelPlan
INFO : Adding track to trainroute << Staangby was added to travelPlan
INFO : "Hedy_Lamarr" has 100 seats. 0 are taken.
: Train is at station "Hjaerup"
: TrainRoute, index: 0 :
2 : "Lund_C"
^ Current ^
2 : "Lund_C"
3 : "Staangby"


For the train Ada_Lovelace, that issue wasn't seen. For the train Marie_Curie, the issue came when adding Gunnesbo station to the travelPlan. In the network file, the Gunnesbo station seems to be ok.

In the next blog post, I'll add extra prints to show what happens when trying to add Gunnesbo station to travel plans.


No comments:

Post a Comment