| author | Rohit Agrawal | 2012-08-08 14:46:06 (EDT) |
|---|---|---|
| committer | Rohit Agrawal | 2012-08-08 14:46:06 (EDT) |
| commit | 1f8643ad8db6f76d085d4f60f7f7f45f3bd77614 (patch) (side-by-side diff) | |
| tree | 335ea42106c0929c83db83d5ea7da32b54e26440 | |
| parent | bc0a551d74fea7de6ea091106889ff8c89d3c809 (diff) | |
| download | org.eclipse.etrice-1f8643ad8db6f76d085d4f60f7f7f45f3bd77614.zip org.eclipse.etrice-1f8643ad8db6f76d085d4f60f7f7f45f3bd77614.tar.gz org.eclipse.etrice-1f8643ad8db6f76d085d4f60f7f7f45f3bd77614.tar.bz2 | |
[CQ6589] : Proposal Generator Class with changes and debugging optionrefs/changes/48/7148/1
added
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: I985a43c67a285f03288b5ae51f143bee062f75dd
6 files changed, 123 insertions, 39 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/.options b/plugins/org.eclipse.etrice.abstractexec.behavior/.options new file mode 100644 index 0000000..c00c227 --- a/dev/null +++ b/plugins/org.eclipse.etrice.abstractexec.behavior/.options @@ -0,0 +1 @@ +org.eclipse.etrice.abstractexec.behavior/trace/proposals=true
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF index 06bec06..b0af886 100644 --- a/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF @@ -1,14 +1,16 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Abstract Execution for State Machines -Bundle-SymbolicName: org.eclipse.etrice.abstractexec.behavior;singleton:=true -Bundle-Version: 0.2.0.qualifier -Bundle-Vendor: eTrice (Incubation) -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.2.0", - org.eclipse.etrice.core.room.ui;bundle-version="0.2.0", - org.eclipse.etrice.core.genmodel;bundle-version="0.2.0", - org.eclipse.etrice.generator;bundle-version="0.2.0", - org.eclipse.emf.ecore;bundle-version="2.7.0", - org.eclipse.xtext;bundle-version="2.1.1", - org.eclipse.xtext.ui;bundle-version="2.1.1" +Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Abstract Execution for State Machines
+Bundle-SymbolicName: org.eclipse.etrice.abstractexec.behavior;singleton:=true
+Bundle-Version: 0.2.0.qualifier
+Bundle-Vendor: eTrice (Incubation)
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.2.0",
+ org.eclipse.etrice.core.room.ui;bundle-version="0.2.0",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.2.0",
+ org.eclipse.etrice.generator;bundle-version="0.2.0",
+ org.eclipse.emf.ecore;bundle-version="2.7.0",
+ org.eclipse.xtext;bundle-version="2.1.1",
+ org.eclipse.xtext.ui;bundle-version="2.1.1"
+Bundle-Activator: org.eclipse.etrice.abstractexec.behavior.Activator
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties b/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties index 6f20375..6965d12 100644 --- a/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties +++ b/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties @@ -2,4 +2,5 @@ source.. = src/ output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ .options
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/Activator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/Activator.java new file mode 100644 index 0000000..860cc13 --- a/dev/null +++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/Activator.java @@ -0,0 +1,37 @@ +/*******************************************************************************
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Rohit Agrawal (initial contribution)
+ *
+ *******************************************************************************/
+package org.eclipse.etrice.abstractexec.behavior;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends AbstractUIPlugin implements BundleActivator {
+
+ private static Activator instance = null;
+
+ public static
+ Activator getDefault() {
+ return instance;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ instance = null;
+ super.stop(context);
+ }
+}
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 8b719d3..c2fc78e 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 @@ -44,10 +44,7 @@ public class ActiveRules { }
public EList<SemanticsRule> getRulesForPort(InterfaceItem port)
{
- if(rules.containsKey(port))
- return rules.get(port);
- else
- return null;
+ return rules.get(port);
}
//checks for currently active rules against a message list and modifies the
//rules which can be merged with the destination node
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 9bde5b0..846a73c 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 @@ -1,3 +1,13 @@ +/*******************************************************************************
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Rohit Agrawal (initial contribution)
+ *
+ *******************************************************************************/
package org.eclipse.etrice.abstractexec.behavior;
import java.util.HashSet;
@@ -5,12 +15,14 @@ import java.util.LinkedList; import java.util.List;
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;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.MessageFromIf;
import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.SemanticsRule;
import org.eclipse.etrice.core.room.State;
@@ -18,39 +30,61 @@ import org.eclipse.etrice.core.room.State; public class ProposalGenerator {
private ExpandedActorClass xpac ;
private SemanticsCheck checker;
+ private List<MessageFromIf> outgoingProposal = new LinkedList<MessageFromIf>();
+ private List<MessageFromIf> incomingProposal = new LinkedList<MessageFromIf>();
+ private List<ActiveTrigger> warningTrigger = new LinkedList<ActiveTrigger>();
+ 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 ProposalGenerator(ExpandedActorClass xp , SemanticsCheck chk)
{
xpac = xp;
checker = chk;
}
- public void getProposals(State st )
+ public List<MessageFromIf> getIncomingProposals()
+ {
+ return incomingProposal;
+ }
+ public List<MessageFromIf> getOutgoingProposals()
{
+ return outgoingProposal;
+ }
+ public List<ActiveTrigger> getWarningTriggers()
+ {
+ return warningTrigger;
+ }
+ public boolean getProposals(State st )
+ {
+ boolean issueWarning = false;
ActiveRules rules = checker.getActiveRules(st);
xpac.getActiveTriggers(st);
- List<MessageFromIf> outgoingProposal = new LinkedList<MessageFromIf>();
- List<MessageFromIf> incomingProposal = new LinkedList<MessageFromIf>();
+
Set<SemanticsRule> rulesToIgnore = new HashSet<SemanticsRule>();
for(ActiveTrigger trigger : xpac.getActiveTriggers(st))
{
- MessageFromIf mifTrig = RoomFactory.eINSTANCE.createMessageFromIf();
- mifTrig.setFrom(trigger.getIfitem());
- mifTrig.setMessage(trigger.getMsg());
- Port port = (Port) mifTrig.getFrom();
+ Port port = (Port) trigger.getIfitem();
if(rules.getPortList().contains(port))
{
EList<SemanticsRule> ruleList = rules.getRulesForPort(port);
- for(SemanticsRule curRules : ruleList)
+ for(SemanticsRule curRule : ruleList)
{
- if(curRules.getMsg()==mifTrig.getMessage())
- {
- //mark this rule for ignoring while generating proposals
- //as they have already been taken care of
- rulesToIgnore.add(curRules);
- }
- else
+ //mark this rule for ignoring while generating proposals
+ //as they have already been taken care of
+ rulesToIgnore.add(curRule);
+ if(!(curRule.getMsg()==trigger.getMsg()))
{
// issue a warning
- rulesToIgnore.add(curRules);
+ issueWarning= true;
+ warningTrigger.add(trigger);
}
}
}
@@ -66,19 +100,29 @@ public class ProposalGenerator { MessageFromIf mif = RoomFactory.eINSTANCE.createMessageFromIf();
mif.setFrom(item);
mif.setMessage(ruleToCheck.getMsg());
- if(((Port)item).isConjugated())
+ ProtocolClass pc = (ProtocolClass) ruleToCheck.getMsg().eContainer();
+ if(pc.getIncomingMessages().contains(ruleToCheck.getMsg()))
{
- incomingProposal.add(mif);
+ if(((Port)item).isConjugated())
+ outgoingProposal.add(mif);
+ else
+ incomingProposal.add(mif);
}
- else
+ else if (pc.getOutgoingMessages().contains(ruleToCheck.getMsg()))
{
- outgoingProposal.add(mif);
+ if(((Port)item).isConjugated())
+ incomingProposal.add(mif);
+ else
+ outgoingProposal.add(mif);
}
}
}
}
+ if(traceProposals)
+ {
System.out.println("Proposals for : " + st.getName());
+
for(MessageFromIf msg : outgoingProposal)
{
System.out.println("Outgoing msg proposal : " + msg.getMessage().getName());
@@ -87,6 +131,8 @@ public class ProposalGenerator { {
System.out.println("Incoming msg proposal : " + msg.getMessage().getName());
}
+ }
+ return issueWarning;
}
}
|

