summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-09-26 08:28:16 (EDT)
committerPeter Karlitschek2012-09-26 08:28:16 (EDT)
commit0118d2fdeceec08236f7dc34a953d55e15228bb6 (patch)
treeccb3cd9140b7a1f544795f3fdedbd056db7ef036
parentaa71161c1f1211d555321fae7124165e1084e1bc (diff)
downloadorg.eclipse.etrice-0118d2fdeceec08236f7dc34a953d55e15228bb6.zip
org.eclipse.etrice-0118d2fdeceec08236f7dc34a953d55e15228bb6.tar.gz
org.eclipse.etrice-0118d2fdeceec08236f7dc34a953d55e15228bb6.tar.bz2
c++ generator: first compiling version!refs/changes/34/8134/1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend196
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend55
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend26
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend133
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend65
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend310
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend105
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java181
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.smap188
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java10
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.smap23
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java230
14 files changed, 1246 insertions, 292 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
index cf32bab..67db5da 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
@@ -4,13 +4,14 @@ Bundle-Name: C++ Generator
Bundle-SymbolicName: org.eclipse.etrice.generator.cpp
Require-Bundle: org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
org.eclipse.etrice.generator;bundle-version="0.1.0",
+ org.eclipse.etrice.core.config;bundle-version="0.2.0",
+ org.eclipse.etrice.generator.doc;bundle-version="0.1.0",
+ org.eclipse.etrice.core.genmodel,
org.eclipse.core.resources;bundle-version="3.6.0",
org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.ui.ide;bundle-version="3.7.0",
- org.eclipse.etrice.generator.doc;bundle-version="0.1.0",
org.eclipse.xtext;bundle-version="2.1.1",
- org.eclipse.etrice.core.genmodel,
org.eclipse.xtend.lib,
com.google.guava,
org.eclipse.xtext.xbase.lib
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
index 1baee4b..ff53dea 100644
--- 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
@@ -1,35 +1,21 @@
-/*******************************************************************************
- * 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 java.util.ArrayList
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.core.room.ActorClass
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
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class ActorClassGen extends GenericActorClassGenerator {
@@ -39,7 +25,7 @@ class ActorClassGen extends GenericActorClassGenerator {
@Inject extension RoomExtensions
@Inject extension ProcedureHelpers
-// @Inject extension StateMachineGen
+ @Inject extension StateMachineGen
@Inject ILogger logger
def doGenerate(Root root) {
@@ -53,7 +39,6 @@ class ActorClassGen extends GenericActorClassGenerator {
logger.logInfo("generating ActorClass source '"+xpac.actorClass.getCppSourceFileName+"' in '"+path+"'")
fileAccess.setOutputPath(path)
fileAccess.generateFile(xpac.actorClass.getCppSourceFileName, root.generateSourceFile(xpac, xpac.actorClass))
-
}
}
@@ -62,7 +47,7 @@ class ActorClassGen extends GenericActorClassGenerator {
val dtor = ac.operations.filter(op|op.destructor).head
'''
- /**
+ /**
* @author generated by eTrice
*
* Header File of ActorClass «ac.name»
@@ -84,12 +69,16 @@ class ActorClassGen extends GenericActorClassGenerator {
#include <vector>
«FOR model : root.getReferencedModels(ac)»
- #include "«model.name».h"
+««« #include "«model.name».h"
«ENDFOR»
«FOR pc : root.getReferencedProtocolClasses(ac)»
- #include "«pc.^package»/«pc.name».h"
+ #include "«pc.path»«pc.name».h"
«ENDFOR»
+ «FOR dc : root.getReferencedDataClasses(ac)»
+ #include "«dc.path»«dc.name».h"
+ «ENDFOR»
+
«ac.userCode(1)»
@@ -99,37 +88,26 @@ class ActorClassGen extends GenericActorClassGenerator {
protected:
//--------------------- ports
- «ac.endPorts.map(port | '''«port.portClassName» «port.name»;''').join()»
+ «ac.endPorts.map(port | '''«port.portClassName» «port.name»;''').join("\n")»
//--------------------- saps
- «ac.strSAPs.map(sap | '''«sap.portClassName» «sap.name»;''').join()»
+ «ac.strSAPs.map(sap | '''«sap.portClassName» «sap.name»;''').join("\n")»
//--------------------- services
- «ac.serviceImplementations.map(svc | '''«svc.portClassName» «svc.spp.name»;''').join()»
+ «ac.serviceImplementations.map(svc | '''«svc.portClassName» «svc.spp.name»;''').join("\n")»
//--------------------- 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
+ //--------------------- construction
+ «ac.name»(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr,
+ const std::vector<std::vector<etRuntime::Address> >& peer_addr);
+
+ «attributeSettersGettersImplementation(ac.attributes, ac.name)»
+ //--------------------- port getters
«FOR ep : ac.getEndPorts()»
«ep.portClassName.getterImplementation(ep.name, ac.name)»
«ENDFOR»
@@ -141,40 +119,22 @@ class ActorClassGen extends GenericActorClassGenerator {
«ENDFOR»
//--------------------- lifecycle functions
- public:
- void init(){
- initUser();
- }
-
- void start(){
- startUser();
- }
-
+ virtual void init();
+ virtual void start();
«IF !ac.overridesStop()»
- void stop(){
- stopUser();
- }
+ virtual void stop();
«ENDIF»
-
- void destroy(){
- «IF dtor!=null»
-
- // user defined destructor body
- «AbstractGenerator::getInstance().getTranslatedCode(dtor.detailCode)»
- «ENDIF»
- }
-
+ virtual void destroy();
«IF ac.hasNonEmptyStateMachine»
««« «xpac.genStateMachine()»
+ //--------------------- dummy instead of state machine gen
+ virtual void receiveEvent(const etRuntime::InterfaceItemBase& ifitem, int evt, void* data){};
+ virtual void executeInitTransition(){};
«ELSEIF !xpac.hasStateMachine()»
+ public:
//--------------------- no state machine
- public:
- void receiveEvent(etRuntime::InterfaceItemBase ifitem, int evt, void* data) {
- handleSystemEvent(ifitem, evt, data);
- }
-
- void executeInitTransition(){
- }
+ virtual void receiveEvent(const etRuntime::InterfaceItemBase& ifitem, int evt, void* data);
+ virtual void executeInitTransition();
«ENDIF»
«ac.userCode(2)»
@@ -188,29 +148,99 @@ class ActorClassGen extends GenericActorClassGenerator {
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])''')
+ initializerList.add('''ActorClassBase( parent, name, port_addr[0][0], peer_addr[0][0])''')
}
else {
- initializerList.add('''«ac.base.name»(parent, name, port_addr, peer_addr)''')
+ initializerList.add('''«ac.base.name»(*this, 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»)''');
+ initializerList.add('''«ep.name»(*this, 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])''');
+ initializerList.add('''«sap.name»(*this, 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»])''');
+ initializerList.add('''«svc.spp.name»(*this, this, "«svc.spp.name»", IFITEM_«svc.spp.name», port_addr[IFITEM_«svc.spp.name»], peer_addr[IFITEM_«svc.spp.name»])''');
}
- return initializerList.join(',\n')
+ return
+ '''
+ «initializerList.join(',\n')»
+ '''
}
def generateSourceFile(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
+ *
+ * Source File of ActorClass «ac.name»
+ *
+ */
+
+ #include "«ac.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include <iostream>
+
+ using namespace etRuntime;
+
+
+ «ac.name»::«ac.name»(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr,
+ const std::vector<std::vector<etRuntime::Address> >& peer_addr)
+ : «ac.generateConstructorInitalizerList»
+ {
+ setClassName("«ac.name»");
+ ««« TODO change to constructor initializer list
+ «ac.attributes.attributeInitialization(false)»
+
+ «IF ctor!=null»
+ {
+ // user defined constructor body
+ «AbstractGenerator::getInstance().getTranslatedCode(ctor.detailCode)»
+ }
+ «ENDIF»
+ }
+
+ void «ac.name»::init(){
+ initUser();
+ }
+
+ void «ac.name»::start(){
+ startUser();
+ }
+
+ «IF !ac.overridesStop()»
+ void «ac.name»::stop(){
+ stopUser();
+ }
+ «ENDIF»
+
+ void «ac.name»::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
+ void «ac.name»::receiveEvent(const etRuntime::InterfaceItemBase& ifitem, int evt, void* data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ void «ac.name»::executeInitTransition(){
+ }
+ «ENDIF»
+ '''
}
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 12e840f..08395be 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,13 +25,19 @@ 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
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.generator.generic.ConfigExtension
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.core.room.ComplexType
@Singleton
class CppExtensions implements ILanguageExtension {
@Inject AbstractTransitionChainGenerator chainGenerator
+ @Inject ILanguageExtension languageExt
+ @Inject extension ConfigExtension
+ @Inject extension TypeHelpers
override String getTypedDataDefinition(Message m) {
@@ -41,6 +47,8 @@ class CppExtensions implements ILanguageExtension {
def String getCppHeaderFileName(RoomClass rc) {rc.name+".h"}
def String getCppSourceFileName(RoomClass rc) {rc.name+".cpp"}
+ def String getInstSourceFileName(RoomClass rc) {rc.name+"_Inst.h"}
+ def String getDispSourceFileName(RoomClass rc) {rc.name+"_Disp.h"}
override String accessLevelPrivate() {""}
override String accessLevelProtected() {""}
@@ -67,11 +75,11 @@ class CppExtensions implements ILanguageExtension {
override String genEnumeration(String name, List<Pair<String, String>> entries) {
'''
- enum «name» {
+ typedef enum {
«FOR entry: entries»
«entry.first» = «entry.second»,
«ENDFOR»
- };'''.toString
+ } «name»;'''.toString
}
override String booleanConstant(boolean b) {
@@ -79,8 +87,8 @@ class CppExtensions implements ILanguageExtension {
}
override String pointerLiteral() { "" }
- override String nullPointer() { "null" }
- override String voidPointer() { "Object" }
+ override String nullPointer() { "0" }
+ override String voidPointer() { "void*" }
override String arrayDeclaration(String type, int size, String name, boolean isRef) {
type+" "+name+"[]";
@@ -124,5 +132,40 @@ class CppExtensions implements ILanguageExtension {
"\"" + s + "\"";
}
-
+
+ def attributeConstructorInitList(List<Attribute> attribs, boolean useClassDefaultsOnly) {
+ '''
+ // initialize attributes
+ «FOR a : attribs»
+ «var value = a.initValue»
+ «IF value!=null»
+ «IF !a.isArray»
+ «a.name» ( «value» ),
+ «ELSE»
+ «a.name» ( {
+ «FOR i : 0 .. a.size»
+ value,
+ «ENDFOR»
+ } )
+ «ENDIF»
+ «ELSEIF a.refType.type instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
+ «IF a.size==0»
+ «IF a.refType.isRef»
+ «a.name» ( «languageExt.nullPointer()» ),
+ «ELSE»
+ «a.name» ( «a.refType.type.defaultValue» ),
+ «ENDIF»
+ «ELSE»
+ «a.name» ( new «a.refType.type.typeName»[«a.size»] ),
+ «IF !useClassDefaultsOnly»
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «IF a.refType.isRef»«languageExt.nullPointer()»«ELSE»«a.refType.type.defaultValue»«ENDIF»;
+ }
+ «ENDIF»
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ '''
+ }
+
}
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 fb4877b..c3cad8f 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,15 +1,4 @@
-/*******************************************************************************
- * 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
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 3fa38b4..87658c1 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
@@ -10,15 +10,15 @@
*
*******************************************************************************/
-package org.eclipse.etrice.generator.cpp.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.etrice.generator.generic.PrepareFileSystem
-import org.eclipse.xtext.generator.IFileSystemAccess
-import org.eclipse.xtext.generator.IGenerator
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.generator.generic.PrepareFileSystem
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.generator.IGenerator
@Singleton
class MainGen implements IGenerator {
@@ -26,8 +26,8 @@ class MainGen implements IGenerator {
@Inject DataClassGen dataClassGen
@Inject ProtocolClassGen protocolClassGen
@Inject ActorClassGen actorClassGen
-// @Inject SubSystemClassGen subsystemClassGen
-// @Inject SubSystemRunnerGen subsystemRunnerGen
+ @Inject SubSystemClassGen subsystemClassGen
+ @Inject SubSystemRunnerGen subsystemRunnerGen
@Inject PrepareFileSystem prepFS
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
@@ -43,10 +43,10 @@ class MainGen implements IGenerator {
dataClassGen.doGenerate(e);
protocolClassGen.doGenerate(e);
actorClassGen.doGenerate(e);
-// subsystemClassGen.doGenerate(e);
-
+ subsystemClassGen.doGenerate(e);
+
if (!e.library) {
-// subsystemRunnerGen.doGenerate(e);
+ subsystemRunnerGen.doGenerate(e);
}
}
} \ No newline at end of file
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 acae5bb..6697ec6 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
@@ -1,35 +1,25 @@
-/*******************************************************************************
- * 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)
- * Thomas Schuetz (changed for C code generator)
- *
- *******************************************************************************/
-package org.eclipse.etrice.generator.cpp.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.CommunicationType
-import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.core.room.PrimitiveType
-import org.eclipse.etrice.core.room.ProtocolClass
-
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.etrice.generator.generic.TypeHelpers
-
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
@Singleton
@@ -159,7 +149,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
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)»
@@ -171,6 +160,37 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
+ def private generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
+ #include "«pc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include <iostream>
+
+ using namespace etRuntime;
+
+ «helpers.userCode(pc.userCode3)»
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ «helpers.userCode(pc.userCode2)»
+
+ «portClassImplementation(pc, false)»
+ «portClassImplementation(pc, true)»
+
+ /*--------------------- debug helpers */
+ «generateDebugHelpersImplementation(root, pc)»
+ «ENDIF»
+
+
+ '''
+ }
+
+
def portClassImplementation(ProtocolClass pc, Boolean conj) {
var pclass = pc.getPortClass(conj)
var portClassName = pc.getPortClassName(conj)
@@ -257,39 +277,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
- def private generateSourceFile(Root root, ProtocolClass pc) {'''
- /**
- * @author generated by eTrice
- *
- * Source File of ProtocolClass «pc.name»
- *
- */
-
- #include "«pc.getCppHeaderFileName»"
- #include "common/debugging/DebuggingService.h"
- #include <iostream>
- «FOR classes : root.getReferencedDataClasses(pc)»
- #include "«classes.name».h"
- «ENDFOR»
-
- using namespace etRuntime;
-
- «helpers.userCode(pc.userCode3)»
-
- «IF pc.commType==CommunicationType::EVENT_DRIVEN»
- «helpers.userCode(pc.userCode2)»
-
- «portClassImplementation(pc, false)»
- «portClassImplementation(pc, true)»
-
- /*--------------------- debug helpers */
- «generateDebugHelpersImplementation(root, pc)»
- «ENDIF»
-
-
- '''
- }
-
@@ -387,4 +374,26 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
//TODO derived data classes are not yet handled correctly
}
+
+ override getMessageID(Message msg, InterfaceItem item) {
+ if (item instanceof Port) {
+ var p = item as Port;
+ var direction = if (p.isConjugated())"OUT_" else "IN_"
+ return enumInUse(p.getProtocol().getName(), direction+msg.getName())
+ }
+ else if (item instanceof SAPRef) {
+ var sap = item as SAPRef;
+ return enumInUse(sap.getProtocol().getName(), "OUT_"+msg.getName())
+ }
+ else if (item instanceof SPPRef) {
+ var spp = item as SPPRef;
+ return enumInUse(spp.getProtocol().getName(), "IN_"+msg.getName())
+ }
+
+ return "unknown interface item";
+ }
+
+ def String enumInUse(String namespace, String member) {
+ return namespace+"::"+member
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
new file mode 100644
index 0000000..e28d2aa
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -0,0 +1,65 @@
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
+
+@Singleton
+class StateMachineGen extends GenericStateMachineGenerator {
+
+ @Inject extension RoomExtensions
+
+ def genHeaderConstants(ExpandedActorClass xpac) {
+
+ }
+
+ def genDataMembers(ExpandedActorClass xpac) {
+ val ac = xpac.actorClass
+ '''
+ /* state machine variables */
+ int m_state;
+ int m_history[«ac.name.toUpperCase»_HISTORY_SIZE];
+ '''}
+
+ def genInitialization(ExpandedActorClass xpac) {
+ val ac = xpac.actorClass
+ '''
+ m_state = STATE_TOP;
+ {
+ int i;
+ for (i=0; i<«ac.name.toUpperCase»_HISTORY_SIZE; ++i)
+ m_history[i] = NO_STATE;
+ }
+ executeInitTransition();
+ '''}
+ override genExtra(ExpandedActorClass xpac) {
+ val ac = xpac.actorClass
+ '''
+ // state names
+ protected:
+ static std::string stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStatesLeavesLast() SEPARATOR ","»"«state.getStatePathName()»"
+ «ENDFOR»};
+
+««« TODOHRR: history defined in ActorClassBase, init in constructor
+««« history = new int[5];
+««« for (int i = 0; i < history.length; i++) {
+««« history[i] = NO_STATE;
+««« }
+ // history
+ protected:
+ int history[] = {NO_STATE,NO_STATE«FOR state : ac.getAllBaseStates()»,NO_STATE«ENDFOR»};
+
+ private:
+ void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+««« TODOTS: model switch for activation
+ std::cout << getInstancePath() << " -> " << stateStrings[new_state] << std::endl;
+ }
+ m_state = new_state;
+ }
+ '''}
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
new file mode 100644
index 0000000..c16c79b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
@@ -0,0 +1,310 @@
+
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.generator.generic.ConfigExtension
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+
+import static extension org.eclipse.etrice.generator.base.Indexed.*
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+
+
+@Singleton
+class SubSystemClassGen {
+
+ @Inject JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions
+ @Inject extension RoomExtensions
+ @Inject extension ConfigExtension
+ @Inject extension ProcedureHelpers
+ @Inject extension TypeHelpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (ssi: root.subSystemInstances) {
+ var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
+ var file = ssi.subSystemClass.getCppHeaderFileName
+ logger.logInfo("generating SubSystemClass declaration: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateHeaderFile(ssi, ssi.subSystemClass))
+
+ file = ssi.subSystemClass.getCppSourceFileName
+ logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateSourceFile(ssi, ssi.subSystemClass))
+
+// file = ssi.subSystemClass.getInstSourceFileName
+// logger.logInfo("generating SubSystemClass instance file: '"+file+"' in '"+path+"'")
+// fileAccess.setOutputPath(path)
+// fileAccess.generateFile(file, root.generateInstanceFile(ssi, ssi.subSystemClass))
+//
+// file = ssi.subSystemClass.getDispSourceFileName
+// logger.logInfo("generating SubSystemClass dispatcher file: '"+file+"' in '"+path+"'")
+// fileAccess.setOutputPath(path)
+// fileAccess.generateFile(file, root.generateDispatcherFile(ssi, ssi.subSystemClass))
+ }
+ }
+
+ def generateHeaderFile(Root root, SubSystemInstance comp, SubSystemClass cc) {'''
+
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of SubSystemClass «comp.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(comp.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(cc)»
+««« #include "«model.name».h"
+ «ENDFOR»
+
+
+ «cc.userCode(1)»
+
+ class «comp.name» : public etRuntime::SubSystemClassBase{
+
+ «cc.userCode(2)»
+
+ public:
+ «comp.name»(IRTObject* parent, std::string name)
+ : etRuntime::SubSystemClassBase(parent, name)
+ {
+ }
+
+ virtual void receiveEvent(const etRuntime::InterfaceItemBase& ifitem, int evt, void* data);
+ virtual void instantiateMessageServices();
+ virtual void instantiateActors();
+
+ private:
+ std::vector<etRuntime::MessageService*> m_msgServices;
+ };
+
+ «generateIncludeGuardEnd(comp.name)»
+ '''
+ }
+
+ def generateSourceFile(Root root, SubSystemInstance comp, SubSystemClass cc) {'''
+
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of SubsystemClass «cc.name»
+ *
+ */
+
+ #include "«cc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include "common/messaging/RTSystemServicesProtocol.h"
+ «FOR ai : comp.allContainedInstances»
+ #include "«ai.actorClass.path»«ai.actorClass.name».h"
+ «ENDFOR»
+ #include <iostream>
+
+ using namespace etRuntime;
+
+ void «comp.name»::receiveEvent(const InterfaceItemBase& ifitem, int evt, void* data){
+ }
+
+ void «comp.name»::instantiateMessageServices(){
+
+ m_msgServices.push_back( new MessageService(this, Address(0, 0, 0),"MessageService_Main") );
+ «FOR thread : cc.threads»
+ m_msgServices.push_back(new MessageService(this, Address(0, «cc.threads.indexOf(thread)+1», 0),"MessageService_«thread.name»", «thread.prio»));
+ «ENDFOR»
+ for (std::vector<MessageService*>::iterator it=m_msgServices.begin(); it != m_msgServices.end(); ++it) {
+ RTServices::getInstance().getMsgSvcCtrl().addMsgSvc( *(*it));
+ }
+ }
+
+ void «comp.name»::instantiateActors(){
+ // all addresses
+ // Addresses for the Subsystem Systemport
+ «FOR ai : comp.allContainedInstances.indexed(comp.maxObjId)»
+ Address addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai.value)»(0,0,«ai.index1»);
+ «ENDFOR»
+
+ «FOR ai : comp.allContainedInstances»
+ // actor instance «ai.path» itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item_«ai.path.getPathName()»(0,«ai.threadId»,«ai.objId»);
+ // interface items of «ai.path»
+ «FOR pi : ai.orderedIfItemInstances»
+ «IF pi.replicated»
+ «FOR peer : pi.peers»
+ «var i = pi.peers.indexOf(peer)»
+ Address addr_item_«pi.path.getPathName()»_«i»(0,«pi.threadId»,«pi.objId+i»);
+ «ENDFOR»
+ «ELSE»
+ Address addr_item_«pi.path.getPathName()»(0,«ai.threadId»,«pi.objId»);
+ «ENDIF»
+ «ENDFOR»
+ «ENDFOR»
+
+ // instantiate all actor instances
+ m_instances.reserve(«comp.allContainedInstances.size»);
+ «FOR ai : comp.allContainedInstances»
+ //----------------------------------------------------------------------------------------------
+ // addresses for actor instance: «ai.name»
+ //----------------------------------------------------------------------------------------------
+ «generateOwnInterfaceItemAddresses(ai)»
+ «generatePeerInterfaceItemAddresses(ai, comp)»
+
+ m_instances[«comp.allContainedInstances.indexOf(ai)»] = new «ai.actorClass.name»(
+ «IF ai.eContainer instanceof SubSystemInstance»
+ this,
+ «ELSE»
+ m_instances[«comp.allContainedInstances.indexOf(ai.eContainer)»],
+ «ENDIF»
+ "«ai.name»",
+ «ai.name»_ownInterfaceItemAddresses,
+ «ai.name»_peerInterfaceItemAddresses
+ );
+ «ENDFOR»
+
+ // apply instance attribute configurations
+ «FOR ai : comp.allContainedInstances»
+ «var attrConfigs = ai.configAttributes»
+ «var portConfigs = ai.getConfigPorts»
+ «IF !attrConfigs.empty || !portConfigs.empty»
+ {
+ «var aiName = "inst"»
+ «ai.actorClass.name» «aiName» = («ai.actorClass.name») m_instances[«comp.allContainedInstances.indexOf(ai)»];
+ «FOR attrConfig : attrConfigs»
+ «var a = attrConfig.attribute»
+ «var value = attrConfig.value.stringValue(a)»
+ «IF !a.isArray»
+ «aiName».«a.name.invokeSetter(ai.actorClass.name, value)»;
+ «ELSEIF value.startsWith("{")»
+ «aiName».«a.name.invokeSetter(ai.actorClass.name, "new "+a.refType.type.typeName+"[]"+value)»;
+ «ELSE»
+ {
+ «a.refType.type.typeName»[] array = «aiName».«a.name.invokeGetter(ai.actorClass.name)»;
+ for (int i=0;i<«a.size»;i++){
+ array[i] = «value»;
+ }
+ }
+ «ENDIF»
+ «ENDFOR»
+ «FOR portConfig : portConfigs»
+ «var item = portConfig.item»
+ «FOR attrConfig : portConfig.attributes»
+ «var a = attrConfig.attribute»
+ «var value = attrConfig.value.stringValue(a)»
+ «var refToItem = aiName+"."+item.name.invokeGetter(item.portClassName)»
+ «IF !a.isArray»
+ «refToItem».«a.name.invokeSetter(item.portClassName, value)»;
+ «ELSEIF value.startsWith("{")»
+ «refToItem».«a.name.invokeSetter(ai.actorClass.name, "new "+a.refType.type.typeName+"[]"+value)»;
+ «ELSE»
+ {
+ «a.refType.type.typeName»[] array = «refToItem».«a.name.invokeGetter(ai.actorClass.name)»;
+ for (int i=0;i<«a.size»;i++){
+ array[i] = «value»;
+ }
+ }
+ «ENDIF»
+ «ENDFOR»
+ «ENDFOR»
+ }
+ «ENDIF»
+ «ENDFOR»
+
+ //----------------------------------------------------------------------------------------------
+ // addresses for the subsystem system port
+ //----------------------------------------------------------------------------------------------
+
+ std::vector<Address> ownAddresses;
+ «FOR ai : comp.allContainedInstances»
+ ownAddresses[«comp.allContainedInstances.indexOf(ai)»] = addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)»;
+ «ENDFOR»
+ std::vector<Address> peerAddresses;
+ «FOR ai : comp.allContainedInstances»
+ peerAddresses[«comp.allContainedInstances.indexOf(ai)»] = addr_item_«ai.path.getPathName()»;
+ «ENDFOR»
+
+
+ // create the subsystem system port
+ m_RTSystemPort = new RTSystemServicesProtocolConjPortRepl(*this, this, "RTSystemPort",
+ 0, //local ID
+ ownAddresses,
+ peerAddresses);
+
+ }
+
+
+ '''
+ }
+ def generateOwnInterfaceItemAddresses(ActorInstance ai) '''
+ std::vector<std::vector<Address> > «ai.name»_ownInterfaceItemAddresses;
+
+ std::vector<Address> «ai.name»_actorInstanceAddresses;
+ «ai.name»_actorInstanceAddresses[0] = addr_item_«ai.path.getPathName()»;
+
+ «ai.name»_ownInterfaceItemAddresses.push_back(«ai.name»_actorInstanceAddresses);
+ «FOR pi : ai.orderedIfItemInstances»
+ std::vector<Address> «ai.name»_«pi.name»Addresses;
+ «IF pi.replicated»
+ «IF pi.peers.empty»
+ «ELSE»
+ «FOR peer : pi.peers»
+ «ai.name»_«pi.name»Addresses[«pi.peers.indexOf(peer)»] = addr_item_«pi.path.getPathName()»_«pi.peers.indexOf(peer)»;
+ «ENDFOR»
+ «ENDIF»
+ «ELSE»
+ «ai.name»_«pi.name»Addresses[0] = addr_item_«pi.path.getPathName()»;
+ «ENDIF»
+ «ai.name»_ownInterfaceItemAddresses.push_back(«ai.name»_«pi.name»Addresses);
+
+ «ENDFOR»
+ '''
+
+ def generatePeerInterfaceItemAddresses(ActorInstance ai, SubSystemInstance comp) '''
+ std::vector<std::vector<Address> > «ai.name»_peerInterfaceItemAddresses;
+
+ std::vector<Address> «ai.name»_systemPortAddresses;
+ «ai.name»_systemPortAddresses[0] = addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)»;
+
+ «ai.name»_peerInterfaceItemAddresses.push_back(«ai.name»_systemPortAddresses);
+ «FOR pi : ai.orderedIfItemInstances »
+ «IF pi.replicated && pi.peers.isEmpty»
+ «ELSE»
+ std::vector<Address> «ai.name»_«pi.name»PeerAddresses;
+ «IF pi.peers.empty»
+ «ELSE»
+ «FOR pp : pi.peers»
+ «IF pp.replicated»
+ «ai.name»_«pi.name»PeerAddresses[«pi.peers.indexOf(pp)»] = addr_item_«pp.path.getPathName()»_«pp.peers.indexOf(pi)»;
+ «ELSE»
+ «ai.name»_«pi.name»PeerAddresses[«pi.peers.indexOf(pp)»] = addr_item_«pp.path.getPathName()»;
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ai.name»_peerInterfaceItemAddresses.push_back(«ai.name»_«pi.name»PeerAddresses);
+ «ENDIF»
+ «ENDFOR»
+ '''
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
new file mode 100644
index 0000000..f6a8a37
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
@@ -0,0 +1,105 @@
+
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.generic.RoomExtensions
+
+@Singleton
+class SubSystemRunnerGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions
+ @Inject extension RoomExtensions roomExt
+
+ def doGenerate(Root root) {
+ for (sc: root.subSystemInstances) {
+ fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
+ fileAccess.generateFile( sc.name+"_Runner.h", root.generateHeaderFile(sc, sc.subSystemClass))
+
+ fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
+ fileAccess.generateFile( sc.name+"_Runner.cpp", root.generateSourceFile(sc, sc.subSystemClass))
+ }
+ }
+
+ def generateHeaderFile(Root root, SubSystemInstance ssc, SubSystemClass cc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component «ssc.name»
+ * it instantiates «ssc.name» and starts and ends the lifecycle
+ */
+
+ «generateIncludeGuardBegin(ssc.name+"_Runner")»
+
+ #include "common/modelbase/SubSystemRunnerBase.h"
+
+ class «ssc.name+"Runner"» :public etRuntime::SubSystemRunnerBase {
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+ public:
+ static void run();
+ };
+
+ «generateIncludeGuardEnd(ssc.name+"_Runner")»
+ '''
+ }
+
+ def generateSourceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component «ssi.name»
+ * it instantiates «ssi.name» and starts and ends the lifecycle
+ */
+
+
+ #include "«ssi.name».h"
+ #include "«ssi.name»_Runner.h"
+
+ #include <iostream>
+
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+
+ int main(void) {
+ «ssc.name+"Runner"»::run();
+ return 0;
+ }
+
+
+ void «ssc.name+"Runner"»::run() {
+ «ssc.name» main_component(0, "«ssc.name»");
+
+ //etUserEntry(); /* platform specific */
+
+ std::cout << "*** T H E B E G I N ***" << std::endl;
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ // application runs until quit
+ waitForQuit();
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+
+ std::cout << "*** T H E E N D ***" << std::endl;
+
+ //etUserExit(); /* platform specific */
+ }
+
+ '''
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
index 025c8b1..b16cdf8 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -1,15 +1,23 @@
package org.eclipse.etrice.generator.cpp.gen;
+import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ComplexType;
+import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.xbase.lib.IntegerRange;
@Singleton
@SuppressWarnings("all")
@@ -17,6 +25,15 @@ public class CppExtensions implements ILanguageExtension {
@Inject
private AbstractTransitionChainGenerator chainGenerator;
+ @Inject
+ private ILanguageExtension languageExt;
+
+ @Inject
+ private ConfigExtension _configExtension;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
public String getTypedDataDefinition(final Message m) {
VarDecl _data = m.getData();
return this.chainGenerator.generateTypedData(_data);
@@ -34,6 +51,18 @@ public class CppExtensions implements ILanguageExtension {
return _plus;
}
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + "_Inst.h");
+ return _plus;
+ }
+
+ public String getDispSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + "_Disp.h");
+ return _plus;
+ }
+
public String accessLevelPrivate() {
return "";
}
@@ -77,10 +106,8 @@ public class CppExtensions implements ILanguageExtension {
public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("enum ");
- _builder.append(name, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
+ _builder.append("typedef enum {");
+ _builder.newLine();
{
for(final Pair<String,String> entry : entries) {
String _first = entry.getFirst();
@@ -92,7 +119,9 @@ public class CppExtensions implements ILanguageExtension {
_builder.newLineIfNotEmpty();
}
}
- _builder.append("};");
+ _builder.append("} ");
+ _builder.append(name, "");
+ _builder.append(";");
String _string = _builder.toString();
return _string;
}
@@ -107,11 +136,11 @@ public class CppExtensions implements ILanguageExtension {
}
public String nullPointer() {
- return "null";
+ return "0";
}
public String voidPointer() {
- return "Object";
+ return "void*";
}
public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
@@ -185,4 +214,142 @@ public class CppExtensions implements ILanguageExtension {
String _plus_1 = (_plus + "\"");
return _plus_1;
}
+
+ public CharSequence attributeConstructorInitList(final List<Attribute> attribs, final boolean useClassDefaultsOnly) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("// initialize attributes");
+ _builder.newLine();
+ {
+ for(final Attribute a : attribs) {
+ String value = this._configExtension.getInitValue(a);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(value, null));
+ if (_notEquals) {
+ {
+ boolean _isArray = this._configExtension.isArray(a);
+ boolean _not = (!_isArray);
+ if (_not) {
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append(" ( ");
+ _builder.append(value, "");
+ _builder.append(" ),");
+ _builder.newLineIfNotEmpty();
+ } else {
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" ( {");
+ _builder.newLineIfNotEmpty();
+ {
+ int _size = a.getSize();
+ IntegerRange _upTo = new IntegerRange(0, _size);
+ for(final Integer i : _upTo) {
+ _builder.append("value,");
+ _builder.newLine();
+ }
+ }
+ _builder.append("} )");
+ _builder.newLine();
+ }
+ }
+ } else {
+ boolean _or = false;
+ boolean _or_1 = false;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof ComplexType)) {
+ _or_1 = true;
+ } else {
+ int _size_1 = a.getSize();
+ boolean _greaterThan = (_size_1 > 1);
+ _or_1 = ((_type instanceof ComplexType) || _greaterThan);
+ }
+ if (_or_1) {
+ _or = true;
+ } else {
+ boolean _not_1 = (!useClassDefaultsOnly);
+ _or = (_or_1 || _not_1);
+ }
+ if (_or) {
+ {
+ int _size_2 = a.getSize();
+ boolean _equals = (_size_2 == 0);
+ if (_equals) {
+ {
+ RefableType _refType_1 = a.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ String _name_2 = a.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" ( ");
+ String _nullPointer = this.languageExt.nullPointer();
+ _builder.append(_nullPointer, "");
+ _builder.append(" ),");
+ _builder.newLineIfNotEmpty();
+ } else {
+ String _name_3 = a.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" ( ");
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _defaultValue = this._typeHelpers.defaultValue(_type_1);
+ _builder.append(_defaultValue, "");
+ _builder.append(" ),");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ String _name_4 = a.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ( new ");
+ RefableType _refType_3 = a.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ String _typeName = this._typeHelpers.typeName(_type_2);
+ _builder.append(_typeName, "");
+ _builder.append("[");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, "");
+ _builder.append("] ),");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _not_2 = (!useClassDefaultsOnly);
+ if (_not_2) {
+ _builder.append("for (int i=0;i<");
+ int _size_4 = a.getSize();
+ _builder.append(_size_4, "");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_5 = a.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("[i] = ");
+ {
+ RefableType _refType_4 = a.getRefType();
+ boolean _isRef_1 = _refType_4.isRef();
+ if (_isRef_1) {
+ String _nullPointer_1 = this.languageExt.nullPointer();
+ _builder.append(_nullPointer_1, " ");
+ } else {
+ RefableType _refType_5 = a.getRefType();
+ DataType _type_3 = _refType_5.getType();
+ String _defaultValue_1 = this._typeHelpers.defaultValue(_type_3);
+ _builder.append(_defaultValue_1, " ");
+ }
+ }
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.smap b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.smap
new file mode 100644
index 0000000..221af31
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.smap
@@ -0,0 +1,188 @@
+SMAP
+DataClassGen.java
+Xtend
+*S Xtend
+*F
++ 0 DataClassGen.xtend
+src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+*L
+33:51
+34:52,3
+35:55,3
+38:58,6
+39:64
+40:65,3
+43:68,6
+44:74
+45:75,3
+34:78,2
+51:83,2
+52:85,9
+53:94,9
+51:103
+56:104,7
+51:111
+58:112,4
+59:116,8
+51:124,3
+61:127,3
+62:130,6
+51:136,2
+64:138,2
+51:140
+65:141
+51:142
+66:143,3
+67:146,6
+51:152,4
+69:156
+71:157,7
+74:164,2
+51:166
+74:167,7
+51:174,2
+74:176,7
+77:183,7
+79:190,7
+81:197,8
+83:205,11
+86:216,5
+87:221,8
+88:229,13
+91:242,12
+95:254,5
+55:259
+51:260,2
+100:265,2
+101:267,9
+102:276,9
+100:285
+104:286,10
+108:296,8
+111:304,5
+113:309,8
+117:317,7
+100:324
+118:325,5
+119:330,5
+100:335,2
+120:337,3
+122:340,4
+100:344
+123:345,9
+100:354
+126:355,5
+127:360,2
+100:362,2
+128:364,3
+100:367,2
+130:369,6
+134:375,13
+100:388
+136:389,4
+137:393,5
+100:398,3
+139:401,3
+100:404,3
+139:407
+100:408
+139:409
+140:410,7
+100:417,2
+141:419,7
+146:426,13
+100:439
+148:440,4
+149:444,9
+100:453,3
+151:456,3
+100:459,3
+151:462
+100:463
+151:464
+152:465,7
+100:472,2
+153:474,7
+158:481,15
+100:496
+161:497,4
+162:501,5
+100:506,3
+164:509,3
+165:512,7
+100:519,2
+166:521,6
+170:527,6
+104:533
+100:534,2
+175:539
+176:540
+177:541,4
+178:545,5
+179:550,2
+180:552,2
+181:554,2
+180:556
+177:557,4
+183:561
+186:565,2
+187:567,2
+186:569,3
+187:572
+186:573
+187:574,3
+186:577,2
+187:579
+191:583
+192:584
+193:585,4
+194:589,5
+195:594,2
+196:596,2
+197:598,2
+196:600
+193:601,4
+199:605
+202:609,2
+203:611,2
+202:613,3
+203:616
+202:617
+203:618,4
+202:622
+203:623,4
+202:627,2
+203:629,4
+202:633,2
+203:635
+209:639
+210:640
+211:641,4
+212:645,5
+213:650,2
+211:652,4
+215:656
+218:660,2
+220:662
+218:663
+221:664,4
+222:668,4
+218:672
+223:673,5
+224:678,7
+218:685
+225:686,2
+226:688,7
+227:695,10
+218:705,2
+229:707,2
+218:709,2
+232:711,4
+233:715,7
+218:722
+234:723
+235:724,6
+236:730,9
+218:739,6
+219:745
+*E
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 b5290b5..f2df9e0 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
@@ -9,6 +9,8 @@ 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.cpp.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.cpp.gen.SubSystemRunnerGen;
import org.eclipse.etrice.generator.generic.PrepareFileSystem;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
@@ -26,6 +28,12 @@ public class MainGen implements IGenerator {
private ActorClassGen actorClassGen;
@Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
private PrepareFileSystem prepFS;
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
@@ -42,9 +50,11 @@ public class MainGen implements IGenerator {
this.dataClassGen.doGenerate(e);
this.protocolClassGen.doGenerate(e);
this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
boolean _isLibrary = e.isLibrary();
boolean _not = (!_isLibrary);
if (_not) {
+ this.subsystemRunnerGen.doGenerate(e);
}
}
}
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
index f1eb532..8c098ac 100644
--- 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
@@ -6,14 +6,17 @@ Xtend
+ 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
+34:40
+35:41,2
+36:43
+37:44
+36:45
+35:46
+43:50
+44:51
+45:52
+46:53
+48:54,3
+49:57
+48:58
*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 1e2bf28..fe300ea 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
@@ -13,13 +13,18 @@ import org.eclipse.etrice.core.room.CommunicationType;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+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.PortOperation;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
@@ -400,9 +405,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.newLine();
- _builder.append("\t\t ");
- _builder.append("virtual void receive(etRuntime::Message* m);");
- _builder.newLine();
{
CommunicationType _commType = pc.getCommType();
boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
@@ -431,6 +433,90 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _xblockexpression;
}
+ private CharSequence generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
+ _builder.append(_cppHeaderFileName, " ");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include <iostream>");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("using namespace etRuntime;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode3 = pc.getUserCode3();
+ CharSequence _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ _builder.append("\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _portClassImplementation = this.portClassImplementation(pc, Boolean.valueOf(false));
+ _builder.append(_portClassImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _portClassImplementation_1 = this.portClassImplementation(pc, Boolean.valueOf(true));
+ _builder.append(_portClassImplementation_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ return _builder;
+ }
+
public CharSequence portClassImplementation(final ProtocolClass pc, final Boolean conj) {
CharSequence _xblockexpression = null;
{
@@ -687,101 +773,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _xblockexpression;
}
- private CharSequence generateSourceFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\t");
- _builder.append("/**");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("*");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("* Source File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"");
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
- _builder.append(_cppHeaderFileName, " ");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("#include \"common/debugging/DebuggingService.h\"");
- _builder.newLine();
- _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;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode3 = pc.getUserCode3();
- CharSequence _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t");
- DetailCode _userCode2 = pc.getUserCode2();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _portClassImplementation = this.portClassImplementation(pc, Boolean.valueOf(false));
- _builder.append(_portClassImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- CharSequence _portClassImplementation_1 = this.portClassImplementation(pc, Boolean.valueOf(true));
- _builder.append(_portClassImplementation_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- return _builder;
- }
-
private CharSequence messageCall(final Message m) {
StringConcatenation _builder = new StringConcatenation();
String _name = m.getName();
@@ -1251,4 +1242,47 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
return _xblockexpression;
}
+
+ public String getMessageID(final Message msg, final InterfaceItem item) {
+ if ((item instanceof Port)) {
+ Port p = ((Port) item);
+ String _xifexpression = null;
+ boolean _isConjugated = p.isConjugated();
+ if (_isConjugated) {
+ _xifexpression = "OUT_";
+ } else {
+ _xifexpression = "IN_";
+ }
+ String direction = _xifexpression;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ String _name = _protocol.getName();
+ String _name_1 = msg.getName();
+ String _plus = (direction + _name_1);
+ return this.enumInUse(_name, _plus);
+ } else {
+ if ((item instanceof SAPRef)) {
+ SAPRef sap = ((SAPRef) item);
+ ProtocolClass _protocol_1 = sap.getProtocol();
+ String _name_2 = _protocol_1.getName();
+ String _name_3 = msg.getName();
+ String _plus_1 = ("OUT_" + _name_3);
+ return this.enumInUse(_name_2, _plus_1);
+ } else {
+ if ((item instanceof SPPRef)) {
+ SPPRef spp = ((SPPRef) item);
+ ProtocolClass _protocol_2 = spp.getProtocol();
+ String _name_4 = _protocol_2.getName();
+ String _name_5 = msg.getName();
+ String _plus_2 = ("IN_" + _name_5);
+ return this.enumInUse(_name_4, _plus_2);
+ }
+ }
+ }
+ return "unknown interface item";
+ }
+
+ public String enumInUse(final String namespace, final String member) {
+ String _plus = (namespace + "::");
+ return (_plus + member);
+ }
}