Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen')
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java34
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend230
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend17
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend14
7 files changed, 181 insertions, 137 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index f9c689c15..ccc9013ac 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -80,7 +80,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«generateIncludeGuardBegin(xpac.name)»
#include "etDatatypes.h"
- #include "etMessage.h"
+ #include "messaging/etMessage.h"
«FOR dataClass : root.getReferencedDataClasses(ac)»
#include "«dataClass.name».h"
@@ -148,9 +148,10 @@ class ActorClassGen extends GenericActorClassGenerator {
#include "«xpac.getCHeaderFileName»"
- #include "etActor.h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "modelbase/etActor.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
+ #include "platform/etMemory.h"
«FOR pc : root.getReferencedProtocolClasses(ac)»
#include "«pc.getCHeaderFileName»"
@@ -178,7 +179,7 @@ class ActorClassGen extends GenericActorClassGenerator {
ET_MSC_LOGGER_SYNC_ENTRY("«xpac.name»", "ReceiveMessage")
«IF xpac.hasNonEmptyStateMachine»
- receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));
+ receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
«ENDIF»
ET_MSC_LOGGER_SYNC_EXIT
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index bea5bdd0a..598ae9024 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -25,7 +25,7 @@ import org.eclipse.etrice.core.room.RoomClass
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.TransitionChain
import org.eclipse.etrice.generator.generic.ILanguageExtension
-import org.eclipse.etrice.generator.generic.LanguageGenerator
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator
import java.util.List
import org.eclipse.xtext.util.Pair
@@ -34,7 +34,7 @@ import org.eclipse.xtext.util.Pair
@Singleton
class CExtensions implements ILanguageExtension {
- @Inject LanguageGenerator languageGen
+ @Inject AbstractLanguageGenerator languageGen
override String getTypedDataDefinition(Message m) {
@@ -133,4 +133,8 @@ class CExtensions implements ILanguageExtension {
def String getExecuteChainCode(ExpandedActorClass ac, TransitionChain tc) {
return languageGen.getExecuteChain(ac, tc)
}
+
+ override String arrayDeclaration(String type, int size, String name) {
+ type+" "+name+"["+size+"]";
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
new file mode 100644
index 000000000..c25db77be
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
@@ -0,0 +1,34 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
+
+public class CLanguageGenerator extends AbstractLanguageGenerator {
+
+ public String[] getArglistAndTypedData(VarDecl data) {
+ if (data==null)
+ return new String[] {"", "", ""};
+
+ String typeName = data.getRefType().getType().getName();
+ String castTypeName = typeName+"*";
+ boolean byVal = false;
+ if (data.getRefType().getType() instanceof PrimitiveType) {
+ typeName = ((PrimitiveType)data.getRefType().getType()).getTargetName();
+ String ct = ((PrimitiveType)data.getRefType().getType()).getCastName();
+ byVal = true;
+ if (ct!=null && !ct.isEmpty())
+ castTypeName = ct;
+ }
+ else {
+ typeName = typeName+"*";
+ }
+
+ String typedData = typeName+" "+data.getName() + " = "+(byVal? "*":"")+"(("+castTypeName+") generic_data);\n";
+ String dataArg = ", "+data.getName();
+ String typedArgList = ", "+typeName+" "+data.getName();
+
+ return new String[]{dataArg, typedData, typedArgList};
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
index ba1eae7a7..80f06f6da 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
@@ -1,116 +1,116 @@
-/*******************************************************************************
- * 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.c.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.generator.base.ILogger
-import org.eclipse.etrice.generator.etricegen.Root
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.generator.extensions.RoomExtensions
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
-
-
-@Singleton
-class DataClassGen {
-
- @Inject extension JavaIoFileSystemAccess fileAccess
- @Inject extension CExtensions stdExt
- @Inject extension RoomExtensions roomExt
- @Inject extension ProcedureHelpers helpers
- @Inject ILogger logger
-
- def doGenerate(Root root) {
- for (dc: root.usedDataClasses) {
- var path = dc.generationTargetPath+dc.getPath
-
- // header file
- logger.logInfo("generating DataClass header '"+dc.getCHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCHeaderFileName, root.generateHeaderFile(dc))
-
- // source file
- logger.logInfo("generating DataClass source '"+dc.getCSourceFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCSourceFileName, root.generateSourceFile(dc))
-
- }
- }
-
- def generateHeaderFile(Root root, DataClass dc) {'''
- /**
- * @author generated by eTrice
- *
- * Header File of DataClass «dc.name»
- *
- */
-
- «generateIncludeGuardBegin(dc.name)»
-
- #include "etDatatypes.h"
-
-««« TODO: includes only for used DataClasses, also for other models
- «FOR dataClass : root.getReferencedDataClasses(dc)»
- #include "«dataClass.name».h"
- «ENDFOR»
-
- «helpers.userCode(dc.userCode1)»
-
- typedef struct {
- »«helpers.attributes(dc.allAttributes)»
- } «dc.name»
-
-««« TODO: do we need setters and getters for C and C++ ?
-
- «helpers.operationsDeclaration(dc.operations, dc.name)»
-
- /* deep copy */
- void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
-
- «helpers.userCode(dc.userCode2)»
-
- «generateIncludeGuardEnd(dc.name)»
-
- '''
- }
-
- def generateSourceFile(Root root, DataClass dc) {'''
- /**
- * @author generated by eTrice
- *
- * Source File of DataClass «dc.name»
- *
- */
-
- #include "«dc.getCHeaderFileName»"
-
- #include <string.h>
-
- «helpers.userCode(dc.userCode3)»
-
-««« TODO: do we need setters and getters for C and C++ ?
-
- «helpers.operationsImplementation(dc.operations, dc.name)»
-
- // deep copy
- void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
- memcpy(target, source, sizeof(«dc.name»));
- }
-
-
- '''}
-
-
+/*******************************************************************************
+ * 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.c.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+
+
+@Singleton
+class DataClassGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (dc: root.usedDataClasses) {
+ var path = dc.generationTargetPath+dc.getPath
+
+ // header file
+ logger.logInfo("generating DataClass header '"+dc.getCHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(dc.getCHeaderFileName, root.generateHeaderFile(dc))
+
+ // source file
+ logger.logInfo("generating DataClass source '"+dc.getCSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(dc.getCSourceFileName, root.generateSourceFile(dc))
+
+ }
+ }
+
+ def generateHeaderFile(Root root, DataClass dc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of DataClass «dc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(dc.name)»
+
+ #include "etDatatypes.h"
+
+««« TODO: includes only for used DataClasses, also for other models
+ «FOR dataClass : root.getReferencedDataClasses(dc)»
+ #include "«dataClass.name».h"
+ «ENDFOR»
+
+ «helpers.userCode(dc.userCode1)»
+
+ typedef struct {
+ «helpers.attributes(dc.allAttributes)»
+ } «dc.name»;
+
+««« TODO: do we need setters and getters for C and C++ ?
+
+ «helpers.operationsDeclaration(dc.operations, dc.name)»
+
+ /* deep copy */
+ void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
+
+ «helpers.userCode(dc.userCode2)»
+
+ «generateIncludeGuardEnd(dc.name)»
+
+ '''
+ }
+
+ def generateSourceFile(Root root, DataClass dc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of DataClass «dc.name»
+ *
+ */
+
+ #include "«dc.getCHeaderFileName»"
+
+ #include <string.h>
+
+ «helpers.userCode(dc.userCode3)»
+
+««« TODO: do we need setters and getters for C and C++ ?
+
+ «helpers.operationsImplementation(dc.operations, dc.name)»
+
+ // deep copy
+ void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
+ memcpy(target, source, sizeof(«dc.name»));
+ }
+
+
+ '''}
+
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index d4ecf5e36..9934fcfea 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -64,7 +64,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«generateIncludeGuardBegin(pc.name)»
#include "etDatatypes.h"
- #include "etPort.h"
+ #include "modelbase/etPort.h"
«helpers.userCode(pc.userCode1)»
@@ -102,7 +102,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
*/
#include "«pc.getCHeaderFileName»"
- #include "etMSCLogger.h"
+ #include "debugging/etMSCLogger.h"
«helpers.userCode(pc.userCode3)»
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index ce83ef9c1..a1fc872c6 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -111,8 +111,8 @@ class SubSystemClassGen {
#include "«ssc.getInstSourceFileName»"
#include "«ssc.getDispSourceFileName»"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
«helpers.userCode(ssc.userCode3)»
@@ -187,14 +187,11 @@ class SubSystemClassGen {
* - configuration of data and connection of ports
*/
- #include "etMessageService.h"
+ #include "messaging/etMessageService.h"
+ #include "platform/etMemory.h"
/* instantiation of message services */
- /* pool and block size */
- #define MESSAGE_POOL_MAX 10
- #define MESSAGE_BLOCK_SIZE 32
-
/* MessageService for Thread1 */
static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
static etMessageService msgService_Thread1;
@@ -310,9 +307,9 @@ class SubSystemClassGen {
* - one generated dispatcher for each MessageService (Thread)
*/
- #include "etMessageReceiver.h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "messaging/etMessageReceiver.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){
ET_MSC_LOGGER_SYNC_ENTRY("MsgDispatcher_Thread1", "receiveMessage")
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
index 740c0b0f9..72d95f03d 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
@@ -45,8 +45,9 @@ class SubSystemRunnerGen {
#include "«ssi.name».h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
+ #include "platform/etPlatform.h"
/**
@@ -55,7 +56,8 @@ class SubSystemRunnerGen {
*/
int main(void) {
-
+ etUserEntry(); /* platform specific */
+
etLogger_logInfo("*** T H E B E G I N ***");
ET_MSC_LOGGER_OPEN("main");
@@ -63,9 +65,13 @@ class SubSystemRunnerGen {
«ssi.name»_init(); /* lifecycle init */
«ssi.name»_start(); /* lifecycle start */
+ etUserPreRun(); /* platform specific */
+
/* run Scheduler */
«ssi.name»_run();
+ etUserPostRun(); /* platform specific */
+
/* shutdown sequence of lifecycle */
«ssi.name»_stop(); /* lifecycle stop */
«ssi.name»_destroy(); /* lifecycle destroy */
@@ -73,6 +79,8 @@ class SubSystemRunnerGen {
ET_MSC_LOGGER_CLOSE
etLogger_logInfo("*** T H E E N D ***");
+ etUserExit(); /* platform specific */
+
return 0;
}

Back to the top