Holarch
Главы курса

Обучение · Курс 9. Основы SysML v2 · Глава 9.7 из 8

9.7 Ограничения и вычисления 4:26

Запишите ограничения и вычисления, проверьте значения седана с единицами и отметьте открытые значения.

Показан Holarch 2.22.

Чему вы научитесь

  • Записывать определение ограничения и определение вычисления с параметрами
  • Связывать параметры использования ограничения со значениями в модели
  • Видеть, как ограничение проходит и не проходит в параметрическом представлении, и проверять все ограничения командой «Решить все»
  • Отмечать открытые значения метаданными TBD и TBR и находить их в реестре TBD/TBR
  • Сворачивать массу части в разделе «Бюджеты и TPM»

Запишите ограничения и вычисления SysML v2 в Holarch по учебному материалу SysML v2 «Constraints and Calculations» на небольшом проекте Hybrid Car: определение ограничения и вычисление, использование ограничения, связанное со значениями седана, параметрическое представление, где проверка не проходит и проходит, «Решить все», сценарий анализа, значения TBD и TBR с их реестром и свёртка массы в бюджетах. SysML является зарегистрированным товарным знаком Object Management Group, Inc.

Файлы проектов

  • Готовый проект (.holarch.json; Управление проектами → Файлы проекта ▾ → Импортировать проект (.json)…)

Видео воспроизводится с holarch.app; см. Политику конфиденциальности.

Практика

Выполните это сами в Holarch на демо-проекте Hybrid Car (SysML v2).

  1. Откройте свой демо-проект Hybrid Car (при необходимости создайте его: Управление проектами → Файлы проекта ▾ → Новый демо-проект → Hybrid Car (SysML v2)), откройте Модель → Редактор и пакет VehicleRequirements.
  2. После constraint def SpeedLimit добавьте constraint sedanBatteryCheck : MassLimit { in mass = fleet.sedan.powertrain.battery.mass; in limit = 50 [kg]; }.
  3. На странице Диаграммы нажмите + Новая диаграмма, выберите Параметрическое представление и VehicleRequirements в поле Показывает и нажмите Создать. Новая проверка проходит: 48 kg укладываются в 50 kg.
  4. В пакете Vehicles измените массу батареи седана на 52 [kg]; представление показывает, что проверка не проходит. Нажмите ⌘Z / Ctrl+Z, затем Решить все, чтобы снова проверить все ограничения.
  5. В requirement def <'VR-2'> Acceleration замените attribute zeroToHundred : TimeValue; на attribute zeroToHundred : TimeValue { @TBD { owner = "Test lead"; rationale = "The test track is not booked yet."; } }. Откройте Потребности и требования → TBD/TBR и найдите требование с его владельцем.
  6. Откройте Архитектура → Бюджеты и TPM, нажмите Выбрать корневую часть… и выберите sedan. В поле Величина выберите Масса и найдите 48 kg батареи.

Готово, когда sedanBatteryCheck показывает «Пройдено» в параметрическом представлении, а реестр TBD/TBR содержит требование Acceleration с владельцем Test lead.

Проверьте себя

  1. Чем constraint def отличается от calc def?
  2. Ограничение в параметрическом представлении показывает «Нужен вход». Чего не хватает?
  3. Зачем отмечать открытое значение с помощью #TBD или @TBD { … }, а не писать TBD в качестве значения?
  4. Что сценарий анализа добавляет к вычислению?
Показать ответы
  1. Чем constraint def отличается от calc def?

    Определение ограничения задаёт условие над своими параметрами, которое выполняется или нет, например mass <= limit. Определение вычисления вычисляет и возвращает значение, например return ratio = power / mass;.

  2. Ограничение в параметрическом представлении показывает «Нужен вход». Чего не хватает?

    У параметра ещё нет значения. Свяжите каждый параметр со значением, например in mass = fleet.sedan.curbMass;.

  3. Зачем отмечать открытое значение с помощью #TBD или @TBD { … }, а не писать TBD в качестве значения?

    TBD вместо значения не является допустимым SysML. Метаданные из пакета Holarch HolarchMetadata сохраняют текст допустимым; TBD и TBR специализируют стандартные метаданные StatusInfo, поэтому другие инструменты SysML v2 читают их как аннотации статуса.

  4. Что сценарий анализа добавляет к вычислению?

    Он применяет вычисление к субъекту, например к седану, возвращает результат и имеет цель (objective), чей require constraint Holarch вычисляет, как любое другое ограничение.

