コースのチャプター
トレーニング · トラック 9. SysML v2 の基礎 · チャプター 9.2(全 8 チャプター)
9.2 ポートとインターフェース 3:44
ポートとインターフェースを定義し、テキストでパートを接続し、ビューでインターフェースを描きます。
Holarch 2.22 の画面です。
学習内容
- 方向付きの属性を持つポートを定義し、`~` で共役にする
- 端がポートで型付けされたインターフェースを定義する
- インターフェース使用でパートを接続し、境界ポートを内部パートのポートにバインドする
- Interconnection View を作成し、2 つのポートの間にインターフェースを描く
小さな Hybrid Car プロジェクトで SysML v2 チュートリアル「Ports and Interfaces」に沿って、Holarch で SysML v2 のポートとインターフェースを定義します。方向を持つポート定義、共役ポート、2 つの端を持つインターフェース定義、インターフェースとバインディングでパートが接続されたパワートレイン、その Interconnection View、そしてビューで描き Holarch がテキストに書き込むインターフェースを扱います。SysML は Object Management Group, Inc. の登録商標です。
プロジェクトファイル
- 完成したプロジェクト (.holarch.json。プロジェクトを管理 → プロジェクトファイル ▾ → プロジェクトをインポート (.json)…)
動画は holarch.app から再生されます。プライバシーポリシーをご覧ください。
演習
Hybrid Car デモプロジェクト(SysML v2)を使って、Holarch で実際に操作します。
- 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 battery : Battery;の後にpart auxBattery : Battery;を追加します。- アーキテクチャ → Interconnection Views とビュー
powertrainConnectionsを開きます。auxBatteryのポートpowerOutのハンドルからモーターのポートpowerInまでドラッグし、インターフェース : 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;の違いは何ですか?- バッテリーの
powerOutからモーターのpowerInへドラッグすると、ビューが「インターフェース : HighVoltageBus」を提示するのはなぜですか?
解答を表示
エンジンには
port fuelIn : ~FuelPort;があります。チルダは何を変えますか?ポートを共役にします。エンジンのポートは FuelPort と同じフィーチャーを持ちますが方向が逆になるため、FuelPort の
out attribute flowRateはエンジンには入力として届きます。bind output = transmission.output;とinterface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;の違いは何ですか?バインディングは 2 つのフィーチャーが同じであることを表します。パワートレインの境界ポートはトランスミッションの出力です。インターフェース使用は 2 つの異なるポートを接続し、そのインターフェース定義が各端で受け付けるポートを決めます。
バッテリーの
powerOutからモーターのpowerInへドラッグすると、ビューが「インターフェース : HighVoltageBus」を提示するのはなぜですか?Holarch は、両端が両方のポートに適合するインターフェース定義を提示します。HighVoltageBus には
source : PowerPortとload : ~PowerPortの端があり、2 つのポートと一致します。
関連資料
トランスクリプト
トランスクリプトを表示 (ナレーションと画面の内容)
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.