BLOG about IBM Rhapsody. Contains technical information as well as more private travel stories.

Tag: UML (Page 2 of 3)

Development of Safety-critical Software

Content

This is also published TechLetter 6, written by Eike Römer. Translated by me and published on the Rhapsody BLOG to allow more people to read it.

The development of safety-critical software is often associated with a certification process. Experiences from the certification environment are presented together with possible work steps.

The procedure is based on the V-model. This Tech-letter covers requirements management, implementation, testing, and end-to-end traceability.

The presented experiences can be adapted to own projects.

Grph - Entwicklung sicherheitskritischer Software-290.png

Practical experience and possible work steps

Creating software for embedded systems in safety-critical areas often requires certification as well. Standards such as IEC 61508 or industry-specific standards are intended to ensure functional safety for safety-critical application areas. In this Techletter practical experiences of the Willert Software Tools GmbH in the range of the software certification are presented.

Example RXF-Cert

Willert develops a so-called semi-finished product, that, being only a part of the software, is being built together with the application software of customers later to create a unit. This unit then must be certified as a whole.

In the specific case, it is the “RXF-Cert” [1], a framework on which the code generator can be based on the UML tool IBM Rational Rhapsody [2] (see Figure 1). In addition to the framework source code and UML model, a “Certification package” is delivered consisting of documents and test suites that facilitate certification in the overall context.

Screen Shot 2018-04-03 at 16.43.06

Figure 1 – RXF-Cert as semi-product in the context of the customers application

Management of Requirements

Probably the most important part of the accompanying documents are the requirements. In order to manage their relationships, versions and status changes, many tools have become established in the market. Such tools are, for example, IBM Rational DOORS® [3] and Polarion [4]. Willert has chosen Polarion for his own use as part of the RXF-Cert project.

Screen Shot 2018-04-03 at 16.44.55

Figure 2 – Specifications and their links in the V-Model

The organization of the requirements has been made in the following levels (see Figure 2)::

  • Customer Requirements (Role of the Customer)
  • System-specification (Role of the SW-Architect)
  • (Software-)Module- and Operation-specification (Role of the developer).

The linking should be defined fixed from the lower level to the next highest level, as a “Satisfies” relationship.

A specification should always have one or more relationships with overlying specifications or requirements. Also links from the resulting software or the source code to the specifications are required here. This makes it clear which code section is used to implement which request (s).

The RXF-Cert comes with a Rhapsody UML model. In addition to the module specification and implementation with the associated code generation, this also contains visualizations of the architecture and of scenarios for more complex processes. In case of a certification diagrams bring the advantage that an auditor can more quickly grasp the construction and implementation of the software. Model elements should also have links to the specifications here.

To create representations for requests in UML tools, there are, for example, the IBM Rational Rhapsody Gateway tools [5] and the Willert ReqXChanger [6] tools. For the RXF-Cert the ReqXChanger, developed by Willert Software Tools, is used that connects e.g. Polarion via the standardized Requirements Interchange Format (ReqIF) and directly supports Rhapsody. Thus, representations for UML elements are also created in the requirements management tool and related to the associated requirements. The associated workflow is visualized later in the document in Figure 5

 

Ensuring functionality through Testing

Certification also requires proof that the functionality is being verified by testing. In a first RXF-Cert project, unit tests and code coverage analyzes were conducted on the basis of manually written C test cases and the gcov tool (from the gcc package) [7] in a test environment. Currently, the effort has been greatly reduced by using the model-based Test-tool BTC TestConductor [8]. In addition, these tests are also performed on the hardware of the target system instead of a PC environment. The results are returned to the test model from the target environment (see Figures 3 and 4).

The test case specification for the unit tests has been linked in the UML model with the implementations of the modules, so that also the test specifications from the model are mirrored in the requirements management tool and in conjunction with the specifications, herewith also a cover and Impact analysis up to the unit tests possible (see Figure 1).

Test Conductor

Figure 3 – Test execution on the target with feedback of the test results into the test model.

Coverage

Figure 4 – Results of the Code Coverage Analysis on the target environment

Cross-phase coverage and impact analysis

Coverage analyzes are important in order to determine, for example, whether all requirements have a test or whether all requirements are linked with software elements. In the approach presented above, coverage analyzes of the UML model can also be performed. From this documents can be generated that can be presented to an auditor.

Impact analyzes are necessary if, for example, requirements are changed during development. One goal is to be able to determine through all levels what needs to be adjusted as a requirement changes. The ReqXChanger can mark changed requests with stereotypes when retransferring requests to the UML tool (see Figure 6). For the certification process, it can be ensured that the software always takes into account the current state of the requirements.

Preparation of documents for certification

Traceability

Figure 5 – Exchange between UML Model und requirement Management

Impact Analysis

Figure 6 – Changed Requirement / Specification obtains Stereotype “Changed” in the model

Creating Certification Documents

From the standard it can be extracted which documentation components are expected. However, combining these into suitable documents and maintaining them involves some work. It therefore makes sense to create an overview document of all delivered goods. Here are source texts, documents and other artifacts of the delivery described and clearly identified including the consistent version numbers. The basics also include adding structure elements to each document, such as a table of contents with page references, a version history, and a cover page with the unique identifier and version. Likewise, a page number indicating the total number of pages on each page in order to be able to verify the completeness.

When recording the requirements, it should be noted from the outset that the corresponding documents must be created for certification. Printing the documents from our internal requirements management with Polarion in an appropriate form requires a lot of effort. The documents managed in Polarion itself can not be used to print the specifications if the links and thus the traceability should also be printed. It is not possible to filter only for specific link types or links to desired targets in the view. One of the consequences of this is that requirements list a relation to the IDs of their chapter headings (these have a hierarchical relationship in the document to each other). A certifier will now stumble upon references that he can not find because headings in the references show the Polarion internal ID, but the header itself does not display an ID. It is therefore strongly recommended that when selecting a tool it is taken into account that it can generate the documents accordingly or how to configure it accordingly. Also with Polarion it is possible via wiki or info pages to prepare the documents for printing accordingly.

Conducting (internal) Reviews

