summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohit Agrawal2012-08-09 17:45:52 (EDT)
committerRohit Agrawal2012-08-09 17:45:52 (EDT)
commit7c4cf98eca44aaff0987a4f45b8b95bb2f002e37 (patch)
tree762e5c22e454f6c94298322775229f51df01761c
parent80c9ca65def943dd032476745e9a52ca42bb889c (diff)
downloadorg.eclipse.etrice-7c4cf98eca44aaff0987a4f45b8b95bb2f002e37.zip
org.eclipse.etrice-7c4cf98eca44aaff0987a4f45b8b95bb2f002e37.tar.gz
org.eclipse.etrice-7c4cf98eca44aaff0987a4f45b8b95bb2f002e37.tar.bz2
[CQ6589] : Complete with proposal generation after multiple case tests.refs/changes/77/7177/1
1. I authored 100% of the content I contributed 2. I have the rights to donate the content to Eclipse 3. I contribute the content under the EPL Change-Id: Ifb54b0e9b272b9498efc03c7e815477ec059e035
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActiveRules.java34
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java11
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java39
3 files changed, 81 insertions, 3 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActiveRules.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActiveRules.java
index ea00711..79be256 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActiveRules.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActiveRules.java
@@ -17,6 +17,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
@@ -29,7 +30,18 @@ import org.eclipse.etrice.core.room.util.RoomHelpers;
public class ActiveRules {
private HashMap<InterfaceItem, EList<SemanticsRule>> rules ;
-
+ private static boolean traceProposals = false;
+ static
+ {
+ if (Activator.getDefault().isDebugging())
+ {
+ String value = Platform.getDebugOption("org.eclipse.etrice.abstractexec.behavior/trace/proposals");
+ if (value!=null && value.equalsIgnoreCase(Boolean.toString(true)))
+ {
+ traceProposals = true;
+ }
+ }
+}
public ActiveRules()
{
rules= new HashMap<InterfaceItem, EList<SemanticsRule>>();
@@ -88,11 +100,21 @@ public class ActiveRules {
{
for(SemanticsRule rule : ar.rules.get(port))
{
+ if(this.rules.containsKey(port))
+ {
if(!this.rules.get(port).contains(rule))
{
this.rules.get(port).add(rule);
added_at_least_one = true;
}
+ }
+ else
+ {
+ EList<SemanticsRule> tempList = new BasicEList<SemanticsRule>();
+ tempList.add(rule);
+ this.rules.put(port, tempList);
+ added_at_least_one = true;
+ }
}
}
return added_at_least_one;
@@ -121,10 +143,20 @@ public class ActiveRules {
follow.addAll(rule.getFollowUps());
//added for removal so it can be replaced the followUp rules
toRemove.add(rule);
+ if(traceProposals)
+ {
+ System.out.println("Rule fulfilled by msg : " + msg.getMessage().getName());
+ System.out.println("Rule being removed : " + rule.getMsg().getName());
+ }
}
else
{
//add the rule for removing since it is violated by the current msg
+ if(traceProposals)
+ {
+ System.out.println("Rule violated by msg : " + msg.getMessage().getName());
+ System.out.println("Rule being removed : " + rule.getMsg().getName());
+ }
toRemove.add(rule);
}
}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java
index 13fb5a4..207e56d 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java
@@ -82,10 +82,17 @@ public class ProposalGenerator {
{
//mark this rule for ignoring while generating proposals
//as they have already been taken care of
- rulesToIgnore.add(curRule);
- if(!(curRule.getMsg()==trigger.getMsg()))
+ if(curRule.getMsg()==trigger.getMsg())
+ {
+ rulesToIgnore.add(curRule);
+ }
+ else
{
// issue a warning
+ if(traceProposals)
+ {
+ System.out.println("Violation of rules with trigger msg : " + trigger.getMsg().getName());
+ }
issueWarning= true;
warningTrigger.add(trigger);
}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java
index 0e9c613..7258a9d 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Queue;
import java.util.Set;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.genmodel.etricegen.ActiveTrigger;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
@@ -37,6 +38,18 @@ public class SemanticsCheck {
private ExpandedActorClass xpAct;
private HashMap<StateGraphItem, ActiveRules> mapToRules = new HashMap<StateGraphItem, ActiveRules>();
private ActionCodeAnalyzer codeAnalyzer;
+ private static boolean traceProposals = false;
+ static
+ {
+ if (Activator.getDefault().isDebugging())
+ {
+ String value = Platform.getDebugOption("org.eclipse.etrice.abstractexec.behavior/trace/proposals");
+ if (value!=null && value.equalsIgnoreCase(Boolean.toString(true)))
+ {
+ traceProposals = true;
+ }
+ }
+}
public SemanticsCheck (ExpandedActorClass xpac) {
queue= new LinkedList<StateGraphNode>();
xpAct = xpac;
@@ -101,6 +114,11 @@ public class SemanticsCheck {
{
for(ActiveTrigger trigger : xpAct.getActiveTriggers(st))
{
+ if(traceProposals)
+ {
+ System.out.println("Currently visiting : " + st.getName());
+ System.out.println("Trigger : " + trigger.getMsg().getName());
+ }
MessageFromIf mifTrig = RoomFactory.eINSTANCE.createMessageFromIf();
mifTrig.setFrom(trigger.getIfitem());
mifTrig.setMessage(trigger.getMsg());
@@ -126,8 +144,29 @@ public class SemanticsCheck {
msgList.addAll(codeAnalyzer.analyze(((State) target).getEntryCode()));
}
ActiveRules tempRule = mapToRules.get(node).createCopy();
+ if(traceProposals)
+ {
+ System.out.println("Messages in msglist before consuming: ");
+ for(MessageFromIf msg : msgList)
+ {
+ System.out.println("Msg : " + msg.getMessage().getName());
+ }
+ }
+ if(traceProposals)
+ {
+ System.out.println("rules before consuming message list : ");
+ printRules();
+ }
tempRule.consumeMessages(msgList);
+ if(traceProposals)
+ System.out.println("Messages consumed");
addAndMergeRules( target, tempRule);
+ if(traceProposals)
+ {
+ System.out.println("rules after consuming and merging message list : ");
+ printRules();
+ }
+
}
}
}