Sunday 24 May 2020

IBM Rhapsody Tip #78 - Keeping user code consistent using Refactor: Rename

This short (silent) tips and tricks video takes a quick look at the Refactor: Rename dialog, available in IBM Rational Rhapsody when you right-click elements generated into code like types and classes. The key thing is that Refactor: Rename does more than just update references; it's a form of search and replace dialog and will do an update inside user code sections as well. Using the dialog you can review both before and after the rename. This helps you keep user code sections consistent when refactoring names of elements such as classes, operations, types and attributes.

Monday 4 May 2020

Rhapsody 9.0 usability enhancements in the Transition features window

While doing the last video, here's a few things I noticed in the Rhapsody 9.0 release related to usability enhancements (the IBM Engineering Systems Design Rhapsody covers both systems and software engineering).

Firstly, the Guard edit frame on the Transition features window is bigger:

This is 8.4:

This is 9.0:

This is simple, but useful (I don't know about you but I often put a return in the guard so that it shows on a different line in the Statechart).

Secondly, the trigger selection now incorporates an active search capability.

This is 8.4:

This is 9.0:

This new pick-list capability is also present in other dialog's, i.e. it's been working its way through the Rhapsody UI for a releases now.

There's further information on the 9.0 release here.

This bit comes under the "Further enhancements to Combo boxes for model selection: active search on all elements selected" bullet point.

It's nice to see that usability features continue to be thought about, even in the old areas of the UI.

IBM Rhapsody Tip #77 - How to animate user-defined types in sequence diagrams (serialization)

With thousands of properties to explore IBM Rational Rhapsody is a powerful and configurable tool for both systems and software engineering. This short silent tips and tricks video comes at subscriber request!

In the video I use IBM Engineering Systems Design Rhapsody 9.0 but the same works for (most) earlier versions.

Here's the transcript:

This silent video covers how to get Rhapsody to show the value of user-defined types in an animated sequence diagram.Let's first have a look at the model. It's a C++ one I created that sends a couple of argument-carrying events to control a traffic light sequence. These events have arguments typed by an enum type and a struct type.

By default, when we animate these in a sequence diagram then raw, rather than type-aware values are shown. Fortunately, this is can be fixed. Let's look at the easy way first. On the properties for the Type we can set the property CPP_CG::Type::GenerateSerializationFunctions.

With this property set, Rhapsody will automatically generate the magic code needed to show meaningful text values when animating. Serialize is just a fancy way of saying 'convert this type to text'. Unserialize is the opposite, i.e. 'convert text (a char *) to a type value'. An unserialize function is used when you type text into the Generate Event dialog.

With the GenerateSerializationFunctions property set to SerializationAndUnserialization, Rhapsody automatically generates global serialize and unserialize functions into the .h/.cpp files for the application. Let's have a peek! Here is the auto-generated serialize function.

This is an auto-generated unserialize function.

Note the function's signatures. We need to match these when creating our own. Any user-defined functions would need to take the same argument and return types.

Here are some user-defined serialize/unserialize functions. They are global functions, i.e. contained by a package.

It's important that animation is turned off.

In this user-defined serialization function, I'm converting the enum type to a char * of Y(es), N(o), F(lash), or E(rror). My user-defined unserialization function does the opposite, i.e. converts a char * to the enum type.

We can tell Rhapsody to use these with the properties CPP_CG::Type::AnimSerializeOperation and CPP_CG::Type::AnimUnserializeOperation. We also need to turn off the auto-generation of serialization functions.

When we rebuild and run we can now see the user-defined serialization in play on the sequence diagram.

The user-defined unserialization is also in play!

In summary, you can easily get Rhapsody to auto-generate serialize and unserialize functions for types by setting the GenerateSerializationFunctions property, or (less easily) you can also create your own serialize/unserialize functions for animation, and tell Rhapsody to use them via properties. Just make sure the arguments and return values match and be careful about releasing memory ;-)