Holarch
課程章節

培訓 · 第 9 單元:SysML v2 基礎 · 第 9.7 章,共 8 章

9.7 約束與計算 4:26

撰寫約束與計算、以單位檢查轎車的數值,並標記待定數值。

展示 Holarch 2.22。

您將學到

  • 撰寫具有參數的約束定義與計算定義
  • 將約束用法的參數繫結到模型中的數值
  • 在參數檢視中看到約束通過與失敗,並以「全部求解」檢查每個約束
  • 以 TBD 與 TBR 中繼資料標記待定數值,並在 TBD/TBR 登錄表中找到它們
  • 在「預算和 TPM」中彙總零件的質量

在 Holarch 中撰寫 SysML v2 約束與計算,依循 SysML v2 教學課程 Constraints and Calculations,以一個小型 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. 開啟架構 → 預算和 TPM,按一下選擇根零件…並選擇 sedan。在數量下選擇質量,找到電池的 48 kg。

當 sedanBatteryCheck 在參數檢視中顯示 Pass,且 TBD/TBR 登錄表列出負責人為 Test lead 的 Acceleration 需求時,即完成。

自我檢查

  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。來自 Holarch HolarchMetadata 套件的中繼資料能讓文字保持有效;TBD 與 TBR 特化了標準的 StatusInfo 中繼資料,因此其他 SysML v2 工具會將它們讀作狀態註記。

  4. 分析案例為計算增加了什麼?

    它將計算套用到一個主體(例如轎車)、回傳結果,並具有一個目標,其 require 約束由 Holarch 像其他約束一樣進行評估。

延伸閱讀

文字稿

顯示文字稿 (旁白與畫面內容)

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.