diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo')
3 files changed, 182 insertions, 0 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.Ft2GalileoTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.Ft2GalileoTransformation.xtendbin new file mode 100644 index 00000000..9fe75a0f --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.Ft2GalileoTransformation.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.gitignore new file mode 100644 index 00000000..3f932890 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.gitignore | |||
@@ -0,0 +1 @@ | |||
/.Ft2GalileoTransformation.java._trace | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.java new file mode 100644 index 00000000..e900c62a --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.java | |||
@@ -0,0 +1,181 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.AndGate; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.BasicEvent; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantDistribution; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Distribution; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ExponentialDistribution; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.KOfMGate; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.OrGate; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
13 | import java.util.Arrays; | ||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
16 | import org.eclipse.xtend2.lib.StringConcatenationClient; | ||
17 | |||
18 | @SuppressWarnings("all") | ||
19 | public class Ft2GalileoTransformation { | ||
20 | public CharSequence toGalileo(final FaultTree faultTree) { | ||
21 | StringConcatenation _builder = new StringConcatenation(); | ||
22 | _builder.append("toplevel "); | ||
23 | String _name = faultTree.getTopEvent().getName(); | ||
24 | _builder.append(_name); | ||
25 | _builder.append(";"); | ||
26 | _builder.newLineIfNotEmpty(); | ||
27 | { | ||
28 | EList<RandomEvent> _events = faultTree.getEvents(); | ||
29 | for(final RandomEvent event : _events) { | ||
30 | String _name_1 = event.getName(); | ||
31 | _builder.append(_name_1); | ||
32 | _builder.append(" "); | ||
33 | StringConcatenationClient _defineEvent = this.defineEvent(event); | ||
34 | _builder.append(_defineEvent); | ||
35 | _builder.append(";"); | ||
36 | _builder.newLineIfNotEmpty(); | ||
37 | } | ||
38 | } | ||
39 | return _builder; | ||
40 | } | ||
41 | |||
42 | protected StringConcatenationClient _defineEvent(final BasicEvent basicEvent) { | ||
43 | return this.defineDistribution(basicEvent.getDistribution()); | ||
44 | } | ||
45 | |||
46 | protected StringConcatenationClient _defineDistribution(final ConstantDistribution distribution) { | ||
47 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
48 | @Override | ||
49 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
50 | _builder.append("p="); | ||
51 | double _p = distribution.getP(); | ||
52 | _builder.append(_p); | ||
53 | } | ||
54 | }; | ||
55 | return _client; | ||
56 | } | ||
57 | |||
58 | protected StringConcatenationClient _defineDistribution(final ExponentialDistribution distribution) { | ||
59 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
60 | @Override | ||
61 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
62 | _builder.append("lambda="); | ||
63 | double _lambda = distribution.getLambda(); | ||
64 | _builder.append(_lambda); | ||
65 | } | ||
66 | }; | ||
67 | return _client; | ||
68 | } | ||
69 | |||
70 | protected StringConcatenationClient _defineDistribution(final Distribution distribution) { | ||
71 | throw new IllegalArgumentException(("Unknown distribution: " + distribution)); | ||
72 | } | ||
73 | |||
74 | protected StringConcatenationClient _defineEvent(final Gate gate) { | ||
75 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
76 | @Override | ||
77 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
78 | StringConcatenationClient _defineGate = Ft2GalileoTransformation.this.defineGate(gate); | ||
79 | _builder.append(_defineGate); | ||
80 | _builder.append(" "); | ||
81 | { | ||
82 | EList<RandomEvent> _inputEvents = gate.getInputEvents(); | ||
83 | boolean _hasElements = false; | ||
84 | for(final RandomEvent input : _inputEvents) { | ||
85 | if (!_hasElements) { | ||
86 | _hasElements = true; | ||
87 | } else { | ||
88 | _builder.appendImmediate(" ", ""); | ||
89 | } | ||
90 | String _name = input.getName(); | ||
91 | _builder.append(_name); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | }; | ||
96 | return _client; | ||
97 | } | ||
98 | |||
99 | protected StringConcatenationClient _defineGate(final AndGate gate) { | ||
100 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
101 | @Override | ||
102 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
103 | _builder.append("and"); | ||
104 | } | ||
105 | }; | ||
106 | return _client; | ||
107 | } | ||
108 | |||
109 | protected StringConcatenationClient _defineGate(final OrGate gate) { | ||
110 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
111 | @Override | ||
112 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
113 | _builder.append("or"); | ||
114 | } | ||
115 | }; | ||
116 | return _client; | ||
117 | } | ||
118 | |||
119 | protected StringConcatenationClient _defineGate(final KOfMGate gate) { | ||
120 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
121 | @Override | ||
122 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
123 | int _k = gate.getK(); | ||
124 | _builder.append(_k); | ||
125 | _builder.append("of"); | ||
126 | int _size = gate.getInputEvents().size(); | ||
127 | _builder.append(_size); | ||
128 | } | ||
129 | }; | ||
130 | return _client; | ||
131 | } | ||
132 | |||
133 | protected StringConcatenationClient _defineGate(final Gate gate) { | ||
134 | throw new IllegalArgumentException(("Unknown gate: " + gate)); | ||
135 | } | ||
136 | |||
137 | protected StringConcatenationClient _defineEvent(final RandomEvent randomEvent) { | ||
138 | throw new IllegalArgumentException(("Unknown random even: " + randomEvent)); | ||
139 | } | ||
140 | |||
141 | protected StringConcatenationClient defineEvent(final RandomEvent basicEvent) { | ||
142 | if (basicEvent instanceof BasicEvent) { | ||
143 | return _defineEvent((BasicEvent)basicEvent); | ||
144 | } else if (basicEvent instanceof Gate) { | ||
145 | return _defineEvent((Gate)basicEvent); | ||
146 | } else if (basicEvent != null) { | ||
147 | return _defineEvent(basicEvent); | ||
148 | } else { | ||
149 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
150 | Arrays.<Object>asList(basicEvent).toString()); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | protected StringConcatenationClient defineDistribution(final Distribution distribution) { | ||
155 | if (distribution instanceof ConstantDistribution) { | ||
156 | return _defineDistribution((ConstantDistribution)distribution); | ||
157 | } else if (distribution instanceof ExponentialDistribution) { | ||
158 | return _defineDistribution((ExponentialDistribution)distribution); | ||
159 | } else if (distribution != null) { | ||
160 | return _defineDistribution(distribution); | ||
161 | } else { | ||
162 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
163 | Arrays.<Object>asList(distribution).toString()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | protected StringConcatenationClient defineGate(final Gate gate) { | ||
168 | if (gate instanceof AndGate) { | ||
169 | return _defineGate((AndGate)gate); | ||
170 | } else if (gate instanceof KOfMGate) { | ||
171 | return _defineGate((KOfMGate)gate); | ||
172 | } else if (gate instanceof OrGate) { | ||
173 | return _defineGate((OrGate)gate); | ||
174 | } else if (gate != null) { | ||
175 | return _defineGate(gate); | ||
176 | } else { | ||
177 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
178 | Arrays.<Object>asList(gate).toString()); | ||
179 | } | ||
180 | } | ||
181 | } | ||