MBSE iNsightsMBSE iNsights

· 13 min read

Reading a SysML v2 Sequence View: What Travels Between the Parts

A sequence view is the quickest way to show who talks to whom, and in what order. Here is a small Fish On! exchange, written in SysML v2 text and drawn as a sequence view, with every line, dot and arrow explained: lifelines, event occurrences, messages, payloads and successions.

A sequence view answers a question every design review asks sooner or later: who sends what to whom, and in what order? It is one of the standard views in SysML v2, and it is one of the easiest to read once you know what each mark means. It is also one of the easiest to misread, because some of what looks like information on the page is only layout.

This article takes one small exchange from the Fish On! rod sensor system, the running example in Models That Answer, writes it in SysML v2 text, shows it as a sequence view, and explains every element of the view.

The exchange

A sensor on the fishing rod detects a bite and sends a radio packet to the base station on the bank. The base station forwards an alert to the angler’s phone. The angler taps the phone to silence the alarm, and the phone sends a silence command back to the base station.

Here is that exchange in SysML v2:

package BiteAlertSequence {
    private import ScalarValues::*;

    item def BitePacket { attribute strength : Integer; }
    item def AppAlert;
    item def SilenceCommand;

    part def RodSensor;
    part def BaseStation;
    part def PhoneApp;

    occurrence def BiteAlert {
        part rod : RodSensor {
            event occurrence biteSent[1];
        }
        part base : BaseStation {
            event occurrence biteReceived[1];
            event occurrence alertSent[1];
            event occurrence silenceReceived[1];
            first biteReceived then alertSent;
            first alertSent then silenceReceived;
        }
        part app : PhoneApp {
            event occurrence alertReceived[1];
            event occurrence silenceSent[1];
            first alertReceived then silenceSent;
        }
        message bite[1] of BitePacket
            from rod.biteSent to base.biteReceived;
        message alert[1] of AppAlert
            from base.alertSent to app.alertReceived;
        message silence[1] of SilenceCommand
            from app.silenceSent to base.silenceReceived;
    }

    view biteAlertSequence : StandardViewDefinitions::SequenceView {
        expose BiteAlert::**;
    }
}

Reading the listing, line by line

Before looking at the picture, here is what each line of the text says.

  • package BiteAlertSequence { … } is a namespace that holds everything else. private import ScalarValues::*; brings in the standard library’s basic value types, here Integer.
  • item def BitePacket { attribute strength : Integer; } defines a kind of thing that can be passed around: a bite packet, which carries a strength value. AppAlert and SilenceCommand are two more kinds of item. These are the payloads, the things the messages carry.
  • part def RodSensor; and the two lines after it define the kinds of part that take part in the exchange. They are left empty here because nothing about their structure matters to the sequence.
  • occurrence def BiteAlert { … } defines the exchange itself. An occurrence is something that happens over time, so a sequence of messages belongs inside one.
  • part rod : RodSensor { … } declares a participant: the rod sensor that takes part in a BiteAlert, defined by (:) the kind RodSensor. The other two participants are base and app.
  • event occurrence biteSent[1]; names something that happens in the rod sensor’s life: the sending of the bite packet. Each part has the events it takes part in. The [1] is a multiplicity: the bite is sent exactly once in each BiteAlert. Leave it off and SysML v2 gives an event occurrence the multiplicity [0..*], any number of times, including never. That difference matters when the order is reasoned about, as the section on successions shows.
  • first biteReceived then alertSent; is a succession: on the base station, the bite is received before the alert is sent.
  • message bite[1] of BitePacket from rod.biteSent to base.biteReceived; declares a message named bite, sent exactly once ([1]), carrying a BitePacket, leaving the rod sensor at its biteSent event and arriving at the base station’s biteReceived event. The dot in rod.biteSent reads “the biteSent of rod”.
  • view biteAlertSequence : StandardViewDefinitions::SequenceView { … } declares the view. In SysML v2 a view is part of the model, written in the same text. SequenceView is the standard library’s kind of view for this, and expose BiteAlert::**; says what the view shows: BiteAlert itself and everything inside it, all the way down.

