diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft')
9 files changed, 0 insertions, 779 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin deleted file mode 100644 index dfae40e9..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventCollection.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventCollection.xtendbin deleted file mode 100644 index 0aaf712d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventCollection.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventMaterializer.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventMaterializer.xtendbin deleted file mode 100644 index e51f73a6..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventMaterializer.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.FaultTreeBuilder.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.FaultTreeBuilder.xtendbin deleted file mode 100644 index 89e003dc..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.FaultTreeBuilder.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore deleted file mode 100644 index 058cff19..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /.Cft2FtTransformation.java._trace | ||
2 | /.EventMaterializer.java._trace | ||
3 | /.MaterializedEvent.java._trace | ||
4 | /.CollectedInputs.java._trace | ||
5 | /.MaterializedEventCollection.java._trace | ||
6 | /.FaultTreeBuilder.java._trace | ||
7 | /.FaultModelBuilder.java._trace | ||
8 | /.EventCollection.java._trace | ||
9 | /.Cft2FtTransformation.xtendbin | ||
10 | /.EventCollection.xtendbin | ||
11 | /.EventMaterializer.xtendbin | ||
12 | /.FaultTreeBuilder.xtendbin | ||
13 | /Cft2FtTransformation.java | ||
14 | /EventCollection.java | ||
15 | /EventMaterializer.java | ||
16 | /FaultTreeBuilder.java | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java deleted file mode 100644 index e87b8865..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantModel; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ReliabilityModel; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft.EventMaterializer; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft.FaultTreeBuilder; | ||
13 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
14 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
15 | |||
16 | @SuppressWarnings("all") | ||
17 | public class Cft2FtTransformation { | ||
18 | public ReliabilityModel createFaultTree(final ComponentFaultTree componentFaultTree) { | ||
19 | ReliabilityModel _xblockexpression = null; | ||
20 | { | ||
21 | final EventMaterializer materializer = new EventMaterializer(); | ||
22 | final Event topEvent = materializer.getOrMaterialize(componentFaultTree.getTopEvent()); | ||
23 | ReliabilityModel _switchResult = null; | ||
24 | boolean _matched = false; | ||
25 | if (topEvent instanceof ConstantEvent) { | ||
26 | _matched=true; | ||
27 | ConstantModel _createConstantModel = FtFactory.eINSTANCE.createConstantModel(); | ||
28 | final Procedure1<ConstantModel> _function = (ConstantModel it) -> { | ||
29 | it.setFailed(((ConstantEvent)topEvent).isFailed()); | ||
30 | }; | ||
31 | _switchResult = ObjectExtensions.<ConstantModel>operator_doubleArrow(_createConstantModel, _function); | ||
32 | } | ||
33 | if (!_matched) { | ||
34 | if (topEvent instanceof RandomEvent) { | ||
35 | _matched=true; | ||
36 | FaultTree _xblockexpression_1 = null; | ||
37 | { | ||
38 | final FaultTreeBuilder builder = new FaultTreeBuilder(); | ||
39 | builder.addTopLevel(((RandomEvent)topEvent)); | ||
40 | _xblockexpression_1 = builder.getFaultTree(); | ||
41 | } | ||
42 | _switchResult = _xblockexpression_1; | ||
43 | } | ||
44 | } | ||
45 | _xblockexpression = _switchResult; | ||
46 | } | ||
47 | return _xblockexpression; | ||
48 | } | ||
49 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.java deleted file mode 100644 index dceef9f8..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.java +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableSet; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
7 | import java.util.Set; | ||
8 | import org.eclipse.xtend.lib.annotations.Data; | ||
9 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
10 | import org.eclipse.xtext.xbase.lib.Pure; | ||
11 | import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; | ||
12 | |||
13 | @Data | ||
14 | @SuppressWarnings("all") | ||
15 | public class EventCollection { | ||
16 | public static class Builder { | ||
17 | private int falseEventCount = 0; | ||
18 | |||
19 | private int trueEventCount = 0; | ||
20 | |||
21 | private final ImmutableSet.Builder<RandomEvent> randomEventsBuilder = ImmutableSet.<RandomEvent>builder(); | ||
22 | |||
23 | private Builder() { | ||
24 | } | ||
25 | |||
26 | public EventCollection.Builder add(final Event event) { | ||
27 | EventCollection.Builder _xblockexpression = null; | ||
28 | { | ||
29 | boolean _matched = false; | ||
30 | if (event instanceof ConstantEvent) { | ||
31 | _matched=true; | ||
32 | boolean _isFailed = ((ConstantEvent)event).isFailed(); | ||
33 | if (_isFailed) { | ||
34 | this.trueEventCount++; | ||
35 | } else { | ||
36 | this.falseEventCount++; | ||
37 | } | ||
38 | } | ||
39 | if (!_matched) { | ||
40 | if (event instanceof RandomEvent) { | ||
41 | _matched=true; | ||
42 | this.randomEventsBuilder.add(((RandomEvent)event)); | ||
43 | } | ||
44 | } | ||
45 | if (!_matched) { | ||
46 | throw new IllegalArgumentException(("Unknown event: " + event)); | ||
47 | } | ||
48 | _xblockexpression = this; | ||
49 | } | ||
50 | return _xblockexpression; | ||
51 | } | ||
52 | |||
53 | public EventCollection.Builder addAll(final EventCollection materializedEvens) { | ||
54 | EventCollection.Builder _xblockexpression = null; | ||
55 | { | ||
56 | int _falseEventCount = this.falseEventCount; | ||
57 | this.falseEventCount = (_falseEventCount + materializedEvens.falseEventCount); | ||
58 | int _trueEventCount = this.trueEventCount; | ||
59 | this.trueEventCount = (_trueEventCount + materializedEvens.trueEventCount); | ||
60 | this.randomEventsBuilder.addAll(materializedEvens.randomEvents); | ||
61 | _xblockexpression = this; | ||
62 | } | ||
63 | return _xblockexpression; | ||
64 | } | ||
65 | |||
66 | public EventCollection build() { | ||
67 | ImmutableSet<RandomEvent> _build = this.randomEventsBuilder.build(); | ||
68 | return new EventCollection(this.falseEventCount, this.trueEventCount, _build); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | private final int falseEventCount; | ||
73 | |||
74 | private final int trueEventCount; | ||
75 | |||
76 | private final Set<RandomEvent> randomEvents; | ||
77 | |||
78 | public boolean containsFalseEvent() { | ||
79 | return (this.falseEventCount >= 1); | ||
80 | } | ||
81 | |||
82 | public boolean containsTrueEvent() { | ||
83 | return (this.trueEventCount >= 1); | ||
84 | } | ||
85 | |||
86 | public int getVariableEventCount() { | ||
87 | return this.randomEvents.size(); | ||
88 | } | ||
89 | |||
90 | public boolean containsRandomEvent() { | ||
91 | int _variableEventCount = this.getVariableEventCount(); | ||
92 | return (_variableEventCount >= 1); | ||
93 | } | ||
94 | |||
95 | public int getCount() { | ||
96 | int _variableEventCount = this.getVariableEventCount(); | ||
97 | return ((this.falseEventCount + this.trueEventCount) + _variableEventCount); | ||
98 | } | ||
99 | |||
100 | public boolean isEmpty() { | ||
101 | return (((!this.containsFalseEvent()) && (!this.containsTrueEvent())) && (!this.containsRandomEvent())); | ||
102 | } | ||
103 | |||
104 | public boolean containsExactlyOneRandomEvent() { | ||
105 | return (((!this.containsFalseEvent()) && (!this.containsTrueEvent())) && (this.getVariableEventCount() == 1)); | ||
106 | } | ||
107 | |||
108 | public RandomEvent toSingleRandomEvent() { | ||
109 | RandomEvent _xblockexpression = null; | ||
110 | { | ||
111 | boolean _containsExactlyOneRandomEvent = this.containsExactlyOneRandomEvent(); | ||
112 | boolean _not = (!_containsExactlyOneRandomEvent); | ||
113 | if (_not) { | ||
114 | throw new IllegalStateException("Input collection is not a single random event"); | ||
115 | } | ||
116 | _xblockexpression = IterableExtensions.<RandomEvent>head(this.randomEvents); | ||
117 | } | ||
118 | return _xblockexpression; | ||
119 | } | ||
120 | |||
121 | public static EventCollection.Builder builder() { | ||
122 | return new EventCollection.Builder(); | ||
123 | } | ||
124 | |||
125 | public EventCollection(final int falseEventCount, final int trueEventCount, final Set<RandomEvent> randomEvents) { | ||
126 | super(); | ||
127 | this.falseEventCount = falseEventCount; | ||
128 | this.trueEventCount = trueEventCount; | ||
129 | this.randomEvents = randomEvents; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | @Pure | ||
134 | public int hashCode() { | ||
135 | final int prime = 31; | ||
136 | int result = 1; | ||
137 | result = prime * result + this.falseEventCount; | ||
138 | result = prime * result + this.trueEventCount; | ||
139 | return prime * result + ((this.randomEvents== null) ? 0 : this.randomEvents.hashCode()); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | @Pure | ||
144 | public boolean equals(final Object obj) { | ||
145 | if (this == obj) | ||
146 | return true; | ||
147 | if (obj == null) | ||
148 | return false; | ||
149 | if (getClass() != obj.getClass()) | ||
150 | return false; | ||
151 | EventCollection other = (EventCollection) obj; | ||
152 | if (other.falseEventCount != this.falseEventCount) | ||
153 | return false; | ||
154 | if (other.trueEventCount != this.trueEventCount) | ||
155 | return false; | ||
156 | if (this.randomEvents == null) { | ||
157 | if (other.randomEvents != null) | ||
158 | return false; | ||
159 | } else if (!this.randomEvents.equals(other.randomEvents)) | ||
160 | return false; | ||
161 | return true; | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | @Pure | ||
166 | public String toString() { | ||
167 | ToStringBuilder b = new ToStringBuilder(this); | ||
168 | b.add("falseEventCount", this.falseEventCount); | ||
169 | b.add("trueEventCount", this.trueEventCount); | ||
170 | b.add("randomEvents", this.randomEvents); | ||
171 | return b.toString(); | ||
172 | } | ||
173 | |||
174 | @Pure | ||
175 | public int getFalseEventCount() { | ||
176 | return this.falseEventCount; | ||
177 | } | ||
178 | |||
179 | @Pure | ||
180 | public int getTrueEventCount() { | ||
181 | return this.trueEventCount; | ||
182 | } | ||
183 | |||
184 | @Pure | ||
185 | public Set<RandomEvent> getRandomEvents() { | ||
186 | return this.randomEvents; | ||
187 | } | ||
188 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.java deleted file mode 100644 index 98a82b7d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.java +++ /dev/null | |||
@@ -1,469 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.AndGateDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.BasicEventDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.GateDefinition; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.KOfMGateDefinition; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.OrGateDefinition; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.AndGate; | ||
16 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.BasicEvent; | ||
17 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent; | ||
18 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Distribution; | ||
19 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event; | ||
20 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory; | ||
21 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate; | ||
22 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.KOfMGate; | ||
23 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.OrGate; | ||
24 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
25 | import hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions; | ||
26 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft.EventCollection; | ||
27 | import java.util.LinkedHashSet; | ||
28 | import java.util.Map; | ||
29 | import org.eclipse.emf.common.util.EList; | ||
30 | import org.eclipse.emf.ecore.util.EcoreUtil; | ||
31 | import org.eclipse.xtend.lib.annotations.Data; | ||
32 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
33 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
34 | import org.eclipse.xtext.xbase.lib.Extension; | ||
35 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
36 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
37 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
38 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
39 | import org.eclipse.xtext.xbase.lib.Pure; | ||
40 | |||
41 | @SuppressWarnings("all") | ||
42 | public class EventMaterializer { | ||
43 | @Data | ||
44 | protected static class EventKey<T extends EventDeclaration> { | ||
45 | private final Component component; | ||
46 | |||
47 | private final T event; | ||
48 | |||
49 | @Override | ||
50 | public String toString() { | ||
51 | StringConcatenation _builder = new StringConcatenation(); | ||
52 | String _name = this.component.getName(); | ||
53 | _builder.append(_name); | ||
54 | _builder.append("_"); | ||
55 | String _name_1 = this.event.getName(); | ||
56 | _builder.append(_name_1); | ||
57 | return _builder.toString(); | ||
58 | } | ||
59 | |||
60 | public EventKey(final Component component, final T event) { | ||
61 | super(); | ||
62 | this.component = component; | ||
63 | this.event = event; | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | @Pure | ||
68 | public int hashCode() { | ||
69 | final int prime = 31; | ||
70 | int result = 1; | ||
71 | result = prime * result + ((this.component== null) ? 0 : this.component.hashCode()); | ||
72 | return prime * result + ((this.event== null) ? 0 : this.event.hashCode()); | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | @Pure | ||
77 | public boolean equals(final Object obj) { | ||
78 | if (this == obj) | ||
79 | return true; | ||
80 | if (obj == null) | ||
81 | return false; | ||
82 | if (getClass() != obj.getClass()) | ||
83 | return false; | ||
84 | EventMaterializer.EventKey<?> other = (EventMaterializer.EventKey<?>) obj; | ||
85 | if (this.component == null) { | ||
86 | if (other.component != null) | ||
87 | return false; | ||
88 | } else if (!this.component.equals(other.component)) | ||
89 | return false; | ||
90 | if (this.event == null) { | ||
91 | if (other.event != null) | ||
92 | return false; | ||
93 | } else if (!this.event.equals(other.event)) | ||
94 | return false; | ||
95 | return true; | ||
96 | } | ||
97 | |||
98 | @Pure | ||
99 | public Component getComponent() { | ||
100 | return this.component; | ||
101 | } | ||
102 | |||
103 | @Pure | ||
104 | public T getEvent() { | ||
105 | return this.event; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | @Extension | ||
110 | private final FtFactory _ftFactory = FtFactory.eINSTANCE; | ||
111 | |||
112 | private final Map<EventMaterializer.EventKey<EventDeclaration>, Event> materializationCache = CollectionLiterals.<EventMaterializer.EventKey<EventDeclaration>, Event>newHashMap(); | ||
113 | |||
114 | private final Map<EventMaterializer.EventKey<InputEvent>, EventCollection> multipleInputCache = CollectionLiterals.<EventMaterializer.EventKey<InputEvent>, EventCollection>newHashMap(); | ||
115 | |||
116 | private final ConstantEvent falseEvent; | ||
117 | |||
118 | private final ConstantEvent trueEvent; | ||
119 | |||
120 | private final LinkedHashSet<EventMaterializer.EventKey<? extends EventDeclaration>> path = new LinkedHashSet<EventMaterializer.EventKey<? extends EventDeclaration>>(); | ||
121 | |||
122 | public EventMaterializer() { | ||
123 | ConstantEvent _createConstantEvent = this._ftFactory.createConstantEvent(); | ||
124 | final Procedure1<ConstantEvent> _function = (ConstantEvent it) -> { | ||
125 | it.setFailed(false); | ||
126 | }; | ||
127 | ConstantEvent _doubleArrow = ObjectExtensions.<ConstantEvent>operator_doubleArrow(_createConstantEvent, _function); | ||
128 | this.falseEvent = _doubleArrow; | ||
129 | ConstantEvent _createConstantEvent_1 = this._ftFactory.createConstantEvent(); | ||
130 | final Procedure1<ConstantEvent> _function_1 = (ConstantEvent it) -> { | ||
131 | it.setFailed(true); | ||
132 | }; | ||
133 | ConstantEvent _doubleArrow_1 = ObjectExtensions.<ConstantEvent>operator_doubleArrow(_createConstantEvent_1, _function_1); | ||
134 | this.trueEvent = _doubleArrow_1; | ||
135 | } | ||
136 | |||
137 | public Event getOrMaterialize(final Output output) { | ||
138 | return this.getOrMaterialize(output.getComponent(), output.getEventDeclaration()); | ||
139 | } | ||
140 | |||
141 | public Event getOrMaterialize(final Component component, final EventDeclaration eventDeclaration) { | ||
142 | Event _xblockexpression = null; | ||
143 | { | ||
144 | final EventMaterializer.EventKey<EventDeclaration> eventKey = new EventMaterializer.EventKey<EventDeclaration>(component, eventDeclaration); | ||
145 | this.pushEventKey(eventKey); | ||
146 | Event _xtrycatchfinallyexpression = null; | ||
147 | try { | ||
148 | Event _xblockexpression_1 = null; | ||
149 | { | ||
150 | Event event = this.materializationCache.get(eventKey); | ||
151 | if ((event == null)) { | ||
152 | event = this.materialize(component, eventDeclaration); | ||
153 | this.materializationCache.put(eventKey, event); | ||
154 | } | ||
155 | _xblockexpression_1 = event; | ||
156 | } | ||
157 | _xtrycatchfinallyexpression = _xblockexpression_1; | ||
158 | } finally { | ||
159 | this.popEventKey(eventKey); | ||
160 | } | ||
161 | _xblockexpression = _xtrycatchfinallyexpression; | ||
162 | } | ||
163 | return _xblockexpression; | ||
164 | } | ||
165 | |||
166 | protected Event materialize(final Component component, final EventDeclaration eventDeclaration) { | ||
167 | RandomEvent _xblockexpression = null; | ||
168 | { | ||
169 | String _name = component.getName(); | ||
170 | String _plus = (_name + "_"); | ||
171 | String _name_1 = eventDeclaration.getName(); | ||
172 | final String eventName = (_plus + _name_1); | ||
173 | RandomEvent _switchResult = null; | ||
174 | boolean _matched = false; | ||
175 | if (eventDeclaration instanceof InputEvent) { | ||
176 | _matched=true; | ||
177 | return this.materializeConnectedEvent(component, ((InputEvent)eventDeclaration)); | ||
178 | } | ||
179 | if (!_matched) { | ||
180 | if (eventDeclaration instanceof BasicEventDefinition) { | ||
181 | _matched=true; | ||
182 | BasicEvent _xblockexpression_1 = null; | ||
183 | { | ||
184 | final BasicEvent basicEvent = this._ftFactory.createBasicEvent(); | ||
185 | basicEvent.setDistribution(EcoreUtil.<Distribution>copy(((BasicEventDefinition)eventDeclaration).getDistribution())); | ||
186 | _xblockexpression_1 = basicEvent; | ||
187 | } | ||
188 | _switchResult = _xblockexpression_1; | ||
189 | } | ||
190 | } | ||
191 | if (!_matched) { | ||
192 | if (eventDeclaration instanceof GateDefinition) { | ||
193 | _matched=true; | ||
194 | Gate _xblockexpression_1 = null; | ||
195 | { | ||
196 | final EventCollection inputs = this.collectInputs(component, ((GateDefinition)eventDeclaration)); | ||
197 | Gate _switchResult_1 = null; | ||
198 | boolean _matched_1 = false; | ||
199 | if (eventDeclaration instanceof AndGateDefinition) { | ||
200 | _matched_1=true; | ||
201 | AndGate _xifexpression = null; | ||
202 | boolean _containsFalseEvent = inputs.containsFalseEvent(); | ||
203 | if (_containsFalseEvent) { | ||
204 | return this.falseEvent; | ||
205 | } else { | ||
206 | AndGate _xifexpression_1 = null; | ||
207 | boolean _isEmpty = inputs.isEmpty(); | ||
208 | if (_isEmpty) { | ||
209 | return this.trueEvent; | ||
210 | } else { | ||
211 | AndGate _xifexpression_2 = null; | ||
212 | boolean _containsExactlyOneRandomEvent = inputs.containsExactlyOneRandomEvent(); | ||
213 | if (_containsExactlyOneRandomEvent) { | ||
214 | return inputs.toSingleRandomEvent(); | ||
215 | } else { | ||
216 | _xifexpression_2 = this._ftFactory.createAndGate(); | ||
217 | } | ||
218 | _xifexpression_1 = _xifexpression_2; | ||
219 | } | ||
220 | _xifexpression = _xifexpression_1; | ||
221 | } | ||
222 | _switchResult_1 = _xifexpression; | ||
223 | } | ||
224 | if (!_matched_1) { | ||
225 | if (eventDeclaration instanceof OrGateDefinition) { | ||
226 | _matched_1=true; | ||
227 | OrGate _xifexpression = null; | ||
228 | boolean _containsTrueEvent = inputs.containsTrueEvent(); | ||
229 | if (_containsTrueEvent) { | ||
230 | return this.trueEvent; | ||
231 | } else { | ||
232 | OrGate _xifexpression_1 = null; | ||
233 | boolean _isEmpty = inputs.isEmpty(); | ||
234 | if (_isEmpty) { | ||
235 | return this.falseEvent; | ||
236 | } else { | ||
237 | OrGate _xifexpression_2 = null; | ||
238 | boolean _containsExactlyOneRandomEvent = inputs.containsExactlyOneRandomEvent(); | ||
239 | if (_containsExactlyOneRandomEvent) { | ||
240 | return inputs.toSingleRandomEvent(); | ||
241 | } else { | ||
242 | _xifexpression_2 = this._ftFactory.createOrGate(); | ||
243 | } | ||
244 | _xifexpression_1 = _xifexpression_2; | ||
245 | } | ||
246 | _xifexpression = _xifexpression_1; | ||
247 | } | ||
248 | _switchResult_1 = _xifexpression; | ||
249 | } | ||
250 | } | ||
251 | if (!_matched_1) { | ||
252 | if (eventDeclaration instanceof KOfMGateDefinition) { | ||
253 | _matched_1=true; | ||
254 | Gate _xblockexpression_2 = null; | ||
255 | { | ||
256 | int _count = inputs.getCount(); | ||
257 | int _k = ((KOfMGateDefinition)eventDeclaration).getK(); | ||
258 | int _multiply = (_count * _k); | ||
259 | int _m = ((KOfMGateDefinition)eventDeclaration).getM(); | ||
260 | final int requiredTrueInputs = (_multiply / _m); | ||
261 | int _trueEventCount = inputs.getTrueEventCount(); | ||
262 | final int k = (requiredTrueInputs - _trueEventCount); | ||
263 | final int m = inputs.getVariableEventCount(); | ||
264 | Gate _xifexpression = null; | ||
265 | if ((k == 0)) { | ||
266 | return this.trueEvent; | ||
267 | } else { | ||
268 | Gate _xifexpression_1 = null; | ||
269 | if ((k > m)) { | ||
270 | return this.falseEvent; | ||
271 | } else { | ||
272 | Gate _xifexpression_2 = null; | ||
273 | boolean _containsExactlyOneRandomEvent = inputs.containsExactlyOneRandomEvent(); | ||
274 | if (_containsExactlyOneRandomEvent) { | ||
275 | return inputs.toSingleRandomEvent(); | ||
276 | } else { | ||
277 | Gate _xifexpression_3 = null; | ||
278 | if ((k == 1)) { | ||
279 | _xifexpression_3 = this._ftFactory.createOrGate(); | ||
280 | } else { | ||
281 | Gate _xifexpression_4 = null; | ||
282 | if ((k == m)) { | ||
283 | _xifexpression_4 = this._ftFactory.createAndGate(); | ||
284 | } else { | ||
285 | KOfMGate _xblockexpression_3 = null; | ||
286 | { | ||
287 | final KOfMGate kOfMGate = this._ftFactory.createKOfMGate(); | ||
288 | kOfMGate.setK(k); | ||
289 | _xblockexpression_3 = kOfMGate; | ||
290 | } | ||
291 | _xifexpression_4 = _xblockexpression_3; | ||
292 | } | ||
293 | _xifexpression_3 = _xifexpression_4; | ||
294 | } | ||
295 | _xifexpression_2 = _xifexpression_3; | ||
296 | } | ||
297 | _xifexpression_1 = _xifexpression_2; | ||
298 | } | ||
299 | _xifexpression = _xifexpression_1; | ||
300 | } | ||
301 | _xblockexpression_2 = _xifexpression; | ||
302 | } | ||
303 | _switchResult_1 = _xblockexpression_2; | ||
304 | } | ||
305 | } | ||
306 | if (!_matched_1) { | ||
307 | throw new IllegalArgumentException(("Unknown gate definition: " + eventDeclaration)); | ||
308 | } | ||
309 | final Gate gate = _switchResult_1; | ||
310 | gate.getInputEvents().addAll(inputs.getRandomEvents()); | ||
311 | _xblockexpression_1 = gate; | ||
312 | } | ||
313 | _switchResult = _xblockexpression_1; | ||
314 | } | ||
315 | } | ||
316 | if (!_matched) { | ||
317 | throw new IllegalArgumentException(("Unknown event declaration: " + eventDeclaration)); | ||
318 | } | ||
319 | final RandomEvent event = _switchResult; | ||
320 | event.setName(eventName); | ||
321 | _xblockexpression = event; | ||
322 | } | ||
323 | return _xblockexpression; | ||
324 | } | ||
325 | |||
326 | protected Event materializeConnectedEvent(final Component component, final InputEvent inputEvent) { | ||
327 | Event _xblockexpression = null; | ||
328 | { | ||
329 | boolean _isMultiple = inputEvent.isMultiple(); | ||
330 | if (_isMultiple) { | ||
331 | StringConcatenation _builder = new StringConcatenation(); | ||
332 | _builder.append("Cannot materialize multiple nput "); | ||
333 | String _name = component.getName(); | ||
334 | _builder.append(_name); | ||
335 | _builder.append("_"); | ||
336 | String _name_1 = inputEvent.getName(); | ||
337 | _builder.append(_name_1); | ||
338 | throw new IllegalArgumentException(_builder.toString()); | ||
339 | } | ||
340 | final Input input = this.findInput(component, inputEvent); | ||
341 | final EList<Connection> incomingConnections = input.getIncomingConnections(); | ||
342 | int _size = incomingConnections.size(); | ||
343 | boolean _notEquals = (_size != 1); | ||
344 | if (_notEquals) { | ||
345 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
346 | _builder_1.append("Input "); | ||
347 | String _name_2 = component.getName(); | ||
348 | _builder_1.append(_name_2); | ||
349 | _builder_1.append("_"); | ||
350 | String _name_3 = inputEvent.getName(); | ||
351 | _builder_1.append(_name_3); | ||
352 | _builder_1.append(" has "); | ||
353 | int _size_1 = incomingConnections.size(); | ||
354 | _builder_1.append(_size_1); | ||
355 | _builder_1.append(" connections instead of 1"); | ||
356 | throw new IllegalArgumentException(_builder_1.toString()); | ||
357 | } | ||
358 | final Output output = IterableExtensions.<Connection>head(incomingConnections).getOutput(); | ||
359 | _xblockexpression = this.getOrMaterialize(output.getComponent(), output.getEventDeclaration()); | ||
360 | } | ||
361 | return _xblockexpression; | ||
362 | } | ||
363 | |||
364 | protected EventCollection collectInputs(final Component component, final GateDefinition gateDefinition) { | ||
365 | EventCollection _xblockexpression = null; | ||
366 | { | ||
367 | final EventCollection.Builder builder = EventCollection.builder(); | ||
368 | EList<EventDeclaration> _inputEvents = gateDefinition.getInputEvents(); | ||
369 | for (final EventDeclaration inputEventDeclaration : _inputEvents) { | ||
370 | boolean _matched = false; | ||
371 | if (inputEventDeclaration instanceof InputEvent) { | ||
372 | boolean _isMultiple = ((InputEvent)inputEventDeclaration).isMultiple(); | ||
373 | if (_isMultiple) { | ||
374 | _matched=true; | ||
375 | final EventCollection materializedEvents = this.getOrMaterializeConnectedEvents(component, ((InputEvent)inputEventDeclaration)); | ||
376 | builder.addAll(materializedEvents); | ||
377 | } | ||
378 | } | ||
379 | if (!_matched) { | ||
380 | builder.add(this.getOrMaterialize(component, inputEventDeclaration)); | ||
381 | } | ||
382 | } | ||
383 | _xblockexpression = builder.build(); | ||
384 | } | ||
385 | return _xblockexpression; | ||
386 | } | ||
387 | |||
388 | protected EventCollection getOrMaterializeConnectedEvents(final Component component, final InputEvent inputEvent) { | ||
389 | EventCollection _xblockexpression = null; | ||
390 | { | ||
391 | final EventMaterializer.EventKey<InputEvent> inputKey = new EventMaterializer.EventKey<InputEvent>(component, inputEvent); | ||
392 | this.pushEventKey(inputKey); | ||
393 | EventCollection _xtrycatchfinallyexpression = null; | ||
394 | try { | ||
395 | EventCollection _xblockexpression_1 = null; | ||
396 | { | ||
397 | EventCollection eventCollection = this.multipleInputCache.get(inputKey); | ||
398 | if ((eventCollection == null)) { | ||
399 | eventCollection = this.materializeConnectedEvents(component, inputEvent); | ||
400 | this.multipleInputCache.put(inputKey, eventCollection); | ||
401 | } | ||
402 | _xblockexpression_1 = eventCollection; | ||
403 | } | ||
404 | _xtrycatchfinallyexpression = _xblockexpression_1; | ||
405 | } finally { | ||
406 | this.popEventKey(inputKey); | ||
407 | } | ||
408 | _xblockexpression = _xtrycatchfinallyexpression; | ||
409 | } | ||
410 | return _xblockexpression; | ||
411 | } | ||
412 | |||
413 | protected EventCollection materializeConnectedEvents(final Component component, final InputEvent inputEvent) { | ||
414 | EventCollection _xblockexpression = null; | ||
415 | { | ||
416 | final Input input = this.findInput(component, inputEvent); | ||
417 | final EventCollection.Builder builder = EventCollection.builder(); | ||
418 | EList<Connection> _incomingConnections = input.getIncomingConnections(); | ||
419 | for (final Connection connection : _incomingConnections) { | ||
420 | boolean _isCurrentlyConnected = CftExtensions.isCurrentlyConnected(connection); | ||
421 | if (_isCurrentlyConnected) { | ||
422 | final Event materializedEvent = this.getOrMaterialize(connection.getOutput()); | ||
423 | builder.add(materializedEvent); | ||
424 | } | ||
425 | } | ||
426 | _xblockexpression = builder.build(); | ||
427 | } | ||
428 | return _xblockexpression; | ||
429 | } | ||
430 | |||
431 | protected Input findInput(final Component component, final InputEvent inputEvent) { | ||
432 | final Function1<Input, Boolean> _function = (Input it) -> { | ||
433 | InputEvent _inputEvent = it.getInputEvent(); | ||
434 | return Boolean.valueOf(Objects.equal(_inputEvent, inputEvent)); | ||
435 | }; | ||
436 | final Input input = IterableExtensions.<Input>findFirst(component.getInputs(), _function); | ||
437 | if ((input == null)) { | ||
438 | StringConcatenation _builder = new StringConcatenation(); | ||
439 | _builder.append("No input "); | ||
440 | _builder.append(inputEvent); | ||
441 | _builder.append(" in component "); | ||
442 | _builder.append(component); | ||
443 | throw new IllegalArgumentException(_builder.toString()); | ||
444 | } | ||
445 | return input; | ||
446 | } | ||
447 | |||
448 | private void pushEventKey(final EventMaterializer.EventKey<? extends EventDeclaration> eventKey) { | ||
449 | boolean _add = this.path.add(eventKey); | ||
450 | boolean _not = (!_add); | ||
451 | if (_not) { | ||
452 | StringConcatenation _builder = new StringConcatenation(); | ||
453 | _builder.append("Circular dependency ["); | ||
454 | { | ||
455 | for(final EventMaterializer.EventKey<? extends EventDeclaration> ancestor : this.path) { | ||
456 | _builder.append(ancestor); | ||
457 | _builder.append(", "); | ||
458 | } | ||
459 | } | ||
460 | _builder.append(eventKey); | ||
461 | _builder.append("] detected"); | ||
462 | throw new IllegalStateException(_builder.toString()); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | private boolean popEventKey(final EventMaterializer.EventKey<? extends EventDeclaration> eventKey) { | ||
467 | return this.path.remove(eventKey); | ||
468 | } | ||
469 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.java deleted file mode 100644 index 9b2dfd76..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.java +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
8 | import java.util.Collection; | ||
9 | import org.eclipse.emf.common.util.EList; | ||
10 | import org.eclipse.emf.ecore.EObject; | ||
11 | import org.eclipse.xtend.lib.annotations.Accessors; | ||
12 | import org.eclipse.xtext.xbase.lib.Pure; | ||
13 | |||
14 | @SuppressWarnings("all") | ||
15 | public class FaultTreeBuilder { | ||
16 | @Accessors | ||
17 | private final FaultTree faultTree = FtFactory.eINSTANCE.createFaultTree(); | ||
18 | |||
19 | public void addTopLevel(final RandomEvent event) { | ||
20 | RandomEvent _topEvent = this.faultTree.getTopEvent(); | ||
21 | boolean _tripleNotEquals = (_topEvent != null); | ||
22 | if (_tripleNotEquals) { | ||
23 | throw new IllegalStateException("Top event was already set"); | ||
24 | } | ||
25 | this.add(event); | ||
26 | this.faultTree.setTopEvent(event); | ||
27 | } | ||
28 | |||
29 | protected void add(final RandomEvent event) { | ||
30 | EObject _eContainer = this.faultTree.eContainer(); | ||
31 | boolean _equals = Objects.equal(_eContainer, this.faultTree); | ||
32 | if (_equals) { | ||
33 | return; | ||
34 | } | ||
35 | EObject _eContainer_1 = this.faultTree.eContainer(); | ||
36 | boolean _tripleNotEquals = (_eContainer_1 != null); | ||
37 | if (_tripleNotEquals) { | ||
38 | throw new IllegalStateException("Event is already in a different fault tree"); | ||
39 | } | ||
40 | EList<RandomEvent> _events = this.faultTree.getEvents(); | ||
41 | _events.add(event); | ||
42 | if ((event instanceof Gate)) { | ||
43 | this.addAll(((Gate)event).getInputEvents()); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | protected void addAll(final Collection<RandomEvent> events) { | ||
48 | for (final RandomEvent event : events) { | ||
49 | this.add(event); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | @Pure | ||
54 | public FaultTree getFaultTree() { | ||
55 | return this.faultTree; | ||
56 | } | ||
57 | } | ||