Holarch
课程章节

培训 · 课程 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 动作,基于一个小型 Hybrid Car 项目,依照 SysML v2 教程“动作和流”:带参数和短名称的动作定义、带 fork、流和 join 的驾驶循环、通过 perform 得到泳道的 Action Flow 视图、对模型进行功能分析,以及在 FFBD 中构建并由 Holarch 写入文本的步骤。SysML 是 Object Management Group, Inc. 的注册商标。

项目文件

  • 完成项目 (.holarch.json;管理项目 → 项目文件 ▾ → 导入项目 (.json)…)

视频从 holarch.app 播放;参见隐私政策。

练习

在 Holarch 中基于 Hybrid Car 演示项目 (SysML v2) 亲自完成此操作。

  1. 打开您的 Hybrid Car 演示项目(如有需要,请创建:管理项目 → 项目文件 ▾ → 新建演示项目 → Hybrid Car (SysML v2)),打开 模型 → 编辑器 和包 VehicleBehavior。
  2. 在 action def <'F.3'> DriveWheels 下方添加 action def <'F.4'> Refuel { in attribute fuelDemand : Real; out item fuel : Fuel; }。
  3. 打开 行为 → FFBD,单击 + 新建图,选择 Refuel,然后单击 创建。在 添加 面板中输入 Open Filler Door 并按 Enter,然后依次输入 Pump Fuel 和 Close Filler Door。
  4. 打开 模型 → 编辑器,找到 Refuel:FFBD 已写入其三个步骤以及它们之间的 succession。
  5. 打开 行为 → 动作流 和视图 driveCycleFlow。找到包含 brake 的泳道,然后在 DrivenCar 中找到将其放在那里的 perform 行。
  6. 打开 行为 → 功能分析,单击 选择… 并选择 DriveCycle。确认其功能按短名称编号。

当 Refuel 在编辑器中显示其参数、三个步骤及其 succession,且您能说出哪个部件的泳道包含 brake 时,即完成练习。

自测

  1. 在 first start then split; fork split; then supply; then produce; 中,哪些步骤并行运行?什么使它们重新汇合?
  2. first supply then ready; 与 flow of Fuel from supply.fuel to produce.fuel; 有什么区别?
  3. Action Flow 视图的泳道从何而来?
显示答案
  1. 在 first start then split; fork split; then supply; then produce; 中,哪些步骤并行运行?什么使它们重新汇合?

    在 fork split 之后,supply 和 produce 作为并行分支开始;fork 之后的每个 then 都开始一个分支。join ready 等待两者都完成后再进入下一步。

  2. first supply then ready; 与 flow of Fuel from supply.fuel to produce.fuel; 有什么区别?

    前者是 succession:它在时间上排列步骤的顺序。后者是流:它将一个 Fuel 项从一个步骤的输出参数传递到另一个步骤的输入,其本身并不排列步骤的顺序。

  3. 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.