Main Content

Create Custom Queuing Systems Using Discrete-Event Stateflow Charts

The Discrete-Event Chart block is similar to a Stateflow® chart but is used for discrete events. You can use the block to receive, process, and send SimEvents® entities. The Discrete-Event Chart block provides graphical state transitions and MATLAB® action language to create custom SimEvents models.

The distinguishing characteristic of the Discrete-Event Chart block is that it executes in an event-based rather than time-based fashion. To model custom discrete-event systems, use these Discrete-Event Chart block behaviors:

Note

With SimEvents software, you can view, edit, and simulate your Discrete Event Chart custom block within a SimEvents example model. However, to save the model you must have a Stateflow license.

For new models, without a Stateflow license, you can view and edit the model, but cannot simulate or save it.

The entities you use with discrete-event charts can be bus objects or anonymous entities.

Properties of Discrete-Event Chart

Discrete-event chart properties allow you to specify how your chart interfaces with Simulink® and SimEvents. These properties are a subset of the Stateflow chart properties.

To specify properties for a single chart:

  1. Double-click a chart.

    Discrete-Event Chart block

  2. Right-click an open area of the chart and select Properties.

    All charts provide general and documentation properties.

  3. Observe that the chart allows the configuration of only these properties on the General tab. It also supports the Fixed-point properties and Documentation tabs.

    Properties window of the Discrete-Event Chart block showing the Name as Discrete-Event Chart, and the Machine as (machine) untitled. The Saturate on integer overflow check box is selected. The Create output for monitoring box check box is greyed out.

    For more information about chart properties, see Specify Properties for Stateflow Charts (Stateflow).

Note

SimEvents supports only MATLAB action language and always supports variable-size arrays.

Define Local Messages

Similar to the Stateflow chart, you can define local messages for the discrete-event chart using the Stateflow Editor or Model Explorer.

To add a local message for the discrete-event chart:

  1. Select Symbols Pane and Create Message.

  2. Select Local Message and rename it to EntityOut.

  3. To specify local message queue properties, such as capacity, sorting policy, and overflow behavior right-click EntityLocal and select Inspect to open Property Inspector.

    Message Queue Properties dialog box with the Use internal queue check box greyed out. The Queue capacity box displays value 10, Queue overflow diagnostic list shows Error and the Queue type list shows FIFO.

Specify Message Properties

Discrete-event charts have additional properties for output messages and local messages.

Message Input Port PropertiesDescription
PriorityIf two message events occur at the same time, to decide which to process first, the discrete-event chart uses this priority. A smaller numeric value indicates a higher priority.

Event Triggering

An event in Stateflow is an object that trigger actions. For more information, see Synchronize Model Components by Broadcasting Events (Stateflow).

SimEvents Discrete-Event Chart support a subset of these events:

  • Message

  • Temporal

  • Local

  • Implicit Events, enter, exit, on, change

SimEvents Discrete-Event Chart does nor support these events:

  • Conditions without an event

  • during, tick

  • Event input from Simulink

  • Event output to Simulink

Note

The SimEvents event calendar displays and prioritizes message, and temporal events. Events of these types execute according to the event calendar schedule.

The event calendar does not display or prioritize local and implicit events. In the SimEvents environment, these events execute as dependent events of message or temporal events. For parallel states, local and implicit events execute in the state execution order.

Message Triggering

When a message or entity arrives at a message input or local queue, the discrete-event chart responds to the message as follows:

  • If the discrete-event chart is in a state of waiting for a message, the discrete-event chart wakes up and makes possible transitions. The chart immediately wakes up in order of message priority, processing the message with the highest priority first. For an example, see Trigger a Discrete-Event Chart Block on Message Arrival.

  • If the discrete-event chart does not need to respond to the arriving message, the discrete-event chart does not wake up and the message is queued.

Temporal Triggering

In a discrete-event chart, you can use both event-based and absolute time-based temporal logic operators. When using absolute time-based temporal logic operators, the SimEvents software uses the specified time delay value exactly. For an example, see Discrete-Event Chart Precise Timing.

For example, the activation of the temporal logic 'after(3,sec)' causes the chart to wake up after three seconds of simulation clock time.

Discrete-event chart showing the Start state connected to a circular connective junction that, in turn, connects to two states: Complete and Incomplete. The transition from the Start state to the junction has temporal condition: after(3,sec). The transition from the junction to the Complete state has condition: u==1.

When using absolute-time temporal logic operators, observe these differences from the Stateflow environment.

OperatorDescription

after

You can use as event notation in both state actions and transitions.

before

When you use as event notation of a transition, you cannot use additional condition notations on this transition. You can apply a connective junction to check additional conditions, as long as the connective junction has one unconditional transition.

In conditional notation, Discrete-Event Chart supports both after and before.

See Also

Related Topics