Lesson 6: Generating code

In this lesson, you learn how to generate code from your model and view the results in the output window.

About this task

IBM® Engineering Systems Design Rhapsody® generates code for the statecharts that define the state behavior of the class. In most environments, before you generate code, you must set an active configuration. The Rhapsody code generator automatically checks for inconsistencies that might cause problems in generating or compiling the code. These inconsistencies can potentially prevent Rhapsody from completing code generation.

To set the active configuration:

Procedure

  1. In the model browser, expand the SensorComp component.
  2. Double-click HostConfigDebug. The Configuration window is displayed.
  3. In the Configuration window, select the Initialization tab.
  4. Expand DesignPkg, then select VehicleSensorSystem as the initial instance.
  5. Click OK.
  6. From the main menu, select Code > Generate > HostConfigDebug.
  7. The Log tab lists the generated files and shows a status message. If no errors are found, you get the following message:
  8. From the main menu, select View > Active Code View.
  9. In the Vehicle Sensor Structure diagram, select itsButton.

Results

You can see the header and code files for the button class are shown in the output window:
Active Code View

Lesson checkpoint

In this lesson, you learned how to:
  • Generate code.
  • Locate code in the Code View window.