Main Content

Describe Component Behavior UsingStateflowCharts

Astate chartdiagram demonstrates the state-dependent behavior of a component throughout its state lifecycle and the events that can trigger a transition between states.

添加Stateflow®chart behavior to describe a component using state machines. You cannot synchronize and reuse Stateflow chart behaviors asReference Componentblocks because the component is part of the parent model.

You can simulate the Stateflow component implementations in System Composer™. Use theSimulation Data Inspectorto view and compare simulation results between model designs.

状态图是由一组有限的智慧h transitions between them to capture the modes of operation for the component. Charts allow you to design for different modes, internal states, and event-based logic of a system. You can also use charts as stubs to mock a complex component implementation during top-down integration testing. This functionality requires a Stateflow license. For more information, seeStateflow.

Add State Chart Behavior to Component

A System Composer component with stereotypes, interfaces, requirement links, and ports, is preserved when you add StateflowChart(Stateflow)behavior.

  1. This example uses the architecture model for an unmanned aerial vehicle (UAV) to add state chart behavior to a component. In the MATLAB®Command Window, enter the following command:

    scExampleSmallUAV

  2. Double-click theAirframecomponent. Select theLandingGearcomponent on the System Composer composition editor.

  3. Select theBrakeport. Open theInterface Editorfrom the toolstripModeling>Interface Editor. Right-click the interfaceoperatorCmdsand selectAssign to Selected Port(s).

  4. Right-click theLandingGearcomponent and selectCreate Stateflow Chart Behavior. Alternatively, navigate toModeling>Create Stateflow Chart Behavior.

    View of menu option for the landing gear component to create Stateflow chart behavior.

  5. Double-clickLandingGear, which has the Stateflow icon. Navigate toModeling>Design Data>Symbols Paneto view the Stateflow symbols. The input portBrakeappears as input data in the symbols pane.

    Note

    Some Stateflow objects remain local to Stateflow charts. Input and output event ports are not supported in System Composer. Only local events are supported.

    The Stateflow canvas in the landing gear component. The port Brake is displayed in the symbols pane.

    Since Stateflow ports show up as input and output data objects, they must follow Stateflow naming conventions. Ports are automatically renamed to follow Stateflow naming conventions. For more information, seeGuidelines for Naming Stateflow Objects(Stateflow).

  6. Select theBrakeinput and view the interface in the Property Inspector. The interface can be accessed like a Simulink®bus signal. For information on how to use bus signals in Stateflow, seeIndex and Assign Values to Stateflow Structures(Stateflow).

    The interface named operator commands is shown as a bus.

  7. You can populate the Stateflow canvas to represent the internal states of theLandingGear.

    Stateflow canvas showing the states Deployed and Stowed.

RemoveStateflowChart Behavior from Component

You can remove Stateflow chart behavior from a component to delete the contents inside the Stateflow chart while preserving interfaces on the component.

  1. Right-click on theLandingGearcomponent and selectInline Behavior.

    The Inline Stateflow Chart behavior menu for a component Landing Gear.

  2. To confirm the operation to delete all the content inside the Stateflow chart, clickOK.

  3. The Stateflow chart behavior on the component is removed. Interfaces on the component are preserved.

    Inlined landing gear component with no Stateflow Chart behavior component badge.

See Also

|

Related Topics