Main Content

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

    message = Stateflow.Message(parent) creates a Stateflow.Message object in a parent chart, state, or box.

    example

    Input Arguments

    expand all

    Parent for the new message, specified as a Stateflow API object of one of these types:

    Properties

    expand all

    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 of the message, specified as a string scalar or character vector.

    Scope of the message, specified as "Local", "Input", or "Output". For more information, see Scope.

    Port index for the message, specified as an integer scalar. This property applies only to input and output messages. For more information, see Port.

    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 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

    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.

    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 the MessagePriorityOrder 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.

    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.

    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.

    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

    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.

    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 the Simulink.Bus object that defines the message data, specified as a string scalar or character vector. This property applies only when the Type.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 the Type.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 the Type.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 the Type.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 the Type.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 the Type.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 the Type.Method property is "Fixed point" and the Type.Fixpt.ScalingMode property is "Binary point".

    • Type.Fixpt.Slope — Slope, specified as a string scalar or character vector. This property applies only when the Type.Method property is "Fixed point" and the Type.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 the Type.Method property is "Fixed point" and the Type.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 the Type.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.

    This property is read-only.

    Message data size as determined by the compiler, specified as a character vector.

    This property is read-only.

    Data type as determined by the compiler, specified as a character vector.

    Hierarchy

    This property is read-only.

    Machine that contains the message, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the parent of the message in the model hierarchy, specified as a character vector.

    Identification

    Description for the message, specified as a string scalar or character vector.

    Document link for the message, specified as a string scalar or character vector.

    User-defined tag for the message, specified as data of any type.

    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.

    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

    getParentIdentify parent of object
    getReferencesIdentify references to symbol name
    renameReferencesRename symbol and update references to symbol name
    dialogOpen properties dialog box
    viewDisplay object in editing environment

    Examples

    collapse all

    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 R2015b

    expand all