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

    example

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

    Input Arguments

    expand all

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

    Properties

    expand all

    Interface

    Name of the message, specified as a character vector.

    Scope of the message, specified as 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 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'.

    For more information, see Initial Value.

    Initial value of the message data, specified as a character vector. For more information, see Initial Value.

    Example: message.Props.InitialValue = '1.5';

    Whether the message data accepts complex values, specified as 'On' or 'Off'. For more information, see Complex Data in Stateflow Charts.

    Example: message.Props.Complexity = 'On';

    Priority for the message, specified as a 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 Type

    Data type of the message, specified as a 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'

      • 'ml' (Supported only in charts that use C as the action language)

      • 'string' (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.

    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 Message properties dialog box. For more information, see Specify Type of Stateflow Data.

    Example: message.Props.Method = 'Built-in';

    Name of the Simulink.Bus object that defines the message data, specified as a character vector. This property applies only when the Props.Type.Method property of the message is 'Bus Object'. For more information, see Access Bus Signals Through Stateflow Structures.

    Example: message.Props.Type.BusObject = 'COUNTERBUS';

    Name of the enumerated type that defines the message data, specified as a character vector. This property applies only when the Props.Type.Method property of the message is 'Enumerated'. For more information, see Reference Values by Name by Using Enumerated Data.

    Example: message.Props.Type.EnumType = 'BasicColors';

    Expression that evaluates to the data type of the message data, specified as a character vector. This property applies only when the Props.Type.Method property of the message is 'Expression'. For more information, see Specify Data Properties by Using MATLAB Expressions.

    Example: message.Props.Type.Expression = 'type(y)';

    Signedness of the fixed-point message data, specified as a numeric or logical 1 (true) or 0 (false). This property applies only when the Props.Type.Method property of the message is 'Fixed point'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: message.Props.Type.Signed = false;

    Word length, in bits, of the fixed-point message data, specified as a character vector. This property applies only when the Props.Type.Method property of the message is 'Fixed point'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: message.Props.Type.WordLength = '32';

    Method for scaling the fixed-point message data, specified as 'Binary point', 'Slope and bias', or 'None'. This property applies only when the Props.Type.Method property of the message is 'Fixed point'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: message.Props.Type.Fixpt.ScalingMode = 'Binary point';

    Fraction length, in bits, of the fixed-point message data, specified as a character vector. This property applies only to fixed-point message data when the Props.Type.Fixpt.ScalingMode property is 'Binary point'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: message.Props.Type.Fixpt.FractionLength = '2';

    Slope of the fixed-point message data, specified as a character vector. This property applies only to fixed-point message data when the Props.Type.Fixpt.ScalingMode property is 'Slope and bias'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: message.Props.Type.Fixpt.Slope = '2^-2';

    Bias of the fixed-point message data, specified as a character vector. This property applies only to fixed-point message data when the Props.Type.Fixpt.ScalingMode property is 'Slope and bias'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: message.Props.Type.Fixpt.Bias = '0';

    Whether to prevent replacement of the fixed-point type of the message data with an autoscaled type chosen by the Fixed-Point Tool (Fixed-Point Designer), specified as a numeric or logical 1 (true) or 0 (false). For more information, see Autoscaling Using the Fixed-Point Tool (Fixed-Point Designer).

    Example: message.Props.Type.Fixpt.Lock = true;

    This property is read-only.

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

    Data Size

    Size of the message data, specified as a character vector. For more information, see Specify Size of Stateflow Data.

    This property is read-only.

    Message data size 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 character vector.

    Document link for the message, specified as a 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 the model.

    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

    classhandleProvide class handle for object
    dialogOpen properties dialog box
    getReturn MATLAB structure containing property settings of object or array of objects
    setSet properties with specified values
    upReturn parent of object
    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';
    Introduced in R2015b