summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-08-15 03:07:23 (EDT)
committer Henrik Rentz-Reichert2012-08-15 03:07:23 (EDT)
commit1f7198e462bb7bff7a1221ce4d6deab7288a0e93 (patch)
treee8b86c9c2a0ca9be1be835560669dd46182294ec
parente9cf09877525d980f13ccf8537281467e2ecbd81 (diff)
downloadorg.eclipse.etrice-1f7198e462bb7bff7a1221ce4d6deab7288a0e93.zip
org.eclipse.etrice-1f7198e462bb7bff7a1221ce4d6deab7288a0e93.tar.gz
org.eclipse.etrice-1f7198e462bb7bff7a1221ce4d6deab7288a0e93.tar.bz2
[abstractexec] connected handled messages with their origin (DetailCode or Trigger)refs/changes/28/7228/1
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java11
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java18
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActiveRules.java13
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/HandledMessage.java41
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java40
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java25
6 files changed, 83 insertions, 65 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
index d449d9a..d9bfaa3 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
@@ -106,16 +106,7 @@ public class AbstractExecutionValidator implements IRoomValidator {
{
ProposalGenerator propGen = new ProposalGenerator(xpac,checker);
State st = (State) obj;
- boolean issueWarning = propGen.getProposals(st);
- if(issueWarning)
- {
- //handle the cases accordingly by retrieving the
- //warning list once clear what exactly is to be included in warnings
- }
- else
- {
- //if there are no warnings, then proposals should be generated
- }
+ propGen.createProposals(st, messageAcceptor);
}
}
if (traceExec)
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java
index ac47532..67c999b 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java
@@ -19,8 +19,6 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
import org.eclipse.etrice.generator.base.DetailCodeTranslator;
@@ -32,9 +30,9 @@ public class ActionCodeAnalyzer {
private class Collector extends DefaultTranslationProvider {
- private ArrayList<MessageFromIf> mifs = new ArrayList<MessageFromIf>();
+ private ArrayList<HandledMessage> mifs = new ArrayList<HandledMessage>();
- public ArrayList<MessageFromIf> getMifs() {
+ public ArrayList<HandledMessage> getMifs() {
return mifs;
}
@@ -45,10 +43,8 @@ public class ActionCodeAnalyzer {
public String getInterfaceItemMessageText(InterfaceItem item,
Message msg, ArrayList<String> args, String index, String orig) {
- MessageFromIf mif = RoomFactory.eINSTANCE.createMessageFromIf();
- mif.setFrom(item);
- mif.setMessage(msg);
- mifs.add(mif);
+ HandledMessage sm = new HandledMessage(item, msg, origin);
+ mifs.add(sm);
return orig;
}
@@ -63,19 +59,21 @@ public class ActionCodeAnalyzer {
// create a new list and leave previous unchanged
public void begin() {
- mifs = new ArrayList<MessageFromIf>();
+ mifs = new ArrayList<HandledMessage>();
}
}
private Collector collector;
private DetailCodeTranslator translator;
+ private DetailCode origin;
public ActionCodeAnalyzer(ActorClass ac) {
collector = new Collector();
translator = new DetailCodeTranslator(ac, collector);
}
- public List<MessageFromIf> analyze(DetailCode dc) {
+ public List<HandledMessage> analyze(DetailCode dc) {
+ origin = dc;
collector.begin();
translator.translateDetailCode(dc);
return collector.getMifs();
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 c12e673..f9f0af0 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
@@ -22,7 +22,6 @@ import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.room.GeneralProtocolClass;
import org.eclipse.etrice.core.room.InSemanticsRule;
import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.MessageFromIf;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SemanticsRule;
import org.eclipse.etrice.core.room.util.RoomHelpers;
@@ -44,7 +43,7 @@ public class ActiveRules {
}
}
- private static final int TRACE_RESULT = 1;
+ //private static final int TRACE_RESULT = 1;
private static final int TRACE_DETAILS = 2;
public ActiveRules() {
@@ -65,13 +64,13 @@ public class ActiveRules {
// checks for currently active rules against a message list and modifies the
// rules which can be merged with the destination node
- public void consumeMessages(List<MessageFromIf> msgList) {
- for (MessageFromIf msg : msgList) {
- List<SemanticsRule> localRules = rules.get(msg.getFrom());
+ public void consumeMessages(List<HandledMessage> msgList) {
+ for (HandledMessage msg : msgList) {
+ List<SemanticsRule> localRules = rules.get(msg.getIfitem());
if (localRules!=null) {
SemanticsRule match = null;
for (SemanticsRule rule : localRules) {
- if (rule.getMsg() == msg.getMessage()) {
+ if (rule.getMsg() == msg.getMsg()) {
match = rule;
break;
}
@@ -79,7 +78,7 @@ public class ActiveRules {
if (match!=null) {
if (traceRules && traceLevel>=TRACE_DETAILS)
- System.out.println(" found match for "+msg.getMessage().getName());
+ System.out.println(" found match for "+msg.getMsg().getName());
// discard all alternatives
localRules.clear();
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/HandledMessage.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/HandledMessage.java
new file mode 100644
index 0000000..00fc8db
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/HandledMessage.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.abstractexec.behavior;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+
+public class HandledMessage {
+ private InterfaceItem ifitem;
+ private Message msg;
+ private EObject origin;
+
+ public HandledMessage(InterfaceItem ifitem, Message msg, EObject origin) {
+ this.ifitem = ifitem;
+ this.msg = msg;
+ this.origin = origin;
+ }
+
+ public InterfaceItem getIfitem() {
+ return ifitem;
+ }
+
+ public Message getMsg() {
+ return msg;
+ }
+
+ public EObject getOrigin() {
+ return origin;
+ }
+} \ No newline at end of file
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 1b25434..ba51819 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
@@ -25,13 +25,14 @@ import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.SemanticsRule;
import org.eclipse.etrice.core.room.State;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.xtext.validation.ValidationMessageAcceptor;
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 List<ActiveTrigger> warningTrigger = new LinkedList<ActiveTrigger>();
private static boolean traceProposals = false;
static {
if (Activator.getDefault().isDebugging()) {
@@ -55,44 +56,43 @@ public class ProposalGenerator {
return outgoingProposal;
}
-// public List<ActiveTrigger> getWarningTriggers() {
-// return warningTrigger;
-// }
+ public List<ActiveTrigger> getWarningTriggers() {
+ return warningTrigger;
+ }
- public boolean getProposals(State st) {
+ public void createProposals(State st, ValidationMessageAcceptor messageAcceptor) {
ActiveRules rules = checker.getActiveRules(st);
// in case the state is disconnected component of the graph
if (rules == null)
- return false;
+ return;
- boolean issueWarning = false;
outgoingProposal.clear();
incomingProposal.clear();
xpac.getActiveTriggers(st);
Set<SemanticsRule> rulesToIgnore = new HashSet<SemanticsRule>();
for (ActiveTrigger trigger : xpac.getActiveTriggers(st)) {
+ SemanticsRule match = null;
Port port = (Port) trigger.getIfitem();
if (rules.getPortList().contains(port)) {
List<SemanticsRule> ruleList = rules.getRulesForPort(port);
for (SemanticsRule curRule : ruleList) {
- // mark this rule for ignoring while generating proposals
- // as they have already been taken care of
if (curRule.getMsg() == trigger.getMsg()) {
- rulesToIgnore.add(curRule);
+ match = curRule;
+ break;
}
- /*else {
- // issue a warning
- if (traceProposals) {
- System.out.println("Violation of rules with trigger msg : "
- + trigger.getMsg().getName());
- }
- issueWarning = true;
- warningTrigger.add(trigger);
- }*/
}
}
+ if (match!=null) {
+ // mark this rule for ignoring while generating proposals
+ // as they have already been taken care of
+ rulesToIgnore.add(match);
+ }
+ else {
+ // according to the rules this trigger isn't necessary
+ warningTrigger.add(trigger);
+ }
}
// now start generating proposals by listing all the rules and ignoring
@@ -126,8 +126,6 @@ public class ProposalGenerator {
System.out.println(" Incoming msg proposal : " + msg.getMessage().getName() + " from " + msg.getFrom().getName());
}
}
-
- return issueWarning;
}
}
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 146c324..b57d32c 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
@@ -23,8 +23,6 @@ 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.InitialTransition;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.State;
import org.eclipse.etrice.core.room.StateGraph;
import org.eclipse.etrice.core.room.StateGraphItem;
@@ -87,11 +85,9 @@ public class SemanticsCheck {
for (Transition trans : transitions)
if (trans instanceof InitialTransition) {
StateGraphNode cur = xpAct.getNode(trans.getTo());
- List<MessageFromIf> msgList = codeAnalyzer.analyze(trans
- .getAction());
+ List<HandledMessage> msgList = codeAnalyzer.analyze(trans.getAction());
if (cur instanceof State) {
- msgList.addAll(codeAnalyzer.analyze(((State) cur)
- .getEntryCode()));
+ msgList.addAll(codeAnalyzer.analyze(((State) cur).getEntryCode()));
}
localRules.consumeMessages(msgList);
boolean rulesChanged = false;
@@ -128,15 +124,12 @@ public class SemanticsCheck {
System.out.println(" Trigger: " + trigger.getMsg().getName());
}
- MessageFromIf mifTrig = RoomFactory.eINSTANCE.createMessageFromIf();
- mifTrig.setFrom(trigger.getIfitem());
- mifTrig.setMessage(trigger.getMsg());
for (Transition trans : trigger.getTransitions()) {
StateGraphNode target = xpAct.getNode(trans.getTo());
- List<MessageFromIf> msgList = new LinkedList<MessageFromIf>();
+ List<HandledMessage> msgList = new LinkedList<HandledMessage>();
// create a list of codes here in the order
// trigger, exit, action, entry
- msgList.add(mifTrig);
+ msgList.add(new HandledMessage(trigger.getIfitem(), trigger.getMsg(), trigger));
StateGraph triggerContext = (StateGraph) trans.eContainer();
State exitCalled = st;
while (true) {
@@ -154,8 +147,8 @@ public class SemanticsCheck {
if (traceChecks && traceLevel>=TRACE_DETAILS) {
System.out.println(" Messages in msglist before consuming: ");
- for (MessageFromIf msg : msgList) {
- System.out.println(" Msg: "+ msg.getMessage().getName());
+ for (HandledMessage msg : msgList) {
+ System.out.println(" Msg: "+ msg.getMsg().getName());
}
}
if (traceChecks && traceLevel>=TRACE_DETAILS) {
@@ -190,12 +183,10 @@ public class SemanticsCheck {
*/
for (Transition trans : xpAct.getOutgoingTransitions(node)) {
ActiveRules tempRule = mapToRules.get(node).createCopy();
- List<MessageFromIf> msgList = codeAnalyzer.analyze(trans
- .getAction());
+ List<HandledMessage> msgList = codeAnalyzer.analyze(trans.getAction());
StateGraphNode target = xpAct.getNode(trans.getTo());
if (target instanceof State) {
- msgList.addAll(codeAnalyzer.analyze(((State) target)
- .getEntryCode()));
+ msgList.addAll(codeAnalyzer.analyze(((State) target).getEntryCode()));
}
tempRule.consumeMessages(msgList);
addAndMergeRules(target, tempRule);