summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-03-04 09:08:02 (EST)
committer Juergen Haug2013-03-04 09:48:43 (EST)
commit21daa0d85fda2895ce24bc43d3a6f8f8ca16ffd4 (patch)
treecbeef6efaf9a3e08b3cdf59a971ff6e4d3e4bdc7
parente1112e3a38570ceafacada8df981895aab48fd05 (diff)
downloadorg.eclipse.etrice-21daa0d85fda2895ce24bc43d3a6f8f8ca16ffd4.zip
org.eclipse.etrice-21daa0d85fda2895ce24bc43d3a6f8f8ca16ffd4.tar.gz
org.eclipse.etrice-21daa0d85fda2895ce24bc43d3a6f8f8ca16ffd4.tar.bz2
[abstractExec] (Bug 402267) reachability check produces false negativesrefs/changes/18/10818/2
for data driven state machines Change-Id: Iac26413a55f7d4d088b26d97fd2b61744038d175
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java66
1 files changed, 31 insertions, 35 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java
index 43c1c91..a44085f 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.genmodel.etricegen.ActiveTrigger;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.room.EntryPoint;
+import org.eclipse.etrice.core.room.GuardedTransition;
import org.eclipse.etrice.core.room.InitialTransition;
import org.eclipse.etrice.core.room.State;
import org.eclipse.etrice.core.room.StateGraph;
@@ -29,19 +30,25 @@ import org.eclipse.etrice.core.room.StateGraphNode;
import org.eclipse.etrice.core.room.TrPoint;
import org.eclipse.etrice.core.room.Transition;
import org.eclipse.etrice.core.room.TransitionPoint;
+import org.eclipse.etrice.core.room.TriggeredTransition;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
public class ReachabilityCheck {
+
+ private static RoomExtensions roomExt;
+
Queue<StateGraphNode> queue;
public Set<StateGraphItem> visited;
private ExpandedActorClass xpAct;
- private Set<StateGraphItem> exitUsed;
+ //private Set<StateGraphItem> exitUsed;
public ReachabilityCheck(ExpandedActorClass xpac) {
+ roomExt = new RoomExtensions();
queue = new LinkedList<StateGraphNode>();
xpAct = xpac;
visited = new HashSet<StateGraphItem>();
- exitUsed = new HashSet<StateGraphItem>();
+ //exitUsed = new HashSet<StateGraphItem>();
}
public void computeReachability() {
@@ -51,7 +58,6 @@ public class ReachabilityCheck {
}
private void addStartingPoints(StateGraph graph, boolean add_initial) {
-
EList<Transition> transitions = graph.getTransitions();
EList<TrPoint> trPoint = graph.getTrPoints();
if (add_initial)
@@ -68,53 +74,42 @@ public class ReachabilityCheck {
queue.add(tp);
}
}
-
- // add transition points
}
private void doTraversal() {
while (!queue.isEmpty()) {
StateGraphNode node = queue.poll();
if (!visited.contains(node))
- Visit(node);
+ visit(node);
// System.out.println("Visited node : " + node.getName());
}
}
- public boolean isExitUsed(StateGraphItem item) {
- return exitUsed.contains(item);
- }
+// public boolean isExitUsed(StateGraphItem item) {
+// return exitUsed.contains(item);
+// }
public boolean isReachable(StateGraphItem item) {
return visited.contains(item);
}
- private void Visit(StateGraphNode node) {
+ private void visit(StateGraphNode node) {
visited.add(node);
if (node instanceof State) {
State st = (State) node;
if (RoomHelpers.hasDirectSubStructure(st)) {
addStartingPoints(st.getSubgraph(), true);
} else {
+ // visit outgoing triggered transitions
for (ActiveTrigger trigger : xpAct.getActiveTriggers(st)) {
- for (Transition trans : trigger.getTransitions()) {
- visited.add(trans);
- StateGraphNode target = RoomHelpers.getNode(trans.getTo());
- if (!visited.contains(target)) {
- queue.add(target);
- StateGraph triggerContext = (StateGraph) trans
- .eContainer();
- State exitCalled = st;
- while (true) {
- exitUsed.add(exitCalled);
- if (exitCalled.eContainer() == triggerContext)
- break;
- exitCalled = (State) exitCalled.eContainer()
- .eContainer();
- }
- }
- }
+ for (TriggeredTransition trans : trigger.getTransitions())
+ visit(trans);
+ }
+ // visit outgoing guarded transitions
+ for(Transition trans : roomExt.getOutgoingTransitionsHierarchical(xpAct, st)){
+ if(trans instanceof GuardedTransition)
+ visit(trans);
}
}
} else {
@@ -129,16 +124,17 @@ public class ReachabilityCheck {
if (markVisited)
visited.add(container);
}
- for (Transition trans : xpAct.getOutgoingTransitions(node)) {
- visited.add(trans);
- StateGraphNode target = RoomHelpers.getNode(trans.getTo());
- if (!visited.contains(target)) {
- queue.add(target);
-
- }
- }
+ for (Transition trans : xpAct.getOutgoingTransitions(node))
+ visit(trans);
}
}
+
+ private void visit(Transition trans){
+ visited.add(trans);
+ StateGraphNode target = RoomHelpers.getNode(trans.getTo());
+ if (!visited.contains(target))
+ queue.add(target);
+ }
}