-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcookbook.sysml
More file actions
460 lines (407 loc) · 10.8 KB
/
Copy pathcookbook.sysml
File metadata and controls
460 lines (407 loc) · 10.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
package Cookbook {
private import DocumentQueries::*;
private import KerML::Root::Element;
private import ScalarValues::*;
private import SI::*;
// ---- The model the recipes query ----
part def Subsystem {
attribute mass : Real;
assert constraint massKnown { mass > 0.0 }
}
part def OpticalSubsystem :> Subsystem;
part def MirrorAssembly :> OpticalSubsystem {
attribute :>> mass = 10.0;
assert constraint lightweight { mass < 5.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;
}
}
// ---- The run the state and event recipes query ----
attribute def Open;
attribute def Close;
attribute def Slew { attribute azimuth : Real; }
state def DomeControl {
attribute azimuth : Real = 0.0;
entry; then closed;
state closed;
transition closed_open first closed accept Open then open;
state open parallel {
state pointing {
entry; then parked;
state parked;
transition parked_slewing first parked accept s : Slew do assign azimuth := s.azimuth then slewing;
state slewing;
}
state shutter {
entry; then opening;
state opening;
transition opening_opened first opening accept after 1 [s] then opened;
state opened;
}
}
transition open_close first open accept Close then closed;
}
part def Dome { exhibit state control : DomeControl; }
part dome : Dome;
part spareDome : Dome;
// ---- 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 NamedParts :> Query {
WhereType(
source = Descendants(source = Named(qualifiedName = ("Cookbook::telescope", "Cookbook::Traceability"))),
type = "PartUsage"
)
}
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", cell = { in row : Subsystem; (row.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
)
}
calc def HeldParts :> Query {
in root : Element;
Project(
source = WhereType(source = Descendants(source = root, maxDepth = 2), type = "Subsystem"),
properties = ("qualifiedName", "mass")
)
}
calc def HeldSubsystems :> Query {
OrderBy(
source = Project(source = Objects(type = "Subsystem"), properties = ("qualifiedName", "mass")),
property = "mass",
direction = "descending",
missing = "last",
multiple = "first"
)
}
calc def Checks :> Query {
in root : Element;
Project(source = Verdicts(source = root), properties = ("path", "name", "verdict", "reason"))
}
calc def Violated :> Query {
in root : Element;
WhereFeature(source = Verdicts(source = root), 'feature' = "verdict", operator = "=", value = "violated")
}
// ---- A requirement nothing satisfies, and the coverage recipes ----
requirement def PointingRequirement {
doc /* The telescope holds a target within the stated accuracy. */
}
requirement <'REQ-2'> pointingRequirement : PointingRequirement {
doc /* The telescope points at a target to within 2 arcseconds. */
requirement <'REQ-2.1'> slewRequirement {
doc /* The mount reaches a new target within 60 seconds. */
}
requirement <'REQ-2.2'> trackingRequirement {
doc /* The mount tracks a target for 30 minutes without drift. */
}
}
verification def PointingTest;
verification pointingVerification : PointingTest {
objective {
verify pointingRequirement;
}
}
calc def Requirements :> Query {
in root : Element;
Except(
source = Union(
source = WhereType(source = Descendants(source = root, maxDepth = 10), type = "RequirementDefinition"),
other = WhereType(source = Descendants(source = root, maxDepth = 10), type = "RequirementUsage")
),
exclude = WhereType(source = Descendants(source = root, maxDepth = 10), type = "SatisfyRequirementUsage")
)
}
calc def UnsatisfiedRequirements :> Query {
in root : Element;
WhereRelated(
source = Requirements(root = root),
relationshipKind = "satisfaction",
direction = "incoming",
maxDepth = 1,
exists = false
)
}
calc def UnverifiedRequirements :> Query {
in root : Element;
WhereRelated(
source = Requirements(root = root),
relationshipKind = "verification",
direction = "incoming",
maxDepth = 1,
exists = false
)
}
calc def UncoveredRequirements :> Query {
in root : Element;
Union(
source = UnsatisfiedRequirements(root = root),
other = UnverifiedRequirements(root = root)
)
}
calc def VerifiedButUnsatisfied :> Query {
in root : Element;
Except(
source = UnsatisfiedRequirements(root = root),
exclude = UnverifiedRequirements(root = root)
)
}
calc def RequirementTree :> Query {
in root : Element;
Project(
source = OrderBy(
source = Requirements(root = root),
property = "qualifiedName",
direction = "ascending",
missing = "last",
multiple = "error"
),
properties = ("shortName", "name", "documentation")
)
}
// ---- Requirement derivation and refinement ----
requirement mirrorMassRequirement;
requirement segmentMassRequirement;
requirement instrumentMassRequirement;
connection deriveMirrorMass : RequirementDerivation::Derivation
connect massRequirement to mirrorMassRequirement;
#RequirementDerivation::derivation connection deriveInstrumentMass
connect massRequirement to instrumentMassRequirement;
#RequirementDerivation::derivation connection deriveSegmentMass
connect mirrorMassRequirement to segmentMassRequirement;
#ModelingMetadata::refinement dependency mirrorRefinesMass
from MirrorAssembly to mirrorMassRequirement;
calc def DerivedFrom :> Query {
in req : Element;
RelatedElements(
source = req,
relationshipKind = "derivation",
direction = "outgoing",
maxDepth = 2
)
}
calc def RefinedBy :> Query {
in req : Element;
RelatedElements(
source = req,
relationshipKind = "refinement",
direction = "incoming",
maxDepth = 1
)
}
calc def DomeStates :> Query {
in root : Element;
Project(source = States(source = root), properties = ("machine", "statePath", "region", "enclosing"))
}
calc def Opened :> Query {
Project(source = InState(name = "open"), properties = ("qualifiedName"))
}
calc def Accepted :> Query {
in root : Element;
Project(
source = Events(source = root, kind = "accept", since = 1 [s], before = 2.5 [s]),
properties = ("time", "event", "payload")
)
}
// ---- Traceability: requirements, what satisfies them, what verifies them ----
package Traceability {
requirement <'TR-1'> pointingRequirement;
requirement <'TR-2'> thermalRequirement;
requirement <'TR-3'> downlinkRequirement;
part gimbal;
part radiator;
part transmitter;
part spacecraft {
satisfy pointingRequirement by gimbal;
satisfy thermalRequirement by radiator;
satisfy downlinkRequirement by transmitter;
}
verification pointingTest : MassTest {
objective {
verify pointingRequirement;
}
}
verification pointingAnalysis : MassTest {
objective {
verify pointingRequirement;
}
}
verification thermalTest : MassTest {
objective {
verify thermalRequirement;
}
}
}
calc def TraceMatrix :> Query {
in root : Element;
Project(
source = WhereType(
source = Descendants(source = root, maxDepth = 1),
type = "RequirementUsage"
),
properties = ("shortName", "name"),
columns = (
RelatedColumn(name = "satisfiedBy", relationshipKind = "satisfaction", direction = "incoming", maxDepth = 1),
RelatedColumn(name = "verifiedBy", relationshipKind = "verification", direction = "incoming", maxDepth = 1),
RelatedColumn(
name = "verifications",
relationshipKind = "verification",
direction = "incoming",
maxDepth = 1,
aggregate = "count"
)
)
)
}
calc def Unverified :> Query {
in root : Element;
WhereFeature(
source = TraceMatrix(root = root),
'feature' = "verifications",
operator = "=",
value = "0"
)
}
}