Розділи курсів
Навчання · Курс 9. Основи SysML v2 · Розділ 9.2 з 8
9.2 Порти та інтерфейси 3:44
Визначайте порти й інтерфейси, з’єднуйте частини в тексті й малюйте інтерфейс у поданні.
Показано Holarch 2.22.
Що ви дізнаєтеся
- Визначити порт зі спрямованими атрибутами й спрягти його через `~`
- Визначити інтерфейс, кінці якого типізовано портами
- З’єднати частини використанням інтерфейсу й прив’язати граничний порт до порту внутрішньої частини
- Створити подання взаємозв’язків і намалювати інтерфейс між двома портами
Визначайте порти й інтерфейси SysML v2 у Holarch за навчальним посібником SysML v2 Ports and Interfaces на невеликому проєкті Hybrid Car: визначення порту з напрямками, спряжений порт, визначення інтерфейсу з двома кінцями, силова установка, частини якої з’єднано інтерфейсами й прив’язуванням, її подання взаємозв’язків та інтерфейс, намальований у поданні, який Holarch записує в текст. SysML є зареєстрованою торговельною маркою Object Management Group, Inc.
Файли проєкту
- Готовий проєкт (.holarch.json; Керування проєктами → Файли проєкту ▾ → Імпортувати проєкт (.json)…)
Відео відтворюється з holarch.app; див. Політику конфіденційності.
Практика
Виконайте це самі в Holarch на демопроєкті Hybrid Car (SysML v2).
- Відкрийте свій демопроєкт Hybrid Car (за потреби створіть його: Керування проєктами → Файли проєкту ▾ → Новий демопроєкт → Hybrid Car (SysML v2)), відкрийте Модель → Редактор і пакет
Vehicles. - Під
interface def HighVoltageBusдодайтеinterface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }. - У
part def Powertrainзамінітьconnect controller.engineCtl to engine.ecu;наinterface engineControl : ControlLink connect controller.engineCtl to engine.ecu;і додайтеpart auxBattery : Battery;післяpart battery : Battery;. - Відкрийте Архітектура → Подання взаємозв’язків і подання
powertrainConnections. Перетягніть від маркера портуpowerOutелементаauxBatteryдо порту двигунаpowerInі оберіть Interface : HighVoltageBus. - Виберіть нову лінію й введіть
auxBusяк її Назва в інспекторі. Потім відкрийте Модель → Редактор і знайдіть рядок, який Holarch записав уPowertrain.
Завдання виконано, коли Powertrain містить interface engineControl : ControlLink … та інтерфейс auxBus з подання, а рядок стану під редактором не повідомляє про проблеми.
Перевірте себе
- Двигун має
port fuelIn : ~FuelPort;. Що змінює тильда? - Чим відрізняються
bind output = transmission.output;іinterface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;? - Чому подання пропонує Interface : HighVoltageBus, коли ви перетягуєте від
powerOutбатареї доpowerInдвигуна?
Показати відповіді
Двигун має
port fuelIn : ~FuelPort;. Що змінює тильда?Вона спрягає порт: порт двигуна має ті самі характеристики, що й FuelPort, з оберненими напрямками, тож
out attribute flowRateз FuelPort надходить до двигуна як вхід.Чим відрізняються
bind output = transmission.output;іinterface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?Прив’язування каже, що дві характеристики — це одне й те саме: граничний порт силової установки є виходом трансмісії. Використання інтерфейсу з’єднує два різні порти, а його визначення інтерфейсу вказує, які порти приймають його кінці.
Чому подання пропонує Interface : HighVoltageBus, коли ви перетягуєте від
powerOutбатареї доpowerInдвигуна?Holarch пропонує визначення інтерфейсів, кінці яких підходять до обох портів. HighVoltageBus має кінці
source : PowerPortіload : ~PowerPort, які відповідають двом портам.
Докладніше
Стенограма
Показати стенограму (озвучення і те, що на екрані)
Introduction
Chapter two: ports and interfaces. A port is where a part meets the world outside it. An interface says which ports may connect.
In this chapter you define a port and an interface, connect parts in a powertrain, and draw an interface in a view.
Start the tutorial
Start the tutorial Ports and Interfaces from Project Files, Start a Tutorial. Its starter project holds the car's components with their torque and power ports, two interface definitions, and nothing yet for fuel.
On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Ports and Interfaces → Start.
Ports
Above the torque port, define the fuel port. A port definition lists what crosses the port. Out means the flow rate leaves the part that owns the port.
On screen: Below FuelKind; type port def FuelPort.
The tank owns a fuel port. The engine takes fuel in, so its port is conjugated with a tilde: the same features, with in and out reversed.
On screen: FuelTank: port fuelOut : FuelPort; Engine: port fuelIn : ~FuelPort;
Interfaces
An interface definition says which ports may connect. Below the high voltage bus, define the fuel line, with a supply end and a conjugated consumer end.
On screen: Below HighVoltageBus; type interface def FuelLine.
Connect the parts
Now the powertrain: a part definition made of parts. Its own output port is bound to the transmission's output, so the two are one and the same.
On screen: After Transmission; type part def Powertrain with five parts, a port and bind.
Connect the tank to the engine with a fuel line. A dotted name reaches into a part: from the tank's fuel out, to the engine's fuel in.
On screen: In Powertrain after part transmission: interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;
The engine and the motor both drive the transmission, through a shaft each.
On screen: Two shaft interfaces.
The status under the editor says the text is applied, with no problems.
On screen: Applied, No problems.
The Interconnection View
Now see the powertrain as a view. Open Architecture, then Interconnection Views, and click New Diagram. Keep Interconnection View, choose the powertrain under Shows, and click Create.
On screen: Architecture → Interconnection Views → + New Diagram; Shows: Vehicles::Powertrain; Create.
The parts sit inside the frame with their ports on their sides. Each line is an interface from the text, and the output port on the frame is bound to the transmission.
On screen: The view.
Draw an interface
The battery does not feed the motor yet. Drag from the battery's power out port to the motor's power in. Holarch offers what fits both ports: choose Interface, High Voltage Bus.
On screen: Select battery.powerOut; drag its handle to motor.powerIn → Interface : HighVoltageBus.
Select the new line, and name it H V Bus in the inspector.
On screen: Click the new line; inspector Name: hvBus.
Close the inspector and open the text again. Holarch wrote the interface into the powertrain, with its name, its type and both ends.
On screen: Inspector ×; Model → Editor: the interface hvBus line in Powertrain.
Recap
Every step is ticked off. Click Mark as Done.
On screen: Step panel → Mark as Done.
Let's recap. You defined a port with a direction, conjugated it for the engine, defined an interface with two ends, connected the powertrain's parts in text, and drew an interface that Holarch wrote back into the text.
Next, actions and flows describe what the car does.