IBM Support

How to use "No Framework" with Statechart implementation in Rational Rhapsody

Technote (FAQ)


Question

How do you use "No Framework" with Statechart implementation in IBM Rational Rhapsody?

Cause

This could be required when the behavior is defined in functions and you want to create or make the libraries (lib files) or dynamic link libraries (DLLs) out of rhapsody and then call these files.

Also that you keep state chart only for design purpose and not use the code generation.


Answer

There are three types of events that are normally supported by Rational Rhapsody:

  • Timer Events
  • Asynchronous Events ("event receptions")
  • Synchronous events ("triggered operations")

The approach for using Rhapsody's statechart code generation capabilities with the framework disabled can be achieved by:
 
  1. Add NoFramework.prp and replace siteC++.prp in <<Rhapsody_installation>>/share/properties

  2. Open your Rhapsody project

  3. Click File > Add to Model

    Use the NoFrameworkSettings.sbs profile

  4. Apply the <<No Framework>> stereotype to the Rhapsody project.

    The regenerated source code should have no reference to the Rhapsody framework (the OXF).

  5. Apply the definitions.h and variables.h files

    The definitions.h and variables.h file can be included in the model as a component file with a File type of Specification

  6. Create a class in Rhapsody, class_0 with statechart

  7. Create and event for transition between the states


  8. In the generated code for class_0, include the rootState_entDef() and rootState_dispatchEvent() operations.


    void class_0::rootState_entDef() {
    {
    rootState_subState = state_0;
    rootState_active = state_0;
    }
    }
    IOxfReactive::TakeEventStatus class_0::rootState_processEvent() {
    IOxfReactive::TakeEventStatus res = eventNotConsumed;
    switch (rootState_active) {
    case state_0:
    {
    if(OM_CURRENT_EVENT_ID == ev1_UserPkg_id)
    {
    rootState_subState = state_1;
    rootState_active = state_1;
    res = eventConsumed;
    }
    break;
    }

    default:
    break;
    }
    return res;
    }


  9. The following line should be manually added as the first line of each class that has a statechart or activity graph

    rootState_entDef();<\code>

  10. For every "event reception" in a class, add a call [eventName] operation

    In this example, class_0 has one event reception ev1

    For example:



  11. The operation callEv1() has a one line implementation

    SEND_EVENT(ev1_UserPkg_id);<\code>

Document information

More support for: Rational Rhapsody
General Information

Software version: 7.2, 7.3, 7.4, 7.5, 7.6

Operating system(s): Linux, Windows

Reference #: 1324332

Modified date: 16 September 2011