Why the ”…Sent” and ”…Received” names are events, not attributes

It is tempting to read biteSent as a property of the rod sensor, an attribute. It is not, and the difference matters. An attribute is a data value a thing has, such as a number or a name. An event occurrence is something that happens during the thing’s lifetime. Messages travel between happenings, not between values. The graphical grammar of SysML v2 states that “ends of messages must refer to occurrences”, and an attribute’s value is data, not an occurrence. In the textual grammar, each end of a message is itself an event occurrence. So the ends of a message are events, and each part declares the events it takes part in.

The view

And here is the view, drawn:

A SysML v2 sequence view titled Sequence view of BiteAlert, verdict Consistent. Three part heads across the top, rod : RodSensor, base : BaseStation and app : PhoneApp, each with a dashed lifeline below. A solid message arrow labeled bite of BitePacket runs from the event biteSent on the rod's lifeline to biteReceived on the base station's. A message labeled alert of AppAlert runs from alertSent on the base station to alertReceived on the phone. A message labeled silence of SilenceCommand runs back from silenceSent on the phone to silenceReceived on the base station.
The view biteAlertSequence, rendered from the listing above. Lifelines hang from the three parts, dots mark event occurrences, and solid arrows are messages labeled with their names and payloads. The three successions in the text are left out of the figure; they are explained below.

The diagram was rendered directly from the listing above, not drawn by hand. Everything on it comes from a line of the text, and the rest of this article walks through each kind of mark.

Lifelines: the parts, with time running down

Each box along the top is a part usage: rod : RodSensor, base : BaseStation and app : PhoneApp. The dashed line hanging below each box is its lifeline, the life of that part over the course of the exchange.

The specification describes the view this way: “The typical rendering in graphical notation depicts the exposed features horizontally along the top, with vertical lifelines. The time axis is vertical, with time increasing from top to bottom.” So the page has two directions that mean different things. Left to right is just which part. Top to bottom is the direction time runs; the order itself is in the model, as the section on successions shows.

Notice what the view is a view of: the occurrence definition BiteAlert. A sequence is something that happens, so it belongs to an occurrence, and the parts inside it are the participants. Parts of the same kinds, a RodSensor, a BaseStation and a PhoneApp, can take part in many different occurrences, each with its own sequence.

Event occurrences: the dots on the lifelines

Each black dot on a lifeline marks an event occurrence, a named happening in that part’s life. In the text, each one is a line like event occurrence biteSent[1]; inside the part it belongs to. The base station has three events, the phone has two and the rod sensor has one.

The events are what everything else attaches to. Messages leave from one event and arrive at another, and orderings are stated between events. Naming the events explicitly is what lets the model say precisely when, in each part’s life, a message is sent or received.

Messages: the solid arrows

Each solid line with an open arrowhead is a message. The text that declares it reads almost like the picture:

message bite of BitePacket from rod.biteSent to base.biteReceived;

That line has four parts, and the label on the arrow shows two of them:

  • bite is the message’s name.
  • of BitePacket is its payload: what is transferred. The payload is optional. A message with no of clause does not constrain what is transferred.
  • from rod.biteSent is the source event, at which the transfer is initiated.
  • to base.biteReceived is the target event, at which it is received. The arrowhead points at the target.

What a message does not say matters just as much. The specification defines a message as a flow usage that “specifies that some transfer happens between the source and target ends, and can define the payload that is to be transferred. However, a message does not specify how the payload is to be obtained from the source or delivered to the target.” There are no ports, no radio and no protocol in this model, and the view does not pretend there are. A message is the abstract, logical exchange. The specification adds that this kind of interaction “may be realized in a more detailed model using streaming or succession flows (or transfers from send actions to accept actions, see 7.17).”

