Stateflow.Message
Message in chart, state, or box
Description
Use Stateflow.Message
objects to communicate data locally or
between Stateflow® charts in Simulink® models. For more information, see Communicate with Stateflow Charts by Sending Messages.
Creation
Description
Input Arguments
parent
— Parent for new message
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object
Parent for the new message, specified as a Stateflow API object of one of these types:
Properties
Stateflow API objects have properties that correspond to the values you set in the Stateflow
Editor. To access or modify a property, use dot notation. To access or modify multiple
properties for multiple API objects, use the get
and
set
functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.
Interface
Name
— Name of message
"message"
(default) | string scalar | character vector
Name of the message, specified as a string scalar or character vector.
Scope
— Scope of message
"Output"
(default) | "Input"
| "Local"
Scope of the message, specified as "Local"
,
"Input"
, or "Output"
. For more information,
see Scope.
Port
— Port index for message
scalar
Port index for the message, specified as an integer scalar. This property applies only to input and output messages. For more information, see Port.
InitializeMethod
— Method for initializing message data
"Expression"
(default) | "Parameter"
| "Not Needed"
Method for initializing the value of the message data, specified as a string scalar or character vector that depends on the scope of the message:
For local and output messages, use
"Expression"
or"Parameter"
.For input messages, use
"Not Needed"
.
To specify the initial value of the message data, use the
Props.InitialValue
property.
For more information, see Initialize method.
Priority
— Priority
"300"
(default) | string scalar | character vector
Priority for the message, specified as a string scalar or character vector. 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 applies only to local and output messages in discrete-event charts. For more information, see Create Custom Queuing Systems Using Discrete-Event Stateflow Charts (SimEvents).
Queue
UseInternalQueue
— Whether chart maintains internal queue for message
true
or 1 (default) | false
or 0
Whether the Stateflow chart maintains an internal receiving queue for the input message,
specified as a numeric or logical 1 (true
) or 0
(false
). This property applies only to input messages. For more
information, see Use Internal Queue.
QueueType
— Order in which messages are removed from queue
"FIFO"
(default) | "LIFO"
| "Priority"
Order in which messages are removed from the receiving queue, specified as one of these values:
"FIFO"
— First in, first out."LIFO"
— Last in, first out."Priority"
— Remove messages according to the value in the data field. To specify the order, use theMessagePriorityOrder
property for the message.
This property applies only to local messages and to input messages that
have UseInternalQueue
set to true
. For more
information, see Queue Type.
MessagePriorityOrder
— Type of priority queue
"Ascending"
(default) | "Descending"
Type of priority queue for the message, specified as one of these values:
"Ascending"
— Messages are received in ascending order of the message data value."Descending"
— Messages are received in descending order of the message data value.
This property applies only when the QueueType
property of the message is "Priority"
. For more information, see
Queue Type.
QueueCapacity
— Length of internal queue
10
(default) | scalar
Length of the internal queue for the message, specified as an integer scalar. This
property applies only to local messages and to input messages that have
UseInternalQueue
set to true
. For more
information, see Queue Capacity.
QueueOverflowDiagnostic
— Level of diagnostic when number of messages exceeds queue capacity
"Error"
(default) | "Warning"
| "None"
Level of diagnostic action when the number of incoming messages exceeds the queue
capacity for the message, specified as "Error"
,
"Warning"
, or "None"
. This property applies
only to local messages and to input messages that have
UseInternalQueue
set to true
. For more
information, see Queue Overflow Diagnostic.
Data Specification
DataType
— Data type of message
"Inherit: Same as Simulink"
(default) | "double"
| "single"
| "int32"
| "uint32"
| "boolean"
| ...
Data type of the message, specified as a string scalar or character vector that
depends on the Props.Type.Method
property of the message:
If the
Props.Type.Method
property of the message is"Inherit"
, the value of this property is"Inherit: Same as Simulink"
.If the
Props.Type.Method
property of the message is"Built-in"
, you can specify this property with one of these options:"double"
"single"
"int8"
"int16"
"int32"
"int64"
"uint8"
"uint16"
"uint32"
"uint64"
"boolean"
"string"
"ml"
(Supported only in charts that use C as the action language)
Otherwise, the
Props.Type
properties of the message determine the value of this property.
For more information, see the section Add Data in Create Charts by Using the Stateflow API.
Props
— Data specification properties
Stateflow.DataProps
object
Data specification properties, specified as a Stateflow.DataProps
object with these properties:
Type.Method
— Method for setting the data type of the message, specified as"Inherited"
,"Built-in"
,"Bus Object"
,"Enumerated"
,"Expression"
, or"Fixed point"
. This property is equivalent to the Mode field of the Data Type Assistant in the Model Explorer and the Data properties dialog box. For more information, see Specify Scope and Type of Stateflow Data.Type.BusObject
— Name of theSimulink.Bus
object that defines the message data, specified as a string scalar or character vector. This property applies only when theType.Method
property of the data object is"Bus Object"
. For more information, see Access Bus Signals.Type.EnumType
— Name of the enumerated type that defines the message data, specified as a string scalar or character vector. This property applies only when theType.Method
property of the data object is"Enumerated"
. For more information, see Reference Values by Name by Using Enumerated Data.Type.Expression
— Expression that evaluates to the data type of the message data, specified as a string scalar or character vector. This property applies only when theType.Method
property of the data object is"Expression"
. For more information, see Specify Data Properties by Using MATLAB Expressions.Type.Signed
— Signedness, specified as a numeric or logical 1 (true
) or 0 (false
). This property applies only when theType.Method
property of the data object is"Fixed point"
. For more information, see Fixed-Point Data in Stateflow Charts.Type.WordLength
— Word length, in bits, specified as a string scalar or character vector. This property applies only when theType.Method
property of the data object is"Fixed point"
. For more information, see Fixed-Point Data in Stateflow Charts.Type.Fixpt.ScalingMode
— Method for scaling the fixed-point message data, specified as"Binary point"
,"Slope and bias"
, or"None"
. This property applies only when theType.Method
property of the data object is"Fixed point"
. For more information, see Fixed-Point Data in Stateflow Charts.Type.Fixpt.FractionLength
— Fraction length, in bits, specified as a string scalar or character vector. This property applies only when theType.Method
property is"Fixed point"
and theType.Fixpt.ScalingMode
property is"Binary point"
.Type.Fixpt.Slope
— Slope, specified as a string scalar or character vector. This property applies only when theType.Method
property is"Fixed point"
and theType.Fixpt.ScalingMode
property is"Slope and bias"
.Type.Fixpt.Bias
— Bias, specified as a string scalar or character vector. This property applies only to when theType.Method
property is"Fixed point"
and theType.Fixpt.ScalingMode
property is"Slope and bias"
.Type.Fixpt.Lock
— Whether to prevent replacement of the fixed-point type with an autoscaled type chosen by the Fixed-Point Tool (Fixed-Point Designer), specified as a numeric or logical 1 (true
) or 0 (false
). This property applies only when theType.Method
property of the data object is"Fixed point"
.Array.Size
— Size of the message data, specified as a string scalar or character vector. For more information, see Specify Size of Stateflow Data.Complexity
— Whether the message accepts complex values, specified as"On"
or"Off"
. For more information, see Complex Data in Stateflow Charts.InitialValue
— Initial value, specified as a string scalar or character vector.
CompiledSize
— Message data size as determined by compiler
''
(default) | character vector
This property is read-only.
Message data size as determined by the compiler, specified as a character vector.
CompiledType
— Data type as determined by compiler
'unknown'
(default) | character vector
This property is read-only.
Data type as determined by the compiler, specified as a character vector.
Hierarchy
Machine
— Machine that contains message
Stateflow.Machine
object
This property is read-only.
Machine that contains the message, specified as a Stateflow.Machine
object.
Path
— Location of parent in model hierarchy
character vector
This property is read-only.
Location of the parent of the message in the model hierarchy, specified as a character vector.
Identification
Description
— Description
""
(default) | string scalar | character vector
Description for the message, specified as a string scalar or character vector.
Document
— Document link
""
(default) | string scalar | character vector
Document link for the message, specified as a string scalar or character vector.
Tag
— User-defined tag
[]
(default) | any data type
User-defined tag for the message, specified as data of any type.
SSIdNumber
— Session-independent identifier
scalar
This property is read-only.
Session-independent identifier, specified as an integer scalar. Use this property to distinguish the message from other objects in its parent chart.
Id
— Unique identifier
scalar
This property is read-only.
Unique identifier, specified as an integer scalar. Unlike
SSIdNumber
, the value of this property is reassigned every time
you start a new MATLAB® session and may be recycled after an object is deleted.
Object Functions
getParent | Identify parent of object |
getReferences | Identify references to symbol name |
renameReferences | Rename symbol and update references to symbol name |
dialog | Open properties dialog box |
view | Display object in editing environment |
Examples
Add Message to Chart
Add a message to the chart ch
. Specify its name, scope, and
data type.
message = Stateflow.Message(ch); message.Name = "M"; message.Scope = "Input"; message.Props.Type.Method = "Built-in"; message.DataType = "int32";
Version History
Introduced in R2015bR2023b: Limitations
Messages are no longer supported in entry actions or default transitions with Execute (enter) Chart At Initialization enabled.
R2023a: New object functions
The object functions getReferences
and
renameReferences
find and update the locations, such as state and
transition actions, where the chart refers to the name of a message:
The object function
getReferences
returns the locations where a chart refers to a message name.The object function
renameReferences
renames a message and updates all references to the message name in the chart.
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)