Main Content

Set Properties for a Message

A message is a Stateflow® object that communicates data locally or between charts in a Simulink® model. For more information, see Communicate with Stateflow Charts by Sending Messages.

When you create Stateflow charts in Simulink models, you can modify message properties in the Property Inspector or the Model Explorer.

To use the Property Inspector:

  1. In the Modeling tab, under Design Data, select Symbols Pane and Property Inspector.

  2. In the Symbols pane, select the message.

  3. In the Property Inspector, edit the message properties.

To use the Model Explorer:

  1. In the Modeling tab, under Design Data, select Model Explorer.

  2. In the Model Hierarchy pane, select the parent of the message.

  3. In the Contents pane, select the message.

  4. In the Dialog pane, edit the message properties.

You can also modify these properties programmatically by using Stateflow.Message objects. For more information about the Stateflow programmatic interface, see Overview of the Stateflow API.

Stateflow Message Properties

Name

Name of the message. For more information, see Guidelines for Naming Stateflow Objects.

Scope

Scope of the message. The scope specifies where the message occurs relative to the parent object.

ScopeDescription
InputMessage that is received from another block in the Simulink model. Each input message can use an internal receiving queue that is maintained by the Stateflow chart or an external receiving queue that is managed by a Queue (Simulink) block.
OutputMessage that is sent through an output port to another block in the Simulink model.
LocalMessage that is local to the Stateflow chart. The Stateflow chart maintains an internal receiving queue for each local message. When you send a local message, it is visible by state and transition actions in the same chart. You cannot send a local message outside the chart.

Port

Index of the port associated with the message. This property applies only to input and output messages.

Size

Size of the message data field. For more information, see Specify Size of Stateflow Data.

Complexity

Specifies whether the message data field accepts complex values.

Complexity SettingDescription
OffData field does not accept complex values.
OnData field accepts complex values.
InheritedData field inherits the complexity setting from a Simulink block.

The default value is Off. For more information, see Complex Data in Stateflow Charts.

Type

Type of the message data field. To specify the data type:

  • From the Type drop-down list, select a built-in type.

  • In the Type field, enter an expression that evaluates to a data type.

Additionally, in the Model Explorer, you can open the Data Type Assistant by clicking the Show data type assistant button . Specify a data Mode, and then specify the data type based on that mode. For more information, see Specify Scope and Type of Stateflow Data.

Note

In charts that use C as the action language, messages do not support multiword fixed-point data.

Initial Value

Initial value of the message data. Enter an expression or parameter defined in the Stateflow hierarchy, MATLAB® base workspace, or Simulink masked subsystem. This property applies only to local and output messages.

If you do not specify a value, the default value for numeric data is 0. For enumerated data, the default value typically is the first one listed in the enumeration section of the definition. You can specify a different default enumerated value in the methods section of the definition. For more information, see Define Enumerated Data Types.

Priority

Priority for the message. If two distinct messages occur at the same time, this property determines which message is processed first. A smaller numeric value indicates a higher priority. This property is visible only for local and output messages in discrete-event charts. For more information, see Create Custom Queuing Systems Using Discrete-Event Stateflow Charts (SimEvents).

Add to Watch Window

Enables watching the message queue and data field in the Stateflow Breakpoints and Watch window. For more information, see View Data in the Breakpoints and Watch Window.

Message Queue Properties

These properties define the behavior of receiving queues and apply only to input and local messages.

Use Internal Queue

Specifies that the Stateflow chart maintains an internal receiving queue for the input message. By default, this property is enabled. When you disable this property, you can connect the message input port to:

  • A Queue (Simulink) block that manages an external queue in your Simulink model

  • A root-level Inport (Simulink) block that enables messages to cross the model boundary

For more information on external message queues, see Messages (Simulink).

Queue Capacity

Specifies the maximum number of messages held in an internal receiving queue. If a chart sends a message when the queue is full, a queue overflow occurs. To avoid dropped messages, set the queue capacity high enough that incoming messages do not cause the queue to overflow. The maximum queue capacity is 216–1.

Queue Overflow Diagnostic

Specifies the level of diagnostic action when the number of incoming messages exceeds the queue capacity. The default option is Error.

Diagnostic SettingDescription
ErrorWhen the queue overflows, the simulation stops with an error.
WarningWhen the queue overflows, the queue drops the last message and simulation continues with a warning.
NoneWhen the queue overflows, the queue drops the last message and simulation continues without issuing a warning.

Queue Type

Specifies the order in which messages are removed from the receiving queue. The default option is FIFO.

Queue Type SettingDescription
FIFOFirst in, first out
LIFOLast in, first out
Priority

Remove messages according to the value in the data field. Choosing this setting exposes the Priority order field, which has these options:

  • Ascending - The messages are removed in ascending order of the message data value.

  • Descending - The messages are removed in descending order of the message data value.

Additional Properties

You can set additional message properties in:

  • The Info tab of the Property Inspector.

  • The Description tab of the Model Explorer.

Description.  Description of the message.

Document Link.  Link to online documentation for the message. You can enter a web URL address or a MATLAB command that displays documentation as an HTML file or as text in the MATLAB Command Window. When you click the Document link hyperlink, Stateflow displays the documentation.

See Also

Blocks

Objects

Tools

Related Topics