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/SubSystemClassGen.xtend')
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend92
1 files changed, 87 insertions, 5 deletions
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 85e6a6dd0..e3e89029e 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
@@ -49,6 +49,10 @@ class SubSystemClassGen {
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))
}
}
@@ -67,13 +71,13 @@ class SubSystemClassGen {
* init -> start -> run (loop) -> stop -> destroy
*/
- void «ssc.name»_init(void); // lifecycle init
- void «ssc.name»_start(void); // lifecycle start
+ void «ssc.name»_init(void); /* lifecycle init */
+ void «ssc.name»_start(void); /* lifecycle start */
- void «ssc.name»_run(void);
+ void «ssc.name»_run(void); /* lifecycle run */
- void «ssc.name»_stop(void); // lifecycle stop
- void «ssc.name»_destroy(void); // lifecycle destroy
+ void «ssc.name»_stop(void); /* lifecycle stop */
+ void «ssc.name»_destroy(void); /* lifecycle destroy */
«generateIncludeGuardEnd(ssc.name)»
@@ -92,6 +96,9 @@ class SubSystemClassGen {
#include "«ssc.getCHeaderFileName»"
+ /* include instances for all classes */
+ #include "«ssc.getInstSourceFileName»"
+
#include "etLogger.h"
/* data for SubSysten «ssc.name» */
@@ -103,6 +110,10 @@ class SubSystemClassGen {
void «ssc.name»_init(void){
etLogger_logInfoF("%s_init", «ssc.name»Inst.name);
+
+ /* initialization of all message services */
+ etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE);
+
}
void «ssc.name»_start(void){
@@ -128,6 +139,77 @@ class SubSystemClassGen {
'''
}
+ def generateInstanceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Instance File of SubSystemClass «ssc.name»
+ * - instantiation of all actor instances and port instances
+ * - configuration of data and connection of ports
+ */
+
+ #include "etMessageService.h"
+
+ /* instantiation of message services */
+ #define MESSAGE_POOL_MAX 10
+ #define MESSAGE_BLOCK_SIZE 32
+ /* MessageService for Thread1 */
+ uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
+ etMessageService msgService_Thread1;
+
+
+ /* include all used ActorClasses */
+ /* TODO: only include used Actor Classes for current SubSystem */
+ «FOR actorClass : root.getUsedActorClasses()»#include "«actorClass.name».h"
+ «ENDFOR»
+
+ /* include all used ProtcolClasses */
+ «FOR protocolClass : root.getUsedProtocolClasses()»#include "«protocolClass.name».h"
+ «ENDFOR»
+
+
+ /* declarations of all ActorClass instances (const and variable structs) */
+
+ /* forward declaration of varible actor structs */
+ «FOR ai : ssi.allContainedInstances»
+ static «ai.actorClass.name» «ai.path.getPathName()»;
+ «ENDFOR»
+
+ «FOR ai : ssi.allContainedInstances»
+
+ /* instance «ai.path.getPathName()» */
+ static const «ai.actorClass.name»_const «ai.path.getPathName()»_const = {
+ &«ai.path.getPathName()»,
+ /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ «FOR port : ai.actorClass.endPorts»
+ {&«ai.path.getPathName()», NULL, &msgService_Thread1, 1, 123} /* Port «port.name» */
+ «ENDFOR»
+
+ };
+ static «ai.actorClass.name» «ai.path.getPathName()» = {&«ai.path.getPathName()»_const};
+ «ENDFOR»
+
+
+««« «FOR ai : ssi.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()» = new Address(0,«ai.threadId»,«ai.objId»);
+««« // interface items of «ai.path»
+««« «FOR pi : ai.orderedIfItemInstances»
+««« «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
+««« «FOR peer : pi.peers»
+««« «var i = pi.peers.indexOf(peer)»
+««« Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»);
+««« «ENDFOR»
+««« «ELSE»
+««« Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
+««« «ENDIF»
+««« «ENDFOR»
+««« «ENDFOR»
+
+ '''
+ }
+
// «var models = root.getReferencedModels(ssc)»
// «FOR model : models»import «model.name».*;«ENDFOR»

Back to the top