That makes the sequence view a good first conversation with a design team. You can agree on what is exchanged and in what order before anyone decides how the bytes travel.

Successions: the order is stated, not drawn

Look at the base station’s lifeline. The bite arrives, then the alert goes out, then the silence command comes back. The view shows that order from top to bottom, but in the model the order is not a matter of position on the page. It is stated:

first biteReceived then alertSent;
first alertSent then silenceReceived;

Each first … then is a succession: the first event must happen before the second. SysML v2 does have a graphical symbol for a succession in a sequence view, a dashed arrow from one event to the other, but the figure above leaves them out to keep the picture simple. The figure places the events in the order the exchange happens; the successions are what make that order true in the model.

This is the most common misreading of a sequence view. Two dots on a lifeline, one below the other, look ordered. But position on the page is not a statement in the model. Only the model can order two events, and it has two ways to do it: a succession, and a message. In the SysML v2 library, a message’s source event is the start of the transfer or happens before it, and its target event is the end of the transfer or happens after it. If nothing in the model orders two events, neither a succession nor a chain of messages and successions through other lifelines, they are not ordered at all; the layout simply had to put one of them first. A sequence view drawn by hand can imply an order the model never states, and a reviewer reading the picture would never know.

That also means one of the base station’s successions is already implied. The alert goes out before it is received, the phone receives it before it sends the silence command, and the silence command is sent before it arrives. Because every event and message in the exchange is declared [1], each of those steps certainly happens, so the model already entails that alertSent comes before silenceReceived. Stating it again as a succession does no harm, and it keeps the base station’s own order readable on its lifeline.

Writing the successions also lets a reasoner work with the order. Asked what must happen before the silence command is received, the SysML v2 Semantic Reasoner (SSR 1.27.1, with the OMG standard library loaded) answers from the model, marking which orderings the text states and which it inferred:

PROVED — 6 occurrence(s) must happen before silenceReceived.
  alert  [INFERRED]  alert happens before silenceReceived
  alertReceived  [INFERRED]  alertReceived happens before silenceReceived
  alertSent  [ASSERTED]  alertSent happens before silenceReceived
  biteReceived  [INFERRED]  biteReceived happens before silenceReceived
  bite  [INFERRED]  bite happens before silenceReceived
  biteSent  [INFERRED]  biteSent happens before silenceReceived

Only one of the six is written in the text. biteReceived before silenceReceived, for example, follows from the two successions on the base station’s lifeline, chained together through alertSent. The chain holds only because alertSent is declared [1]. Without it the alert might never be sent, and then nothing would order the bite and the silence command; the reasoner would rightly conclude nothing. With successions and multiplicities in the model, questions such as “what must happen before the silence command is received?” have answers you can check, not just a picture you can look at.

Reading the whole view

Put together, the view reads top to bottom as a short story:

  1. The rod sensor sends bite, carrying a BitePacket, to the base station.
  2. Having received the bite, the base station sends alert, carrying an AppAlert, to the phone.
  3. Having received the alert, the phone sends silence, carrying a SilenceCommand, back to the base station.

Every word of that story is in the model: the participants, the events, what moves between the parts and the order of the events within each part. The diagram is a way of seeing the model, not a second source of truth that can drift away from it.

One model, many views

A sequence view is not a separate drawing that has to be kept in step with the rest of the model. It holds no copy of what it shows. The specification describes what a view does: “A view usage exposes a portion of a model”. The expose BiteAlert::**; line chooses which portion, and the view draws what is already there.

So the same elements show up wherever another view exposes them. A general view of the package shows BitePacket, AppAlert and SilenceCommand as item definitions, and RodSensor, BaseStation and PhoneApp as part definitions. An interconnection view of BiteAlert can show the same three messages as arrows between the parts; the specification’s own table of message notation includes a “Message (in Interconnection View)”, in which the message’s ends are labeled with the names of its events. Rename alertSent in the text and it is renamed in every view at once, because there is only one alertSent.

