use the sequence viewer to visualize messages, events, and entities
to see the interchange of messages and events between the blocks from the simulink® messages & events library, stateflow® charts in simulink models, and simevents® blocks, you can:
use the tool from the simulink toolstrip.
add a block to your simulink model.
the sequence viewer allows you to visualize message transition events and the data that the messages carry. in the sequence viewer, you can view event data related to stateflow chart execution and the exchange of messages between stateflow charts. the sequence viewer window shows messages as they are created, sent, forwarded, received, and destroyed at different times during model execution. the sequence viewer window also displays state activity, transitions, and function calls to stateflow graphical functions, simulink functions, and matlab® functions.
with the sequence viewer, you can also visualize the movement of entities between blocks when simulating simevents models. all simevents blocks that can store entities appear as lifelines in the sequence viewer window. entities moving between these blocks appear as lines with arrows. you can view calls to simulink function blocks and to matlab function blocks.
you can add a sequence viewer block to the top level of a model or any subsystem. if you place a sequence viewer block in a subsystem that does not have messages, events, or state activity, the sequence viewer window informs you that there is nothing to display.
for instance, open the stateflow example sf_msg_traffic_light
.
openexample("stateflow/modelingadistributedtrafficcontrolsystemusingmessageexample")
this model has three simulink subsystems: traffic light 1, traffic light 2, and gui. during simulation, the stateflow charts in these subsystems exchange data by sending messages. as messages pass through the system, you can view them in the sequence viewer window. the sequence viewer window represents each block in the model as a vertical lifeline with simulation time progressing downward.
components of the sequence viewer window
navigation toolbar
at the top of the sequence viewer window, a navigation toolbar displays the model hierarchy path. using the toolbar buttons, you can:
show or hide the property inspector.
select an automatic or manual layout.
show or hide inactive lifelines.
save sequence viewer settings.
restore sequence viewer settings.
configure sequence viewer parameters.
access the sequence viewer documentation.
property inspector
in the property inspector, you can choose filters to show or hide:
events
messages
function calls
state changes and transitions
header pane
the header pane below the sequence viewer toolbar shows lifeline headers containing the names of the corresponding blocks in a model.
gray rectangular headers correspond to subsystems.
white rectangular headers correspond to masked subsystems.
yellow headers with rounded corners correspond to stateflow charts.
to open a block in the model, click the name in the corresponding lifeline header. to show or hide a lifeline, double-click the corresponding header. to resize a lifeline header, click and drag its right-hand side. to fit all lifeline headers in the sequence viewer window, press the space bar.
message pane
below the header pane is the message pane. the message pane displays messages, events, and function calls between lifelines as arrows from the sender to the receiver. to display sender, receiver, and payload information in the property inspector, click the arrow corresponding to the message, event, or function call.
navigate the lifeline hierarchy
in the sequence viewer window, the hierarchy of lifelines corresponds to the model hierarchy. when you pause or stop the model, you can expand or contract lifelines and change the root of focus for the viewer.
expand a parent lifeline
in the message pane, a thick, gray lifeline indicates that you can expand the lifeline to see its children. to show the children of a lifeline, click the expander icon below the header or double-click the parent lifeline.
for example, expanding the lifeline for the traffic light 1 block reveals two new lifelines corresponding to the stateflow charts ped button sensor and controller.
expand a masked subsystem lifeline
the sequence viewer window displays masked subsystems as white blocks. to show the children of a masked subsystem, point over the bottom left corner of the lifeline header and click the arrow.
for example, the gui subsystem contains four masked subsystems: traffic lamp 1,traffic lamp 2, ped lamp 1, and ped lamp 2.
you can display the child lifelines in these masked subsystems by clicking the arrow in the parent lifeline header.
change root of focus
to make a lifeline the root of focus for the viewer, point over the bottom left corner of the lifeline header and click the arrow. alternatively, you can use the navigation toolbar at the top of the sequence viewer window to move the current root up and down the lifeline hierarchy. to move the current root up one level, press the esc key.
the sequence viewer window displays the current root lifeline path and shows its child lifelines. any external events and messages are displayed as entering or exiting through vertical slots in the diagram gutter. when you point to a slot in the diagram gutter, a tooltip displays the name of the sending or receiving block.
view state activity and transitions
to see state activity and transitions in the sequence viewer window, expand the state hierarchy until you have reached the lowest child state. vertical yellow bars show which state is active. blue horizontal arrows denote the transitions between states.
in this example, you can see a transition from go
to
preparetostop
followed, after 1 second, by a transition to
stop
.
to display the start state, end state, and full transition label in the property inspector, click the arrow corresponding to the transition.
to display information about the interactions that occur while a state is active, click the yellow bar corresponding to the state. in the property inspector, use the search up and search down buttons to move through the transitions, messages, events, and function calls that take place while the state is active.
view function calls
the sequence viewer displays function calls and replies. this table lists the type of support for each type of function call.
function call type | support |
---|---|
calls to simulink function blocks | fully supported. |
calls to stateflow graphical or stateflow matlab functions |
|
calls to function-call subsystems | fully supported and displayed. |
calls from matlab function block | supports displaying function call events with the limitation of calls crossing model reference boundaries. |
the sequence viewer window displays function calls as solid arrows
labeled with the format
function_name(argument_list)
.
replies to function calls are displayed as dashed arrows labeled with the format
[argument_list]=function_name
.
for example, in the model slexprinterexample
, a subsystem calls the
simulink function block addprinterjob
. the function block
replies with an output value of false
.
to open this example, enter:
openexample("stateflow/sharefcnsacrossslandsfexample")
simulation time in the sequence viewer window
the sequence viewer window shows events vertically, ordered in time. multiple events in simulink can happen at the same time. conversely, there can be long periods of time during simulation with no events. as a consequence, the sequence viewer window shows time by using a combination of linear and nonlinear displays. the time ruler shows linear simulation time. the time grid shows time in a nonlinear fashion. each time grid row, bordered by two blue lines, contains events that occur at the same simulation time. the time strip provides the times of the events in that grid row.
to show events in a specific simulation time range, use the scroll wheel or drag the time slider up and down the time ruler. to navigate to the beginning or end of the simulation, click the go to first event or go to last event buttons. to see the entire simulation duration on the time ruler, click the fit to view button .
when using a variable step solver, you can adjust the precision of the time ruler. in the model explorer, on the main tab of the sequence viewer block parameters pane, adjust the value of the time precision for variable step field.
redisplay of information in the sequence viewer window
the sequence viewer saves the order and states of lifelines between simulation runs. when you close and reopen the sequence viewer window, it preserves the last open lifeline state. to save a particular viewer state, click the save settings button in the toolbar. saving the model then saves that state information across sessions. to load the saved settings, click the restore settings button .
you can modify the time precision for variable step and history parameters only between simulations. you can access the buttons in the toolbar before simulation or when the simulation is paused. during a simulation, the buttons in the toolbar are disabled.
see also
blocks
tools
related topics
- communicate with stateflow charts by sending messages (stateflow)
- (stateflow)