User Screens:
With some minor tuning the operating system was in its final state for this semester. Next, I began to write code for the user interface. Till this point, the CUserScreen class just opened the other windows and had a menu option to toggle turnout one. Rachel and I designed look of user screen. I loaded the bitmap from the last semester on the screen and drew circles on the bitmap to represent Turnouts and Photocells. Clicking on the turnouts dots allows a user to toggle the direction of a turnout All points needed to be relative to the upper left corner to the bitmap so that the system could be implemented on different screen sizes or if someone else wanted to place the bitmap in a different place one the screen. I implemented two list boxes that inform the user about the status of the system by outputting train information about all trains on the course and informing the user if turnouts can be toggled at the moment. I added buttons that allowed the user to disable the entire course and then enable the course again. Finally, I put text on the screen to show which trains owned the photocells around the track.
I also wrote the TrainControl class. This window allows a user to give trains commands. It shows the train’s status, id, resources, speed, headlight status, and taillight status, and provides buttons to brake, change a trains speed, and adjust the headlight or taillight status. Both user windows use timers to display the correct data on the screen. Every time the timer is fired, the data on both the TrainControl class and CUserWindow are updated with current values. The data and the display are separated.
Some problems that I encountered at this point are still unexplained. To draw the photocells and turnouts on the screen, I wrote classes that contained a photocells and turnouts location and color. When I declared these classes inside of CUserScreen the system crashed. If I declared them globally everything executed correctly. Finally, I changed the class to a struct the everything worked well. I also needed to fix the constant flashing that occurred on the CUserScreen because of timers updating the screen. I fixed this by using arrays to keep the current and past statuses of the turnouts and photocells. Only when the arrays differ is the screen updated. This made the screen much easier to look at.
This was the last major update of the system. Rachel and I are trying to get the dialogue boxes to initialize the track running. Right now a user must change the code to set up the track with different trains. This is done in the constructor of CUserScreen. I recommend looking at both my code and power point documents and website for more detailed information on the classes.