Kurs bölümleri
Eğitim · Kurs 9. SysML v2 temelleri · Bölüm 9.1 / 8
9.1 Tanımlar ve öznitelikler 4:33
SysML v2 metninde değer türlerini ve bileşenleri, değerleri birimleriyle yazın.
Holarch 2.22 sürümünü gösterir.
Neler öğreneceksiniz
- Düzenleyici'de bir numaralandırma, bir değer türü ve soyut bir parça tanımı yazın
- Bir tanımı `:>` ile özelleştirin ve devralınan özniteliklere `redefines` ile birimli değerler verin
- Denetleyicinin altını çizdiği bir birim hatasını bulup düzeltin
- Ekle ▾ ve tamamlama ile bir tanım yazın ve bir türü Standart kitaplık'ta arayın
- Bir öğeyi F2 ile tek bir geri alma adımında her yerde yeniden adlandırın
Küçük bir Hybrid Car projesi üzerinde SysML v2 öğreticisi Definitions and Attributes'u izleyerek Holarch'ın Düzenleyici'sinde SysML v2 tanımları ve öznitelikleri yazın: bir numaralandırma, ScalarValue'yu özelleştiren bir değer türü, soyut bir bileşen ve birimli değerleriyle özelleştirmeleri, denetleyicinin bulduğu bir birim hatası, tamamlama ve Standart kitaplık, Ekle ve F2 ile yeniden adlandırma. 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.
- Hybrid Car demosunu oluşturun: Projeleri yönet → Proje dosyaları ▾ → Yeni demo proje → Hybrid Car (SysML v2). Model → Düzenleyici'yi ve
Vehiclespaketini açın. enum def FuelKind'ın altınaenum def CoolingMode { enum passive; enum active; }ekleyin.part def Body'nin altında Ekle ▾ → Parça tanımı'nı seçin vepart def Radiator :> Component'iattribute redefines mass = 8 [kg];,attribute coolantVolume : VolumeValue;(Voluyazın ve tamamlama listesindenVolumeValue'yu Enter ile kabul edin) veattribute mode : CoolingMode;ile tamamlayın.- Kütleyi
8 [W]olarak değiştirin, iletiyi okumak için alt çizginin üzerine gelin, ardından yeniden8 [kg]yapın. part def Powertrainiçinepart radiator : Radiator;ekleyin. Ardından imlecicoolantVolumeüzerine getirin, F2'ye basın ve adınıcoolantCapacityolarak değiştirin.- Denetimli bir adım adım anlatım için SysML v2 öğreticisi Definitions and Attributes'u çalıştırın (Yardım → Öğreticiler).
Düzenleyicinin altındaki durum hiçbir sorun bildirmediğinde ve Gezgin Vehicles altında coolantCapacity ve mode ile Radiator'ı gösterdiğinde işiniz bitmiştir.
Kendinizi sınayın
part def Battery :> Component { attribute redefines mass = 45 [kg]; }içinde:>veredefinesher biri ne yapar?- Component neden
abstract part defolarak bildirilmiştir? attribute redefines power = 60 [kg];neden hata verir?doc /* … */ile bir//satırı arasındaki fark nedir?
Yanıtları göster
part def Battery :> Component { attribute redefines mass = 45 [kg]; }içinde:>veredefinesher biri ne yapar?:>, Battery'yi Component'in bir özelleştirmesi yapar, böylece mass, partNumber ve power'ı devralır.redefines, Battery'de devralınanmass'ı burada 45 kg'a bağlanmış kendi özelliğiyle değiştirir.Component neden
abstract part defolarak bildirilmiştir?Hiçbir şey kendi başına bir bileşen değildir, yalnızca bileşen türleri vardır. Soyut bir tanım her bileşenin paylaştığını toplar ve yalnızca Battery veya Engine gibi özelleştirmeleri gerçek parçaları tanımlar.
attribute redefines power = 60 [kg];neden hata verir?power'ın türüPowerValue'dur ve kilogram bir kütle birimidir. Denetleyici birimleri değerlendirir, bu yüzden birim[W]gibi bir güç birimi olana kadar değerin altını çizer.doc /* … */ile bir//satırı arasındaki fark nedir?docyorumu öğeye ait olan ve modelin parçası olan bir belgelemedir.//notu ise yalnızca metinde kalır ve modelin parçası değildir.
Daha fazla bilgi
- Öğretici: Definitions and Attributes (SysML v2 öğreticileri)
- Belgeler: SysML v2 metinsel gösterimi, Türleme, özelleştirme ve yeniden tanımlama
- Belgeler: SysML v2 metinsel gösterimi, Değerler ve birimler
- Belgeler: SysML v2 metin düzenleyicisi, Bir yapı ekleme
- Belgeler: SysML v2 metin düzenleyicisi, Bir tanıma gitme ve yeniden adlandırma
- Yardım: Standart kitaplık
Döküm
Dökümü göster (anlatım ve ekranda görünenler)
Introduction
Welcome to SysML v2 Fundamentals. This track teaches the SysML v2 textual notation and views in Holarch, one task per chapter, on the starter projects of Holarch's SysML v2 tutorials, so you can follow along step by step.
In this chapter you write definitions and attributes: an enumeration, a value type, an abstract component and the components that specialize it, with values in units.
Start the tutorial
In Manage Projects, open Project Files and choose Start a Tutorial. Under the tutorials for SysML v2 projects, click Start on Definitions and Attributes. Holarch creates a small Hybrid Car project and opens the step panel, which checks each step as you go.
On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Definitions and Attributes → Start; the step panel opens.
Enumerations and value types
Open Model, then Editor. The package Vehicles holds one part definition, Car, with two attributes. Every declaration is a keyword and a name, then a body in braces, or a semicolon when there is no body.
On screen: Model → Editor: Vehicles; outline part def Car.
An enumeration is a value type with a fixed set of values. Above the car, write the drive mode: economy, normal or sport.
On screen: Caret after the imports; type enum def DriveMode.
Next, a value type of your own. Tire pressure specializes Scalar Value from the standard library. The short symbol after the name means specializes.
On screen: Below DriveMode; type attribute def TirePressure :> ScalarValue;
Specialization and units
Now an abstract component. There is no component as such, only kinds of components, and every one has a mass, a part number and a power. The doc comment is part of the model. Two slashes start a note that stays in the text only.
On screen: Below TirePressure; type abstract part def Component.
The battery is a component, so it has a mass, a part number and a power of its own. Write it with a mistake on purpose: a power in kilograms.
On screen: Below Component; type part def Battery :> Component with power = 60 [kg].
The checker underlines the value, and the status under the editor counts the error. Point at the underline to read the message.
On screen: Problems count; the information card on 60 [kg].
Change kilograms to watts, and the error clears. Redefines gives each inherited attribute the battery's own value, with its unit in square brackets.
On screen: kg → W; No problems, Applied.
Completion and the Standard Library
Completion knows the model and the library. Inside the battery, type attribute capacity, a colon, and the start of Energy Value. Press Enter to take it from the list, and end the line with a semicolon.
On screen: Inside Battery: attribute capacity : Ener → completion → Enter → ;
Point at Energy Value. The card shows that it comes from the I S Q package of the standard library.
On screen: The information card on EnergyValue.
The Standard Library page lists every package and definition of that library. Open Settings, then Standard Library, and search for Energy Value.
On screen: Settings → Standard Library; Find EnergyValue.
Insert
Back in the Editor, Insert writes a construct for you. Place the cursor below the battery, open Insert, and choose Part Definition. Type Engine, and press Tab to move into its body.
On screen: Model → Editor; caret below Battery; Insert ▾ (open on camera) → Part Definition; Engine; Tab.
The engine is a component too. Give it its mass and a number of cylinders, and make it specialize Component.
On screen: Body: mass 110 kg, cylinders : Integer; then :> Component after the name.
Usages and rename
Now use the definitions. Inside the car, add a drive mode, a battery and an engine. Each usage is typed by a definition after the colon, the drive mode by the enumeration you wrote first.
On screen: In Car after curbMass: attribute mode : DriveMode; part battery : Battery; part engine : Engine;
To rename a name everywhere it is used, place the cursor on cylinders and press F2. Enter cylinder count and confirm. Every reference to it changes, in one undo step.
On screen: Caret in cylinders; F2; New name cylinderCount; OK.
Every step is ticked off. Click Mark as Done to finish the tutorial.
On screen: Step panel → Mark as Done.
Recap
Let's recap. You started a SysML v2 tutorial, wrote an enumeration and a value type, an abstract component with specializations and values in units, let the checker find a wrong unit, and used completion, the Standard Library, Insert and rename.
Next, ports and interfaces connect these components.