과정의 장
교육 · 트랙 9. SysML v2 기초 · 9.1장 (전체 8장)
9.1 정의와 속성 4:33
값 타입과 구성 요소를 단위가 있는 값과 함께 SysML v2 텍스트로 작성합니다.
Holarch 2.22 화면입니다.
학습 내용
- 편집기에서 열거형, 값 타입, 추상 파트 정의 작성하기
- `:>`로 정의를 특수화하고 `redefines`로 상속된 속성에 단위가 있는 값 지정하기
- 검사기가 밑줄로 표시한 단위 오류를 찾아 고치기
- 삽입 ▾과 자동 완성으로 정의를 작성하고 표준 라이브러리에서 타입 찾아보기
- F2로 요소 이름을 모든 곳에서 한 번의 실행 취소 단계로 바꾸기
Hybrid Car라는 작은 프로젝트에서 SysML v2 튜토리얼 Definitions and Attributes를 따라 Holarch 편집기에서 SysML v2 정의와 속성을 작성합니다. 열거형, ScalarValue를 특수화하는 값 타입, 추상 구성 요소와 단위가 있는 값을 가진 특수화, 검사기가 찾은 단위 오류, 자동 완성과 표준 라이브러리, 삽입, F2로 이름 바꾸기를 다룹니다. SysML은 Object Management Group, Inc.의 등록 상표입니다.
실습
Hybrid Car 데모 프로젝트(SysML v2)에서 Holarch로 직접 해 보십시오.
- Hybrid Car 데모를 만듭니다. 프로젝트 관리 → 프로젝트 파일 ▾ → 새 데모 프로젝트 → Hybrid Car (SysML v2). 모델 → 편집기와 패키지
Vehicles를 엽니다. enum def FuelKind아래에enum def CoolingMode { enum passive; enum active; }를 추가합니다.part def Body아래에서 삽입 ▾ → 파트 정의를 선택하고part def Radiator :> Component를attribute redefines mass = 8 [kg];,attribute coolantVolume : VolumeValue;(Volu를 입력하고 자동 완성 목록에서 Enter로VolumeValue선택),attribute mode : CoolingMode;로 완성합니다.- 질량을
8 [W]로 바꾸고 밑줄을 가리켜 메시지를 읽은 다음, 다시8 [kg]로 바꿉니다. part def Powertrain에part radiator : Radiator;를 추가합니다. 그런 다음 커서를coolantVolume에 두고 F2를 눌러 이름을coolantCapacity로 바꿉니다.- 검사가 포함된 단계별 실습은 SysML v2 튜토리얼 Definitions and Attributes(도움말 → 튜토리얼)를 실행하십시오.
편집기 아래의 상태에 문제가 없다고 표시되고, 브라우저에서 Vehicles 아래에 coolantCapacity와 mode가 있는 Radiator가 표시되면 완료입니다.
스스로 확인
part def Battery :> Component { attribute redefines mass = 45 [kg]; }에서:>와redefines는 각각 무엇을 합니까?- Component가
abstract part def로 선언된 이유는 무엇입니까? attribute redefines power = 60 [kg];가 오류를 내는 이유는 무엇입니까?doc /* … */와//줄의 차이는 무엇입니까?
답 보기
part def Battery :> Component { attribute redefines mass = 45 [kg]; }에서:>와redefines는 각각 무엇을 합니까?:>는 Battery를 Component의 특수화로 만들어 mass, partNumber, power를 상속하게 합니다.redefines는 Battery에서 상속된mass를 자체 피처로 대체하며, 여기서는 45 kg에 바인딩됩니다.Component가
abstract part def로 선언된 이유는 무엇입니까?구성 요소 그 자체인 것은 없고, 구성 요소의 종류만 있습니다. 추상 정의는 모든 구성 요소가 공유하는 것을 모으며, Battery나 Engine 같은 특수화만이 실제 부품을 기술합니다.
attribute redefines power = 60 [kg];가 오류를 내는 이유는 무엇입니까?power의 타입은PowerValue이고, 킬로그램은 질량 단위입니다. 검사기는 단위를 평가하므로, 단위가[W]같은 전력 단위가 될 때까지 값에 밑줄을 칩니다.doc /* … */와//줄의 차이는 무엇입니까?doc주석은 요소에 속하는 문서이며 모델의 일부입니다.//메모는 텍스트에만 남고 모델의 일부가 아닙니다.
더 읽어 보기
대본
대본 보기 (내레이션과 화면 내용)
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.