Holarch
فصول الدورة

التدريب · المسار 9. أساسيات SysML v2 · الفصل 9.8 من 8

9.8 المتغيرات والتكوينات 3:42

اكتب خط منتجات بنقاط تباين وقواعد، وتكوينات يفحصها المحرر.

يعرض Holarch 2.22.

→ 9.7 القيود والحسابات · كل الفصول

ما ستتعلمه

  • اكتب تباينًا بمتغيرات واستخدمه كنقطة تباين في خط منتجات
  • أضف قاعدة إلى خط منتجات باستخدام 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).

  1. افتح مشروع Hybrid Car التوضيحي (أنشئه إذا لزم الأمر: إدارة المشاريع ← ملفات المشروع ▾ ← مشروع توضيحي جديد ← Hybrid Car (SysML v2))، وافتح النموذج ← المحرر والحزمة Vehicles. وهي تستورد HolarchVariability مسبقًا.
  2. في part def CarLine، بعد التباين charger، أضف variation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. ينبّه المحرر إلى أن التكوينات الثلاثة لم تختر rims بعد.
  3. بعد wallboxNeedsLargePack، أضف القاعدة assert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }.
  4. افتح النموذج ← المستعرض وحدد selfChargingHybrid. في قسم التكوين في لوحة الخصائص، اختر steelRims لـ rims؛ واختر alloyRims لـ plugInHybrid وlongRangeHybrid. ثم جرّب alloyRims على selfChargingHybrid، واقرأ الحكم، واضغط ⌘Z / Ctrl+Z.
  5. افتح قائمة الصف (⋯) لـ CarLine واختر تكوين جديد…. سمّه cityHybrid، واختر standardPack وnoCharger وsteelRims، وتحقق من أن الحكم «صالح»، ثم انقر إنشاء.
  6. انقر العرض بوصفه ▾ في الشريط العلوي واختر cityHybrid، ثم افتح العرض carLineVariants من قائمة المخططات: المتغيرات التي لا يختارها مخفية.

تكون قد انتهيت عندما يذكر قسم «خط المنتجات» في لوحة الخصائص لـ CarLine أربعة تكوينات، كلها صالحة، والقاعدة alloyNeedsLargePack.

اختبر نفسك

  1. ما الفرق بين variation part def BatteryPack { … } وvariation part charger : Component { … }؟
  2. يختار plugInHybrid كلًا من BatteryPack::standardPack وcharger::wallbox. ماذا يحدث، ولماذا؟
  3. تكوين لم يختر متغيرًا لكل نقطة بعد. ما حكمه؟
  4. ما الذي يتيح لك metadata def <safetyCritical> SafetyCritical كتابته، وكيف تراه أدوات SysML v2 الأخرى؟
إظهار الإجابات
  1. ما الفرق بين variation part def BatteryPack { … } وvariation part charger : Component { … }؟

    الأول تعريف تباين، أي مجموعة خيارات قابلة لإعادة الاستخدام: والاستخدام المنمّط به، مثل part pack : BatteryPack;، نقطة تباين. والثاني استخدام تباين، أي نقطة مُعلنة داخل تصميم واحد.

  2. يختار plugInHybrid كلًا من BatteryPack::standardPack وcharger::wallbox. ماذا يحدث، ولماذا؟

    تُخرق القاعدة wallboxNeedsLargePack: إذ تقول إن wallbox يستلزم الحزمة الكبيرة. ويسمّي الحكم القاعدة، ويُبلغ المحرر عن الإثبات الذي أخفق.

  3. تكوين لم يختر متغيرًا لكل نقطة بعد. ما حكمه؟

    غير مكتمل، مع تسمية النقطة المفتوحة. وما دامت نقطة بلا خيار، فإن القاعدة عليها لا تُستوفى ولا تُخرق.

  4. ما الذي يتيح لك 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.