MCA2 Calculator Tutorial Chapter 5

From Mca2
Revision as of 16:12, 27 February 2014 by Pbecker (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 fields for numbers,
  • a radio button box to choose the calculation type and
  • a LCD-display field to view the result


Calc tut mcabrowser07.jpeg

Figure 6: Here you see the group with all four modules for each calculation type and the multiplexer connected by edges.


Calc tut mcabrowser08.jpeg Calc tut mcabrowser09.jpeg


Figure 7(a)and (b): Modifying the group’s ControllerInputs will result in a different value on the group’s SensorOutput

To start the graphical interface run

[mca-home-dir]$ mcagui

Most operations in mcagui can be done by using the mouse buttons with different modifiers. 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 field 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.


Calc tut mcagui01.jpeg

Figure 8: Editing the properties of the radio button group in mcagui.


Calc tut mcagui02.jpeg

Figure 9: The final gui with two textual value imput fields, a LCD and a radio button group.


Repeat this for another input field 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 field. Click on the LCD button in the tool bar to create one. Move it to a fitting position. Edit it’s properties. Connect the SensorOutput

Result to Port No. 0 and change the widget label to “Result”. To distinguish between the different 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 figure 8). In the actors tab, connect the CalculationType ControllerInput to the Value Output. Save the .mcagui file under projects/calculator/etc/pcalc.mcagui. It should somehow look like figure 9.

< Back === Forward >

Personal tools