MCA2 Calculator Tutorial Chapter 5

From Mca2
Revision as of 13:13, 26 November 2010 by Badruduja (Talk | contribs)

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 LCD-display field to view the result and
  • a LCD-display field to view the result and
      Run
      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.

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.

Personal tools