diff options
author | 2019-08-01 14:49:53 +0200 | |
---|---|---|
committer | 2019-08-01 14:49:53 +0200 | |
commit | 972baab642bd889d2c3476c0c9e17a6929e0c318 (patch) | |
tree | 8f724cb348c60e4fc45d446d8532988ed8e40748 /Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java | |
parent | Counting scope propagator (simpler than BasicTypeHierarchy) (diff) | |
download | VIATRA-Generator-972baab642bd889d2c3476c0c9e17a6929e0c318.tar.gz VIATRA-Generator-972baab642bd889d2c3476c0c9e17a6929e0c318.tar.zst VIATRA-Generator-972baab642bd889d2c3476c0c9e17a6929e0c318.zip |
[Stochastic] Remove fault tree support for now
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java')
-rw-r--r-- | Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java deleted file mode 100644 index 41703289..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap; | ||
4 | import com.google.common.collect.Iterables; | ||
5 | import com.google.common.collect.Maps; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Assignment; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventReference; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler; | ||
16 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries; | ||
17 | import java.util.HashMap; | ||
18 | import java.util.HashSet; | ||
19 | import java.util.Map; | ||
20 | import java.util.Set; | ||
21 | import java.util.function.Consumer; | ||
22 | import org.eclipse.emf.common.util.EList; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
25 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
26 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
27 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
28 | |||
29 | @SuppressWarnings("all") | ||
30 | public class MappingHandler { | ||
31 | private final ViatraQueryMatcher<? extends IPatternMatch> matcher; | ||
32 | |||
33 | private final MappingDefinition mappingDefinition; | ||
34 | |||
35 | private final Map<LookupDefinition, LookupHandler> lookupHandlers; | ||
36 | |||
37 | public MappingHandler(final MappingDefinition mappingDefinition, final MappingQueries mappingQueries) { | ||
38 | this.matcher = mappingQueries.getMatcher(mappingDefinition); | ||
39 | this.mappingDefinition = mappingDefinition; | ||
40 | final HashSet<Variable> variables = CollectionLiterals.<Variable>newHashSet(); | ||
41 | EList<Assignment> _assignments = mappingDefinition.getAssignments(); | ||
42 | for (final Assignment assignment : _assignments) { | ||
43 | { | ||
44 | Variable _component = assignment.getInput().getComponent(); | ||
45 | variables.add(_component); | ||
46 | Variable _component_1 = assignment.getOutput().getComponent(); | ||
47 | variables.add(_component_1); | ||
48 | } | ||
49 | } | ||
50 | final Function1<LookupDefinition, LookupDefinition> _function = (LookupDefinition it) -> { | ||
51 | return it; | ||
52 | }; | ||
53 | final Function1<LookupDefinition, LookupHandler> _function_1 = (LookupDefinition lookupDefinition) -> { | ||
54 | return mappingQueries.createLookupHandler(mappingDefinition, lookupDefinition); | ||
55 | }; | ||
56 | this.lookupHandlers = ImmutableMap.<LookupDefinition, LookupHandler>copyOf(IterableExtensions.<LookupDefinition, LookupDefinition, LookupHandler>toMap(Iterables.<LookupDefinition>filter(variables, LookupDefinition.class), _function, _function_1)); | ||
57 | } | ||
58 | |||
59 | public void instantiateComponents(final ComponentFaultTreeTrace faultTreeTrace) { | ||
60 | boolean _hasComponentInstace = this.hasComponentInstace(); | ||
61 | boolean _not = (!_hasComponentInstace); | ||
62 | if (_not) { | ||
63 | return; | ||
64 | } | ||
65 | final Consumer<IPatternMatch> _function = (IPatternMatch match) -> { | ||
66 | final ComponentInstanceTrace componentTrace = faultTreeTrace.instantiateComponent(match, this.getComponentDefinition()); | ||
67 | boolean _isTopLevel = this.isTopLevel(); | ||
68 | if (_isTopLevel) { | ||
69 | faultTreeTrace.setTopLevel(componentTrace); | ||
70 | } | ||
71 | }; | ||
72 | this.matcher.forEachMatch(_function); | ||
73 | } | ||
74 | |||
75 | public void instantiateConnections(final ComponentFaultTreeTrace faultTreeTrace) { | ||
76 | boolean _hasConnections = this.hasConnections(); | ||
77 | boolean _not = (!_hasConnections); | ||
78 | if (_not) { | ||
79 | return; | ||
80 | } | ||
81 | final Consumer<IPatternMatch> _function = (IPatternMatch match) -> { | ||
82 | final Map<Variable, ComponentInstanceTrace> lookedUpComponents = this.lookupComponents(faultTreeTrace, match); | ||
83 | EList<Assignment> _assignments = this.mappingDefinition.getAssignments(); | ||
84 | for (final Assignment assignment : _assignments) { | ||
85 | { | ||
86 | final EventReference input = assignment.getInput(); | ||
87 | final ComponentInstanceTrace inputComponent = lookedUpComponents.get(input.getComponent()); | ||
88 | final EventReference output = assignment.getOutput(); | ||
89 | final ComponentInstanceTrace outputComponent = lookedUpComponents.get(output.getComponent()); | ||
90 | if (((inputComponent != null) && (outputComponent != null))) { | ||
91 | inputComponent.assign(input.getEvent(), outputComponent, output.getEvent()); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | }; | ||
96 | this.matcher.forEachMatch(_function); | ||
97 | } | ||
98 | |||
99 | private Map<Variable, ComponentInstanceTrace> lookupComponents(final ComponentFaultTreeTrace faultTreeTrace, final IPatternMatch match) { | ||
100 | HashMap<Variable, ComponentInstanceTrace> _xblockexpression = null; | ||
101 | { | ||
102 | int _size = this.lookupHandlers.size(); | ||
103 | int _plus = (_size + 1); | ||
104 | final HashMap<Variable, ComponentInstanceTrace> lookedUpComponents = Maps.<Variable, ComponentInstanceTrace>newHashMapWithExpectedSize(_plus); | ||
105 | boolean _hasComponentInstace = this.hasComponentInstace(); | ||
106 | if (_hasComponentInstace) { | ||
107 | final ComponentInstanceTrace componentInstance = faultTreeTrace.lookup(match); | ||
108 | lookedUpComponents.put(this.mappingDefinition.getComponentInstance(), componentInstance); | ||
109 | } | ||
110 | Set<Map.Entry<LookupDefinition, LookupHandler>> _entrySet = this.lookupHandlers.entrySet(); | ||
111 | for (final Map.Entry<LookupDefinition, LookupHandler> pair : _entrySet) { | ||
112 | { | ||
113 | final ComponentInstanceTrace componentInstance_1 = pair.getValue().lookupForMatch(faultTreeTrace, match); | ||
114 | if ((componentInstance_1 != null)) { | ||
115 | lookedUpComponents.put(pair.getKey(), componentInstance_1); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | _xblockexpression = lookedUpComponents; | ||
120 | } | ||
121 | return _xblockexpression; | ||
122 | } | ||
123 | |||
124 | private ComponentDefinition getComponentDefinition() { | ||
125 | ComponentInstance _componentInstance = this.mappingDefinition.getComponentInstance(); | ||
126 | ComponentDefinition _componentType = null; | ||
127 | if (_componentInstance!=null) { | ||
128 | _componentType=_componentInstance.getComponentType(); | ||
129 | } | ||
130 | return _componentType; | ||
131 | } | ||
132 | |||
133 | private boolean hasComponentInstace() { | ||
134 | ComponentDefinition _componentDefinition = this.getComponentDefinition(); | ||
135 | return (_componentDefinition != null); | ||
136 | } | ||
137 | |||
138 | private boolean isTopLevel() { | ||
139 | return this.mappingDefinition.isTopLevel(); | ||
140 | } | ||
141 | |||
142 | private boolean hasConnections() { | ||
143 | boolean _isEmpty = this.mappingDefinition.getAssignments().isEmpty(); | ||
144 | return (!_isEmpty); | ||
145 | } | ||
146 | } | ||