Holarch
Capítulos do curso

Treinamento · Trilha 9. Fundamentos do SysML v2 · Capítulo 9.8 de 8

9.8 Variantes e configurações 3:42

Escreva uma linha de produtos com pontos de variação e regras, e configurações que o Editor checa.

Mostra o Holarch 2.22.

← 9.7 Restrições e cálculos · Todos os capítulos

O que você vai aprender

  • Escrever uma variação com variantes e usá-la como ponto de variação de uma linha de produtos
  • Adicionar uma regra a uma linha de produtos com uma assert constraint
  • Criar configurações que escolhem uma variante por ponto e ler seus vereditos
  • Definir uma palavra-chave de metadados própria e aplicá-la com `#`
  • Mostrar o modelo como uma configuração

Escreva uma linha de produtos SysML v2 no Holarch, seguindo o tutorial de SysML v2 Variants and Configurations em um pequeno projeto Hybrid Car: o pacote de variabilidade do Holarch, uma variação com variantes, uma linha de produtos com um ponto de variação e uma asserção, configurações que o Editor checa, uma palavra-chave própria definida por metadados e uma Visão geral da linha de produtos. SysML é uma marca registrada da Object Management Group, Inc.

Arquivos de projeto

  • Projeto concluído (.holarch.json; Gerenciar projetos → Arquivos de projeto ▾ → Importar projeto (.json)…)

O vídeo é reproduzido a partir de holarch.app; veja a Política de Privacidade.

Prática

Faça isto você mesmo no Holarch, no projeto de demonstração Hybrid Car (SysML v2).

  1. Abra seu projeto de demonstração Hybrid Car (crie-o se necessário: Gerenciar projetos → Arquivos de projeto ▾ → Novo projeto de demonstração → Hybrid Car (SysML v2)), abra Modelo → Editor e o pacote Vehicles. Ele já importa HolarchVariability.
  2. Em part def CarLine, depois da variação charger, adicione variation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. O Editor indica que as três configurações ainda não escolheram rims.
  3. Depois de wallboxNeedsLargePack, adicione a regra assert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }.
  4. Abra Modelo → Navegador e selecione selfChargingHybrid. Na seção Configuração do inspetor, escolha steelRims para rims; escolha alloyRims para plugInHybrid e longRangeHybrid. Depois experimente alloyRims em selfChargingHybrid, leia o veredito e pressione ⌘Z / Ctrl+Z.
  5. Abra o menu da linha (⋯) de CarLine e escolha Nova configuração…. Dê o nome cityHybrid, escolha standardPack, noCharger e steelRims, confira que o veredito é Válida e clique em Criar.
  6. Clique em Ver como ▾ na barra superior e escolha cityHybrid; depois abra a visão carLineVariants na lista Diagramas: as variantes que ela não escolhe ficam ocultas.

Você terminou quando a seção Linha de produtos do inspetor para CarLine listar quatro configurações, todas Válidas, e a regra alloyNeedsLargePack.

Teste-se

  1. Qual é a diferença entre variation part def BatteryPack { … } e variation part charger : Component { … }?
  2. plugInHybrid escolhe BatteryPack::standardPack e charger::wallbox. O que acontece, e por quê?
  3. Uma configuração ainda não escolheu uma variante para cada ponto. Qual é o veredito dela?
  4. O que metadata def <safetyCritical> SafetyCritical permite escrever, e como outras ferramentas SysML v2 o veem?
Mostrar as respostas
  1. Qual é a diferença entre variation part def BatteryPack { … } e variation part charger : Component { … }?

    A primeira é uma definição de variação, um conjunto reutilizável de escolhas: um uso tipado por ela, como part pack : BatteryPack;, é um ponto de variação. A segunda é um uso de variação, um ponto declarado dentro de um único projeto.

  2. plugInHybrid escolhe BatteryPack::standardPack e charger::wallbox. O que acontece, e por quê?

    A regra wallboxNeedsLargePack é violada: ela diz que o wallbox implica o pacote grande. O veredito cita a regra, e o Editor informa a asserção que falhou.

  3. Uma configuração ainda não escolheu uma variante para cada ponto. Qual é o veredito dela?

    Incompleta, citando o ponto em aberto. Enquanto um ponto não tem escolha, uma regra sobre ele não é nem atendida nem violada.

  4. O que metadata def <safetyCritical> SafetyCritical permite escrever, e como outras ferramentas SysML v2 o veem?

    O nome curto vira uma palavra-chave, como em #safetyCritical part controller : Controller;. É um uso de metadados comum, então outras ferramentas SysML v2 o veem como metadados na parte.

Saiba mais

Transcrição

Mostrar a transcrição (narração e o que aparece na tela)

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.