-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcookbook.sysml
More file actions
191 lines (167 loc) · 3.8 KB
/
Copy pathcookbook.sysml
File metadata and controls
191 lines (167 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package Cookbook {
private import DocumentQueries::*;
private import KerML::Root::Element;
private import ScalarValues::*;
// ---- The model the recipes query ----
part def Subsystem {
attribute mass : Real;
}
part def OpticalSubsystem :> Subsystem;
part def MirrorAssembly :> OpticalSubsystem {
attribute :>> mass = 10.0;
}
metadata def Critical;
port def OpticalPort;
port def DataPort;
part telescope {
part primaryMirror : MirrorAssembly {
@Critical;
port opticalOut : OpticalPort;
}
part instrumentCluster : Subsystem {
attribute redefines mass = 4.5;
port opticalIn : OpticalPort;
port dataOut : DataPort;
}
part mountControl : Subsystem {
attribute redefines mass = 15.0;
port dataIn : DataPort;
}
connection opticalPath connect primaryMirror.opticalOut to instrumentCluster.opticalIn;
connection dataPath connect instrumentCluster.dataOut to mountControl.dataIn;
}
part def Computer;
part scienceComputer : Computer;
allocation processing allocate telescope.instrumentCluster to scienceComputer;
requirement massRequirement;
part observatory {
satisfy massRequirement by telescope;
}
verification def MassTest;
verification massVerification : MassTest {
objective {
verify massRequirement;
}
}
// ---- Recipe queries ----
calc def Children :> Query {
in root : Element;
OwnedElements(source = root)
}
calc def AllParts :> Query {
in root : Element;
WhereType(
source = Descendants(source = root, maxDepth = 10),
type = "PartUsage"
)
}
calc def Enclosing :> Query {
in leaf : Element;
Ancestors(source = leaf, maxDepth = 2)
}
calc def Connections :> Query {
in root : Element;
WhereType(
source = Descendants(source = root, maxDepth = 10),
type = "ConnectionUsage"
)
}
calc def MirrorParts :> Query {
in root : Element;
WhereName(
source = AllParts(root = root),
operator = "contains",
value = "Mirror"
)
}
calc def CriticalParts :> Query {
in root : Element;
WhereMetadata(
source = AllParts(root = root),
'metadata' = "Cookbook::Critical"
)
}
calc def HeavyParts :> Query {
in root : Element;
in threshold : String;
WhereFeature(
source = AllParts(root = root),
'feature' = "mass",
operator = ">=",
value = threshold
)
}
calc def PartsByMass :> Query {
in root : Element;
OrderBy(
source = AllParts(root = root),
property = "mass",
direction = "descending",
missing = "last",
multiple = "error"
)
}
calc def MassTable :> Query {
in root : Element;
Project(
source = PartsByMass(root = root),
properties = ("name", "mass", "qualifiedName")
)
}
calc def MassBudget :> Query {
in root : Element;
Project(
source = PartsByMass(root = root),
properties = ("name", "mass"),
columns = (
Column(name = "massLbs", expression = (Subsystem::mass ?? 0.0) * 2.2),
Column(name = "label", expression = "part: " + Element::name)
)
)
}
calc def ConnectedTo :> Query {
in origin : Element;
RelatedElements(
source = origin,
relationshipKind = "connection",
direction = "outgoing",
maxDepth = 1
)
}
calc def AllocatedTargets :> Query {
in origin : Element;
RelatedElements(
source = origin,
relationshipKind = "allocation",
direction = "outgoing",
maxDepth = 1
)
}
calc def SatisfiedBy :> Query {
in req : Element;
RelatedElements(
source = req,
relationshipKind = "satisfaction",
direction = "incoming",
maxDepth = 1
)
}
calc def VerifiedBy :> Query {
in req : Element;
RelatedElements(
source = req,
relationshipKind = "verification",
direction = "incoming",
maxDepth = 1
)
}
calc def Specializers :> Query {
in general : Element;
RelatedElements(
source = general,
relationshipKind = "specialization",
direction = "incoming",
maxDepth = 2
)
}
}