Sunday, May 8, 2016

Great progress rebuilding GUI for SAC Interface Box


Restructuring the GUI

After working with the more complex 2501 functionality, I have a more solid approach to building the view, controller and model objects for each device. I am also clear on how to make updates across threads, since parts of each device run in their own threads but GUI actions must all occur in the main thread.

The updated window for the 2501 now displays the count of cards sitting in the virtual card hopper. It added an NPRO button (non-process runout is how you empty a card reader) to clear out the hopper and set the device not ready.

When the user clicks buttons or icons on the graphic window for a device, those actions are handled by the view module. It runs in the main thread. It may present dialogs to select files as part of the process - for example when clicking the card deck icon to load more cards in the 2501 hopper. The card images and updated card count are updated by a call to the model module, which maintains the state of the device. Checking modes like binary cards or last card will also call the model module to update state. The view module can be triggered by an event if the controller, in another thread, wants the view to update.

The controller module runs the main processing for the device in a separate thread. This module is what sticks requests on the queue to be issued to the fpga board. The controller module must check the state of the device as well as ask for card images from the model module. While this is a cross thread operation, it does not need any locking. If the controller module sees it has updated the state of the device which should be reflected on the GUI, it sticks a custom event in the queue which is processed by the view module under the main thread.

Thus, the view and controller modules each communicate only with the model module. The controller can trigger a custom event that is processed by the view module, but it is not calling directly thus the event switches threads.

Both 2310 and 2501 devices active with files loaded
After the screen image I saved above, I changed the icon of the punched card to a obvious deck of card picture. I think I have the 2310, 1627, 1134 and 2501 code ready to test, the 1403 printer code mostly completed, and am starting in on the 1442 restructuring. Still to be worked on are the mirror 1132 printer, mirror 1053 printer, mirror console entry switches, and the core memory loading function.

Control panel for 1403 printer function
New version of 2501 panel with card deck icon
I did take some time to refactor some code, although often that involves a dive into fine points of how Python works that chews up some time. This involves building strings that will become pointers or function objects, making use of the functions like getattr, setattr and delattr that manipulate name spaces.
Control panel for 1442 - note files for input hopper and output stackers

No comments:

Post a Comment