Link collection for the Requirements Talk

Funded by the BMBFIf you’ve come here you have probably attended one of my talks on ReqIF and domain specific languages. Here is a collection of links for further reading.

At Embbeded World we are at booth 10-529!

ReqIF/RIF

ReqIF/ OMG : http://www.omg.org/spec/ReqIF/

Automotive HIS – RIF: http://www.automotive-his.de/rif/doku.php?id=welcome

Prostep – RIF: http://www.prostep.org/de/projektgruppen/internationalization-of-the-requirements-interchange-format-intrif.html

Domain Specific Languages Tools

Xtext: http://www.eclipse.org/Xtext/

 

Textual Domain Specific Languages to be researched in VERDE / IMES

Natural Rule Language

OMG MARTE Profile spec (look at VSL for textual language) : http://www.omg.org/spec/MARTE/1.0/PDF/

Research Projects

VERDE – Research Project: http://www.itea-verde.org/

ProR – Research Project: http://www.pror.org/

IMES – Research Project (no website yet).

 

My related material:

Topcased Days, Toulouse – http://gforge.enseeiht.fr/docman/view.php/52/4277/A1-Itemis-HHUD.pdf
Article in ATZ-Elektronik: http://www.atzonline.de/Artikel/3/12285/Forschungsprojekt-Verde-–-Prozessuebergreifende-Werkzeugplattform-fuer-Embedded-Systems.html

Validating Xtext models with OCL

Installing the ocl editor

Installing the ocl editor

OCL and Xtext work together quite well on Eclipse: There are some OCL editors implemented with Xtext. But if you are familiar with OCL, could you also use it to write validations for Xtext models? Of course, since Xtext generates an .ecore for each grammar and you can use OCL constraints on an .ecore. How to do this is described in the Eclipse OCL help, but it is a little hard to find and if you are mainly an Xtext user you might not see all the necessary steps.

It is necessary to install the OCL editor and examples. Now, in your Xtext project, in the src-gen directory you will find the ecore that has been generated for your Xtext grammar. In the context menu, you will find a “open with OCLinEcore” menu entry that will open a textual editor.

In this editor, you can edit the OCL constraints for the model elements.

Editing OCL constraints
Editing OCL constraints

After that, you have to tweak the genmodel a bit, by opening it and setting the property Model/Operation Reflection to true and regenerating code from the genmodel. Caution: If you change your grammar and restart the .mwe2 work flow, the .ecore might be overwritten. So keep a copy of all your OCL constraints to be able to paste them back in.

Now start your Xtext editor and you will see the OCL constraint errors show up alongside with the normal Xtext errors:

OCL constraints in Xtext
OCL constraints in Xtext

Other useful things:

You can also open Xtext models with the builtin-tree like editor (Open with … <GrammarName> Model Editor).  Open the OCL console and you can type away OCL queries on the element selected in the tree view (which is your Xtext model).

Opening the OCL console
Opening the OCL console
1: Type the query, 2: query result

Xtext and existing .ecore: Making use of the Atlan Model zoo

Xtext is a great tool for defining your own languages and generating editors for that. A lot of the work involved is in the definition of the language. So obviously, if there is some available similar language or meta-model you might want to reuse that. With Xtext, you can use existing .ecore files and create a grammar and editor out of those.

The AtlanMod Meta-Model Zoos

One source to start looking for existing meta-models is the AtlanMod Meta-Model Zoo. It provides a variety of meta-models. The meta-models are originally in KM3 format, but they have an automatic conversion into other meta-meta-models, so you can download meta-models in UML or .ecore format. As an example, we will use the FiniteStateMachine.ecore from the AtlandMod Meta-Model Zoo.

The EMF Project

Adding the .ecore to your project

Adding the .ecore to your project

To start, simply download your .ecore from the website. Create an empty EMF Project in your Eclipse workspace and copy the .ecore into your “model” sub-directory. The Xtext project wizard does actually require a .genmodel, so we need to create this first. If you open your .ecore and have a look at the properties of the FSM and PrimitiveTypes package, you will see that the properties “Ns Prefix” and “Ns URI” are unset. We need to set these values to be able to create a genmodel.

