summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-09-12 06:26:19 (EDT)
committerPeter Karlitschek2012-09-12 06:26:19 (EDT)
commitaa71161c1f1211d555321fae7124165e1084e1bc (patch)
tree43956abbc0ccc29fb7d9cc1d67aebed8e1d1e306
parentb858839b0232732c9ada4022bfb979163b59ee5c (diff)
downloadorg.eclipse.etrice-aa71161c1f1211d555321fae7124165e1084e1bc.zip
org.eclipse.etrice-aa71161c1f1211d555321fae7124165e1084e1bc.tar.gz
org.eclipse.etrice-aa71161c1f1211d555321fae7124165e1084e1bc.tar.bz2
cpp generator: first shot of actor generatorrefs/changes/33/8133/1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend217
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend245
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java19
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.smap19
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java473
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp60
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h56
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h2
15 files changed, 510 insertions, 608 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
new file mode 100644
index 0000000..1baee4b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+
+import org.eclipse.etrice.generator.base.AbstractGenerator
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
+import java.util.ArrayList
+import org.eclipse.xtend2.lib.StringConcatenation
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
+
+@Singleton
+class ActorClassGen extends GenericActorClassGenerator {
+
+ @Inject JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions
+ @Inject extension RoomExtensions
+
+ @Inject extension ProcedureHelpers
+// @Inject extension StateMachineGen
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (xpac: root.xpActorClasses) {
+ var path = xpac.actorClass.generationTargetPath+xpac.actorClass.getPath
+
+ logger.logInfo("generating ActorClass header '"+xpac.actorClass.getCppHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(xpac.actorClass.getCppHeaderFileName, root.generateHeaderFile(xpac, xpac.actorClass))
+
+ logger.logInfo("generating ActorClass source '"+xpac.actorClass.getCppSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(xpac.actorClass.getCppSourceFileName, root.generateSourceFile(xpac, xpac.actorClass))
+
+ }
+ }
+
+ def generateHeaderFile(Root root, ExpandedActorClass xpac, ActorClass ac) {
+ val ctor = ac.operations.filter(op|op.constructor).head
+ val dtor = ac.operations.filter(op|op.destructor).head
+
+ '''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass «ac.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(ac.name)»
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/messaging/IRTObject.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/modelbase/ActorClassBase.h"
+ #include "common/modelbase/SubSystemClassBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/IMessageReceiver.h"
+ #include "common/debugging/DebuggingService.h"
+ #include <string>
+ #include <vector>
+
+ «FOR model : root.getReferencedModels(ac)»
+ #include "«model.name».h"
+ «ENDFOR»
+
+ «FOR pc : root.getReferencedProtocolClasses(ac)»
+ #include "«pc.^package»/«pc.name».h"
+ «ENDFOR»
+
+ «ac.userCode(1)»
+
+
+ class «ac.name» : public «IF ac.base!=null»«ac.base.name»«ELSE»etRuntime::ActorClassBase«ENDIF» {
+
+
+ protected:
+ //--------------------- ports
+ «ac.endPorts.map(port | '''«port.portClassName» «port.name»;''').join()»
+ //--------------------- saps
+ «ac.strSAPs.map(sap | '''«sap.portClassName» «sap.name»;''').join()»
+ //--------------------- services
+ «ac.serviceImplementations.map(svc | '''«svc.portClassName» «svc.spp.name»;''').join()»
+
+ //--------------------- interface item IDs
+ «genInterfaceItemConstants(xpac, ac)»
+
+ «ac.attributes.attributes»
+ «ac.operationsImplementation»
+
+ //--------------------- construction
+ public:
+ «ac.name»(etRuntime::IRTObject* parent, std::string name, std::vector<std::vector<etRuntime::Address>*> port_addr,
+ std::vector<std::vector<etRuntime::Address>*> peer_addr)
+ :«ac.generateConstructorInitalizerList»
+ {
+ setClassName("«ac.name»");
+
+ «ac.attributes.attributeInitialization(false)»
+
+ «IF ctor!=null»
+ {
+ // user defined constructor body
+ «AbstractGenerator::getInstance().getTranslatedCode(ctor.detailCode)»
+ }
+ «ENDIF»
+ }
+ «attributeSettersGettersImplementation(ac.attributes, ac.name)»
+ //--------------------- port getters
+ «FOR ep : ac.getEndPorts()»
+ «ep.portClassName.getterImplementation(ep.name, ac.name)»
+ «ENDFOR»
+ «FOR sap : ac.strSAPs»
+ «sap.portClassName.getterImplementation(sap.name, ac.name)»
+ «ENDFOR»
+ «FOR svc : ac.serviceImplementations»
+ «svc.portClassName.getterImplementation(svc.spp.name, ac.name)»
+ «ENDFOR»
+
+ //--------------------- lifecycle functions
+ public:
+ void init(){
+ initUser();
+ }
+
+ void start(){
+ startUser();
+ }
+
+ «IF !ac.overridesStop()»
+ void stop(){
+ stopUser();
+ }
+ «ENDIF»
+
+ void destroy(){
+ «IF dtor!=null»
+
+ // user defined destructor body
+ «AbstractGenerator::getInstance().getTranslatedCode(dtor.detailCode)»
+ «ENDIF»
+ }
+
+ «IF ac.hasNonEmptyStateMachine»
+««« «xpac.genStateMachine()»
+ «ELSEIF !xpac.hasStateMachine()»
+ //--------------------- no state machine
+ public:
+ void receiveEvent(etRuntime::InterfaceItemBase ifitem, int evt, void* data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ void executeInitTransition(){
+ }
+ «ENDIF»
+
+ «ac.userCode(2)»
+
+ };
+
+
+ «generateIncludeGuardEnd(ac.name)»
+ '''
+ }
+ def generateConstructorInitalizerList(ActorClass ac) {
+ var initializerList = new ArrayList<CharSequence>();
+ if (ac.base==null) {
+ initializerList.add('''etRuntime::ActorClassBase(parent, name, (*port_addr[0])[0], (*peer_addr[0])[0])''')
+ }
+ else {
+ initializerList.add('''«ac.base.name»(parent, name, port_addr, peer_addr)''')
+ }
+ // own ports
+ for ( ep : ac.getEndPorts() ) {
+ initializerList.add('''«ep.name»(this, "«ep.name»", IFITEM_«ep.name», «IF ep.multiplicity==1»0, «ENDIF»port_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF», peer_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF»)''');
+ }
+ // own saps
+ for ( sap : ac.strSAPs ) {
+ initializerList.add('''«sap.name»(this, "«sap.name»", IFITEM_«sap.name», 0, port_addr[IFITEM_«sap.name»][0], peer_addr[IFITEM_«sap.name»][0])''');
+ }
+ // own service implementations
+ for (svc : ac.serviceImplementations) {
+ initializerList.add('''«svc.spp.name»(this, "«svc.spp.name»", IFITEM_«svc.spp.name», port_addr[IFITEM_«svc.spp.name»], peer_addr[IFITEM_«svc.spp.name»])''');
+ }
+ return initializerList.join(',\n')
+ }
+
+
+ def generateSourceFile(Root root, ExpandedActorClass xpac, ActorClass ac) {
+ ''''''
+ }
+
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index 11e398e..12e840f 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -25,6 +25,7 @@ import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator
import java.util.List
import org.eclipse.xtext.util.Pair
+import org.eclipse.etrice.core.room.Port
@Singleton
@@ -123,4 +124,5 @@ class CppExtensions implements ILanguageExtension {
"\"" + s + "\"";
}
+
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index 9fafaeb..fb4877b 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -1,3 +1,4 @@
+
/*******************************************************************************
* Copyright (c) 2011 protos software gmbh (http://www.protos.de).
* All rights reserved. This program and the accompanying materials
@@ -66,10 +67,10 @@ class DataClassGen {
«generateIncludeGuardBegin(dc.path + dc.name)»
«IF dc.base!=null»
- #include "«dc.base.name».h"
+ #include "«dc.base.path»«dc.base.name».h"
«ENDIF»
«FOR classes : root.getReferencedDataClasses(dc)»
- #include "«classes.name».h"
+ #include "«classes.path»«classes.name».h"
«ENDFOR»
«var models = root.getReferencedModels(dc)»
«FOR model : models»
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
index 61ed44a..3fa38b4 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
@@ -25,7 +25,7 @@ class MainGen implements IGenerator {
@Inject DataClassGen dataClassGen
@Inject ProtocolClassGen protocolClassGen
-// @Inject ActorClassGen actorClassGen
+ @Inject ActorClassGen actorClassGen
// @Inject SubSystemClassGen subsystemClassGen
// @Inject SubSystemRunnerGen subsystemRunnerGen
@Inject PrepareFileSystem prepFS
@@ -42,7 +42,7 @@ class MainGen implements IGenerator {
def void doGenerate(Root e) {
dataClassGen.doGenerate(e);
protocolClassGen.doGenerate(e);
-// actorClassGen.doGenerate(e);
+ actorClassGen.doGenerate(e);
// subsystemClassGen.doGenerate(e);
if (!e.library) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index fce06d9..acae5bb 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -84,36 +84,32 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«helpers.userCode(pc.userCode1)»
«FOR dataClass : root.getReferencedDataClasses(pc)»
- #include "«dataClass.name».h"
+ #include "«dataClass.path»«dataClass.name».h"
«ENDFOR»
class «pc.name» {
public:
«IF pc.commType==CommunicationType::EVENT_DRIVEN» /* message IDs */
- class Events {
- public:
- «genMessageIDs(pc)»
- static bool isValidEvtID(int evtId) {
- return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
- };
- static bool isValidOutgoingEvtID(int evtId) {
- return ((Events::MSG_MIN < evtId) && (evtId < Events::«IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF»));
- };
- static bool isValidIncomingEvtID(int evtId) {
- return ((Events::«IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF» <= evtId) && (evtId < Events::MSG_MAX));
- };
- static std::string getMessageString(int msg_id);
-
- private:
- static std::string s_messageStrings[];
- };
+ «genMessageIDs(pc)»
+ static bool isValidEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
+ };
+ static bool isValidOutgoingEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < «IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF»));
+ };
+ static bool isValidIncomingEvtID(int evtId) {
+ return ((«IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF» <= evtId) && (evtId < MSG_MAX));
+ };
+ static std::string getMessageString(int msg_id);
+
+ private:
+ static std::string s_messageStrings[];
«ENDIF»
«helpers.userCode(pc.userCode2)»
-
-
- «portClassDeclaration(pc, false)»
- «portClassDeclaration(pc, true)»
};
+
+ «portClassDeclaration(pc, false)»
+ «portClassDeclaration(pc, true)»
«generateIncludeGuardEnd(pc.name)»
'''
}
@@ -123,55 +119,55 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
var portClassName = pc.getPortClassName(conj)
var replPortClassName = pc.getPortClassName(conj, true)
'''
- //------------------------------------------------------------------------------------------------------------
- // «IF conj»conjugated «ENDIF»port class
- //------------------------------------------------------------------------------------------------------------
- class «portClassName» : public etRuntime::PortBase {
- «IF pclass!=null»
- «helpers.userCode(pclass.userCode)»
- «ENDIF»
- public:
- // constructors
- «portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
- «portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»port class
+ //------------------------------------------------------------------------------------------------------------
+ class «portClassName» : public etRuntime::PortBase {
+ «IF pclass!=null»
+ «helpers.userCode(pclass.userCode)»
+ «ENDIF»
+ public:
+ // constructors
+ «portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
+ «portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);
+
+ virtual void receive(etRuntime::Message* m);
+ «IF pclass!=null»
+ «helpers.attributes(pclass.attributes)»
+ «helpers.operationsDeclaration(pclass.operations, portClassName)»
+ «ENDIF»
+ // outgoing messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessageDeclaration(m,conj)»
+ «ENDFOR»
+ };
+
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ class «replPortClassName» {
+ private:
+ int m_replication;
+ std::vector<«portClassName»> m_ports;
+
+ public:
+ «replPortClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);
+ virtual ~«replPortClassName»() {};
+
+ int getReplication() { return m_replication; }
+ int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
+ «portClassName» get(int i) {return m_ports.at(i);}
+
virtual void receive(etRuntime::Message* m);
- «IF pclass!=null»
- «helpers.attributes(pclass.attributes)»
- «helpers.operationsDeclaration(pclass.operations, portClassName)»
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ // outgoing messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessageDeclaration(m,conj)»
+ «ENDFOR»
«ENDIF»
- // outgoing messages
- «FOR m : pc.getOutgoing(conj)»
- «sendMessageDeclaration(m,conj)»
- «ENDFOR»
- };
-
- //------------------------------------------------------------------------------------------------------------
- // «IF conj»conjugated «ENDIF»replicated port class
- //------------------------------------------------------------------------------------------------------------
- class «replPortClassName» {
- private:
- int m_replication;
- std::vector<«portClassName»> m_ports;
-
- public:
- «replPortClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);
- virtual ~«replPortClassName»() {};
-
- int getReplication() { return m_replication; }
- int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
- «portClassName» get(int i) {return m_ports.at(i);}
-
- virtual void receive(etRuntime::Message* m);
- «IF pc.commType==CommunicationType::EVENT_DRIVEN»
- // outgoing messages
- «FOR m : pc.getOutgoing(conj)»
- «sendMessageDeclaration(m,conj)»
- «ENDFOR»
- «ENDIF»
-
- };
+ };
'''
}
@@ -184,25 +180,25 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// «IF conj»conjugated «ENDIF»port class
//------------------------------------------------------------------------------------------------------------
- «pc.name»::«portClassName»::«portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress)
+ «portClassName»::«portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress)
: PortBase(actor, parent, name, localId, 0, addr, peerAddress)
{
DebuggingService::getInstance().addPortInstance(*this);
}
- «pc.name»::«portClassName»::«portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress)
+ «portClassName»::«portClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress)
: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
{
DebuggingService::getInstance().addPortInstance(*this);
}
- void «pc.name»::«portClassName»::receive(Message* msg) {
- if (! Events::isValidIncomingEvtID(msg->getEvtId())) {
+ void «portClassName»::receive(Message* msg) {
+ if (! «pc.name»::isValidIncomingEvtID(msg->getEvtId())) {
std::cout << "unknown" << std::endl;
}
else {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), Events::getMessageString(msg->getEvtId()));
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), «pc.name»::getMessageString(msg->getEvtId()));
}
«IF pc.handlesReceive(conj)»
@@ -230,13 +226,13 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// sent messages
«FOR m : pc.getOutgoing(conj)»
- «sendMessage(m, pc.name + "::" + portClassName, conj)»
+ «sendMessage(m, pc.name, portClassName, conj)»
«ENDFOR»
//------------------------------------------------------------------------------------------------------------
// «IF conj»conjugated «ENDIF»replicated port class
//------------------------------------------------------------------------------------------------------------
- «pc.name»::«replPortClassName»::«replPortClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress)
+ «replPortClassName»::«replPortClassName»(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress)
: m_replication(addr.size()),
m_ports()
{
@@ -252,7 +248,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// outgoing messages
«FOR m : pc.getOutgoing(conj)»
- «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
+ «messageSignatureDefinition(m, replPortClassName)»{
for (int i=0; i<m_replication; ++i) {
m_ports.at(i).«messageCall(m)»;
}
@@ -272,6 +268,9 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
#include "«pc.getCppHeaderFileName»"
#include "common/debugging/DebuggingService.h"
#include <iostream>
+ «FOR classes : root.getReferencedDataClasses(pc)»
+ #include "«classes.name».h"
+ «ENDFOR»
using namespace etRuntime;
@@ -293,93 +292,19 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
- def private genDataDrivenPortHeaders(ProtocolClass pc) {
- var sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
-
- '''
- /* data driven send port (conjugated) */
- typedef struct {
- «FOR msg : sentMsgs»
- «var typeName = msg.data.refType.type.typeName»
- «var refp = if (msg.data.refType.ref) "*" else ""»
- «typeName»«refp» «msg.name»;
- «ENDFOR»
- }
- «pc.getPortClassName(true)»;
-
- /* data driven receive port (regular) */
- typedef struct {
- const «pc.getPortClassName(true)»* peer;
- }
- «pc.getPortClassName(false)»;
-
- «FOR message : sentMsgs»
- «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)) "*" else ""»
- «var data = if (hasData) ", "+typeName+refp+" data" else ""»
- «messageSetterSignature(pc.getPortClassName(true), message.name, data)»;
- «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)»;
-
- «ENDFOR»
- '''
- }
- def private genDataDrivenPortSources(ProtocolClass pc) {
- var messages = pc.allIncomingMessages.filter(m|m.data!=null)
- '''
- «FOR message : messages»
- «var typeName =message.data.refType.type.typeName»
- «var refp = if (!(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
- «var refa = if ((message.data.refType.type instanceof PrimitiveType)) "&" else ""»
- «var data = ", "+typeName+refp+" data"»
- «messageSetterSignature(pc.getPortClassName(true), message.name, data)» {
- self->«message.name» = data;
- }
- «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)» {
- return self->peer->«message.name»;
- }
-
- «ENDFOR»
- '''
- }
-
-
- def private messageSetterSignature(String className, String messageName, String data) {
- "void "+className+"_"+messageName+"_set("+className+"* self"+data+")"
- }
-
- def private messageGetterSignature(String className, String messageName, String type) {
- type+" "+className+"_"+messageName+"_get(const "+className+"* const self)"
- }
def private messageCall(Message m) {
'''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
}
- def private genReceiveHandlers(ProtocolClass pc, Boolean conj){
- var portClassName = pc.getPortClassName(conj)
- var replPortClassName = pc.getPortClassName(conj, true)
-
- '''
- /* receiver handlers */
- «FOR h:getReceiveHandlers(pc,conj)»
- void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
- «userCode(h.detailCode)»
- /* hand over the message to the actor: */
- /* (*receiveMessageFunc)(actor, self, msg); */
- }
- «ENDFOR»
- '''}
-
-
def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
««« TODO: make this optional or different for smaller footprint
/* message names as strings for debugging (generate MSC) */
- std::string «pc.name»::Events::s_messageStrings[]
+ std::string «pc.name»::s_messageStrings[]
= {"MIN",
«FOR m : pc.getAllOutgoingMessages()»
"«m.name»",
@@ -389,7 +314,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDFOR»
"MAX"};
- std::string «pc.name»::Events::getMessageString(int msg_id) {
+ std::string «pc.name»::getMessageString(int msg_id) {
if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
return s_messageStrings[msg_id];
} else {
@@ -401,9 +326,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
- //----------------------------------------------------
- // from java generator
- //---------------------------------------------------
+
def messageSignature(Message m) {
'''«IF m.priv»private:«ELSE»public:«ENDIF» void «m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
}
@@ -435,7 +358,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
- def sendMessage(Message m, String classPrefix, boolean conj) {
+ def sendMessage(Message m, String portClassName, String classPrefix, boolean conj) {
var dir = if (conj) "IN" else "OUT"
var hdlr = m.getSendHandler(conj)
'''
@@ -445,19 +368,23 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDFOR»
«ELSE»
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- Events::getMessageString(Events::«dir»_«m.name»));
+ «portClassName»::getMessageString(«portClassName»::«dir»_«m.name»));
if (getPeerAddress().isValid()){
- «IF m.data==null»getPeerMsgReceiver()->receive(new Message(getPeerAddress(), Events::«dir»_«m.name»));
- «ELSE»getPeerMsgReceiver()->receive(new Message(getPeerAddress(),Events::«dir»_«m.name», reinterpret_cast<void*>(«IF (m.data.refType.ref && !(m.data.refType.type instanceof PrimitiveType))»&«ENDIF»«m.data.name»), sizeof()));
+ «IF m.data==null»getPeerMsgReceiver()->receive(new Message(getPeerAddress(), «portClassName»::«dir»_«m.name»));
+ «ELSE»getPeerMsgReceiver()->receive(new Message(getPeerAddress(),«portClassName»::«dir»_«m.name»,
+ reinterpret_cast<void*>(«IF (m.data.refType.ref && !(m.data.refType.type instanceof PrimitiveType))»&«ENDIF»«m.data.name»),
+ sizeof(«m.data.refType.type.typeName»)));
«ENDIF»
}
«ENDIF»
}
+
«IF m.data!=null && m.data.refType.type instanceof DataClass»
«messageSignatureExplicitDefinition(m, classPrefix)» {
- «m.name»(new «m.data.refType.type.name»(«IF (m.data.refType.type as DataClass).base!=null»_super, «ENDIF»«FOR a : (m.data.refType.type as DataClass).attributes SEPARATOR ", "»«a.name»«ENDFOR»));
+ «m.name»(«m.data.refType.type.name»(«IF (m.data.refType.type as DataClass).base!=null»_super, «ENDIF»«FOR a : (m.data.refType.type as DataClass).attributes SEPARATOR ", "»«a.name»«ENDFOR»));
}
«ENDIF»
'''
+ //TODO derived data classes are not yet handled correctly
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
index b7c8bb7..9318fee 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
@@ -114,7 +114,10 @@ public class DataClassGen {
if (_notEquals) {
_builder.append("#include \"");
DataClass _base_1 = dc.getBase();
- String _name_1 = _base_1.getName();
+ String _path_1 = this.roomExt.getPath(_base_1);
+ _builder.append(_path_1, "");
+ DataClass _base_2 = dc.getBase();
+ String _name_1 = _base_2.getName();
_builder.append(_name_1, "");
_builder.append(".h\"");
_builder.newLineIfNotEmpty();
@@ -124,6 +127,8 @@ public class DataClassGen {
HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
for(final DataClass classes : _referencedDataClasses) {
_builder.append("#include \"");
+ String _path_2 = this.roomExt.getPath(classes);
+ _builder.append(_path_2, "");
String _name_2 = classes.getName();
_builder.append(_name_2, "");
_builder.append(".h\"");
@@ -138,8 +143,8 @@ public class DataClassGen {
EList<DataClass> _dataClasses = model.getDataClasses();
for(final DataClass classes_1 : _dataClasses) {
_builder.append("#include \"");
- String _path_1 = this.roomExt.getPath(classes_1);
- _builder.append(_path_1, "");
+ String _path_3 = this.roomExt.getPath(classes_1);
+ _builder.append(_path_3, "");
String _name_3 = classes_1.getName();
_builder.append(_name_3, "");
_builder.append(".h\"");
@@ -159,12 +164,12 @@ public class DataClassGen {
String _name_4 = dc.getName();
_builder.append(_name_4, "");
{
- DataClass _base_2 = dc.getBase();
- boolean _notEquals_1 = (!Objects.equal(_base_2, null));
+ DataClass _base_3 = dc.getBase();
+ boolean _notEquals_1 = (!Objects.equal(_base_3, null));
if (_notEquals_1) {
_builder.append(" : public ");
- DataClass _base_3 = dc.getBase();
- String _name_5 = _base_3.getName();
+ DataClass _base_4 = dc.getBase();
+ String _name_5 = _base_4.getName();
_builder.append(_name_5, "");
}
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
index ddd8374..b5290b5 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
@@ -6,6 +6,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.cpp.gen.ActorClassGen;
import org.eclipse.etrice.generator.cpp.gen.DataClassGen;
import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
import org.eclipse.etrice.generator.generic.PrepareFileSystem;
@@ -22,6 +23,9 @@ public class MainGen implements IGenerator {
private ProtocolClassGen protocolClassGen;
@Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
private PrepareFileSystem prepFS;
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
@@ -37,6 +41,7 @@ public class MainGen implements IGenerator {
public void doGenerate(final Root e) {
this.dataClassGen.doGenerate(e);
this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
boolean _isLibrary = e.isLibrary();
boolean _not = (!_isLibrary);
if (_not) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.smap b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.smap
new file mode 100644
index 0000000..f1eb532
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.smap
@@ -0,0 +1,19 @@
+SMAP
+MainGen.java
+Xtend
+*S Xtend
+*F
++ 0 MainGen.xtend
+src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
+*L
+34:32
+35:33,2
+36:35
+37:36
+36:37
+35:38
+43:42
+44:43
+45:44
+48:45,4
+*E
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
index 8fb6ef3..1e2bf28 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
@@ -28,8 +28,6 @@ import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
@Singleton
@SuppressWarnings("all")
@@ -147,6 +145,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
for(final DataClass dataClass : _referencedDataClasses) {
_builder.append("#include \"");
+ String _path = this.roomExt.getPath(dataClass);
+ _builder.append(_path, "");
String _name_2 = dataClass.getName();
_builder.append(_name_2, "");
_builder.append(".h\"");
@@ -168,30 +168,24 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
if (_equals) {
_builder.append("\t /* message IDs */");
_builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("class Events {");
- _builder.newLine();
_builder.append("\t\t");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t\t\t");
String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, " ");
+ _builder.append(_genMessageIDs, " ");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("static bool isValidEvtID(int evtId) {");
_builder.newLine();
- _builder.append("\t\t\t\t");
+ _builder.append("\t\t\t");
_builder.append("return ((MSG_MIN < evtId) && (evtId < MSG_MAX));");
_builder.newLine();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("};");
_builder.newLine();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("static bool isValidOutgoingEvtID(int evtId) {");
_builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("return ((Events::MSG_MIN < evtId) && (evtId < Events::");
+ _builder.append("\t\t\t");
+ _builder.append("return ((MSG_MIN < evtId) && (evtId < ");
{
EList<Message> _incomingMessages = pc.getIncomingMessages();
int _size = _incomingMessages.size();
@@ -203,19 +197,19 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
EList<Message> _incomingMessages_1 = pc.getIncomingMessages();
Message _get = _incomingMessages_1.get(0);
String _name_4 = _get.getName();
- _builder.append(_name_4, " ");
+ _builder.append(_name_4, " ");
}
}
_builder.append("));");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("};");
_builder.newLine();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("static bool isValidIncomingEvtID(int evtId) {");
_builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("return ((Events::");
+ _builder.append("\t\t\t");
+ _builder.append("return ((");
{
EList<Message> _incomingMessages_2 = pc.getIncomingMessages();
int _size_1 = _incomingMessages_2.size();
@@ -227,28 +221,25 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
EList<Message> _incomingMessages_3 = pc.getIncomingMessages();
Message _get_1 = _incomingMessages_3.get(0);
String _name_5 = _get_1.getName();
- _builder.append(_name_5, " ");
+ _builder.append(_name_5, " ");
}
}
- _builder.append(" <= evtId) && (evtId < Events::MSG_MAX));");
+ _builder.append(" <= evtId) && (evtId < MSG_MAX));");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("};");
_builder.newLine();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("static std::string getMessageString(int msg_id);");
_builder.newLine();
- _builder.append("\t\t");
+ _builder.append("\t");
_builder.newLine();
- _builder.append("\t\t");
+ _builder.append("\t");
_builder.append("private:");
_builder.newLine();
- _builder.append("\t\t\t");
+ _builder.append("\t\t");
_builder.append("static std::string s_messageStrings[];");
_builder.newLine();
- _builder.append("\t");
- _builder.append("};");
- _builder.newLine();
}
}
_builder.append("\t\t");
@@ -256,19 +247,15 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
_builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
+ _builder.append("};");
_builder.newLine();
- _builder.append("\t \t\t");
_builder.newLine();
- _builder.append("\t\t");
CharSequence _portClassDeclaration = this.portClassDeclaration(pc, Boolean.valueOf(false));
- _builder.append(_portClassDeclaration, " ");
+ _builder.append(_portClassDeclaration, "");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t");
CharSequence _portClassDeclaration_1 = this.portClassDeclaration(pc, Boolean.valueOf(true));
- _builder.append(_portClassDeclaration_1, " ");
+ _builder.append(_portClassDeclaration_1, "");
_builder.newLineIfNotEmpty();
- _builder.append("};");
- _builder.newLine();
String _name_6 = pc.getName();
CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_6);
_builder.append(_generateIncludeGuardEnd, "");
@@ -464,9 +451,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("//------------------------------------------------------------------------------------------------------------");
_builder.newLine();
_builder.newLine();
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("::");
_builder.append(portClassName, "");
_builder.append("::");
_builder.append(portClassName, "");
@@ -483,9 +467,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("}");
_builder.newLine();
_builder.newLine();
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append("::");
_builder.append(portClassName, "");
_builder.append("::");
_builder.append(portClassName, "");
@@ -504,15 +485,15 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
_builder.newLine();
_builder.append("void ");
- String _name_2 = pc.getName();
- _builder.append(_name_2, "");
- _builder.append("::");
_builder.append(portClassName, "");
_builder.append("::receive(Message* msg) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("if (! Events::isValidIncomingEvtID(msg->getEvtId())) {");
- _builder.newLine();
+ _builder.append("if (! ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append("::isValidIncomingEvtID(msg->getEvtId())) {");
+ _builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("std::cout << \"unknown\" << std::endl;");
_builder.newLine();
@@ -526,8 +507,11 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("if (msg->hasDebugFlagSet()) {\t\t\t// TODO: model switch for activation of this flag");
_builder.newLine();
_builder.append("\t\t\t");
- _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), Events::getMessageString(msg->getEvtId()));");
- _builder.newLine();
+ _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), ");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("::getMessageString(msg->getEvtId()));");
+ _builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
@@ -614,10 +598,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
List<Message> _outgoing = this.roomExt.getOutgoing(pc, (conj).booleanValue());
for(final Message m : _outgoing) {
- String _name_3 = pc.getName();
- String _plus = (_name_3 + "::");
- String _plus_1 = (_plus + portClassName);
- CharSequence _sendMessage = this.sendMessage(m, _plus_1, (conj).booleanValue());
+ String _name_2 = pc.getName();
+ CharSequence _sendMessage = this.sendMessage(m, _name_2, portClassName, (conj).booleanValue());
_builder.append(_sendMessage, "");
_builder.newLineIfNotEmpty();
}
@@ -636,9 +618,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLineIfNotEmpty();
_builder.append("//------------------------------------------------------------------------------------------------------------");
_builder.newLine();
- String _name_4 = pc.getName();
- _builder.append(_name_4, "");
- _builder.append("::");
_builder.append(replPortClassName, "");
_builder.append("::");
_builder.append(replPortClassName, "");
@@ -683,10 +662,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
for(final Message m_1 : _outgoing_1) {
- String _name_5 = pc.getName();
- String _plus_2 = (_name_5 + "::");
- String _plus_3 = (_plus_2 + replPortClassName);
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, _plus_3);
+ CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName);
_builder.append(_messageSignatureDefinition, "");
_builder.append("{");
_builder.newLineIfNotEmpty();
@@ -746,6 +722,17 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
_builder.append("#include <iostream>");
_builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass classes : _referencedDataClasses) {
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _name_1 = classes.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.newLine();
_builder.append("\t");
_builder.append("using namespace etRuntime;");
@@ -795,249 +782,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _builder;
}
- private CharSequence genDataDrivenPortHeaders(final ProtocolClass pc) {
- CharSequence _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- return Boolean.valueOf(_notEquals);
- }
- };
- Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* data driven send port (conjugated) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- {
- for(final Message msg : sentMsgs) {
- _builder.append("\t");
- VarDecl _data = msg.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String typeName = this._typeHelpers.typeName(_type);
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression = null;
- VarDecl _data_1 = msg.getData();
- RefableType _refType_1 = _data_1.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(typeName, " ");
- _builder.append(refp, " ");
- _builder.append(" ");
- String _name = msg.getName();
- _builder.append(_name, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- String _portClassName = this.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* data driven receive port (regular) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName_1, " ");
- _builder.append("* peer;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
- _builder.append(_portClassName_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- for(final Message message : sentMsgs) {
- VarDecl _data_2 = message.getData();
- boolean hasData = (!Objects.equal(_data_2, null));
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- String _typeName = this._typeHelpers.typeName(_type_1);
- _xifexpression_1 = _typeName;
- } else {
- _xifexpression_1 = "";
- }
- String typeName_1 = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _and = false;
- if (!hasData) {
- _and = false;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- DataType _type_2 = _refType_3.getType();
- boolean _not = (!(_type_2 instanceof PrimitiveType));
- _and = (hasData && _not);
- }
- if (_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp_1 = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _plus = (", " + typeName_1);
- String _plus_1 = (_plus + refp_1);
- String _plus_2 = (_plus_1 + " data");
- _xifexpression_3 = _plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _portClassName_3 = this.roomExt.getPortClassName(pc, true);
- String _name_1 = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _portClassName_4 = this.roomExt.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
- _builder.append(_messageGetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence genDataDrivenPortSources(final ProtocolClass pc) {
- CharSequence _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- return Boolean.valueOf(_notEquals);
- }
- };
- Iterable<Message> messages = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String typeName = this._typeHelpers.typeName(_type);
- _builder.newLineIfNotEmpty();
- String _xifexpression = null;
- VarDecl _data_1 = message.getData();
- RefableType _refType_1 = _data_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _not = (!(_type_1 instanceof PrimitiveType));
- if (_not) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- VarDecl _data_2 = message.getData();
- RefableType _refType_2 = _data_2.getRefType();
- DataType _type_2 = _refType_2.getType();
- if ((_type_2 instanceof PrimitiveType)) {
- _xifexpression_1 = "&";
- } else {
- _xifexpression_1 = "";
- }
- String refa = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _plus = (", " + typeName);
- String _plus_1 = (_plus + refp);
- String data = (_plus_1 + " data");
- _builder.newLineIfNotEmpty();
- String _portClassName = this.roomExt.getPortClassName(pc, true);
- String _name = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("self->");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = data;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_1 = this.roomExt.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
- _builder.append(_messageGetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return self->peer->");
- String _name_3 = message.getName();
- _builder.append(_name_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private String messageSetterSignature(final String className, final String messageName, final String data) {
- String _plus = ("void " + className);
- String _plus_1 = (_plus + "_");
- String _plus_2 = (_plus_1 + messageName);
- String _plus_3 = (_plus_2 + "_set(");
- String _plus_4 = (_plus_3 + className);
- String _plus_5 = (_plus_4 + "* self");
- String _plus_6 = (_plus_5 + data);
- String _plus_7 = (_plus_6 + ")");
- return _plus_7;
- }
-
- private String messageGetterSignature(final String className, final String messageName, final String type) {
- String _plus = (type + " ");
- String _plus_1 = (_plus + className);
- String _plus_2 = (_plus_1 + "_");
- String _plus_3 = (_plus_2 + messageName);
- String _plus_4 = (_plus_3 + "_get(const ");
- String _plus_5 = (_plus_4 + className);
- String _plus_6 = (_plus_5 + "* const self)");
- return _plus_6;
- }
-
private CharSequence messageCall(final Message m) {
StringConcatenation _builder = new StringConcatenation();
String _name = m.getName();
@@ -1057,47 +801,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _builder;
}
- private CharSequence genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* receiver handlers */");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler h : _receiveHandlers) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- Message _msg = h.getMsg();
- 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");
- DetailCode _detailCode = h.getDetailCode();
- CharSequence _userCode = this.helpers.userCode(_detailCode);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _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();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
@@ -1106,7 +809,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("std::string ");
String _name = pc.getName();
_builder.append(_name, "");
- _builder.append("::Events::s_messageStrings[] ");
+ _builder.append("::s_messageStrings[] ");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("= {\"MIN\", ");
@@ -1140,7 +843,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("std::string ");
String _name_3 = pc.getName();
_builder.append(_name_3, "");
- _builder.append("::Events::getMessageString(int msg_id) {");
+ _builder.append("::getMessageString(int msg_id) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {");
@@ -1362,7 +1065,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _builder;
}
- public CharSequence sendMessage(final Message m, final String classPrefix, final boolean conj) {
+ public CharSequence sendMessage(final Message m, final String portClassName, final String classPrefix, final boolean conj) {
CharSequence _xblockexpression = null;
{
String _xifexpression = null;
@@ -1397,7 +1100,10 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t\t\t\t\t\t\t\t\t\t\t ");
- _builder.append("Events::getMessageString(Events::");
+ _builder.append(portClassName, " ");
+ _builder.append("::getMessageString(");
+ _builder.append(portClassName, " ");
+ _builder.append("::");
_builder.append(dir, " ");
_builder.append("_");
String _name = m.getName();
@@ -1413,7 +1119,9 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
VarDecl _data = m.getData();
boolean _equals = Objects.equal(_data, null);
if (_equals) {
- _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(), Events::");
+ _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(), ");
+ _builder.append(portClassName, " ");
+ _builder.append("::");
_builder.append(dir, " ");
_builder.append("_");
String _name_1 = m.getName();
@@ -1423,12 +1131,19 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
_builder.append("\t");
} else {
- _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(),Events::");
+ _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(),");
+ _builder.append(portClassName, " ");
+ _builder.append("::");
_builder.append(dir, " ");
_builder.append("_");
String _name_2 = m.getName();
_builder.append(_name_2, " ");
- _builder.append(", reinterpret_cast<void*>(");
+ _builder.append(", ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(" ");
+ _builder.append("reinterpret_cast<void*>(");
{
boolean _and = false;
VarDecl _data_1 = m.getData();
@@ -1449,8 +1164,19 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
VarDecl _data_3 = m.getData();
String _name_3 = _data_3.getName();
- _builder.append(_name_3, " ");
- _builder.append("), sizeof()));");
+ _builder.append(_name_3, " ");
+ _builder.append("),");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(" ");
+ _builder.append("sizeof(");
+ VarDecl _data_4 = m.getData();
+ RefableType _refType_2 = _data_4.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName, " ");
+ _builder.append(")));");
_builder.newLineIfNotEmpty();
}
}
@@ -1461,17 +1187,18 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
_builder.append("}");
_builder.newLine();
+ _builder.newLine();
{
boolean _and_1 = false;
- VarDecl _data_4 = m.getData();
- boolean _notEquals_1 = (!Objects.equal(_data_4, null));
+ VarDecl _data_5 = m.getData();
+ boolean _notEquals_1 = (!Objects.equal(_data_5, null));
if (!_notEquals_1) {
_and_1 = false;
} else {
- VarDecl _data_5 = m.getData();
- RefableType _refType_2 = _data_5.getRefType();
- DataType _type_1 = _refType_2.getType();
- _and_1 = (_notEquals_1 && (_type_1 instanceof DataClass));
+ VarDecl _data_6 = m.getData();
+ RefableType _refType_3 = _data_6.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ _and_1 = (_notEquals_1 && (_type_2 instanceof DataClass));
}
if (_and_1) {
CharSequence _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
@@ -1481,28 +1208,28 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
String _name_4 = m.getName();
_builder.append(_name_4, " ");
- _builder.append("(new ");
- VarDecl _data_6 = m.getData();
- RefableType _refType_3 = _data_6.getRefType();
- DataType _type_2 = _refType_3.getType();
- String _name_5 = _type_2.getName();
+ _builder.append("(");
+ VarDecl _data_7 = m.getData();
+ RefableType _refType_4 = _data_7.getRefType();
+ DataType _type_3 = _refType_4.getType();
+ String _name_5 = _type_3.getName();
_builder.append(_name_5, " ");
_builder.append("(");
{
- VarDecl _data_7 = m.getData();
- RefableType _refType_4 = _data_7.getRefType();
- DataType _type_3 = _refType_4.getType();
- DataClass _base = ((DataClass) _type_3).getBase();
+ VarDecl _data_8 = m.getData();
+ RefableType _refType_5 = _data_8.getRefType();
+ DataType _type_4 = _refType_5.getType();
+ DataClass _base = ((DataClass) _type_4).getBase();
boolean _notEquals_2 = (!Objects.equal(_base, null));
if (_notEquals_2) {
_builder.append("_super, ");
}
}
{
- VarDecl _data_8 = m.getData();
- RefableType _refType_5 = _data_8.getRefType();
- DataType _type_4 = _refType_5.getType();
- EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
+ VarDecl _data_9 = m.getData();
+ RefableType _refType_6 = _data_9.getRefType();
+ DataType _type_5 = _refType_6.getType();
+ EList<Attribute> _attributes = ((DataClass) _type_5).getAttributes();
boolean _hasElements = false;
for(final Attribute a : _attributes) {
if (!_hasElements) {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
index 8dea489..901694c 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
@@ -10,7 +10,7 @@
namespace etRuntime {
-std::string RTSystemServicesProtocol::Events::s_messageStrings[] =
+std::string RTSystemServicesProtocol::s_messageStrings[] =
{ "MIN",
"dummy",
"executeInitialTransition",
@@ -18,7 +18,7 @@ std::string RTSystemServicesProtocol::Events::s_messageStrings[] =
"stopDebugging",
"MAX"};
-std::string RTSystemServicesProtocol::Events::getMessageString(int msg_id) {
+std::string RTSystemServicesProtocol::getMessageString(int msg_id) {
if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
return s_messageStrings[msg_id];
} else {
@@ -43,27 +43,27 @@ RTSystemServicesProtocol::~RTSystemServicesProtocol() {
// RTSystemServicesProtocolPort
//------------------------------------------------------------------
-RTSystemServicesProtocol::RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
int localId, Address addr, Address peerAddress)
:PortBase(actor, parent, name, localId, 0, addr, peerAddress)
{
DebuggingService::getInstance().addPortInstance(*this);
};
-RTSystemServicesProtocol::RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
int localId, int idx, Address addr, Address peerAddress)
: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
{
DebuggingService::getInstance().addPortInstance(*this);
};
-void RTSystemServicesProtocol::RTSystemServicesProtocolPort::receive(Message* msg) {
- if (! Events::isValidIncomingEvtID(msg->getEvtId())) {
+void RTSystemServicesProtocolPort::receive(Message* msg) {
+ if (! RTSystemServicesProtocol::isValidIncomingEvtID(msg->getEvtId())) {
std::cout << "unknown" << std::endl;
}
else {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), Events::getMessageString(msg->getEvtId()));
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
}
getActor().receiveEvent(*this, msg->getEvtId(), msg->getData());
}
@@ -71,10 +71,10 @@ void RTSystemServicesProtocol::RTSystemServicesProtocolPort::receive(Message* ms
// sent messages
-void RTSystemServicesProtocol::RTSystemServicesProtocolPort::dummy() {
+void RTSystemServicesProtocolPort::dummy() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- Events::getMessageString(Events::OUT_dummy));
- PortBase::send(Events::OUT_dummy);
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::OUT_dummy));
+ PortBase::send(RTSystemServicesProtocol::OUT_dummy);
};
//------------------------------------------------------------------
@@ -82,7 +82,7 @@ void RTSystemServicesProtocol::RTSystemServicesProtocolPort::dummy() {
//------------------------------------------------------------------
-RTSystemServicesProtocol::RTSystemServicesProtocolPortRepl::
+RTSystemServicesProtocolPortRepl::
RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress)
: m_replication(addr.size()),
m_ports()
@@ -98,7 +98,7 @@ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::
// outgoing messages
-void RTSystemServicesProtocol::RTSystemServicesProtocolPortRepl::dummy() {
+void RTSystemServicesProtocolPortRepl::dummy() {
for (int i = 0; i < m_replication; ++i) {
m_ports.at(i).dummy();
}
@@ -108,13 +108,13 @@ void RTSystemServicesProtocol::RTSystemServicesProtocolPortRepl::dummy() {
// RTSystemServicesProtocolConjPort
//------------------------------------------------------------------
-RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
std::string name, int localId, Address addr, Address peerAddress)
: PortBase(actor, parent, name, localId, 0, addr, peerAddress)
{
DebuggingService::getInstance().addPortInstance(*this);
}
-RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
std::string name, int localId, int idx, Address addr,
Address peerAddress)
: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
@@ -122,13 +122,13 @@ RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::RTSystemServicesProt
DebuggingService::getInstance().addPortInstance(*this);
}
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::receive(Message* msg) {
- if (! Events::isValidOutgoingEvtID(msg->getEvtId())) { //conjugated port receives out-messages
+void RTSystemServicesProtocolConjPort::receive(Message* msg) {
+ if (! RTSystemServicesProtocol::isValidOutgoingEvtID(msg->getEvtId())) { //conjugated port receives out-messages
std::cout << "unknown" << std::endl;
}
else {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), Events::getMessageString(msg->getEvtId()));
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
}
getActor().receiveEvent(*this, msg->getEvtId(), msg->getData());
}
@@ -136,22 +136,22 @@ void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::receive(Message
// sent messages
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::executeInitialTransition() {
+void RTSystemServicesProtocolConjPort::executeInitialTransition() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- Events::getMessageString(Events::IN_executeInitialTransition));
- PortBase::send(Events::IN_executeInitialTransition);
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_executeInitialTransition));
+ PortBase::send(RTSystemServicesProtocol::IN_executeInitialTransition);
}
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::startDebugging() {
+void RTSystemServicesProtocolConjPort::startDebugging() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- Events::getMessageString(Events::IN_startDebugging));
- PortBase::send(Events::IN_startDebugging);
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_startDebugging));
+ PortBase::send(RTSystemServicesProtocol::IN_startDebugging);
}
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::stopDebugging() {
+void RTSystemServicesProtocolConjPort::stopDebugging() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- Events::getMessageString(Events::IN_stopDebugging));
- PortBase::send(Events::IN_stopDebugging);
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_stopDebugging));
+ PortBase::send(RTSystemServicesProtocol::IN_stopDebugging);
}
//------------------------------------------------------------------
@@ -159,7 +159,7 @@ void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::stopDebugging()
//------------------------------------------------------------------
//TODO: data type of addr and peerAddress
-RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::
+RTSystemServicesProtocolConjPortRepl::
RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress)
: m_replication(addr.size()),
m_ports()
@@ -175,19 +175,19 @@ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, s
// sent messages
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
+void RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
for (int i = 0; i < m_replication; ++i) {
m_ports.at(i).executeInitialTransition();
}
}
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::startDebugging() {
+void RTSystemServicesProtocolConjPortRepl::startDebugging() {
for (int i = 0; i < m_replication; ++i) {
m_ports.at(i).startDebugging();
}
}
-void RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::stopDebugging() {
+void RTSystemServicesProtocolConjPortRepl::stopDebugging() {
for (int i = 0; i < m_replication; ++i) {
m_ports.at(i).stopDebugging();
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
index 848d4af..0658393 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
@@ -16,10 +16,29 @@
namespace etRuntime {
+//---------------------------------------------------
+// interface for port class
+//---------------------------------------------------
+class IRTSystemServicesProtocolPort {
+public:
+ virtual ~IRTSystemServicesProtocolPort() {};
+ virtual void dummy() = 0;
+};
+
+//---------------------------------------------------
+// interface for conjugated port class
+//---------------------------------------------------
+class IRTSystemServicesProtocolConjPort {
+public:
+ virtual ~IRTSystemServicesProtocolConjPort() {};
+ virtual void executeInitialTransition() = 0;
+ virtual void startDebugging() = 0;
+ virtual void stopDebugging() = 0;
+};
+
+
class RTSystemServicesProtocol {
public:
- class Events {
- public:
enum eventIDs {
MSG_MIN = 0,
OUT_dummy = 1,
@@ -33,39 +52,19 @@ public:
return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
};
static bool isValidOutgoingEvtID(int evtId) {
- return ((Events::MSG_MIN < evtId) && (evtId < Events::MSG_SEP));
+ return ((MSG_MIN < evtId) && (evtId < MSG_SEP));
};
static bool isValidIncomingEvtID(int evtId) {
- return ((Events::MSG_SEP <= evtId) && (evtId < Events::MSG_MAX));
+ return ((MSG_SEP <= evtId) && (evtId < MSG_MAX));
};
static std::string getMessageString(int msg_id);
private:
- static std::string s_messageStrings[];
- };
+ static std::string s_messageStrings[];
- //---------------------------------------------------
- // interface for port class
- //---------------------------------------------------
- class IRTSystemServicesProtocolPort {
- public:
- virtual void dummy() = 0;
- };
-
- //---------------------------------------------------
- // interface for conjugated port class
- //---------------------------------------------------
- class IRTSystemServicesProtocolConjPort {
- public:
- virtual void executeInitialTransition() = 0;
- virtual void startDebugging() = 0;
- virtual void stopDebugging() = 0;
- };
-
-public:
-
- RTSystemServicesProtocol();
- virtual ~RTSystemServicesProtocol();
+ RTSystemServicesProtocol();
+ virtual ~RTSystemServicesProtocol();
+};
//---------------------------------------------------
// port class
@@ -140,7 +139,6 @@ public:
void startDebugging();
void stopDebugging();
};
-};
} /* namespace etRuntime */
#endif /* RTSYSTEMSERVICESPROTOCOL_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
index a19b46d..dbd5682 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
@@ -19,7 +19,7 @@ ActorClassBase::ActorClassBase(IRTObject* parent, std::string name, Address ownA
m_ownMsgsvc(RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(ownAddr.m_threadID)) {
// own ports
- m_RTSystemPort = new RTSystemServicesProtocol::RTSystemServicesProtocolPort(*this, this, "RTSystemPort", 0, 0, ownAddr,
+ m_RTSystemPort = new RTSystemServicesProtocolPort(*this, this, "RTSystemPort", 0, 0, ownAddr,
systemPortPeerAddr);
}
@@ -34,12 +34,12 @@ bool ActorClassBase::handleSystemEvent(InterfaceItemBase ifitem, int evt, void*
}
switch (evt) {
- case RTSystemServicesProtocol::Events::IN_executeInitialTransition:
+ case RTSystemServicesProtocol::IN_executeInitialTransition:
executeInitTransition();
break;
- case RTSystemServicesProtocol::Events::IN_startDebugging:
+ case RTSystemServicesProtocol::IN_startDebugging:
break;
- case RTSystemServicesProtocol::Events::IN_stopDebugging:
+ case RTSystemServicesProtocol::IN_stopDebugging:
break;
}
return true;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
index 28dc8a1..7beaa54 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
@@ -59,7 +59,7 @@ protected:
* the current state
*/
int m_state;
- RTSystemServicesProtocol::RTSystemServicesProtocolPort* m_RTSystemPort;
+ RTSystemServicesProtocolPort* m_RTSystemPort;
bool handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data);
private:
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
index 173cb77..7d32bac 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
@@ -9,6 +9,7 @@
#include "common/messaging/MessageService.h"
#include "common/messaging/RTServices.h"
#include "ActorClassBase.h"
+#include "common/debugging/DebuggingService.h"
namespace etRuntime {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
index c1da895..d6b1065 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
@@ -53,7 +53,7 @@ public:
void testFinished(int errorCode);
protected:
- RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl* m_RTSystemPort;
+ RTSystemServicesProtocolConjPortRepl* m_RTSystemPort;
//--------------------- interface item IDs
static const int IFITEM_RTSystemPort = 0;
std::vector<ActorClassBase*> m_instances;