부록 A. 구문 찾아보기
이 부록은 SysML v2 구문을 빠르게 찾아보기 위한 색인입니다. 구문의 종류별로 표준적인 선언 형식, 쓰임, 의미를 자세히 설명하는 장을 정리했습니다. 무엇을 작성할지는 알지만 키워드 순서가 기억나지 않을 때 찾아보세요.
코드 블록의 구문 틀에는 필요한 최소 요소를 표시했습니다. <Name>처럼 꺾쇠괄호 안에 넣은 자리는 작성자가 채우고, [...] 안의 항목은 생략할 수 있습니다. |로 나눈 항목은 대안입니다.
연산자와 관계 기호
다음 표는 SysML v2 선언에서 이름 뒤에 붙여 관계를 나타내는 기호들을 정리한 것입니다.
| 기호 | 키워드 표기 | 의미 |
|---|---|---|
: | defined by | Feature의 type을 지정합니다. 즉 그 feature의 값이 어느 classifier에 속해야 하는지 나타냅니다. |
:> | specializes / subsets | Type을 특수화하거나, 한 feature의 값이 다른 feature 값의 부분집합이라고 지정합니다. |
:>> | redefines | 상속한 feature를 재정의합니다. |
::> | references | Reference subsetting: 다른 feature를 소유하지 않고 참조합니다. |
=> | crosses | Cross-subsetting: 이항 connection definition의 두 끝이 서로 대응하도록 제한합니다. |
~ | (없음) | Conjugate port를 type으로 지정합니다. port p : ~P는 P의 in/out 방향을 뒤집은 type을 사용합니다. |
= | (feature value) | Feature의 값을 식으로 지정합니다. default 없이 쓰면 고정값입니다. |
:= | (초기값) | 실행 중 바뀔 수 있는 초기값을 지정합니다. |
default = | (기본값) | 하위 type에서 달리 지정할 수 있는 기본값을 정합니다. |
default := | (초기값의 기본값) | 초기값을 따로 지정하지 않았을 때 사용할 값을 정합니다. |
표의 긴 형식은 SysML 표기입니다. KerML에서는 :를 typed by로 쓰고 type 선언에 일반 conjugates 키워드를 쓸 수 있지만, 둘 다 SysML 키워드는 아닙니다. 부록 G에는 기호와 키워드의 대응 및 각 표기가 생성하는 metamodel 클래스가 정리되어 있습니다.
예제
part def MachineBase {
attribute waterTemp : Real;
part components : Grinder[*];
part sensors : CupSensor[1..*];
}
part def EspressoUnit :> MachineBase {
part grinder : Grinder :> components;
attribute espressoBrewTemp :>> waterTemp;
ref primarySensor ::> sensors;
port waterReturn : ~WaterPort;
attribute maxTemp : Real = 96.0;
attribute currentTemp : Real := 20.0;
attribute targetTemp : Real default = 93.0;
}
Multiplicity
Multiplicity는 feature가 허용하는 인스턴스 수를 제한합니다. Feature 이름 또는 type 뒤에 대괄호로 씁니다.
| 구문 | 의미 |
|---|---|
[1] | 정확히 하나(많은 feature에서 적용되는 기본값) |
[0..1] | 0개 또는 1개(선택 사항) |
[1..*] | 하나 이상 |
[*] | 0개 이상(상한 없음) |
[2] | 정확히 두 개 |
[1..4] | 1개 이상 4개 이하 |
// Two sensors, exactly
part sensors : CupSensor [2];
// Optional steam wand
part steamWand : SteamWand [0..1];
// Any number of logged events
item events : LogEvent [*];
Feature 한정자
다음 키워드는 feature 선언에 성질을 추가합니다. 대부분 feature 키워드 앞에 붙지만 ordered와 nonunique는 예외로 multiplicity 뒤에 옵니다.
| 한정자 | 의미 |
|---|---|
abstract | 직접 인스턴스를 갖지 않는 추상 feature 또는 definition입니다. 구체적인 하위 type이 필요합니다. |
in | 입력 방향(action 매개변수) |
out | 출력 방향(action 매개변수) |
inout | 양방향(action 매개변수) |
ref | 대상을 소유하지 않는 reference usage |
derived | 다른 feature로부터 계산하는 값입니다. 직접 지정하지 않습니다. |
constant | 해당 feature를 갖는 인스턴스가 존재하는 동안 값이 변하지 않습니다(KerML 파일에서는 const). |
variation | Definition이나 usage를 variation point로 표시합니다. 그 안의 variant 멤버가 선택할 수 있는 대안입니다. |
ordered | Feature 값의 순서가 의미를 갖습니다(multiplicity 뒤에 표기). |
nonunique | 값의 중복을 허용합니다(multiplicity 뒤에 표기). |
var | 시간이 지나면서 값이 바뀔 수 있습니다(KerML 파일 전용 표기). |
end | Connector의 끝을 나타내는 feature를 표시합니다. |
// Abstract part: every concrete machine must specialize this
abstract part def Machine;
// Input parameter
action def SetPressure { in attribute targetPressure : Real; }
// Derived attribute computed from sub-parts
derived attribute totalMass : Real;
// Ordered list of brew steps (`ordered` follows the multiplicity)
ref action brewSteps : BrewStep [*] ordered;
가시성
가시성은 멤버를 소유한 namespace 밖에서도 그 멤버에 접근할 수 있는지를 정합니다.
| 키워드 | 의미 |
|---|---|
public | 이 멤버를 소유한 namespace 밖에서도 접근할 수 있습니다. Package 멤버의 기본 가시성입니다. |
private | 그 멤버가 속한 namespace 안에서만 접근할 수 있습니다. |
protected | Type 안에서는 하위 type이 이 멤버를 상속하지만 외부에 공개하지는 않습니다. Package처럼 type이 아닌 namespace에서는 가시성이 private일 때와 같습니다. |
package CoffeeMachineDomain {
public part def CoffeeMachine; // visible outside
private part def InternalBoard; // hidden from importers
}
문서화와 주석
// Line note -- discarded by the parser
//* Block note, also discarded.
It runs to the closing marker, so always close it. */
/* A bare block comment IS model data: it becomes a Comment element
whose body is this text */
doc /* Documentation attached to the owning element as model data */
comment about CoffeeMachine
/* Standalone annotating comment -- can target any element */
//와 //*로 시작하는 메모는 공백과 같은 숨김 토큰입니다(hidden(WS, ML_NOTE, SL_NOTE)). 구문 분석에 쓰이지 않으므로 모델 요소로 남지 않습니다. 반면 /* ... */를 단독으로 쓰면 Comment 요소가 되고, doc 뒤에 쓰면 그 선언이 속한 요소에 대한 설명이 됩니다.
닫는 기호를 잊지 마세요. ML_NOTE의 규칙이 '//*' -> '*/'이므로 //* 메모는 같은 줄이 아니라도 파일 뒤쪽에서 처음 만나는 */까지 이어집니다. 닫는 기호를 빼먹으면 다음 블록 주석까지의 내용이 메모에 포함될 수 있습니다. doc와 //*의 차이 및 쓰임은 부록 H를 참고하세요.
1. Package와 namespace
Package는 모델 요소를 이름 있는 범위로 묶습니다.
// Plain package
package <Name> {
<members>
}
// Library package (marks reusable standard content)
library package <Name> {
<members>
}
// Standard library package (normative standard libraries only)
standard library package <Name> {
<members>
}
문법: SysML.xtext 183~208행
관련 내용: 4장. Package와 import
2. Import와 별칭
Import는 다른 namespace의 이름을 현재 범위에서 사용할 수 있게 합니다.
// Import a single named member
private import <Package>::<Name>;
// Import all public members of a package
private import <Package>::*;
// Import all members recursively (including nested packages)
private import <Package>::*::**;
// Private import (imported names stay private to this namespace)
private import <Package>::*;
// Alias: give a new local name to an existing element
alias <LocalName> for <Package>::<OriginalName>;
문법: SysML.xtext 234~298행
관련 내용: 4장. Package와 import
3. Definition과 usage
주요 요소 종류에는 재사용할 type을 선언하는 definition과 그 type을 특정 문맥에서 사용하는 usage의 짝이 있습니다. 여러 요소 계열에서 같은 형식을 만날 수 있습니다.
// General pattern
<keyword> def <Name> [specialization] {
<members>
}
<keyword> <name> [: <Type>] [specialization] [= <value>];
<keyword> <name> [: <Type>] [specialization] {
<members>
}
Definition은 재사용할 classifier를 선언합니다. Usage는 특정 문맥에서 그 classifier의 인스턴스가 맡을 역할을 선언합니다. 예를 들어 커피 머신 안에서 추출기가 맡는 역할은 usage이고, 추출기라는 종류는 definition입니다.
문법: SysML.xtext 303~330행, KerML.xtext 460~558행
관련 내용: 3장. Definition과 usage
4. Typing과 specialization
다음 네 관계는 type 사이의 관계를 나타냅니다.
part def Assembly {
part components : Grinder[*];
part grinder : Grinder :> components;
}
part def EspressoAssembly :> Assembly {
part espressoGrinder :>> grinder;
port waterReturn : ~WaterPort;
}
문법: KerML.xtext 332~626행
관련 내용: 12장. Specialization과 redefinition
5. 구조를 나타내는 구문
attribute
스칼라 값, 문자열, 물리량 등의 데이터 값을 나타냅니다.
// Definition
attribute def <Name> [: <SuperType>] { <members> }
// Usage
attribute <name> : <Type> [multiplicity] [= <value>];
attribute def Temperature :> Real;
attribute waterTemp : Temperature = 93.0;
문법: SysML.xtext 739~749행
Enumeration
값으로 쓸 수 있는 리터럴을 미리 정하고 각각에 이름을 붙인 type입니다.
enum def <Name> {
<literal>;
<literal>;
}
enum def DrinkSize {
small;
medium;
large;
}
문법: SysML.xtext 764~787행
item
물질, 에너지, 신호, 데이터 등 시스템을 통해 전달될 수 있는 대상입니다.
// Definition
item def <Name> [: <SuperType>] { <members> }
// Usage
item <name> : <Type> [multiplicity];
item def Water;
item def BrewedCoffee;
item waterSupply : Water [1];
문법: SysML.xtext 910~916행
관련 내용: 5장. 구조
part
시스템을 구성하는 물리적 또는 논리적 요소입니다.
// Definition
part def <Name> [:> <SuperType>] { <members> }
// Usage
part <name> : <Type> [multiplicity];
part def CoffeeMachine {
part grinder : Grinder [1];
part brewer : Brewer [1];
}
part myCoffeeMachine : CoffeeMachine;
문법: SysML.xtext 932~938행
관련 내용: 5장. 구조
Port
Part가 주변과 상호작용하는 지점입니다.
// Definition
port def <Name> { <port features> }
// Usage
port <name> : <PortType>;
port <name> : ~<PortType>; // conjugated: reverses in/out
port def WaterPort {
out item waterOut : Water;
}
part def WaterTank {
port waterOut : WaterPort;
}
part def Brewer {
port waterInlet : ~WaterPort; // conjugated: receives water
}
문법: SysML.xtext 952~985행
관련 내용: 5장. 구조
Connection
두 개 이상의 part 또는 port 끝점을 연결합니다.
// Definition
connection def <Name> [:> <SuperType>] { <members> }
// Usage: named connection
connection <name> connect <source> to <target>;
// Usage: anonymous inline connection
connect <source> to <target>;
// Binding connector (equates two features)
bind <feature1> = <feature2>;
connection def WaterLine :> BinaryConnection;
connect waterTank.waterOut to brewer.waterInlet;
bind brewer.targetTemp = controlPanel.setTemp;
문법: SysML.xtext 1015~1080행
관련 내용: 6장. Connection과 interface
Interface
Port 사이에서 지켜야 할 규약을 type으로 지정한 connection입니다.
// Definition
interface def <Name> {
end <portName> : <PortType>;
end <portName> : <PortType>;
}
// Usage
interface <name> : <InterfaceType> connect <port1> to <port2>;
interface <name> connect <port1> to <port2>; // untyped
interface def WaterInterface {
end supply : WaterPort;
end demand : ~WaterPort;
}
interface waterLine : WaterInterface connect
waterTank.waterOut to brewer.waterInlet;
문법: SysML.xtext 1102~1181행
관련 내용: 6장. Connection과 interface
Allocation
한 요소를 다른 요소에 대응시키는 방향성 있는 관계입니다(예: 논리 설계에서 물리 설계로, 기능에서 구성요소로).
// Definition
allocation def <Name> [:> <SuperType>];
// Usage
allocate <source> to <target>;
allocation <name> allocate <source> to <target>;
allocate brewCycle to brewer;
allocation heatingAlloc allocate heatAction to brewer.heatingElement;
문법: SysML.xtext 1195~1216행
관련 내용: 6장. Connection과 interface
6. 동작을 나타내는 구문
Action
입력, 출력, 내부 제어 흐름을 갖는 동작 단위입니다.
// Definition
action def <Name> {
in <param> : <Type>;
out <result> : <Type>;
<action body>
}
// Usage
action <name> : <ActionType>;
// Perform (reference an action that already exists elsewhere)
perform action <name> : <ActionType>;
// Succession (ordering between two steps)
first <actionName>
then <nextAction>;
action def BrewCycle {
in beanType : BeanType;
out coffee : BrewedCoffee;
action grind : GrindBeans;
action heat : HeatWater;
action extract : Extract;
first grind then heat;
first heat then extract;
}
action brewCycle : BrewCycle;
문법: SysML.xtext 1352~1518행
관련 내용: 7장. action
Action 노드와 제어 흐름
Action 본문에서 구조화된 제어 흐름을 나타내는 내장 노드의 종류입니다.
// Conditional
if <condition> {
<true branch>
} else {
<false branch>
}
// While loop
while <condition> {
<body>
}
// Loop-until variant (`loop` takes no condition of its own)
loop {
<body>
} until <condition>;
// For loop
for <var> : <Type> in <collection> {
<body>
}
// Send a message (`to` names the receiver, `via` the sending port; both optional)
send <payloadExpr> to <receiver>;
send <payloadExpr> via <senderPort>;
send <payloadExpr> via <senderPort> to <receiver>;
// Accept a message or trigger
accept <payload> : <Type>;
accept <payload> : <Type> via <port>;
accept at <time>;
accept after <duration>;
accept when <change-condition>;
// Assignment
assign <target> := <expr>;
// Control nodes (name optional)
fork <name>; // split into concurrent branches
join <name>; // wait for all branches
merge <name>; // accept whichever branch arrived
// A decision node is followed by its branches, one succession per line
decide <name>;
if <guardExpr> then <targetStep>;
else <targetStep>;
// Abort the enclosing action
terminate;
문법: SysML.xtext 1437~1734행
관련 내용: 7장. action
State
State machine 안에서 이름을 붙인 상태입니다. 이 state에 들어갈 때, 머무르는 동안, 나갈 때 수행할 하위 action을 지정할 수 있습니다.
// Definition
state def <Name> {
entry; // or: entry <action>;
do; // or: do <action>;
exit; // or: exit <action>;
transition <Name> first <state>
accept <trigger>
if <guard>
do <effect>
then <target>;
}
// Usage
state <name> : <StateType>;
// Exhibit (reference a state that exists elsewhere)
exhibit state <name> : <StateType>;
exhibit state <name> { <states and transitions> }
exhibit <stateUsageRef>;
// Parallel states
state <name> parallel {
<region1>;
<region2>;
}
state def MachineStates {
attribute cupDetected : Boolean;
state idle;
state brewing;
state cleaning;
transition T1 first idle
accept StartBrewEvent
if cupDetected
then brewing;
transition T2 first brewing
accept BrewCompleteEvent
then idle;
}
state machineStates : MachineStates;
문법: SysML.xtext 1735~1923행
관련 내용: 8장. state
Transition
두 state 사이의 방향성 있는 관계입니다. 트리거, 가드, 효과를 선택적으로 지정합니다.
transition [<Name>] first <source>
[accept <trigger> [via <port>]]
[if <guard-expression>]
[do <effect-action>]
then <target>;
transition T1 first idle
accept StartBrewEvent
if cupSensor.cupDetected
then brewing;
문법: SysML.xtext 1849~1877행
관련 내용: 8장. state
Succession
두 occurrence의 시간 순서(‘먼저 일어난다’)를 정하는 관계입니다.
// Inline within an action or state body
first <occurrence1>
then <occurrence2>;
// Explicit succession
succession <name> first <occurrence1> then <occurrence2>;
// Guarded target -- follows a decision node, one line per branch
if <guardExpr> then <targetStep>;
// Default target -- taken when no guard matched (note: no `then`)
else <targetStep>;
문법: SysML.xtext 1028~1033행
관련 내용: 7장. action
Flow
한쪽 끝의 feature에서 다른 쪽 끝의 feature로 item이 전달된다는 뜻입니다.
// Definition
flow def <Name> [:> <SuperType>];
// Usage: anonymous inline flow
flow of <ItemType> from <source> to <target>;
// Named flow usage
flow <name> of <ItemType> from <source> to <target>;
// Succession flow (ordered flow across a time boundary)
succession flow of <ItemType> from <source> to <target>;
flow def WaterFlow { end source : WaterSupplyPort; end sink : WaterPort; }
flow of Water from waterTank.waterOut.water to brewer.waterInlet.water;
문법: SysML.xtext 1230~1285행
관련 내용: 6장. Connection과 interface
Calculation
값을 반환하는 함수 형태의 동작입니다. Expression과 해석에 사용합니다.
// Definition
calc def <Name> {
in <param> : <Type>;
return <result> : <ReturnType>;
<result expression>
}
// Usage
calc <name> : <CalcType>;
calc def BrewTime {
in volume : Real;
in pressure : Real;
return t : Real = volume / pressure * 60.0;
}
문법: SysML.xtext 1937~1974행
관련 내용: 9장. Expression과 constraint
7. 분석을 나타내는 구문
constraint
모델이 유효하려면 참이어야 하는 불리언 predicate입니다.
// Definition
constraint def <Name> {
<boolean expression>
}
// Usage
constraint <name> : <ConstraintType>;
// Inline constraint
constraint { <boolean expression> }
// Assert a constraint holds
assert constraint <name>;
// Assert a constraint does not hold
assert not constraint <name>;
constraint def BrewTempInRange {
in brewer : Brewer;
brewer.waterTemp >= 90.0 and brewer.waterTemp <= 96.0
}
part def TestStation {
part sample : Brewer;
assert constraint inRange : BrewTempInRange { in :>> brewer = sample; }
}
문법: SysML.xtext 1988~2012행
관련 내용: 9장. Expression과 constraint
Concern
이해관계자의 관심을 requirement와 유사한 predicate로 나타냅니다.
// Definition
concern def <Name> { <requirement body> }
// Usage
concern <name> : <ConcernType>;
문법: SysML.xtext 2150~2160행
관련 내용: 10장. Requirement와 검증
8. 요구사항을 나타내는 구문
Requirement는 시스템이 무엇을 해야 하고 어떤 조건을 갖춰야 하는지를 규정합니다.
requirement
// Definition
requirement def <Name> {
subject <subjectName> : <SubjectType>;
assume constraint { <assumption expression> }
require constraint { <requirement expression> }
frame <concern>;
stakeholder <name>;
}
// Usage
requirement <name> : <RequirementType>;
requirement def BrewTimeRequirement {
subject machine : CoffeeMachine;
require constraint { machine.brewTime <= 60.0 }
}
requirement brewTime : BrewTimeRequirement;
문법: SysML.xtext 2026~2110행
관련 내용: 10장. Requirement와 검증
Satisfy
Subject가 requirement를 충족한다고 선언합니다.
// Reference an existing requirement usage
satisfy <requirementUsageRef> by <subject>;
// Declare the satisfied requirement here, typed by a requirement definition
satisfy requirement [<name>] : <RequirementDef> by <subject>;
assert satisfy <requirementUsageRef> by <subject>;
assert not satisfy <requirementUsageRef> by <subject>;
satisfy requirement : BrewTimeReq by myCoffeeMachine;
문법: SysML.xtext 2112~2120행
관련 내용: 10장. Requirement와 검증
9. Case
Case는 subject와 objective, 결과를 갖춘 구조화된 분석 단위입니다.
Analysis case
성능이나 안전성 등 시스템 해석을 나타냅니다.
analysis def <Name> {
subject <name> : <SubjectType>;
objective { <requirement body> }
<action body items>
return <result> : <ResultType>;
}
analysis <name> : <AnalysisType>;
문법: SysML.xtext 2227~2233행
관련 내용: 10장. Requirement와 검증
Verification case
Requirement를 어떻게 검증할 것인지 기술합니다.
verification def <Name> {
subject <name> : <SubjectType>;
objective { verify requirement <ReqName>; }
}
verification <name> : <VerificationType>;
문법: SysML.xtext 2249~2255행
관련 내용: 10장. Requirement와 검증
Use case
Actor가 시스템을 사용하는 방식을 기술합니다.
use case def <Name> {
subject <name> : <SubjectType>;
actor <actorName> : <ActorType>;
objective { <requirement body> }
}
use case <name> : <UseCaseType>;
// Include another use case inline
include use case <name>;
문법: SysML.xtext 2287~2301행
관련 내용: 10장. Requirement와 검증
10. View와 viewpoint
View는 모델에서 특정 독자에게 필요한 내용을 골라 보여 줍니다.
Viewpoint
View가 다뤄야 할 관심사와 이해관계자를 정의합니다.
viewpoint def <Name> {
stakeholder <name> : <StakeholderType>;
frame <concern>;
require constraint { <criteria> }
}
viewpoint <name> : <ViewpointType>;
문법: SysML.xtext 2399~2405행
관련 내용: 13장. Metadata와 view
View
선택한 모델 내용을 rendering을 통해 보여 줍니다.
view def <Name> :> <SupertypeView> {
filter <BooleanExpression>;
render rendering <name> : <RenderingDef>;
}
view <name> : <ViewType> {
expose <element>; // member expose
expose <Namespace>::*; // namespace expose
filter <BooleanExpression>;
render <renderingUsageRef>;
}
// Anonymous view usage — no def required
view <name> { expose <element>; }
view def StructuralView :> InterconnectionView {
filter @SysML::PartUsage;
render rendering asTree : Views::GraphicalRendering;
}
view structuralView : StructuralView {
expose CoffeeMachineDomain::*;
}
view scratch { expose CoffeeMachine; } // anonymous
View definition은 재사용할 규칙을 제공하고, view usage에서는 expose로 모델 요소를 선택합니다.
StandardViewDefinitions package에는 GeneralView, InterconnectionView, ActionFlowView, StateTransitionView, SequenceView, GeometryView, GridView, BrowserView의 여덟 표준 view definition이 있습니다. 표준 UseCaseView나 RequirementView는 없습니다. Requirement view는 GeneralView를 특수화하고 requirement metaclass를 선택하는 filter를 붙여 만듭니다.
filter @SysML::PartUsage;나 filter @Safety and Safety::isMandatory; 같은 불리언 expression을 사용합니다. 필터가 여러 개면 같은 선택 대상에 모두 적용됩니다.
문법: SysML.xtext 2315~2383행
관련 내용: 13장. Metadata와 view
Rendering
View의 내용을 어떤 방식으로 표시할지 정의합니다.
rendering def <Name> { <rendering body> }
rendering <name> : <RenderingType>;
문법: SysML.xtext 2417~2427행
11. Metadata
Metadata를 사용하면 어느 모델 요소에든 type을 지정한 데이터를 추가할 수 있습니다. 이렇게 기록한 값은 나중에 도구로 조회할 수 있습니다.
// Definition (a metaclass)
metadata def <Name> {
attribute <field> : <Type>;
}
// Usage: attach metadata to an element
@<MetadataType> { <field> = <value>; }
// Using the metadata keyword explicitly
metadata <name> : <MetadataType> about <element>;
// Prefix form: a user-defined keyword before the declaration it annotates
#<MetadataType>
<annotated element>
metadata def ReviewStatus {
attribute reviewer : String;
attribute approved : Boolean;
}
part def CoffeeMachine {
// Without an `about` clause, a metadata usage annotates its
// containing element -- so this attaches to CoffeeMachine
@ReviewStatus { :>> reviewer = "Alice"; :>> approved = true; }
}
문법: SysML.xtext 115~177행
관련 내용: 13장. Metadata와 view
12. Expression
Expression은 값을 계산합니다. Constraint, feature 값, calculation, 가드 조건 등에서 사용합니다.
산술 연산자와 논리 연산자
| 범주 | 연산자 |
|---|---|
| 산술 | + - * / % ** ^ |
| 비교 | < > <= >= |
| 동등성 | == != === !== |
| 논리 연산(양쪽 피연산자를 모두 평가) | & | xor |
| 논리 연산(단락 평가) | and or implies |
| 값이 없을 때의 대체값 | ?? |
| 단항 | + - ~ not |
| 삼항 조건식 | if <cond> ? <then> else <else> |
| 범위 | <low>..<high> |
Type 검사와 변환
// Test whether a value is an instance of a type
<expr> hastype <Type>
<expr> istype <Type>
<expr> @ <Type>
// Cast to a type
<expr> as <Type>
// Metaclass test / cast
<expr> @@ <MetaType>
<expr> meta <MetaType>
// Extent: all instances of a type
all <Type>
컬렉션과 feature 탐색
// Dot notation: navigate to an owned feature
brewer.waterTemp
// Feature chaining: navigate through a chain
machine.brewer.waterTemp
// Sequence expression (parenthesized, comma-separated)
(a, b, c)
// Range (also usable in expressions)
1..10
// Indexing (1-based)
<sequence>#(n)
// Sequence operators (arrow form; the per-element rule is a body expression)
<sequence>->select {in <x>; <predicate over x>}
<sequence>->collect {in <x>; <expr over x>}
<sequence>->reject {in <x>; <predicate over x>}
<sequence>->forAll {in <x>; <predicate over x>}
<sequence>->exists {in <x>; <predicate over x>}
// Aggregators (argument-list form -- the sequence is the argument)
<sequence>->size()
<sequence>->isEmpty()
<sequence>->notEmpty()
<sequence>->sum()
<sequence>->product()
// min and max are two-argument functions, so a sequence is folded with ->reduce
<sequence>->reduce min
<sequence>->reduce max
본문 expression과 인라인 함수
// Body expression -- the inline function passed to ->select, ->collect, ->forAll, ...
{in <param>; <expression>}
{in <param> : <Type>; <expression>}
문법: KerMLExpressions.xtext (파일 전체, 579행)
관련 내용: 9장. Expression과 constraint
Occurrence 한정자
Part, item, action, state 같은 occurrence에는 시간에 관한 한정자를 붙일 수 있습니다.
| 키워드 | 의미 |
|---|---|
individual | 재사용 가능한 종류가 아니라 현실의 개체 하나만을 가리킵니다. |
snapshot | 한 순간의 상태를 나타내는 시간적 부분입니다. |
timeslice | 일정한 시간 구간에 걸친 부분입니다. |
individual part myEspressoMachine : EspressoMachine {
snapshot part machineAtStartup;
timeslice part machineInOperation;
}
문법: SysML.xtext 801~860행
Definition과 usage 대응표
SysML v2의 주요 구문은 다음과 같이 definition과 usage가 짝을 이룹니다.
| Definition 키워드 | Usage 키워드 | 모델링 대상 |
|---|---|---|
attribute def | attribute | 스칼라 데이터 값 |
enum def | enum | 열거형 |
item def | item | 전달되는 대상 |
part def | part | 물리적 또는 논리적 구성요소 |
port def | port | 상호작용 지점 |
connection def | connection | 끝점 사이의 연결 |
interface def | interface | Type을 지정한 port 간 연결 |
allocation def | allocation | 논리 요소와 물리 요소의 대응 |
flow def | flow | Item 전달 |
action def | action | 동작 단위 |
state def | state | state machine state |
calc def | calc | 값을 반환하는 계산 |
constraint def | constraint | 불리언 predicate |
requirement def | requirement | 시스템이 충족해야 하는 조건 |
concern def | concern | 이해관계자의 관심사 |
case def | case | 일반적인 구조화된 분석 |
analysis def | analysis | 시스템 해석 case |
verification def | verification | verification case |
use case def | use case | Actor와 시스템의 상호작용 |
viewpoint def | viewpoint | 이해관계자의 관심사를 다룰 관점 |
view def | view | 선택해 표시한 모델 내용 |
rendering def | rendering | 표시 형식 |
metadata def | metadata 또는 @ | 모델 annotation |
connect <a> to <b>는 connection usage 자체를 나타내는 키워드가 아니라 끝점을 지정하는 절입니다. 이름 없는 connection을 짧게 쓸 때만 이 절을 단독으로 씁니다. allocate(usage 키워드 allocation)와 bind(usage 키워드 binding)도 같은 형식입니다. 각 쌍에 해당하는 metamodel 클래스는 부록 G에 있습니다.
관련 장
- 1장. SysML v2를 텍스트로 쓰는 이유에서는 definition과 usage를 구분하고 텍스트로 모델링하는 이유를 설명합니다.
- 3장. Definition과 usage에서는 소유 관계와 membership의 의미를 설명합니다.
- 4장. Package와 import에서는 package와 import를 자세히 설명합니다.
- 5장. 구조에서는 part, item, attribute, port를 설명합니다.
- 6장. Connection과 interface에서는 connection, interface, allocation, flow를 설명합니다.
- 7장. action에서는 action, 제어 노드, succession을 설명합니다.
- 8장. state에서는 state machine과 transition을 설명합니다.
- 9장. Expression과 constraint에서는 calculation, constraint, expression을 설명합니다.
- 10장. Requirement와 검증에서는 requirement, concern, case와 충족 관계를 설명합니다.
- 12장. Specialization과 redefinition에서는 위 표에 나온 관계 연산자를 설명합니다.
- 13장. Metadata와 view에서는 metadata 체계와 view, viewpoint를 설명합니다.
원문 자료
OMG SysML 명세, KerML 명세, 파일럿 구현의 문법 소스를 참고하세요. 교재에 함께 제공하는 커피 머신 파일은 11장에서 소개합니다.
예제 소스: 이 장의 코드와 공통 모델 선언을 함께 사용합니다. 교재 프로젝트의 루트에서 sysml -strict -validate src/examples/lessons/vocabulary.sysml src/examples/lessons/appendix-a.sysml을 실행하세요.