implement component behavior using stateflow charts -凯发k8网页登录

main content

implement component behavior using stateflow charts

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

add stateflow® chart behavior to describe a component using state machines. you cannot synchronize and reuse stateflow chart behaviors as reference component blocks because the component is part of the parent model.

you can simulate the stateflow component implementations in system composer™. use the simulation data inspector to view and compare simulation results between model designs.

state charts consist of a finite set of states with 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, see stateflow.

add state chart behavior to component

a system composer component with stereotypes, interfaces, requirement links, and ports, is preserved when you add stateflow (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 the airframe component. select the landinggear component on the system composer composition editor.

  3. select the brake port. open the from the toolstrip modeling > interface editor. right-click the interface operatorcmds and select assign to selected port(s).

  4. right-click the landinggear component and select create stateflow chart behavior. alternatively, navigate to modeling > create stateflow chart behavior.

    view of menu option for the landing gear component to create stateflow chart behavior.

  5. double-click landinggear, which has the stateflow icon. navigate to modeling > design data > symbols pane to view the stateflow symbols. the input port brake appears 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, see (stateflow).

  6. select the brake input and view the interface in the . the interface can be accessed like a simulink® bus signal. for information on how to use bus signals in stateflow, see (stateflow).

    the interface named operator commands is shown as a bus.

  7. you can populate the stateflow canvas to represent the internal states of the landinggear.

    stateflow canvas showing the states deployed and stowed.

remove stateflow chart 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 the landinggear component and select inline 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, click ok.

  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

网站地图