itemis ????????????????? . Xtext ? Textual Modeling Framework?TMF???????????? Galileo ??????. ???? Xtext ??? EBNF ???? DSL???????????????? AST ?????? EMF ???????????? Eclipse ??????
Monthly Archives: Juli 2009
Vortrag auf der Embedded Software Engineering Kongress 2009 in Sindelfingen
Wir halten am 10.Dezember 2009 um 16:00 Uhr einen Vortrag über die Einführung von MDSD in einem Projekt auf dem Embedded Software Engineering Kongress 2009 in Sindelfingen:
Textuelle domänenspezifische Sprachen sind ein starker Trend in der Software-Entwicklung. Welche Lessons-Learned macht ein mittelständisches Unternehmen bei der Einführung von modellbasierter Software-Entwicklung für Embedded Systems? In diesem Talk werden an Hand eines realen Projekts die Lessons Learned und die Vorteile des Einsatzes von textuellen domänenspezifischen Modellen auf Basis von Open Source-Tools erörtert.
Gerade im Embedded Bereich wird Modellierung noch mit ineffizienter Implementierung in Verbindung gebracht. Mit neuen Modellierungstechniken ist dies jedoch nicht der Fall.
Die Referenten werden darüber sprechen, wie sich die Einführung auf Anforderungsmanagement, Projektplanung, Design und Implementierung auswirken. Somit wird modellgetriebene Software-Entwicklung nicht nur vom technischen Standpunkt
der Werkzeuge betrachtet, sondern aus einer gesamthaften Projektsicht.
Die Teilnehmer erhalten Informationen über den praktischen Einsatz von textuellen DSLs, die sie in die Bewertung ihres eigenen Entwicklungsprozesses einbringen können. Da es sich um ein typisches Embedded-System handelt, zeigen wir, dass sich der Einsatz auch in kleineren Projekten und Systemen mit beschränkten Ressourcen lohnt.
Tom de Marco, Software Engineering is dead und Musterbrecher
Für viel Diskussion in den Blogger-Welt sorgt ein Artikel von Tom de Marco, in dem er angeblich Software Engineering für tot erklärt:
http://www2.computer.org/cms/Computer.org/ComputingNow/homepage/2009/0709/rW_SO_Viewpoints.pdf
Dabei ist dieser Artikel im wesentlichen die englische Variante eines älteren deutschen Artikels:
http://www.sigs.de/publications/os/2008/06/interview_DeMarco_OS_06_08.pdf
Die Diskussion in den Blogs geht dabei m.M. nach oft an der Aussage des Artikels vorbei. Interessant ist jedoch zu sehen, wie divers doch die Ansichten auf die Software-Entwicklung noch sind: von wildem Hacken bis zu rigiden Prozessen.
Für mich ist das interessante Tom de Marco’s Reflexion über den “Missbrauch” seiner Konzepte. Es ist aus meiner Sicht immer wieder notwendig bekannte Muster zu überdenken und gegebenenfalls zu durchbrechen.
Interessant finde ich hierzu die Artikel von den “Musterbrechern”:
http://www.musterbrecher.de/index.php/kiosk/fachartikel
wie z.B.
Scoping with Xtext / TMF
The new Xtext version in Galileo changed a few things. To do scoping, a little bit of Java development is necessary. Documentation is very brief, but with a little research it is quite easy. Consider the following grammar, that allows us to define components, instances of those components and – the interesting part here – connect ports of instances:
Component :
   "component" name = ID "{"
   (ports+=Port)*
   "}";
Port :
   "port" dir=Direction name=ID ":" ref=[Interface|ID] ";"
   ;
enum Direction :
   IN="in" | OUT="out";
Instance:
   "instance" name=ID ":" type=[Component|ID] ";"
   ;
Connection:
   "connect" in=[Instance|ID]"."p=[Port|ID] "->" in2=[Instance|ID]"."p2=[Port|ID] ";"
   ;
