-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDDIBuilderHelpers.eol
2125 lines (2027 loc) · 62.9 KB
/
DDIBuilderHelpers.eol
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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
MIT License
Copyright (c) 2019 DEIS Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
Script must be executed against the following models:
1. m: the subject DDI which helpers reference
*/
// General Helpers
/**
@Clone
@context
@type Any
The subject EMF element to be cloned
@return-type
@type Any
The clone of the context EMF element
@comments
Clone deep-copies a EMF element using org.eclipse.epsilon.emc.emf.tools.EmfTool.EcoreUtil.copy
<br><b>IMPORTANT: </b>For the cloned element to be usable (properties accessible), it must be copied into a container element in the subject model
*/
operation Any Clone() : Any {
var emfTool : new Native("org.eclipse.epsilon.emc.emf.tools.EmfTool");
var result = emfTool.ecoreUtil.copy(self);
return result;
}
// ODE ProductPackages Builders
// Base Builders
/**
@GetID
@return-type
@type Integer
A randomly generated integer to serve as an element ID
@comments
Generates a unique pseudo-random ID using java.util.Random
<br> The range is [0, MAX_ID], MAX_ID is a global Integer that should be defined by the user
<br> The user must also define a global ID_LIST Collection of existing IDs for checking the uniqueness
*/
operation GetID() : Integer {
var result : Integer;
var javaRandom : new Native("java.util.Random");
var newID = javaRandom.nextInt(MAX_ID);
while (ID_LIST.includes(newID))
newID = javaRandom.nextInt(MAX_ID);
ID_LIST.add(newID);
return newID;
}
/**
@SetNameDescription
@context
@type BaseElement
The BaseElement whose name and description should be set
@param name
@type String
The name the element should be set to
@param description
@type String
The description the element should be set to
@comments
SetNameDescription sets a BaseElement's name and description
*/
operation m!BaseElement SetNameDescription(name : String, description : String) {
self.name = name;
self.description = description;
}
/**
@AddKeyValue(1)
@context
@type BaseElement
The BaseElement to which the key-value pair is to be added
@param key
@type String
The key of the key-value pair
@param value
@type String
The value of the key-value pair
@comments
Adds the key-value pair to the context BaseElement
*/
operation m!BaseElement AddKeyValue(key : String, value : String) {
self.AddKeyValue(key, value, "");
}
/**
@AddKeyValue(2)
@context
@type BaseElement
The BaseElement to which the key-value pair is to be added
@param key
@type String
The key of the key-value pair
@param value
@type String
The value of the key-value pair
@param tag
@type String
Additional specification of key-value pair
@comments
Adds the key-value pair to the context BaseElement, also adds tag with pair
*/
operation m!BaseElement AddKeyValue(key : String, value : String, tag : String) {
var existingEntry = self.keyValueMaps.select(entry | entry.key = key).first();
if(not existingEntry.isDefined()) {
var newEntry = new m!KeyValueMap;
newEntry.key = key;
self.keyValueMaps.add(newEntry);
existingEntry = newEntry;
}
var newValue : new m!Value;
newValue.tag = tag;
newValue.value = value;
existingEntry.values.add(newValue);
}
// DesignPackage Builders
/**
@BuildSystem(1)
@context
@type DesignPackage
The DesignPackage to which the built System should be added to
@return-type
@type System
The built System
@param name
@type String
The name of the built System
@param description
@type String
The description of the built System
@comments
Builds a new System with given name and description, adds it to the context DesignPackage and returns it
<br> The built System is initialised with an ID using GetID()
*/
operation m!DesignPackage BuildSystem(name : String, description : String) : m!System {
var result : new m!System;
result.SetNameDescription(name, description);
var defaultBoundary : new m!SystemBoundary;
defaultBoundary.name = result.name + " Default Boundary";
result.systemBoundaries.add(defaultBoundary);
self.systems.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildSystem(2)
@context
@type DesignPackage
The DesignPackage to which the built System should be added to
@return-type
@type System
The built System
@param name
@type String
The name of the built System
@param description
@type String
The description of the built System
@param parentSystem
@type System
The parent system under which the built System is added
@comments
Builds a new System with given name and description, adds it to the context DesignPackage and returns it
<br> The built System is initialised with an ID using GetID()
<br> Adds the built System under the parentSystem's subSystems
*/
operation m!DesignPackage BuildSystem(name : String, description : String, parentSystem : System) {
var result = self.BuildSystem(name, description);
parentSystem.subSystems.add(result);
return result;
}
/**
@BuildFunction
@context
@type DesignPackage
The DesignPackage to which the built Function should be added to
@return-type
@type Function
The built Function
@param name
@type String
The name of the built Function
@param description
@type String
The description of the built Function
@comments
Builds a new Function with given name and description, adds it to the context DesignPackage and returns it
<br> The built Function is initialised with an ID using GetID()
*/
operation m!DesignPackage BuildFunction(name : String, description : String) : m!Function {
var result : new m!Function;
result.SetNameDescription(name, description);
self.functions.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildPort(1)
@context
@type System
The System to which the built Port should be added to
@return-type
@type Port
The built Port
@param name
@type String
The name of the built Port
@param description
@type String
The description of the built Port
@comments
Builds a new Port with given name and description, adds it to the context System's ports and returns it
<br> The built Port is initialised with an ID using GetID()
*/
operation m!System BuildPort(name : String, description : String) : m!Port {
var result : new m!Port;
result.SetNameDescription(name, description);
result.direction = m!PortDirection#INOUT;
self.ports.add(result);
self.systemBoundaries.first().ports.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildPort(2)
@context
@type System
The System to which the built Port should be added to
@return-type
@type Port
The built Port
@param name
@type String
The name of the built Port
@param description
@type String
The description of the built Port
@param direction
@type String
The direction ("IN", "OUT", "INOUT") of the Port
@comments
Builds a new Port with given name and description, adds it to the context System's ports and returns it
<br> The built Port is initialised with an ID using GetID()
<br> Also sets the Port's direction
*/
operation m!System BuildPort(name : String, description : String, direction : String) : m!Port {
var result = self.BuildPort(name, description);
result.SetDirection(direction);
return result;
}
/**
@BuildPort(3)
@context
@type Function
The Function to which the built Port should be added to
@return-type
@type Port
The built Port
@param name
@type String
The name of the built Port
@param description
@type String
The description of the built Port
@param direction
@type String
The direction ("IN", "OUT", "INOUT") of the Port
@comments
Builds a new Port with given name and description, adds it to the context Function's ports and returns it
<br> The built Port is initialised with an ID using GetID()
<br> Also sets the Port's direction
*/
operation m!Function BuildPort(name : String, description : String, direction : String) : m!Port {
var result : new m!Port;
result.SetNameDescription(name, description);
self.ports.add(result);
result.SetDirection(direction);
result.Id = GetID().asLong();
return result;
}
/**
@SetDirection
@context
@type Port
The Port whose direction is set
@param direction
@type String
The direction ("IN", "OUT", "INOUT") to be set
@comments
Sets the direction of the context Port
<br> "INOUT" is assumed if the input does not match the other options
*/
operation m!Port SetDirection(direction : String) {
if (direction = "IN")
self.direction = m!PortDirection#IN;
else if (direction = "OUT")
self.direction = m!PortDirection#OUT;
else // if (direction = "INOUT")
self.direction = m!PortDirection#INOUT;
}
/**
@BuildSignal(1)
@context
@type System
The System to which the Signal will be added
@return-type
@type Signal
The built Signal
@param name
@type String
The name of the built String
@param description
@type String
The description of the built String
@param fromPort
@type Port
The Port from which the built Signal originates
@param toPort
@type Port
The Port to which the built Signal connects
@comments
Builds a Signal connecting two Ports, adding it under the context System's signals and returns it
<br> The built Signal is initialised with an ID using GetID()
*/
operation m!System BuildSignal(name : String, description : String, fromPort : m!Port, toPort : m!Port) : m!Signal {
var result : new m!Signal;
result.SetNameDescription(name, description);
result.fromPort = fromPort;
result.toPort = toPort;
self.signals.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildSignal(2)
@context
@type System
The System to which the Signal will be added
@return-type
@type Signal
The built Signal
@param fromPort
@type Port
The Port from which the built Signal originates
@param toPort
@type Port
The Port to which the built Signal connects
@comments
Builds a Signal connecting two Ports, adding it under the context System's signals and returns it
<br> The built Signal is initialised with an ID using GetID()
*/
operation m!System BuildSignal(fromPort : m!Port, toPort : m!Port) : m!Signal {
return self.BuildSignal("", "", fromPort, toPort);
}
/**
@AddFailureModel
@context
@type System
The System to which the FailureModel will be added
@param fm
@type FailureModel
The FailureModel to be added to the context System
@comments
Adds the input FailureModel under the context System's failureModels
*/
operation m!System AddFailureModel(fm : m!FailureModel) {
self.failureModels.add(fm);
}
/**
@AddFailure(1)
@context
@type Port
The Port to which the Failure will be added
@param f
@type Failure
The Failure to be added to the Port
@comments
Adds the input Failure to the context Port
*/
operation m!Port AddFailure(f : m!Failure) {
self.interfaceFailures.add(f);
}
/**
@AddFailure(2)
@context
@type Port
The Port to which the Cause will be added
@param f
@type Cause
The Cause to be added to the Port
@comments
Adds the input Cause to the context Port
*/
operation m!Port AddFailure(f : m!Cause) {
self.AddFailure(f.failure);
}
// FailurePackage Builders
/**
@BuildFaultTree(1)
@context
@type FailureLogicPackage
The FailureLogicPackage under which the built FaultTree is to be added
@return-type
@type FaultTree
The built FaultTree
@param name
@type String
The name of the built FaultTree
@comments
Builds a FaultTree, adds it under the context FailureLogicPackage and returns it
<br> The built FaultTree is initialised with an ID using GetID()
*/
operation m!FailureLogicPackage BuildFaultTree(name : String) : m!FaultTree {
var result : new m!FaultTree;
result.name = name;
self.failureModels.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildFaultTree(2)
@context
@type FailureLogicPackage
The FailureLogicPackage under which the built FaultTree is to be added
@return-type
@type FaultTree
The built FaultTree
@param name
@type String
The name of the built FaultTree
@param parent
@type FailureModel
The FailureModel under which the built FaultTree is to be added
@comments
Builds a FaultTree, adds it under the context FailureLogicPackage and the FailureModel and returns it
<br> The built FaultTree is initialised with an ID using GetID()
*/
operation m!FailureLogicPackage BuildFaultTree(name : String, parent : m!FailureModel) : m!FaultTree {
var result = self.BuildFaultTree(name);
parent.subModels.add(result);
return result;
}
/**
@BuildFailure
@context
@type FailureModel
The FailureModel under which the built Failure is to be added
@return-type
@type Failure
The built Failure
@param name
@type String
The name of the built Failure
@param description
@type String
The description of the built Failure
@param failureClass
@type String
The class of the built Failure
@param failureRate
@type Real
The failure rate of the built Failure
@comments
Builds a Failure, adds it to the context FailureModel and returns it
<br> The Failure is initialised with an ID using GetID()
*/
operation m!FailureModel BuildFailure(name : String, description : String, failureClass : String, failureRate : Real, isCCF : Boolean, originType : String) : m!Failure {
var result : new m!Failure;
result.SetNameDescription(name, description);
result.failureClass = failureClass;
if(not (failureRate = 0.0d)) {
var probDist : new m!ProbDist;
probDist.type = "Fit";
probDist.Id = GetID().asLong();
var probDistParam : new m!ProbDistParam;
probDistParam.name = "Value";
probDistParam.Id = GetID().asLong();
probDistParam.value = failureRate.asString();
probDist.parameters.add(probDistParam);
result.failureProbDistribution = probDist;
}
result.isCcf = isCCF;
result.SetOriginType(originType);
self.failures.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildGate(1)
@context
@type FaultTree
The FaultTree under which the built Gate is to be added
@return-type
@type Gate
The built Gate
@param name
@type String
The name of the built Gate
@param gateType
@type String
The type of the built Gate, set using SetGateType
@comments
Builds a Gate, adds it to the context FaultTree and returns it
<br> The built Gate is initialised with an ID usign GetID()
*/
operation m!FaultTree BuildGate(name : String, gateType : String) : m!Gate {
var result = self.BuildGate(gateType);
result.name = name;
return result;
}
/**
@BuildGate(2)
@context
@type FaultTree
The FaultTree under which the built Gate is to be added
@return-type
@type Gate
The built Gate
@param gateType
@type String
The type of the built Gate, set using SetGateType
@comments
Builds a Gate, adds it to the context FaultTree and returns it
<br> The built Gate is initialised with an ID usign GetID()
*/
operation m!FaultTree BuildGate(gateType : String) : m!Gate {
var result : new m!Gate;
result.SetGateType(gateType);
result.SetCauseType("GATE");
self.causes.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@AddCause
@context
@type Gate
The Gate under which the built Cause will be added
@param c
@type Cause
The Cause to be added to the context Gate
@comments
Adds a Cause to the context Gate
*/
operation m!Gate AddCause(c : m!Cause) {
self.causes.add(c);
}
/**
@BuildBasicEvent
@context
@type FaultTree
The FaultTree under which the built BasicEvent is to be added
@return-type
@type Cause
The built Cause
@param name
@type String
The name of the built BasicEvent
@param description
@type String
The description of the built BasicEvent
@param failureClass
@type String
The failure class of the built BasicEvent
@param failureRate
@type Real
The failure rate of the built BasicEvent
@param isCCF
@type Boolean
Whether the built BasicEvent is a Common Cause Failure
@comments
Builds a BasicEvent, adds it under the context FaultTree and returns it
<br> The built BasicEvent is initialised with an ID using GetID()
*/
operation m!FaultTree BuildBasicEvent(name : String, description : String, failureClass : String, failureRate : Real, isCCF : Boolean) : m!Cause {
var result : new m!Cause;
result.SetNameDescription(name, description);
var linkedFailure = self.BuildFailure(name, description, failureClass, failureRate, isCCF, "INTERNAL");
result.failure = linkedFailure;
result.SetCauseType("INTERNAL");
self.causes.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildInputEvent
@context
@type FaultTree
The FaultTree under which the built Gate(InputEvent) is to be added
@return-type
@type Gate
The built Gate(InputEvent)
@param name
@type String
The name of the built Gate
@param description
@type String
The description of the built Gate
@param failureClass
@type String
The failure class of the built Gate
@param failureRate
@type Real
The failure rate of the built Gate
@param isCCF
@type Boolean
Whether the built Gate is also a Common Cause Failure
@comments
Builds a Gate(InputEvent), adds it under the FaultTree and returns it
<br> The build Gate is initialised with an ID using GetID()
*/
operation m!FaultTree BuildInputEvent(name : String, description : String, failureClass : String, failureRate : Real, isCCF : Boolean) : m!Gate {
var result : new m!Gate;
result.SetNameDescription(name, description);
var linkedFailure = self.BuildFailure(name, description, failureClass, failureRate, isCCF, "INPUT");
result.failure = linkedFailure;
result.SetCauseType("INPUT");
result.SetGateType("INPUT");
self.causes.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildOutputEvent
@context
@type FaultTree
The FaultTree under which the built Gate(OutputEvent) is to be added
@return-type
@type Gate
The built Gate(OutputEvent)
@param name
@type String
The name of the built Gate
@param description
@type String
The description of the built Gate
@param failureClass
@type String
The failure class of the built Gate
@param failureRate
@type Real
The failure rate of the built Gate
@param isCCF
@type Boolean
Whether the built Gate is also a Common Cause Failure
@comments
Builds a Gate(OutputEvent), adds it under the FaultTree and returns it
<br> The build Gate is initialised with an ID using GetID()
*/
operation m!FaultTree BuildOutputEvent(name : String, description : String, failureClass : String, failureRate : Real, isCCF : Boolean) : m!Gate {
var result : new m!Gate;
result.SetNameDescription(name, description);
var linkedFailure = self.BuildFailure(name, description, failureClass, failureRate, isCCF, "OUTPUT");
result.failure = linkedFailure;
result.SetCauseType("OUTPUT");
result.SetGateType("OUTPUT");
self.causes.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@SetOriginType
@context
@type Failure
Sets the origin type of the context Failure
@param originType
@type String
The origin type ("INPUT", "OUTPUT", "INTERNAL") the context Failure should be set to
@comments
Sets the Failure to the origin type ("INPUT", "OUTPUT", "INTERNAL")
<br> Set by default to "INTERNAL" if the other options are not chosen instead
*/
operation m!Failure SetOriginType(originType : String) {
if (originType = "INPUT")
self.originType = m!FailureOriginType#Input;
else if (originType = "OUTPUT")
self.originType = m!FailureOriginType#Output;
else //if (originType = "INTERNAL")
self.originType = m!FailureOriginType#Internal;
}
/**
@SetGateType
@context
@type Gate
The Gate whose type should be set
@param gateType
@type String
The type the context Gate should be set to
@comments
The type ("OR", "AND", "NOT", "XOR", "VOTE", "PAND", "SAND", "INPUT", "OUTPUT") the context Gate should be set to
<br> Defaults to "OUTPUT" if the other options are not chosen
*/
operation m!Gate SetGateType(gateType : String) {
if (gateType = "OR")
self.gateType = m!GateType#OR;
else if (gateType = "AND")
self.gateType = m!GateType#AND;
else if (gateType = "NOT")
self.gateType = m!GateType#NOT;
else if (gateType = "XOR")
self.gateType = m!GateType#XOR;
else if (gateType = "VOTE")
self.gateType = m!GateType#VOTE;
else if (gateType = "PAND")
self.gateType = m!GateType#PAND;
else if (gateType = "SAND")
self.gateType = m!GateType#SAND;
else if (gateType = "INPUT")
self.gateType = m!GateType#InputEvent;
else // if (gateType = "OUTPUT")
self.gateType = m!GateType#OutputEvent;
}
/**
@SetCauseType
@context
@type Cause
The Cause whose type should be set
@param causeType
@type String
The type ("INPUT", "OUTPUT", "GATE", "INTERNAL") the context Cause should be set to
@comments
Sets the type of the context Cause to one of the mentioned options
<br> If no other options match, defaults to "INTERNAL"
*/
operation m!Cause SetCauseType(causeType : String) {
if (causeType = "INPUT")
self.causeType = m!CauseType#InputEvent;
else if (causeType = "OUTPUT")
self.causeType = m!CauseType#OutputEvent;
else if (causeType = "GATE")
self.causeType = m!CauseType#Gate;
else // if (causeType = "INTERNAL")
self.causeType = m!CauseType#BasicEvent;
}
// Dependability Package Builders
/**
@BuildHazardType
@context
@type HARAPackage
The HARAPackage under which the built HazardType should be added
@return-type
@type HazardType
The built HazardType
@param name
@type String
The name of the built HazardType
@param description
@type String
The description of the built HazardType
@comments
Builds a HazardType, adds it to the HARAPackage and returns it
<br> The built HazardType is initialised with an ID using GetID()
*/
operation m!HARAPackage BuildHazardType(name : String, description : String) : m!HazardType {
var result : new m!HazardType;
result.SetNameDescription(name, description);
self.hazardTypes.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildHazard
@context
@type HARAPackage
The HARAPackage under which the built Hazard should be added
@return-type
@type Hazard
The built Hazard
@param name
@type String
The name of the built Hazard
@param description
@type String
The desription of the built Hazard
@param condition
@type String
The condition of the built Hazard
@param hazardType
@type HazardType
The HazardType of the built Hazard
@param failures
@type Collection
A Collection containing Failures to be added to the Hazard
@param measures
@type Collection
A Collection containing Measures to be added to the Hazard
@comments
Builds a Hazard, adds it to the context HARAPackage and returns it
<br> The built Hazard is initialised with an ID using GetID()
*/
operation m!HARAPackage BuildHazard(name : String, description : String, condition : String, hazardType : m!HazardType, failures : Collection, measures : Collection) : m!Hazard {
var result : new m!Hazard;
result.SetNameDescription(name, description);
result.condition = condition;
result.hazardType = hazardType;
result.failures.addAll(failures);
result.measures.addAll(measures);
self.hazards.add(result);
result.Id = GetID().asLong();
return result;
}
/**
@BuildMalfunction
@context
@type HARAPackage
The HARAPackage under which the built Malfunction should be added
@return-type
@type Malfunction
The built Malfunction
@param name
@type String
The name of the built Malfunction
@param description
@type String
The description of the built Malfunction
@param hazards
@type Collection
A Collection of Hazards to be added to the built Malfunction
@comments
Builds a Malfunction, adds it to the context HARAPackage and returns it
<br> The built Malfunction is initialised with an ID using GetID()
*/
operation m!HARAPackage BuildMalfunction(name : String, description : String, hazards : Collection) : m!Malfunction {
var result : new m!Malfunction;
result.SetNameDescription(name, description);
result.hazards.addAll(hazards);
self.malfunctions.add(result);
result.Id = GetID().asLong();
return result;
}
// SACM Builders
/**
@SetName
@context
@type ModelElement
The ModelElement whose 'name' should be set
@param input
@type String
The name of the ModelElement
@comments
Sets the 'name' of a ModelElement; given ModelElements do not have an explicit 'name' property,
<br> the name is set as a LangString and added to the ModelElement.
<br> The LangString's lang is 'en' and its content is the name
*/
operation m!ModelElement SetName(input : String) {
var name : new m!LangString;
name.lang = "en";
name.content = input;
self.name = name;
}
/**
@BuildLangString(1)
@return-type
@type LangString
The built LangString
@param content
@type String
The content of the LangString
@param lang
@type String
The language of the LangString e.g. 'eng' for english
@comments
Builds a LangString
*/
operation BuildLangString(content : String, lang : String) : m!LangString {
var result : new m!LangString;
result.lang = lang;
result.content = content;
return result;
}
/**
@BuildLangString(2)
@context
@type MultiLangString
The MultiLangString to which the built LangString will be added
@return-type
@type LangString
The built LangString
@param content
@type String
The content of the LangString
@param lang
@type String
The language of the LangString e.g. 'eng' for english
@comments
Builds a LangString, adds it to the context MultiLangString
*/
operation m!MultiLangString BuildLangString(lang : String, content : String) : m!LangString {
var result : new m!LangString;
result.lang = lang;
result.content = content;
self.value.add(result);
return result;
}
/**
@BuildTaggedValue
@context
@type ModelElement
The ModelElement to which the constructed TaggedValue will be added
@return-type
@type TaggedValue
The built TaggedValue
@param key
@type String
The 'key' of the TaggedValue
@param value
@type String
The 'value' of the TaggedValue
@comments
Builds a TaggedValue, adds it to the context ModelElement and returns it
<br> The built TaggedValue is initialised with an ID using GetID()
<br><b>Attention: Method updated to comply to SACM meta model:</b>
<br> Each TaggedValue consists of a MultiLangString <key> containing LangStrings.
<br> The key value is now in the "content" attribute of the LangString element <value>.
<br> It is further now possible to add multiple keys for one TaggedValue.
<br> See functions below.
<br> Each TaggedValue further has a MultiLangString <content> to store the value
<br> as a LangString. Here, the value is also located in the "content" attribute
<br> of the LangString element <value>.
<br> It is now also possible to add multiple values to one or more keys within
<br> a single TaggedValue element. See functions below.
*/
operation m!ModelElement BuildTaggedValue(key : String, value : String) : m!TaggedValue {
var result : new m!TaggedValue;
result.key = new m!MultiLangString;
result.key.BuildLangString("en", key );
result.content = new m!MultiLangString;
result.content.BuildLangString("en", value);
self.taggedValue.add(result);
result.gid = GetID().asString();
return result;
}
/**
@BuildTaggedValue
@context
@type ModelElement
The ModelElement to which the constructed TaggedValue will be added
@return-type
@type TaggedValue