Holarch
Kurskapitel

Schulung · Reihe 9. SysML-v2-Grundlagen · Kapitel 9.2 von 8

9.2 Ports und Schnittstellen 3:44

Ports und Interfaces definieren, Parts im Text verbinden und ein Interface in einer Ansicht zeichnen.

Zeigt Holarch 2.22.

Das lernen Sie

  • Einen Port mit gerichteten Attributen definieren und ihn mit `~` konjugieren
  • Ein Interface definieren, dessen Enden durch Ports typisiert sind
  • Parts mit einer Interface-Usage verbinden und einen Grenzport an den Port eines inneren Parts binden
  • Eine Interconnection-Ansicht erstellen und ein Interface zwischen zwei Ports zeichnen

Definieren Sie SysML-v2-Ports und -Interfaces in Holarch, nach dem SysML-v2-Tutorial „Ports and Interfaces“ an einem kleinen Hybrid-Car-Projekt: eine Port-Definition mit Richtungen, ein konjugierter Port, eine Interface-Definition mit zwei Enden, ein Antriebsstrang, dessen Parts durch Interfaces und ein Binding verbunden sind, eine Interconnection-Ansicht davon und ein in der Ansicht gezeichnetes Interface, das Holarch in den Text schreibt. SysML ist eine eingetragene Marke der Object Management Group, Inc.

Projektdateien

  • Fertiges Projekt (.holarch.json; Projekte verwalten → Projektdateien ▾ → Projekt importieren (.json)…)

Das Video wird von holarch.app abgespielt; siehe Datenschutzerklärung.

Übung

Führen Sie dies selbst in Holarch durch, am Demoprojekt Hybrid Car (SysML v2).

  1. Öffnen Sie Ihr Demoprojekt Hybrid Car (erstellen Sie es bei Bedarf: Projekte verwalten → Projektdateien ▾ → Neues Demoprojekt → Hybridauto (SysML v2)), öffnen Sie Modell → Editor und das Package Vehicles.
  2. Fügen Sie unter interface def HighVoltageBus interface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; } hinzu.
  3. Ersetzen Sie in part def Powertrain connect controller.engineCtl to engine.ecu; durch interface engineControl : ControlLink connect controller.engineCtl to engine.ecu; und fügen Sie nach part battery : Battery; part auxBattery : Battery; hinzu.
  4. Öffnen Sie Architektur → Interconnection Views und die Ansicht powertrainConnections. Ziehen Sie vom Griff des Ports powerOut von auxBattery zum Port powerIn des Motors und wählen Sie Interface : HighVoltageBus.
  5. Wählen Sie die neue Linie aus und geben Sie im Inspektor auxBus als Name ein. Öffnen Sie dann Modell → Editor und suchen Sie die Zeile, die Holarch in Powertrain geschrieben hat.

Sie sind fertig, wenn Powertrain interface engineControl : ControlLink … und das Interface auxBus aus der Ansicht enthält und der Status unter dem Editor keine Probleme meldet.

Selbsttest

  1. Der Motor hat port fuelIn : ~FuelPort;. Was ändert die Tilde?
  2. Was ist der Unterschied zwischen bind output = transmission.output; und interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?
  3. Warum bietet die Ansicht Interface : HighVoltageBus an, wenn Sie vom powerOut einer Batterie zum powerIn des Motors ziehen?
Antworten anzeigen
  1. Der Motor hat port fuelIn : ~FuelPort;. Was ändert die Tilde?

    Sie konjugiert den Port: Der Port des Motors hat dieselben Features wie FuelPort mit umgekehrten Richtungen, daher kommt das out attribute flowRate von FuelPort beim Motor als Eingang an.

  2. Was ist der Unterschied zwischen bind output = transmission.output; und interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?

    Ein Binding sagt, dass die beiden Features dasselbe sind: Der Grenzport des Antriebsstrangs ist der Ausgang des Getriebes. Eine Interface-Usage verbindet zwei verschiedene Ports, und ihre Interface-Definition sagt, welche Ports ihre Enden akzeptieren.

  3. Warum bietet die Ansicht Interface : HighVoltageBus an, wenn Sie vom powerOut einer Batterie zum powerIn des Motors ziehen?

    Holarch bietet die Interface-Definitionen an, deren Enden zu beiden Ports passen. HighVoltageBus hat die Enden source : PowerPort und load : ~PowerPort, die zu den beiden Ports passen.

Weiterlesen

Transkript

Transkript anzeigen (Erzählung und Bildschirminhalt)

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.