The default code completion will traverse all defined Ports for the references p and p2 in the Connection rule. A better behaviour would be:
- Show only the ports in the instances (in, in2)
- For p, show only “OUT”-Ports, for p2, show only “IN”-ports.
To do this, we need to define methods in a class derived from AbstractDeclarativeScopeProvider. The method names follow the signature scope_<rule>_<element>, so the code fragment for p2 is:
IScope scope_Connection_p2(Connection ctx, EReference ref)
   {
      if(ctx.getIn2() == null )
         return IScope.NULLSCOPE;
      else
         return new SimpleScope(IScope.NULLSCOPE, getRPorts(ctx.getIn2().getType()));
   }
With some additional code the full Provider for p and p2 looks like this:
public class AutomotiveDSLScopeProvider extends AbstractDeclarativeScopeProvider {
   IScope scope_Connection_p2(Connection ctx, EReference ref)
   {
      if(ctx.getIn2() == null )
         return IScope.NULLSCOPE;
      else
         return new SimpleScope(IScope.NULLSCOPE, getRPorts(ctx.getIn2().getType()));
   }
   IScope scope_Connection_p(Connection ctx, EReference ref)
   {
      if(ctx.getIn() == null )
         return IScope.NULLSCOPE;
      else
         return new SimpleScope(IScope.NULLSCOPE, getPPorts(ctx.getIn().getType()));
   }
   private Iterable<IScopedElement> getPPorts(Component clazz) {
      List<IScopedElement> result = new ArrayList<IScopedElement>();
      for (Port f : clazz.getPorts())
         if (f instanceof Port && f.getDir() == Direction.OUT)
            result.add(ScopedElement.create(f.getName(), f,"("));
      return result;
   }
   private Iterable<IScopedElement> getRPorts(Component clazz) {
      List<IScopedElement> result = new ArrayList<IScopedElement>();
      for (Port f : clazz.getPorts())
         if (f instanceof Port && f.getDir() == Direction.IN)
            result.add(ScopedElement.create(f.getName(), f));
      return result;
   }
}
Screencast Transcript: MDSD for on- and off-board software
This is a transcript of the first itemis screencast introducing model based design and implementation for embedded systems. It is intended for those readers that cannot access the screencast. The screencast is on Youtube.
Introduction
Welcome to the itemis introduction screencast for Model Driven Software-Design for On- and Off-board software.
This is the first in a series of screencasts where we explain various aspects of Model Driven Software Design for complex systems comprised of embedded processors, mobile applications and enterprise infrastructure. We will show how to use open source tools for the engineering process. This screencast will explain the motivation and methodology for model driven software design and introduce the showcase that is used to explain various aspects in the following screencasts.
Software in embedded systems is getting increasingly complex. It is now a major part of electronics development. In addition, embedded systems are more and more connected. Modern cars consist of nearly 100 embedded control units and a complex network. And those systems are connected to off-board systems, as for example in remote diagnosis systems. This is an engineering challenge. We need flexible, reliable systems that comply with various safety standards. Those standards define process and methodologies for safety-critical systems. Manual engineering of software often leads to errors and increased cost in complex systems. We need a methodology and tools that can handle those systems.
We at itemis meet those challenges with model based design. Models help to manage complexity by increasing the level of abstraction. That allows us to discuss the relevant aspects for a problem and not getting confused by all the other aspects. A good model will separate the domain knowledge from the underlying infrastructure. It will also have different views for dynamic and static aspects of the system.
By raising the level of abstraction, a good model will provide a better understanding of the problem at hand. It will improve communication in the project team. And a good model will always be up to date and represent the actual system. However, that is not enough.
To reduce the error-prone manual coding, a good model has to support code generation. It will also support generation of a test framework and generation of the documentation. So, the model has to be at the core of the development process.
So does it this approach really work? Yes it does. We have set up a showcase to show how model driven software design works in embedded and enterprise systems.
Showcase
The showcase system that we built is an example from the automotive domain.
It consists of three major parts. The sensor, the embedded devices and the enterprise applications.




