Holarch
Capítulos do curso

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

9.1 Definições e atributos 4:33

Escreva tipos de valor e componentes em texto SysML v2, com valores em unidades.

Mostra o Holarch 2.22.

Todos os capítulos · 9.2 Portas e interfaces →

O que você vai aprender

  • Escrever uma enumeração, um tipo de valor e uma definição de part abstrata no Editor
  • Especializar uma definição com `:>` e dar valores com unidades a atributos herdados usando `redefines`
  • Encontrar e corrigir um erro de unidade que o verificador sublinha
  • Escrever uma definição com Inserir ▾ e o preenchimento automático, e consultar um tipo na Biblioteca padrão
  • Renomear um elemento em todos os lugares com F2 em um único passo de desfazer

Escreva definições e atributos SysML v2 no Editor do Holarch, seguindo o tutorial de SysML v2 Definitions and Attributes em um pequeno projeto Hybrid Car: uma enumeração, um tipo de valor que especializa ScalarValue, um componente abstrato e suas especializações com valores em unidades, um erro de unidade encontrado pelo verificador, o preenchimento automático e a Biblioteca padrão, Inserir e a renomeação com F2. 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. Crie o demo Hybrid Car: Gerenciar projetos → Arquivos de projeto ▾ → Novo projeto de demonstração → Hybrid Car (SysML v2). Abra Modelo → Editor e o pacote Vehicles.
  2. Abaixo de enum def FuelKind, adicione enum def CoolingMode { enum passive; enum active; }.
  3. Abaixo de part def Body, escolha Inserir ▾ → Definição de part e complete part def Radiator :> Component com attribute redefines mass = 8 [kg];, attribute coolantVolume : VolumeValue; (digite Volu e aceite VolumeValue na lista de preenchimento com Enter) e attribute mode : CoolingMode;.
  4. Mude a massa para 8 [W], aponte para o sublinhado para ler a mensagem e depois volte para 8 [kg].
  5. Em part def Powertrain, adicione part radiator : Radiator;. Depois coloque o cursor em coolantVolume, pressione F2 e renomeie para coolantCapacity.
  6. Para um passo a passo checado, execute o tutorial de SysML v2 Definitions and Attributes (Ajuda → Tutoriais).

Você terminou quando o status sob o editor não indicar problemas e o Navegador mostrar Radiator sob Vehicles com coolantCapacity e mode.

Teste-se

  1. Em part def Battery :> Component { attribute redefines mass = 45 [kg]; }, o que :> e redefines fazem cada um?
  2. Por que Component é declarado abstract part def?
  3. Por que attribute redefines power = 60 [kg]; dá erro?
  4. Qual é a diferença entre doc /* … */ e uma linha //?
Mostrar as respostas
  1. Em part def Battery :> Component { attribute redefines mass = 45 [kg]; }, o que :> e redefines fazem cada um?

    :> torna Battery uma especialização de Component, então ela herda mass, partNumber e power. redefines substitui o mass herdado em Battery por uma feature própria, aqui vinculada a 45 kg.

  2. Por que Component é declarado abstract part def?

    Nada é um componente em si, apenas tipos de componentes. Uma definição abstrata reúne o que todo componente compartilha, e só suas especializações, como Battery ou Engine, descrevem partes reais.

  3. Por que attribute redefines power = 60 [kg]; dá erro?

    power é do tipo PowerValue, e quilogramas são uma unidade de massa. O verificador avalia unidades, então ele sublinha o valor até que a unidade seja uma unidade de potência, como [W].

  4. Qual é a diferença entre doc /* … */ e uma linha //?

    Um comentário doc é uma documentação que pertence ao elemento e faz parte do modelo. Uma nota // fica apenas no texto e não faz parte do modelo.

Saiba mais

Transcrição

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

Introduction

Welcome to SysML v2 Fundamentals. This track teaches the SysML v2 textual notation and views in Holarch, one task per chapter, on the starter projects of Holarch's SysML v2 tutorials, so you can follow along step by step.

In this chapter you write definitions and attributes: an enumeration, a value type, an abstract component and the components that specialize it, with values in units.

Start the tutorial

In Manage Projects, open Project Files and choose Start a Tutorial. Under the tutorials for SysML v2 projects, click Start on Definitions and Attributes. Holarch creates a small Hybrid Car project and opens the step panel, which checks each step as you go.

On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Definitions and Attributes → Start; the step panel opens.

Enumerations and value types

Open Model, then Editor. The package Vehicles holds one part definition, Car, with two attributes. Every declaration is a keyword and a name, then a body in braces, or a semicolon when there is no body.

On screen: Model → Editor: Vehicles; outline part def Car.

An enumeration is a value type with a fixed set of values. Above the car, write the drive mode: economy, normal or sport.

On screen: Caret after the imports; type enum def DriveMode.

Next, a value type of your own. Tire pressure specializes Scalar Value from the standard library. The short symbol after the name means specializes.

On screen: Below DriveMode; type attribute def TirePressure :> ScalarValue;

Specialization and units

Now an abstract component. There is no component as such, only kinds of components, and every one has a mass, a part number and a power. The doc comment is part of the model. Two slashes start a note that stays in the text only.

On screen: Below TirePressure; type abstract part def Component.

The battery is a component, so it has a mass, a part number and a power of its own. Write it with a mistake on purpose: a power in kilograms.

On screen: Below Component; type part def Battery :> Component with power = 60 [kg].

The checker underlines the value, and the status under the editor counts the error. Point at the underline to read the message.

On screen: Problems count; the information card on 60 [kg].

Change kilograms to watts, and the error clears. Redefines gives each inherited attribute the battery's own value, with its unit in square brackets.

On screen: kg → W; No problems, Applied.

Completion and the Standard Library

Completion knows the model and the library. Inside the battery, type attribute capacity, a colon, and the start of Energy Value. Press Enter to take it from the list, and end the line with a semicolon.

On screen: Inside Battery: attribute capacity : Ener → completion → Enter → ;

Point at Energy Value. The card shows that it comes from the I S Q package of the standard library.

On screen: The information card on EnergyValue.

The Standard Library page lists every package and definition of that library. Open Settings, then Standard Library, and search for Energy Value.

On screen: Settings → Standard Library; Find EnergyValue.

Insert

Back in the Editor, Insert writes a construct for you. Place the cursor below the battery, open Insert, and choose Part Definition. Type Engine, and press Tab to move into its body.

On screen: Model → Editor; caret below Battery; Insert ▾ (open on camera) → Part Definition; Engine; Tab.

The engine is a component too. Give it its mass and a number of cylinders, and make it specialize Component.

On screen: Body: mass 110 kg, cylinders : Integer; then :> Component after the name.

Usages and rename

Now use the definitions. Inside the car, add a drive mode, a battery and an engine. Each usage is typed by a definition after the colon, the drive mode by the enumeration you wrote first.

On screen: In Car after curbMass: attribute mode : DriveMode; part battery : Battery; part engine : Engine;

To rename a name everywhere it is used, place the cursor on cylinders and press F2. Enter cylinder count and confirm. Every reference to it changes, in one undo step.

On screen: Caret in cylinders; F2; New name cylinderCount; OK.

Every step is ticked off. Click Mark as Done to finish the tutorial.

On screen: Step panel → Mark as Done.

Recap

Let's recap. You started a SysML v2 tutorial, wrote an enumeration and a value type, an abstract component with specializations and values in units, let the checker find a wrong unit, and used completion, the Standard Library, Insert and rename.

Next, ports and interfaces connect these components.