Exercise 1 of 10
What sets a flow apart from a connect?
Learn how SysML v2 says that two ports are connected and what travels over the connection: connect, named connections, interface def with ends, and flow of ... from ... to ... for the item flow. With exercises, for beginners and SysML v1 users.
Lesson 4 put ports on the parts and linked two of them with a first connect. What travels along the connection stayed open. This lesson answers that: you write connections more precisely, give them a type, and describe with flow which item they carry. The example stays the invented coffee machine.
connect a to b; creates a connection between two features. In practice these are usually two ports of parts that sit in the same machine. The notation names each end by the part and the port: pump.waterOut is the port waterOut of the part pump.
The keyword connection gives the connection a name. You can then refer to it later, and it appears in the model under that name.
// Excerpt of the coffee machine model
part def CoffeeMachine {
part pump : Pump;
part boiler : Boiler;
connection pumpToBoiler connect pump.waterOut to boiler.waterIn;
}When many connections have the same kind of interface, define the kind once. This interface def has two ends, each with a port type. Here the ends are called supply and consume. The end supply delivers, so its type is conjugated: ~WaterPort (lesson 4). The end consume receives and is WaterPort.
A usage starts with interface, names the definition and connects the two ports. The order matches the ends: the first port belongs to the first end, the second to the second.
// Excerpt of the coffee machine model
interface def WaterLink {
end supply : ~WaterPort;
end consume : WaterPort;
}
part def CoffeeMachine {
part tank : WaterTank;
part pump : Pump;
interface tankToPump : WaterLink connect tank.waterOut to pump.waterIn;
}A connection says that two ports are linked. It does not say what travels over it. A flow describes that: flow of Water from a to b; means that items of type Water travel from a to b, in that direction.
The ends of a flow are features. This lesson names the feature that carries the item: in WaterPort that is item water, so the path ends at the item inside the port, pump.waterOut.water (part, port and item, separated by dots). The shorter flow of Water from pump.waterOut to boiler.waterIn;, with the ports as ends, is valid too.
// Excerpt of the coffee machine model
part def CoffeeMachine {
part pump : Pump;
part boiler : Boiler;
flow of Water from pump.waterOut.water to boiler.waterIn.water;
}Both are connectors, but they say different things. A connection describes structure: these ports are linked. A flow describes behaviour on that structure: this item travels from here to there. A flow has a direction, a connection does not.
It is usual to write both for the same ports. The connection records the structure, the flow names the item. The flow can also stand alone. Then it is the only statement about those two features.
If a flow should have a type of its own, for example with properties of its own, there is flow def. This lesson does not need it.
// Excerpt of the coffee machine model
part def CoffeeMachine {
part boiler : Boiler;
part brewUnit : BrewUnit;
connect boiler.waterOut to brewUnit.waterIn;
flow of Water from boiler.waterOut.water to brewUnit.waterIn.water;
}The water path from lesson 4: the tank is linked to the pump through a WaterLink interface, the other two connections are plain connect, and water flows on all three stretches. The coffee that leaves the brew unit has no taker yet. That is your task below.
// The coffee machine model of this lesson
package CoffeeMachine {
item def Water;
item def Electricity;
item def Coffee;
port def WaterPort { in item water : Water; }
port def PowerPort { in item power : Electricity; }
port def CoffeePort { out item coffee : Coffee; }
interface def WaterLink {
end supply : ~WaterPort;
end consume : WaterPort;
}
part def WaterTank {
port waterOut : ~WaterPort;
}
part def Pump {
port waterIn : WaterPort;
port waterOut : ~WaterPort;
port powerIn : PowerPort;
}
part def Boiler {
port waterIn : WaterPort;
port waterOut : ~WaterPort;
port powerIn : PowerPort;
}
part def BrewUnit {
port waterIn : WaterPort;
port powerIn : PowerPort;
port coffeeOut : CoffeePort;
}
part def CoffeeMachine {
part tank : WaterTank;
part pump : Pump;
part boiler : Boiler;
part brewUnit : BrewUnit;
interface tankToPump : WaterLink connect tank.waterOut to pump.waterIn;
connect pump.waterOut to boiler.waterIn;
connect boiler.waterOut to brewUnit.waterIn;
flow of Water from tank.waterOut.water to pump.waterIn.water;
flow of Water from pump.waterOut.water to boiler.waterIn.water;
flow of Water from boiler.waterOut.water to brewUnit.waterIn.water;
}
}Statements follow the OMG SysML v2 specification, Part 1 (Language Specification), in the clauses on connections, interfaces and flow connections, and the KerML specification, which defines connectors and item flows for all feature kinds. We checked with the PRISM parser that the grammar accepts the notations shown and that the names resolve. It does not check whether the types of the ends fit together; tools with full type checking do.
This is the coffee machine model of the lesson: the water path from tank to brew unit, now with an interface and with flows. The diagram shows the machine with its parts; a line carries the name of the flow (Water) and, where there is one, of the interface (WaterLink). 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.
What sets a flow apart from a connect?
Match each SysML v1 term with its counterpart in SysML v2.
SysML v1SysML v2
Which keyword gives the connection the name pumpToBoiler?
part def CoffeeMachine {
part pump : Pump;
part boiler : Boiler;
___ pumpToBoiler connect pump.waterOut to boiler.waterIn;
}Tap the line that is not valid SysML v2.
part def CoffeeMachine {
part pump : Pump;
part boiler : Boiler;
flow of Water from pump.waterOut.water boiler.waterIn.water;
}Tap a line, or move to it with the Tab key and press Enter.
Put the pieces in the order of the line through which water travels from the pump to the boiler.
Drag the pieces, or use the arrow buttons.
toflowboiler.waterIn.waterfromof;pump.waterOut.waterWaterWhat does the last piece water in pump.waterOut.water refer to?
port def WaterPort { in item water : Water; }
part def Pump {
port waterOut : ~WaterPort;
}What is WaterLink in this line?
interface tankToPump : WaterLink connect tank.waterOut to pump.waterIn;Tap the line that is not valid SysML v2.
port def WaterPort { in item water : Water; }
interface def WaterLink {
end supply ~WaterPort;
end consume : WaterPort;
}Tap a line, or move to it with the Tab key and press Enter.
Which line in CoffeeMachine says that water travels from the pump to the boiler?
part def CoffeeMachine {
part pump : Pump;
part boiler : Boiler;
}Type the keyword that defines an interface with ends.
___ def WaterLink {
end supply : ~WaterPort;
end consume : WaterPort;
}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 nowNot only what the machine consists of, but what it does: actions, parameters and the order of the steps.