Розділи курсів
Навчання · Курс 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).
- Відкрийте свій демопроєкт Hybrid Car (за потреби створіть його: Керування проєктами → Файли проєкту ▾ → Новий демопроєкт → Hybrid Car (SysML v2)), відкрийте Модель → Редактор і пакет
VehicleRequirements. - Після
constraint def SpeedLimitдодайтеconstraint sedanBatteryCheck : MassLimit { in mass = fleet.sedan.powertrain.battery.mass; in limit = 50 [kg]; }. - На сторінці Діаграми натисніть + Нова діаграма, оберіть Параметричне подання і
VehicleRequirementsу Показує та натисніть Створити. Нова перевірка виконується: 48 kg не перевищує 50 kg. - У пакеті
Vehiclesзмініть масу батареї седана на52 [kg]; подання показує, що перевірка не виконується. Натисніть ⌘Z / Ctrl+Z, потім натисніть Розв’язати все, щоб знову перевірити всі обмеження. - У
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 і знайдіть вимогу з її відповідальним. - Відкрийте Архітектура → Бюджети й TPM, натисніть Вибрати кореневий складник… і оберіть
sedan. У Величина оберіть Маса і знайдіть 48 kg батареї.
Завдання виконано, коли sedanBatteryCheck показує Pass у параметричному поданні, а реєстр TBD/TBR перелічує вимогу Acceleration з відповідальним Test lead.
Перевірте себе
- Чим відрізняються
constraint defіcalc def? - Обмеження в параметричному поданні показує «Потребує входу». Чого бракує?
- Чому відкрите значення варто позначати через
#TBDабо@TBD { … }, а не писати TBD як значення? - Що випадок аналізу додає до обчислення?
Показати відповіді
Чим відрізняються
constraint defіcalc def?Визначення обмеження задає умову над своїми параметрами, яка виконується чи ні, як-от
mass <= limit. Визначення обчислення обчислює й повертає значення, як-отreturn ratio = power / mass;.Обмеження в параметричному поданні показує «Потребує входу». Чого бракує?
Параметр ще не має значення. Прив’яжіть кожен параметр до значення, наприклад
in mass = fleet.sedan.curbMass;.Чому відкрите значення варто позначати через
#TBDабо@TBD { … }, а не писати TBD як значення?TBDзамість значення — недійсний SysML. Метадані з пакета HolarchHolarchMetadataзберігають текст дійсним; TBD і TBR спеціалізують стандартні метаданіStatusInfo, тож інші інструменти SysML v2 читають їх як анотації статусу.Що випадок аналізу додає до обчислення?
Він застосовує обчислення до суб’єкта, як-от седана, повертає результат і має мету, чий require constraint Holarch обчислює як будь-яке інше обмеження.
Докладніше
- Навчальний посібник: Constraints and Calculations (SysML v2 Tutorials)
- Docs: Аналіз SysML v2, перевірка обмежень у параметричному поданні
- Docs: Аналіз SysML v2, розв’язання значень
- Docs: Вимоги в проєктах SysML v2, позначення значення як TBD або TBR
- Docs: Аналіз SysML v2, підсумок бюджету
- Довідка: Бюджети й TPM у проєктах SysML v2
Стенограма
Показати стенограму (озвучення і те, що на екрані)
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.