diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit')
6 files changed, 51 insertions, 20 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend index c9aefe51..6b3ed0d0 100644 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend | |||
@@ -17,6 +17,8 @@ import java.util.Map | |||
17 | import org.eclipse.emf.ecore.util.EcoreUtil | 17 | import org.eclipse.emf.ecore.util.EcoreUtil |
18 | import org.eclipse.xtend.lib.annotations.Data | 18 | import org.eclipse.xtend.lib.annotations.Data |
19 | 19 | ||
20 | import static extension hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions.* | ||
21 | |||
20 | class EventMaterializer { | 22 | class EventMaterializer { |
21 | extension val FtFactory = FtFactory.eINSTANCE | 23 | extension val FtFactory = FtFactory.eINSTANCE |
22 | 24 | ||
@@ -169,8 +171,10 @@ class EventMaterializer { | |||
169 | val input = findInput(component, inputEvent) | 171 | val input = findInput(component, inputEvent) |
170 | val builder = EventCollection.builder | 172 | val builder = EventCollection.builder |
171 | for (connection : input.incomingConnections) { | 173 | for (connection : input.incomingConnections) { |
172 | val materializedEvent = getOrMaterialize(connection.output) | 174 | if (connection.isCurrentlyConnected) { |
173 | builder.add(materializedEvent) | 175 | val materializedEvent = getOrMaterialize(connection.output) |
176 | builder.add(materializedEvent) | ||
177 | } | ||
174 | } | 178 | } |
175 | builder.build | 179 | builder.build |
176 | } | 180 | } |
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend index 7a3e377b..10c91fb4 100644 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend | |||
@@ -2,6 +2,7 @@ package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | |||
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory | 3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory |
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | 4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition |
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
5 | import java.util.Map | 6 | import java.util.Map |
6 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 7 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
7 | import org.eclipse.xtend.lib.annotations.Accessors | 8 | import org.eclipse.xtend.lib.annotations.Accessors |
@@ -13,10 +14,16 @@ class ComponentFaultTreeTrace { | |||
13 | val Map<IPatternMatch, ComponentInstanceTrace> componentInstancesMap = newHashMap | 14 | val Map<IPatternMatch, ComponentInstanceTrace> componentInstancesMap = newHashMap |
14 | 15 | ||
15 | def instantiateComponent(IPatternMatch patternMatch, ComponentDefinition componenDefinition) { | 16 | def instantiateComponent(IPatternMatch patternMatch, ComponentDefinition componenDefinition) { |
17 | instantiateComponent(patternMatch, componenDefinition, Modality.MUST, false) | ||
18 | } | ||
19 | |||
20 | def instantiateComponent(IPatternMatch patternMatch, ComponentDefinition componenDefinition, Modality exists, | ||
21 | boolean allowMultiple) { | ||
16 | if (componentInstancesMap.containsKey(patternMatch)) { | 22 | if (componentInstancesMap.containsKey(patternMatch)) { |
17 | throw new IllegalArgumentException("Already instantiated component for match: " + patternMatch) | 23 | throw new IllegalArgumentException("Already instantiated component for match: " + patternMatch) |
18 | } | 24 | } |
19 | val componentTrace = new ComponentInstanceTrace(componentFaultTree, componenDefinition, nameGenerator) | 25 | val componentTrace = new ComponentInstanceTrace(componentFaultTree, componenDefinition, nameGenerator, |
26 | exists, allowMultiple) | ||
20 | componentInstancesMap.put(patternMatch, componentTrace) | 27 | componentInstancesMap.put(patternMatch, componentTrace) |
21 | componentTrace | 28 | componentTrace |
22 | } | 29 | } |
@@ -30,6 +37,9 @@ class ComponentFaultTreeTrace { | |||
30 | throw new IllegalArgumentException("Top level component must have 1 output, got " + outputs.size + | 37 | throw new IllegalArgumentException("Top level component must have 1 output, got " + outputs.size + |
31 | " instead") | 38 | " instead") |
32 | } | 39 | } |
40 | if (!trace.appearsExactlyOnce) { | ||
41 | throw new IllegalArgumentException("Top level must appear in the fault tree exactly once") | ||
42 | } | ||
33 | componentFaultTree.topEvent = outputs.head | 43 | componentFaultTree.topEvent = outputs.head |
34 | } | 44 | } |
35 | 45 | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend index 7353bfe5..158ab2e1 100644 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend | |||
@@ -6,18 +6,23 @@ import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | |||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree | 6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree |
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration | 7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration |
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent | 8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent |
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output | 10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output |
10 | import java.util.Map | 11 | import java.util.Map |
11 | 12 | ||
13 | import static extension hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions.* | ||
14 | |||
12 | class ComponentInstanceTrace { | 15 | class ComponentInstanceTrace { |
13 | val componentInstance = CftFactory.eINSTANCE.createComponent | 16 | val componentInstance = CftFactory.eINSTANCE.createComponent |
14 | val Map<InputEvent, InputTrace> inputEventsMap | 17 | val Map<InputEvent, InputTrace> inputEventsMap |
15 | val Map<EventDeclaration, Output> outputEventsMap | 18 | val Map<EventDeclaration, Output> outputEventsMap |
16 | 19 | ||
17 | protected new(ComponentFaultTree faultTree, ComponentDefinition componentDefinition, | 20 | protected new(ComponentFaultTree faultTree, ComponentDefinition componentDefinition, |
18 | ComponentNameGenerator nameGenerator) { | 21 | ComponentNameGenerator nameGenerator, Modality exists, boolean multipleAllowed) { |
19 | componentInstance.componentDefinition = componentDefinition | 22 | componentInstance.componentDefinition = componentDefinition |
20 | componentInstance.name = nameGenerator.nextName(componentDefinition) | 23 | componentInstance.name = nameGenerator.nextName(componentDefinition) |
24 | componentInstance.exists = exists | ||
25 | componentInstance.multipleAllowed = multipleAllowed | ||
21 | inputEventsMap = Maps.newHashMapWithExpectedSize(componentDefinition.inputEvents.size) | 26 | inputEventsMap = Maps.newHashMapWithExpectedSize(componentDefinition.inputEvents.size) |
22 | for (inputEvent : componentDefinition.inputEvents) { | 27 | for (inputEvent : componentDefinition.inputEvents) { |
23 | val inputTrace = new InputTrace(componentInstance, inputEvent) | 28 | val inputTrace = new InputTrace(componentInstance, inputEvent) |
@@ -34,6 +39,11 @@ class ComponentInstanceTrace { | |||
34 | } | 39 | } |
35 | 40 | ||
36 | def void assign(EventDeclaration inputEvent, ComponentInstanceTrace sourceComponent, EventDeclaration outputEvent) { | 41 | def void assign(EventDeclaration inputEvent, ComponentInstanceTrace sourceComponent, EventDeclaration outputEvent) { |
42 | assign(inputEvent, sourceComponent, outputEvent, Modality.MUST) | ||
43 | } | ||
44 | |||
45 | def void assign(EventDeclaration inputEvent, ComponentInstanceTrace sourceComponent, EventDeclaration outputEvent, | ||
46 | Modality exists) { | ||
37 | val inputTrace = inputEventsMap.get(inputEvent) | 47 | val inputTrace = inputEventsMap.get(inputEvent) |
38 | if (inputTrace === null) { | 48 | if (inputTrace === null) { |
39 | throw new IllegalArgumentException("Unknown input: " + inputEvent) | 49 | throw new IllegalArgumentException("Unknown input: " + inputEvent) |
@@ -42,10 +52,14 @@ class ComponentInstanceTrace { | |||
42 | if (output === null) { | 52 | if (output === null) { |
43 | throw new IllegalArgumentException("Unknown output: " + outputEvent) | 53 | throw new IllegalArgumentException("Unknown output: " + outputEvent) |
44 | } | 54 | } |
45 | inputTrace.assign(output) | 55 | inputTrace.assign(output, exists) |
46 | } | 56 | } |
47 | 57 | ||
48 | protected def getOutputs() { | 58 | protected def getOutputs() { |
49 | componentInstance.outputs | 59 | componentInstance.outputs |
50 | } | 60 | } |
61 | |||
62 | protected def appearsExactlyOnce() { | ||
63 | componentInstance.appearsExactlyOnce | ||
64 | } | ||
51 | } | 65 | } |
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend index c529a09b..b892eff1 100644 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend | |||
@@ -5,9 +5,12 @@ import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component | |||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection | 5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection |
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input | 6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input |
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent | 7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent |
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output | 9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output |
9 | import java.util.Map | 10 | import java.util.Map |
10 | 11 | ||
12 | import static extension hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions.* | ||
13 | |||
11 | class InputTrace { | 14 | class InputTrace { |
12 | val Input input = CftFactory.eINSTANCE.createInput | 15 | val Input input = CftFactory.eINSTANCE.createInput |
13 | val Map<Output, Connection> connectionsMap = newHashMap | 16 | val Map<Output, Connection> connectionsMap = newHashMap |
@@ -17,13 +20,16 @@ class InputTrace { | |||
17 | component.inputs += input | 20 | component.inputs += input |
18 | } | 21 | } |
19 | 22 | ||
20 | def void assign(Output output) { | 23 | def void assign(Output output, Modality exists) { |
21 | val connection = connectionsMap.get(output) | 24 | val connection = connectionsMap.get(output) |
22 | if (connection === null) { | 25 | if (connection === null) { |
23 | val newConnection = CftFactory.eINSTANCE.createConnection | 26 | val newConnection = CftFactory.eINSTANCE.createConnection |
24 | newConnection.output = output | 27 | newConnection.output = output |
28 | newConnection.exists = exists | ||
25 | input.incomingConnections += newConnection | 29 | input.incomingConnections += newConnection |
26 | connectionsMap.put(output, newConnection) | 30 | connectionsMap.put(output, newConnection) |
31 | } else if (exists.isMoreConcreteThan(connection.exists)) { | ||
32 | connection.exists = exists | ||
27 | } | 33 | } |
28 | } | 34 | } |
29 | } | 35 | } |
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend index 732d9fed..4a19e2cd 100644 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend | |||
@@ -14,14 +14,15 @@ import org.eclipse.xtend2.lib.StringConcatenationClient | |||
14 | 14 | ||
15 | class Ft2GalileoTransformation { | 15 | class Ft2GalileoTransformation { |
16 | def toGalileo(FaultTree faultTree) ''' | 16 | def toGalileo(FaultTree faultTree) ''' |
17 | toplevel «faultTree.topEvent.name»; | 17 | toplevel "«faultTree.topEvent.name»"; |
18 | «FOR event : faultTree.events» | 18 | «FOR event : faultTree.events» |
19 | «event.name» «defineEvent(event)»; | 19 | "«event.name»" «defineEvent(event)»; |
20 | «ENDFOR» | 20 | «ENDFOR» |
21 | ''' | 21 | ''' |
22 | 22 | ||
23 | protected dispatch def defineEvent(BasicEvent basicEvent) { | 23 | protected dispatch def defineEvent(BasicEvent basicEvent) { |
24 | defineDistribution(basicEvent.distribution) | 24 | // ft-diet (https://moves.rwth-aachen.de/ft-diet/) needs a dormancy factor. |
25 | '''«defineDistribution(basicEvent.distribution)» dorm=0.0''' | ||
25 | } | 26 | } |
26 | 27 | ||
27 | protected dispatch def StringConcatenationClient defineDistribution(ConstantDistribution distribution) { | 28 | protected dispatch def StringConcatenationClient defineDistribution(ConstantDistribution distribution) { |
@@ -37,7 +38,7 @@ class Ft2GalileoTransformation { | |||
37 | } | 38 | } |
38 | 39 | ||
39 | protected dispatch def StringConcatenationClient defineEvent(Gate gate) { | 40 | protected dispatch def StringConcatenationClient defineEvent(Gate gate) { |
40 | '''«defineGate(gate)» «FOR input : gate.inputEvents SEPARATOR " "»«input.name»«ENDFOR»''' | 41 | '''«defineGate(gate)» «FOR input : gate.inputEvents SEPARATOR " "»"«input.name»"«ENDFOR»''' |
41 | } | 42 | } |
42 | 43 | ||
43 | protected dispatch def StringConcatenationClient defineGate(AndGate gate) '''and''' | 44 | protected dispatch def StringConcatenationClient defineGate(AndGate gate) '''and''' |
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend index 91c6a0d0..a250a955 100644 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend | |||
@@ -8,8 +8,6 @@ import java.io.IOException | |||
8 | import java.io.InputStream | 8 | import java.io.InputStream |
9 | import java.io.InputStreamReader | 9 | import java.io.InputStreamReader |
10 | import java.util.regex.Pattern | 10 | import java.util.regex.Pattern |
11 | import jnr.constants.platform.Signal | ||
12 | import org.apache.commons.lang.SystemUtils | ||
13 | 11 | ||
14 | class StormDftException extends RuntimeException { | 12 | class StormDftException extends RuntimeException { |
15 | new(String s) { | 13 | new(String s) { |
@@ -29,8 +27,9 @@ class StormDftHandler { | |||
29 | static val RESULT_REGEX = '''^Result:\s*\[(?:(?<«SINGLE_RESULT_GROUP»>«DOUBLE_REGEX»)|\((?<«LOWER_BOUND_GROUP»>«DOUBLE_REGEX»),\s*(?<«UPPER_BOUND_GROUP»>«DOUBLE_REGEX»)\))\]''' | 27 | static val RESULT_REGEX = '''^Result:\s*\[(?:(?<«SINGLE_RESULT_GROUP»>«DOUBLE_REGEX»)|\((?<«LOWER_BOUND_GROUP»>«DOUBLE_REGEX»),\s*(?<«UPPER_BOUND_GROUP»>«DOUBLE_REGEX»)\))\]''' |
30 | static val RESULT_PATTERN = Pattern.compile(RESULT_REGEX) | 28 | static val RESULT_PATTERN = Pattern.compile(RESULT_REGEX) |
31 | 29 | ||
32 | // See http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/jdk7-b147/src/solaris/native/java/lang/UNIXProcess_md.c#l332 | 30 | static val SIGNAL_EXIT_VALUE_OFFSET = 0x80 |
33 | static val SIGNAL_EXIT_VALUE_OFFSET = if(SystemUtils.IS_OS_SOLARIS) 0 else 0x80 | 31 | static val SIGXCPU = 24 |
32 | static val SIGXFSZ = 25 | ||
34 | 33 | ||
35 | static val STORM_GENERAL_ERROR = (-1).bitwiseAnd(0xff) | 34 | static val STORM_GENERAL_ERROR = (-1).bitwiseAnd(0xff) |
36 | static val STORM_TIMEOUT = (-2).bitwiseAnd(0xff) | 35 | static val STORM_TIMEOUT = (-2).bitwiseAnd(0xff) |
@@ -166,18 +165,15 @@ class StormDftHandler { | |||
166 | case STORM_GENERAL_ERROR: | 165 | case STORM_GENERAL_ERROR: |
167 | throw new StormDftException("Storm error: " + error) | 166 | throw new StormDftException("Storm error: " + error) |
168 | case STORM_TIMEOUT, | 167 | case STORM_TIMEOUT, |
169 | case SIGNAL_EXIT_VALUE_OFFSET + Signal.SIGXCPU.intValue: | 168 | case SIGNAL_EXIT_VALUE_OFFSET + SIGXCPU: |
170 | ReliabilityResult.TIMEOUT | 169 | ReliabilityResult.TIMEOUT |
171 | case STORM_MEMOUT, | 170 | case STORM_MEMOUT, |
172 | case SIGNAL_EXIT_VALUE_OFFSET + Signal.SIGXFSZ.intValue: | 171 | case SIGNAL_EXIT_VALUE_OFFSET + SIGXFSZ: |
173 | ReliabilityResult.MEMOUT | 172 | ReliabilityResult.MEMOUT |
174 | default: { | 173 | default: { |
175 | if (exitValue > SIGNAL_EXIT_VALUE_OFFSET) { | 174 | if (exitValue > SIGNAL_EXIT_VALUE_OFFSET) { |
176 | val signalNumber = exitValue - SIGNAL_EXIT_VALUE_OFFSET | 175 | val signalNumber = exitValue - SIGNAL_EXIT_VALUE_OFFSET |
177 | val signal = Signal.values.findFirst[intValue == signalNumber] | 176 | throw new StormDftException("Storm unexpectedly killed by signal " + signalNumber + ": " + error) |
178 | if (signal !== null) { | ||
179 | throw new StormDftException("Storm unexpectedly killed by signal " + signal + ": " + error) | ||
180 | } | ||
181 | } | 177 | } |
182 | throw new StormDftException("Storm unexpectedly exit with status " + exitValue + ": " + error) | 178 | throw new StormDftException("Storm unexpectedly exit with status " + exitValue + ": " + error) |
183 | } | 179 | } |