To simulate a real sensor, we patched the open source racing simulation “Torcs” to send out information about the car state. Telemetric data from the sensor is sent throughout the system. It is generated by a virtual sensor on a PC and sent through an UDP link to a Gateway. This gateway is a blackfin board running Embedded Linux. The telemetric data is then sent over two channels. On the embedded side, it is broadcast on a CAN bus, where it is received by a display 3000 board. This is an atmel processor without operating system, but with a small display.
On the enterprise side, the data is sent over a serial link to a PC running a JBOSS application server. It can then remotely be accessed from iphones and android phones by means of standard web services.
With a manual approach, code for all these plattforms would have to be manually written. This is a source for errors and problems.
With model driven software design, we use an abstract unified model to represent the system. We generate code for all those platforms automatically and increasing the speed of the engineering process.

The power of model-based engineering is easily visible if we introduce a second item of sensor data, for example the rotations per minutes of the motor. All the software in the system would have to be changed manually, to handle the additional information.

However, with model based design, we just add the new piece of information to the model and then regenerate the code for the entire system.

More Information
We will explain methods and tools in several screencasts. You have just seen a summary of the introduction screencast.
- Screencast 2 will explain the use of domain specific languages for architecture modeling and code generation.
- Screencast 3 will show how to use an eclipse-based open source toolchain for developing software for embedded systems.
- In Screencast 4 we will bridge the gap from embedded systems to enterprise application and generate the infrastructure and mobile applications.
- Screencast 5 explains the handling of variants and product lines. Screencast 6 will deal with model based diagnosis of embedded systems.
All screencasts use the same showcase system.
Uses of Textual DSLs: IF (Interactive Fiction)
I was reminded of the early age of text adventures by this slashdot article. The great adventures by Infocom and Magnetic Scrolls bring back memories of long hours of trying to solve puzzles. Text adventures have long lost their market share to graphical adventures, but it seems there is a strong community of interactive fiction. A quick look at the current tooling shows a surprising example of textual DSLs. The IF authoring system Inform 7 uses a textual DSL for specifying the game, that makes it easy for authors, not programmers, to create interactive fiction. Look at this piece of “source code”, describing objects and their locations and what happens, when you attack “the donkey”:
The Twinkie is a thing.
The description of the Twinkie is “A confection made of gelatin and preservatives.”
Two hands are part of every person.
The prevailing wind is a direction that varies.
Instead of attacking the donkey:
remove the donkey from play;
if the donkey carries something, now everything carried by the donkey is in the location;
say “The donkey bolts, of course.”
The textual DSL is a formal variant of English. The source code for the game itself reads like English. This is a more complex piece code (from the Inform 7 docs):
“Interrogation”
The X-Ray Vision Wand is carried by the player.
Instead of waving the X-Ray Vision Wand:
say “Disappointingly, nothing happens.”
Instead of waving the X-Ray Vision Wand when the player can see someone who is concealing something:
say “The wand glows green. Immediately you see on the monitor [a list of things which are concealed by people who can be seen by the player].”
After printing the name of a thing (called target) which is carried by someone while waving the wand:
say ” (carried by [a random person who carries the target])”
The Interrogation Chamber is a room. “Despite its gothic name, this room is a rather civilized place for your work, with large plate-glass windows and a fitted carpet.”
A thing can be secret or obvious. A thing is usually obvious.
Brian is in the Interrogation Chamber.”Brian lounges against the wall.” Brian carries a quantity of plastic explosive. The explosive is secret.
Janine is in the Interrogation Chamber. “Janine toys nervously with a laptop bag.” Janine carries a chocolate biscuit, a laptop bag, and a microfilm. The microfilm is secret. The laptop bag is wearable. In the bag is a laptop computer.
Rule for deciding the concealed possessions of something: if the particular possession is secret, yes; otherwise no.
Instead of examining someone: say “[The noun] is openly carrying [a list of unconcealed things carried by the noun].”
Test me with “wave wand / examine janine / examine brian”.