課程章節
培訓 · 第 9 單元:SysML v2 基礎 · 第 9.3 章,共 8 章
9.3 動作與流 4:31
將功能與行駛循環寫成動作,並以 Action Flow 檢視與 FFBD 查看。
展示 Holarch 2.22。
您將學到
- 定義具有輸入與輸出參數、並以功能編號為短名稱的動作
- 撰寫含有 fork、join、succession 與項流的動作
- 從 `perform` 取得 Action Flow 檢視中的泳道
- 在功能分析中挑選最上層功能
- 在 FFBD 中建立動作的步驟,並在文字中找到它們
在 Holarch 中撰寫 SysML v2 動作,依循 SysML v2 教學課程 Actions and Flows,以一個小型 Hybrid Car 專案進行:具有參數與短名稱的動作定義、含 fork、流與 join 的行駛循環、依 perform 產生泳道的 Action Flow 檢視、對模型進行功能分析,以及在 FFBD 中建立、由 Holarch 寫入文字的步驟。SysML 是 Object Management Group, Inc. 的註冊商標。
練習
在 Holarch 中於 Hybrid Car 示範專案(SysML v2)上親自操作。
- 開啟您的 Hybrid Car 示範專案(如有需要請建立:管理專案 → 專案檔案 ▾ → 新增示範專案 → Hybrid Car (SysML v2)),開啟模型 → 編輯器以及套件
VehicleBehavior。 - 在
action def <'F.3'> DriveWheels下方新增action def <'F.4'> Refuel { in attribute fuelDemand : Real; out item fuel : Fuel; }。 - 開啟行為 → FFBD,按一下 + 新增圖,選擇
Refuel,然後按一下建立。在新增面板中輸入Open Filler Door並按 Enter,接著輸入Pump Fuel與Close Filler Door。 - 開啟模型 → 編輯器並找到
Refuel:FFBD 已寫入它的三個步驟以及步驟之間的 succession。 - 開啟行為 → Action Flow以及檢視
driveCycleFlow。找到包含brake的泳道,然後在DrivenCar中找到將它放在那裡的perform行。 - 開啟行為 → 功能分析,按一下選擇…並挑選
DriveCycle。確認其功能是依短名稱編號的。
當 Refuel 在編輯器中顯示其參數、三個步驟及其 succession,且您能說出哪個零件的泳道包含 brake 時,即完成。
自我檢查
- 在
first start then split; fork split; then supply; then produce;中,哪些步驟平行執行?又是什麼讓它們重新匯合? first supply then ready;與flow of Fuel from supply.fuel to produce.fuel;有什麼不同?- Action Flow 檢視的泳道從哪裡來?
顯示答案
在
first start then split; fork split; then supply; then produce;中,哪些步驟平行執行?又是什麼讓它們重新匯合?在 fork
split之後,supply與produce以平行分支開始;fork 之後的每個then都會開始一個分支。joinready會等待兩者完成後才進入下一步。first supply then ready;與flow of Fuel from supply.fuel to produce.fuel;有什麼不同?前者是 succession:它依時間排定步驟的順序。後者是 flow:它將一個 Fuel 項從某個步驟的輸出參數傳到另一個步驟的輸入,本身並不排定步驟的順序。
Action Flow 檢視的泳道從哪裡來?
來自
perform:每個執行某步驟的零件,例如part redefines tank { perform trip.supply; },都會得到一條包含其執行步驟的泳道。
延伸閱讀
文字稿
顯示文字稿 (旁白與畫面內容)
Introduction
Chapter three: actions and flows. Actions describe what the system does, in what order, and what passes between the steps.
In this chapter you define functions with parameters, write a drive cycle with a fork, flows and a join, see it as an Action Flow View with swim lanes, and build steps in the FFBD.
Start the tutorial
Start the tutorial Actions and Flows from Project Files, Start a Tutorial. Its starter project holds the fuel and torque items, two of the car's three functions, and the parts that will perform them.
On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Actions and Flows → Start; Model → Editor.
Functions
An action definition describes something the system does, and its parameters say what goes in and out. Below the torque item, define Supply Fuel. The short name in angle brackets, F one, is its function number.
On screen: Below item def Torque; type action def <'F.1'> SupplyFuel.
The drive cycle
Now the drive cycle, at the end of the package. Its action usages are the steps, each typed by a function. First start, then split, begins with a fork, and each then after the fork starts a parallel branch.
On screen: After DriveWheels; type action def <'F'> DriveCycle with the fork and two steps.
A flow carries an item from one step's output to another step's input. After the two steps, add a flow that carries the fuel from the supply step to the torque step.
On screen: After action produce: flow of Fuel from supply.fuel to produce.fuel;
Both branches end at a join named ready. Then the car drives the wheels, and the trip is done. A second flow carries the torque to the drive step.
On screen: After the flow: successions to the join ready, then action drive, then done; flow of torque.
The Action Flow View
Now see the drive cycle as a view. Open Behavior, then Action Flows, and click New Diagram. Keep Action Flow View, choose the drive cycle under Shows, and click Create.
On screen: Behavior → Action Flows → + New Diagram; Shows: VehicleBehavior::DriveCycle; Create.
Steps are rounded boxes, with their parameters as pins. The fork and the join are bars, and the flows are arrows between pins.
On screen: The view.
Swim lanes come from perform. Back in the Editor, at the end of the package, add a driven car. It performs the drive cycle as its trip, and its parts perform the steps.
On screen: Model → Editor; after DriveCycle: part def DrivenCar with perform.
Open the Action Flow View again. It now has a lane for each part that performs a step.
On screen: Behavior → Action Flows → the view; lanes tank, engine, transmission.
Functional Analysis and the FFBD
The same model drives Functional Analysis. Open it under Behavior, click Choose, and pick the drive cycle. Its functions are the steps, numbered by their short names.
On screen: Behavior → Functional Analysis; Choose… → DriveCycle.
Back in the Editor, at the end of the package, declare one more action: emergency shutdown. You build its steps in the FFBD.
On screen: Model → Editor; after DrivenCar: action def EmergencyShutdown;
Open Behavior, then FFBD, and click New Diagram. Type the start of emergency shutdown, pick it from the list, and click Create.
On screen: Behavior → FFBD → + New Diagram; Diagram of: EmergencyShutdown; Create.
In the Add panel, type Open Contactors and press Enter, then Cut Fuel. Each step is written into the model with its succession, one undo step each.
On screen: Add panel: Open Contactors ↵, Cut Fuel ↵.
Open the Editor and find emergency shutdown. The FFBD wrote its steps, and the successions between them.
On screen: Model → Editor: EmergencyShutdown with two steps and successions.
Recap
Every step is ticked off. Click Mark as Done.
On screen: Step panel → Mark as Done.
Let's recap. You defined functions with parameters and short names, wrote a drive cycle with a fork, flows and a join, saw it as an Action Flow View with lanes from perform, and built steps in the FFBD that Holarch wrote into the text.
Next, states and transitions describe how the car reacts to events.