Exercise 1 of 10
Which statement about the textual and the graphical notation of SysML v2 is correct?
Learn what SysML v2 is, how its text and diagrams describe one model, and the pattern behind the whole language: definition and usage. With package, import, doc and comments, exercises and a coffee machine model. For beginners and SysML v1 users.
SysML v2 is a modelling language for systems engineering, standardised by the OMG. If you want the bigger picture first, read SysML v2 and the textual notation. This lesson shows what a SysML v2 model looks like and introduces the one pattern the rest of the course builds on. The running example is an invented coffee machine.
SysML v2 defines a textual and a graphical notation for the same model. Both notations express the same model: the elements in the text below are the elements you would see in a diagram. Tools can show the text, the diagram, or both side by side.
This course mostly works with text, because text is precise and easy to compare. Every lesson also shows the matching diagram in the editor, so you see both notations.
// Excerpt of the coffee machine model
part def Pump;The most important pattern in SysML v2: a definition describes a kind of thing, a usage puts such a thing into a context. part def Pump; defines what a pump is. part pump : Pump; says that this machine has a pump, and the : Pump types it by the definition.
By convention definitions start with a capital letter and usages with a lowercase letter. A definition can have many usages, for example two pumps.
// Excerpt of the coffee machine model
part def Pump;
part def CoffeeMachine {
part pump : Pump;
}part is only one element kind. Attributes, items, ports and actions follow the same pattern: attribute def and attribute, item def and item, port def and port, action def and action. If you know the pattern once, you can read every one of them.
The coming lessons fill in these kinds one after another. You do not need to know them yet.
// Excerpt, one pattern for different kinds
attribute def Temperature;
item def Water;
port def WaterPort;
action def Brew;A package groups model elements and gives them a namespace. Everything declared inside the braces is a member of the package. Our whole coffee machine lives in one package.
From outside, a member is reached with its qualified name: the package name, two colons and the member name, as in Components::Pump.
// Excerpt of the coffee machine model
package Components {
part def Pump;
part def Boiler;
}To use members of another package by their simple name, write an import. import Components::*; makes all members of Components available. import Components::Pump; imports only Pump.
You will often see private import. It keeps the imported names from being visible to everyone who imports your package. From lesson 2 on, imports also bring in the standard library with units.
// Excerpt, two packages
package Components {
part def Pump;
}
package Machine {
import Components::*;
part def CoffeeMachine {
part pump : Pump;
}
}doc attaches documentation to the element it stands in. It becomes part of the model, so tools can show it. Write what the element is for, not what the code already says.
A line starting with // is a note for readers of the text. It is not stored in the model.
// Excerpt of the coffee machine model
part def Pump {
doc /* Moves water from the tank to the boiler. */
// Internal note: this line is not stored in the model
}Here is the first version of the machine: one package, four part definitions, and a CoffeeMachine with one usage of each. In the next lessons the same machine gets attributes, variants and ports. In lesson 4 it connects the parts.
// The coffee machine model of this lesson
package CoffeeMachine {
doc /* A fictional coffee machine. */
part def WaterTank;
part def Pump;
part def Boiler;
part def BrewUnit;
part def CoffeeMachine {
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 language description (elements, packages and imports, definition and usage, comments and documentation) and the KerML specification for the lexical rules of notes and comments.
This is the coffee machine model of the lesson: four part definitions and a CoffeeMachine that uses each of them once. Edit the text; the diagram redraws while you type. 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.
Which statement about the textual and the graphical notation of SysML v2 is correct?
Match each SysML v1 term to its SysML v2 counterpart.
SysML v1SysML v2
Which line places a pump into a machine, instead of describing the kind of thing a pump is?
part def Pump;
part def CoffeeMachine {
part pump : Pump;
}Define a new kind of part called Boiler. Which keyword completes the line?
___ def Boiler;Arrange the pieces into a usage of the definition Boiler named boiler.
Drag the pieces, or use the arrow buttons.
;Boilerpart:boilerTap the line that is not valid SysML v2.
package CoffeeMachine {
part def Pump;
def part Boiler;
part def BrewUnit;
}Tap a line, or move to it with the Tab key and press Enter.
How many definitions and how many usages does this model contain?
part def Pump;
part def CoffeeMachine {
part mainPump : Pump;
part backupPump : Pump;
}Which line is stored in the model as documentation of Pump?
part def Pump {
// Check the dimensions again
doc /* Moves water from the tank to the boiler. */
}Inside Machine there is no import. Which line uses the Pump from the package Components?
package Components {
part def Pump;
}
package Machine {
part def CoffeeMachine {
// which line uses the pump?
}
}What does import Components::*; do inside the package Machine?
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 nowGive the parts of the coffee machine properties: attributes, values and units.