| Contents | Index |
| On this page… |
|---|
The examples in Using Stateflow Charts to Implement a Failure State use Stateflow charts to implement the logic that determines whether a server is down, under repair, or operational. SimEvents blocks model the asynchronous arrival of customers, advancement of customers through a queue and server, and asynchronous failures of the server. While these examples could alternatively have represented the server's states using signal values instead of states of a Stateflow chart, the chart approach is more intuitive and scales more easily to include additional complexity.
The Packet Communication Within a Go-Back-N ARQ System demo uses SimEvents and Stateflow blocks to model a communication system. SimEvents blocks implement the movement of data frames and acknowledgment messages from one part of the system to another. Stateflow blocks implement the logical transitions among finitely many state values of the transmitter and the receiver.
At the receiver, the chart decides whether to accept or discard an incoming frame of data, records the identifier of the last accepted frame, and regulates the creation of acknowledgment messages. Interactions between the Stateflow chart and SimEvents blocks include these:
The arrival of an entity representing a data frame causes the generation of a function call that invokes the chart.
The chart can produce a routing signal that determines which path entities take at an Output Switch block.
The chart can produce a function call that causes the Event-Based Entity Generator block to generate an entity representing an acknowledgment message.
At the transmitter, the chart controls the transmission and retransmission of frames. Interactions between the Stateflow chart and SimEvents blocks include these:
The arrival of an entity representing a new data frame or an acknowledgment message causes the generation of a function call that invokes the chart.
The completion of transmission of a frame (that is, the completion of service on an entity representing a frame) causes the generation of a function call that invokes the chart.
The chart can produce a routing signal that determines which path entities take at an Output Switch block.
The chart can produce a function call that causes the Release Gate block to permit the advancement of an entity representing a data frame to transmit (function call at Stateflow block's tx output port) or retransmit (function call at Stateflow block's retx output port).
![]() | Guidelines for Using Stateflow and SimEvents Blocks | Debugging Discrete-Event Simulations | ![]() |

Model electronic system architectures, process flows, and logistics as queuing systems or agent-based systems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |