Holarch
Capitoli del corso

Formazione · Percorso 9. Fondamenti di SysML v2 · Capitolo 9.2 di 8

9.2 Ports and Interfaces 3:44

Definire porte e interfacce, collegare parti nel testo e disegnare un’interfaccia in una vista.

Mostra Holarch 2.22.

← 9.1 Definitions and Attributes · Tutti i capitoli · 9.3 Actions and Flows →

Che cosa si impara

  • Definire una porta con attributi orientati e coniugarla con `~`
  • Definire un’interfaccia le cui estremità sono tipizzate da porte
  • Collegare parti con un uso di interfaccia e legare una porta di confine alla porta di una part interna (binding)
  • Creare una Vista di interconnessione e disegnare un’interfaccia tra due porte

Definire porte e interfacce SysML v2 in Holarch, seguendo il tutorial SysML v2 Ports and Interfaces su un piccolo progetto Hybrid Car: una definizione di porta con direzioni, una porta coniugata, una definizione di interfaccia con due estremità, un gruppo motopropulsore le cui parti sono collegate da interfacce e da un binding, una sua Vista di interconnessione e un’interfaccia disegnata nella vista che Holarch scrive nel testo. SysML è un marchio registrato di Object Management Group, Inc.

File di progetto

  • Progetto completato (.holarch.json; Gestisci progetti → File di progetto ▾ → Importa progetto (.json)…)

Il video viene riprodotto da holarch.app; vedere l’Informativa sulla privacy.

Esercitazione

Provare in prima persona in Holarch, sul progetto demo Hybrid Car (SysML v2).

  1. Aprire il progetto demo Hybrid Car (crearlo se necessario: Gestisci progetti → File di progetto ▾ → Nuovo progetto demo → Hybrid Car (SysML v2)), aprire Modello → Editor e il package Vehicles.
  2. Sotto interface def HighVoltageBus, aggiungere interface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }.
  3. In part def Powertrain, sostituire connect controller.engineCtl to engine.ecu; con interface engineControl : ControlLink connect controller.engineCtl to engine.ecu; e aggiungere part auxBattery : Battery; dopo part battery : Battery;.
  4. Aprire Architettura → Viste di interconnessione e la vista powertrainConnections. Trascinare dalla maniglia della porta powerOut di auxBattery alla porta powerIn del motore e scegliere Interface : HighVoltageBus.
  5. Selezionare la nuova linea e inserire auxBus come Nome nell’ispettore. Poi aprire Modello → Editor e trovare la riga che Holarch ha scritto in Powertrain.

L’esercizio è completato quando Powertrain contiene interface engineControl : ControlLink … e l’interfaccia auxBus creata dalla vista, e lo stato sotto l’editor non segnala problemi.

Verifica

  1. Il motore ha port fuelIn : ~FuelPort;. Che cosa cambia la tilde?
  2. Qual è la differenza tra bind output = transmission.output; e interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?
  3. Perché la vista propone Interface : HighVoltageBus quando si trascina dalla powerOut di una batteria alla powerIn del motore?
Mostra le risposte
  1. Il motore ha port fuelIn : ~FuelPort;. Che cosa cambia la tilde?

    Coniuga la porta: la porta del motore ha le stesse feature di FuelPort con le direzioni invertite, quindi l’out attribute flowRate di FuelPort arriva al motore come input.

  2. Qual è la differenza tra bind output = transmission.output; e interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?

    Un binding dice che le due feature sono la stessa: la porta di confine del gruppo motopropulsore è l’uscita della trasmissione. Un uso di interfaccia collega due porte diverse, e la sua definizione di interfaccia dice quali porte accettano le sue estremità.

  3. Perché la vista propone Interface : HighVoltageBus quando si trascina dalla powerOut di una batteria alla powerIn del motore?

    Holarch propone le definizioni di interfaccia le cui estremità si adattano a entrambe le porte. HighVoltageBus ha le estremità source : PowerPort e load : ~PowerPort, che corrispondono alle due porte.

Per saperne di più

Trascrizione

Mostra la trascrizione (narrazione e contenuto dello schermo)

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.