Holarch
Capítulos del curso

Formación · Curso 9. Fundamentos de SysML v2 · Capítulo 9.1 de 8

9.1 Definiciones y atributos 4:33

Escribir tipos de valor y componentes en texto de SysML v2, con valores en unidades.

Muestra Holarch 2.22.

Todos los capítulos · 9.2 Puertos e interfaces →

Lo que aprenderá

  • Escribir una enumeración, un tipo de valor y una definición de parte abstracta en el Editor
  • Especializar una definición con `:>` y dar valores con unidades a los atributos heredados mediante `redefines`
  • Encontrar y corregir un error de unidades que el comprobador subraya
  • Escribir una definición con Insertar ▾ y el autocompletado, y consultar un tipo en la Biblioteca estándar
  • Cambiar el nombre de un elemento en todas partes con F2 en un único paso de deshacer

Escriba definiciones y atributos de SysML v2 en el Editor de Holarch, siguiendo el tutorial de SysML v2 Definitions and Attributes en un pequeño proyecto Hybrid Car: una enumeración, un tipo de valor que especializa ScalarValue, un componente abstracto y sus especializaciones con valores en unidades, un error de unidades encontrado por el comprobador, el autocompletado y la Biblioteca estándar, Insertar y el cambio de nombre con F2. SysML es una marca registrada de Object Management Group, Inc.

Archivos de proyecto

  • Proyecto terminado (.holarch.json; Gestionar proyectos → Archivos de proyecto ▾ → Importar proyecto (.json)…)

El vídeo se reproduce desde holarch.app; consulte la Política de privacidad.

Práctica

Hágalo usted mismo en Holarch, en el proyecto de demostración Hybrid Car (SysML v2).

  1. Cree la demostración Hybrid Car: Gestionar proyectos → Archivos de proyecto ▾ → Nuevo proyecto de demostración → Hybrid Car (SysML v2). Abra Modelo → Editor y el paquete Vehicles.
  2. Debajo de enum def FuelKind, añada enum def CoolingMode { enum passive; enum active; }.
  3. Debajo de part def Body, elija Insertar ▾ → Definición de part y complete part def Radiator :> Component con attribute redefines mass = 8 [kg];, attribute coolantVolume : VolumeValue; (escriba Volu y acepte VolumeValue de la lista de autocompletado con Intro) y attribute mode : CoolingMode;.
  4. Cambie la masa a 8 [W], sitúe el puntero sobre el subrayado para leer el mensaje y después vuelva a cambiarla a 8 [kg].
  5. En part def Powertrain, añada part radiator : Radiator;. Después coloque el cursor sobre coolantVolume, pulse F2 y cámbiele el nombre a coolantCapacity.
  6. Para un recorrido guiado y comprobado, ejecute el tutorial de SysML v2 Definitions and Attributes (Ayuda → Tutoriales).

Habrá terminado cuando el estado bajo el editor no indique problemas y el Navegador muestre Radiator bajo Vehicles con coolantCapacity y mode.

Compruebe lo aprendido

  1. En part def Battery :> Component { attribute redefines mass = 45 [kg]; }, ¿qué hacen :> y redefines?
  2. ¿Por qué Component se declara como abstract part def?
  3. ¿Por qué attribute redefines power = 60 [kg]; da un error?
  4. ¿Qué diferencia hay entre doc /* … */ y una línea //?
Mostrar las respuestas
  1. En part def Battery :> Component { attribute redefines mass = 45 [kg]; }, ¿qué hacen :> y redefines?

    :> convierte Battery en una especialización de Component, de modo que hereda mass, partNumber y power. redefines sustituye el mass heredado en Battery por una característica propia, aquí vinculada a 45 kg.

  2. ¿Por qué Component se declara como abstract part def?

    Nada es un componente en sí, solo tipos de componentes. Una definición abstracta reúne lo que comparten todos los componentes, y solo sus especializaciones, como Battery o Engine, describen partes reales.

  3. ¿Por qué attribute redefines power = 60 [kg]; da un error?

    power es de tipo PowerValue, y el kilogramo es una unidad de masa. El comprobador evalúa las unidades, de modo que subraya el valor hasta que la unidad sea de potencia, como [W].

  4. ¿Qué diferencia hay entre doc /* … */ y una línea //?

    Un comentario doc es documentación que pertenece al elemento y forma parte del modelo. Una nota // queda solo en el texto y no forma parte del modelo.

Más información

Transcripción

Mostrar la transcripción (narración y lo que aparece en pantalla)

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.