diff options
author | tjung | 2012-04-25 18:15:16 +0000 |
---|---|---|
committer | tjung | 2012-04-25 18:15:16 +0000 |
commit | 0bd09dc1dc8cb0643fcfc39d4abe9fb47d89b409 (patch) | |
tree | a9cb5bb68657f6a4f07ffb285a1cff047ec09366 | |
parent | 23c680ff9c5567d0f8ed1237ab3ed7b03471f07f (diff) | |
download | org.eclipse.etrice-0bd09dc1dc8cb0643fcfc39d4abe9fb47d89b409.tar.gz org.eclipse.etrice-0bd09dc1dc8cb0643fcfc39d4abe9fb47d89b409.tar.xz org.eclipse.etrice-0bd09dc1dc8cb0643fcfc39d4abe9fb47d89b409.zip |
[generator.c] port handles and port attributes implemented, C runtime adapted
6 files changed, 555 insertions, 263 deletions
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 dd9773f3e..b9058d588 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 @@ -136,31 +136,48 @@ class ProtocolClassGen extends GenericProtocolClassGenerator { var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
'''
+ typedef etPort «portClassName»;
+ typedef etReplPort «replPortClassName»;
- 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 {
+ «helpers.attributes(pc.getPortClass(conj).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»
+ «ENDIF»
- «FOR message : messages»
- «var hasData = message.data!=null»
- «var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
- «var data = if (hasData) ", "+typeName+refp+" data" else ""»
- «messageSignature(portClassName, message.name, "", data)»;
- «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
- «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
- «ENDFOR»
+ «FOR message : messages»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «messageSignature(portClassName, message.name, "", data)»;
+ «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
+ «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
+ «ENDFOR»
«IF (pc.getPortClass(conj) != null)»
«helpers.operationsDeclaration(pc.getPortClass(conj).operations, portClassName)»
«helpers.operationsDeclaration(pc.getPortClass(conj).operations, replPortClassName)»
«ENDIF»
- «IF pc.handlesReceive(conj)»
- void «portClassName»_handleReceive(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «IF pc.handlesReceive(conj)»
+ «FOR h:getReceiveHandlers(pc,conj)»
+void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «ENDFOR»
«ENDIF»
-
'''
}
+
+
def private genDataDrivenPortHeaders(ProtocolClass pc) {
var sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
@@ -234,9 +251,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator { «ENDFOR»
«ELSE»
ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
- if (self->receiveMessageFunc!=NULL) {
«sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
ET_MSC_LOGGER_SYNC_EXIT
«ENDIF»
}
@@ -328,18 +343,15 @@ class ProtocolClassGen extends GenericProtocolClassGenerator { '''
/* receiver handlers */
- void «portClassName»_handleReceive(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
- switch (msg->evtID){
- «FOR h:getReceiveHandlers(pc,conj)»
- case «pc.name»_«h.msg.codeName»:
+ «FOR h:getReceiveHandlers(pc,conj)»
+ void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
«userCode(h.detailCode)»
- break;
- «ENDFOR»
- default:receiveMessageFunc(actor, self, msg);
- break;
+ /* hand over the message to the actor: */
+ /* (*receiveMessageFunc)(actor, self, msg); */
}
- }
+ «ENDFOR»
'''}
+
def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend index 833b68afd..190133bf5 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend @@ -268,7 +268,26 @@ class SubSystemClassGen { «FOR ai : ssi.allContainedInstances»
static «ai.actorClass.name» «ai.path.getPathName()»;
«ENDFOR»
-
+
+ /* forward declaration of variable port structs */
+ «FOR ai: ssi.allContainedInstances»
+ «IF ai.orderedIfItemInstances.empty»
+/*nothing to do */
+ «ELSE»
+ «FOR pi:ai.orderedIfItemInstances»
+ «IF pi.interfaceItem.protocol.getPortClass(pi.conjugated)!=null»
+ «IF !pi.interfaceItem.protocol.getPortClass(pi.conjugated).attributes.empty»
+ «IF pi.replicated»
+ static «pi.interfaceItem.protocol.getPortClassName(pi.conjugated)»_var «pi.path.pathName»_var[«pi.peers.size»];
+ «ELSE»
+ static «pi.interfaceItem.protocol.getPortClassName(pi.conjugated)»_var «pi.path.pathName»_var;
+ «ENDIF»
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ENDFOR»
+
«FOR ai : ssi.allContainedInstances»
/* instance «ai.path.getPathName()» */
@@ -313,7 +332,7 @@ class SubSystemClassGen { '''
«IF haveReplSubPorts»
static const etReplSubPort «replSubPortsArray»[«offset»] = {
- /* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, index} */
+ /* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */
«FOR pi : replPorts SEPARATOR ","»
«genReplSubPortInitializers(root, ai, pi)»
«ENDFOR»
@@ -321,7 +340,7 @@ class SubSystemClassGen { «ENDIF»
«IF !(eventPorts.empty && recvPorts.empty)»
static const «ai.actorClass.name»_const «instName»_const = {
- /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ /* Ports: {varData, msgService, peerAddress, localId} */
«FOR pi : eventPorts SEPARATOR ","»
«IF pi.simple»
«genPortInitializer(root, ai, pi)»
@@ -345,14 +364,23 @@ class SubSystemClassGen { var objId = if (pi.peers.empty) 0 else pi.peers.get(0).objId
var idx = if (pi.peers.empty) 0 else pi.peers.get(0).peers.indexOf(pi)
- "{&"+ai.path.getPathName()+", "
- +recvMsg+", "
+ "{"+getInterfaceItemInstanceData(pi)+","
+"&msgService_Thread1, "
+(objId+idx)+", "
+(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.interfaceItem)+1)
+"} /* Port "+pi.name+" */"
}
+ def private getInterfaceItemInstanceData(InterfaceItemInstance pi){
+ if (pi.interfaceItem.protocol.getPortClass(pi.conjugated)== null) return "0"
+ if (pi.interfaceItem.protocol.getPortClass(pi.conjugated).attributes.empty){
+ return "0"
+ }else{
+ return "&"+pi.path.pathName+"_var"
+ }
+ }
+
+
def private String genRecvPortInitializer(Root root, ActorInstance ai, InterfaceItemInstance pi) {
if (pi.peers.empty)
return "{NULL}"
@@ -370,9 +398,10 @@ class SubSystemClassGen { for (p: pi.peers) {
var idx = pi.peers.indexOf(p)
var comma = if (idx<pi.peers.size-1) "," else ""
+ var iiiD = getInterfaceItemInstanceData(pi)
+ iiiD = if (iiiD.equals("0")) iiiD+"," else iiiD+"["+idx+"],"
result = result +
- "{&"+ai.path.getPathName()+", "
- +ai.actorClass.name+"_receiveMessage, "
+ "{"+iiiD
+"&msgService_Thread1, "
+p.objId+", "
+(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.interfaceItem)+1)+", "
@@ -401,24 +430,38 @@ class SubSystemClassGen { «FOR ai : ssi.allContainedInstances»
/* interface items of «ai.path» */
- «FOR pi : ai.orderedIfItemInstances.filter(p|p.interfaceItem.protocol.commType==CommunicationType::EVENT_DRIVEN)»
+ «FOR pi : ai. orderedIfItemInstances.filter(p|p.interfaceItem.protocol.commType==CommunicationType::EVENT_DRIVEN)»
«IF pi.replicated»
«FOR peer: pi.peers»
case «pi.objId+pi.peers.indexOf(peer)»:
- «IF (pi.interfaceItem.protocol. handlesReceive(pi.isConjugated()))»
- «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated())»_handleReceive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»],msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ «IF (pi.interfaceItem.protocol.handlesReceive(pi.isConjugated()))»
+ switch (msg->evtID){
+ «FOR h:getReceiveHandlers(pi.interfaceItem.protocol,pi.isConjugated())»
+ case «pi.interfaceItem.protocol.name»_«h.msg.codeName»:
+ «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated)»_«h.msg.name»_receiveHandler((etPort *)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»],msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ break;
+ «ENDFOR»
+ default: «ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
+ break;
+ }
«ELSE»
- //etPort_receive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
«ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
«ENDIF»
break;
«ENDFOR»
«ELSE»
case «pi.objId»:
- «IF (pi.interfaceItem.protocol. handlesReceive(pi.isConjugated()))»
- «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated())»_handleReceive((etPort*)&«ai.path.pathName»_const.«pi.name»,msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ «IF (pi.interfaceItem.protocol.handlesReceive(pi.isConjugated()))»
+ switch (msg->evtID){
+ «FOR h:getReceiveHandlers(pi.interfaceItem.protocol,pi.isConjugated())»
+ case «pi.interfaceItem.protocol.name»_«h.msg.codeName»:
+ «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated)»_«h.msg.name»_receiveHandler((etPort *)&«ai.path.pathName»_const.«pi.name»,msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ break;
+ «ENDFOR»
+ default: «ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name», msg);
+ break;
+ }
«ELSE»
- //etPort_receive(&«ai.path.pathName»_const.«pi.name», msg);
«ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name», msg);
«ENDIF»
break;
@@ -428,13 +471,13 @@ class SubSystemClassGen { default:
etLogger_logErrorF("MessageService_Thread1_receiveMessage: address %d does not exist ", msg->address);
- break;
+ break;
}
ET_MSC_LOGGER_SYNC_EXIT
}
'''
}
-
+
def private generateDatadrivenExecutes(Root root, SubSystemInstance ssi) {'''
«FOR ai : ssi.allContainedInstances»
«IF ai.actorClass.commType == ActorCommunicationType::ASYNCHRONOUS || ai.actorClass.commType == ActorCommunicationType::DATA_DRIVEN»
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 453ce84dc..b611b8f30 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 @@ -5,6 +5,7 @@ import com.google.inject.Singleton; import java.util.HashSet; import java.util.List; import org.eclipse.emf.common.util.EList; +import org.eclipse.etrice.core.room.Attribute; import org.eclipse.etrice.core.room.CommunicationType; import org.eclipse.etrice.core.room.DataClass; import org.eclipse.etrice.core.room.DataType; @@ -286,27 +287,77 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { } List<Message> messages = _xifexpression; StringConcatenation _builder = new StringConcatenation(); - _builder.newLine(); - _builder.append("\t"); _builder.append("typedef etPort "); - _builder.append(portClassName, " "); + _builder.append(portClassName, ""); _builder.append(";"); _builder.newLineIfNotEmpty(); - _builder.append("\t"); _builder.append("typedef etReplPort "); - _builder.append(replPortClassName, " "); + _builder.append(replPortClassName, ""); _builder.append(";"); _builder.newLineIfNotEmpty(); + _builder.newLine(); + { + PortClass _portClass = this.roomExt.getPortClass(pc, conj); + boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null); + if (_operator_notEquals) { + { + PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj); + EList<Attribute> _attributes = _portClass_1.getAttributes(); + boolean _isEmpty = _attributes.isEmpty(); + boolean _operator_not = BooleanExtensions.operator_not(_isEmpty); + if (_operator_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.roomExt.getPortClass(pc, conj); + EList<Attribute> _attributes_1 = _portClass_2.getAttributes(); + StringConcatenation _attributes_2 = this.helpers.attributes(_attributes_1); + _builder.append(_attributes_2, " "); + _builder.newLineIfNotEmpty(); + _builder.append("\t"); + _builder.append("};"); + _builder.newLine(); + { + PortClass _portClass_3 = this.roomExt.getPortClass(pc, conj); + EList<Attribute> _attributes_3 = _portClass_3.getAttributes(); + for(final Attribute a : _attributes_3) { + { + String _defaultValueLiteral = a.getDefaultValueLiteral(); + boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null); + if (_operator_notEquals_1) { + _builder.append("\t\t\t\t"); + String _operator_plus = StringExtensions.operator_plus(portClassName, " "); + String _name = a.getName(); + String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name); + String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C"); + this.logger.logInfo(_operator_plus_2); + _builder.newLineIfNotEmpty(); + } + } + } + } + } + } + } + } _builder.append("\t"); _builder.newLine(); { for(final Message message : messages) { - _builder.append("\t"); VarDecl _data = message.getData(); - boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null); - boolean hasData = _operator_notEquals; + boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_data, null); + boolean hasData = _operator_notEquals_2; _builder.newLineIfNotEmpty(); - _builder.append("\t"); String _xifexpression_1 = null; if (hasData) { VarDecl _data_1 = message.getData(); @@ -319,7 +370,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { } String typeName = _xifexpression_1; _builder.newLineIfNotEmpty(); - _builder.append("\t"); String _xifexpression_2 = null; boolean _operator_and = false; if (!hasData) { @@ -329,14 +379,14 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { VarDecl _data_2 = message.getData(); RefableType _refType_1 = _data_2.getRefType(); DataType _type_1 = _refType_1.getType(); - boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType)); - if (_operator_not) { + boolean _operator_not_1 = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType)); + if (_operator_not_1) { _operator_or = true; } else { VarDecl _data_3 = message.getData(); RefableType _refType_2 = _data_3.getRefType(); boolean _isRef = _refType_2.isRef(); - _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef); + _operator_or = BooleanExtensions.operator_or(_operator_not_1, _isRef); } _operator_and = BooleanExtensions.operator_and(hasData, _operator_or); } @@ -347,35 +397,31 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { } String refp = _xifexpression_2; _builder.newLineIfNotEmpty(); - _builder.append("\t"); String _xifexpression_3 = null; if (hasData) { - String _operator_plus = StringExtensions.operator_plus(", ", typeName); - String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp); - String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data"); - _xifexpression_3 = _operator_plus_2; + String _operator_plus_3 = StringExtensions.operator_plus(", ", typeName); + String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, refp); + String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, " data"); + _xifexpression_3 = _operator_plus_5; } else { _xifexpression_3 = ""; } String data = _xifexpression_3; _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _name = message.getName(); - String _messageSignature = this.messageSignature(portClassName, _name, "", data); - _builder.append(_messageSignature, " "); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); String _name_1 = message.getName(); - String _messageSignature_1 = this.messageSignature(replPortClassName, _name_1, "_broadcast", data); - _builder.append(_messageSignature_1, " "); + String _messageSignature = this.messageSignature(portClassName, _name_1, "", data); + _builder.append(_messageSignature, ""); _builder.append(";"); _builder.newLineIfNotEmpty(); - _builder.append("\t"); String _name_2 = message.getName(); - String _operator_plus_3 = StringExtensions.operator_plus(", int idx", data); - String _messageSignature_2 = this.messageSignature(replPortClassName, _name_2, "", _operator_plus_3); - _builder.append(_messageSignature_2, " "); + String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data); + _builder.append(_messageSignature_1, ""); + _builder.append(";"); + _builder.newLineIfNotEmpty(); + String _name_3 = message.getName(); + String _operator_plus_6 = StringExtensions.operator_plus(", int idx", data); + String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _operator_plus_6); + _builder.append(_messageSignature_2, ""); _builder.append(";"); _builder.newLineIfNotEmpty(); } @@ -383,16 +429,16 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { _builder.append("\t"); _builder.newLine(); { - PortClass _portClass = this.roomExt.getPortClass(pc, conj); - boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_portClass, null); - if (_operator_notEquals_1) { - PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj); - EList<PortOperation> _operations = _portClass_1.getOperations(); + PortClass _portClass_4 = this.roomExt.getPortClass(pc, conj); + boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_portClass_4, null); + if (_operator_notEquals_3) { + PortClass _portClass_5 = this.roomExt.getPortClass(pc, conj); + EList<PortOperation> _operations = _portClass_5.getOperations(); StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName); _builder.append(_operationsDeclaration, ""); _builder.newLineIfNotEmpty(); - PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj); - EList<PortOperation> _operations_1 = _portClass_2.getOperations(); + PortClass _portClass_6 = this.roomExt.getPortClass(pc, conj); + EList<PortOperation> _operations_1 = _portClass_6.getOperations(); StringConcatenation _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName); _builder.append(_operationsDeclaration_1, ""); _builder.newLineIfNotEmpty(); @@ -402,16 +448,23 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { { boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj); if (_handlesReceive) { - _builder.append("void "); - _builder.append(portClassName, ""); - _builder.append("_handleReceive("); - _builder.append(portClassName, ""); - _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);"); - _builder.newLineIfNotEmpty(); + { + List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj); + for(final MessageHandler h : _receiveHandlers) { + _builder.append("void "); + _builder.append(portClassName, ""); + _builder.append("_"); + Message _msg = h.getMsg(); + String _name_4 = _msg.getName(); + _builder.append(_name_4, ""); + _builder.append("_receiveHandler("); + _builder.append(portClassName, ""); + _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);"); + _builder.newLineIfNotEmpty(); + } + } } } - _builder.append("\t"); - _builder.newLine(); _xblockexpression = (_builder); } return _xblockexpression; @@ -800,9 +853,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { _builder.append("\")"); _builder.newLineIfNotEmpty(); _builder.append("\t"); - _builder.append("if (self->receiveMessageFunc!=NULL) {"); - _builder.newLine(); - _builder.append("\t"); _builder.append("\t"); String _name_2 = pc.getName(); String _name_3 = message.getName(); @@ -814,9 +864,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { _builder.append(_sendMessageCall, " "); _builder.newLineIfNotEmpty(); _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); _builder.newLine(); } @@ -1079,50 +1126,34 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator { StringConcatenation _builder = new StringConcatenation(); _builder.append("/* receiver handlers */"); _builder.newLine(); - _builder.append("void "); - _builder.append(portClassName, ""); - _builder.append("_handleReceive("); - _builder.append(portClassName, ""); - _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("switch (msg->evtID){"); - _builder.newLine(); { List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj); for(final MessageHandler h : _receiveHandlers) { - _builder.append("\t"); - _builder.append("case "); - String _name = pc.getName(); - _builder.append(_name, " "); + _builder.append("void "); + _builder.append(portClassName, ""); _builder.append("_"); Message _msg = h.getMsg(); - String _codeName = this.roomExt.getCodeName(_msg); - _builder.append(_codeName, " "); - _builder.append(":"); + String _name = _msg.getName(); + _builder.append(_name, ""); + _builder.append("_receiveHandler("); + _builder.append(portClassName, ""); + _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){"); _builder.newLineIfNotEmpty(); _builder.append("\t"); - _builder.append("\t"); DetailCode _detailCode = h.getDetailCode(); StringConcatenation _userCode = this.helpers.userCode(_detailCode); - _builder.append(_userCode, " "); + _builder.append(_userCode, " "); _builder.newLineIfNotEmpty(); _builder.append("\t"); - _builder.append("break;"); + _builder.append("/* hand over the message to the actor: */"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */"); + _builder.newLine(); + _builder.append("}"); _builder.newLine(); } } - _builder.append("\t"); - _builder.append("default:receiveMessageFunc(actor, self, msg);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); _xblockexpression = (_builder); } return _xblockexpression; diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java index 9d7bcf17a..96b737de8 100644 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java +++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java @@ -4,14 +4,19 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; import org.eclipse.etrice.core.room.ActorClass; import org.eclipse.etrice.core.room.ActorCommunicationType; +import org.eclipse.etrice.core.room.Attribute; import org.eclipse.etrice.core.room.CommunicationType; 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.MessageHandler; import org.eclipse.etrice.core.room.Port; +import org.eclipse.etrice.core.room.PortClass; import org.eclipse.etrice.core.room.ProtocolClass; import org.eclipse.etrice.core.room.StandardOperation; import org.eclipse.etrice.core.room.SubSystemClass; @@ -733,24 +738,100 @@ public class SubSystemClassGen { } } _builder.newLine(); + _builder.append("/* forward declaration of variable port structs */\t\t"); + _builder.newLine(); { EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances(); for(final ActorInstance ai_1 : _allContainedInstances_1) { + { + EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances(); + boolean _isEmpty = _orderedIfItemInstances.isEmpty(); + if (_isEmpty) { + _builder.append("/*nothing to do */"); + _builder.newLine(); + } else { + { + EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_1.getOrderedIfItemInstances(); + for(final InterfaceItemInstance pi : _orderedIfItemInstances_1) { + { + InterfaceItem _interfaceItem = pi.getInterfaceItem(); + ProtocolClass _protocol = _interfaceItem.getProtocol(); + boolean _isConjugated = this.roomExt.isConjugated(pi); + PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated); + boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null); + if (_operator_notEquals) { + { + InterfaceItem _interfaceItem_1 = pi.getInterfaceItem(); + ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol(); + boolean _isConjugated_1 = this.roomExt.isConjugated(pi); + PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1); + EList<Attribute> _attributes = _portClass_1.getAttributes(); + boolean _isEmpty_1 = _attributes.isEmpty(); + boolean _operator_not = BooleanExtensions.operator_not(_isEmpty_1); + if (_operator_not) { + { + boolean _isReplicated = pi.isReplicated(); + if (_isReplicated) { + _builder.append("static "); + InterfaceItem _interfaceItem_2 = pi.getInterfaceItem(); + ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol(); + boolean _isConjugated_2 = this.roomExt.isConjugated(pi); + String _portClassName = this.roomExt.getPortClassName(_protocol_2, _isConjugated_2); + _builder.append(_portClassName, ""); + _builder.append("_var "); + String _path_1 = pi.getPath(); + String _pathName_1 = this.roomExt.getPathName(_path_1); + _builder.append(_pathName_1, ""); + _builder.append("_var["); + EList<InterfaceItemInstance> _peers = pi.getPeers(); + int _size = _peers.size(); + _builder.append(_size, ""); + _builder.append("];"); + _builder.newLineIfNotEmpty(); + } else { + _builder.append("static "); + InterfaceItem _interfaceItem_3 = pi.getInterfaceItem(); + ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol(); + boolean _isConjugated_3 = this.roomExt.isConjugated(pi); + String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3); + _builder.append(_portClassName_1, ""); + _builder.append("_var "); + String _path_2 = pi.getPath(); + String _pathName_2 = this.roomExt.getPathName(_path_2); + _builder.append(_pathName_2, ""); + _builder.append("_var;"); + _builder.newLineIfNotEmpty(); + } + } + } + } + } + } + } + } + } + } + } + } + _builder.newLine(); + { + EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances(); + for(final ActorInstance ai_2 : _allContainedInstances_2) { _builder.newLine(); _builder.append("/* instance "); - String _path_1 = ai_1.getPath(); - String _pathName_1 = this.roomExt.getPathName(_path_1); - _builder.append(_pathName_1, ""); + String _path_3 = ai_2.getPath(); + String _pathName_3 = this.roomExt.getPathName(_path_3); + _builder.append(_pathName_3, ""); _builder.append(" */"); _builder.newLineIfNotEmpty(); { - EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances(); - boolean _isEmpty = _orderedIfItemInstances.isEmpty(); - if (_isEmpty) { + EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances(); + boolean _isEmpty_2 = _orderedIfItemInstances_2.isEmpty(); + if (_isEmpty_2) { _builder.append("/* no ports/saps/services - nothing to initialize statically */"); _builder.newLine(); } else { - StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_1); + StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_2); _builder.append(_genActorInstanceInitializer, ""); _builder.newLineIfNotEmpty(); } @@ -884,7 +965,7 @@ public class SubSystemClassGen { _builder.append("] = {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); - _builder.append("/* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, index} */"); + _builder.append("/* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */"); _builder.newLine(); { boolean hasAnyElements = false; @@ -924,7 +1005,7 @@ public class SubSystemClassGen { _builder.append("_const = {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); - _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */"); + _builder.append("/* Ports: {varData, msgService, peerAddress, localId} */"); _builder.newLine(); { boolean hasAnyElements_1 = false; @@ -1053,30 +1134,53 @@ public class SubSystemClassGen { _xifexpression_2 = _indexOf; } int idx = _xifexpression_2; - String _path = ai.getPath(); - String _pathName = this.roomExt.getPathName(_path); - String _operator_plus_1 = StringExtensions.operator_plus("{&", _pathName); - String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", "); - String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, recvMsg); - String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, ", "); - String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, "); - int _operator_plus_6 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx)); - String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_operator_plus_6)); - String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", "); + String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi); + String _operator_plus_1 = StringExtensions.operator_plus("{", _interfaceItemInstanceData); + String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ","); + String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "&msgService_Thread1, "); + int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx)); + String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_3, ((Integer)_operator_plus_4)); + String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ", "); ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai); InterfaceItem _interfaceItem = pi.getInterfaceItem(); int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem); - int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1)); - String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9)); - String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, "} /* Port "); + int _operator_plus_7 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1)); + String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_6, ((Integer)_operator_plus_7)); + String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, "} /* Port "); String _name_1 = pi.getName(); - String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, _name_1); - String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, " */"); - _xblockexpression = (_operator_plus_13); + String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, _name_1); + String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, " */"); + _xblockexpression = (_operator_plus_11); } return _xblockexpression; } + private String getInterfaceItemInstanceData(final InterfaceItemInstance pi) { + InterfaceItem _interfaceItem = pi.getInterfaceItem(); + ProtocolClass _protocol = _interfaceItem.getProtocol(); + boolean _isConjugated = this.roomExt.isConjugated(pi); + PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated); + boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null); + if (_operator_equals) { + return "0"; + } + InterfaceItem _interfaceItem_1 = pi.getInterfaceItem(); + ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol(); + boolean _isConjugated_1 = this.roomExt.isConjugated(pi); + PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1); + EList<Attribute> _attributes = _portClass_1.getAttributes(); + boolean _isEmpty = _attributes.isEmpty(); + if (_isEmpty) { + return "0"; + } else { + String _path = pi.getPath(); + String _pathName = this.roomExt.getPathName(_path); + String _operator_plus = StringExtensions.operator_plus("&", _pathName); + String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_var"); + return _operator_plus_1; + } + } + private String genRecvPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) { String _xblockexpression = null; { @@ -1124,35 +1228,42 @@ public class SubSystemClassGen { _xifexpression = ""; } String comma = _xifexpression; - String _operator_plus = StringExtensions.operator_plus(result, "{&"); - String _path = ai.getPath(); - String _pathName = this.roomExt.getPathName(_path); - String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _pathName); - String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", "); - ActorClass _actorClass = ai.getActorClass(); - String _name = _actorClass.getName(); - String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name); - String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_receiveMessage, "); - String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, "); + String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi); + String iiiD = _interfaceItemInstanceData; + String _xifexpression_1 = null; + boolean _equals = iiiD.equals("0"); + if (_equals) { + String _operator_plus = StringExtensions.operator_plus(iiiD, ","); + _xifexpression_1 = _operator_plus; + } else { + String _operator_plus_1 = StringExtensions.operator_plus(iiiD, "["); + String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ((Integer)idx)); + String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "],"); + _xifexpression_1 = _operator_plus_3; + } + iiiD = _xifexpression_1; + String _operator_plus_4 = StringExtensions.operator_plus(result, "{"); + String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, iiiD); + String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "&msgService_Thread1, "); int _objId = p.getObjId(); - String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_objId)); - String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", "); + String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ((Integer)_objId)); + String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", "); ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai); InterfaceItem _interfaceItem = pi.getInterfaceItem(); int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem); - int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1)); - String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8)); - String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, ", "); - String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ((Integer)idx)); - String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "}"); - String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, comma); - String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, " /* Repl Sub Port "); - String _name_1 = pi.getName(); - String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, _name_1); - String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, " idx +"); - String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, ((Integer)idx)); - String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, "*/\n"); - result = _operator_plus_18; + int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1)); + String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9)); + String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", "); + String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, ((Integer)idx)); + String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, "}"); + String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, comma); + String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, " /* Repl Sub Port "); + String _name = pi.getName(); + String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, _name); + String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, " idx +"); + String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, ((Integer)idx)); + String _operator_plus_19 = StringExtensions.operator_plus(_operator_plus_18, "*/\n"); + result = _operator_plus_19; } } return result; @@ -1241,62 +1352,113 @@ public class SubSystemClassGen { boolean _handlesReceive = this.roomExt.handlesReceive(_protocol, _isConjugated); if (_handlesReceive) { _builder.append("\t\t"); - InterfaceItem _interfaceItem_1 = pi.getInterfaceItem(); - ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol(); - boolean _isConjugated_1 = this.roomExt.isConjugated(pi); - String _portClassName = this.roomExt.getPortClassName(_protocol_1, _isConjugated_1); - _builder.append(_portClassName, " "); - _builder.append("_handleReceive((etPort*)&"); - String _path_1 = ai.getPath(); - String _pathName = this.roomExt.getPathName(_path_1); - _builder.append(_pathName, " "); - _builder.append("_const."); - String _name_1 = pi.getName(); - _builder.append(_name_1, " "); - _builder.append(".ports["); - EList<InterfaceItemInstance> _peers_2 = pi.getPeers(); - int _indexOf_1 = _peers_2.indexOf(peer); - _builder.append(_indexOf_1, " "); - _builder.append("],msg,(void*)&"); - String _path_2 = ai.getPath(); - String _pathName_1 = this.roomExt.getPathName(_path_2); - _builder.append(_pathName_1, " "); - _builder.append(","); - ActorClass _actorClass = ai.getActorClass(); - String _name_2 = _actorClass.getName(); - _builder.append(_name_2, " "); - _builder.append("_receiveMessage);"); - _builder.newLineIfNotEmpty(); - } else { + _builder.append("switch (msg->evtID){"); + _builder.newLine(); + { + InterfaceItem _interfaceItem_1 = pi.getInterfaceItem(); + ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol(); + boolean _isConjugated_1 = this.roomExt.isConjugated(pi); + List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(_protocol_1, _isConjugated_1); + for(final MessageHandler h : _receiveHandlers) { + _builder.append("\t\t"); + _builder.append("\t"); + _builder.append("case "); + InterfaceItem _interfaceItem_2 = pi.getInterfaceItem(); + ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol(); + String _name_1 = _protocol_2.getName(); + _builder.append(_name_1, " "); + _builder.append("_"); + Message _msg = h.getMsg(); + String _codeName = this.roomExt.getCodeName(_msg); + _builder.append(_codeName, " "); + _builder.append(":"); + _builder.newLineIfNotEmpty(); + _builder.append("\t\t"); + _builder.append("\t"); + _builder.append("\t"); + InterfaceItem _interfaceItem_3 = pi.getInterfaceItem(); + ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol(); + boolean _isConjugated_2 = this.roomExt.isConjugated(pi); + String _portClassName = this.roomExt.getPortClassName(_protocol_3, _isConjugated_2); + _builder.append(_portClassName, " "); + _builder.append("_"); + Message _msg_1 = h.getMsg(); + String _name_2 = _msg_1.getName(); + _builder.append(_name_2, " "); + _builder.append("_receiveHandler((etPort *)&"); + String _path_1 = ai.getPath(); + String _pathName = this.roomExt.getPathName(_path_1); + _builder.append(_pathName, " "); + _builder.append("_const."); + String _name_3 = pi.getName(); + _builder.append(_name_3, " "); + _builder.append(".ports["); + EList<InterfaceItemInstance> _peers_2 = pi.getPeers(); + int _indexOf_1 = _peers_2.indexOf(peer); + _builder.append(_indexOf_1, " "); + _builder.append("],msg,(void*)&"); + String _path_2 = ai.getPath(); + String _pathName_1 = this.roomExt.getPathName(_path_2); + _builder.append(_pathName_1, " "); + _builder.append(","); + ActorClass _actorClass = ai.getActorClass(); + String _name_4 = _actorClass.getName(); + _builder.append(_name_4, " "); + _builder.append("_receiveMessage);"); + _builder.newLineIfNotEmpty(); + _builder.append("\t\t"); + _builder.append("\t"); + _builder.append("break;"); + _builder.newLine(); + } + } _builder.append("\t\t"); - _builder.append("//etPort_receive((etPort*)&"); + _builder.append("\t"); + _builder.append("default: "); + ActorClass _actorClass_1 = ai.getActorClass(); + String _name_5 = _actorClass_1.getName(); + _builder.append(_name_5, " "); + _builder.append("_receiveMessage((void*)&"); String _path_3 = ai.getPath(); String _pathName_2 = this.roomExt.getPathName(_path_3); - _builder.append(_pathName_2, " "); + _builder.append(_pathName_2, " "); + _builder.append(",(etPort*)&"); + String _path_4 = ai.getPath(); + String _pathName_3 = this.roomExt.getPathName(_path_4); + _builder.append(_pathName_3, " "); _builder.append("_const."); - String _name_3 = pi.getName(); - _builder.append(_name_3, " "); + String _name_6 = pi.getName(); + _builder.append(_name_6, " "); _builder.append(".ports["); EList<InterfaceItemInstance> _peers_3 = pi.getPeers(); int _indexOf_2 = _peers_3.indexOf(peer); - _builder.append(_indexOf_2, " "); + _builder.append(_indexOf_2, " "); _builder.append("], msg);"); _builder.newLineIfNotEmpty(); _builder.append("\t\t"); - ActorClass _actorClass_1 = ai.getActorClass(); - String _name_4 = _actorClass_1.getName(); - _builder.append(_name_4, " "); + _builder.append("\t"); + _builder.append("break;"); + _builder.newLine(); + _builder.append("\t\t"); + _builder.append("\t"); + _builder.append("}\t\t\t\t\t\t\t\t\t\t"); + _builder.newLine(); + } else { + _builder.append("\t\t"); + ActorClass _actorClass_2 = ai.getActorClass(); + String _name_7 = _actorClass_2.getName(); + _builder.append(_name_7, " "); _builder.append("_receiveMessage((void*)&"); - String _path_4 = ai.getPath(); - String _pathName_3 = this.roomExt.getPathName(_path_4); - _builder.append(_pathName_3, " "); - _builder.append(",(etPort*)&"); String _path_5 = ai.getPath(); String _pathName_4 = this.roomExt.getPathName(_path_5); _builder.append(_pathName_4, " "); + _builder.append(",(etPort*)&"); + String _path_6 = ai.getPath(); + String _pathName_5 = this.roomExt.getPathName(_path_6); + _builder.append(_pathName_5, " "); _builder.append("_const."); - String _name_5 = pi.getName(); - _builder.append(_name_5, " "); + String _name_8 = pi.getName(); + _builder.append(_name_8, " "); _builder.append(".ports["); EList<InterfaceItemInstance> _peers_4 = pi.getPeers(); int _indexOf_3 = _peers_4.indexOf(peer); @@ -1318,49 +1480,70 @@ public class SubSystemClassGen { _builder.append(":"); _builder.newLineIfNotEmpty(); { - InterfaceItem _interfaceItem_2 = pi.getInterfaceItem(); - ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol(); - boolean _isConjugated_2 = this.roomExt.isConjugated(pi); - boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_2, _isConjugated_2); + InterfaceItem _interfaceItem_4 = pi.getInterfaceItem(); + ProtocolClass _protocol_4 = _interfaceItem_4.getProtocol(); + boolean _isConjugated_3 = this.roomExt.isConjugated(pi); + boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_4, _isConjugated_3); if (_handlesReceive_1) { _builder.append("\t\t"); - InterfaceItem _interfaceItem_3 = pi.getInterfaceItem(); - ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol(); - boolean _isConjugated_3 = this.roomExt.isConjugated(pi); - String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3); - _builder.append(_portClassName_1, " "); - _builder.append("_handleReceive((etPort*)&"); - String _path_6 = ai.getPath(); - String _pathName_5 = this.roomExt.getPathName(_path_6); - _builder.append(_pathName_5, " "); - _builder.append("_const."); - String _name_6 = pi.getName(); - _builder.append(_name_6, " "); - _builder.append(",msg,(void*)&"); - String _path_7 = ai.getPath(); - String _pathName_6 = this.roomExt.getPathName(_path_7); - _builder.append(_pathName_6, " "); - _builder.append(","); - ActorClass _actorClass_2 = ai.getActorClass(); - String _name_7 = _actorClass_2.getName(); - _builder.append(_name_7, " "); - _builder.append("_receiveMessage);"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t\t"); - _builder.append("//etPort_receive(&"); - String _path_8 = ai.getPath(); - String _pathName_7 = this.roomExt.getPathName(_path_8); - _builder.append(_pathName_7, " "); - _builder.append("_const."); - String _name_8 = pi.getName(); - _builder.append(_name_8, " "); - _builder.append(", msg);"); - _builder.newLineIfNotEmpty(); + _builder.append("switch (msg->evtID){"); + _builder.newLine(); + { + InterfaceItem _interfaceItem_5 = pi.getInterfaceItem(); + ProtocolClass _protocol_5 = _interfaceItem_5.getProtocol(); + boolean _isConjugated_4 = this.roomExt.isConjugated(pi); + List<MessageHandler> _receiveHandlers_1 = this.roomExt.getReceiveHandlers(_protocol_5, _isConjugated_4); + for(final MessageHandler h_1 : _receiveHandlers_1) { + _builder.append("\t\t"); + _builder.append("case "); + InterfaceItem _interfaceItem_6 = pi.getInterfaceItem(); + ProtocolClass _protocol_6 = _interfaceItem_6.getProtocol(); + String _name_9 = _protocol_6.getName(); + _builder.append(_name_9, " "); + _builder.append("_"); + Message _msg_2 = h_1.getMsg(); + String _codeName_1 = this.roomExt.getCodeName(_msg_2); + _builder.append(_codeName_1, " "); + _builder.append(":"); + _builder.newLineIfNotEmpty(); + _builder.append("\t\t"); + _builder.append("\t"); + InterfaceItem _interfaceItem_7 = pi.getInterfaceItem(); + ProtocolClass _protocol_7 = _interfaceItem_7.getProtocol(); + boolean _isConjugated_5 = this.roomExt.isConjugated(pi); + String _portClassName_1 = this.roomExt.getPortClassName(_protocol_7, _isConjugated_5); + _builder.append(_portClassName_1, " "); + _builder.append("_"); + Message _msg_3 = h_1.getMsg(); + String _name_10 = _msg_3.getName(); + _builder.append(_name_10, " "); + _builder.append("_receiveHandler((etPort *)&"); + String _path_7 = ai.getPath(); + String _pathName_6 = this.roomExt.getPathName(_path_7); + _builder.append(_pathName_6, " "); + _builder.append("_const."); + String _name_11 = pi.getName(); + _builder.append(_name_11, " "); + _builder.append(",msg,(void*)&"); + String _path_8 = ai.getPath(); + String _pathName_7 = this.roomExt.getPathName(_path_8); + _builder.append(_pathName_7, " "); + _builder.append(","); + ActorClass _actorClass_3 = ai.getActorClass(); + String _name_12 = _actorClass_3.getName(); + _builder.append(_name_12, " "); + _builder.append("_receiveMessage);"); + _builder.newLineIfNotEmpty(); + _builder.append("\t\t"); + _builder.append("break;"); + _builder.newLine(); + } + } _builder.append("\t\t"); - ActorClass _actorClass_3 = ai.getActorClass(); - String _name_9 = _actorClass_3.getName(); - _builder.append(_name_9, " "); + _builder.append("default: "); + ActorClass _actorClass_4 = ai.getActorClass(); + String _name_13 = _actorClass_4.getName(); + _builder.append(_name_13, " "); _builder.append("_receiveMessage((void*)&"); String _path_9 = ai.getPath(); String _pathName_8 = this.roomExt.getPathName(_path_9); @@ -1370,8 +1553,32 @@ public class SubSystemClassGen { String _pathName_9 = this.roomExt.getPathName(_path_10); _builder.append(_pathName_9, " "); _builder.append("_const."); - String _name_10 = pi.getName(); - _builder.append(_name_10, " "); + String _name_14 = pi.getName(); + _builder.append(_name_14, " "); + _builder.append(", msg);"); + _builder.newLineIfNotEmpty(); + _builder.append("\t\t"); + _builder.append("break;"); + _builder.newLine(); + _builder.append("\t\t"); + _builder.append("}"); + _builder.newLine(); + } else { + _builder.append("\t\t"); + ActorClass _actorClass_5 = ai.getActorClass(); + String _name_15 = _actorClass_5.getName(); + _builder.append(_name_15, " "); + _builder.append("_receiveMessage((void*)&"); + String _path_11 = ai.getPath(); + String _pathName_10 = this.roomExt.getPathName(_path_11); + _builder.append(_pathName_10, " "); + _builder.append(",(etPort*)&"); + String _path_12 = ai.getPath(); + String _pathName_11 = this.roomExt.getPathName(_path_12); + _builder.append(_pathName_11, " "); + _builder.append("_const."); + String _name_16 = pi.getName(); + _builder.append(_name_16, " "); _builder.append(", msg);"); _builder.newLineIfNotEmpty(); } @@ -1392,7 +1599,7 @@ public class SubSystemClassGen { _builder.append("\t\t\t"); _builder.append("etLogger_logErrorF(\"MessageService_Thread1_receiveMessage: address %d does not exist \", msg->address);"); _builder.newLine(); - _builder.append("\t\t\t"); + _builder.append("\t\t"); _builder.append("break;"); _builder.newLine(); _builder.append("\t"); diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c index 90b0f19cb..d8b94aa04 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.c @@ -16,13 +16,14 @@ #include "platform/etMemory.h"
#include <string.h>
+/*
void etPort_receive(const etPort* self, const etMessage* msg) {
ET_MSC_LOGGER_SYNC_ENTRY("etPort", "receive")
if (self->receiveMessageFunc!=NULL)
(self->receiveMessageFunc)(self->myActor, (void*)self, msg);
ET_MSC_LOGGER_SYNC_EXIT
}
-
+*/
void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data) {
int offset = MEM_CEIL(sizeof(etMessage));
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h index 49321065a..f6fe71c2d 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h @@ -21,8 +21,7 @@ #include "messaging/etMessageService.h"
typedef struct {
- void* myActor;
- etActorReceiveMessage receiveMessageFunc;
+ void* varData;
etMessageService* msgService;
etAddressId peerAddress;
etAddressId localId;
@@ -34,8 +33,7 @@ typedef struct { } etPort;
typedef struct {
- void* myActor;
- etActorReceiveMessage receiveMessageFunc;
+ void* varData;
etMessageService* msgService;
etAddressId peerAddress;
etAddressId localId;
@@ -54,7 +52,7 @@ typedef struct { typedef etPort* InterfaceItemBase;
-void etPort_receive(const etPort* self, const etMessage* msg);
+//void etPort_receive(const etPort* self, const etMessage* msg);
void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data);
|