Main Content

Implement Component Behavior Using Activity Diagrams

An activity diagram describes system behavior that helps visualize the functional flow of a system through actions or decisions. Activity diagrams can help you understand how system components interact with one another. For more information, see Describe System Behavior Using Activity Diagrams.

You can add activity diagram behavior for components within System Composer™ to describe or specify flow-based behavior using nodes, pins, and flows. You can also reference an activity diagram within a Simulink® model using a Model block.

This topic uses the RobotActivity activity diagram from the scMobileRobotExample project to show how to:

  • Create a new activity diagram behavior for a System Composer component.

  • Link an existing activity diagram to a System Composer component.

Open this project using the following example.

openExample('systemcomposer/OpenActivityDiagramForRobotExample');

Create Component

To create an activity diagram behavior, you can use an existing component or create a component. To create a new component:

  1. At the MATLAB® Command Window, enter this command.

    systemcomposer

    Select Architecture Model.

  2. On the Simulation tab, select New , and then select Architecture .

  3. Left-click and drag a component from the palette and release the mouse button to commit.

  4. To change the name of the component, click the component, and then click its name. Change the name to MobileRobot.

MobileRobot component for activity diagram behavior

Note

You cannot create activity behavior for a component that has existing ports or subcomponents.

Create Activity Diagram Behavior

To create activity diagram behavior for the RobotActivity component, take one of these two actions: right-click menu and toolstrip.

To create activity diagram behavior for the RobotActivity component, take one of these actions:

  • Right-click the component MobileRobot and select Create Behavior > Create Activity Diagram Behavior. This action opens a new activity diagram behavior canvas.

  • From the toolstrip, on the Modeling tab, click the down arrow in the Component section, and then select Create Activity Diagram Behavior.

The Create Activity Diagram behavior dialog box opens. In the New file name box, enter RobotActivity. To create a data dictionary for the new component, select Create a local dictionary for the new component. In the Name box, enter the data dictionary as MobileRobot_dict.sldd.

To create the new activity diagram behavior, click OK.

Dialog box to create activity diagram behavior

Link to Existing Activity Diagram

You can also link to an existing activity diagram behavior model. For this example, use the RobotActivity model.

  • Right-click the MobileRobotcomponent and select Link to Model.

  • Type or browse for the name of an activity diagram model. For this example, enter RobotActivity.slx.

  • To create the link, click OK.

The component displays input and output ports that correspond to the parameter nodes within the activity diagram. The icon on the top-right corner of the component represents an activity diagram behavior.

Link activity diagram to component

To add or remove the model preview, right-click and select Format > Content Preview.

See Also

Functions

Tools

Blocks

Topics