That is the answer to the question every team with more than one diagram eventually asks: how do we keep the views consistent? You do not. You keep one model, and the views are windows onto it.

What a message is connected to

A message is not a free-floating arrow. It is tied into the model in three ways.

  • Through its payload. of BitePacket refers to the item definition BitePacket. That is the same definition you would use for the items that flow through the rod sensor’s radio port in a more detailed interconnection view, so the logical exchange and the physical one name the same thing.
  • Through its events. from rod.biteSent and to base.biteReceived refer to events declared on the parts. In the grammar, the ends of a message are themselves event occurrences that refer to those events, so the message is anchored to something that happens in each participant’s life.
  • As behavior. “A flow usage is an action usage”, and a message is a kind of flow usage. A message is something that happens, so it sits naturally inside an occurrence such as BiteAlert.

Breaking an event down into more detail

The specification is explicit that an event is deliberately abstract: “An event is a reference from one occurrence to another occurrence that represents some relevant happening during the lifetime of the first occurrence. Such an event model makes no commitment as to how the event actually happens. Different specializations of the containing occurrence may realize the modeled event in different ways.”

That is how a sequence is refined without being redrawn. In the metamodel, an event occurrence usage “represents another OccurrenceUsage occurring as a suboccurrence of the containing occurrence”, and the occurrence it represents is attached with references (or its symbol, ::>). Until you say otherwise, an event refers only to itself. Later, a more detailed model says what the event really is:

occurrence def DetailedBiteAlert :> BiteAlert {
    part :>> rod {
        action detectBite;
        action transmitBite;
        first detectBite then transmitBite;
        event occurrence :>> biteSent references transmitBite;
    }
    part :>> base {
        action forwardAlert;
        event occurrence :>> alertSent references forwardAlert;
    }
}

Reading it line by line:

  • occurrence def DetailedBiteAlert :> BiteAlert specializes the exchange. Every DetailedBiteAlert is a BiteAlert, so it keeps the same three participants, the same events, the same messages and the same order.
  • part :>> rod { … } redefines the rod sensor participant to add detail to it. :>> means “redefines”.
  • action detectBite; action transmitBite; give the rod sensor two steps, and first detectBite then transmitBite; puts them in order.
  • event occurrence :>> biteSent references transmitBite; is the key line. It says that the event biteSent is the rod sensor performing transmitBite. The abstract event now has a concrete realization.

The original sequence still holds for DetailedBiteAlert; nothing in it had to change. And transmitBite is an action like any other, so it can be broken down further and shown in its own action flow view. The specification names the usual realizations: the sending and receipt of a message “can possibly be realized as the performance of a send action and corresponding accept action, respectively, with the message being the resulting transfer between them”, or “as the start and end of an explicitly modeled flow”. A second specialization could realize the same events another way, for example in a version of the kit that alerts over Wi-Fi instead of radio, and both would still be BiteAlerts.

The reasoner reads the refined model too. With the DetailedBiteAlert added to the package, SSR still reports the model consistent and still infers that biteReceived happens before silenceReceived. The redefined events keep the [1] of the events they redefine.

Going further

A sequence like this one can also be the result of behavior rather than its starting point. Recipe 29 of How to Model Anything in SysML v2 models a protocol handshake as two state machines whose transitions accept one message and send the next; the message sequence is written nowhere, because the two machines produce it. Spread 21 of SysML v2 at a Glance covers succession, first … then, on two facing pages. The full Fish On! model, including the alert path this exchange runs over, is built chapter by chapter in Models That Answer: A Practitioner’s Guide to Model-Based Systems Engineering with SysML v2. For the ports and interfaces that a more detailed model would add underneath these messages, see Ports and Interfaces in SysML v2.

Get the next article by email

One email when a new article goes live, usually Thursday morning. SysML v2 and MBSE practice, no filler. Unsubscribe with one click.

More of this, on video

Walkthroughs in SysML v2 and MBSE tooling, with the model on screen.

Subscribe on YouTube