Check, check, modelcheck….

Introduction

Lots of times I get questions about model checks in Rhapsody. First of all if Rhapsody does model checks, the short answer here is: yes.
The longer answer is that Rhapsody does not check much, just if there are no errors in the model that prevent code generation.
You can start model check by hand (Menu: “Tools”, “Check Model”, “<<Configuration Name>>”. This will start a better Model Checker.
Does that check your complete model? Short answer: Yes. Long answer: Not exactly….
It does some checks like if you have added a description to your model elements and if you have changed the default names (Class_01, etc) But nothing more.
If you want more thorough checks you have to provide them yourself. This is not as bad as it sounds, the UML is a language, it is very difficult to check if somebody is using it in the wrong way.
If you want to check something you first have to define your model guide lines. How do you want to model. Then you can define how you want to check that.

Java API

Rhapsody has a Java API that allows you to (almost) completely control Rhapsody from extern.
You can use that to check the model, convert model elements, generate code and much more.
For check model you need to extend the model check interface and implement checks. Via the API you can walk through the model selecting elements based on type/name/position in the Browser Tree. You can access all information from the model and even change it when you like.
Same thing for Code Generation, you can, of course, walk the model and generate your won code but you can also instruct Rhapsody to call your Java functions when Rhapsody is ready generating code. We call that the Simplifier, Rhapsody will first take your model and generate a simplified model You can make that visible by setting: CPP_CG::Configuration::ShowCgSimplifiedModelPackage to TRUE.

Oh no… not Eclipse….

Yes… this works with Eclipse. Eclipse and I have a difficult relationship… We don’t like each other. It is getting better last years… but still not as easy as other IDEs.
You just create an Eclipse Java Project and you go to the properties of your project. Open the Java Build Path tab, then in Libraries open “Add External JARs”, now select the Rhapsody.jar file in “Share/JavaApi” . That’s all… should work now.

The Check

First Ccreate a project (e.g. CustomChecksHelper). You can then create a class (e.g. CheckPlugin) that needs an entry point function:
RhpPluginInit (IRPApplication rpApp)
that will be called by Rhapsody. You can then instantiate all checks that you have made, all the classes that do checks have to extend RPExternalCheck and have to override the
check( IRPModelElement elem, IRPCollection failElem)
function.

Helper

Rhapsody uses “Helper” files to pre-load plugins. That makes them faster and immediately available. Therefor create a file under Share\Helpers with .hep as extension. The syntax of that file is quite cryptic, I always have to try 3 times before it works… Beware if you already have helpers then the numbers change.

[Helpers]
numberOfElements=1
name1=Checks_Plugin
isPlugin1=1
RhpVersion1=8.4
JavaMainClass1=com.telelogic.helpers.CheckPlugin
JavaClassPath1=$(OMROOT)\Helpers\CustomChecksHelper.jar

OK. That’s it! Have fun checking with Rhapsody!

Walter van der Heiden ( wvdheiden@willert.de )

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.