Exercise 1 of 10
What does item def Water; define?
Learn how SysML v2 describes what flows through a system and where it crosses a boundary: item def, port def, in/out/inout, ports on parts, conjugation with ~ and a first connect. With exercises, for beginners and SysML v1 users.
SysML v2 describes a system as parts that exchange things with each other. This lesson covers the two building blocks for that: the things that flow, and the points where they cross a part’s boundary. The running example is an invented coffee machine. If you want the bigger picture first, start with SysML v2 and the textual notation.
An item def defines a kind of thing that can flow through a system: water, electricity, coffee. It is a type and nothing more. Nothing flows yet, and no part is involved.
Items are not limited to matter. Energy and information are items too. In our coffee machine we need three.
// Excerpt of the coffee machine model
item def Water;
item def Electricity;
item def Coffee;A port def describes an interface point: which items cross it, and in which direction. The direction keyword in, out or inout stands in front of each item inside the port definition.
The direction is relative to the part that owns the port: in means the item enters that part through the port. in item water : Water; means: water enters the part here. inout means the item can pass both ways, for example energy into and out of a battery.
// Excerpt of the coffee machine model, plus a battery port for inout
port def WaterPort { in item water : Water; }
port def PowerPort { in item power : Electricity; }
port def CoffeePort { out item coffee : Coffee; }
port def BatteryPort { inout item energy : Electricity; }A part def defines a kind of part. A port usage inside it, introduced with port, places an interface point on that part. It has a name and is typed by a port definition.
Read port waterIn : WaterPort; as: this part has a port called waterIn of type WaterPort. Because WaterPort has in item water, the pump receives water through it.
// Excerpt of the coffee machine model
part def Pump {
port waterIn : WaterPort;
port powerIn : PowerPort;
}The pump must also deliver water. Do we need a second port definition with out item water? No. A ~ in front of the type gives the conjugated port definition: same items, every direction reversed. in becomes out, out becomes in, inout stays inout.
A port and its conjugate fit together: what one delivers, the other receives. That is why WaterTank and Pump can be linked.
// Excerpt of the coffee machine model
part def Pump {
port waterIn : WaterPort;
port waterOut : ~WaterPort;
port powerIn : PowerPort;
}Parts are used inside other parts: part pump : Pump; is a usage of the definition Pump. Between two ports of such parts you write connect ... to ...;.
connect tank.waterOut to pump.waterIn; links the tank’s outlet to the pump’s inlet. A connection only says that the two ports are linked. Which item travels along it is the subject of lesson 5.
// Excerpt of the coffee machine model
part def CoffeeMachine {
part tank : WaterTank;
part pump : Pump;
connect tank.waterOut to pump.waterIn;
}Statements follow the OMG SysML v2 specification, Part 1 (Language Specification), in the clauses on items, ports and connections, and the KerML specification, which defines conjugation and connectors. We checked with the PRISM parser that the notations shown are valid.
This is the running coffee machine model of the lesson: all definitions plus the water path from tank to brew unit. Edit it in the editor; the diagram below 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.
What does item def Water; define?
The boiler must receive water at waterIn and deliver it at waterOut. Which direction keyword completes WaterPort?
port def WaterPort {
___ item water : Water;
}
part def Boiler {
port waterIn : WaterPort;
port waterOut : ~WaterPort;
}Match each SysML v1 term to its SysML v2 counterpart.
SysML v1SysML v2
Tap the line that is not valid SysML v2.
package CoffeeMachine {
item def Water;
port def WaterPort { in item water : Water; }
block Pump {
port waterIn : WaterPort;
}
}Tap a line, or move to it with the Tab key and press Enter.
Arrange the pieces into the line inside a port def that lets water of type Water enter.
Drag the pieces, or use the arrow buttons.
:Wateritem;waterinWaterPort has in item water. What does the pump do at waterOut, which is typed ~WaterPort?
port def WaterPort { in item water : Water; }
part def Pump {
port waterOut : ~WaterPort;
}Which sketch matches the Boiler? Arrows show the direction in which items cross the boundary. WaterPort and PowerPort each contain an in item.
part def Boiler {
port waterIn : WaterPort;
port waterOut : ~WaterPort;
port powerIn : PowerPort;
}Type the keyword that places a named interface point on a part.
part def Pump {
___ waterIn : WaterPort;
}Inside CoffeeMachine, which line connects the tank's outlet to the pump's inlet?
part def WaterTank { port waterOut : ~WaterPort; }
part def Pump { port waterIn : WaterPort; port powerIn : PowerPort; }
part def CoffeeMachine {
part tank : WaterTank;
part pump : Pump;
}Tap the line that is not valid SysML v2.
item def Water;
port def WaterPort {
item in water : Water;
}
part def Pump {
port waterIn : WaterPort;
}Tap a line, or move to it with the Tab key and press Enter.
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 nowWhich item actually travels along a connection, and how to describe it.