Monday 26 May 2014

TrafficControl: Overall Structure of the Program

The program is co-ordinating trains with track segments and stations in order to simulate a train network.

For example, a train is currently at a station. That train asks a track segment if it is allowed to use that segment and leaves the station. After some time on that track, the train slows down and asks for permission to enter the target station.



The program will be designed to simulate any (reasonable) complex track network, for example the TGV network in France or the local trains in Skåne county in Sweden.

I have some objects representing all trains, stations and tracks. They will communicate with each other using a signal-and-slots mechanism in QT (similar to the events in other framesets). Don't worry if you are not familiar with those concepts, I will describe it in more detail later.

To be able to handle several trains, tracks and stations, I have three lists, that contain all objects: trainList, stationList and trackList.

All stations, tracks and trains will have a unique ID number that corresponds to their position in the lists (the first train will have the index zero. This will give a quite easy way of addressing each object.

An object, trafficControl will co-ordinate the objects.

The information will be displayed with the model-view framework. This means that, instead of writing a number to a table directly, that number will be written to a datamodel. When that is done, the view will get the data from the model. This slightly more complicated approach will hopefully make the program easier to adapt in the future.

I will describe the frameworks in more detail in future blog posts, so don't worry if it feels to advanced. Meanwhile, I can recommend the video tutorials that I wrote about in The Qt Part of the Blog.

No comments:

Post a Comment