Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.c')
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend4
-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.xtend12
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java922
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java406
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java466
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java122
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java1136
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java158
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java1988
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java308
13 files changed, 2769 insertions, 2769 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 d1e052c41..f9a7d0d7a 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,9 @@ 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"
«FOR pc : root.getReferencedProtocolClasses(ac)»
#include "«pc.getCHeaderFileName»"
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..1b8abe3ac 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
@@ -69,8 +69,8 @@ class DataClassGen {
«helpers.userCode(dc.userCode1)»
typedef struct {
- »«helpers.attributes(dc.allAttributes)»
- } «dc.name»
+ «helpers.attributes(dc.allAttributes)»
+ } «dc.name»;
««« TODO: do we need setters and getters for C and C++ ?
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 09e8012cc..fc76fd5f4 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
@@ -61,7 +61,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«generateIncludeGuardBegin(pc.name)»
#include "etDatatypes.h"
- #include "etPort.h"
+ #include "modelbase/etPort.h"
«helpers.userCode(pc.userCode1)»
@@ -99,7 +99,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..54c270fef 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,7 +187,7 @@ class SubSystemClassGen {
* - configuration of data and connection of ports
*/
- #include "etMessageService.h"
+ #include "messaging/etMessageService.h"
/* instantiation of message services */
@@ -310,9 +310,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..5c00020d0 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,8 @@ class SubSystemRunnerGen {
#include "«ssi.name».h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
/**
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 183b717b9..768489999 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -1,461 +1,461 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Annotation;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.c.gen.StateMachineGen;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ActorClassGen extends GenericActorClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private StateMachineGen stateMachineGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
- for (final ExpandedActorClass xpac : _xpActorClasses) {
- {
- ActorClass _actorClass = xpac.getActorClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this.roomExt.getPath(_actorClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3);
- ActorClass _actorClass_4 = xpac.getActorClass();
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- boolean _hasBehaviorAnnotation = this.hasBehaviorAnnotation(xpac, "BehaviorManual");
- if (_hasBehaviorAnnotation) {
- ActorClass _actorClass_5 = xpac.getActorClass();
- String _name = _actorClass_5.getName();
- String _operator_plus_5 = StringExtensions.operator_plus("omitting ActorClass source for \'", _name);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' since @BehaviorManual is specified");
- this.logger.logInfo(_operator_plus_6);
- } else {
- {
- ActorClass _actorClass_6 = xpac.getActorClass();
- String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_6);
- String _operator_plus_7 = StringExtensions.operator_plus("generating ActorClass source \'", _cSourceFileName);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\' in \'");
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, path);
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\'");
- this.logger.logInfo(_operator_plus_10);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_7 = xpac.getActorClass();
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_7);
- ActorClass _actorClass_8 = xpac.getActorClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
- }
- }
-
- public boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
- ActorClass _actorClass = xpac.getActorClass();
- EList<Annotation> _annotations = _actorClass.getAnnotations();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_annotations, null);
- if (_operator_notEquals) {
- ActorClass _actorClass_1 = xpac.getActorClass();
- EList<Annotation> _annotations_1 = _actorClass_1.getAnnotations();
- final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
- public Boolean apply(final Annotation e) {
- String _name = e.getName();
- boolean _operator_equals = ObjectExtensions.operator_equals(_name, annotation);
- return ((Boolean)_operator_equals);
- }
- };
- Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_annotations_1, _function);
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_findFirst, null);
- if (_operator_notEquals_1) {
- return true;
- }
- }
- return false;
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of ActorClass ");
- String _name = xpac.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = xpac.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"etMessage.h\"");
- _builder.newLine();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("#include \"");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("typedef struct ");
- String _name_4 = xpac.getName();
- _builder.append(_name_4, "");
- _builder.append(" ");
- String _name_5 = xpac.getName();
- _builder.append(_name_5, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* const part of ActorClass (ROM) */");
- _builder.newLine();
- {
- List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
- boolean _isEmpty = _allEndPorts.isEmpty();
- if (_isEmpty) {
- _builder.append("/* this actor class has no ports and thus no constant data */");
- _builder.newLine();
- } else {
- _builder.append("typedef struct ");
- String _name_6 = xpac.getName();
- _builder.append(_name_6, "");
- _builder.append("_const {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* simple ports */");
- _builder.newLine();
- {
- List<Port> _allEndPorts_1 = this.roomExt.getAllEndPorts(ac);
- for(final Port ep : _allEndPorts_1) {
- {
- int _multiplicity = ep.getMultiplicity();
- boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- if (_operator_equals) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName = this.roomExt.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_7 = ep.getName();
- _builder.append(_name_7, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* replicated ports */");
- _builder.newLine();
- {
- List<Port> _allEndPorts_2 = this.roomExt.getAllEndPorts(ac);
- for(final Port ep_1 : _allEndPorts_2) {
- {
- int _multiplicity_1 = ep_1.getMultiplicity();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity_1), ((Integer)1));
- if (_operator_notEquals) {
- _builder.append("\t");
- _builder.append("const etReplPort ");
- String _name_8 = ep_1.getName();
- _builder.append(_name_8, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("} ");
- String _name_9 = xpac.getName();
- _builder.append(_name_9, "");
- _builder.append("_const;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("/* variable part of ActorClass (RAM) */");
- _builder.newLine();
- _builder.append("struct ");
- String _name_10 = xpac.getName();
- _builder.append(_name_10, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- List<Port> _allEndPorts_3 = this.roomExt.getAllEndPorts(ac);
- boolean _isEmpty_1 = _allEndPorts_3.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty_1);
- if (_operator_not) {
- _builder.append("\t");
- _builder.append("const ");
- String _name_11 = xpac.getName();
- _builder.append(_name_11, " ");
- _builder.append("_const* constData;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(ac);
- StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
- _builder.append(_attributes, " ");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- StringConcatenation _genDataMembers = this.stateMachineGen.genDataMembers(xpac, ac);
- _builder.append(_genDataMembers, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_12 = xpac.getName();
- _builder.append(_name_12, "");
- _builder.append("_init(");
- String _name_13 = xpac.getName();
- _builder.append(_name_13, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_14 = xpac.getName();
- _builder.append(_name_14, "");
- _builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_15 = xpac.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_15);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of ActorClass ");
- String _name = xpac.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etActor.h\"");
- _builder.newLine();
- _builder.append("#include \"etLogger.h\"");
- _builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("#include \"");
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName_1, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode3 = xpac.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* interface item IDs */");
- _builder.newLine();
- String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
- _builder.append(_genInterfaceItemConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine) {
- StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
- _builder.append(_genStateMachine, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("void ");
- String _name_1 = xpac.getName();
- _builder.append(_name_1, "");
- _builder.append("_init(");
- String _name_2 = xpac.getName();
- _builder.append(_name_2, "");
- _builder.append("* self){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_3 = xpac.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", \"init\")");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine_1 = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine_1) {
- _builder.append("\t");
- StringConcatenation _genInitialization = this.stateMachineGen.genInitialization(xpac, ac);
- _builder.append(_genInitialization, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_4 = xpac.getName();
- _builder.append(_name_4, "");
- _builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_5 = xpac.getName();
- _builder.append(_name_5, " ");
- _builder.append("\", \"ReceiveMessage\")");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine_2 = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine_2) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Annotation;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.c.gen.StateMachineGen;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private StateMachineGen stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this.roomExt.getPath(_actorClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ boolean _hasBehaviorAnnotation = this.hasBehaviorAnnotation(xpac, "BehaviorManual");
+ if (_hasBehaviorAnnotation) {
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _name = _actorClass_5.getName();
+ String _operator_plus_5 = StringExtensions.operator_plus("omitting ActorClass source for \'", _name);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' since @BehaviorManual is specified");
+ this.logger.logInfo(_operator_plus_6);
+ } else {
+ {
+ ActorClass _actorClass_6 = xpac.getActorClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_6);
+ String _operator_plus_7 = StringExtensions.operator_plus("generating ActorClass source \'", _cSourceFileName);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\' in \'");
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, path);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\'");
+ this.logger.logInfo(_operator_plus_10);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_7 = xpac.getActorClass();
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_7);
+ ActorClass _actorClass_8 = xpac.getActorClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+ }
+ }
+
+ public boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
+ ActorClass _actorClass = xpac.getActorClass();
+ EList<Annotation> _annotations = _actorClass.getAnnotations();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_annotations, null);
+ if (_operator_notEquals) {
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ EList<Annotation> _annotations_1 = _actorClass_1.getAnnotations();
+ final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
+ public Boolean apply(final Annotation e) {
+ String _name = e.getName();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_name, annotation);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_annotations_1, _function);
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_findFirst, null);
+ if (_operator_notEquals_1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ActorClass ");
+ String _name = xpac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = xpac.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessage.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = ac.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ String _name_4 = xpac.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = xpac.getName();
+ _builder.append(_name_5, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* const part of ActorClass (ROM) */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
+ boolean _isEmpty = _allEndPorts.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/* this actor class has no ports and thus no constant data */");
+ _builder.newLine();
+ } else {
+ _builder.append("typedef struct ");
+ String _name_6 = xpac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_const {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* simple ports */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts_1 = this.roomExt.getAllEndPorts(ac);
+ for(final Port ep : _allEndPorts_1) {
+ {
+ int _multiplicity = ep.getMultiplicity();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_equals) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName = this.roomExt.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_7 = ep.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* replicated ports */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts_2 = this.roomExt.getAllEndPorts(ac);
+ for(final Port ep_1 : _allEndPorts_2) {
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity_1), ((Integer)1));
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ _builder.append("const etReplPort ");
+ String _name_8 = ep_1.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("} ");
+ String _name_9 = xpac.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_const;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* variable part of ActorClass (RAM) */");
+ _builder.newLine();
+ _builder.append("struct ");
+ String _name_10 = xpac.getName();
+ _builder.append(_name_10, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ List<Port> _allEndPorts_3 = this.roomExt.getAllEndPorts(ac);
+ boolean _isEmpty_1 = _allEndPorts_3.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty_1);
+ if (_operator_not) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_11 = xpac.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("_const* constData;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(ac);
+ StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genDataMembers = this.stateMachineGen.genDataMembers(xpac, ac);
+ _builder.append(_genDataMembers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_12 = xpac.getName();
+ _builder.append(_name_12, "");
+ _builder.append("_init(");
+ String _name_13 = xpac.getName();
+ _builder.append(_name_13, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_14 = xpac.getName();
+ _builder.append(_name_14, "");
+ _builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = ac.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_15 = xpac.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_15);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ActorClass ");
+ String _name = xpac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etActor.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName_1, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode3 = xpac.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* interface item IDs */");
+ _builder.newLine();
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine) {
+ StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
+ _builder.append(_genStateMachine, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = xpac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_init(");
+ String _name_2 = xpac.getName();
+ _builder.append(_name_2, "");
+ _builder.append("* self){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_3 = xpac.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", \"init\")");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine_1 = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine_1) {
+ _builder.append("\t");
+ StringConcatenation _genInitialization = this.stateMachineGen.genInitialization(xpac, ac);
+ _builder.append(_genInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = xpac.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_5 = xpac.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\", \"ReceiveMessage\")");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine_2 = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index 98bee5eaf..b8917e980 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -1,203 +1,203 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.Message;
-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.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class CExtensions implements ILanguageExtension {
- @Inject
- private LanguageGenerator languageGen;
-
- public String getTypedDataDefinition(final Message m) {
- String _typedData = this.languageGen.getTypedData(m);
- return _typedData;
- }
-
- public String accessLevelPrivate() {
- return "static ";
- }
-
- public String accessLevelProtected() {
- return "static ";
- }
-
- public String accessLevelPublic() {
- return "";
- }
-
- public String memberAccess() {
- return "self->";
- }
-
- public String selfPointer(final String classname, final boolean hasArgs) {
- String _xifexpression = null;
- if (hasArgs) {
- _xifexpression = "* self, ";
- } else {
- _xifexpression = "* self";
- }
- String _operator_plus = StringExtensions.operator_plus(classname, _xifexpression);
- return _operator_plus;
- }
-
- public String selfPointer(final boolean hasArgs) {
- String _xifexpression = null;
- if (hasArgs) {
- _xifexpression = "self, ";
- } else {
- _xifexpression = "self";
- }
- return _xifexpression;
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- String _operator_plus = StringExtensions.operator_plus(classname, "_");
- return _operator_plus;
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- String _operator_plus = StringExtensions.operator_plus(namespace, "_");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _operator_plus = StringExtensions.operator_plus(namespace, "_");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- /**
- * TODO: move specific code elsewhere
- */
- public String getCHeaderFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".h");
- return _operator_plus;
- }
-
- public String getCSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".c");
- return _operator_plus;
- }
-
- public String getInstSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, "_Inst.h");
- return _operator_plus;
- }
-
- public String getDispSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, "_Disp.h");
- return _operator_plus;
- }
-
- public StringConcatenation getIncludeGuardString(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("_");
- String _upperCase = filename.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_H_");
- return _builder;
- }
-
- public StringConcatenation generateIncludeGuardBegin(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef ");
- StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.newLineIfNotEmpty();
- _builder.append("#define ");
- StringConcatenation _includeGuardString_1 = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString_1, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation generateIncludeGuardEnd(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#endif /* ");
- StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public boolean usesInheritance() {
- return false;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- String _xblockexpression = null;
- {
- boolean _isEmpty = entries.isEmpty();
- if (_isEmpty) {
- return "/* empty enum not generated */";
- }
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("enum ");
- _builder.append(name, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean hasAnyElements = false;
- for(final Pair<String,String> entry : entries) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _first = entry.getFirst();
- _builder.append(_first, " ");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- String _string = _builder.toString();
- _xblockexpression = (_string);
- }
- return _xblockexpression;
- }
-
- public String booleanConstant(final boolean b) {
- String _xifexpression = null;
- if (b) {
- _xifexpression = "TRUE";
- } else {
- _xifexpression = "FALSE";
- }
- return _xifexpression;
- }
-
- public String nullPointer() {
- return "NULL";
- }
-
- public String voidPointer() {
- return "void*";
- }
-
- public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
- String _executeChain = this.languageGen.getExecuteChain(ac, tc);
- return _executeChain;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.Message;
+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.xtext.util.Pair;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class CExtensions implements ILanguageExtension {
+ @Inject
+ private LanguageGenerator languageGen;
+
+ public String getTypedDataDefinition(final Message m) {
+ String _typedData = this.languageGen.getTypedData(m);
+ return _typedData;
+ }
+
+ public String accessLevelPrivate() {
+ return "static ";
+ }
+
+ public String accessLevelProtected() {
+ return "static ";
+ }
+
+ public String accessLevelPublic() {
+ return "";
+ }
+
+ public String memberAccess() {
+ return "self->";
+ }
+
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "* self, ";
+ } else {
+ _xifexpression = "* self";
+ }
+ String _operator_plus = StringExtensions.operator_plus(classname, _xifexpression);
+ return _operator_plus;
+ }
+
+ public String selfPointer(final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "self, ";
+ } else {
+ _xifexpression = "self";
+ }
+ return _xifexpression;
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ String _operator_plus = StringExtensions.operator_plus(classname, "_");
+ return _operator_plus;
+ }
+
+ public String memberInDeclaration(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, "_");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
+ return _operator_plus_1;
+ }
+
+ public String memberInUse(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, "_");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
+ return _operator_plus_1;
+ }
+
+ /**
+ * TODO: move specific code elsewhere
+ */
+ public String getCHeaderFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".h");
+ return _operator_plus;
+ }
+
+ public String getCSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".c");
+ return _operator_plus;
+ }
+
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_Inst.h");
+ return _operator_plus;
+ }
+
+ public String getDispSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_Disp.h");
+ return _operator_plus;
+ }
+
+ public StringConcatenation getIncludeGuardString(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("_");
+ String _upperCase = filename.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_H_");
+ return _builder;
+ }
+
+ public StringConcatenation generateIncludeGuardBegin(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#ifndef ");
+ StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#define ");
+ StringConcatenation _includeGuardString_1 = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString_1, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation generateIncludeGuardEnd(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#endif /* ");
+ StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public boolean usesInheritance() {
+ return false;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ String _xblockexpression = null;
+ {
+ boolean _isEmpty = entries.isEmpty();
+ if (_isEmpty) {
+ return "/* empty enum not generated */";
+ }
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("enum ");
+ _builder.append(name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean hasAnyElements = false;
+ for(final Pair<String,String> entry : entries) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _first = entry.getFirst();
+ _builder.append(_first, " ");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ String _string = _builder.toString();
+ _xblockexpression = (_string);
+ }
+ return _xblockexpression;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _xifexpression = null;
+ if (b) {
+ _xifexpression = "TRUE";
+ } else {
+ _xifexpression = "FALSE";
+ }
+ return _xifexpression;
+ }
+
+ public String nullPointer() {
+ return "NULL";
+ }
+
+ public String voidPointer() {
+ return "void*";
+ }
+
+ public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
+ String _executeChain = this.languageGen.getExecuteChain(ac, tc);
+ return _executeChain;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 2dbbb5e4b..116ea9646 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -1,233 +1,233 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
- String _path = this.roomExt.getPath(dc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this.stdExt.getCSourceFileName(dc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = dc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = dc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\u00BB");
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
- StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
- _builder.append(_attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("} ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_4 = dc.getName();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, _name_4);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* deep copy */");
- _builder.newLine();
- _builder.append("void ");
- String _name_5 = dc.getName();
- _builder.append(_name_5, "");
- _builder.append("_deepCopy(");
- String _name_6 = dc.getName();
- _builder.append(_name_6, "");
- _builder.append("* source, ");
- String _name_7 = dc.getName();
- _builder.append(_name_7, "");
- _builder.append("* target);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode2 = dc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_8 = dc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_8);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include <string.h>");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = dc.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_1 = dc.getName();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_1);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// deep copy");
- _builder.newLine();
- _builder.append("void ");
- String _name_2 = dc.getName();
- _builder.append(_name_2, "");
- _builder.append("_deepCopy(");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- _builder.append("* source, ");
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
- _builder.append("* target) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("memcpy(target, source, sizeof(");
- String _name_5 = dc.getName();
- _builder.append(_name_5, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
+ String _path = this.roomExt.getPath(dc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(dc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = dc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = dc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
+ StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("} ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_4 = dc.getName();
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, _name_4);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* deep copy */");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("_deepCopy(");
+ String _name_6 = dc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("* source, ");
+ String _name_7 = dc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("* target);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = dc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_8 = dc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_8);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <string.h>");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = dc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_1 = dc.getName();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_1);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = dc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_deepCopy(");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("* source, ");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("* target) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("memcpy(target, source, sizeof(");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
index e3a53f78b..ddbb7e3d4 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
@@ -1,61 +1,61 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.generator.c.gen.ActorClassGen;
-import org.eclipse.etrice.generator.c.gen.DataClassGen;
-import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
- if (_operator_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.generator.c.gen.ActorClassGen;
+import org.eclipse.etrice.generator.c.gen.DataClassGen;
+import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
+ if (_operator_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index b2d9d327b..a3742c516 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -1,568 +1,568 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this.stdExt.getCSourceFileName(pc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(pc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = pc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"etPort.h\"");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("/* message IDs */");
- _builder.newLine();
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port classes */");
- _builder.newLine();
- StringConcatenation _portClassHeader = this.portClassHeader(pc, ((Boolean)false));
- _builder.append(_portClassHeader, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _portClassHeader_1 = this.portClassHeader(pc, ((Boolean)true));
- _builder.append(_portClassHeader_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* get message string for message id */");
- _builder.newLine();
- _builder.append("const char* ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("_getMessageString(int msg_id);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_4 = pc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = pc.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port classes */");
- _builder.newLine();
- StringConcatenation _portClassSource = this.portClassSource(pc, ((Boolean)false));
- _builder.append(_portClassSource, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _portClassSource_1 = this.portClassSource(pc, ((Boolean)true));
- _builder.append(_portClassSource_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation portClass(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pClass = _portClass;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> ports = _xifexpression;
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("typedef etPort ");
- _builder.append(portClassName, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("typedef etReplPort ");
- _builder.append(replPortClassName, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- for(final Message message : ports) {
- _builder.append("\t");
- _builder.append("void ");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name = message.getName();
- _builder.append(_name, " ");
- _builder.append("(const ");
- _builder.append(portClassName, " ");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("void ");
- _builder.append(replPortClassName, " ");
- _builder.append("_");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append("_broadcast(const ");
- _builder.append(replPortClassName, " ");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("void ");
- _builder.append(replPortClassName, " ");
- _builder.append("_");
- String _name_2 = message.getName();
- _builder.append(_name_2, " ");
- _builder.append("(const ");
- _builder.append(replPortClassName, " ");
- _builder.append("* self, int idx);");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pClass = _portClass;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- String _xifexpression_1 = null;
- if (conj) {
- _xifexpression_1 = "IN_";
- } else {
- _xifexpression_1 = "OUT_";
- }
- String dir = _xifexpression_1;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- _builder.newLine();
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- String _name = message.getName();
- _builder.append(_name, "");
- _builder.append("(const ");
- _builder.append(portClassName, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(portClassName, " ");
- _builder.append("\", \"");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (self->receiveMessageFunc!=NULL) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("etPort_sendMessage(self, ");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _operator_plus = StringExtensions.operator_plus(dir, _name_3);
- String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus);
- _builder.append(_memberInUse, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- _builder.append(replPortClassName, "");
- _builder.append("_");
- String _name_4 = message.getName();
- _builder.append(_name_4, "");
- _builder.append("_broadcast(const ");
- _builder.append(replPortClassName, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_5 = message.getName();
- _builder.append(_name_5, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (i=0; i<self->size; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("etPort_sendMessage((etPort*)(&self->ports[i]), ");
- String _name_6 = pc.getName();
- String _name_7 = message.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(dir, _name_7);
- String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_1);
- _builder.append(_memberInUse_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- _builder.append(replPortClassName, "");
- _builder.append("_");
- String _name_8 = message.getName();
- _builder.append(_name_8, "");
- _builder.append("(const ");
- _builder.append(replPortClassName, "");
- _builder.append("* self, int idx) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_9 = message.getName();
- _builder.append(_name_9, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (0<=idx && idx<self->size) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("etPort_sendMessage((etPort*)(&self->ports[idx]), ");
- String _name_10 = pc.getName();
- String _name_11 = message.getName();
- String _operator_plus_2 = StringExtensions.operator_plus(dir, _name_11);
- String _memberInUse_2 = this.stdExt.memberInUse(_name_10, _operator_plus_2);
- _builder.append(_memberInUse_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation messageSignature(final ProtocolClass pc, final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("void ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_");
- String _name_1 = m.getName();
- _builder.append(_name_1, "");
- _builder.append(" (");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _name_2 = _type.getName();
- _builder.append(_name_2, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_3 = _data_2.getName();
- _builder.append(_name_3, "");
- }
- }
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* message names as strings for debugging (generate MSC) */");
- _builder.newLine();
- _builder.append("static const char* ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, "");
- _builder.append("\",");
- }
- }
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\"");
- String _name_2 = m_1.getName();
- _builder.append(_name_2, "");
- _builder.append("\", ");
- }
- }
- _builder.append("\"MAX\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("const char* ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("_getMessageString(int msg_id) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (msg_id<");
- String _name_4 = pc.getName();
- _builder.append(_name_4, " ");
- _builder.append("_MSG_MIN || msg_id>");
- String _name_5 = pc.getName();
- _builder.append(_name_5, " ");
- _builder.append("_MSG_MAX+1){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("/* id out of range */");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("else{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return ");
- String _name_6 = pc.getName();
- _builder.append(_name_6, " ");
- _builder.append("_messageStrings[msg_id];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
+ String _path = this.roomExt.getPath(pc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(pc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(pc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etPort.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = pc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* message IDs */");
+ _builder.newLine();
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port classes */");
+ _builder.newLine();
+ StringConcatenation _portClassHeader = this.portClassHeader(pc, ((Boolean)false));
+ _builder.append(_portClassHeader, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _portClassHeader_1 = this.portClassHeader(pc, ((Boolean)true));
+ _builder.append(_portClassHeader_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* get message string for message id */");
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = pc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = pc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port classes */");
+ _builder.newLine();
+ StringConcatenation _portClassSource = this.portClassSource(pc, ((Boolean)false));
+ _builder.append(_portClassSource, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _portClassSource_1 = this.portClassSource(pc, ((Boolean)true));
+ _builder.append(_portClassSource_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation portClass(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ PortClass pClass = _portClass;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> ports = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final Message message : ports) {
+ _builder.append("\t");
+ _builder.append("void ");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name = message.getName();
+ _builder.append(_name, " ");
+ _builder.append("(const ");
+ _builder.append(portClassName, " ");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("void ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("_");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("_broadcast(const ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("void ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("_");
+ String _name_2 = message.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("(const ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("* self, int idx);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ PortClass pClass = _portClass;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if (conj) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ _builder.newLine();
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ String _name = message.getName();
+ _builder.append(_name, "");
+ _builder.append("(const ");
+ _builder.append(portClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(portClassName, " ");
+ _builder.append("\", \"");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (self->receiveMessageFunc!=NULL) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("etPort_sendMessage(self, ");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _operator_plus = StringExtensions.operator_plus(dir, _name_3);
+ String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus);
+ _builder.append(_memberInUse, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_");
+ String _name_4 = message.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_broadcast(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<self->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("etPort_sendMessage((etPort*)(&self->ports[i]), ");
+ String _name_6 = pc.getName();
+ String _name_7 = message.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(dir, _name_7);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_1);
+ _builder.append(_memberInUse_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_");
+ String _name_8 = message.getName();
+ _builder.append(_name_8, "");
+ _builder.append("(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self, int idx) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_9 = message.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<self->size) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("etPort_sendMessage((etPort*)(&self->ports[idx]), ");
+ String _name_10 = pc.getName();
+ String _name_11 = message.getName();
+ String _operator_plus_2 = StringExtensions.operator_plus(dir, _name_11);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_10, _operator_plus_2);
+ _builder.append(_memberInUse_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation messageSignature(final ProtocolClass pc, final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("void ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" (");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _name_2 = _type.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_3 = _data_2.getName();
+ _builder.append(_name_3, "");
+ }
+ }
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("static const char* ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\", ");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (msg_id<");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_MSG_MIN || msg_id>");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_MSG_MAX+1){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("/* id out of range */");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_messageStrings[msg_id];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
index c1b22f966..0762d5a77 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
@@ -1,79 +1,79 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- public StringConcatenation genDataMembers(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* state machine variables */");
- _builder.newLine();
- _builder.append("etInt16 state;");
- _builder.newLine();
- _builder.append("etInt16 history[");
- List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
- int _size = _allLeafStates.size();
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_size), ((Integer)1));
- _builder.append(_operator_plus, "");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation genInitialization(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("self->state = STATE_TOP;");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("for (i=0; i<");
- List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
- int _size = _allLeafStates.size();
- _builder.append(_size, " ");
- _builder.append("; ++i)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("self->history[i] = NO_STATE;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("executeInitTransition(self);");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- String _accessLevelPrivate = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate, "");
- _builder.append("void setState(");
- String _name = ac.getName();
- _builder.append(_name, "");
- _builder.append("* self, int new_state) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("self->state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public StringConcatenation genDataMembers(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* state machine variables */");
+ _builder.newLine();
+ _builder.append("etInt16 state;");
+ _builder.newLine();
+ _builder.append("etInt16 history[");
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
+ int _size = _allLeafStates.size();
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_size), ((Integer)1));
+ _builder.append(_operator_plus, "");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation genInitialization(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("self->state = STATE_TOP;");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<");
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
+ int _size = _allLeafStates.size();
+ _builder.append(_size, " ");
+ _builder.append("; ++i)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("self->history[i] = NO_STATE;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("executeInitTransition(self);");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void setState(");
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append("* self, int new_state) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index 3ea4f0c18..bca5df385 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -1,994 +1,994 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.HashMap;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.ActorInstance;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.generator.etricegen.PortInstance;
-import org.eclipse.etrice.generator.etricegen.PortKind;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.CollectionExtensions;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance ssi : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(_subSystemClass_2);
- String file = _cHeaderFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass declaration: \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generateHeaderFile);
- SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
- String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_4);
- file = _cSourceFileName;
- String _operator_plus_5 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
- this.fileAccess.generateFile(file, _generateSourceFile);
- SubSystemClass _subSystemClass_6 = ssi.getSubSystemClass();
- String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_6);
- file = _instSourceFileName;
- String _operator_plus_9 = StringExtensions.operator_plus("generating SubSystemClass instance file: \'", file);
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\' in \'");
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, path);
- String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "\'");
- this.logger.logInfo(_operator_plus_12);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_7 = ssi.getSubSystemClass();
- StringConcatenation _generateInstanceFile = this.generateInstanceFile(root, ssi, _subSystemClass_7);
- this.fileAccess.generateFile(file, _generateInstanceFile);
- SubSystemClass _subSystemClass_8 = ssi.getSubSystemClass();
- String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_8);
- file = _dispSourceFileName;
- String _operator_plus_13 = StringExtensions.operator_plus("generating SubSystemClass dispatcher file: \'", file);
- String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, "\' in \'");
- String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, path);
- String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, "\'");
- this.logger.logInfo(_operator_plus_16);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_9 = ssi.getSubSystemClass();
- StringConcatenation _generateDispatcherFile = this.generateDispatcherFile(root, ssi, _subSystemClass_9);
- this.fileAccess.generateFile(file, _generateDispatcherFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of SubSystemClass ");
- String _name = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = ssc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode1 = ssc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* lifecycle functions");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* init -> start -> run (loop) -> stop -> destroy");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_2 = ssc.getName();
- _builder.append(_name_2, "");
- _builder.append("_init(void);\t\t/* lifecycle init \t */");
- _builder.newLineIfNotEmpty();
- _builder.append("void ");
- String _name_3 = ssc.getName();
- _builder.append(_name_3, "");
- _builder.append("_start(void);\t/* lifecycle start \t */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_4 = ssc.getName();
- _builder.append(_name_4, "");
- _builder.append("_run(void);\t\t/* lifecycle run \t */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_5 = ssc.getName();
- _builder.append(_name_5, "");
- _builder.append("_stop(void); \t/* lifecycle stop\t */");
- _builder.newLineIfNotEmpty();
- _builder.append("void ");
- String _name_6 = ssc.getName();
- _builder.append(_name_6, "");
- _builder.append("_destroy(void); \t/* lifecycle destroy */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode2 = ssc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_7 = ssc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_7);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of SubSystemClass ");
- String _name = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(ssc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* include instances for all classes */");
- _builder.newLine();
- _builder.append("#include \"");
- String _instSourceFileName = this.stdExt.getInstSourceFileName(ssc);
- _builder.append(_instSourceFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"");
- String _dispSourceFileName = this.stdExt.getDispSourceFileName(ssc);
- _builder.append(_dispSourceFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etLogger.h\"");
- _builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = ssc.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* data for SubSysten ");
- String _name_1 = ssc.getName();
- _builder.append(_name_1, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- _builder.append("typedef struct ");
- String _name_2 = ssc.getName();
- _builder.append(_name_2, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("char *name;");
- _builder.newLine();
- _builder.append("} ");
- String _name_3 = ssc.getName();
- _builder.append(_name_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("static ");
- String _name_4 = ssc.getName();
- _builder.append(_name_4, "");
- _builder.append(" ");
- String _name_5 = ssc.getName();
- _builder.append(_name_5, "");
- _builder.append("Inst = {\"");
- String _name_6 = ssc.getName();
- _builder.append(_name_6, "");
- _builder.append("\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_7 = ssc.getName();
- _builder.append(_name_7, "");
- _builder.append("_initActorInstances(void);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_8 = ssc.getName();
- _builder.append(_name_8, "");
- _builder.append("_init(void){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"init\")");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfoF(\"%s_init\", ");
- String _name_9 = ssc.getName();
- _builder.append(_name_9, " ");
- _builder.append("Inst.name);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* initialization of all message services */");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_Thread1_receiveMessage);");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* init all actors */");
- _builder.newLine();
- _builder.append("\t");
- String _name_10 = ssc.getName();
- _builder.append(_name_10, " ");
- _builder.append("_initActorInstances();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_11 = ssc.getName();
- _builder.append(_name_11, "");
- _builder.append("_start(void){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"start\")");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfoF(\"%s_start\", ");
- String _name_12 = ssc.getName();
- _builder.append(_name_12, " ");
- _builder.append("Inst.name);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_13 = ssc.getName();
- _builder.append(_name_13, "");
- _builder.append("_run(void){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"run\")");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int32 i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("for (i=0; i<100; i++){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("etLogger_logInfoF(\"%s Scheduler tick %d\", ");
- String _name_14 = ssc.getName();
- _builder.append(_name_14, " ");
- _builder.append("Inst.name, i);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("etMessageService_execute(&msgService_Thread1);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_15 = ssc.getName();
- _builder.append(_name_15, "");
- _builder.append("_stop(void){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"stop\")");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfoF(\"%s_stop\", ");
- String _name_16 = ssc.getName();
- _builder.append(_name_16, " ");
- _builder.append("Inst.name);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_17 = ssc.getName();
- _builder.append(_name_17, "");
- _builder.append("_destroy(void){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"destroy\")");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfoF(\"%s_destroy\", ");
- String _name_18 = ssc.getName();
- _builder.append(_name_18, " ");
- _builder.append("Inst.name);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_19 = ssc.getName();
- _builder.append(_name_19, "");
- _builder.append("_initActorInstances(void){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_20 = ssc.getName();
- _builder.append(_name_20, " ");
- _builder.append("\", \"initActorInstances\")");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
- for(final ActorInstance ai : _allContainedInstances) {
- _builder.append("\t");
- ActorClass _actorClass = ai.getActorClass();
- String _name_21 = _actorClass.getName();
- _builder.append(_name_21, " ");
- _builder.append("_init(&");
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- _builder.append(_pathName, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateInstanceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Instance File of SubSystemClass ");
- String _name = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* - instantiation of all actor instances and port instances");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* - configuration of data and connection of ports");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"etMessageService.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* instantiation of message services */");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* pool and block size */");
- _builder.newLine();
- _builder.append("#define MESSAGE_POOL_MAX 10");
- _builder.newLine();
- _builder.append("#define MESSAGE_BLOCK_SIZE 32");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* MessageService for Thread1 */");
- _builder.newLine();
- _builder.append("static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];");
- _builder.newLine();
- _builder.append("static etMessageService msgService_Thread1;");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* include all used ActorClasses */");
- _builder.newLine();
- {
- EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
- for(final ActorClass actorClass : _usedActorClasses) {
- _builder.append("#include \"");
- String _name_1 = actorClass.getName();
- _builder.append(_name_1, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("/* include all used ProtcolClasses */");
- _builder.newLine();
- {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for(final ProtocolClass protocolClass : _usedProtocolClasses) {
- _builder.append("#include \"");
- String _name_2 = protocolClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* declarations of all ActorClass instances (const and variable structs) */");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* forward declaration of variable actor structs */");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
- for(final ActorInstance ai : _allContainedInstances) {
- _builder.append("static ");
- ActorClass _actorClass = ai.getActorClass();
- String _name_3 = _actorClass.getName();
- _builder.append(_name_3, "");
- _builder.append(" ");
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- _builder.append(_pathName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
- for(final ActorInstance ai_1 : _allContainedInstances_1) {
- _builder.newLine();
- _builder.append("/* instance ");
- String _path_1 = ai_1.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName_1, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- {
- EList<PortInstance> _ports = ai_1.getPorts();
- boolean _isEmpty = _ports.isEmpty();
- if (_isEmpty) {
- _builder.append("/* no ports, nothing to initialize statically */");
- _builder.newLine();
- } else {
- StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_1);
- _builder.append(_genActorInstanceInitializer, "");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- return _builder;
- }
-
- private StringConcatenation genActorInstanceInitializer(final Root root, final ActorInstance ai) {
- StringConcatenation _xblockexpression = null;
- {
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- String instName = _pathName;
- ArrayList<PortInstance> _arrayList = new ArrayList<PortInstance>();
- ArrayList<PortInstance> replPorts = _arrayList;
- EList<PortInstance> _ports = ai.getPorts();
- final Function1<PortInstance,Boolean> _function = new Function1<PortInstance,Boolean>() {
- public Boolean apply(final PortInstance e) {
- boolean _operator_and = false;
- PortKind _kind = e.getKind();
- String _literal = _kind.getLiteral();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_literal, "RELAY");
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- Port _port = e.getPort();
- int _multiplicity = _port.getMultiplicity();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(((Integer)_multiplicity), ((Integer)1));
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
- }
- return ((Boolean)_operator_and);
- }
- };
- Iterable<PortInstance> _filter = IterableExtensions.<PortInstance>filter(_ports, _function);
- CollectionExtensions.<PortInstance>addAll(replPorts, _filter);
- ArrayList<PortInstance> _arrayList_1 = new ArrayList<PortInstance>();
- ArrayList<PortInstance> ports = _arrayList_1;
- EList<PortInstance> _ports_1 = ai.getPorts();
- final Function1<PortInstance,Boolean> _function_1 = new Function1<PortInstance,Boolean>() {
- public Boolean apply(final PortInstance e) {
- boolean _operator_and = false;
- PortKind _kind = e.getKind();
- String _literal = _kind.getLiteral();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_literal, "RELAY");
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- Port _port = e.getPort();
- int _multiplicity = _port.getMultiplicity();
- boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_equals);
- }
- return ((Boolean)_operator_and);
- }
- };
- Iterable<PortInstance> _filter_1 = IterableExtensions.<PortInstance>filter(_ports_1, _function_1);
- Iterable<PortInstance> _union = this.roomExt.<PortInstance>union(_filter_1, replPorts);
- CollectionExtensions.<PortInstance>addAll(ports, _union);
- HashMap<PortInstance,Integer> _hashMap = new HashMap<PortInstance,Integer>();
- HashMap<PortInstance,Integer> offsets = _hashMap;
- int offset = 0;
- for (final PortInstance p : replPorts) {
- {
- offsets.put(p, ((Integer)offset));
- EList<InterfaceItemInstance> _peers = p.getPeers();
- int _size = _peers.size();
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)_size));
- offset = _operator_plus;
- }
- }
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isEmpty = replPorts.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append("static const etReplSubPort ");
- _builder.append(instName, "");
- _builder.append("_repl_sub_ports[");
- _builder.append(offset, "");
- _builder.append("] = {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, idx} */");
- _builder.newLine();
- {
- boolean hasAnyElements = false;
- for(final PortInstance pi : replPorts) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi);
- _builder.append(_genReplSubPortInitializers, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- }
- }
- _builder.append("static const ");
- ActorClass _actorClass = ai.getActorClass();
- String _name = _actorClass.getName();
- _builder.append(_name, "");
- _builder.append("_const ");
- _builder.append(instName, "");
- _builder.append("_const = {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
- _builder.newLine();
- {
- boolean hasAnyElements_1 = false;
- for(final PortInstance pi_1 : ports) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- Port _port = pi_1.getPort();
- int _multiplicity = _port.getMultiplicity();
- boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- if (_operator_equals) {
- _builder.append("\t");
- String _genPortInitializer = this.genPortInitializer(root, ai, pi_1);
- _builder.append(_genPortInitializer, " ");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("{");
- EList<InterfaceItemInstance> _peers_1 = pi_1.getPeers();
- int _size_1 = _peers_1.size();
- _builder.append(_size_1, " ");
- _builder.append(", ");
- _builder.append(instName, " ");
- _builder.append("_repl_sub_ports+");
- Integer _get = offsets.get(pi_1);
- _builder.append(_get, " ");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.append("static ");
- ActorClass _actorClass_1 = ai.getActorClass();
- String _name_1 = _actorClass_1.getName();
- _builder.append(_name_1, "");
- _builder.append(" ");
- _builder.append(instName, "");
- _builder.append(" = {&");
- _builder.append(instName, "");
- _builder.append("_const};");
- _builder.newLineIfNotEmpty();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private String genPortInitializer(final Root root, final ActorInstance ai, final PortInstance pi) {
- String _xblockexpression = null;
- {
- String _xifexpression = null;
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- boolean _isEmpty = _peers.isEmpty();
- if (_isEmpty) {
- _xifexpression = "NULL";
- } else {
- ActorClass _actorClass = ai.getActorClass();
- String _name = _actorClass.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, "_ReceiveMessage");
- _xifexpression = _operator_plus;
- }
- String recvMsg = _xifexpression;
- int _xifexpression_1 = (int) 0;
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- boolean _isEmpty_1 = _peers_1.isEmpty();
- if (_isEmpty_1) {
- _xifexpression_1 = 0;
- } else {
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- InterfaceItemInstance _get = _peers_2.get(0);
- int _objId = _get.getObjId();
- _xifexpression_1 = _objId;
- }
- int objId = _xifexpression_1;
- int _xifexpression_2 = (int) 0;
- EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
- boolean _isEmpty_2 = _peers_3.isEmpty();
- if (_isEmpty_2) {
- _xifexpression_2 = 0;
- } else {
- EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
- InterfaceItemInstance _get_1 = _peers_4.get(0);
- EList<InterfaceItemInstance> _peers_5 = _get_1.getPeers();
- int _indexOf = _peers_5.indexOf(pi);
- _xifexpression_2 = _indexOf;
- }
- int idx = _xifexpression_2;
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- String _operator_plus_1 = StringExtensions.operator_plus("{&", _pathName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, recvMsg);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, ", ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
- int _operator_plus_6 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_operator_plus_6));
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
- ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
- Port _port = pi.getPort();
- int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_port);
- int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, "} /* Port ");
- String _name_1 = pi.getName();
- String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, _name_1);
- String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, " */");
- _xblockexpression = (_operator_plus_13);
- }
- return _xblockexpression;
- }
-
- private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final PortInstance pi) {
- String result = "";
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- for (final InterfaceItemInstance p : _peers) {
- {
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int _indexOf = _peers_1.indexOf(p);
- int idx = _indexOf;
- String _xifexpression = null;
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- int _size = _peers_2.size();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
- boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)idx), ((Integer)_operator_minus));
- if (_operator_lessThan) {
- _xifexpression = ",";
- } else {
- _xifexpression = "";
- }
- String comma = _xifexpression;
- String _operator_plus = StringExtensions.operator_plus(result, "{&");
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _pathName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
- ActorClass _actorClass = ai.getActorClass();
- String _name = _actorClass.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_ReceiveMessage, ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
- int _objId = p.getObjId();
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_objId));
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", ");
- ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
- Port _port = pi.getPort();
- int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_port);
- int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8));
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, ", ");
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ((Integer)idx));
- String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "}");
- String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, comma);
- String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, " /* Repl Sub Port ");
- String _name_1 = pi.getName();
- String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, _name_1);
- String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, " idx +");
- String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, ((Integer)idx));
- String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, "*/\n");
- result = _operator_plus_18;
- }
- }
- return result;
- }
-
- public StringConcatenation generateDispatcherFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Dispatcher File of SubSystemClass ");
- String _name = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* - one generated dispatcher for each MessageService (Thread)");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"etMessageReceiver.h\"");
- _builder.newLine();
- _builder.append("#include \"etLogger.h\"");
- _builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.append("static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_Thread1\", \"receiveMessage\")");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("switch(msg->address){");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
- for(final ActorInstance ai : _allContainedInstances) {
- _builder.append("\t\t");
- _builder.append("/* interface items of ");
- String _path = ai.getPath();
- _builder.append(_path, " ");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _operator_and = false;
- if (!(pi instanceof PortInstance)) {
- _operator_and = false;
- } else {
- Port _port = ((PortInstance) pi).getPort();
- int _multiplicity = _port.getMultiplicity();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity), ((Integer)1));
- _operator_and = BooleanExtensions.operator_and((pi instanceof PortInstance), _operator_notEquals);
- }
- if (_operator_and) {
- {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers) {
- _builder.append("\t\t");
- _builder.append("case ");
- int _objId = pi.getObjId();
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int _indexOf = _peers_1.indexOf(peer);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_objId), ((Integer)_indexOf));
- _builder.append(_operator_plus, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("etPort_receive((etPort*)&");
- String _path_1 = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append("_const.");
- String _name_1 = pi.getName();
- _builder.append(_name_1, " ");
- _builder.append(".ports[");
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- int _indexOf_1 = _peers_2.indexOf(peer);
- _builder.append(_indexOf_1, " ");
- _builder.append("], msg);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("case ");
- int _objId_1 = pi.getObjId();
- _builder.append(_objId_1, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("etPort_receive(&");
- String _path_2 = ai.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_2);
- _builder.append(_pathName_1, " ");
- _builder.append("_const.");
- String _name_2 = pi.getName();
- _builder.append(_name_2, " ");
- _builder.append(", msg);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("default:");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("etLogger_logErrorF(\"MessageService_Thread1_ReceiveMessage: address %d does not exist \", msg->address);");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("break;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashMap;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
+import org.eclipse.etrice.generator.etricegen.PortInstance;
+import org.eclipse.etrice.generator.etricegen.PortKind;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance ssi : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(_subSystemClass_2);
+ String file = _cHeaderFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass declaration: \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generateHeaderFile);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_4);
+ file = _cSourceFileName;
+ String _operator_plus_5 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
+ this.fileAccess.generateFile(file, _generateSourceFile);
+ SubSystemClass _subSystemClass_6 = ssi.getSubSystemClass();
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_6);
+ file = _instSourceFileName;
+ String _operator_plus_9 = StringExtensions.operator_plus("generating SubSystemClass instance file: \'", file);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\' in \'");
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, path);
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "\'");
+ this.logger.logInfo(_operator_plus_12);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_7 = ssi.getSubSystemClass();
+ StringConcatenation _generateInstanceFile = this.generateInstanceFile(root, ssi, _subSystemClass_7);
+ this.fileAccess.generateFile(file, _generateInstanceFile);
+ SubSystemClass _subSystemClass_8 = ssi.getSubSystemClass();
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_8);
+ file = _dispSourceFileName;
+ String _operator_plus_13 = StringExtensions.operator_plus("generating SubSystemClass dispatcher file: \'", file);
+ String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, "\' in \'");
+ String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, path);
+ String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, "\'");
+ this.logger.logInfo(_operator_plus_16);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_9 = ssi.getSubSystemClass();
+ StringConcatenation _generateDispatcherFile = this.generateDispatcherFile(root, ssi, _subSystemClass_9);
+ this.fileAccess.generateFile(file, _generateDispatcherFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = ssc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode1 = ssc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* lifecycle functions");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* init -> start -> run (loop) -> stop -> destroy");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_init(void);\t\t/* lifecycle init \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_start(void);\t/* lifecycle start \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_run(void);\t\t/* lifecycle run \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("_stop(void); \t/* lifecycle stop\t */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_destroy(void); \t/* lifecycle destroy */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = ssc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_7 = ssc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_7);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(ssc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* include instances for all classes */");
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(ssc);
+ _builder.append(_instSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"");
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(ssc);
+ _builder.append(_dispSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = ssc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data for SubSysten ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef struct ");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("char *name;");
+ _builder.newLine();
+ _builder.append("} ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("static ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("Inst = {\"");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = ssc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_initActorInstances(void);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_8 = ssc.getName();
+ _builder.append(_name_8, "");
+ _builder.append("_init(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"init\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_init\", ");
+ String _name_9 = ssc.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* initialization of all message services */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_Thread1_receiveMessage);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* init all actors */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_10 = ssc.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("_initActorInstances();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_11 = ssc.getName();
+ _builder.append(_name_11, "");
+ _builder.append("_start(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"start\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_start\", ");
+ String _name_12 = ssc.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_13 = ssc.getName();
+ _builder.append(_name_13, "");
+ _builder.append("_run(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"run\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int32 i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<100; i++){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("etLogger_logInfoF(\"%s Scheduler tick %d\", ");
+ String _name_14 = ssc.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("Inst.name, i);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("etMessageService_execute(&msgService_Thread1);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_15 = ssc.getName();
+ _builder.append(_name_15, "");
+ _builder.append("_stop(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"stop\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_stop\", ");
+ String _name_16 = ssc.getName();
+ _builder.append(_name_16, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_17 = ssc.getName();
+ _builder.append(_name_17, "");
+ _builder.append("_destroy(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"destroy\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_destroy\", ");
+ String _name_18 = ssc.getName();
+ _builder.append(_name_18, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_19 = ssc.getName();
+ _builder.append(_name_19, "");
+ _builder.append("_initActorInstances(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_20 = ssc.getName();
+ _builder.append(_name_20, " ");
+ _builder.append("\", \"initActorInstances\")");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("\t");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_21 = _actorClass.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("_init(&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateInstanceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Instance File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - instantiation of all actor instances and port instances");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* - configuration of data and connection of ports");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessageService.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* instantiation of message services */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* pool and block size */");
+ _builder.newLine();
+ _builder.append("#define MESSAGE_POOL_MAX 10");
+ _builder.newLine();
+ _builder.append("#define MESSAGE_BLOCK_SIZE 32");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* MessageService for Thread1 */");
+ _builder.newLine();
+ _builder.append("static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];");
+ _builder.newLine();
+ _builder.append("static etMessageService msgService_Thread1;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* include all used ActorClasses */");
+ _builder.newLine();
+ {
+ EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
+ for(final ActorClass actorClass : _usedActorClasses) {
+ _builder.append("#include \"");
+ String _name_1 = actorClass.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* include all used ProtcolClasses */");
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for(final ProtocolClass protocolClass : _usedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_2 = protocolClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* declarations of all ActorClass instances (const and variable structs) */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* forward declaration of variable actor structs */");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("static ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" ");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ _builder.newLine();
+ _builder.append("/* instance ");
+ String _path_1 = ai_1.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<PortInstance> _ports = ai_1.getPorts();
+ boolean _isEmpty = _ports.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/* no ports, nothing to initialize statically */");
+ _builder.newLine();
+ } else {
+ StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_1);
+ _builder.append(_genActorInstanceInitializer, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation genActorInstanceInitializer(final Root root, final ActorInstance ai) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String instName = _pathName;
+ ArrayList<PortInstance> _arrayList = new ArrayList<PortInstance>();
+ ArrayList<PortInstance> replPorts = _arrayList;
+ EList<PortInstance> _ports = ai.getPorts();
+ final Function1<PortInstance,Boolean> _function = new Function1<PortInstance,Boolean>() {
+ public Boolean apply(final PortInstance e) {
+ boolean _operator_and = false;
+ PortKind _kind = e.getKind();
+ String _literal = _kind.getLiteral();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_literal, "RELAY");
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ Port _port = e.getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(((Integer)_multiplicity), ((Integer)1));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<PortInstance> _filter = IterableExtensions.<PortInstance>filter(_ports, _function);
+ CollectionExtensions.<PortInstance>addAll(replPorts, _filter);
+ ArrayList<PortInstance> _arrayList_1 = new ArrayList<PortInstance>();
+ ArrayList<PortInstance> ports = _arrayList_1;
+ EList<PortInstance> _ports_1 = ai.getPorts();
+ final Function1<PortInstance,Boolean> _function_1 = new Function1<PortInstance,Boolean>() {
+ public Boolean apply(final PortInstance e) {
+ boolean _operator_and = false;
+ PortKind _kind = e.getKind();
+ String _literal = _kind.getLiteral();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_literal, "RELAY");
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ Port _port = e.getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_equals);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<PortInstance> _filter_1 = IterableExtensions.<PortInstance>filter(_ports_1, _function_1);
+ Iterable<PortInstance> _union = this.roomExt.<PortInstance>union(_filter_1, replPorts);
+ CollectionExtensions.<PortInstance>addAll(ports, _union);
+ HashMap<PortInstance,Integer> _hashMap = new HashMap<PortInstance,Integer>();
+ HashMap<PortInstance,Integer> offsets = _hashMap;
+ int offset = 0;
+ for (final PortInstance p : replPorts) {
+ {
+ offsets.put(p, ((Integer)offset));
+ EList<InterfaceItemInstance> _peers = p.getPeers();
+ int _size = _peers.size();
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)_size));
+ offset = _operator_plus;
+ }
+ }
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = replPorts.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("static const etReplSubPort ");
+ _builder.append(instName, "");
+ _builder.append("_repl_sub_ports[");
+ _builder.append(offset, "");
+ _builder.append("] = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, idx} */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements = false;
+ for(final PortInstance pi : replPorts) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi);
+ _builder.append(_genReplSubPortInitializers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ }
+ }
+ _builder.append("static const ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ _builder.append(_name, "");
+ _builder.append("_const ");
+ _builder.append(instName, "");
+ _builder.append("_const = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements_1 = false;
+ for(final PortInstance pi_1 : ports) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ Port _port = pi_1.getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_equals) {
+ _builder.append("\t");
+ String _genPortInitializer = this.genPortInitializer(root, ai, pi_1);
+ _builder.append(_genPortInitializer, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("{");
+ EList<InterfaceItemInstance> _peers_1 = pi_1.getPeers();
+ int _size_1 = _peers_1.size();
+ _builder.append(_size_1, " ");
+ _builder.append(", ");
+ _builder.append(instName, " ");
+ _builder.append("_repl_sub_ports+");
+ Integer _get = offsets.get(pi_1);
+ _builder.append(_get, " ");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("static ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_1 = _actorClass_1.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" ");
+ _builder.append(instName, "");
+ _builder.append(" = {&");
+ _builder.append(instName, "");
+ _builder.append("_const};");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String genPortInitializer(final Root root, final ActorInstance ai, final PortInstance pi) {
+ String _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ if (_isEmpty) {
+ _xifexpression = "NULL";
+ } else {
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_ReceiveMessage");
+ _xifexpression = _operator_plus;
+ }
+ String recvMsg = _xifexpression;
+ int _xifexpression_1 = (int) 0;
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ boolean _isEmpty_1 = _peers_1.isEmpty();
+ if (_isEmpty_1) {
+ _xifexpression_1 = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ InterfaceItemInstance _get = _peers_2.get(0);
+ int _objId = _get.getObjId();
+ _xifexpression_1 = _objId;
+ }
+ int objId = _xifexpression_1;
+ int _xifexpression_2 = (int) 0;
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ boolean _isEmpty_2 = _peers_3.isEmpty();
+ if (_isEmpty_2) {
+ _xifexpression_2 = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ InterfaceItemInstance _get_1 = _peers_4.get(0);
+ EList<InterfaceItemInstance> _peers_5 = _get_1.getPeers();
+ int _indexOf = _peers_5.indexOf(pi);
+ _xifexpression_2 = _indexOf;
+ }
+ int idx = _xifexpression_2;
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _operator_plus_1 = StringExtensions.operator_plus("{&", _pathName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, recvMsg);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, ", ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
+ int _operator_plus_6 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_operator_plus_6));
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ Port _port = pi.getPort();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_port);
+ int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, "} /* Port ");
+ String _name_1 = pi.getName();
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, _name_1);
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, " */");
+ _xblockexpression = (_operator_plus_13);
+ }
+ return _xblockexpression;
+ }
+
+ private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final PortInstance pi) {
+ String result = "";
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for (final InterfaceItemInstance p : _peers) {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(p);
+ int idx = _indexOf;
+ String _xifexpression = null;
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _size = _peers_2.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
+ boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)idx), ((Integer)_operator_minus));
+ if (_operator_lessThan) {
+ _xifexpression = ",";
+ } else {
+ _xifexpression = "";
+ }
+ String comma = _xifexpression;
+ String _operator_plus = StringExtensions.operator_plus(result, "{&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _pathName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_ReceiveMessage, ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
+ int _objId = p.getObjId();
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_objId));
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ Port _port = pi.getPort();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_port);
+ int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, ", ");
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ((Integer)idx));
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "}");
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, comma);
+ String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, " /* Repl Sub Port ");
+ String _name_1 = pi.getName();
+ String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, _name_1);
+ String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, " idx +");
+ String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, ((Integer)idx));
+ String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, "*/\n");
+ result = _operator_plus_18;
+ }
+ }
+ return result;
+ }
+
+ public StringConcatenation generateDispatcherFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Dispatcher File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - one generated dispatcher for each MessageService (Thread)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessageReceiver.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_Thread1\", \"receiveMessage\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("switch(msg->address){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("\t\t");
+ _builder.append("/* interface items of ");
+ String _path = ai.getPath();
+ _builder.append(_path, " ");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ {
+ boolean _operator_and = false;
+ if (!(pi instanceof PortInstance)) {
+ _operator_and = false;
+ } else {
+ Port _port = ((PortInstance) pi).getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity), ((Integer)1));
+ _operator_and = BooleanExtensions.operator_and((pi instanceof PortInstance), _operator_notEquals);
+ }
+ if (_operator_and) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId = pi.getObjId();
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(peer);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_objId), ((Integer)_indexOf));
+ _builder.append(_operator_plus, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("etPort_receive((etPort*)&");
+ String _path_1 = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append("_const.");
+ String _name_1 = pi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_1 = _peers_2.indexOf(peer);
+ _builder.append(_indexOf_1, " ");
+ _builder.append("], msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId_1 = pi.getObjId();
+ _builder.append(_objId_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("etPort_receive(&");
+ String _path_2 = ai.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_1, " ");
+ _builder.append("_const.");
+ String _name_2 = pi.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("default:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("etLogger_logErrorF(\"MessageService_Thread1_ReceiveMessage: address %d does not exist \", msg->address);");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
index 125f76155..00727b482 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
@@ -1,154 +1,154 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- this.fileAccess.setOutputPath(_operator_plus);
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "_Runner.c");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_operator_plus_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* this class contains the main function running component ");
- String _name = ssi.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = ssi.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _name_2 = ssi.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etLogger.h\"");
- _builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("int main(void) {");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_OPEN(\"main\");");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* startup sequence of lifecycle */");
- _builder.newLine();
- _builder.append("\t");
- String _name_3 = ssi.getName();
- _builder.append(_name_3, " ");
- _builder.append("_init(); \t\t/* lifecycle init */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_4 = ssi.getName();
- _builder.append(_name_4, " ");
- _builder.append("_start(); \t/* lifecycle start */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* run Scheduler */");
- _builder.newLine();
- _builder.append("\t");
- String _name_5 = ssi.getName();
- _builder.append(_name_5, " ");
- _builder.append("_run();");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* shutdown sequence of lifecycle */");
- _builder.newLine();
- _builder.append("\t");
- String _name_6 = ssi.getName();
- _builder.append(_name_6, " ");
- _builder.append("_stop(); \t\t/* lifecycle stop */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_7 = ssi.getName();
- _builder.append(_name_7, " ");
- _builder.append("_destroy(); \t/* lifecycle destroy */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_CLOSE");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfo(\"*** T H E E N D ***\");");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("return 0;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ this.fileAccess.setOutputPath(_operator_plus);
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "_Runner.c");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_operator_plus_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssi.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _name_2 = ssi.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("int main(void) {");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_OPEN(\"main\");");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* startup sequence of lifecycle */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_3 = ssi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("_init(); \t\t/* lifecycle init */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_4 = ssi.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_start(); \t/* lifecycle start */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* run Scheduler */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_5 = ssi.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_run();");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* shutdown sequence of lifecycle */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_6 = ssi.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_stop(); \t\t/* lifecycle stop */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_7 = ssi.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("_destroy(); \t/* lifecycle destroy */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_CLOSE");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfo(\"*** T H E E N D ***\");");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return 0;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}

Back to the top