פרקי הקורס
הדרכה · מסלול 9. יסודות SysML v2 · פרק 9.8 מתוך 8
9.8 ווריאנטים ותצורות 3:42
כותבים קו מוצרים עם נקודות וריאציה וכללים, ותצורות שהעורך בודק.
מציג את Holarch 2.22.
מה תלמדו
- לכתוב וריאציה עם ווריאנטים ולהשתמש בה כנקודת וריאציה של קו מוצרים
- להוסיף כלל לקו מוצרים עם assert constraint
- ליצור תצורות שבוחרות ווריאנט אחד לכל נקודה, ולקרוא את פסקי הדין שלהן
- להגדיר מילת מפתח משלכם במטא-נתונים ולהחיל אותה עם `#`
- להציג את המודל כתצורה אחת
כותבים קו מוצרים של SysML v2 ב-Holarch, לפי המדריך Variants and Configurations של SysML v2 על פרויקט Hybrid Car קטן: חבילת השונוּת של Holarch, וריאציה עם ווריאנטים, קו מוצרים עם נקודת וריאציה וטענה, תצורות שהעורך בודק, מילת מפתח משלכם שמוגדרת במטא-נתונים, ו-General View של קו המוצרים. 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; בוחרים alloyRims עבורplugInHybridו-longRangeHybrid. אחר כך מנסים את 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 מחייב את החבילה הגדולה. פסק הדין מציין את הכלל, והעורך מדווח על הטענה (assertion) שנכשלה.תצורה עדיין לא בחרה ווריאנט לכל נקודה. מהו פסק הדין שלה?
לא שלמה, עם ציון הנקודה הפתוחה. כל עוד לנקודה אין בחירה, כלל שחל עליה לא מתקיים וגם לא מופר.
מה
metadata def <safetyCritical> SafetyCriticalמאפשר לכתוב, ואיך כלי SysML v2 אחרים רואים את זה?השם המקוצר הופך למילת מפתח, כמו ב-
#safetyCritical part controller : Controller;. זהו שימוש מטא-נתונים רגיל, כך שכלי 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.