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.


Thursday 23 March 2017

TrafficControl: Four Commits and a Bug

I pushed the code with the dynamic QML stations, code cleanup and fixes to the KML parser to the CuteTrains GitHub repo  in four commits (one of them since I'm still on the Git learning curve and two of them are simply bad planning from my side). 

The fixes to the KML parser (trackStationConnector.py) considers the direction of the track in the file name. 

The code cleanup is an attempt to follow the C coding style according to https://www.gnu.org/prep/standards/html_node/Writing-C.html

When running three trains on the bigger network file (Skane_Coordinates.txt), I notice that the trains doesn't follow the travel plans. I know that the train::move part of the program is a mess and needs refactoring. 

I'll focus on debugging the issue with the trains inability to follow the travel plan in future blog posts.

Thursday 16 March 2017

TrafficControl: Adding QML Components Dynamically

To be useful, TrafficControl needs to present the stations on an interactive map. The program logic is currently implemented in C++ with some Qt Graphical User interfaces using model-view relations.

The original presentation of the stations and tracks, that were imported from a KML file.

A part of the user interface will be based on QML, that imports a map from OpenStreet maps. QML is a design language where one can add graphical elements easily. I will describe a simple QML demo program later and publish it on my github account. 

The challenge for me has been to add components in QML dynamically from C++, when stations or tracks are found. The placemarks below are from Google Earth/KML.

The yellow placemarks are representing stations.
The stations has been identified and their coordinate has been sent to the QML part of the program,

The stations has been identified by trafficControl and dynamically added as circles

Some of the next steps will be:
  • Modifying the different stations individually
  • Adding tracks
  • Adding trains
  • Showing status when hovering the mouse pointer over the items
  • Modifying the components regarding their statuses
  • Investigating model/view for QML map items

Saturday 11 March 2017

TrafficControl: Resuming...


When resuming the project, I've seen that the tile issue with tiles that aren't shown seem to be unstable. Some zoom levels work but not others. Qt Blog has addressed that issue and discussed solutions to the issue:
http://blog.qt.io/blog/2017/03/09/provisioning-openstreetmap-providers-in-qtlocation/

I also installed Microsoft Visual Studio, and used that compiler. No missing DLLs and much quicker compilation. I assume the reason is that MSVC is more adopted to the Windows 10 workstation that I'm using than MinGW that I used before.

The next blog post will describe a breakthrough in TrafficControl!