In addition, the PrimitiveTypes have unset Instance Type Names and we need those for the genmodel too, so we set them (we will get rid of most of the Primitive Types package later, but at this stage we still need to keep it).

Setting the model properties
Setting the model properties

At this point in time, make sure that the ecore is saved and then create a genmodel for the .ecore. After the genmodel is created, create all necessary emf-projects.

Creating the Xtext Project

Use the Create New Project wizard and select “Xtext from existing ecore”. Add the FSM genmodel by clicking “add” and you are almost ready to go.

A small but important selection

There is a very important but small detail: In the dialog-box you have to select the model element that should be the root rule of your grammar. Usually this is not set to a good default, so you need to pick it by yourself (State Machine in our case). Create the project and find the default grammar.

Cleaning the Xtext Project

You will find some errors in the project. The first is a duplicate import. Since the AtlanMod .ecores have more than one root package, we need to do some tweaking here by adding the fragment here. If you are familiar with the URI syntax, you might have tried something like appending “#/FSM”.

Problem with import

However, this does not work for root packages. As Sebastian Zarnekow points out, the names don’t work on the root level, you have to use the numeric reference to the packages.

Import fixed

In addition there is a number of optimizations that you can do:

  • References in the grammar often use EString as the parser rule, you might want to replace the EStrings with the ID
  • The model zoo uses String for names etc., you might want to really check if you want Strings, replace them with the terminal STRING, or if you want IDs (replace them with ID)
  • Similar with Integers (replace by INT) and other datatypes. At this point, you might have replaced all data types by built-ins so that you might want to remove the PrimitiveTypes import and rules completely
  • The generated grammar is verbose. Often you would want the “name” rule of an element to just be an ID, not preceded by the keyword “name”. So you might want to remove some of the keywords (Have a look at the generated editor to see where the keywords are too annoying for you).

At this point, you are ready to go and try your new editor.

Reporting with EMF, Xpand and Excel

itemis is participating in several research projects and I am currently the itemis PM for the projects VERDE and IMES. Research projects involve some reporting to the sponsoring entities (german ministry, european union…). Necessary data for the reports is distributed over a number of data sources (project reporting tools, excel sheets) etc. I had started out with Excel-based reporting, but that is really annoying if reporting format, level of detail changes.

Initial Meta-Model. Layout won't win a design price.

Initial Meta-Model. Layout won't win a design price.

When looking for an alternative that allows for reporting in the required format, I couldn’t find any decent available tooling, so the option was DIY. The meta-model for the project data was easily setup as an ecore model (originally modelling with Papyrus UML). Data imports from .csv where written by providing an Xtext grammar for CSV and then transforming the data to the project meta-model by means of QVTO.

Then there is the reporting part. Obviously you cannot avoid Excel when it comes to reporting to project management and sponsoring entities. So the question is how to generate Excel?

The first approach was to generate a .ecore out of XMLs schema definition and use M2M transformations. This turned out to be hell. There is a lot of xsds that you have to download and then there is problems with missing attributes names. I gave up on this.

Then there is the .zip based format of recent office versions. Data is split among several XML files which cross-reference each other. That is also very tedious.

Generating SpreadsheetXML with Xpand
Generating SpreadsheetXML with Xpand

However, office still supports the .xml format from office 2003 (known as SpreadsheetML). SpreadsheetML is a nice option if you want to generate Excel documents. It contains the Excel sheet in one flat file. Find out how the table data is stored by creating a small document that looks like you would like it to and then create a Xpand template out of it.

