Holarch
Capitoli del corso

Formazione · Percorso 9. Fondamenti di SysML v2 · Capitolo 9.8 di 8

9.8 Variants and Configurations 3:42

Scrivere una linea di prodotti con punti di variazione e regole, e configurazioni che l’Editor verifica.

Mostra Holarch 2.22.

← 9.7 Constraints and Calculations · Tutti i capitoli

Che cosa si impara

  • Scrivere una variation con varianti e usarla come punto di variazione di una linea di prodotti
  • Aggiungere una regola a una linea di prodotti con un assert constraint
  • Creare configurazioni che scelgono una variante per ogni punto e leggerne i verdetti
  • Definire una propria parola chiave di metadati e applicarla con `#`
  • Mostrare il modello come un’unica configurazione

Scrivere una linea di prodotti SysML v2 in Holarch, seguendo il tutorial SysML v2 Variants and Configurations su un piccolo progetto Hybrid Car: il package di variabilità di Holarch, una variation con varianti, una linea di prodotti con un punto di variazione e un’asserzione, configurazioni che l’Editor verifica, una parola chiave propria definita con i metadati e una Vista generale della linea di prodotti. SysML è un marchio registrato di Object Management Group, Inc.

File di progetto

  • Progetto completato (.holarch.json; Gestisci progetti → File di progetto ▾ → Importa progetto (.json)…)

Il video viene riprodotto da holarch.app; vedere l’Informativa sulla privacy.

Esercitazione

Provare in prima persona in Holarch, sul progetto demo Hybrid Car (SysML v2).

  1. Aprire il progetto demo Hybrid Car (crearlo se necessario: Gestisci progetti → File di progetto ▾ → Nuovo progetto demo → Hybrid Car (SysML v2)), aprire Modello → Editor e il package Vehicles. Importa già HolarchVariability.
  2. In part def CarLine, dopo la variation charger, aggiungere variation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. L’Editor segnala che le tre configurazioni non hanno ancora scelto rims.
  3. Dopo wallboxNeedsLargePack, aggiungere la regola assert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }.
  4. Aprire Modello → Browser e selezionare selfChargingHybrid. Nella sezione Configurazione dell’ispettore, scegliere steelRims per rims; scegliere alloyRims per plugInHybrid e longRangeHybrid. Poi provare alloyRims su selfChargingHybrid, leggere il verdetto e premere ⌘Z / Ctrl+Z.
  5. Aprire il menu della riga (⋯) di CarLine e scegliere Nuova configurazione…. Chiamarla cityHybrid, scegliere standardPack, noCharger e steelRims, verificare che il verdetto sia Valida e fare clic su Crea.
  6. Fare clic su Visualizza come ▾ nella barra superiore e scegliere cityHybrid, poi aprire la vista carLineVariants dall’elenco Diagrammi: le varianti che non sceglie sono nascoste.

L’esercizio è completato quando la sezione Linea di prodotti dell’ispettore per CarLine elenca quattro configurazioni, tutte Valide, e la regola alloyNeedsLargePack.

Verifica

  1. Qual è la differenza tra variation part def BatteryPack { … } e variation part charger : Component { … }?
  2. plugInHybrid sceglie BatteryPack::standardPack e charger::wallbox. Che cosa succede e perché?
  3. Una configurazione non ha ancora scelto una variante per ogni punto. Qual è il suo verdetto?
  4. Che cosa permette di scrivere metadata def <safetyCritical> SafetyCritical, e come lo vedono gli altri strumenti SysML v2?
Mostra le risposte
  1. Qual è la differenza tra variation part def BatteryPack { … } e variation part charger : Component { … }?

    La prima è una definizione di variation, un insieme riutilizzabile di scelte: un uso tipizzato da essa, come part pack : BatteryPack;, è un punto di variazione. La seconda è un uso di variation, un punto dichiarato all’interno di un unico progetto.

  2. plugInHybrid sceglie BatteryPack::standardPack e charger::wallbox. Che cosa succede e perché?

    La regola wallboxNeedsLargePack è violata: dice che il wallbox implica il pacco grande. Il verdetto nomina la regola e l’Editor segnala l’asserzione non riuscita.

  3. Una configurazione non ha ancora scelto una variante per ogni punto. Qual è il suo verdetto?

    Incompleta, con l’indicazione del punto aperto. Finché un punto non ha una scelta, una regola su di esso non è né soddisfatta né violata.

  4. Che cosa permette di scrivere metadata def <safetyCritical> SafetyCritical, e come lo vedono gli altri strumenti SysML v2?

    Il nome breve diventa una parola chiave, come in #safetyCritical part controller : Controller;. È un normale uso di metadati, quindi gli altri strumenti SysML v2 lo vedono come metadati sulla part.

Per saperne di più

Trascrizione

Mostra la trascrizione (narrazione e contenuto dello schermo)

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.