Holarch
Kurs bölümleri

Eğitim · Kurs 9. SysML v2 temelleri · Bölüm 9.2 / 8

9.2 Portlar ve arayüzler 3:44

Portları ve arayüzleri tanımlayın, parçaları metinde bağlayın ve bir görünümde bir arayüz çizin.

Holarch 2.22 sürümünü gösterir.

Neler öğreneceksiniz

  • Yönlü özniteliklere sahip bir port tanımlayın ve onu `~` ile eşlenik yapın
  • Uçları portlarla türlenmiş bir arayüz tanımlayın
  • Parçaları bir arayüz kullanımıyla bağlayın ve bir sınır portunu bir iç parçanın portuna bağlayın
  • Bir Interconnection View oluşturun ve iki port arasında bir arayüz çizin

Küçük bir Hybrid Car projesi üzerinde SysML v2 öğreticisi Ports and Interfaces'i izleyerek Holarch'ta SysML v2 portlarını ve arayüzlerini tanımlayın: yönleri olan bir port tanımı, eşlenik bir port, iki uçlu bir arayüz tanımı, parçaları arayüzlerle ve bir bağlamayla bağlanmış bir güç aktarma organı, onun bir Interconnection View'u ve görünümde çizilip Holarch'ın metne yazdığı bir arayüz. SysML, Object Management Group, Inc.'in tescilli ticari markasıdır.

Proje dosyaları

  • Bitmiş proje (.holarch.json; Projeleri yönet → Proje dosyaları ▾ → Proje içe aktar (.json)…)

Video holarch.app'ten oynatılır; bkz. Gizlilik Politikası.

Alıştırma

Bunu Holarch'ta, Hybrid Car demo projesinde (SysML v2) kendiniz yapın.

  1. Hybrid Car demo projenizi açın (gerekirse oluşturun: Projeleri yönet → Proje dosyaları ▾ → Yeni demo proje → Hybrid Car (SysML v2)), Model → Düzenleyici'yi ve Vehicles paketini açın.
  2. interface def HighVoltageBus'ın altına interface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; } ekleyin.
  3. part def Powertrain içinde connect controller.engineCtl to engine.ecu; satırını interface engineControl : ControlLink connect controller.engineCtl to engine.ecu; ile değiştirin ve part battery : Battery;'den sonra part auxBattery : Battery; ekleyin.
  4. Mimari → Interconnection View'lar'ı ve powertrainConnections görünümünü açın. auxBattery'nin powerOut portunun tutamacından motorun powerIn portuna sürükleyin ve Interface : HighVoltageBus'ı seçin.
  5. Yeni çizgiyi seçin ve özellik panelinde Ad olarak auxBus girin. Ardından Model → Düzenleyici'yi açın ve Holarch'ın Powertrain içine yazdığı satırı bulun.

Powertrain, interface engineControl : ControlLink … ile görünümden gelen auxBus arayüzünü içerdiğinde ve düzenleyicinin altındaki durum hiçbir sorun bildirmediğinde işiniz bitmiştir.

Kendinizi sınayın

  1. Motorda port fuelIn : ~FuelPort; var. Tilde neyi değiştirir?
  2. bind output = transmission.output; ile interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn; arasındaki fark nedir?
  3. Bir bataryanın powerOut'undan motorun powerIn'ine sürüklediğinizde görünüm neden Interface : HighVoltageBus seçeneğini sunar?
Yanıtları göster
  1. Motorda port fuelIn : ~FuelPort; var. Tilde neyi değiştirir?

    Portu eşlenik yapar: motorun portu FuelPort ile aynı özelliklere sahiptir ama yönleri terstir, bu yüzden FuelPort'un out attribute flowRate'i motora girdi olarak ulaşır.

  2. bind output = transmission.output; ile interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn; arasındaki fark nedir?

    Bir bağlama iki özelliğin aynı olduğunu söyler: güç aktarma organının sınır portu, şanzımanın çıktısıdır. Bir arayüz kullanımı ise iki farklı portu bağlar ve arayüz tanımı uçlarının hangi portları kabul ettiğini söyler.

  3. Bir bataryanın powerOut'undan motorun powerIn'ine sürüklediğinizde görünüm neden Interface : HighVoltageBus seçeneğini sunar?

    Holarch, uçları her iki porta da uyan arayüz tanımlarını sunar. HighVoltageBus'ın uçları source : PowerPort ve load : ~PowerPort'tur ve bunlar iki portla eşleşir.

Daha fazla bilgi

Döküm

Dökümü göster (anlatım ve ekranda görünenler)

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.