There are a few caveats:

  • Style ids: Cells will have a “style” attribute in .xml. However, the same style may have different style ids in two different documents, depending on the order of creation. This takes some effort to get it right.
  • Rows, cells, etc. might have some information about their position. This needs to be removed in most cases
  • Each worksheet has information about the number of columns and rows in it. Make sure that you adjust this, otherwise your sheets will not load.
  • Debugging: If you .xml is wrong, Excel will complain and show you the path to a log file. Examine that to find out more information on the error. Information is brief, prepare for some searching.
Generated report (one worksheet of many)
Generated report (one worksheet of many)

But there is also a number of nice features:

  • You can set the page breaks. I have information in sheets, that should exactly print to several pages. The breaks are correctly generated, no manual tweaking required.
  • Layout of sheets can be easily changed by the generator.

Not everything can be created this way however. It is impossible to create SmartArt and diagrams.

Research project IMES

We have been able to get funding for the IMES research project, together with our project partners:

Goal of IMES is the exploitation of the full potential of model based development (MBD) by both applying MDB for application function oriented requirements engineering and the architecture centric design of software intensive systems and by using MBD for quality assurance and integration. One focal point of the project is the formalization of in-use approaches that are less formal (e.g. structured modeling of application functions), as well as the extension of the models in use to cover essential characteristics (e.g. definition of dynamic interface characteristic in AUTOSAR).

Another focal point is the transfer of the model based development process to industrial application, both by defining reference documents and models (i.e. application function oriented model for the specification documents) and reference solutions (e.g. standard architectures) as well as providing methods for analysis and synthesis.

An essential part is the distributed development process for automotive systems, i.e. the collaboration of OEMs and 1-tiers. Illustration one shows the intended modular structure for that collaboration. In current practice, the OEM basically defines the function to be provided by the software and uses that definition for the functional verification. The ECU and its software is developed for the most part by the 1-tier. This separation introduces an extensive effort during integration and quality assurance of the function into the full system: The OEM does not have knowledge in the software architecture and the 1-tier lacks the view on the full system to be able to design a feasible software architecture.

The system architecture is driven by the integration of monolithic single application functions. The architecture is not design for quality characteristics (e.g. ISO 9126). The reuse of application functions and software components for new models and product lines is restricted, since both function and software are designed for one product line. The adaptation of existing functions to new technical platforms requires huge effort, that should better be invested to develop new, innovative functions.

IMES aims to increase the modularization of the development. Specification of requirements, functional elements and functional software components is in the hands of the OEM. 1-tiers focus on the implementation of software and middle ware as well as the production of the ECUs. Functions do not have any implications on the competitive advantage could still be developed by the supplier. In a modular development process, development steps can be addressed by different entities. To industrialize the transition from one step to the next, a precise specification is required.

To address these issues, IMES addresses four major topics as well as the cross-cutting topic “model repository”.

  • Function oriented requirements definition
  • Architecture-centric system development
  • Quality assurance of models
  • Model based quality Assurance
  • Model repository

For itemis, this is another step into bringing our technologies “up the left leg of the V” in development. Within VERDE, we are designing and implementing a solution for the traceability of requirements with Eclipse. IMES is a perfect match for that activity, since requirements specification and application function modeling are critical steps that are not yet supported enough by Eclipse based tooling.

Samson G-Track, static noise and Windows 7

For producing the screencasts and podcasts I needed a mic with better quality than the built-in mic of my laptop. After checking the reviews on Amazon I ordered a Samson G-Track. Much to my disappointment, after plugin in there was a lot of static noise when recording. How could that be with that much good reviews? Most of the great reviews, it turns out, where from people still using XP. Windows 7 changed the sound architecture / drivers so that a USB mic that works great on XP does not necessarily work on W7.

I could not find any solution on any of the forums where this problem was discussed. After some googling I decided to give a ASIO driver a try and downloaded the demo from www.usb-audio.de: Success! No static noise anymore. So if you want to get your G-Track running on Windows 7, try to find some USB ASIO drivers. It even gets the mic to work with software that does not support ASIO. I am using Audacity with MME to record – no static,  but the input level might be a bit low. Unfortunately, the driver I found costs EUR 60,-, which is basically half of what the mic costs.Be sure to get an evaluation version of your driver first to see what Windows 7 makes of your combination of HW/SW.

