IBM Support

How to terminate an application in a normal way inside the main function using Rational Rhapsody

Question & Answer


Question

How do you create a model to terminate an application in a normal way inside the main function using IBM Rational Rhapsody?

Cause

You must clear StartFrameworkInMainThread property to exit OXF::start() in a main function and could need to use event flag to wait for the end of another thread.

Answer

The following steps are an example that an application terminates using an event flag after waiting for the end of a reactive class, and explain how to implement using Rhapsody v7.6.1:

Note: You may review the attached sample model created by these steps as an example.

  1. Include OMOSEventFlag
    1. Create an external package oxf

    2. Tick CG::Package::UseAsExternal property on the General tab of the feature diagram of the package

    3. Create OMOSEventFlag class to refer under oxf package

    4. Set oxf/os.h to CG::Class::FileName property on the General tab of the feature diagram of the class



  2. Define EndAppEventFlag
    1. Create EndAppEventFlag variable under the target package

    2. Select OMOSEventFlag created by step 1 in Type field on the General tab of thr feature diagram

    3. Tick Reference checkbox

    4. Set OMOSFactory::instance()->createOMOSEventFlag() to Initial Value field





  3. Configure to wait for a signal and end an application
    1. Clear CG::Configuration::StartFrameworkInMainThread property

    2. Set EndAppEventFlag->wait(); to CG::Configuration::PostFrameworkThreadSegment property

    3. Set OMOS::endApplication(status); to CPP_CG::MSVC9::EndApplicationCode property



  4. Configure to send signal from a terminate state

    Set EndAppEventFlag->signal(); to Action on entry field of a terminate state


  5. Configure Initial instance

Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



EndAppSample761cpp.zip

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Rational Rhapsody Developer","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.0.1;7.5.1;7.5.1.1;7.5.2;7.5.2.1;7.5.3;7.5.3.1;7.5.3.2;7.6;7.6.0.1;7.6.1;7.6.1.1","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21597440