Course chapters
Training · Track 9. SysML v2 Fundamentals · Chapter 9.8 of 8
9.8 Variants and Configurations 3:42
Write a product line with variation points and rules, and configurations the Editor checks.
Shows Holarch 2.22.
What you’ll learn
- Write a variation with variants and use it as a variation point of a product line
- Add a rule to a product line with an assert constraint
- Create configurations that choose one variant per point, and read their verdicts
- Define a metadata keyword of your own and apply it with `#`
- Show the model as one configuration
Write a SysML v2 product line in Holarch, following the SysML v2 tutorial Variants and Configurations on a small Hybrid Car project: Holarch's variability package, a variation with variants, a product line with a variation point and an assertion, configurations the Editor checks, a keyword of your own defined by metadata, and a General View of the product line. SysML is a registered trademark of Object Management Group, Inc.
Project files
- Finished project (.holarch.json; Manage Projects → Project Files ▾ → Import Project (.json)…)
The video plays from holarch.app; see the Privacy Policy.
Practice
Do this yourself in Holarch, on the Hybrid Car demo project (SysML v2).
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
Vehicles. It already importsHolarchVariability. - In
part def CarLine, after thechargervariation, addvariation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. The Editor notes that the three configurations have not chosenrimsyet. - After
wallboxNeedsLargePack, add the ruleassert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }. - Open Model → Browser and select
selfChargingHybrid. In the inspector's Configuration section, choose steelRims for rims; choose alloyRims forplugInHybridandlongRangeHybrid. Then try alloyRims onselfChargingHybrid, read the verdict, and press ⌘Z / Ctrl+Z. - Open the row menu (⋯) of
CarLineand choose New Configuration…. Name itcityHybrid, choose standardPack, noCharger and steelRims, check that the verdict is Valid, and click Create. - Click View as ▾ in the top bar and choose
cityHybrid, then open the viewcarLineVariantsfrom the Diagrams list: the variants it does not choose are hidden.
You're done when the inspector's Product Line section for CarLine lists four configurations, all Valid, and the rule alloyNeedsLargePack.
Check yourself
- What is the difference between
variation part def BatteryPack { … }andvariation part charger : Component { … }? plugInHybridchoosesBatteryPack::standardPackandcharger::wallbox. What happens, and why?- A configuration has not chosen a variant for every point yet. What is its verdict?
- What does
metadata def <safetyCritical> SafetyCriticallet you write, and how do other SysML v2 tools see it?
Show the answers
What is the difference between
variation part def BatteryPack { … }andvariation part charger : Component { … }?The first is a variation definition, a reusable set of choices: a usage typed by it, such as
part pack : BatteryPack;, is a variation point. The second is a variation usage, a point declared inside one design.plugInHybridchoosesBatteryPack::standardPackandcharger::wallbox. What happens, and why?The rule
wallboxNeedsLargePackis broken: it says that the wallbox implies the large pack. The verdict names the rule, and the Editor reports the failed assertion.A configuration has not chosen a variant for every point yet. What is its verdict?
Incomplete, naming the open point. While a point has no choice, a rule over it is neither met nor broken.
What does
metadata def <safetyCritical> SafetyCriticallet you write, and how do other SysML v2 tools see it?The short name becomes a keyword, as in
#safetyCritical part controller : Controller;. It is an ordinary metadata usage, so other SysML v2 tools see it as metadata on the part.
Read more
- Tutorial: Variants and Configurations (SysML v2 Tutorials)
- Docs: SysML v2 Variants and Configurations, Concepts
- Docs: SysML v2 Variants and Configurations, Create a configuration
- Docs: SysML v2 Textual Notation, Variations, variants and configurations
- Docs: Product Lines, SysML v2 projects
- Help: Variants and Configurations
Transcript
Show the transcript (narration and what is on screen)
Introduction
Chapter eight: variants and configurations. A product line offers choices, and a configuration picks one variant for each choice.
In this chapter you write a variation with variants, a product line with a rule, configurations the Editor checks, and a keyword of your own.
Start the tutorial
Start the tutorial Variants and Configurations from Project Files, Start a Tutorial. Its starter project holds the components, the car and the powertrain.
On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Variants and Configurations → Start; Model → Editor.
Variations
Holarch's variability package lets the Editor check configurations. Import it after the other imports.
On screen: After the imports: private import HolarchVariability::*;
A variation lists the choices offered. Before the powertrain, write the battery pack variation: a standard pack and a large pack, each with its own capacity, and the large one with its own mass.
On screen: After Car: variation part def BatteryPack with two variants.
The product line
Below it, the car line. Its pack is typed by the variation, its charger is a variation point with two variants, and an assertion rules out the wallbox with the standard pack.
On screen: Below BatteryPack: part def CarLine :> Car with pack, charger and the assertion.
Configurations
A configuration is a part of the car line, marked Holarch Configuration. Until it chooses a variant for each point, the Editor notes the points still open.
On screen: Below CarLine: part plugInHybrid : CarLine { @HolarchConfiguration; }
Inside the plug-in hybrid, choose the standard pack and the wallbox. The assertion fails: the wallbox needs the large pack.
On screen: In plugInHybrid: pack = BatteryPack::standardPack; charger = charger::wallbox; the assertion error.
Choose the large pack instead, and the configuration checks.
On screen: standardPack → largePack; No problems.
Add a second configuration: a self-charging hybrid, with the standard pack and no charger.
On screen: Below plugInHybrid: part selfChargingHybrid : CarLine.
A keyword of your own
You can also define keywords of your own. At the end of the package, add a metadata definition. Its short name, safety critical, becomes a keyword.
On screen: After Powertrain: metadata def <safetyCritical> SafetyCritical.
In the powertrain, put the keyword before the controller, after a number sign. Other SysML v2 tools see it as ordinary metadata.
On screen: In Powertrain: #safetyCritical part controller : Controller;
The General View
Open Architecture, then General Views, and click New Diagram. Keep General View, choose the Vehicles package under Shows, and click Create.
On screen: Architecture → General Views → + New Diagram; Shows: Vehicles; Create.
The battery pack is marked variation in its heading.
On screen: BatteryPack: «variation part def».
Recap
Every step is ticked off. Click Mark as Done.
On screen: Step panel → Mark as Done.
Let's recap. You imported Holarch's variability package, wrote a variation with variants and a product line with a rule, built configurations that the Editor checks, and defined a keyword of your own.
That completes SysML v2 Fundamentals.