Xtext 1.0.0 and UML (Xpand on top)

Several projects combine textual DSLs with Xtext with UML models and there have been some postings (by Sven, Holger and others) on how to achieve this with earlier versions of Xtext. This is a short sketch on how to do it with the latest version. If you do not now what this is about, have a look at the screenshot on the left: The Xtext grammar references a UML model with an Activity and two classes. This is fully integrated you see that content assist suggest the elements from the UML model.

The biggest difference is the need for IResourceProviders for UML. Xtext comes with a IResourceProvider for EMF models, and this can be used for writing an UML version. I added three new files to the Xtext project: UmlResourceDescriptionManager.java and UMLResourceServiceProviderImpl.java UMLResourceDescription.java . The former two are very simple: UMLResourceServiceProviderImpl.java only binds the .uml extension.

This is a very basic implemenation of a UML Resource Description: It returns all "NamedElements" from the UML model.  The functionality could be extended to different purposes, but this does the job right now.

The grammar of our languages is pretty ssimple. Nothing new compared to earlier releases:

As in the other tutorials, you should copy the relevant-meta-models into your project. However, there's a lot of changes in the work flow. Have a look at this work flow to see how to adapt it to UML:

In the Manifest, the Resource Provider has to be made known through an extension. If you add org.eclipse.uml2.codegen.ecore, org.eclipse.uml2.uml and org.eclipse.xtext.ecore you are ready to go and create and run a grammar references to UML. However, if you want to also use code generation, this is a good time to modify the StandaloneSetup.java class:
package de.itemis.graf;

At this point, you can run the editor, create a UML model and reference the model elements from within your Xtext model.

On top, if you want to process this with Xpand, here is the work flow:

And here an example of a template:

Enjoy combining your DSLs with UML.

Installing Trufun UML Plato Free Edition

Last year I had already mentioned a free chinese UML tool in articles etc. I think it could be worthwhile investigating. However, since the website is all in Chinese, finding and downloading it is a problem for most Western people. Which is a pity, since the tool itself has both a Chinese and an English user interface.

The Home Page of Trufun is www.trufun.net , downloads are at http://www.trufun.net/www1/Ch/Downlist.asp The tools are based on Eclipse 3.5 (Galileo), but I just installed the Update-Version in Helios and it seems to run fine. Download http://download.trufun.net/uml/x/Plato-Free-Plugins-X-V3.0.zip and extract it into your Eclipse installation.

After starting your Eclipse, you are asked to update to the latest version. Don’t do this, this didn’t work on my installation. You can create new models with New->Other->Trufun UML Modeling.

Trufun stores its models as .tmx, which is a variant of uml2tools’ .uml format and can be converted with some tricks, so you can use Xpand etc. to use Xpand, Acceleo and other tools on the model. I will write about that in a later post.

Modeling Tool Usability Checklist – Element Deletion

Working with modeling tools that provide different views on the same model (like UML with diagrams) can be an interesting experience. The relationship between model and views introduces some challenges for usability, which is addressed differently by tools. These aspects can easily confuse those that do their first steps in modeling and annoy those that work with several tools. I suggest that you might want to have some checklist for your tool for quick reference to navigate these quirks. In a number of blog posts, I will propose and explain this checklist.

For illustration, I am working with Papyrus/MDT. Papyrus at the time of writing is available in version 0.7.0. Usability might change, but Papyrus is only used to illustrate the checklist, not to comment on the tool itself.

Checklist: In your tool, what commands are used for local deletion (in diagram) and from model.

Assume we have a small UML model with three classes, RainSensor, RainSensor Variant and SunRoof in two diagrams A and B.

Diagram A

Diagram A

Diagram B

Diagram B

It is important to remember, that diagrams are only views on the model. The actual model can be seen in the tree view. Obviously we should only find one RainSensor in the model.

Model Viewer

