Saturday 24 February 2018

TrafficControl: Adding a Program Icon to the Ececutable

A program should not only be functional, it must also look like a functional program. The default icon for executables clearly suggest that the program is more a stub/pet project than a mature software.

Creating an icon is quite simple:

  • Start with creating an image that you want to have as an icon




  • Add the icon file to the Qt project's Resources folder. 
  • Create a .rc file that points to the icon file.


  • Finally, include the rc file  in the pro file.
  • Run QMake and compile the program. The executable will now have a window icon.


Note that unless you include/provide the Qt libraries into that executable, the program won't run outside of the Qt environment. I've written about dynamic linking in another blog post.



Thursday 22 February 2018

TrafficControl: Crash for QQuickItem in QDockWidget after Update

After an update of Qt 5.10, TrafficControl crashes when it is setting up the QtQuick/QML widget in the user interface. The program worked fine before the update (2018-01-17) and I have isolated the issue by removing other parts of TrafficControl.

I suspect strongly that changes in Qt 5.10 has made my application crash. After installing Qt 5.9.3, the program works fine with that version.

If I remember, I'll post updates on this topic when there are news/fixes about this issue.

Saturday 17 February 2018

Android: Bringing Up the IDE

In 2018, I want to learn developing Android apps. The first step is to run a default app in Android studio.

When building such an example, I got a compile error about a missing Android-26 file.

The issue is that the corresponding Android SDK version isn't installed.

After installing that package, I saw a new issue when building again:

I installed the corresponding Build Tools revision:

This time, the build was successful. I had to restart Android Studio to see the Virtual Device manager (AVD), that I need in order to emulate my app.

Before running, the project must be synced with Android version (Tools - Android - Sync Project with Gradle Files).
The purpose of this blog is to show my learning curve as a software developer. Don't take my blog posts as some truth or golden solutions.

Saturday 10 February 2018

TrafficControl: Making TrackStationConnector Ignore Hidden Tracks/Stations

The python script TrackStationConnector adds tracks/stations and connects them to each other. if they are close enough. The input is a KML file, and the output defines the train network.

In Google Earth, it is possible to hide items. They are still present in the KML file but not visible.
Currently, that script adds all items it finds (including hidden items), and I need to make the script only consider the enabled items.

The invisible station has a corresponding tag.
When an item is hidden in the KML file, there is a visibility tag that is set to 0. That tag is present both for folders (meaning that there are no visible items in that folder) and for the hidden items.

To make the python script ignore the invisible tracks, I added a boolean variable ignorePM. That variable is set to false when the script reaches a placemark. If the script reaches the visibility tag, it sets the variable to 1.  The corresponding station/junction/track is created only if ignorePM is set to false and the placemark isn't added to the track network.

ignorePM is set to true if the visibility tag is present for the placemark. That variable is later used to decide whether to process that particular placemark.
Further, I've found a bug. The program assumes that all tracks has a station or junction at the start and end of the track. If that is not the case, the python script will use the same station for start and end for a track. I resolved that by adding a condition for connecting tracks to stations.

If the closest station is more than 200 meters from the end/start of the track, the script concludes that the search fails. In that case, the program will add the track but not connect it to any stations.

Saturday 3 February 2018

StockReader: What Data I Want and the Final Script

I want to acquire the following data for stocks on Swedish markets:
  • Name, DI
  • Price, DI
  • Earning per share, DI
  • P/E, DI
  • Book value per share, DI
  • Price per adjusted equity, DI 
  • Yield, DI
  • Yield per share, DI
  • Profit margin, DI
  • RSI, DI
  • Date of next report, DI
  • Date of next yield, DI
(In Swedish: Namn;Kurs;Vinst per aktie;P E;Kapital per aktie;P JEK;Direktavkastning;Utdelning per aktie;Vinstmarginal;RSI;Nasta rapport;Utdelningsdatum;TA)

I'll start with fetching 

If that allows, I'll fetch the entire stock list:

For each stock in that list, I'll use the hyperlink to get the stocks unique id number:
https://trader.di.se/index.php/quote/kurs/730

This is done using re.findall("/index.php/quote/kurs/[0-9]{1,10}", stockListResponse)

I'll use that number to fetch the key numbers of that stock:
https://trader.di.se/index.php/quote/nyckeltal/730

The code is shown below:
The new script is 24 lines of code, compared with the original C program with 300+ lines of code.
The data is encapsulated in table tags. The regex command generates a list of all matches, and I cherry-pick the data I want.

The next step was to add StockReader to scheduled tasks in windows.