blob: 4a19e2cd26b3ec2f80eb494dff99e282d13fc668 (
plain) (
blame)
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
|
package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.AndGate
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.BasicEvent
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantDistribution
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Distribution
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ExponentialDistribution
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.KOfMGate
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.OrGate
import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent
import org.eclipse.xtend2.lib.StringConcatenationClient
class Ft2GalileoTransformation {
def toGalileo(FaultTree faultTree) '''
toplevel "«faultTree.topEvent.name»";
«FOR event : faultTree.events»
"«event.name»" «defineEvent(event)»;
«ENDFOR»
'''
protected dispatch def defineEvent(BasicEvent basicEvent) {
// ft-diet (https://moves.rwth-aachen.de/ft-diet/) needs a dormancy factor.
'''«defineDistribution(basicEvent.distribution)» dorm=0.0'''
}
protected dispatch def StringConcatenationClient defineDistribution(ConstantDistribution distribution) {
'''p=«distribution.p»'''
}
protected dispatch def StringConcatenationClient defineDistribution(ExponentialDistribution distribution) {
'''lambda=«distribution.lambda»'''
}
protected dispatch def StringConcatenationClient defineDistribution(Distribution distribution) {
throw new IllegalArgumentException("Unknown distribution: " + distribution)
}
protected dispatch def StringConcatenationClient defineEvent(Gate gate) {
'''«defineGate(gate)» «FOR input : gate.inputEvents SEPARATOR " "»"«input.name»"«ENDFOR»'''
}
protected dispatch def StringConcatenationClient defineGate(AndGate gate) '''and'''
protected dispatch def StringConcatenationClient defineGate(OrGate gate) '''or'''
protected dispatch def StringConcatenationClient defineGate(KOfMGate gate) '''«gate.k»of«gate.inputEvents.size»'''
protected dispatch def StringConcatenationClient defineGate(Gate gate) {
throw new IllegalArgumentException("Unknown gate: " + gate)
}
protected dispatch def StringConcatenationClient defineEvent(RandomEvent randomEvent) {
throw new IllegalArgumentException("Unknown random even: " + randomEvent)
}
}
|