Saturday, 15 April 2017

Monday, 10 April 2017

Trains: Walking the Tracks

First of all: Don't ever walk on a railway track where there are active trains. Looking at a time table isn't enough - trains can be late and several trains don't follow time tables.

No trains will pass some time.
Over a hundred and twenty years ago, a railway company, MöToJ (Malmö-Tomelilla Järnväg) was founded. They operated passenger traffic until 1970 and freight traffic some more years. 

Formally, the line is still in use but in order to use it, track needs to be upgraded and renovated. Trafikverket (the Swedish Ministry for Transportation) has a paused project for that work. http://www.trafikverket.se/nara-dig/skane/projekt-i-skane-lan/simrishamn_malmo-simrishamnsbanan/. 

The railway track that goes from Östervärn, Malmö to Staffanstorp is deactivated. Most of the tracks are remaining but the tracks are removed at road intersections so it will take some time until trains are seen on that track.
My walk started from Lund and ended in Malmö. Five kilometers along non-functional tracks.
One afternoon after work, I walked home from my work, a distance of some 20 km. Five of them along Staffanstorpsbanan.
Nordanå railway station.
Along the trail, I saw some stations that I've missed adding. Nordanå is one of those stations.




It will take lots of work to make the track useful again, and I can understand that it is hard to motivate renovating the line from an economical viewpoint. Raising power connectors, groundworks and replacing tracks will be too expensive.
Neither passengers nor trains will accept the gaps between the rails.

Sege Station, another station that I forgot adding.

The railway enters the eastern parts of Malmö through a golf course.

Sunday, 2 April 2017

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

After re-testing with more debug prints, I've made an observation:

INFO : TRAIN SET MODEL recognised with Model= "X41" . To be implemented!
INFO : TRAIN SET STATION recognised with Station= "Lund_C" . Check that the station exists.
INFO : TRAIN SET DESIRED SPEED recognised with DesiredSpeed= "145"
IMPORT : "Gunnesbo" found. Adding to travelplan
ERROR : Train::addTrackToTrainRoute Error: negative number specified. 0 : "Gunnesbo"<<The stationID 0 is a valid ID.
INFO : "Marie_Curie" has 100 seats. 0 are taken.
: Train is at station "Lund_C"
: TrainRoute, index: 0 :

The program shall check whether the stationID is smaller than zero (invalid value). The bug is that the program is checking whether the stationID is smaller or equal to zero. The new condition is (stationID < 0)


Another issue has been seen: The check for end of travel plans doesn't seem to work:

INFO : "Ada_Lovelace" has reached end of travelplan. tp_s : 2 pos: 1<<For this particular event, the train hasn't reached the end of the travel plan.
INFO : "Marie_Curie" has reached end of travelplan. tp_s : 2 pos: 1
INFO : "Marie_Curie" has reached end of travelplan. tp_s : 2 pos: 1

This new issue will be debugged in a later blog post.

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!