Diagrams are views on the model.  This has a view implications on usability. If we have a look on the context menu of Papyrus, we see two commands for deletion:

Deletion Commands

These two kinds of deletion commands can be found with all kinds of different naming conventions in graphical modeling tools. 2) will remove the symbol from the diagram without modifying the model. 1) will actually remove the model element. If you try 2), the model will not be changed. However, this is how the screenshots change after you choose 1): Since the model element has been deleted, its symbol is removed from Diagram B.

Don’t confuse the two, you might accidentally remove elements. It would be great if your tool had functionality to show you the impact of a deletion (the impact of any change would even be better).

Model elements can also be deleted by using the pop-up from the tree view:

Checklist: Check the semantics of Undo

If you try the above in any of your tools, try the undo function as well and see what your tool does. If you try the steps above and use undo after deleting from within the diagram, you will get the following results:

and, unexpectedly:

This tool does not undo any side effect a change has on other diagrams! Be sure to check the semantics of undo, to make sure you do not loose any data.

Checklist: Changes on closed diagrams

If you close the diagram (i.e. it is not open for editing), changes can have a different semantics. Again, deleting the model element RainSensor from within Diagram A, but having closed Diagram B results in the expected deletion of the model element. This is how B looks after opening it again:

Suddenly, there is an element “model” in there? What happened? Tools that do not actively update closed diagrams when the model changes, have to check the consistency of diagram and model upon opening. This specific tool seems to follow the strategy to replace references to non existing model elements with references to others. Check what your tool does!

Checklist: Collaboration

Several people working on one model at the same time opens another can of worms. Without going into detail: Check how deletions by one person are propagated throughout the system.

Checklist: Find unreferenced elements

You can easily imagine, that you might delete an element from the diagram, actually forgetting about it. But it is still there in the model. Does your tool have functionality to find unreferenced elements? You wouldn’t want to browse through all the diagrams just to find the unused items.

The next post on the topic will be on element renaming.

Modeling AUTOSAR with UML / Papyrus

In the early days of AUTOSAR (Release 2.0) there was the idea of using UML tools for AUTOSAR modeling by applying profiles. At this time, an actual profile had been defined as part of the documents provided by AUTOSAR (http://www.autosar.org/download/R2.0/AUTOSAR_UML_Profile.pdf).  This document has not been updated further, partly because the main contributor (an UML tool provider) left AUTOSAR at that time. I was never convinced that the UML profile approach was feasible. Grafting AUTOSAR on top of UML requires mapping a complex meta-model to another. In terms of AUTOSAR ECU configuration, there is no real correspondence in UML and the UI of the UML tool would have to go major changes. Today, with the availability of an AUTOSAR meta-model tooling in the form of Artop, domain specific languages and graphical editing frameworks (GMF/Graphiti), the approach is even less feasible IMHO.

You can easily create AUTOSAR software-component models with textual modeling by using ARText. There is, however, no low-cost tooling available right now for showing graphical models. So if you want to avoid license costs and still be able to graphically software components, for this case, an UML profile could be one approach. Both AUTOSAR and UML provide a component model, so the meta-model structures have more similarities than in other areas of AUTOSAR.

The nice thing is, that you can use open source UML tools for modeling. If you use Papyrus, you can easily define stereotypes for AUTOSAR:

The basic component types of AUTOSAR are easily added. But the great thing is that Papyrus allows you to change the graphical representation of elements depending on the stereotype. AUTOSAR defines a certain notation for sender/receiver ports, so we can bring this notation to Papyrus by first defining a stereotype for sender and receiver ports:

Note the “<Image>” elements in the property sheet. You can set these to any image. To do this, you have to locate them in the model browser and load an image by pressing the “+” button. After that, the “+” button will be replaced by a preview of your icon:

Now go ahead to model in “AUTOSAR”-style (change the appearance of the ports in the corresponding tab to “icon”):

Of course, you now have an UML model. But with Eclipse M2T/M2M technologies you can transform that to an AUTOSAR model.