Holarch
Chapitres du cours

Formation · Parcours 9. Les fondamentaux de SysML v2 · Chapitre 9.2 sur 8

9.2 Ports et interfaces 3:44

Définir des ports et des interfaces, relier des parts en texte, et dessiner une interface dans une vue.

Montre Holarch 2.22.

Ce que vous allez apprendre

  • Définir un port avec des attributs orientés et le conjuguer avec `~`
  • Définir une interface dont les extrémités sont typées par des ports
  • Relier des parts avec un usage d'interface et lier un port de frontière au port d'une part interne
  • Créer une Vue d'interconnexion et dessiner une interface entre deux ports

Définissez des ports et des interfaces SysML v2 dans Holarch, en suivant le tutoriel SysML v2 Ports and Interfaces sur un petit projet Hybrid Car : une définition de port avec des directions, un port conjugué, une définition d'interface à deux extrémités, un groupe motopropulseur dont les parts sont reliées par des interfaces et une liaison, une Vue d'interconnexion de celui-ci, et une interface dessinée dans la vue que Holarch écrit dans le texte. SysML est une marque déposée d'Object Management Group, Inc.

Fichiers de projet

  • Projet terminé (.holarch.json ; Gérer les projets → Fichiers de projet ▾ → Importer un projet (.json)…)

La vidéo est diffusée depuis holarch.app ; voir la Politique de confidentialité.

Pratique

Faites-le vous-même dans Holarch, sur le projet de démonstration Hybrid Car (SysML v2).

  1. Ouvrez votre projet de démonstration Hybrid Car (créez-le si besoin : Gérer les projets → Fichiers de projet ▾ → Nouveau projet de démonstration → Hybrid Car (SysML v2)), ouvrez Modèle → Éditeur et le package Vehicles.
  2. Sous interface def HighVoltageBus, ajoutez interface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }.
  3. Dans part def Powertrain, remplacez connect controller.engineCtl to engine.ecu; par interface engineControl : ControlLink connect controller.engineCtl to engine.ecu;, et ajoutez part auxBattery : Battery; après part battery : Battery;.
  4. Ouvrez Architecture → Vues d'interconnexion et la vue powertrainConnections. Faites glisser depuis la poignée du port powerOut d'auxBattery jusqu'au port powerIn du moteur et choisissez Interface : HighVoltageBus.
  5. Sélectionnez la nouvelle ligne et saisissez auxBus comme Nom dans l'inspecteur. Ouvrez ensuite Modèle → Éditeur et trouvez la ligne que Holarch a écrite dans Powertrain.

C'est terminé quand Powertrain contient interface engineControl : ControlLink … et l'interface auxBus issue de la vue, et que l'état sous l'éditeur ne signale aucun problème.

Vérifiez vos connaissances

  1. Le moteur a port fuelIn : ~FuelPort;. Que change le tilde ?
  2. Quelle est la différence entre bind output = transmission.output; et interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn; ?
  3. Pourquoi la vue propose-t-elle Interface : HighVoltageBus quand vous faites glisser du powerOut d'une batterie vers le powerIn du moteur ?
Afficher les réponses
  1. Le moteur a port fuelIn : ~FuelPort;. Que change le tilde ?

    Il conjugue le port : le port du moteur a les mêmes features que FuelPort avec les directions inversées, si bien que l'out attribute flowRate de FuelPort arrive au moteur comme une entrée.

  2. Quelle est la différence entre bind output = transmission.output; et interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn; ?

    Une liaison (binding) dit que les deux features sont identiques : le port de frontière du groupe motopropulseur est la sortie de la transmission. Un usage d'interface relie deux ports différents, et sa définition d'interface indique quels ports ses extrémités acceptent.

  3. Pourquoi la vue propose-t-elle Interface : HighVoltageBus quand vous faites glisser du powerOut d'une batterie vers le powerIn du moteur ?

    Holarch propose les définitions d'interface dont les extrémités conviennent aux deux ports. HighVoltageBus a les extrémités source : PowerPort et load : ~PowerPort, qui correspondent aux deux ports.

Pour aller plus loin

Transcription

Afficher la transcription (narration et contenu de l'écran)

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.