Exercise 1 of 10
What does allocate prepare.brew to machine.brewUnit; do?
Learn how SysML v2 assigns behaviour to structure and shows models in views: allocate ... to ..., view with expose and render, and a first look at viewpoint. With exercises, for beginners and SysML v1 users.
The model now says what the machine does (actions) and what it consists of (parts). What is open is who does what: which part takes over which step? That is allocation. After that the question is how to show only what a reader needs out of a larger model: the view. The example stays the invented coffee machine; its actions are the process Prepare espresso from lesson 6, here without parameters.
allocate prepare.brew to machine.brewUnit; says that the step brew of the process prepare is taken over by the brew unit of the machine. On the left stands what is assigned, on the right to whom it is assigned. Both sides are paths to features: prepare is the usage of the process, machine that of the machine.
With allocation and a name you can name the assignment, as with connections in lesson 5.
// Excerpt of the coffee machine model
part machine : CoffeeMachine;
action prepare : PrepareEspresso;
allocate prepare.brew to machine.brewUnit;
allocation tampAllocation allocate prepare.tamp to machine.tamper;An allocation records who carries the function. With it you can ask which steps do not have a carrier yet and which parts have no task. The allocation changes neither the step nor the part: it links the two, just as a satisfy links part and requirement.
The diagram below draws the assignment: the process on the left, the machine on the right, and a dashed arrow for each allocation.
A model grows large. A view selects what is shown for a particular purpose. expose names which elements belong to it: expose machine; shows the machine. With ::* you take the direct elements of a namespace, with ::** all those below it as well.
render says how the selection is presented. asTreeDiagram comes from the standard library and presents it as a tree; so that tools find the name, you import it in the same package.
// Excerpt of the coffee machine model
private import Views::asTreeDiagram;
view machineView {
expose machine;
render asTreeDiagram;
}A viewpoint frames the concern of a stakeholder: whose question a view answers. It is a kind of requirement, not a kind of view; the definition of a kind of view is view def. A view can say with satisfy that it meets a viewpoint. That is enough for a start. Whoever maintains many views for different readers later ties them to viewpoints.
// Excerpt of the coffee machine model
viewpoint def StructureViewpoint {
doc /* Shows how the machine is built from its parts, for the mechanical team. */
}The process with its three steps, the machine with three parts and one allocation: grinding is with the grinder. Two assignments are still missing, and there is no view on the machine either. Both are your task below.
// The coffee machine model of this lesson
package CoffeeMachine {
action def Grind;
action def Tamp;
action def Brew;
action def PrepareEspresso {
first start;
then action grind : Grind;
then action tamp : Tamp;
then action brew : Brew;
then done;
}
part def Grinder;
part def Tamper;
part def BrewUnit;
part def CoffeeMachine {
part grinder : Grinder;
part tamper : Tamper;
part brewUnit : BrewUnit;
}
part machine : CoffeeMachine;
action prepare : PrepareEspresso;
allocate prepare.grind to machine.grinder;
}Statements follow the OMG SysML v2 specification, Part 1 (Language Specification), in the clauses on allocations and on views and viewpoints (view, expose, rendering, viewpoint), and the standard library for views, which asTreeDiagram comes from. PRISM reads these constructs, draws the allocations and knows render asTreeDiagram. PRISM does not evaluate the filters of a view; they are therefore not part of this lesson.
This is the coffee machine model of the lesson: the process Prepare espresso on the left, the machine with its parts on the right, and the dashed lines are the allocations. What is drawn is the assignment; the view stands in the text, PRISM draws only the allocations here. 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 does allocate prepare.brew to machine.brewUnit; do?
Match each SysML v1 term with its counterpart in SysML v2.
SysML v1SysML v2
Which keyword assigns the step to the brew unit?
part machine : CoffeeMachine;
action prepare : PrepareEspresso;
___ prepare.brew to machine.brewUnit;Tap the line that is not valid SysML v2.
package CoffeeMachine {
action def PrepareEspresso { action brew; }
part def CoffeeMachine { part brewUnit; }
part machine : CoffeeMachine;
action prepare : PrepareEspresso;
allocate prepare.brew machine.brewUnit;
}Tap a line, or move to it with the Tab key and press Enter.
Put the pieces in the order of the line that assigns the step brew to the brew unit.
Drag the pieces, or use the arrow buttons.
tomachine.brewUnitallocate;prepare.brewWhat sets allocate apart from satisfy?
What does expose machine; do in a view?
view machineView {
expose machine;
render asTreeDiagram;
}Type the keyword that defines a view.
___ machineView {
expose machine;
}Which line assigns the step tamp to the part tamper?
package CoffeeMachine {
action def PrepareEspresso { action tamp; }
part def CoffeeMachine { part tamper; }
part machine : CoffeeMachine;
action prepare : PrepareEspresso;
}What does a viewpoint stand for?
viewpoint def StructureViewpoint {
doc /* Shows how the machine is built from its parts, for the mechanical team. */
}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 nowYou now know the building blocks a SysML v2 model is made of: definition and usage, parts, attributes, ports, connections, actions, states, requirements, allocation and views. Everything you learned is text in a file that any tool with SysML v2 textual notation reads. If you want to work on a model, not only read it: PRISM draws it as a diagram and lets you keep working in the diagram and in the text.