You can follow the CruiseControlSystem simulation
example to activate and run the simulation of your dynamic models.
Before you begin
The following software is required for integrating Simulink
components into a Rational® Rhapsody® model:
- Matlab must be available and licensed (Matlab 7), with Simulink
(version 6), and the Real-Time Workshop component which generates
C and C++ code from Simulink models.
- Version 7.0 or greater of the Rational Rhapsody product.
Procedure
- Open a new or existing Rational Rhapsody model in C or C++.
- Optional: Add the SysML profile.
- Add the Simulink, or SimulinkInC if
C is the language of the profile.
- Create some new blocks, and give those blocks the SimulinkBlock stereotype.
These blocks represent the continuous subsystems.
- Right click on each SimulinkBlock,
and select Import/Sync Simulink model.

- In the Import/Synch Simulink Model, select the location
of the Simulink model, and click the Import/Sync button.

- Create some new blocks and implement their behavior. These
blocks are the discrete subsystems.
- Create a new block, that will be the builder block, and
assign it with the SimulinkStructureBlock stereotype.
- Open the feature's dialog window of theSimulinkStructureBlock,
open the Tags tab, and fill in the needed info
for the Simulink simulation.

- Create an Internal Block Diagram (IBD)
to the SimulinkStructureBlock, add parts of
the Rhapsody and SimulinkBlocks,
and connect the flowports of the parts via connectors (links).

- Right click on the SimulinkStructureBlock or
in the Internal Block Diagram (IBD), and choose
one of the four options under the Simulink submenu
- Generate: generates the SimulinkStructureBlock as
a Simulink model. The Rhapsody generated
code is not going to be instrumented.
- Generate and Simulate: generates the SimulinkStructureBlock as
a Simulink model, and auto starts the Simulink simulation.
- Generate for Animation: generates the SimulinkStructureBlockas
a Simulink model. You will be able to see only the animation
of the Rhapsody blocks.
- Generate and Simulate for Animation: generates
the SimulinkStructureBlock as a Simulink model,
and auto starts the Simulink simulation.

As
a result, Matlab opens, a new SFunction is created and
compiled, and a new Simulink model appears representing
the SimulinkStructureBlock. The SimulinkBlocks, PropFeedback and EnvironmentReaction exist
as regular Simulink subsystems, and all Rhapsody blocks are transformed into one SFunction,
which is implemented via the Rhapsody generated
code.

Results
Now, you can simulate the system in Simulink.
The left scope image represents the desiredSpeed simulation
example, and the right image represents the actualSpeed simulation
example.
