diff options
author | Kristóf Marussy <kris7topher@gmail.com> | 2019-03-20 16:09:09 +0100 |
---|---|---|
committer | Kristóf Marussy <kris7topher@gmail.com> | 2019-03-20 16:09:09 +0100 |
commit | 3f5aaab5025b8eb243f414b1c789085327df04f4 (patch) | |
tree | 156d9d95888fce6b003d73f509b9155e6b24555f /Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.model/src/hu | |
parent | Fix ParseUtil to avoid breaking the .vql editor in Eclipse (diff) | |
download | VIATRA-Generator-3f5aaab5025b8eb243f414b1c789085327df04f4.tar.gz VIATRA-Generator-3f5aaab5025b8eb243f414b1c789085327df04f4.tar.zst VIATRA-Generator-3f5aaab5025b8eb243f414b1c789085327df04f4.zip |
Fault tree transformation for partial models WIP
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.model/src/hu')
-rw-r--r-- | Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.model/src/hu/bme/mit/inf/dslreasoner/faulttree/model/util/CftExtensions.xtend | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.model/src/hu/bme/mit/inf/dslreasoner/faulttree/model/util/CftExtensions.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.model/src/hu/bme/mit/inf/dslreasoner/faulttree/model/util/CftExtensions.xtend new file mode 100644 index 00000000..ddf2c266 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.model/src/hu/bme/mit/inf/dslreasoner/faulttree/model/util/CftExtensions.xtend | |||
@@ -0,0 +1,48 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.model.util | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ModalElement | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
7 | |||
8 | final class CftExtensions { | ||
9 | private new() { | ||
10 | throw new IllegalStateException("This is a static utility class and should not be instantiated directly.") | ||
11 | } | ||
12 | |||
13 | static def isMoreConcreteThan(Modality newModality, Modality original) { | ||
14 | switch (original) { | ||
15 | case MAY: newModality != Modality.MAY | ||
16 | case CURRENT: newModality == Modality.MUST | ||
17 | case MUST: false | ||
18 | } | ||
19 | } | ||
20 | |||
21 | static def currentlyExists(ModalElement element) { | ||
22 | element.exists != Modality.MAY | ||
23 | } | ||
24 | |||
25 | static def mustExist(ModalElement element) { | ||
26 | element.exists == Modality.MUST | ||
27 | } | ||
28 | |||
29 | static def appearsExactlyOnce(Component componentInstance) { | ||
30 | componentInstance.mustExist && !componentInstance.multipleAllowed | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * Checks whether the connection and its target component are both currently present. | ||
35 | * | ||
36 | * A currently present connection without a present target component is a partial model error, | ||
37 | * so we throw an exception instead of returning <code>false</code>. | ||
38 | * | ||
39 | * @param connection The connection to check. | ||
40 | * @throws IllegalStateException When the target component is not currently present. | ||
41 | */ | ||
42 | static def isCurrentlyConnected(Connection connection) { | ||
43 | if (connection.output.component.currentlyExists) { | ||
44 | throw new IllegalStateException("Inconsistent partial model: current connection to a component that may not currently exist") | ||
45 | } | ||
46 | connection.currentlyExists | ||
47 | } | ||
48 | } | ||