Подробнее

Расшифровка

Показать расшифровку (дикторский текст и то, что на экране)

Introduction

Chapter seven: constraints and calculations. They turn the model's values into checks and results that Holarch evaluates with units.

In this chapter you write a constraint and a calculation, bind a check to the sedan's values, see it fail and pass in a Parametric View, run an analysis case, and mark open values.

Start the tutorial

Start the tutorial Constraints and Calculations from Project Files, Start a Tutorial. Its starter project holds the sedan with its engine and battery values, and two targets: the maximum curb mass and the minimum power to weight.

On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Constraints and Calculations → Start; Model → Editor.

Constraints and calculations

A constraint definition states a condition over its parameters. After the constraints comment, write the mass limit: the mass is at most the limit.

On screen: After // ---- Constraints and calculations ----: constraint def MassLimit.

Below it, a calculation: power to weight divides the power by the mass, and returns the ratio.

On screen: Below it: calc def PowerToWeight.

A constraint usage binds each parameter to a value: here, the sedan's curb mass and the maximum curb mass.

On screen: Below it: constraint sedanMassCheck : MassLimit with bound inputs.

The Parametric View

Open the Diagrams page, click New Diagram, and choose Parametric View. Choose the vehicle analysis package under Shows, and click Create.

On screen: Diagrams → + New Diagram → Parametric View; Shows: VehicleAnalysis; Create.

The check shows its expression, with its parameters bound to the values. Fifteen hundred eighty kilograms is within sixteen hundred fifty, so it passes.

On screen: The mass check: pass.

In the Editor, change the sedan's curb mass to seventeen hundred kilograms. Back in the Parametric View, the mass check now fails.

On screen: Model → Editor: curbMass 1580 → 1700; Diagrams → the Parametric View: fail.

Change it back to fifteen hundred eighty in the Editor. In the view, Solve All checks every constraint again, with units.

On screen: Model → Editor: 1700 → 1580; the view → Solve All → Pass; Close.

An analysis case

An analysis case computes a result for a subject. At the end of the package, add the power to weight analysis, and apply it to the sedan. Its objective requires at least the minimum, and the checker evaluates it like any constraint.

On screen: Model → Editor; after sedanMassCheck: analysis def PowerToWeightAnalysis; analysis sedanPowerToWeight.

TBD and TBR

Values that are still open get a mark. First import Holarch's metadata package after the other imports.

On screen: After the imports: private import HolarchMetadata::*;

Then add a charge time requirement. TBR marks the time limit to be reviewed, and TBD marks the charger power to be determined, with an owner, a due date and a rationale. Both come from Holarch's metadata library and specialize the standard status metadata, so other SysML v2 tools see them as status annotations.

On screen: At the end: requirement def <'VR-5'> ChargeTime with #TBR and @TBD.

Open Needs and Requirements, then TBD/TBR. The charge time is listed with the owner and the due date from its metadata. The register only lists them: to change them, edit the metadata in the Editor.

On screen: Needs & Requirements → TBD/TBR; the ChargeTime row with owner and due date.

Budgets

Last, open Architecture, then Budgets, and select the sedan as the root part. The quantity Mass reads each part's mass attribute with its unit: the battery shows the sedan's own forty eight kilograms.

On screen: Architecture → Budgets & TPMs → Select Root Part… → sedan; the battery 48 kg.

Recap

Every step is ticked off. Click Mark as Done.

On screen: Step panel → Mark as Done.

Let's recap. You wrote a constraint and a calculation, bound a check to the sedan's values, saw it fail and pass in a Parametric View, ran an analysis case, marked open values for the register, and rolled up the mass.

Next, variants and configurations describe a product line.