Eclipse, english, Software Development

Model transformations for MBSE with Cameo and Xtend

Model-Based Systems Engineering (MBSE) is one of the most important approaches to managing complexity. Using models as central artifacts also implies that they have to be integrated with other development artifacts. It also means that the tools being used to create and manage systems engineering models should be integrated with other tools.

Some kinds of such integrations require transformations of different kinds of models.

Within the Eclipse framework, the Xtend project provides good support for model-to-model and model-to-text transformations. On the tooling side, Cameo is one of the widely-used tools for creating and managing SysML models.

Combining Cameo and Xtend

For accessing the SysML model, Cameo and MagicDraw provide a rich API. The API is Java-based. And since Xtend is fully integrated with Java, we can easily write Cameo integrations and extensions with Xtend.

Setting up the Eclipse IDE for Cameo integrations

MagicDraw comes with detailed explanations and demos of customization projects built with Eclipse.

However, when we tried using the API with Cameo, we had to do a couple of additional steps. For some of them, hints needed to perform them successfully were spread over several support forum entries.

Using the basic documentation, you have Cameo installed, but MagicDraw is started. Since the installed license is valid only for Cameo, the tools request another valid license for MagicDraw.

Solution: Manually add the brand_api.jar to the MagicDraw project, which is contained in the IDE integration package provided by NoMagic.

  • In Eclipse, open the context menu with a right-click on the MagicDraw project and select Properties.
  • In the “Properties for MagicDraw” window, select “Java Build Path” in the list of the left side, then click on the Library pane on the right.
  • Click on the “Add External JARs…” button on the right, and find brand_api.jar in the lib folder inside the NoMagic installation path, e.g. D:\tools\CameoSystemsModeler\lib.
  • In the “Order and Export” pane, locate brand_api.jar on the bottom of the list, and enable the checkbox to the left of it.
  • Now having the brand_api.jar line selected, click on the Up button as many times as needed to pull this item almost to the top of the list. Ensure that it is right below patch.jar.
  • Apply the changes and close the window.

In order to get a full SysML version running, we needed to add further plugins to the classpath:

add-plugins-to-classpath

 

Writing Xtend code

Instead of Java, we can use Xtend code to create, modify, or process the SysML model. Here is some simple code to create a SysML block in a package blocks:

create-a-SysML-block

 

Xtend is part of the Eclipse ecosystem and freely available. The benefits of Xtend are explained in my talk at EclipseCon 2017.

Setting up the Cameo plugins

We are now able to create a plugin, as described in the MagicDraw documentation. Since we are using Xtend, we have to add the Xtend jars to our project:

add-Xtend-jars-to-project

 

and to the Cameo-specific plugin.xml:

add-Xtend-jars-to-Cameo-plugin-xml

 

Now we only have to create a jar of our project, using the Eclipse export functionality:

create-jar-via-eclipse-export

 

Make sure that you include the xtend-gen directory in the export as well:

include-Xtend-gen-directory

 

And that's it! Now we are actually ready to run Camo with our Xtend-based extension in the Eclipse IDE.

You want to learn more about model transformations?

Read my article about "specification-by-example"

   
About Andreas Graf

I am working at itemis as a project manager and business development manager (automotive) supporting and promoting the use of Eclipse and Open Source tooling for the implementation of integrated tool chains and the support of model driven (software) engineering.