Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java17
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend60
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java11
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java161
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend64
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java87
9 files changed, 304 insertions, 104 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
index f611161a6..10fcfe3d2 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
@@ -100,6 +100,23 @@ public class RoomHelpers extends FSMHelpers {
/**
* Compute a list of the class itself and its base classes in reverse order (super classes to sub classes)
*
+ * @param pc the {@link ProtocolClass}
+ * @return a list of the class itself and its base classes in reverse order (super classes to sub classes)
+ */
+ public List<ProtocolClass> getClassHierarchy(ProtocolClass pc) {
+ ArrayList<ProtocolClass> result = new ArrayList<ProtocolClass>();
+
+ while (pc!=null) {
+ result.add(0, pc);
+ pc = pc.getBase();
+ }
+
+ return result;
+ }
+
+ /**
+ * Compute a list of the class itself and its base classes in reverse order (super classes to sub classes)
+ *
* @param dc the {@link DataClass}
* @return a list of the class itself and its base classes in reverse order (super classes to sub classes)
*/
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index e27d01a2f..4639c8f7e 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -353,6 +353,10 @@ class CExtensions implements ILanguageExtension {
"\""+(rc.eContainer as RoomModel).name.replaceAll("\\.","/")+"/"+rc.getCHeaderFileName+"\""
}
+ def getUtilsIncludePath(RoomClass rc) {
+ "\""+(rc.eContainer as RoomModel).name.replaceAll("\\.","/")+"/"+rc.getCUtilsFileName+"\""
+ }
+
override getTargetType(EnumerationType type) {
if (type.getPrimitiveType()!=null)
type.getPrimitiveType().getTargetName()
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index 4cb4b94c7..f792caed0 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -124,7 +124,12 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
*/
«generateIncludeGuardBegin(filename)»
-
+
+ «IF pc.base!=null»
+ // include base class utils
+ #include «pc.base.utilsIncludePath»
+
+ «ENDIF»
#include «pc.includePath»
/*
@@ -199,24 +204,25 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
var portClassName = pc.getPortClassName(conj)
var replPortClassName = pc.getPortClassName(conj, true)
var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
+ val allPortClasses = pc.getAllPortClasses(conj)
+ val allAttributes = allPortClasses.map[p|p.attributes].flatten.toList
+ val allOperations = allPortClasses.map[p|p.operations].flatten.toList
'''
typedef etPort «portClassName»;
typedef etReplPort «replPortClassName»;
- «IF pc.getPortClass(conj)!=null»
- «IF !(pc.getPortClass(conj).attributes.empty)»
- /* variable part of PortClass (RAM) */
- typedef struct «portClassName»_var «portClassName»_var;
- struct «portClassName»_var {
- «pc.getPortClass(conj).attributes.attributes»
- };
- «FOR a:pc.getPortClass(conj).attributes»
- «IF a.defaultValueLiteral!=null»
- «logger.logInfo(portClassName+" "+a.name+": Attribute initialization not supported in C")»
- «ENDIF»
- «ENDFOR»
- «ENDIF»
+ «IF !(allAttributes.empty)»
+ /* variable part of PortClass (RAM) */
+ typedef struct «portClassName»_var «portClassName»_var;
+ struct «portClassName»_var {
+ «allAttributes.attributes»
+ };
+ «FOR a:allAttributes»
+ «IF a.defaultValueLiteral!=null»
+ «logger.logInfo(portClassName+" "+a.name+": Attribute initialization not supported in C")»
+ «ENDIF»
+ «ENDFOR»
«ENDIF»
«FOR message : messages»
@@ -229,12 +235,12 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
«ENDFOR»
- «IF (pc.getPortClass(conj) != null)»
- «pc.getPortClass(conj).operations.operationsDeclaration(portClassName)»
+ «IF !(allOperations.empty)»
+ «allOperations.operationsDeclaration(portClassName)»
«ENDIF»
- «IF pc.handlesReceive(conj)»
- «FOR h:getReceiveHandlers(pc,conj)»
+ «IF pc.handlesReceiveIncludingSuper(conj)»
+ «FOR h:pc.getReceiveHandlersIncludingSuper(conj)»
void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
«ENDFOR»
«ENDIF»
@@ -349,7 +355,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
}
def private portClassSource(ProtocolClass pc, Boolean conj) {
- val pclass = pc.getPortClass(conj)
+ val allPortClasses = pc.getAllPortClasses(conj)
val portClassName = pc.getPortClassName(conj)
val replPortClassName = pc.getPortClassName(conj, true)
val messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
@@ -414,12 +420,16 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
}
«ENDFOR»
- «IF pclass!=null»
- /* begin «portClassName» specific */
- «pclass.userCode.userCode»
+ «IF !allPortClasses.empty»
+ /* begin «portClassName» specific (including base classes) */
+ «FOR p : allPortClasses»
+ «p.userCode.userCode»
+ «ENDFOR»
- «pc.getPortClass(conj).operations.operationsImplementation(portClassName)»
- /* end «portClassName» specific */
+ «FOR p : allPortClasses»
+ «p.operations.operationsImplementation(portClassName)»
+ «ENDFOR»
+ /* end «portClassName» specific (including base classes) */
«ENDIF»
etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
@@ -470,7 +480,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
/* receiver handlers */
- «FOR h:getReceiveHandlers(pc,conj)»
+ «FOR h:pc.getReceiveHandlers(conj)»
void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
«AbstractGenerator::getInstance().getTranslatedCode(h.detailCode)»
/* hand over the message to the actor: */
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index 17987b6fb..bf0bb37e9 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -746,6 +746,17 @@ public class CExtensions implements ILanguageExtension {
return (_plus_2 + "\"");
}
+ public String getUtilsIncludePath(final RoomClass rc) {
+ EObject _eContainer = rc.eContainer();
+ String _name = ((RoomModel) _eContainer).getName();
+ String _replaceAll = _name.replaceAll("\\.", "/");
+ String _plus = ("\"" + _replaceAll);
+ String _plus_1 = (_plus + "/");
+ String _cUtilsFileName = this.getCUtilsFileName(rc);
+ String _plus_2 = (_plus_1 + _cUtilsFileName);
+ return (_plus_2 + "\"");
+ }
+
@Override
public String getTargetType(final EnumerationType type) {
String _xifexpression = null;
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index cb54e0a94..04f0106dc 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -12,6 +12,7 @@
package org.eclipse.etrice.generator.c.gen;
import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
@@ -47,6 +48,7 @@ import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
@Singleton
@SuppressWarnings("all")
@@ -263,6 +265,20 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(_generateIncludeGuardBegin, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
+ {
+ ProtocolClass _base = pc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ _builder.append("// include base class utils");
+ _builder.newLine();
+ _builder.append("#include ");
+ ProtocolClass _base_1 = pc.getBase();
+ String _utilsIncludePath = this._cExtensions.getUtilsIncludePath(_base_1);
+ _builder.append(_utilsIncludePath, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
_builder.append("#include ");
String _includePath = this._cExtensions.getIncludePath(pc);
_builder.append(_includePath, "");
@@ -481,6 +497,25 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_xifexpression = this._roomHelpers.getAllOutgoingMessages(pc);
}
List<Message> messages = _xifexpression;
+ final List<PortClass> allPortClasses = this._roomExtensions.getAllPortClasses(pc, (conj).booleanValue());
+ final Function1<PortClass, EList<Attribute>> _function = new Function1<PortClass, EList<Attribute>>() {
+ @Override
+ public EList<Attribute> apply(final PortClass p) {
+ return p.getAttributes();
+ }
+ };
+ List<EList<Attribute>> _map = ListExtensions.<PortClass, EList<Attribute>>map(allPortClasses, _function);
+ Iterable<Attribute> _flatten = Iterables.<Attribute>concat(_map);
+ final List<Attribute> allAttributes = IterableExtensions.<Attribute>toList(_flatten);
+ final Function1<PortClass, EList<PortOperation>> _function_1 = new Function1<PortClass, EList<PortOperation>>() {
+ @Override
+ public EList<PortOperation> apply(final PortClass p) {
+ return p.getOperations();
+ }
+ };
+ List<EList<PortOperation>> _map_1 = ListExtensions.<PortClass, EList<PortOperation>>map(allPortClasses, _function_1);
+ Iterable<PortOperation> _flatten_1 = Iterables.<PortOperation>concat(_map_1);
+ final List<PortOperation> allOperations = IterableExtensions.<PortOperation>toList(_flatten_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("typedef etPort ");
_builder.append(portClassName, "");
@@ -492,50 +527,38 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLineIfNotEmpty();
_builder.newLine();
{
- PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- boolean _notEquals = (!Objects.equal(_portClass, null));
- if (_notEquals) {
+ boolean _isEmpty = allAttributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("/* variable part of PortClass (RAM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var ");
+ _builder.append(portClassName, "");
+ _builder.append("_var; ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _attributes = this._procedureHelpers.attributes(allAttributes);
+ _builder.append(_attributes, "\t");
+ _builder.newLineIfNotEmpty();
+ _builder.append("};");
+ _builder.newLine();
{
- PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<Attribute> _attributes = _portClass_1.getAttributes();
- boolean _isEmpty = _attributes.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- _builder.append("/* variable part of PortClass (RAM) */");
- _builder.newLine();
- _builder.append("typedef struct ");
- _builder.append(portClassName, "");
- _builder.append("_var ");
- _builder.append(portClassName, "");
- _builder.append("_var; ");
- _builder.newLineIfNotEmpty();
- _builder.append("struct ");
- _builder.append(portClassName, "");
- _builder.append("_var {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
- CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
- _builder.append(_attributes_2, "\t");
- _builder.newLineIfNotEmpty();
- _builder.append("};");
- _builder.newLine();
+ for(final Attribute a : allAttributes) {
{
- PortClass _portClass_3 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
- for(final Attribute a : _attributes_3) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
- if (_notEquals_1) {
- String _name = a.getName();
- String _plus = ((portClassName + " ") + _name);
- String _plus_1 = (_plus + ": Attribute initialization not supported in C");
- this.logger.logInfo(_plus_1);
- _builder.newLineIfNotEmpty();
- }
- }
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals) {
+ String _name = a.getName();
+ String _plus = ((portClassName + " ") + _name);
+ String _plus_1 = (_plus + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_1);
+ _builder.newLineIfNotEmpty();
}
}
}
@@ -594,23 +617,21 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
_builder.newLine();
{
- PortClass _portClass_4 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- boolean _notEquals_2 = (!Objects.equal(_portClass_4, null));
- if (_notEquals_2) {
- PortClass _portClass_5 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<PortOperation> _operations = _portClass_5.getOperations();
- CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, portClassName);
+ boolean _isEmpty_1 = allOperations.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(allOperations, portClassName);
_builder.append(_operationsDeclaration, "");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
{
- boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive) {
+ boolean _handlesReceiveIncludingSuper = this._roomExtensions.handlesReceiveIncludingSuper(pc, (conj).booleanValue());
+ if (_handlesReceiveIncludingSuper) {
{
- List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler h : _receiveHandlers) {
+ List<MessageHandler> _receiveHandlersIncludingSuper = this._roomExtensions.getReceiveHandlersIncludingSuper(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlersIncludingSuper) {
_builder.append("void ");
_builder.append(portClassName, "");
_builder.append("_");
@@ -1079,7 +1100,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
private CharSequence portClassSource(final ProtocolClass pc, final Boolean conj) {
CharSequence _xblockexpression = null;
{
- final PortClass pclass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ final List<PortClass> allPortClasses = this._roomExtensions.getAllPortClasses(pc, (conj).booleanValue());
final String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
final String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
List<Message> _xifexpression = null;
@@ -1349,25 +1370,33 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
}
{
- boolean _notEquals_3 = (!Objects.equal(pclass, null));
- if (_notEquals_3) {
+ boolean _isEmpty = allPortClasses.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
_builder.append("/* begin ");
_builder.append(portClassName, "");
- _builder.append(" specific */");
- _builder.newLineIfNotEmpty();
- DetailCode _userCode = pclass.getUserCode();
- CharSequence _userCode_1 = this._procedureHelpers.userCode(_userCode);
- _builder.append(_userCode_1, "");
+ _builder.append(" specific (including base classes) */");
_builder.newLineIfNotEmpty();
+ {
+ for(final PortClass p : allPortClasses) {
+ DetailCode _userCode = p.getUserCode();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(_userCode);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.newLine();
- PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<PortOperation> _operations = _portClass.getOperations();
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
+ {
+ for(final PortClass p_1 : allPortClasses) {
+ EList<PortOperation> _operations = p_1.getOperations();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("/* end ");
_builder.append(portClassName, "");
- _builder.append(" specific */");
+ _builder.append(" specific (including base classes) */");
_builder.newLineIfNotEmpty();
_builder.newLine();
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
index b45609742..93e6473c4 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
@@ -111,7 +111,7 @@ class ProcedureHelpers {
// Attributes
/**
- * @param EnumTest a list of {@link Attribute}s
+ * @param attributes a list of {@link Attribute}s
* @return code declaring the attributes
*/
def attributes(List<Attribute> attributes) {
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
index 04dbb16a4..b33fd9333 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
@@ -296,6 +296,31 @@ class RoomExtensions extends FSMExtensions {
/**
* @param pc a {@link ProtocolClass}
+ * @param conj flag indicating the desired {@link PortClass}
+ * @return the port class
+ */
+ def List<PortClass> getAllPortClasses(ProtocolClass pc, boolean conj) {
+ val ArrayList<PortClass> result = newArrayList()
+
+ var protocol = pc
+ while (protocol!=null) {
+ if (conj) {
+ if (protocol.conjugated!=null)
+ result.add(protocol.conjugated)
+ }
+ else {
+ if (protocol.regular!=null)
+ result.add(protocol.regular)
+ }
+
+ protocol = protocol.base
+ }
+
+ return result
+ }
+
+ /**
+ * @param pc a {@link ProtocolClass}
* @param conj flag indicating the desired communication direction
* @return <code>true</code> if a send handler is specified for this direction
*/
@@ -327,6 +352,20 @@ class RoomExtensions extends FSMExtensions {
}
/**
+ * @param pc a {@link ProtocolClass}
+ * @param conj flag indicating the desired communication direction
+ * @return <code>true</code> if a receive handler is specified for this direction including base classes
+ */
+ def boolean handlesReceiveIncludingSuper(ProtocolClass pc, boolean conj) {
+ val allPortClasses = pc.getAllPortClasses(conj)
+ for (p : allPortClasses)
+ for (hdlr : pc.getPortClass(conj).msgHandlers)
+ if (pc.getAllMessages(!conj).contains(hdlr.msg))
+ return true;
+ return false;
+ }
+
+ /**
* @param iii an {@link InterfaceItemInstance}
* @return <code>true</code> if the interface item instance is logically conjugate
*/
@@ -352,16 +391,31 @@ class RoomExtensions extends FSMExtensions {
* @return a list of defined receive {@link MessageHandler} for this direction
*/
def List<MessageHandler> getReceiveHandlers(ProtocolClass pc, boolean conj) {
- if (pc.getPortClass(conj)==null)
- return new ArrayList<MessageHandler>()
- else {
- var res = new ArrayList<MessageHandler>()
+ val res = new ArrayList<MessageHandler>()
+ if (pc.getPortClass(conj)!=null) {
for (hdlr : pc.getPortClass(conj).msgHandlers) {
if (pc.getAllMessages(!conj).contains(hdlr.msg))
res.add(hdlr)
}
- return res
}
+ return res
+ }
+
+ /**
+ * @param pc a {@link ProtocolClass}
+ * @param conj flag indicating the desired communication direction
+ * @return a list of defined receive {@link MessageHandler} for this direction including base classes
+ */
+ def List<MessageHandler> getReceiveHandlersIncludingSuper(ProtocolClass pc, boolean conj) {
+ val res = new ArrayList<MessageHandler>()
+ val allPortClasses = pc.getAllPortClasses(conj)
+ for (p : allPortClasses) {
+ for (hdlr : p.msgHandlers) {
+ if (pc.getAllMessages(!conj).contains(hdlr.msg))
+ res.add(hdlr)
+ }
+ }
+ return res
}
/**
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
index 0a679b3c8..c0ee94e10 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
@@ -185,7 +185,7 @@ public class ProcedureHelpers {
}
/**
- * @param EnumTest a list of {@link Attribute}s
+ * @param attributes a list of {@link Attribute}s
* @return code declaring the attributes
*/
public CharSequence attributes(final List<Attribute> attributes) {
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
index 8157879d2..2a2c67767 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
@@ -46,6 +46,7 @@ import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers;
import org.eclipse.etrice.generator.fsm.generic.FSMExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -351,6 +352,38 @@ public class RoomExtensions extends FSMExtensions {
/**
* @param pc a {@link ProtocolClass}
+ * @param conj flag indicating the desired {@link PortClass}
+ * @return the port class
+ */
+ public List<PortClass> getAllPortClasses(final ProtocolClass pc, final boolean conj) {
+ final ArrayList<PortClass> result = CollectionLiterals.<PortClass>newArrayList();
+ ProtocolClass protocol = pc;
+ while ((!Objects.equal(protocol, null))) {
+ {
+ if (conj) {
+ PortClass _conjugated = protocol.getConjugated();
+ boolean _notEquals = (!Objects.equal(_conjugated, null));
+ if (_notEquals) {
+ PortClass _conjugated_1 = protocol.getConjugated();
+ result.add(_conjugated_1);
+ }
+ } else {
+ PortClass _regular = protocol.getRegular();
+ boolean _notEquals_1 = (!Objects.equal(_regular, null));
+ if (_notEquals_1) {
+ PortClass _regular_1 = protocol.getRegular();
+ result.add(_regular_1);
+ }
+ }
+ ProtocolClass _base = protocol.getBase();
+ protocol = _base;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @param pc a {@link ProtocolClass}
* @param conj flag indicating the desired communication direction
* @return <code>true</code> if a send handler is specified for this direction
*/
@@ -400,6 +433,28 @@ public class RoomExtensions extends FSMExtensions {
}
/**
+ * @param pc a {@link ProtocolClass}
+ * @param conj flag indicating the desired communication direction
+ * @return <code>true</code> if a receive handler is specified for this direction including base classes
+ */
+ public boolean handlesReceiveIncludingSuper(final ProtocolClass pc, final boolean conj) {
+ final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj);
+ for (final PortClass p : allPortClasses) {
+ PortClass _portClass = this.getPortClass(pc, conj);
+ EList<MessageHandler> _msgHandlers = _portClass.getMsgHandlers();
+ for (final MessageHandler hdlr : _msgHandlers) {
+ List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
+ Message _msg = hdlr.getMsg();
+ boolean _contains = _allMessages.contains(_msg);
+ if (_contains) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
* @param iii an {@link InterfaceItemInstance}
* @return <code>true</code> if the interface item instance is logically conjugate
*/
@@ -426,12 +481,10 @@ public class RoomExtensions extends FSMExtensions {
* @return a list of defined receive {@link MessageHandler} for this direction
*/
public List<MessageHandler> getReceiveHandlers(final ProtocolClass pc, final boolean conj) {
+ final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
PortClass _portClass = this.getPortClass(pc, conj);
- boolean _equals = Objects.equal(_portClass, null);
- if (_equals) {
- return new ArrayList<MessageHandler>();
- } else {
- ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
+ boolean _notEquals = (!Objects.equal(_portClass, null));
+ if (_notEquals) {
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
for (final MessageHandler hdlr : _msgHandlers) {
@@ -442,8 +495,30 @@ public class RoomExtensions extends FSMExtensions {
res.add(hdlr);
}
}
- return res;
}
+ return res;
+ }
+
+ /**
+ * @param pc a {@link ProtocolClass}
+ * @param conj flag indicating the desired communication direction
+ * @return a list of defined receive {@link MessageHandler} for this direction including base classes
+ */
+ public List<MessageHandler> getReceiveHandlersIncludingSuper(final ProtocolClass pc, final boolean conj) {
+ final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
+ final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj);
+ for (final PortClass p : allPortClasses) {
+ EList<MessageHandler> _msgHandlers = p.getMsgHandlers();
+ for (final MessageHandler hdlr : _msgHandlers) {
+ List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
+ Message _msg = hdlr.getMsg();
+ boolean _contains = _allMessages.contains(_msg);
+ if (_contains) {
+ res.add(hdlr);
+ }
+ }
+ }
+ return res;
}
/**

Back to the top