The review of the specification and elements of the software should be done in the requirements management tool. It is helpful to specify that for a “review attribute” (here: “status”) of work items (eg requirements) certain values ​​can only be set one after the other (see Figure 7).

Req Review.png

For the “Specify action”, Polarion has been configured to invite specified users to “approve” the work items. Here are two responsible persons. Only when these persons have both given their “Approval”, a status transition to “Reviewed” is possible. This fact is explained in the supplied validation plan and thus ensures the four-eyes principle in the review process.

Also reviews of models can be managed with this mechanism. In addition, the module specifications specify which SVN revision number (of a checked-in model unit) a review was carried out for. For new revisions, new reviews must be made accordingly.

At the code level, we have had good experience with the Crucible tool [9] and have created a PDF export plugin there that can be used to create code review reports suitable for certification.

Evaluation by a certification consultant

In order to assess the described status independently, we have obtained an evaluation of our procedure by an external certification consultant. This has brought many valuable experience. Among other things, we understood better what content and documents are required by the standard. For example, A security officer must be named in the company, who of course also lives up to his task, and there must be a corporate policy statement on the handling of software security in a “Safety Policy” document.

We have received a lot of positive feedback on the approach and process in development, as well as the approach to meeting the standard. For us in the consultation also the large difference in the standard, whether something is certified as software or as a tool (tool), clear. When you certify a tool, you only have to deal with about one-tenth of the IEC 61508 requirements than with a complete software certification. Nevertheless, we strive to classify our RXF-Cert as software in general. This must also be clearly documented and the user should be made aware of the field of application. If our RXF-Cert were e.g. Not only supporting the development of software, but also the systems engineering, would be added to several other requirements.

In conclusion, we still see the effort associated with certifying software as considerable – but it also shows for us that the requirements of the standard are absolutely meaningful. The development process becomes more sophisticated, the software quality can improve significantly and almost as a by-product the software becomes certifiable.

Passed certifications

The RXF-Cert has now been deployed in several functional safety software projects along with the customer applications. The areas Railway, Automotive and Space are represented. Some of these projects have already successfully passed the certification with the RXF-Cert package, others are currently or will only be in the project status in which the certification will be carried out in the near future. Thus, it has already been shown that the general procedure, meaningful use of tools and careful work steps described in this Techletter make it possible to plan and implement certification according to a standard based on IEC 61508.

Referenced Tools

[1] Willert RXF-Cert, Framework for modeling and code-generation of safety-critical Software:
https://www.willert.de/uml-rxf-cert

[2] IBM Rational Rhapsody, UML-Tool:
https://www.willert.de/rhapsody

[3] IBM Rational DOORS®, Requirements Management:
     https://www.willert.de/doors

[4] Siemens Polarion, Application Lifecycle Management:
https://www.willert.de/polarion/

[5] IBM Rational Rhapsody Gateway, Tool for the exchange and trace of Requirements:
https://www.willert.de/gateway

[6] Willert ReqXChanger, Tool for the exchange and trace of Requirements:
https://www.willert.de/reqxchanger

[7] gcov (from the gcc package), Open Source Tool for Code Coverage Analysis:
https://gcc.gnu.org/onlinedocs/gcc/Gcov.html

[8] IBM Rational TestConductor, Model-based Testing:
http://www.willert.de/testconductor/

[9] Atlassian Crucible, Code Review Tool:
https://de.atlassian.com/software/crucible

 

Happy Modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)
Eike Römer (eroemer@willert.de)

 

 

Nantes – Jules Verne

Introduction

The coolest thing about traveling: you always learn new stuff. Not necessarily about modeling but also about the cities and countries that you visit. I had to do work in the nice city of Nantes in France for 3 days. Nantes is about 1000km through the air and a lot more in a car or by train so we took the plane.
When flying, you have the choice when you’re on location, hire a car or use public transportation.
I’ve been to Nantes before and I remembered that they had Uber there and that the traffic is not really “my style” so I decided to do that. The Uber driver told us a lot about Nantes and one of its famous inhabitants: Jules Verne. There is even a museum there. Also there is a warship museum in the harbor where the film “??” was recorded. Not that we had time for that… but nice to know for the next visit.

What Diagram shall I use?

As long as you use UML to document your software, it does not really matter which Diagram you use for what. It does not even matter if you use the UML correctly. Or even worse, you don’t know while you cannot check if you use the UML correctly. At least in Rhapsody you can generate code to check if your model does what you specified. But there is enough left to do wrong… you can only generate code from Class-, Object-, Package-, State-machine- and activity Diagrams.

Admitted, the UML is not clear on when to use what diagram. The argument for not having that is that it is a programming language. “C does not tell you when to you which statement either”. Correct but if someone else does something in a certain way, that does not force me to do the same….

So the UML lacks a “process” that divides your development in stages with deliverables and rules on what to use when and how.

V-Model

The V-model is still used widely in software development. As it should be because it is a proven way to develop software. The exact way it is used changed over the last decades. From a waterfall model where each stage was finished completely before starting the next to the agile process we use now that makes the V-model more a system where you store your development artifacts.

Process

There are numerous processes that describe how to develop software. Some of them are more common and some of them specify UML or even Rhapsody specific, like IBM’s Harmony. Older processes are still used like RUP from rational, Ropes from Bruce and many more like Automotive Spice (a-spice)
You don’t need to try and follow these processes, you can use them to describe your own process. How thorough you do that is mostly depending on the safety level of your software. Railway systems or cars or planes have huge processes that require really thoroughly described steps.

Requirements

When you don’t know what to do, you cannot do it. So you first have to be clear on what it is that you are building. This is a difficult part for experienced software developers… We (Yes I am a software developer…) are very solution oriented. If somebody describes a problem to us we immediately start to think solution. Write down the real requirements of your product. Concentrate on “What do I need” not on “How do I do that”. You can use a Requirements Management Tool like DOORS (Next) or Polarion or even Word or Excel (Not good for linking and traceability but will work)

May be you are lucky and you will receive the requirements from your stakeholder, like in the Automotive industry.

Then import the requirements in your UML model. In Rhapsody you can use either the Gateway of the Willert RequirementXChanger. These tools will create a package with your requirements. They can even synchronize them if the requirements change and mark the changed requirements accordingly so you can do impact analysis on changes.

