Chapter 1. Modeling the State Structure of a System

Items and Parts

Core Modeling Concepts

Types
classify things and may have features.
There are two kinds of types: classifiers and features.
Classifiers
are types that classify things.
Examples: data types, item types, part types, action types.
Features
model the relations between things.
Examples: attributes, item properties, part properties, action steps.

Types

Examples of Classifiers and Features

An item type definition with two attributes
item def Person {
  attribute name : String;
  attribute age : Natural;
}
Two part type definitions
part def Engine;
part def Wheel;
A part type definition with four features
part def Car {
  attribute mass : ISQ::MassValue;
  Three part properties
  part engine : Engine;
  part wheels[4] : Wheel;
  ref part driver[0..1] : Person;
}
  1. The data type MassValue is predefined in the library package ISQ.
  2. wheels[4] means that the part property wheels has the multiplicity 4, implying that it has exactly 4 values.
  3. driver[0..1] means that this part property has at most one value.
  4. By default, part properties are "composite" features, representing parts/components, which cannot exist after the whole ceases to exist, unlike "referential" features.
  5. ref part means that this part property is not composite, but referential.

Terminology

SysML v2 comes with a superfluous jargon: calling classifiers (like data types or item types) "definitions" and calling features (like attributes or item properties) "usages", which is confusing.

Official SysML v2 TerminologyPreferrable (Classsical) Terminology
attribute definitiondata type
attribute usageattribute
item (part/port/action/etc.) definitionitem (part/port/action/etc.) type
item (part/port/etc.) usageitem (part/port/etc.) property
action usageaction property (or action step)

Connection Types

A connection is both a relationship between parts and a kind of part.

A connection type is an association that classifies connections between related parts.

Mounting association class model
part def Axle {...}
part def Wheel {...}
connection def Mounting {
  end [1] part mountingAxle : Axle;
  end [2] part mountedWheel : Wheel;
}

End properties, like mountingAxle and mountedWheel, always have the multiplicity 1.

The yellow multiplicities are called cross multiplicities.

The cross multiplicity [2] of the end property mountedWheel expresses the constraint that for any instance of Axle, there are exactly two links in the extent of Mounting linking the axle to two different wheels.

Connection Properties

An axle assembly consists of one axle, two wheels and two mount connections, such that each of the two wheels is connected to the axle via a mount connection.

part def Axle {...}
part def Wheel {...}
connection def Mounting {
  end [1] part mountingAxle : Axle;
  end [2] part mountedWheel : Wheel;
}
part def AxleAssembly {
  part axle : Axle;
  part wheels[2] : Wheel;
  connection mount[2] : Mounting 
    connect axle to wheels;
}

The connection property mount restricts the connection type Mounting by only allowing links formed with values from the corresponding part properties axle and wheels. It has exactly 2 values: one mount connection for each of the 2 wheels.

Ports and Interfaces

Ports, as values of port properties, are special objects representing connection points. The ports referenced by two port properties can be connected via an interface property for enabling transfers (e.g., of signals or physical quantities) if their types match in the sense that they have the same directed parameters, but with inverse direction.

port def MotorCtrlPort {
  out attribute speed : Real;
  out attribute dir : Integer;
  in errorStatus : Integer;
}
port def CtrlInputPort {
  in attribute speed : Real;
  in attribute dir : Integer;
  out errorStatus : Integer;
}
part def Vehicle {
  part motorController {
    port motorCtrlPort : MotorCtrlPort;
  }
  part motor {
    port ctrlInputPort : CtrlInputPort;
  }
  interface motorController.motorCtrlPort 
    to motor.ctrlInputPort;
}

An interface property is a special kind of connection property for connecting ports.

Functions as “Calculation Definitions”

A function (with named input parameters and a result parameter specified with return) can be declared as a calculation definition with calc def, like so:

calc def Average {
  in values[1..*] : Real;
  return : Real = sum(values) / size(values);
}

A function declared as a calculation definition can be used in expressions:

part def Sensor {
  attribute values[1..*] : Real;
  attribute avg : Real = Average( values); 
}

A function can also be embedded within a type in the form of a calculation property declared with calc and (1) defined by an inline expression or (2) typed by a calculation definition. An example of a calculation property defined by an inline expression is:

part def Sensor {
  attribute values[1..*] : Real;
  attribute avg : Real = average(); 
  calc average { sum(values) / size(values) }
}

Constraints

A constraint definition defines a reusable condition, like so:

constraint def MassConstraint {
  in partMasses[0..*] : ISQ::MassValue;
  in massLimit : ISQ::MassValue;
  sum( partMasses) <= massLimit
}

This constraint definition has two input parameters, partMasses and massLimit.

A constraint can be embedded within a type in the form of a constraint property declared with constraint and (1) defined by an inline Boolean expression or (2) typed by a constraint definition. An example of a constraint property typed by a constraint definition is:

part def Vehicle {
  attribute chassisMass : ISQ::MassValue;
  part engine : Engine {
    attribute mass : ISQ::MassValue;
  }
  constraint massConstraint : MassConstraint {
    in partMasses = (chassisMass, engine.mass);
    in massLimit = 2500[kg];
  }
}

An example of a constraint property defined by an inline expression is:

part def Vehicle {
  attribute chassisMass : ISQ::MassValue;
  part engine : Engine {
    attribute mass : ISQ::MassValue;
  }
  constraint massConstraint { chassisMass + engine.mass <= 2500[kg] }
}

Such a constraint may be true or false in a given context. It may be violated (false) without making the model inconsistent. Only if a constraint is asserted in the form of an assert constraint property, it must be true under all circumstances. Otherwise, it indicates an inconsistency. An example of an asserted constraint is the following:

part def Vehicle {
  attribute chassisMass : ISQ::MassValue;
  part engine : Engine {
    attribute mass : ISQ::MassValue;
  }
  assert constraint { chassisMass + engine.mass <= 2500[kg] }
}