Exercise 1 of 10
Match each SysML v1 term to its SysML v2 counterpart.
SysML v1SysML v2
Learn how SysML v2 describes what a part is made of and what it is like: part def, part, attribute, values and units, and your own value types with attribute def. With exercises, for beginners and SysML v1 users.
Lesson 1 gave the machine its parts. This lesson describes what the parts are like: their size, power and name. In SysML v2 this is done with attributes, which hold values. The running example stays the coffee machine.
An attribute inside a part def describes a characteristic of that part. It has a name and a type, just like a part usage. attribute modelName : String; means: every coffee machine has a modelName that is a string of text.
The basic types String, Boolean, Integer and Real come from the standard library package ScalarValues, which you import first.
// Excerpt of the coffee machine model
private import ScalarValues::*;
part def CoffeeMachine {
attribute modelName : String;
attribute cupCount : Integer;
attribute hasMilkFrother : Boolean;
}A = after the type gives the attribute a value: attribute modelName : String = "Aroma One";. Text values are written in double quotes, numbers without.
An attribute without a value only says that the characteristic exists. A part usage or a more specific definition can supply the value later, which lesson 3 shows.
// Excerpt of the coffee machine model
private import ScalarValues::*;
part def CoffeeMachine {
attribute modelName : String = "Aroma One";
attribute cupCount : Integer;
}A water tank does not hold “1.5”, it holds 1.5 litres. For this the standard library offers quantity types such as VolumeValue, PowerValue and DurationValue in the package ISQ, and units such as L, W and s in SI. A value with a unit is written with the unit in square brackets: 1.5 [L].
The standard library is part of the SysML v2 standard. PRISM does not load it. PRISM accepts these imports and names and draws the model, but it does not check quantities or units. Tools that load the library do.
// Excerpt of the coffee machine model
private import ISQ::*;
private import SI::*;
part def WaterTank {
attribute capacity : VolumeValue = 1.5 [L];
}
part def BrewUnit {
attribute brewTime : DurationValue = 25 [s];
}A boiler has a water temperature, and in everyday life that is 95 °C. The standard library handles Celsius with care: the unit °C and the absolute Celsius scale are separate definitions, which is a trap for beginners. This course therefore uses kelvin, the SI base unit: 95 °C is 368.15 K.
The type is TemperatureValue from ISQ.
// Excerpt of the coffee machine model
private import ISQ::*;
private import SI::*;
part def Boiler {
attribute waterTemp : TemperatureValue = 368.15 [K];
}If one number is not enough, define a value type with attribute def. It follows the pattern from lesson 1: a definition describes the kind of value, an attribute usage uses it.
Here a cup size consists of a volume and a name. The coffee machine then has an attribute typed by it.
// Excerpt, an own value type
private import ScalarValues::*;
private import ISQ::*;
attribute def CupSize {
attribute volume : VolumeValue;
attribute label : String;
}
part def CoffeeMachine {
attribute smallCup : CupSize;
}Use an attribute for a value that describes something: a temperature, a name, a count. Use a part for a thing of its own that can have attributes and parts itself.
The boiler’s water temperature is an attribute. The boiler is a part: it has a temperature, a power and, later, ports.
// Excerpt of the coffee machine model
private import ScalarValues::*;
part def Boiler;
part def CoffeeMachine {
attribute modelName : String;
part boiler : Boiler;
}The machine from lesson 1, now with attributes. The Pump has a power without a value; lesson 3 fills it in for a special pump. Lesson 4 returns to the structure and adds ports.
// The coffee machine model of this lesson
package CoffeeMachine {
doc /* A fictional coffee machine, modelled step by step in the PRISM learning module. */
private import ScalarValues::*;
private import ISQ::*;
private import SI::*;
part def WaterTank {
attribute capacity : VolumeValue = 1.5 [L];
}
part def Pump {
attribute power : PowerValue;
}
part def Boiler {
attribute waterTemp : TemperatureValue = 368.15 [K];
}
part def BrewUnit {
attribute brewTime : DurationValue = 25 [s];
}
part def CoffeeMachine {
attribute modelName : String = "Aroma One";
part tank : WaterTank;
part pump : Pump;
part boiler : Boiler;
part brewUnit : BrewUnit;
}
}Statements follow the OMG SysML v2 specification, Part 1 (Language Specification), in the clauses on attributes and on definition and usage, and the standard domain libraries: ScalarValues (Kernel Data Type Library) and ISQ and SI (Quantities and Units domain library). The note on Celsius refers to the definitions of °C and the Celsius scale in the SI library.
This is the coffee machine model of the lesson: the four part definitions now carry attributes with units, and the machine has a name. Edit the text; the diagram redraws while you type. Attributes are values and are not drawn in this diagram, they live in the text. Everything runs in your browser, nothing is sent anywhere. At the end of the page you can download the file and open it in any tool that reads SysML v2 textual notation.
The editor contains open-source components. Third-party notices · Source offer
10 short exercises. Every answer gets feedback right away. Exercises you get wrong come back at the end. Your progress stays in this browser.
Match each SysML v1 term to its SysML v2 counterpart.
SysML v1SysML v2
The tank has a capacity, a value with a unit. Which keyword completes the line?
part def WaterTank {
___ capacity : VolumeValue = 1.5 [L];
}Arrange the pieces into an attribute brewTime of type DurationValue with the value 25 seconds.
Drag the pieces, or use the arrow buttons.
DurationValueattribute;[s]:=brewTime25Tap the line that is not valid SysML v2.
private import ISQ::*;
private import SI::*;
part def WaterTank {
attribute capacity : VolumeValue = 1.5 L;
}Tap a line, or move to it with the Tab key and press Enter.
Type the unit symbol for litres, as the SI library defines it.
part def WaterTank {
attribute capacity : VolumeValue = 1.5 [___];
}Which line gives the pump a power of 20 watts?
part def Pump {
// which line gives the power?
}The boiler's target water temperature is 95 °C. How do you model the temperature inside the boiler?
What are ISQ and SI in private import ISQ::*; and private import SI::*;?
What is smallCup in this model?
attribute def CupSize {
attribute volume : VolumeValue;
attribute label : String;
}
part def CoffeeMachine {
attribute smallCup : CupSize;
}Boiler is a part def. What is wrong with attribute heater : Boiler; inside CoffeeMachine?
The coffee machine model as a SysML v2 text file.
Download coffee-machine.sysmlPRISM turns SysML v2 text like this into diagrams and views. Try it on the sample model.
Try it nowDerive an espresso machine from the coffee machine: specialization, redefinition and multiplicity.