What diagram should you use for requirements? That is a good question since the UML does not know a requirement diagram. There are a couple of possibilities in Rhapsody, you can stereotype an OMD (Object Model Diagram) as a new term “Requirement Diagram”. Very elegant way, Rhapsody creates a category for new Terms so that you see them as a folder in the browser. Another possibility is to not show the requirements on diagrams but to create a table where you have the requirements on one axis and your linked model elements on the other. Have a dependency with “trace” stereotype as cell item and you can link requirements very easily. Also possible is to drag your requirements in the diagrams where you have the model elements that you want to link. This will make your diagrams messy but there is a solution for that too! You can apply filters (actually queries) to your diagrams and blend out certain elements.

Analysis

The next step is to analyze your requirements and create diagrams where you extract behavior.
The Diagram of choice here is a Sequence Diagram (At least that is my opinion) The nice thing about Sequence Diagrams is:

  • Even non-techies understand SD’s
  • They are easy to draw
  • They can be used for tests!

You just start drawing the first diagram by treating your system as a black-box, defining what output you expect for certain input. You then create new SD’s by refining the first one  in horizontal way (splitting up the system in sub-systems, then sub-sub-systems until you are at Class level) and vertical way (split the functions in sub-functions and so on…)
You can use Class Diagrams (Or Object Model Diagrams) to already start drawing your system architecture that you find out when drawing the SD’s.
Some use Activity Diagrams or even State-charts for this part. There is nothing against that, I just don’t like it. Activity Diagrams are more or less OK but I think State-charts are just too complicated and distract your mind too much during analysing your system. Also if you need to speak with non-technical people about the exact requirements of the system, State-charts are much less “natural” to use.

Design/Implementation

Here you use the same diagrams as in the Analysis and now it is time for state-machines. Together with the state-machines you start creating tests for all your sequence diagrams, in that way you can immediately test if what you have created is correct. And even better: you can do so whenever you have made changes.
This allows you to do Analysis/Design/Implementation in a sort of spiral model. Just keep adding small pieces of functionality, keep starting automated tests (using Test Conductor) and you always have a working system.

Some pictures from Nantes

That’s it for today, happy modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

O….M….G….

The OMG is the keeper of (amongst others) the UML and SysML standard. Today they have released the UML 2.5.1, a relatively small release. As far as I know there are no immediate plans for a UML 2.6 nor a UML 3.0.

The changes are not shocking and you will probably not even notice it. But I wanted to give you a small look into the factory of the standard.

