MCA2 Calculator Tutorial Chapter 5
With mca2 creating a gui that connects to your running program (running on your local machine or on a remote computer) is very easy. In the gui for our calculator program we need
- two input ﬁelds for numbers,
- a radio button box to choose the calculation type and
- a LCD-display ﬁeld to view the result
Figure 6: Here you see the group with all four modules for each calculation type and the multiplexer connected by edges.
Figure 7(a)and (b): Modifying the group’s ControllerInputs will result in a diﬀerent value on the group’s SensorOutput
To start the graphical interface run
Most operations in mcagui can be done by using the mouse buttons with diﬀerent modiﬁers. A quick overview is listed in table 1.
operation shortcut ----------- -------- move object CTRL + left mouse button open object properties overview CTRL + middle mouse button resize object CTRL + right mouse buttons Table1: Basic shortcuts within the tool mcagui.
Click on a (textual value) input ﬁeld in the top tool bar to create one. Move it to a desired place in the gui window and then edit it’s properties: In the tab “common” change the widged label to “Value 1”. In the tab “Actors” click on the ControllerInput Value1 on the left side and Value Output on the right side. Connect them by clicking the arrow button.
Figure 8: Editing the properties of the radio button group in mcagui.
Figure 9: The ﬁnal gui with two textual value imput ﬁelds, a LCD and a radio button group.
Repeat this for another input ﬁeld with the widget label “Value 2” and a connection to the ControllerInput Value2.
To display the result of the calculation we use a LCD-display ﬁeld. Click on the LCD button in the tool bar to create one. Move it to a ﬁtting position. Edit it’s properties. Connect the SensorOutput
Result to Port No. 0 and change the widget label to “Result”. To distinguish between the diﬀerent calculation types we use a radio button group. Create one and move it around. In the properties window on the special tab change the number of values to 4. Add a value description (add, subtract, multiply, divide) and adjust the values (0, ..., 3) (see ﬁgure 8). In the actors tab, connect the CalculationType ControllerInput to the Value Output. Save the .mcagui ﬁle under projects/calculator/etc/pcalc.mcagui. It should somehow look like ﬁgure 9.