Thursday 27 July 2017

Trains: Estación Internacional de Canfranc

Estación Internacional de Canfranc is a partially closed station in the French/Spanish border, between Pau, France and Zaragosa, Spain.





The line opened 1915, and the station opened in July, 1928 as the biggest station of Europe at that time. With a length of 241 meters and 75 doors on each side, the station is impressive. It also has an interesting history from WWII.





The village of Canfranc is quite small, but a huge station was needed to transfer passengers and cargo between the French standard gauge (1485 mm) to the Spanish gauge (1672 mm).


The line wasn't profitable and it was shut down after a derailment accident on the French side 1970, since SNCF decided not to repair the line.


Currently, there is still some traffic to the station from the Spanish side.










The last pictures are from another closed station along the line.






For more pictures of the interior of Canfranc station, I can recommend http://www.canfranc.de/

Saturday 22 July 2017

TrafficControl: Adding Trains to the QML Map - Coding

The trains are added in the C++ and QML part when the "ADD TRAIN" command is used. Initially, the trains are placed on a default location on the map,


When the station is specified (TRAIN SET CURRENT STATION), the train will be visible and get proper coordinates, according to the station name. In order to do this, the tcStation and tcTrack need to have their own coordinates in the C++ part. Until now, C++ has only passed the parameters to QML.
The train positions will be updated using qmlTrainPositionSlot.

From now on, the C++ station object will be aware of its own coordinates.

The train will be relocated using signal/slot mechanism, with position, delay status and number of passengers. For the current commit, the signal qmlTrainPositionSignal is only emitted when the train arrives to a station.
The red dots are the trains (currently only updated when arriving to stations)


The train from Ada_Lovelace from Gunnesbo has arrived to Lund
In the next blog post, I'll implement a function that will help the trains to calculate their coordinates based on the position of the tracks.

A side note: When compiling, the error message "Cannot convert QVariant to QVariant" might pop up. Include QVariant to the header file to resolve that issue.

Monday 17 July 2017

TrafficControl: Adding Trains to the QML Map - Background

The trains will be visualized as a rectangle QML type or possibly a QML polyline with two coordinates.

The color should reflect the type of train that is used. Initially, I'll use the color used in the most common trains in Skåne:

  • Pågatågen are using X61 trains that are 74.3 m long and 3.26 m wide, with a top speed of 160 km/h and the engines have a power of 2000 kW. It has a seat capacity of 234 passengers and a weight of 155 tonnes.

https://commons.wikimedia.org/wiki/File:X61.jpg CC by SA 3.0
  • Öresundståg are using X31 trains that are 78,9 m long and 2.97 m wide, with a top speed of 180 km/h and the engines has a power of 2300 kW. The seat capacity is 229 and the weight is 156 metric tonnes. The color will be gray.



https://commons.wikimedia.org/wiki/File:X31-Boras.JPG CC by SA 3.0  

It is possible to import a QtQuickItem to a map:

A MapCircle will be used for visualising the train. The initial proposal for visualising the train will be:
  • border.width : ceiling(Number of passengers / 100)  
  • border.color : Delay status (Green/Yellow/Red)
  • center : Location of the train
  • color : Color of the train
  • opacity : 1
  • radius : Indicator of train length. Radius = length / 2


It should be possible to animate that item. Check https://doc.qt.io/qt-5/qtlocation-planespotter-example.html


Wednesday 12 July 2017

TrafficControl: Adding Tracks to QML Map (part 3)

I found how to add coordinates to a QML Map Polyline, so now the tracks are much smoother.


The method AddCoordinate needs a coordinate that is created using QtPositioning.coordinate(...). Using that, it is easy to loop over the coordinates in the coordinatelist and generate the curved tracks, as can be seen below.

I also implemented a better way of separating the double tracks, shifting the second track 90 degrees from the principal direction of the track. That is done in the KMLParser script (Python).

For now, I'm happy with the visualisation of the tracks. The next step will be to implement the trains.

Friday 7 July 2017

TrafficControl: Adding Tracks to QML Map (part 2)

In order to make the map more useful, I had to separate the duplicate tracks on the map. I did this by adding an offset to the coordinates in the polyline.

A queue was also added for each track, in order to track how many trains are on the track. The queue will also help detecting whether the tracks will really follow a First In-First Out order.

The visualization rules will be defined in the QML JavaScripts. C++ will send the new states of the stations and trains.



The next steps will be to fix the tracks in QML and to add the trains to the QML map and update them.

Monday 3 July 2017

TrafficControl: Adding Tracks to QML Map

The next step is to add tracks to the QML map as a MapPolyLine.

As before, a KML file in Google Earth is parsed to an input file:

When scanning the input file, a typical track will look like this:

The function TrafficControl::importPredefinedNetwork() will catch the track info and call TrafficControl::addTrackToNetwork(name, length, coordinates):

After the trafficControl item is added, the QML method for creating tracks is called.

The JS function in the QML file calls a function in the separate JS source file (TODO: try to avoid this step.


The jsCreateQMLTrack creates a polyLine with two coordinates only. I am trying to make it create a polyLinr with an arbitary number of coordinates.


The final result is a map with lines between the stations.

The next step will be to make the colour and width of the tracks reflect the state of the track.
  • Width will reflect number of trains on the segment. Width will be number of trains + 1.
  • Color will reflect the state of the track:
    • Green means available with no trains on the track
    • Yellow means that there are trains on the track, but more trains may enter
    • Red means that no trains may enter (Busy or Emergency stop)
    • Grey means signal error. Only trains movements in primary direction, and with reduced speed.