Holarch
Розділи курсів

Навчання · Курс 9. Основи SysML v2 · Розділ 9.3 з 8

9.3 Дії та потоки 4:31

Запишіть функції та їздовий цикл як дії й перегляньте їх як подання Action Flow і FFBD.

Показано Holarch 2.22.

← 9.2 Порти та інтерфейси · Усі розділи · 9.4 Стани та переходи →

Що ви дізнаєтеся

  • Визначити дію з вхідними й вихідними параметрами та номером функції як коротким іменем
  • Написати дію з fork, join, послідовностями й потоками елементів
  • Отримати доріжки в поданні Action Flow з `perform`
  • Вибрати функцію верхнього рівня у «Функціональний аналіз»
  • Побудувати кроки дії в FFBD і знайти їх у тексті

Пишіть дії SysML v2 у Holarch за навчальним посібником SysML v2 Actions and Flows на невеликому проєкті Hybrid Car: визначення дій із параметрами й короткими іменами, їздовий цикл із fork, потоками та join, подання Action Flow з доріжками з perform, функціональний аналіз на моделі й кроки, побудовані в 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 записала три його кроки й послідовності між ними.
  5. Відкрийте Поведінка → Потоки дій і подання driveCycleFlow. Знайдіть доріжку з brake, а потім рядок perform у DrivenCar, що поміщає її туди.
  6. Відкрийте Поведінка → Функціональний аналіз, натисніть Вибрати… і виберіть DriveCycle. Перевірте, що її функції пронумеровано за їхніми короткими іменами.

Завдання виконано, коли Refuel показує в Редакторі свої параметри, три кроки та їхні послідовності, і ви можете назвати частину, чия доріжка містить 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 починаються як паралельні гілки; кожен then після fork починає гілку. Join ready чекає на обидві перед наступним кроком.

  2. Чим відрізняються first supply then ready; і flow of Fuel from supply.fuel to produce.fuel;?

    Перше — це послідовність: вона впорядковує кроки в часі. Друге — потік: він переносить елемент 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.