Moving to MCA 2.6

From Mca2
Jump to: navigation, search

Now you will change the edges of the calculator to a xml basis. Through this the edges wont be pre-defined by the code, but in xml and connected live with the program start.


Contents

Building the mcaeditor

Now you open our calculator in mcaeditor. First we have to build the editor by typing

  ninja/make mcaeditor

into the scons console.

Creating xml file

Create a folder xml in ../projects/calculator/etc/ by typing into the directory console:

  mkdir xml

Starting the mcaeditor

Open the newly built editor in your directory console by typing

  mcaeditor

The MCAeditor will now create an xml file for us, by marking PocketCalc and chosing Generate XML Recursive under File. MCAeditor.png

Save the file under ../projects/calculator/etc/xml with the recommended title.

Now we close the editor and comment out/delete the edges we defined in gpocketCalc.cpp, save the file build the calculator new.

  ninja/make  pcalc

The next command opens pcalc with respect to the just created xml file.

  directory console ../projects/calculator:  pcalc -x etc/xml/gPocketCalc-PocketCalc.xml

Overview in Mcaeditor and Explanation

We can now open pcalc with the mcaeditor and see that the calculator looks like the old calculator with the same connections and edges.

  directory console ../projects/calculator: mcaeditor pcalc

Why did we switch to the xml files if the calculator is now the same as before?

What we actually did is switch from enums to strings (or in other words we switched from numbers to names). This makes it much easier to control the edges. Assume we have a file with over a hundred edges and we would like to add a new edge in the middle block. If we add the new edge all the enums below our new edge change the channel. This leads to a new configuration which we have to redirect manually. It is easy to understand that connecting "mAdd" to "mMultiplexer" is much simpler than connecting channel 3 to channel 6. To see an example of the xml edges expressed in words. open the xml file you created above.

Example:

   <Edge>
           <From>
               <Module>
                   <Description>Add</Description>
                   <ModuleName>mAdd</ModuleName>
               </Module>
           </From>
           <To>
               <Module>
                   <Description>Calculation Type MUX </Description>
                   <ModuleName>mMultiplexer</ModuleName>
               </Module>
           </To>
           <Connection>
               <FromDescription>Result</FromDescription>
               <ToDescription>00 Result</ToDescription>
           </Connection>
       </Edge>
Personal tools