Розділи курсів
Навчання · Курс 9. Основи SysML v2 · Розділ 9.8 з 8
9.8 Варіанти та конфігурації 3:42
Напишіть лінійку продуктів із точками варіації й правилами та конфігурації, які перевіряє Редактор.
Показано Holarch 2.22.
Що ви дізнаєтеся
- Написати варіацію з варіантами й використати її як точку варіації лінійки продуктів
- Додати правило до лінійки продуктів через assert constraint
- Створити конфігурації, що обирають по одному варіанту для кожної точки, і прочитати їхні вердикти
- Визначити власне ключове слово метаданих і застосувати його через `#`
- Показати модель як одну конфігурацію
Напишіть лінійку продуктів SysML v2 у Holarch за навчальним посібником SysML v2 Variants and Configurations на невеликому проєкті Hybrid Car: пакет варіативності Holarch, варіація з варіантами, лінійка продуктів із точкою варіації й твердженням, конфігурації, які перевіряє Редактор, власне ключове слово, визначене метаданими, і загальне подання лінійки продуктів. SysML є зареєстрованою торговельною маркою Object Management Group, Inc.
Файли проєкту
- Готовий проєкт (.holarch.json; Керування проєктами → Файли проєкту ▾ → Імпортувати проєкт (.json)…)
Відео відтворюється з holarch.app; див. Політику конфіденційності.
Практика
Виконайте це самі в Holarch на демопроєкті Hybrid Car (SysML v2).
- Відкрийте свій демопроєкт Hybrid Car (за потреби створіть його: Керування проєктами → Файли проєкту ▾ → Новий демопроєкт → Hybrid Car (SysML v2)), відкрийте Модель → Редактор і пакет
Vehicles. Він уже імпортуєHolarchVariability. - У
part def CarLineпісля варіаціїchargerдодайтеvariation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. Редактор зазначає, що три конфігурації ще не вибралиrims. - Після
wallboxNeedsLargePackдодайте правилоassert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }. - Відкрийте Модель → Браузер і виберіть
selfChargingHybrid. У розділі інспектора Конфігурація оберіть steelRims для rims; дляplugInHybridіlongRangeHybridоберіть alloyRims. Потім спробуйте alloyRims дляselfChargingHybrid, прочитайте вердикт і натисніть ⌘Z / Ctrl+Z. - Відкрийте меню рядка (⋯)
CarLineі оберіть Нова конфігурація…. Назвіть їїcityHybrid, оберіть standardPack, noCharger і steelRims, перевірте, що вердикт — «Коректна», і натисніть Створити. - Натисніть Переглянути як ▾ на верхній панелі й оберіть
cityHybrid, потім відкрийте поданняcarLineVariantsзі списку Діаграми: варіанти, яких вона не обирає, приховано.
Завдання виконано, коли розділ «Лінійка продуктів» інспектора для CarLine перелічує чотири конфігурації, усі коректні, і правило alloyNeedsLargePack.
Перевірте себе
- Чим відрізняються
variation part def BatteryPack { … }іvariation part charger : Component { … }? plugInHybridобираєBatteryPack::standardPackіcharger::wallbox. Що відбувається і чому?- Конфігурація ще не обрала варіант для кожної точки. Який її вердикт?
- Що дає змогу писати
metadata def <safetyCritical> SafetyCriticalі як це бачать інші інструменти SysML v2?
Показати відповіді
Чим відрізняються
variation part def BatteryPack { … }іvariation part charger : Component { … }?Перше — визначення варіації, багаторазовий набір виборів: використання, типізоване ним, як-от
part pack : BatteryPack;, є точкою варіації. Друге — використання варіації, точка, оголошена всередині одного проєкту.plugInHybridобираєBatteryPack::standardPackіcharger::wallbox. Що відбувається і чому?Порушено правило
wallboxNeedsLargePack: воно каже, що wallbox передбачає великий акумуляторний блок. Вердикт називає правило, а Редактор повідомляє про невиконане твердження.Конфігурація ще не обрала варіант для кожної точки. Який її вердикт?
«Неповна» з назвою відкритої точки. Поки для точки немає вибору, правило щодо неї ані виконано, ані порушено.
Що дає змогу писати
metadata def <safetyCritical> SafetyCriticalі як це бачать інші інструменти SysML v2?Коротке ім’я стає ключовим словом, як у
#safetyCritical part controller : Controller;. Це звичайне використання метаданих, тож інші інструменти SysML v2 бачать його як метадані на частині.
Докладніше
- Навчальний посібник: Variants and Configurations (SysML v2 Tutorials)
- Docs: Варіанти та конфігурації SysML v2, поняття
- Docs: Варіанти та конфігурації SysML v2, створення конфігурації
- Docs: Текстова нотація SysML v2, варіації, варіанти й конфігурації
- Docs: Лінійки продуктів, проєкти SysML v2
- Довідка: Варіанти та конфігурації
Стенограма
Показати стенограму (озвучення і те, що на екрані)
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.