Holarch
فصول الدورة

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

9.7 القيود والحسابات 4:26

اكتب القيود والحسابات، وتحقق من قيم السيدان بالوحدات، وعلّم القيم المفتوحة.

يعرض Holarch 2.22.

ما ستتعلمه

  • اكتب تعريف قيد وتعريف حساب بمعاملات
  • اربط معاملات استخدام قيد بقيم في النموذج
  • شاهد قيدًا ينجح ويخفق في «العرض البارامتري»، وتحقق من كل قيد باستخدام «حل الكل»
  • علّم القيم المفتوحة ببيانات وصفية TBD وTBR واعثر عليها في سجل TBD/TBR
  • اجمع كتلة جزء في «الميزانيات وTPMs»

اكتب قيود وحسابات SysML v2 في Holarch، باتباع البرنامج التعليمي Constraints and Calculations الخاص بـ SysML v2 على مشروع 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. افتح البنية ← الميزانيات وTPMs، وانقر تحديد الجزء الجذري… واختر 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 صالحًا. والبيانات الوصفية من حزمة HolarchMetadata في Holarch تُبقي النص صالحًا؛ إذ تخصّص TBD وTBR البيانات الوصفية القياسية StatusInfo، فتقرؤها أدوات SysML v2 الأخرى كتعليقات توضيحية للحالة.

  4. ما الذي تضيفه حالة التحليل إلى الحساب؟

    تطبّق الحساب على موضوع، مثل السيدان، وتعيد النتيجة، ولها هدف يقيّم Holarch قيده require كأي قيد آخر.

قراءة المزيد

النص المكتوب

إظهار النص المكتوب (التعليق الصوتي وما يظهر على الشاشة)

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.