Reverse Engineering for Dummies

How to import external sources to an Rhapsody Model

Sometimes it is necessary  to use data-types and/or functions defined in header files given by an other developer. In this case the best way is to import these header files as external files to the working model. For external files no code is generated.

In the following article two models are mentioned. A working model with whom the application is developed and an import model to perform Reverse Engineering.

1 – Initial import

To import external sources to a Rhapsody model Reverse Engineering can be used. In the following steps the import process is described.

    1. Open Rhapsody (depending on the language of the given source files choose Rhapsodoy in C or Rhapsody in C++)
    2. Create a new project (the import model).
    3. Open Tools > Reverse Engineering
    4. Choose Logical Modelling

      image2018-9-10_15-46-7

    5. Browse to file which have to be imported and select them.
      image2018-9-10_15-49-12
    6. Click Next and set External elements and Single top level package.
      image2018-9-10_15-52-38
    7. Import files with Next  and Finish. After that you should get something like in the next figure

      image2018-9-10_16-1-0
      At the package icon the small yellow arrow shows that no code is generated for the content of this package.

    8. (Optional) If the sources are in C and should be used in an C++ model (the working model) the language of the unit has to be changed to C++. With a right click of the package open the context menu and choose Unit > Edit Unit… and open the following window.
      image2018-9-10_16-6-26
      Switch the language to C++ and click OK.
    9. Close the import model and open the working model in which the sources should be used.
    10. Choose  File > Add to model… and browse to the created package.
      image2018-9-10_16-14-15
      As options choose As Unit and Copy Into Model.
    11. Now the data-types and functions can be referenced in the working model. In the following picture some samples of usage are shown.

      Select return type

      or argument type

      image2018-9-10_16-23-9

      or with the shortcut Ctrl + Space in the implementation.

image2018-9-10_16-24-40


Attention

When executed again, other GUID are assigned to the data types and functions. As a result, they are no longer recognised in the working model and must be reassigned.
If changes occur to the imported sources, they must be manually added to the imported package.
To prevent accidental overwriting, it is recommended to delete the import model used for reverse engineering after importing the package into the working model  


2 – Add additional header files

If new header files has to be imported to the externalSources package proceed as follows:

  1. Open Rhapsody (depending on the language of the given source files choose Rhapsodoy in C or Rhapsody in C++)
  2. Create a new project (the import model).
  3. Open Tools > Reverse Engineering
  4. Choose Logical Modelling

    image2018-9-10_15-46-7
  5. Browse to file which have to be imported and select them.

    image2018-9-12_9-59-0
  6. Click Next and set External elements and Single top level package. Choose another package name (externalSources_new) than in the working model.

    image2018-9-12_10-2-12


  7.  Import files with Next  and Finish. After that you should get something like in the next figure.
    image2018-9-12_10-3-44At the package icon the small yellow arrow shows that no code is generated for the content of this package.
  8. (Optional) If the sources are in C and should be used in an C++ model (the working model) the language of the unit has to be changed to C++. With a right click of the package open the context menu and choose Unit > Edit Unit… and open the following window.
    image2018-9-12_10-5-34
    Switch the language to C++ and click OK.

     

  9. Close the import model and open the working model in which the sources should be used
  10. Choose  File > Add to model… and browse to the created package.
  11. Now the new file can be moved to the externalSources package. It is easier to handle only one external package.
    image2018-9-12_10-8-4
  12. After that you should get something like in the next figure.
    image2018-9-12_10-9-56
  13. Now the new file can be moved to the externalSources package. It is easier to handle only one external package.
  14. Following video shows step 9 to 13:
    [wpvideo aFGPYz13]

     

That was it! Thanks to Dennis Koelbel for creating this article and video!

Happy Modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

2 Comments

  1. rhapsody207

    Hi,
    Thank you for the helpful information.

    I’m trying to Reverse Engineer C (IBM Rational® Rhapsody® 8.4) code to visualize its model, I go with the same steps but I have two differences:
    * The first is that, in “Reverse Engineer mode”, I have the “code centric without code generation” and “model driven” options.
    * Secondly, when I finish the steps, I see “Roundtripping has been completed.” log. And the results of step 7 are not product.

    I’m wondering if I have to take care of an additional step or settings.

    I’m looking forward to your reply

    your sincerely,
    Maziar

  2. rhapsody207

    Hi,
    Thank you for the helpful information.

    I’m trying to Reverse Engineer C (IBM Rational® Rhapsody® 8.4) code to visualize its model, I go with the same steps but I have two differences:
    * The first is that, in “Reverse Engineer mode”, I have the “code centric without code generation” and “model driven” options.
    * Secondly, when I finish the steps, I see “Roundtripping has been completed.” log. And the results of step 7 are not product.

    I’m wondering if I have to take care of an additional step or settings.

    I’m looking forward to your reply

    your sincerely,
    Maziar

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2025 Rhapsody TechBlog

Theme by Anders NorenUp ↑