systemcomposer.interaction.Message - Message between lifelines in interaction - MATLAB (original) (raw)
Main Content
Message between lifelines in interaction
Since R2024a
Description
A Message
object represents a communication between two lifelines of an interaction. On the sequence diagram representing the interaction, a message is shown as an arrow. Messages have labels that can describe the communication occurrence either formally or informally. A message corresponds to a connector connecting ports of two components in an architecture model.
A message label has a trigger, an optional guard, and an optional constraint in the form of trigger[guard]{constraint}
.trigger
represents the identifying event for this message.guard
represents an additional condition to determine whether the message occurs. constraint
is an expression that is expected to be true when this message occurs.
- In signal events, the trigger follows this format:
direction(signal [+|-] value)
, which specifies a triggering edge with a direction and an expression. The direction can be:- Rising — The edge expression is rising from strictly below zero to a value equal to or greater than zero.
- Falling — The edge expression is falling from strictly above zero.
- Crossing — The edge expression either rising or falling past zero.
- In message events, the trigger is in the format
port
, which specifies the name of the input message port and represents the arrival of a message. - A guard in square brackets on the message label is a MATLAB® Boolean expression that is an additional condition to determine whether the message occurs. Evaluation of the guard only occurs once the software detects a valid trigger. During execution, the sequence diagram waits to proceed to the next message until the guard expression evaluates to true.
- A constraint in curly brackets on the message label is a MATLAB Boolean expression that specifies an expected value of inputs to the destination lifeline. During execution, the evaluation of the constraint determines whether the sequence diagram shows a pass or fail for that message.
Properties
Message type, specified as one of these options:
"Signal"
for signal-based communication"Message"
for Simulink® message-based communication
Data Types: string
Message label, specified as a string.
Data Types: string
Unique external identifier, specified as a character vector. The external ID is preserved over the lifespan of the element and through all operations that preserve the UUID
.
Data Types: char
Universal unique identifier, specified as a character vector.
Example: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'
Data Types: char
Object Functions
move | Move message within interaction |
---|---|
destroy | Remove model element |
Examples
You can use read-only API workflows to navigate sequence diagrams in System Composer™ and display information about each element.
Open Traffic Light Example
Open the traffic light example architecture model so that you can inspect the sequence diagrams visually and confirm the programmatic outputs.
model = systemcomposer.openModel("TLExample");
To view the sequence diagrams associated with the model, on the System Composer toolstrip, navigate to Modeling > Sequence Diagram.
Programmatically Navigate Sequence Diagram
Collect the sequence diagrams represented by interactions
that contain specific interactions of elements in the model.
interactions = model.getInteractions;
For the first interaction, extract the name of the sequence diagram.
disp("The first sequence diagram is called " + interactions(1).Name + ".")
The first sequence diagram is called SignalSequence.
For this sequence diagram, display each lifeline and the component the lifeline represents.
for i = 1:length(interactions(1).Lifelines) disp("The " + interactions(1).Lifelines(i).Name + ... " lifeline represents the " + ... interactions(1).Lifelines(i).RelatedElements.Name + ... " component.") end
The source lifeline represents the source component. The poller lifeline represents the poller component. The lampController lifeline represents the lampController component. The ped lamp lifeline represents the ped lamp component.
Display the contents of one message in the root fragment.
disp("The sequence diagram message starting at the " + ... interactions(1).RootFragment.Operands.Fragments(1).Name + ... " message end is of type " + ... string(interactions(1).RootFragment.Operands.Fragments(1).Message.Type) + ... " and the message label is " + ... interactions(1).RootFragment.Operands.Fragments(1).Message.Condition + ".")
The sequence diagram message starting at the switchout message end is of type Signal and the message label is rising(sw-1){sw==1}.
Use Iterator Utility to Step Through Sequence Diagram
Step through the Inhibit
sequence diagram using the Iterator
utility.
interaction = model.getInteraction('Inhibit'); interaction.open
Display the annotation from the interaction.
disp(interaction.Annotations.Content)
When inhibit is true, it means pedestrian crossing is not controlled by a walk signal on this intersection.
Use an iterator to navigate through all elements of a sequence diagram before extracting their properties.
iterator = systemcomposer.interaction.Iterator(interaction.RootFragment); next = iterator.next; while ~isempty(next) disp(class(next)) next = iterator.next; end
systemcomposer.interaction.RootFragment systemcomposer.interaction.Operand systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent systemcomposer.interaction.AltFragment systemcomposer.interaction.Operand systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent systemcomposer.interaction.Operand systemcomposer.interaction.MessageEvent systemcomposer.interaction.MessageEvent
More About
Term | Definition | Application | More Information |
---|---|---|---|
Interaction | An interaction specifies how each part of a system should interact as a sequence of message exchanges. | Use interactions to describe operational system behaviors. | Describe System Behavior Using Sequence Diagrams |
Sequence diagram | A sequence diagram is a visual representation of an interaction. | Use sequence diagrams to visually specify how each part of a system should interact. | Describe System Behavior Using Sequence Diagrams |
Lifeline | A lifeline represents an instance of a component as a participant of an interaction. | A lifeline corresponds to a component in an architecture. | Describe Interactions with Lifelines and Messages |
Message | A message represents communication between two lifelines. Messages have labels to specify the expected condition for the message to occur. | A message label has a trigger, an optional guard, and an optional constraint where a trigger represents the identifying event for this message, a guard represents an additional condition to determine whether the message occurs, and a constraint is an expression that is expected to be true when this message occurs. | Describe Interactions with Lifelines and Messages |
Gate | A gate represents the root of an architectural hierarchy. | A gate allows you to describe the exchange of messages between the architecture and its environment. | Describe Interactions with Lifelines and Messages |
Annotation | An annotation describes the elements of a sequence diagram. | Use annotations to provide detailed explanations of elements or workflows captured by sequence diagrams. | Annotate Sequence Diagrams with Annotations |
Fragment | A fragment encloses a group of lifelines and messages within an interaction to allow for the specification of more complex patterns of interaction. | A fragment defines the type of ordering logic such as looping and alternatives. Fragments can have one or more operands. | Model Complex Interactions with Fragments and Operands |
Operand | An operand is a region in a fragment, or group of messages. The condition of an operand specifies whether the messages inside the operand execute. | The condition of an operand can specify constraints on the input signal of a lifeline as a MATLAB Boolean expression. | Model Complex Interactions with Fragments and Operands |
Duration constraint | A duration constraint defines a constraint on elapsed time between a start and an end occurrence. | Use duration constraints to explicitly express a constraint on the duration between a start occurrence and an end occurrence. | Specify Timing Constraints Between Message Events with Duration Constraints |
Version History
Introduced in R2024a
See Also
Tools
Functions
- openViews | sim | addInteraction | getInteraction | getInteractions | open | addLifeline | addFragment | addOperand | addMessage | addDurationConstraint | addAnnotation | findLifeline | findElement | move | move | move | destroy | next | current | reset
Objects
- systemcomposer.arch.Model | systemcomposer.interaction.Interaction | systemcomposer.interaction.Iterator | systemcomposer.interaction.Lifeline | systemcomposer.interaction.MessageEvent | systemcomposer.interaction.FormalGate | systemcomposer.interaction.Fragment | systemcomposer.interaction.Operand | systemcomposer.interaction.DurationConstraint | systemcomposer.interaction.Annotation