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.
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
double-click the
airframe
component. select thelandinggear
component on the system composer composition editor.select the
brake
port. open the from the toolstrip modeling > interface editor. right-click the interfaceoperatorcmds
and select assign to selected port(s).right-click the
landinggear
component and selectcreate stateflow chart behavior
. alternatively, navigate to modeling > create stateflow chart behavior.double-click
landinggear
, which has the stateflow icon. navigate to modeling > design data > symbols pane to view the stateflow symbols. the input portbrake
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.
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).
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).you can populate the stateflow canvas to represent the internal states of the
landinggear
.
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.
right-click on the
landinggear
component and selectinline behavior
.to confirm the operation to delete all the content inside the stateflow chart, click ok.
the stateflow chart behavior on the component is removed. interfaces on the component are preserved.
see also
|