Holarch
פרקי הקורס

הדרכה · מסלול 9. יסודות SysML v2 · פרק 9.2 מתוך 8

9.2 פתחות וממשקים 3:44

מגדירים פתחות וממשקים, מחברים חלקים בטקסט ומשרטטים ממשק בתצוגה.

מציג את Holarch 2.22.

מה תלמדו

  • להגדיר פתחה עם מאפיינים מכוונים ולהפוך אותה לצמודה עם `~`
  • להגדיר ממשק שהקצוות שלו מוגדרים לפי פתחות
  • לחבר חלקים עם שימוש בממשק ולקשור פתחת גבול לפתחה של חלק פנימי
  • ליצור Interconnection View ולשרטט ממשק בין שתי פתחות

מגדירים פתחות וממשקים של SysML v2 ב-Holarch, לפי המדריך Ports and Interfaces של SysML v2 על פרויקט Hybrid Car קטן: הגדרת פתחה עם כיוונים, פתחה צמודה, הגדרת ממשק עם שני קצוות, מערכת הנעה שהחלקים שלה מחוברים בממשקים ובקשירה, Interconnection View שלה, וממשק שמשורטט בתצוגה ו-Holarch כותב לטקסט. SysML הוא סימן מסחרי רשום של Object Management Group, Inc.

קובצי פרויקט

  • פרויקט גמור (.holarch.json; ניהול פרויקטים ← קובצי פרויקט ▾ ← ייבוא פרויקט (.json)…)

הסרטון מוצג מ-holarch.app; ראו את מדיניות הפרטיות.

תרגול

עושים את זה בעצמכם ב-Holarch, על פרויקט ההדגמה Hybrid Car ‏(SysML v2).

  1. פותחים את פרויקט ההדגמה Hybrid Car (יוצרים אותו אם צריך: ניהול פרויקטים ← קובצי פרויקט ▾ ← פרויקט הדגמה חדש ← Hybrid Car (SysML v2)), פותחים את מודל ← עורך ואת החבילה Vehicles.
  2. מתחת ל-interface def HighVoltageBus מוסיפים interface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }.
  3. ב-part def Powertrain מחליפים את connect controller.engineCtl to engine.ecu; ב-interface engineControl : ControlLink connect controller.engineCtl to engine.ecu;, ומוסיפים part auxBattery : Battery; אחרי part battery : Battery;.
  4. פותחים את ארכיטקטורה ← Interconnection Views ואת התצוגה powertrainConnections. גוררים מהידית של הפתחה powerOut של auxBattery אל הפתחה powerIn של המנוע ובוחרים Interface : HighVoltageBus.
  5. בוחרים את הקו החדש ומזינים auxBus כשם שלו בחלונית המאפיינים. אחר כך פותחים את מודל ← עורך ומוצאים את השורה ש-Holarch כתב ב-Powertrain.

סיימתם כש-Powertrain מכיל את interface engineControl : ControlLink … ואת הממשק auxBus מהתצוגה, והסטטוס מתחת לעורך מדווח שאין בעיות.

בדיקה עצמית

  1. למנוע יש port fuelIn : ~FuelPort;. מה הטילדה משנה?
  2. מה ההבדל בין bind output = transmission.output; לבין interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?
  3. למה התצוגה מציעה Interface : HighVoltageBus כשגוררים מ-powerOut של סוללה אל powerIn של המנוע?
הצגת התשובות
  1. למנוע יש port fuelIn : ~FuelPort;. מה הטילדה משנה?

    היא הופכת את הפתחה לצמודה (conjugated): לפתחה של המנוע יש אותן תכונות כמו ל-FuelPort עם כיוונים הפוכים, כך ש-out attribute flowRate של FuelPort מגיע למנוע כקלט.

  2. מה ההבדל בין bind output = transmission.output; לבין interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?

    קשירה (binding) אומרת ששתי התכונות זהות: פתחת הגבול של מערכת ההנעה היא הפלט של תיבת ההילוכים. שימוש בממשק מחבר שתי פתחות שונות, והגדרת הממשק שלו קובעת אילו פתחות הקצוות שלו מקבלים.

  3. למה התצוגה מציעה Interface : HighVoltageBus כשגוררים מ-powerOut של סוללה אל powerIn של המנוע?

    Holarch מציע את הגדרות הממשק שהקצוות שלהן מתאימים לשתי הפתחות. ל-HighVoltageBus יש את הקצוות source : PowerPort ו-load : ~PowerPort, שתואמים לשתי הפתחות.

קריאה נוספת

תמליל

הצגת התמליל (הקריינות ומה שמוצג על המסך)

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.