Capítulos do curso
Treinamento · Trilha 9. Fundamentos do SysML v2 · Capítulo 9.2 de 8
9.2 Portas e interfaces 3:44
Defina portas e interfaces, conecte partes em texto e desenhe uma interface em uma visão.
Mostra o Holarch 2.22.
O que você vai aprender
- Definir uma porta com atributos direcionados e conjugá-la com `~`
- Definir uma interface cujas pontas são tipadas por portas
- Conectar partes com um uso de interface e vincular uma porta de fronteira à porta de uma parte interna
- Criar uma Visão de interconexão e desenhar uma interface entre duas portas
Defina portas e interfaces SysML v2 no Holarch, seguindo o tutorial de SysML v2 Ports and Interfaces em um pequeno projeto Hybrid Car: uma definição de porta com direções, uma porta conjugada, uma definição de interface com duas pontas, um powertrain cujas partes estão conectadas por interfaces e um binding, uma Visão de interconexão dele e uma interface desenhada na visão que o Holarch escreve no texto. SysML é uma marca registrada da Object Management Group, Inc.
Arquivos de projeto
- Projeto concluído (.holarch.json; Gerenciar projetos → Arquivos de projeto ▾ → Importar projeto (.json)…)
O vídeo é reproduzido a partir de holarch.app; veja a Política de Privacidade.
Prática
Faça isto você mesmo no Holarch, no projeto de demonstração Hybrid Car (SysML v2).
- Abra seu projeto de demonstração Hybrid Car (crie-o se necessário: Gerenciar projetos → Arquivos de projeto ▾ → Novo projeto de demonstração → Hybrid Car (SysML v2)), abra Modelo → Editor e o pacote
Vehicles. - Abaixo de
interface def HighVoltageBus, adicioneinterface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }. - Em
part def Powertrain, substituaconnect controller.engineCtl to engine.ecu;porinterface engineControl : ControlLink connect controller.engineCtl to engine.ecu;e adicionepart auxBattery : Battery;depois depart battery : Battery;. - Abra Arquitetura → Visões de interconexão e a visão
powertrainConnections. Arraste da alça da portapowerOutdeauxBatteryaté a portapowerIndo motor e escolha Interface : HighVoltageBus. - Selecione a nova linha e digite
auxBuscomo Nome no inspetor. Depois abra Modelo → Editor e encontre a linha que o Holarch escreveu emPowertrain.
Você terminou quando Powertrain contiver interface engineControl : ControlLink … e a interface auxBus da visão, e o status sob o editor não indicar problemas.
Teste-se
- O motor tem
port fuelIn : ~FuelPort;. O que o til muda? - Qual é a diferença entre
bind output = transmission.output;einterface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;? - Por que a visão oferece Interface : HighVoltageBus quando você arrasta da
powerOutde uma bateria até apowerIndo motor?
Mostrar as respostas
O motor tem
port fuelIn : ~FuelPort;. O que o til muda?Ele conjuga a porta: a porta do motor tem as mesmas features de FuelPort com as direções invertidas, então o
out attribute flowRatede FuelPort chega ao motor como entrada.Qual é a diferença entre
bind output = transmission.output;einterface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?Um binding diz que as duas features são a mesma: a porta de fronteira do powertrain é a saída da transmissão. Um uso de interface conecta duas portas diferentes, e sua definição de interface diz quais portas suas pontas aceitam.
Por que a visão oferece Interface : HighVoltageBus quando você arrasta da
powerOutde uma bateria até apowerIndo motor?O Holarch oferece as definições de interface cujas pontas se encaixam nas duas portas. HighVoltageBus tem as pontas
source : PowerPorteload : ~PowerPort, que correspondem às duas portas.
Saiba mais
Transcrição
Mostrar a transcrição (narração e o que aparece na tela)
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.