Holarch
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).

  1. 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 imports HolarchVariability.
  2. In part def CarLine, after the charger variation, add variation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. The Editor notes that the three configurations have not chosen rims yet.
  3. After wallboxNeedsLargePack, add the rule assert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }.
  4. Open Model → Browser and select selfChargingHybrid. In the inspector's Configuration section, choose steelRims for rims; choose alloyRims for plugInHybrid and longRangeHybrid. Then try alloyRims on selfChargingHybrid, read the verdict, and press ⌘Z / Ctrl+Z.
  5. Open the row menu (⋯) of CarLine and choose New Configuration…. Name it cityHybrid, choose standardPack, noCharger and steelRims, check that the verdict is Valid, and click Create.
  6. Click View as ▾ in the top bar and choose cityHybrid, then open the view carLineVariants from 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

  1. What is the difference between variation part def BatteryPack { … } and variation part charger : Component { … }?
  2. plugInHybrid chooses BatteryPack::standardPack and charger::wallbox. What happens, and why?
  3. A configuration has not chosen a variant for every point yet. What is its verdict?
  4. What does metadata def <safetyCritical> SafetyCritical let you write, and how do other SysML v2 tools see it?
Show the answers
  1. What is the difference between variation part def BatteryPack { … } and variation 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.

  2. plugInHybrid chooses BatteryPack::standardPack and charger::wallbox. What happens, and why?

    The rule wallboxNeedsLargePack is broken: it says that the wallbox implies the large pack. The verdict names the rule, and the Editor reports the failed assertion.

  3. 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.

  4. What does metadata def <safetyCritical> SafetyCritical let 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

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.