You can read about this on the website of the OMG ( http://www.omg.org ) but also on the special UML website: ( http://www.uml.org )

In spite of what most people think: the standard is much more readable than you would expect. Not all of it, there are “boring” parts in there but it is readable and it can answer your questions on how to apply the UML to your development.

Interesting Articles

This is an article telling about the UML. Where does it come from, what does it do, how should you use it.  http://www.uml.org/what-is-uml.htm

The past, present and future of visual modeling: http://www.uml.org/Visual_Modeling.pdf

The UML Specification: http://www.omg.org/spec/UML

Happy Modeling with UML (and SysML!) in Rhapsody!

Walter van der Heiden ( wvdheiden@willert.de )

State-chart

USA

Screen Shot 2017-10-22 at 13.35.47

Table of states visited

My first visit to the US was in november 1999. I had to be in Salt Lake City for work and took the opportunity to visit my friend Arno, who lived in Philadelphia back then. He worked in DC and I flew there to drive with him to Philly.
From there I went to Utah but  on the way back I took a small stop in New York to complete a real cool trip with a visit to already a number of states.

Cancelled flight

From that moment on I flew to the US almost once a year on average. And kept on visiting states. In 2004 I was on the way to Las Vegas together with Andreas Willert for the I-Logix Kick-Off Event. We booked the flight from Amsterdam via Minneapolis. We travelled a few days before the conference and wanted to drive around Las Vegas to see some of the Parks there. I already booked a hotel for the first night in Vegas and we planned on driving around and find ourselves places to stay on the go.
Unfortunately, KLM/North-West were not able to produce a working plane on the day we were supposed to fly so we had a forced night out in Amsterdam.
I phoned the hotel in LV to shift our stay for one day, just to find out that the next night was “Superbowl night” and the hotel price would not be $49,- but $249,-…
So I told the to shove their room somewhere dark and let KLM deal with it. It was their fault. (But my problem……as I found out later)
Luckily a have a friend who lives in “020”(As we from Rotterdam call our Capital, it’s the telephone area code) guided us through the city and after some beers (and some more) the next day we stood, slightly hangovered, before the KLM desk to get a room in LV for the next night.
They could not help us, this would have to be sorted out in Minneapolis they said.
So we first flew to Minnesota and went to the KLM desk over there to find out how they planned to get us in LV. It turned out to be a quite late flight that would arrive in LV on 00:30. They also told us to sort the hotel thing out when we arrived in Las Vegas.
This is where I intervened and said: no way I fly to LV without a hotel room.
So after some negotiations KLM booked us a room in Minneapolis and we rented a car to drive to LV because: What’s the difference? We wanted to drive around in LV and now we were driving around in the USA. No difference?

A small difference…

As it turned out, there was a small difference. We landed in Minneapolis, we noticed that it was snowing there. What we first noticed after we rented a car and went to five (5!) sliding doors to pick up our rental car. After each door the temperature dropped for more than 10ºC….
It was cold there. And I mean really cold. On the way to the hotel we were overtaken by a snowmobile. That was the first time I saw a sno-bolie in my entire life….
In the hotel we watched television just to find out that the USA was in something they called “The Blizzard of the Century”….
So the driving thing turned out to be a so-called “Bad Idea”
( “Bad Idea” is a trademark of  Microsoft Corporation )
So we decided to drive south as soon as possible to find better weather and to avoid going through the Rocky Mountains where this would certainly be worse.
So we did 3500 kilometers USA with at least 95% of that through the snow. Even on the Grand Canyon there was 50cm of snow. We have seen more crashed trucks and cars than in the rest of my life.
But we arrived in LV where is was nice and warm. And we passed about 12 states on the go.

State Count

As you can see in the state-chart, my current state count is 33, I hope that the next trip will bring me at least 2 more.

State-machines

OK, now a little about UML and Rhapsody. State-charts or state-machines are an important part of UML but certainly of Rhapsody. This, of course, stems from the fact that Mr. State-machine, David Harel, is the founder of I-Logix, and one of the fathers of Rhapsody and Statemate, it’s predecessor.
Although it is said that David Harel invented state-machines, this is not true, he merely described them thoroughly for the first time. His definition was taken into the UML.
There are many more implementations and definitions of state-machines.

State-machines are excellent when you implement behavior that has discrete logic. For Control loops, it may look tempting to use a state-chart but that is a mistake. There are far better mechanisms to model continuous behavior.

Example

Picture: You have a new job at the software department of “El Cheapo” a manufacturer of computer LCD monitors, known for it’s really good value for money displays.
Your new boss gives you the assignment to make the software for a new monitor that El Cheapo will release soon. The monitor is aimed at the lower end of the market so it has only 4 buttons: one for on/off, one for switching between brightness and contrast and 2 to control whatever you have selected (plus and minus)
You remember from your last job that you had a UML Training with Rhapsody (from some Dutch guy…) and decide to use that for your new job.
After 2 hours of thinking you have your first version ready:

Monitor Statechart

Not bad for a new guy, you think and you are on your way to your boss to tell him about your success.

Your boss is impressed until he starts asking you about the “evMode”, “evDown” and “evUp”. “Where are these events coming from?” he asks.
“Easy”, you say, “The hardware guys have to send these events from the button interrupts when they program the hardware drivers”.
Your new boss starts rolling his eyes and drops backwards back in his chair. “INTERRUPTS???” he shouts! “No interrupts allowed over here!”. “Do you have any idea how dangerous interrupts are??”.
You ask: “But how do you detect that buttons are pressed then?”. “The safe way”, your boss replies, “by polling all inputs every 100 milliseconds”. “Sigh”, you think.
But no matter how you try to explain that this is so wrong, you are eventually forced to curb your enthusiasm and go back to the drawing board.

But… you never give up without a fight and you come back with another plan. You have learned in your Rhapsody Training (from that vague Dutch guy…) that you can tweak the generated code from Rhapsody using properties (see Properties. Stairway to heaven, highway to hell….) and you start tweaking the state-chart. You ignore the Framework (see Real-Time Framework, the robust base for your embedded applications. ) and you come up with this solution:

Monitor Statechart 2

All events are replaced by guards. The state-chart code is now tweaked so that the generated function (rootstate_dispatchevent() ) can be called by the 100mS loop.
Some quick tests prove that this also works and now without interrupts.

Really???

Is the second state-chart really a functional copy of the first?

NO!!! it is not. In this example nobody would notice because 100mS is fast enough to fool humans. But suppose you press both the “mode” and the “up” button within the 100mS time frame. Which one is pressed first?
You can never know since you were not looking. The first state-chart knows while that uses interrupts and the framework. Events are stored in the queue and processed according to the FIFO principle.

You have to choose which of the variables “mode”, “up”, and “down” has the highest priority. And react to that. So the state-machine should actually look like this:
That is the big difference between these methods.

You have to take the priority into account and then create the state-chart like this:

Monitor Statechart 3

If I show this state-chart during training, people tell me: “Walter… you always told us to use state-charts because they make it easier to understand your application.”, “This is not understandable”.
And they are right… this is not what I call a good and understandable state-chart. It’s a chaos. I checked it multiple times but I’m still not convinced that it is really 100% OK…

An easier way!

What!!?!! there is an easier way? Yes, there is… This is actually the state-chart that does the exact same as the one above here.

Monitor Statechart 4

Does that state-chart remind you of something? Another diagram maybe?

It should… It is an activity diagram. Or flow chart (As the activity diagram of an operation is called in Rhapsody). Check it out here:

activityDiagram

An activity diagram…. does the exact same that the state-chart does. And.. If you compare the LOC (Lines Of Code) you will see that the real state-chart (the first example with the events) uses more code then the activity diagram but it is more correct. The other examples (And certainly the incomprehensible one) use way more code and are much slower!

Conclusion

Use state-charts when you have discrete logic. For continuous logic or polling solutions: use activity diagrams or flow charts. Or use Matlab Simulink for control loops.

That’s it for today, happy modeling with Rhapsody

Walter van der Heiden (wvdheiden@willert.de)

 

Divide and Conquer

Introduction

As I always tell the people who attend my UML Trainings: without using Classes and Objects to split up the work your application must do, it is impossible to handle todays complexity.

Programming used to be easy, in the early days of computers and the early days of embedded. The first boards had small controllers on them that had a few kilobytes of ROM memory and a few bytes of RAM.

Getting these to work from scratch involved a day of reading some stuff and applying power to the board, then your first blinking LED was reality. (and how cool it was..)

Later using 16-bit controllers, still with Kilobytes but now more than a few,  but using ‘C’ instead of Assembler, this was already complex. Could take a few days to get the first stuff running. (Not to forget that you had to learn ‘C’ as well…

With UML the initial effort increases again, you have to learn UML, ‘C’ (or ‘C++’ ) and you have to install a lot more stuff. But this is also doable and after the initial effort you’ll notice that things go faster.

The complexity, however, is still increasing and the only way to master it will be to re-use existing stuff. This is only possible if we have “designed for re-use”.

 

Modeling or Programming?

That is the question. The difference is not clear to people who use Rhapsody for the first time, it is, however, crucial for the way you use your models and how you do the implementation. So just breaking up in multiple Classes and Objects is no longer sufficient, you need to be able to divide your models in “Components” that can be re-used without having to look deeply into them to understand what they do.

Rhapsody supports a couple of ways to do that in your model. You can use (parts of) other models. In the menu you have “File”, “Add to Model”.

Then a menu pops up that lets you select a Rhapsody model (Or a file in a model, i.e. a Unit like a Package or a Component) You can also select “As unit (with a “copy” tick) or as reference.

  • As Reference, links the selected model element in the open model as a read-only reference. (Same GUIDs) You cannot edit the element in your Rhapsody model, you have to open the original model for that.
  • As Unit, links the selected model element in the open model as a writable reference. (Same GUIDs) You can edit the element in your Rhapsody model and it will then change the original model as well.
  • As Unit (with copy) copies the selected model element in the open model. (New GUIDs) You can change the element in your Rhapsody model but the original element will be left untouched.

GUIDs are the generated 128-bit ID’s that Rhapsody assigns to every Model element. Rhapsody uses the GUID to recognize model elements (It does NOT use the name for that!) So copying renews the GUIDs so there will be no name clashes with existing model elements.

Now try to model as independent as possible by using only unidirectional relations, eventually ports and interfaces. Use private attributes and operations when possible, at least describe the public interface as good as possible so re-use is easier while the re-user does not have to study the inside of your model.

 

Attention points.

  • Paths. If you use referenced model elements, be sure that they are in the right path on all computers of all project members… Otherwise check-in  and -out will be a torture. You have to manually adapt the paths in your model. It helps to use relative paths in your model

    General::Model::ReferenceUnitPath
    General::Model::PathInProjectList
    can be helpful there. You might also use an Environment variable to point to your working directory and sync that with your colleagues. (Like the OMROOT variable that Rhapsody uses to make it independent where your Rhapsody Share directory is)

  • Config Management. If you check in and out models and parts of models, it is easy to fetch a wrong version of a referenced model. Think about your CM structure!
  • Names. Don’t use default names like “default” for the package, etc. Use meaningful names that can be used in their projects without causing collisions.
  • Documentation. Is even more important when your model is re-used inside other models.

Tips and Tricks

  • As long as you make changes in your model _and_ in the referenced model, load both models in a project (Using “File”, “Insert Project”. You have to switch the active project to make changes but it will reduce time. Rhapsody saves the Workspace separately! (You can even edit it if you make changes to your paths)
  • Using Ports and Interfaces greatly improve the way you can use models in models.
  • There are more ways to create Interfaces, see my Techletter about using Interfaces.

 

Dividing up your models.

If you have made a model that represents the hardware you use in multiple projects, you can easily use that model in all projects that use the same hardware. The nice thing is that if you have your version system right (perhaps even with a check in the model..) and really defined your interfaces, then you can use different versions of the hardware without really worrying about you model.
Another advantage is that referenced model load faster.

 

That’s it! Happy modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

Virtual Open Space

What is that????

openspace

Open Space is a way to organize meetings and congresses invented by Harrison Owen.

Basically it is a meeting where there you define time/space slots and where all attendees can bring in topics. These topics are connected to a certain room and time, this is done on a board where everybody can see the topics and can apply to join the meeting on that topic.

The organizer will be in the designated room and time to start  the meeting, he.she will also take care that minutes are being made so that others that could not be present ( e.g. because there was another interesting topic in another room) can still read what was discussed afterwards. There is some more to it, when you want to read more:

Open Space on Wikipedia

We always use that for our own events and it is a very successful way to communicate with clients. The disadvantage, however, is that physical presence is required.

In the current time where we care about energy and environment, this is not what we want. So we invented “Virtual Open Space”, where we do an Open Space Meeting using modern technology.

We use doodle to find out what the topic is that people want to talk about, we then use WebEx to create a “virtual” room on the internet where people can speak with each other and, when necessary, share their screens with others.

Check out: Willert Open Space.

This weeks topic: UML debugging!

Happy Modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

 

Don’t let the bedbugs bite…..

Introduction

Using UML and Rhapsody to develop software is a very good way to cope with increasing complexity. The ultimate usage of Rhapsody is using the code generator to generate production code.

Although using UML makes it much easier to maintain an overview over the software, it is still no guarantee for error-free software.

So even in Model Driven Development there is point where there is need for a debugger.

Rhapsody offers a few ways to debug the generated software.

  1. Using Rhapsody Developer and Animation, basically generate code with instrumentation
  2. Using a source code debugger provided by the compiler
  3. Using the Willert Embedded UML Target Debugger

The first solution is directly connected to the use of the Rhapsody Developer, a license that is not generally available. It is also available in the Rhapsody Architect for System Engineers (Designer) which is often used by System Designers. In fact, the Designer can ONLY generate instrumented code.

This is a very comfortable way to debug UML Models, Animation can show „Live“ State-charts, trace Sequence Diagrams and much more. There is, however, a price to be paid for this comfort.

Animation uses a TCP/IP connection and does a lot of communication, also the Code Instrumentation uses an incredible amount of RAM and ROM. This makes it unsuitable for small targets.

Of course it is possible to create models that will be runnable on both PC and embedded target, this is not always easy and allows you to only debug the logic of your software.

When doing Systems Engineering this is mostly exactly what is needed and Animation is very suitable for that.

Using a source code debugger is possible but it requires deep knowledge of the generated source code and the used Framework. Also, the use of object orientation is making debugging in a classic way more difficult. (When using multiple objects, a breakpoint tells you where you are in the code but not in which object.)

A great way to debug is using the WST Embedded UML Target Debugger., short: TD.

What is the TD

The TD, the Willert Software Tools Embedded UML Target Debugger is a tool for debugging UML Models on a model level. It consists of 2 parts:

– The Monitor

The WST RXF has a small monitor built-in that will transport information about what is happening inside the framework to your PC.

– The Target Debugger GUI

TDWorkingTakes the information from the monitor and presents that in the form of UML Diagrams using symbolic information from an XML file that is generated during code generation.

In the process of creating the new version of the framework we also redesigned the TD from the bottom up. The Code is made with Rhapsody (Quote George Clooney: what else…) and the Qt Framework from Willert.

What can the TD do?

It can draw 2 types of UML diagrams: Timing Diagrams and Sequence Diagrams. These diagrams are drawn from the information that the target provides. They provide you with enough information to see what your system is doing.

  • Breakpoints
    Intelligent breakpoints can be used to allow stopping when you need it. The diagrams will then provide you with the correct information.
  • Filters (Host/Target)
    You can filter what information you want to see, dynamically on the host (The diagrams will be re-drawn with the requested information) but also on the target (Only the requested information will be sent, saving valuable resources)
  • Event injection
    Use the TD for your own testing by sending events to your target. You can also predefine sequences of events to be sent to easy do test sequences.
  • Test Conductor integration
    Use the Test Conductor together with the TD to automatically run tests e.g. for nightly testing.
  • Multiple targets
    It is possible to use multiple targets to debug larger systems consisting of multiple components. Synchronize the time between the targets with one button.

The Target debugger is included in the RXF, it must be adapted to your environment and your communication interface. But it can save you loads of time debugging and testing.

Happy Modeling (and Debugging) with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

Reverse, forward or roundtrip?

What is it anyway?

Let me start by specifying what I mean when I say: reverse engineering, roundtrip engineering and forward engineering. All in the context of UML and Rhapsody of course.

  • Reverse Engineering: Reading in existing source code and inserting it in a Rhapsody model in such a way that it continues to work.
  • Roundtrip Engineering: Reading in source code that was generated by Rhapsody but was changed by the user. Note!: Please understand the difference between reverse and roundtrip! It is very different for Rhapsody to read in “strange” code then it is to read in “familiar” code.
  • Forward Engineering: Something I invented myself (Or maybe it already exists then I just re-invented it…)  It is reverse engineering but the user will take the result and do the necessary steps to make a decent UML Model out of it.

So. As I already wrote in a previous post, I don’t like reverse engineering. Sometimes you need to do it but it is something that prevents good modeling IMHO.
Roundtrip Engineering is OK although Rhapsody knows 3 modes there: Basic, Advanced and Respect.

  • Basic: Allows you to change code that is between the Rhapsody generated comments: /*#[ and #]*/ That is the code that you type in state-chart entry/exit/transition and in the implementation body of your operations. Nothing else, changes to other parts will be ignored when Rhapsody generates new code. Is not trivial since Rhapsody sometimes uses the same code twice and will then ignore your changes! (Of course without commenting it…. Rhapsody is a tool for real men…) ***Recommended Setting***
  • Advanced: Same as Basic but also allows you to add attributes and operations. Is also OK if you know what you are doing but keep way from it until you know what the effects are of what you change.
  • Respect: The “Evil Knievel” option. Or “Eddy the Eagle” if you prefer him. This allows you to change every line in the generated code. Rhapsody will try to keep it as long as it is syntactically OK. To make things worse, Rhapsody will store this information in “source artifacts” that are hidden by default. (I still wonder which sadistically inclined person designed that option….) ***Not Recommended at all Setting***. At least switch on “Show Source Artifacts” (“View”, “Browser Display Options”, “Show Source Artifacts”).

So you have to be careful using these options. This is all more valid for ‘C’ then it is for other languages like ‘C++’ and Java, these languages are much closer to the UML and can therefore produce much better results when doing reverse or roundtrip engineering!

LCD Display on the Keil MCB1700 Board

We use that board for our trainings. We do this since years and we use the LCD display on that board using some ‘C’ files that Keil provides. GLCD.C and GLCD.H. Here are these files: GLCD so you can check yourself.

The .h file has function prototypes (Useful for checking which functions are “public”!) and the defines for the colors. Reverse engineering will show these as types.

The .c file contains a couple of defines that are reverse engineered just as the all the defines in the .h file. Then there are all the functions. After examining the functions we can see that there are “public” functions (GLCD_xxxx() ) and “private” functions (spi_)

In the training we include glcd.h via the “external file” mechanism and the dependency with “Usage” stereotype. Glcd.c is inserted via the Component file and a “text element”. This works fine (And is of course aimed at learning different methods to use legacy code)

Reverse engineering also works, I tried, you can call the functions if you have reverse engineered them.

But we want something else: we want Classes that are completely generated from Rhapsody! So first we will create a class GLCD. Since SPI works a little bit different we will use a Singleton Object there.

Then we move all the functions to the respective class/object. Nice side-effect: the “me-pointer” is added automatically! But unfortunately… not to the code. This is where you have to do some work, add me-> to all uses of the attributes. I have created attributes from a few variables like orientation, bbps and position. You can add them to the init function. That is something that also needs to be done by hand: The init function must be converted into a constructor (initializer)

The SPI functions are moved to the SPI object. No me pointer is needed there but I used the variables that determine the exact version of the LCD hardware to attributes, you have to add the spi.<attribute> yourself.

The colors must be converted to an enum type. A bit of work which cannot be done automatically but it is worth it! (Why this is not done in the original ‘C’-code??)

I added some fine-tuning like converting some variables to enumerations or at least types, always a good habit in programming: let the compiler check as much as possible!

The result is quite nice: RhpGLCD, see for yourself.

Happy modeling with Rhapsody and greetings from the Bavarian Forest!

Walter van der Heiden (wvdheiden@willert.de)

 

Rhapsody Getting Started – part 1.

San José

The second part of this USA trip brings me to San José in California. I am joining the 10th AUTOSAR Conference there. The meeting is held in the Computer Museum in San Jose.
I think that’s pretty cool. Also in the neighborhood are Apple, Google, Tesla, the famous garage of Jobs&the Woz and the HP garage. When there’s time I will take pictures. But we will fly to Detroit very early on Thursday.. so there is only limited time.

San José is nice but very, very expensive. Hotels cost a fortune, the hotels that are affordable are really low-class. The weather is nice, about 20ºC .

 

Introduction

People ask me a lot of times: “Why don’t you write something for “beginners”?”
OK, good point. Let’s do something for beginners.

First: what are we going to do, what are we going to use.

  • Board: Infineon XMC2Go Board
    ARM Cortex M0 – XMC1100, 64k ROM, 16k RAM
  • Keil µVision IDE
    When installed without a license, this acts like an eval version with a 32k size limit: we can live with that! The Willert Frameworks are really small, a Blinky is only a few KiloBytes without optimisation. If optimising it’s just over 1 KiloByte.
  • Keil CMSIS2 RTOS
    Embedded RTOS that implements the CMSIS standard
  • Rhapsody 8.2.1, the latest version
    We use the ‘C’ or the ‘C++’ version. We will cover both languages.
  • Willert RXF for C or C++
    The “general” version of the award-winning Rhapsody Framework.
    includes the UML Target Debugger
  • CygWin/Visual Studio/Eclipse
    Some C/C++ compiler running on a PC, preferably a free one.

Second: The sequence of installing:

  • C/C++-Compiler
  • Keil
  • Rhapsody
  • Willert RXF

See Installing Rhapsody for more info.

Third: What are we going to make?

That’s easy, there is a Hello World equivalent in the embedded world. It’s called Blinky. We let an LED blink on the board, that is about the smallest complete program you can make that still has user interaction.

Getting Started

Now we have installed it all, we can start using the environment to create a project.

First we start Rhapsody. I always like to make a shortcut on the Desktop to have Rhapsody accessible always. In Windows 10 you can pin it to the taskbar. As you can read a in the Installing Rhapsody part, you can influence the version of Rhapsody that is started by adding command line options.

So the version we need to start is Rhapsody Developer in C++. You can start Rhapsody Developer in C if you like, i will describe the differences between these versions.

People that just start with Rhapsody often ask: Why do I have to choose a language when I start a new model? Why can’t I do that later. Well that is because Rhapsody not only generates code, it also accepts your own code that you type in. You can do that in operations that are in classes but also in state-charts and activity diagram actions.

So changing the language after a while would implicate that you would have to change your own code as well. Can be done, but is much work. Also there are differences in the language versions. Rhapsody in C cannot generate code for inheritance (only from Interfaces) and there are mode differences.

Luckily you never switch the programming language that often, where I worked we always decided which one we’d use upfront and stayed with it…

Now that looks pretty empty

Yes, it does. That’s why it’s now time to create a new model. Rhapsody works with models. Models as in representations of the real world not the models from the middle pages of certain magazines… We can open an existing model but for now we will create a complete new one. Can be done in multiple ways;

I don’t use the mouse often so I usually press CTRL-N. Yes, I like the keyboard…. I’m old enough. And now we are outing ourselves anyway: Yes I like VI…. But feel free to use the mouse if you like. You’ll become a small window that asks you to enter 4 things.

  • Name, the name of the model. You’ll notice that Rhapsody adds the name of the model to the path. So it will create a new directory for every model you create.
  • Path, where the model is stored. Non-existing parts of the path will be created (after asking…. after all this is Windows!) only if you create a new directory in the root directory, this cannot be created. It’s not Rhapsody, it’s a Windows relict from the past. Have I already mentioned that I hate Windows?
  • Project type, here you can select a profile to be loaded with the new model. The profiles have to be stored in a Rhapsody directory (and preferably have an accompanying text file with the same name that contains a description)
  • Project settings, almost the same as project type but adds a settings file

You should create a directory that you can find easy, preferably c:\work or something similar. This is the directory to filled in after “Path”. As Project Name you take “Blinky”, as project Type you click on select, then scroll down to the directory “WST_RXF_V7”, in there choose “RXF_CPP_V7”. In the Settings Tab, go to the same directory and choose WSTProfile

If you have filled in everything a new model is created.

OK… Now what?

You see an empty model [picture of Rhapsody GUI]

There are a few area’s on the screen.

  • Menu
  • Browser
  • Diagram area
  • Output Area
  • Drawing Menu

The menu is a partly straightforward, the stuff that visual studio gives you for free, but parts are Rhapsody specific. You can create and open diagrams and do a lot more.

What is the Browser? It is the view to your model. It contains all element of your UML or SysML model. You can select what you see in the browser by using queries, you can from the browser, create and delete model elements. Your Browser View will not be empty, it will contain some default elements and the profiles you have selected when creating the model.

The Diagram Area is logically the view on your diagram. Per default Rhapsody will create and open a diagram for you: An object Model Diagram named “Model1”.

The Output Area is empty until you start doing things like generating, compiling or executing code. Then the output is shown here, beware, it has multiple tabs.

The drawing menu is on the right and contains the elements that can be used on the currently open diagram type. Rhapsody has possibilities to add items to it or to limit the items on the drawing menu.

Repository

Or, as we call it, the browser. When a new model is just created, it contains a few folders.

  • Components, contain what you are actually creating with Rhapsody. Per default it contains a single component: “DefaultComponent”. If you double-click that’s window will open, the Features Window. All Elements in Rhapsody have a feature window, a double-click will open it. Even diagrams have features, only they are not opened with a double click but with a right-click and selecting “Features”. A double click on a diagram will of course open that diagram. The first tab contains the name and type (library, executable or other”.The second has a “Scope” that lets you select what other UML elements are part of this component.
    Under a component there is at least one “Configuration” (Default: DefaultConfiguration” . This contains the information about the target environment.
  • Object Model Diagrams, normally all diagrams are located under a package, like all other UML elements. But to make a model better accessible for others we need diagrams on the top-level to assure an entry in the model. You can (Actually you should…) add navigation info to allow for traversing the model from there.
  • Packages, the base of your UML Model. Packages are nothing more than folders, however they have influence on the generated code, some elements will be generated inside .c (or .cpp) and .h. You can organize your work by dividing it in packages and sub-packages. And sub-sub-packages, and sub-sub-sub-packages, and… you get it I guess.
  • Profiles, these are the profiles that were loaded when we selected our project type. It is, of course possible to load more profiles after you have created the model. Just use “File”, “Add Profile to Model”. Profiles are used to transfer a lot of properties in one go but also to include certain information in the model.
  • Settings, about the same as profiles, technically there is no difference. Then why? Beats me….

C or C++?

What is the difference between Rhapsody in C and in C++? There are a few differences which I will explain but there is also a lot that is the same. You can draw exactly the same elements, the generated code will differ. Also the code that you enter must be equal to the chosen language otherwise nothing will work.

‘C++’ is of course closer to the UML. It already has classes, OO, inheritance and a lot more. But Rhapsody in ‘C’ also offers OO. Here you see the same class code, in ‘C’ and in ‘C++’.

The Object orientation in C is done by using a struct to mimic a class. (Private members are not really private there, unfortunately.But in Rhapsody, the get and set methods are used to implement private, public and (only in ‘C++) protected.
Functions have the name of the class as prefix to prevent linking problems when 2 classes have the same functions. Private functions have only the name of the function and are “static” which makes them really private.
All functions have a “class * me” as first parameter to have access to the objects attributes.
Calling a function in C++: object->function();
Calling the same in C: class_function(object);

So. That was the start. Happy modeling with Rhapsody and see you in part 2!

Walter van der Heiden (wvdheiden@willert.de)

Code-centric vs Model-centric Development with Rhapsody.

Keep on dreaming…..

On the phone with a customer I noticed that the customer was disappointed in Rhapsody and in its ability to handle C source code that was externally written.
I always find it very difficult to deal with people who are not happy with the tools we sold them. But yes, it does happen sometimes and unfortunately, this was no different.

This particular customer wanted to use Rhapsody to more or less monitor his coding in C and in the meantime draw diagrams that represent his documentation. And also when it fitted better he wanted to draw in Rhapsody and then generate the C code according to his coding standard.
I never promised that such a scenario would work, I’m very sure, but this is what the customer understood from my words in earlier visits before buying.
I think that is OK, I am not offended, nor angry, nor do I take it personally. Customers are just as human as I am. I also hear what I want to hear and interpret until it’s right for me.
So, I do hear the ice cream man say: “I will be in your street today” and I do not hear him add: “but I wont be stopping…..” No problem.

The problem is that it I hate it when my customers are unhappy and I would like to change that but it I find it very difficult to transfer the correct information to a future customer during the sales process. Let’s give it a try here…

The truth, the whole truth and nothing but the truth.

NO! It is NOT possible! You cannot use Rhapsody and just continue coding C or C++ (or even Java).
Well… not entirely…. You can do some of that.
Is it any good? No, it’s not. Well.. it is OK but not more than that. If you just want to understand your fuzzy written code and expect Rhapsody to generate perfect UML diagrams so that you can understand some spaghetti code that you found on your hard disk: Keep on Dreaming. Never gonna happen.

As I always say: Reverse Engineering is a GiGo Process: Garbage in, Garbage out. There is no way that you can automatically make the incomprehensible understandable.
That is perfectly OK, badly written code should be re-designed and re-made….
(Yes, I know there are programmers that think otherwise…
– It was hard to write, it should be hard to read….
– Better write software with “built-in understandability protection” to ensure your pension plan.
…but I do not agree there…)

Now in C++ or Java the conversion to UML works reasonably well since these languages already support OO like UML does. But even in these languages you have to comply with Rhapsody coding, it is not a simple process. Reverse Engineering for C, however, is a totally different matter.
There are some YouTube movies in the internet describing RE in Rhapsody (see links at the bottom) but for these demo’s they all used Rhapsody in C++.
And there is a reason for that…

But before I tell you what is possible and what not in Rhapsody in C, may I gently remind you that Rhapsody is a UML Tool? Yes!, that is what it was built for. From the beginning in 1996 it was designed from the bottom up to be the worlds greatest UML Tool. And it is!
(It is possible that I am a bit prejudiced here)

For Rhapsody the same applies as for all tools: the best way to become happy with a tool is by using it as closely to the way the creators have intended it. The more you bend the tool to do things your way, the unhappily you will become.

I always tell that to my customers and to my future customers. Always. But funny enough nobody hears it. That is just not what they want to hear. They all want the holy grail of software developers: the tool that does exactly what you want without errors. And there is no such thing, sorry. But, enough ranting, let’s go through what you _can_ do.

(Re-) Using your code in Rhapsody

Basically there are 3 variants: Code-centric, Model-centric and Code-aware.

Model-centric:

This is the way to use Rhapsody. Your Model is the base of all. Code generation will generate your application. It can be compiled and linked to the framework (RXF) and you have a working application.
Code will be generated from Class and Object Diagrams, Structure Diagrams and from State-machine Diagrams and Activity Diagrams.
Rhapsody also supports flowcharts (Although these are NOT UML!) for the behavioral code of operations.

Code-centric:

Here you use Rhapsody only to visualize your code. You can change the code and Rhapsody can process it to reflect the code in your model and in (some) diagrams.

How does that work?

  1. Switch your Rhapsody to Code-centric. How?
    – When you are working in the Rhapsody Architect for Software your project will be code-centric by default.
    – In Developer (or EUSIII) you can add the CodeCentric profile via the menu “Add Profile to Model”. In the next file selection screen go up one directory and then go to “Settings”. There you will find “CodeCentric” (Or if you have a Willert Install, “CodeCentric_Original) and load the newest file with the correct language)
  2. You can now use “Tools”, “Reverse Engineering” (RE) from the menu to read-in the files that you want to use. Beware!: Starting RE makes changes to Rhapsody that might not be easy to revert.
  3. Things you can (or should) do before using RE:
    • Create a new Component
  4. Your reversed engineered code is now in Rhapsody. How does it look?
    • You will see Packages, Files with variables and functions.
    • These artefacts are NOT UML artefacts, they are introduced by Rhapsody to allow working with code.
  5. Rhapsody will generate OMD’s (Object Model Diagrams) with the structure of your files. If you have a lot of include files this does not really help.
  6. Rhapsody will NOT automatically generate Flow Diagrams (Activity Diagrams for functions). You can ask Rhapsody to do so (Right-click, “Populate FlowChart”).
    remember: there is always just one “leading” source. Either your code or your Diagram. Check your settings.
  7. The best way to use the reversed engineered stuff is to convert it to “decent” Rhapsody elements like classes and objects. It is a bit of work but the result is very helpful.

 

Code-Aware:

The “hybrid” form. Not really supported.

Problems and possible solutions

  • All the code-centric stuff is (current version is 8.2) only useable on 32-bit Rhapsody. 64-bit is improving but not there yet.
  • Don’t expect miracles. If your code sucks, it will suck in Rhapsody as well. No way around it.
  • Be prepared to experiment with re-reading in a new model. Sometimes that clears things.
  • It’s 5 am…. do you know where your properties are? You better…. Check out what is set. Remember: Reverse Engineering sets properties by itself!

More information on YouTube

Gavin Arthurs speaks about Rhapsody mode/code centric:
Gavin on Rhapsody

Fraser Chadburn speaks about Code-centric development in C++:
Fraser on Code-centric

Chris Carson speaks about Code Reuse:
Chris about Code Reuse

Thomas Hall speaks about Reverse Engineering:
Thomas on Reverse Engineering

« Older posts Newer posts »

© 2026 Rhapsody TechBlog

Theme by Anders NorenUp ↑