Chapter 3. Modeling the Dynamics of a System

Actions

Action Types and Action Steps

An action type classifies actions (or action performances). An action property ("usage") is an action-valued feature. A composite action type has action properties representing action steps.

action def Focus;
action def Shoot;
action def TakePicture {
  action focus[1] : Focus;
  action shoot[1] : Shoot;
}

The composite action type TakePicture has two action steps, focus and shoot, both of which have the multiplicity 1 expressing that a TakePicture action is composed of one focus and one shoot action.

part def Camera {
  attribute model : String;
  action focus[*] : Focus;
  action shoot[*] : Shoot;
}

The part type Camera has two action properties, focus and shoot, both of which have the multiplicity zero-or-many expressing that during the lifetime of a Camera, it may perform zero or many actions of these two types.

How to Express "Control Flow" Arrows in SysML v2?

What does a "control flow" arrow mean?

Succession

Action steps, such as focus and shoot, can be sequenced with the help of successions, which are special properties for connecting action steps expressing temporal precedence.

action def TakePicture {
  action focus : Focus;
  action shoot : Shoot;
  succession focus then shoot;
}

In this example, the source and target of the succession, focus and shoot, have the implicit default multiplicity of 1, implying that a focus action is succeeded by exactly one shoot action and a shoot action is preceded by exactly one focus action.

Succession Multiplicities

action def TakePictureWithMultiFocusing {
  action focus[1..*] : Focus;
  action shoot[1] : Shoot;
  // a shoot action must be preceded by at least one focus action, and
  // a focus action must be succeeded by exactly one shoot action
  succession multiFocusing
    first [1..*] focus then [1] shoot;
  // a shoot action must not be succeeded by a focus action
  first [0] shoot then [0] focus;
}

Admissible sequences: ( focus, shoot ), ( focus, focus, shoot ), ...
Non-admissible sequences: ( shoot, focus ), ( focus, shoot, focus ), ...

Passing Parameters to Succeeding Actions

Parameters can be passed in the form of bindings or with the help of flows, both of which are special connection properties.

action def Focus { in scene; out image; }
action def Shoot { in image; out picture; }
action def TakePicture {
  in scene : Scene;
  out picture : Picture;
  binding focus.scene = scene;
  action focus : Focus;
  succession focus then shoot;
  flow focus.image to shoot.image;
  action shoot : Shoot;
  binding picture = shoot.picture;
}

While bindings represent abstract connections, flows represent interactions in space and time, possibly having specific properties. This means that when parameter passing is modeled with a binding, it does not take any time. Consequently, when parameter passing takes time (as in streaming), it should be modeled as a flow.

Coordinating Actions with Control Nodes

Control nodes are used for expressing conditional and parallel branching of control flows (e.g., in flow-charts). In SysML v2, they represent special, predefined types of action steps.

Our example describes the loading of a battery with the help of a loop that is constructed with the control nodes Decide and Merge.

Visual and Textual Notation

action def MonitorBattery {
  out batteryCharge : Real;
}
action def ChargeBattery {
  first start;
  then merge continueCharging;
  then action monitor : MonitorBattery;
  then decide;
    if monitor.batteryCharge < 100 then addCharge;
    else endCharging;
  action addCharge : AddCharge;
  then continueCharging;
  action endCharging : EndCharging;
  then done;
}

This example is based on a corresponding example presented by Ed Seidewitz in his Introduction to the SysML v2 Language Textual Notation.