Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/generator/ConfigGenerator.java22
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java1562
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java480
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java494
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java120
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java2370
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java234
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java342
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java2106
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java346
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java82
-rw-r--r--plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/.FSMtestGenerator.java._tracebin880 -> 880 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/FSMtestGenerator.java22
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java1184
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java920
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java288
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java120
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java1580
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java162
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java1820
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java302
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend84
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java540
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java180
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java238
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java2784
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java162
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java1686
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java1918
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java114
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zipbin15546 -> 16271 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin68940 -> 41262 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin214649 -> 126908 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin35474 -> 30056 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.zipbin101476 -> 101307 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/.cproject11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/platform/etMemory.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h)4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_EXP430F5438/etDatatypes.h (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etDatatypes.h)0
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_EXP430F5438/etLogger.c (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etLogger.c)0
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_EXP430F5438/etPlatform.c (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c)0
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_EXP430F5438/etTimer.c (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etTimer.c)0
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_EXP430F5438/info.txt (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/info.txt)0
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etDatatypes.h72
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etLogger.c78
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.c291
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.h36
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etTimer.c99
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_G2553_CCS5_LaunchPad/etDatatypes.h72
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_G2553_CCS5_LaunchPad/etLogger.c96
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_G2553_CCS5_LaunchPad/etPlatform.c (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h)80
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_G2553_CCS5_LaunchPad/etTimer.c69
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_G2553_CCS5_LaunchPad/info.txt1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/naming-convention.txt9
59 files changed, 12023 insertions, 11173 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/generator/ConfigGenerator.java b/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/generator/ConfigGenerator.java
index 15a186d3d..fbcb0e7f5 100644
--- a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/generator/ConfigGenerator.java
+++ b/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/generator/ConfigGenerator.java
@@ -1,11 +1,11 @@
-package org.eclipse.etrice.core.generator;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@SuppressWarnings("all")
-public class ConfigGenerator implements IGenerator {
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- }
-}
+package org.eclipse.etrice.core.generator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@SuppressWarnings("all")
+public class ConfigGenerator implements IGenerator {
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ }
+}
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 f9038caf3..33e8f8df8 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
@@ -124,7 +124,7 @@ class SubSystemClassGen {
#include "debugging/etMSCLogger.h"
#include "platform/etTimer.h"
- #include "etGlobalFlags.h"
+ #include "etRuntimeConfig.h"
«helpers.userCode(ssc.userCode3)»
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 c174aa5c4..b798d9355 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,781 +1,781 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.common.base.Objects;
-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.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorCommunicationType;
-import org.eclipse.etrice.core.room.Annotation;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.CommunicationType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.StateGraph;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.c.gen.StateMachineGen;
-import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class ActorClassGen extends GenericActorClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions _cExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @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._roomExtensions.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this._roomExtensions.getPath(_actorClass_1);
- String path = (_generationTargetPath + _path);
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _cHeaderFileName = this._cExtensions.getCHeaderFileName(_actorClass_2);
- String _plus = ("generating ActorClass header \'" + _cHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(_actorClass_3);
- ActorClass _actorClass_4 = xpac.getActorClass();
- CharSequence _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 _plus_4 = ("omitting ActorClass source for \'" + _name);
- String _plus_5 = (_plus_4 + "\' since @BehaviorManual is specified");
- this.logger.logInfo(_plus_5);
- } else {
- ActorClass _actorClass_6 = xpac.getActorClass();
- String _cSourceFileName = this._cExtensions.getCSourceFileName(_actorClass_6);
- String _plus_6 = ("generating ActorClass source \'" + _cSourceFileName);
- String _plus_7 = (_plus_6 + "\' in \'");
- String _plus_8 = (_plus_7 + path);
- String _plus_9 = (_plus_8 + "\'");
- this.logger.logInfo(_plus_9);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_7 = xpac.getActorClass();
- String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(_actorClass_7);
- ActorClass _actorClass_8 = xpac.getActorClass();
- CharSequence _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
- }
-
- private boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
- ActorClass _actorClass = xpac.getActorClass();
- EList<Annotation> _behaviorAnnotations = _actorClass.getBehaviorAnnotations();
- boolean _notEquals = (!Objects.equal(_behaviorAnnotations, null));
- if (_notEquals) {
- ActorClass _actorClass_1 = xpac.getActorClass();
- EList<Annotation> _behaviorAnnotations_1 = _actorClass_1.getBehaviorAnnotations();
- final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
- public Boolean apply(final Annotation e) {
- String _name = e.getName();
- boolean _equals = Objects.equal(_name, annotation);
- return Boolean.valueOf(_equals);
- }
- };
- Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_behaviorAnnotations_1, _function);
- boolean _notEquals_1 = (!Objects.equal(_findFirst, null));
- if (_notEquals_1) {
- return true;
- }
- }
- return false;
- }
-
- private CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- List<Port> _allEndPorts = this._roomExtensions.getAllEndPorts(ac);
- final Function1<Port,Boolean> _function = new Function1<Port,Boolean>() {
- public Boolean apply(final Port p) {
- GeneralProtocolClass _protocol = p.getProtocol();
- CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- return Boolean.valueOf(_equals);
- }
- };
- Iterable<Port> eventPorts = IterableExtensions.<Port>filter(_allEndPorts, _function);
- List<Port> _allEndPorts_1 = this._roomExtensions.getAllEndPorts(ac);
- final Function1<Port,Boolean> _function_1 = new Function1<Port,Boolean>() {
- public Boolean apply(final Port p) {
- boolean _and = false;
- GeneralProtocolClass _protocol = p.getProtocol();
- CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
- if (!_equals) {
- _and = false;
- } else {
- boolean _isConjugated = p.isConjugated();
- _and = (_equals && _isConjugated);
- }
- return Boolean.valueOf(_and);
- }
- };
- Iterable<Port> sendPorts = IterableExtensions.<Port>filter(_allEndPorts_1, _function_1);
- List<Port> _allEndPorts_2 = this._roomExtensions.getAllEndPorts(ac);
- final Function1<Port,Boolean> _function_2 = new Function1<Port,Boolean>() {
- public Boolean apply(final Port p) {
- boolean _and = false;
- GeneralProtocolClass _protocol = p.getProtocol();
- CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
- if (!_equals) {
- _and = false;
- } else {
- boolean _isConjugated = p.isConjugated();
- boolean _not = (!_isConjugated);
- _and = (_equals && _not);
- }
- return Boolean.valueOf(_and);
- }
- };
- Iterable<Port> recvPorts = IterableExtensions.<Port>filter(_allEndPorts_2, _function_2);
- ActorCommunicationType _commType = ac.getCommType();
- boolean dataDriven = Objects.equal(_commType, ActorCommunicationType.DATA_DRIVEN);
- ActorCommunicationType _commType_1 = ac.getCommType();
- boolean async = Objects.equal(_commType_1, ActorCommunicationType.ASYNCHRONOUS);
- 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 = ac.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = ac.getName();
- CharSequence _generateIncludeGuardBegin = this._cExtensions.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();
- CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("typedef struct ");
- String _name_4 = ac.getName();
- _builder.append(_name_4, "");
- _builder.append(" ");
- String _name_5 = ac.getName();
- _builder.append(_name_5, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* const part of ActorClass (ROM) */");
- _builder.newLine();
- {
- boolean _and = false;
- boolean _and_1 = false;
- boolean _and_2 = false;
- boolean _isEmpty = IterableExtensions.isEmpty(eventPorts);
- if (!_isEmpty) {
- _and_2 = false;
- } else {
- boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
- _and_2 = (_isEmpty && _isEmpty_1);
- }
- if (!_and_2) {
- _and_1 = false;
- } else {
- List<SAPRef> _allSAPs = this._roomExtensions.getAllSAPs(ac);
- boolean _isEmpty_2 = _allSAPs.isEmpty();
- _and_1 = (_and_2 && _isEmpty_2);
- }
- if (!_and_1) {
- _and = false;
- } else {
- List<ServiceImplementation> _allServiceImplementations = this._roomExtensions.getAllServiceImplementations(ac);
- boolean _isEmpty_3 = _allServiceImplementations.isEmpty();
- _and = (_and_1 && _isEmpty_3);
- }
- if (_and) {
- _builder.append("/* this actor class has no ports and thus no constant data */");
- _builder.newLine();
- } else {
- _builder.append("typedef struct ");
- String _name_6 = ac.getName();
- _builder.append(_name_6, "");
- _builder.append("_const {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* simple ports */");
- _builder.newLine();
- {
- for(final Port ep : eventPorts) {
- {
- int _multiplicity = ep.getMultiplicity();
- boolean _equals = (_multiplicity == 1);
- if (_equals) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName = this._roomExtensions.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("/* data receive ports */");
- _builder.newLine();
- {
- for(final Port ep_1 : recvPorts) {
- {
- int _multiplicity_1 = ep_1.getMultiplicity();
- boolean _equals_1 = (_multiplicity_1 == 1);
- if (_equals_1) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1);
- _builder.append(_portClassName_1, " ");
- _builder.append(" ");
- String _name_8 = ep_1.getName();
- _builder.append(_name_8, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* saps */");
- _builder.newLine();
- {
- List<SAPRef> _allSAPs_1 = this._roomExtensions.getAllSAPs(ac);
- for(final SAPRef sap : _allSAPs_1) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_2 = this._roomExtensions.getPortClassName(sap);
- _builder.append(_portClassName_2, " ");
- _builder.append(" ");
- String _name_9 = sap.getName();
- _builder.append(_name_9, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* replicated ports */");
- _builder.newLine();
- {
- List<Port> _allEndPorts_3 = this._roomExtensions.getAllEndPorts(ac);
- for(final Port ep_2 : _allEndPorts_3) {
- {
- int _multiplicity_2 = ep_2.getMultiplicity();
- boolean _notEquals = (_multiplicity_2 != 1);
- if (_notEquals) {
- _builder.append("\t");
- _builder.append("const etReplPort ");
- String _name_10 = ep_2.getName();
- _builder.append(_name_10, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* services */");
- _builder.newLine();
- {
- List<ServiceImplementation> _allServiceImplementations_1 = this._roomExtensions.getAllServiceImplementations(ac);
- for(final ServiceImplementation svc : _allServiceImplementations_1) {
- _builder.append("\t");
- _builder.append("const etReplPort ");
- SPPRef _spp = svc.getSpp();
- String _name_11 = _spp.getName();
- _builder.append(_name_11, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("} ");
- String _name_12 = ac.getName();
- _builder.append(_name_12, "");
- _builder.append("_const;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- StateGraph _stateMachine = xpac.getStateMachine();
- boolean _isEmpty_4 = RoomHelpers.isEmpty(_stateMachine);
- boolean _not = (!_isEmpty_4);
- if (_not) {
- _builder.newLine();
- CharSequence _genHeaderConstants = this._stateMachineGen.genHeaderConstants(xpac);
- _builder.append(_genHeaderConstants, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("/* variable part of ActorClass (RAM) */");
- _builder.newLine();
- _builder.append("struct ");
- String _name_13 = ac.getName();
- _builder.append(_name_13, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _and_3 = false;
- boolean _and_4 = false;
- boolean _and_5 = false;
- boolean _isEmpty_5 = IterableExtensions.isEmpty(eventPorts);
- if (!_isEmpty_5) {
- _and_5 = false;
- } else {
- boolean _isEmpty_6 = IterableExtensions.isEmpty(recvPorts);
- _and_5 = (_isEmpty_5 && _isEmpty_6);
- }
- if (!_and_5) {
- _and_4 = false;
- } else {
- List<SAPRef> _allSAPs_2 = this._roomExtensions.getAllSAPs(ac);
- boolean _isEmpty_7 = _allSAPs_2.isEmpty();
- _and_4 = (_and_5 && _isEmpty_7);
- }
- if (!_and_4) {
- _and_3 = false;
- } else {
- List<ServiceImplementation> _allServiceImplementations_2 = this._roomExtensions.getAllServiceImplementations(ac);
- boolean _isEmpty_8 = _allServiceImplementations_2.isEmpty();
- _and_3 = (_and_4 && _isEmpty_8);
- }
- boolean _not_1 = (!_and_3);
- if (_not_1) {
- _builder.append("\t");
- _builder.append("const ");
- String _name_14 = ac.getName();
- _builder.append(_name_14, " ");
- _builder.append("_const* const constData;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("/* data send ports */");
- _builder.newLine();
- {
- for(final Port ep_3 : sendPorts) {
- {
- int _multiplicity_3 = ep_3.getMultiplicity();
- boolean _equals_2 = (_multiplicity_3 == 1);
- if (_equals_2) {
- _builder.append("\t");
- String _portClassName_3 = this._roomExtensions.getPortClassName(ep_3);
- _builder.append(_portClassName_3, " ");
- _builder.append(" ");
- String _name_15 = ep_3.getName();
- _builder.append(_name_15, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t");
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(ac);
- CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes);
- _builder.append(_attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- List<Attribute> _allAttributes_1 = this._roomExtensions.getAllAttributes(ac);
- for(final Attribute a : _allAttributes_1) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
- if (_notEquals_1) {
- String _name_16 = ac.getName();
- String _plus = (_name_16 + " ");
- String _name_17 = a.getName();
- String _plus_1 = (_plus + _name_17);
- String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
- this.logger.logInfo(_plus_2);
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- StateGraph _stateMachine_1 = xpac.getStateMachine();
- boolean _isEmpty_9 = RoomHelpers.isEmpty(_stateMachine_1);
- boolean _not_2 = (!_isEmpty_9);
- if (_not_2) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- CharSequence _genDataMembers = this._stateMachineGen.genDataMembers(xpac);
- _builder.append(_genDataMembers, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_18 = ac.getName();
- _builder.append(_name_18, "");
- _builder.append("_init(");
- String _name_19 = ac.getName();
- _builder.append(_name_19, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_20 = ac.getName();
- _builder.append(_name_20, "");
- _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- boolean _or = false;
- if (dataDriven) {
- _or = true;
- } else {
- _or = (dataDriven || async);
- }
- if (_or) {
- _builder.append("void ");
- String _name_21 = ac.getName();
- _builder.append(_name_21, "");
- _builder.append("_execute(");
- String _name_22 = ac.getName();
- _builder.append(_name_22, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- EList<StandardOperation> _operations = ac.getOperations();
- String _name_23 = ac.getName();
- CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, _name_23);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_24 = ac.getName();
- CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_24);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- ActorCommunicationType _commType = ac.getCommType();
- boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
- ActorCommunicationType _commType_1 = ac.getCommType();
- boolean eventDriven = Objects.equal(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
- ActorCommunicationType _commType_2 = ac.getCommType();
- boolean dataDriven = Objects.equal(_commType_2, ActorCommunicationType.DATA_DRIVEN);
- boolean _or = false;
- if (async) {
- _or = true;
- } else {
- _or = (async || eventDriven);
- }
- boolean handleEvents = _or;
- 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 = ac.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._cExtensions.getCHeaderFileName(ac);
- _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.append("#include \"etUnit/etUnit.h\"");
- _builder.newLine();
- _builder.append("#include \"platform/etMemory.h\"");
- _builder.newLine();
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("#include \"");
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName_1, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(ac, 3);
- _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();
- {
- StateGraph _stateMachine = xpac.getStateMachine();
- boolean _isEmpty = RoomHelpers.isEmpty(_stateMachine);
- boolean _not = (!_isEmpty);
- if (_not) {
- CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
- _builder.append(_genStateMachine, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("void ");
- String _name_1 = ac.getName();
- _builder.append(_name_1, "");
- _builder.append("_init(");
- String _name_2 = ac.getName();
- _builder.append(_name_2, "");
- _builder.append("* self){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_3 = ac.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", \"init\")");
- _builder.newLineIfNotEmpty();
- {
- StateGraph _stateMachine_1 = xpac.getStateMachine();
- boolean _isEmpty_1 = RoomHelpers.isEmpty(_stateMachine_1);
- boolean _not_1 = (!_isEmpty_1);
- if (_not_1) {
- _builder.append("\t");
- CharSequence _genInitialization = this._stateMachineGen.genInitialization(xpac);
- _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 = ac.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 = ac.getName();
- _builder.append(_name_5, " ");
- _builder.append("\", \"_receiveMessage\")");
- _builder.newLineIfNotEmpty();
- {
- StateGraph _stateMachine_2 = xpac.getStateMachine();
- boolean _isEmpty_2 = RoomHelpers.isEmpty(_stateMachine_2);
- boolean _not_2 = (!_isEmpty_2);
- if (_not_2) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("receiveEvent(self");
- {
- if (handleEvents) {
- _builder.append(", (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))");
- }
- }
- _builder.append(");");
- _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();
- {
- boolean _or_1 = false;
- if (dataDriven) {
- _or_1 = true;
- } else {
- _or_1 = (dataDriven || async);
- }
- if (_or_1) {
- _builder.append("void ");
- String _name_6 = ac.getName();
- _builder.append(_name_6, "");
- _builder.append("_execute(");
- String _name_7 = ac.getName();
- _builder.append(_name_7, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_8 = ac.getName();
- _builder.append(_name_8, " ");
- _builder.append("\", \"_execute\")");
- _builder.newLineIfNotEmpty();
- {
- StateGraph _stateMachine_3 = xpac.getStateMachine();
- boolean _isEmpty_3 = RoomHelpers.isEmpty(_stateMachine_3);
- boolean _not_3 = (!_isEmpty_3);
- if (_not_3) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("receiveEvent(self");
- {
- if (handleEvents) {
- _builder.append(", NULL, 0, NULL");
- }
- }
- _builder.append(");");
- _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();
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.common.base.Objects;
+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.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.Annotation;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.c.gen.StateMachineGen;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions _cExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @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._roomExtensions.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this._roomExtensions.getPath(_actorClass_1);
+ String path = (_generationTargetPath + _path);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(_actorClass_2);
+ String _plus = ("generating ActorClass header \'" + _cHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ CharSequence _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 _plus_4 = ("omitting ActorClass source for \'" + _name);
+ String _plus_5 = (_plus_4 + "\' since @BehaviorManual is specified");
+ this.logger.logInfo(_plus_5);
+ } else {
+ ActorClass _actorClass_6 = xpac.getActorClass();
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(_actorClass_6);
+ String _plus_6 = ("generating ActorClass source \'" + _cSourceFileName);
+ String _plus_7 = (_plus_6 + "\' in \'");
+ String _plus_8 = (_plus_7 + path);
+ String _plus_9 = (_plus_8 + "\'");
+ this.logger.logInfo(_plus_9);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_7 = xpac.getActorClass();
+ String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(_actorClass_7);
+ ActorClass _actorClass_8 = xpac.getActorClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+ }
+
+ private boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
+ ActorClass _actorClass = xpac.getActorClass();
+ EList<Annotation> _behaviorAnnotations = _actorClass.getBehaviorAnnotations();
+ boolean _notEquals = (!Objects.equal(_behaviorAnnotations, null));
+ if (_notEquals) {
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ EList<Annotation> _behaviorAnnotations_1 = _actorClass_1.getBehaviorAnnotations();
+ final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
+ public Boolean apply(final Annotation e) {
+ String _name = e.getName();
+ boolean _equals = Objects.equal(_name, annotation);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_behaviorAnnotations_1, _function);
+ boolean _notEquals_1 = (!Objects.equal(_findFirst, null));
+ if (_notEquals_1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Port> _allEndPorts = this._roomExtensions.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ GeneralProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Iterable<Port> eventPorts = IterableExtensions.<Port>filter(_allEndPorts, _function);
+ List<Port> _allEndPorts_1 = this._roomExtensions.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function_1 = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ boolean _and = false;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
+ if (!_equals) {
+ _and = false;
+ } else {
+ boolean _isConjugated = p.isConjugated();
+ _and = (_equals && _isConjugated);
+ }
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<Port> sendPorts = IterableExtensions.<Port>filter(_allEndPorts_1, _function_1);
+ List<Port> _allEndPorts_2 = this._roomExtensions.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function_2 = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ boolean _and = false;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
+ if (!_equals) {
+ _and = false;
+ } else {
+ boolean _isConjugated = p.isConjugated();
+ boolean _not = (!_isConjugated);
+ _and = (_equals && _not);
+ }
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<Port> recvPorts = IterableExtensions.<Port>filter(_allEndPorts_2, _function_2);
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean dataDriven = Objects.equal(_commType, ActorCommunicationType.DATA_DRIVEN);
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean async = Objects.equal(_commType_1, ActorCommunicationType.ASYNCHRONOUS);
+ 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 = ac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = ac.getName();
+ CharSequence _generateIncludeGuardBegin = this._cExtensions.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();
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ String _name_4 = ac.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = ac.getName();
+ _builder.append(_name_5, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* const part of ActorClass (ROM) */");
+ _builder.newLine();
+ {
+ boolean _and = false;
+ boolean _and_1 = false;
+ boolean _and_2 = false;
+ boolean _isEmpty = IterableExtensions.isEmpty(eventPorts);
+ if (!_isEmpty) {
+ _and_2 = false;
+ } else {
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
+ _and_2 = (_isEmpty && _isEmpty_1);
+ }
+ if (!_and_2) {
+ _and_1 = false;
+ } else {
+ List<SAPRef> _allSAPs = this._roomExtensions.getAllSAPs(ac);
+ boolean _isEmpty_2 = _allSAPs.isEmpty();
+ _and_1 = (_and_2 && _isEmpty_2);
+ }
+ if (!_and_1) {
+ _and = false;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations = this._roomExtensions.getAllServiceImplementations(ac);
+ boolean _isEmpty_3 = _allServiceImplementations.isEmpty();
+ _and = (_and_1 && _isEmpty_3);
+ }
+ if (_and) {
+ _builder.append("/* this actor class has no ports and thus no constant data */");
+ _builder.newLine();
+ } else {
+ _builder.append("typedef struct ");
+ String _name_6 = ac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_const {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* simple ports */");
+ _builder.newLine();
+ {
+ for(final Port ep : eventPorts) {
+ {
+ int _multiplicity = ep.getMultiplicity();
+ boolean _equals = (_multiplicity == 1);
+ if (_equals) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName = this._roomExtensions.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("/* data receive ports */");
+ _builder.newLine();
+ {
+ for(final Port ep_1 : recvPorts) {
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _equals_1 = (_multiplicity_1 == 1);
+ if (_equals_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1);
+ _builder.append(_portClassName_1, " ");
+ _builder.append(" ");
+ String _name_8 = ep_1.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* saps */");
+ _builder.newLine();
+ {
+ List<SAPRef> _allSAPs_1 = this._roomExtensions.getAllSAPs(ac);
+ for(final SAPRef sap : _allSAPs_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_2 = this._roomExtensions.getPortClassName(sap);
+ _builder.append(_portClassName_2, " ");
+ _builder.append(" ");
+ String _name_9 = sap.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* replicated ports */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts_3 = this._roomExtensions.getAllEndPorts(ac);
+ for(final Port ep_2 : _allEndPorts_3) {
+ {
+ int _multiplicity_2 = ep_2.getMultiplicity();
+ boolean _notEquals = (_multiplicity_2 != 1);
+ if (_notEquals) {
+ _builder.append("\t");
+ _builder.append("const etReplPort ");
+ String _name_10 = ep_2.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* services */");
+ _builder.newLine();
+ {
+ List<ServiceImplementation> _allServiceImplementations_1 = this._roomExtensions.getAllServiceImplementations(ac);
+ for(final ServiceImplementation svc : _allServiceImplementations_1) {
+ _builder.append("\t");
+ _builder.append("const etReplPort ");
+ SPPRef _spp = svc.getSpp();
+ String _name_11 = _spp.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("} ");
+ String _name_12 = ac.getName();
+ _builder.append(_name_12, "");
+ _builder.append("_const;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ boolean _isEmpty_4 = RoomHelpers.isEmpty(_stateMachine);
+ boolean _not = (!_isEmpty_4);
+ if (_not) {
+ _builder.newLine();
+ CharSequence _genHeaderConstants = this._stateMachineGen.genHeaderConstants(xpac);
+ _builder.append(_genHeaderConstants, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* variable part of ActorClass (RAM) */");
+ _builder.newLine();
+ _builder.append("struct ");
+ String _name_13 = ac.getName();
+ _builder.append(_name_13, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _and_3 = false;
+ boolean _and_4 = false;
+ boolean _and_5 = false;
+ boolean _isEmpty_5 = IterableExtensions.isEmpty(eventPorts);
+ if (!_isEmpty_5) {
+ _and_5 = false;
+ } else {
+ boolean _isEmpty_6 = IterableExtensions.isEmpty(recvPorts);
+ _and_5 = (_isEmpty_5 && _isEmpty_6);
+ }
+ if (!_and_5) {
+ _and_4 = false;
+ } else {
+ List<SAPRef> _allSAPs_2 = this._roomExtensions.getAllSAPs(ac);
+ boolean _isEmpty_7 = _allSAPs_2.isEmpty();
+ _and_4 = (_and_5 && _isEmpty_7);
+ }
+ if (!_and_4) {
+ _and_3 = false;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations_2 = this._roomExtensions.getAllServiceImplementations(ac);
+ boolean _isEmpty_8 = _allServiceImplementations_2.isEmpty();
+ _and_3 = (_and_4 && _isEmpty_8);
+ }
+ boolean _not_1 = (!_and_3);
+ if (_not_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_14 = ac.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("_const* const constData;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("/* data send ports */");
+ _builder.newLine();
+ {
+ for(final Port ep_3 : sendPorts) {
+ {
+ int _multiplicity_3 = ep_3.getMultiplicity();
+ boolean _equals_2 = (_multiplicity_3 == 1);
+ if (_equals_2) {
+ _builder.append("\t");
+ String _portClassName_3 = this._roomExtensions.getPortClassName(ep_3);
+ _builder.append(_portClassName_3, " ");
+ _builder.append(" ");
+ String _name_15 = ep_3.getName();
+ _builder.append(_name_15, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(ac);
+ CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ List<Attribute> _allAttributes_1 = this._roomExtensions.getAllAttributes(ac);
+ for(final Attribute a : _allAttributes_1) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals_1) {
+ String _name_16 = ac.getName();
+ String _plus = (_name_16 + " ");
+ String _name_17 = a.getName();
+ String _plus_1 = (_plus + _name_17);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ boolean _isEmpty_9 = RoomHelpers.isEmpty(_stateMachine_1);
+ boolean _not_2 = (!_isEmpty_9);
+ if (_not_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genDataMembers = this._stateMachineGen.genDataMembers(xpac);
+ _builder.append(_genDataMembers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_18 = ac.getName();
+ _builder.append(_name_18, "");
+ _builder.append("_init(");
+ String _name_19 = ac.getName();
+ _builder.append(_name_19, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_20 = ac.getName();
+ _builder.append(_name_20, "");
+ _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _or = false;
+ if (dataDriven) {
+ _or = true;
+ } else {
+ _or = (dataDriven || async);
+ }
+ if (_or) {
+ _builder.append("void ");
+ String _name_21 = ac.getName();
+ _builder.append(_name_21, "");
+ _builder.append("_execute(");
+ String _name_22 = ac.getName();
+ _builder.append(_name_22, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ EList<StandardOperation> _operations = ac.getOperations();
+ String _name_23 = ac.getName();
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, _name_23);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_24 = ac.getName();
+ CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_24);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean eventDriven = Objects.equal(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ ActorCommunicationType _commType_2 = ac.getCommType();
+ boolean dataDriven = Objects.equal(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ boolean _or = false;
+ if (async) {
+ _or = true;
+ } else {
+ _or = (async || eventDriven);
+ }
+ boolean handleEvents = _or;
+ 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 = ac.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._cExtensions.getCHeaderFileName(ac);
+ _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.append("#include \"etUnit/etUnit.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etMemory.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName_1, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 3);
+ _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();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ boolean _isEmpty = RoomHelpers.isEmpty(_stateMachine);
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
+ _builder.append(_genStateMachine, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_init(");
+ String _name_2 = ac.getName();
+ _builder.append(_name_2, "");
+ _builder.append("* self){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_3 = ac.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", \"init\")");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ boolean _isEmpty_1 = RoomHelpers.isEmpty(_stateMachine_1);
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ _builder.append("\t");
+ CharSequence _genInitialization = this._stateMachineGen.genInitialization(xpac);
+ _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 = ac.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 = ac.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\", \"_receiveMessage\")");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ boolean _isEmpty_2 = RoomHelpers.isEmpty(_stateMachine_2);
+ boolean _not_2 = (!_isEmpty_2);
+ if (_not_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self");
+ {
+ if (handleEvents) {
+ _builder.append(", (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))");
+ }
+ }
+ _builder.append(");");
+ _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();
+ {
+ boolean _or_1 = false;
+ if (dataDriven) {
+ _or_1 = true;
+ } else {
+ _or_1 = (dataDriven || async);
+ }
+ if (_or_1) {
+ _builder.append("void ");
+ String _name_6 = ac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_execute(");
+ String _name_7 = ac.getName();
+ _builder.append(_name_7, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("\", \"_execute\")");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_3 = xpac.getStateMachine();
+ boolean _isEmpty_3 = RoomHelpers.isEmpty(_stateMachine_3);
+ boolean _not_3 = (!_isEmpty_3);
+ if (_not_3) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self");
+ {
+ if (handleEvents) {
+ _builder.append(", NULL, 0, NULL");
+ }
+ }
+ _builder.append(");");
+ _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();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
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 ca33e2853..d63a7ff0d 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,240 +1,240 @@
-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.core.room.VarDecl;
-import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.util.Pair;
-
-@Singleton
-@SuppressWarnings("all")
-public class CExtensions implements ILanguageExtension {
- @Inject
- private AbstractTransitionChainGenerator chainGenerator;
-
- public String getTypedDataDefinition(final Message m) {
- VarDecl _data = m.getData();
- return this.chainGenerator.generateTypedData(_data);
- }
-
- 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 _plus = (classname + _xifexpression);
- return _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 _plus = (classname + "_");
- return _plus;
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- String _plus = (namespace + "_");
- return (_plus + member);
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _plus = (namespace + "_");
- return (_plus + member);
- }
-
- /**
- * TODO: move specific code elsewhere
- */
- public String getCHeaderFileName(final RoomClass rc) {
- String _name = rc.getName();
- return (_name + ".h");
- }
-
- public String getCSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- return (_name + ".c");
- }
-
- public String getInstSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- return (_name + "_Inst.h");
- }
-
- public String getDispSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- return (_name + "_Disp.h");
- }
-
- public CharSequence getIncludeGuardString(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("_");
- String _upperCase = filename.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_H_");
- return _builder;
- }
-
- public CharSequence generateIncludeGuardBegin(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef ");
- CharSequence _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.newLineIfNotEmpty();
- _builder.append("#define ");
- CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString_1, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence generateIncludeGuardEnd(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#endif /* ");
- CharSequence _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 _hasElements = false;
- for(final Pair<String,String> entry : entries) {
- if (!_hasElements) {
- _hasElements = 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 pointerLiteral() {
- return "*";
- }
-
- public String nullPointer() {
- return "NULL";
- }
-
- public String voidPointer() {
- return "void*";
- }
-
- public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
- String _xifexpression = null;
- if (isRef) {
- String _plus = (type + "* ");
- String _plus_1 = (_plus + name);
- String _plus_2 = (_plus_1 + "[");
- String _plus_3 = (_plus_2 + Integer.valueOf(size));
- String _plus_4 = (_plus_3 + "]");
- _xifexpression = _plus_4;
- } else {
- String _plus_5 = (type + " ");
- String _plus_6 = (_plus_5 + name);
- String _plus_7 = (_plus_6 + "[");
- String _plus_8 = (_plus_7 + Integer.valueOf(size));
- String _plus_9 = (_plus_8 + "]");
- _xifexpression = _plus_9;
- }
- return _xifexpression;
- }
-
- public String constructorName(final String cls) {
- return "ctor";
- }
-
- public String destructorName(final String cls) {
- return "dtor";
- }
-
- public String constructorReturnType() {
- return "void";
- }
-
- public String destructorReturnType() {
- return "void";
- }
-
- public String toCharArrayExpr(final String s) {
- String _plus = ("\"" + s);
- String _plus_1 = (_plus + "\"");
- return _plus_1;
- }
-
- public String superCall(final String baseClassName, final String method, final String args) {
- return "";
- }
-}
+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.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+
+@Singleton
+@SuppressWarnings("all")
+public class CExtensions implements ILanguageExtension {
+ @Inject
+ private AbstractTransitionChainGenerator chainGenerator;
+
+ public String getTypedDataDefinition(final Message m) {
+ VarDecl _data = m.getData();
+ return this.chainGenerator.generateTypedData(_data);
+ }
+
+ 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 _plus = (classname + _xifexpression);
+ return _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 _plus = (classname + "_");
+ return _plus;
+ }
+
+ public String memberInDeclaration(final String namespace, final String member) {
+ String _plus = (namespace + "_");
+ return (_plus + member);
+ }
+
+ public String memberInUse(final String namespace, final String member) {
+ String _plus = (namespace + "_");
+ return (_plus + member);
+ }
+
+ /**
+ * TODO: move specific code elsewhere
+ */
+ public String getCHeaderFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + ".h");
+ }
+
+ public String getCSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + ".c");
+ }
+
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + "_Inst.h");
+ }
+
+ public String getDispSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + "_Disp.h");
+ }
+
+ public CharSequence getIncludeGuardString(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("_");
+ String _upperCase = filename.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_H_");
+ return _builder;
+ }
+
+ public CharSequence generateIncludeGuardBegin(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#ifndef ");
+ CharSequence _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#define ");
+ CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString_1, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence generateIncludeGuardEnd(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#endif /* ");
+ CharSequence _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 _hasElements = false;
+ for(final Pair<String,String> entry : entries) {
+ if (!_hasElements) {
+ _hasElements = 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 pointerLiteral() {
+ return "*";
+ }
+
+ public String nullPointer() {
+ return "NULL";
+ }
+
+ public String voidPointer() {
+ return "void*";
+ }
+
+ public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
+ String _xifexpression = null;
+ if (isRef) {
+ String _plus = (type + "* ");
+ String _plus_1 = (_plus + name);
+ String _plus_2 = (_plus_1 + "[");
+ String _plus_3 = (_plus_2 + Integer.valueOf(size));
+ String _plus_4 = (_plus_3 + "]");
+ _xifexpression = _plus_4;
+ } else {
+ String _plus_5 = (type + " ");
+ String _plus_6 = (_plus_5 + name);
+ String _plus_7 = (_plus_6 + "[");
+ String _plus_8 = (_plus_7 + Integer.valueOf(size));
+ String _plus_9 = (_plus_8 + "]");
+ _xifexpression = _plus_9;
+ }
+ return _xifexpression;
+ }
+
+ public String constructorName(final String cls) {
+ return "ctor";
+ }
+
+ public String destructorName(final String cls) {
+ return "dtor";
+ }
+
+ public String constructorReturnType() {
+ return "void";
+ }
+
+ public String destructorReturnType() {
+ return "void";
+ }
+
+ public String toCharArrayExpr(final String s) {
+ String _plus = ("\"" + s);
+ String _plus_1 = (_plus + "\"");
+ return _plus_1;
+ }
+
+ public String superCall(final String baseClassName, final String method, final String args) {
+ return "";
+ }
+}
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 61236fc9c..991eef03f 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,247 +1,247 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.common.base.Objects;
-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.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions _cExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
- String _path = this._roomExtensions.getPath(dc);
- String path = (_generationTargetPath + _path);
- String _cHeaderFileName = this._cExtensions.getCHeaderFileName(dc);
- String _plus = ("generating DataClass header \'" + _cHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(dc);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this._cExtensions.getCSourceFileName(dc);
- String _plus_4 = ("generating DataClass source \'" + _cSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(dc);
- CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public CharSequence 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();
- CharSequence _generateIncludeGuardBegin = this._cExtensions.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();
- CharSequence _userCode = this._procedureHelpers.userCode(dc, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(dc);
- CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes);
- _builder.append(_attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("} ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- List<Attribute> _allAttributes_1 = this._roomExtensions.getAllAttributes(dc);
- for(final Attribute a : _allAttributes_1) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
- if (_notEquals) {
- String _name_4 = dc.getName();
- String _plus = (_name_4 + " ");
- String _name_5 = a.getName();
- String _plus_1 = (_plus + _name_5);
- String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
- this.logger.logInfo(_plus_2);
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_6 = dc.getName();
- CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, _name_6);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* deep copy */");
- _builder.newLine();
- _builder.append("void ");
- String _name_7 = dc.getName();
- _builder.append(_name_7, "");
- _builder.append("_deepCopy(");
- String _name_8 = dc.getName();
- _builder.append(_name_8, "");
- _builder.append("* source, ");
- String _name_9 = dc.getName();
- _builder.append(_name_9, "");
- _builder.append("* target);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_10 = dc.getName();
- CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_10);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence 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._cExtensions.getCHeaderFileName(dc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include <string.h>");
- _builder.newLine();
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(dc, 3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_1 = dc.getName();
- CharSequence _operationsImplementation = this._procedureHelpers.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.common.base.Objects;
+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.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions _cExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
+ String _path = this._roomExtensions.getPath(dc);
+ String path = (_generationTargetPath + _path);
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(dc);
+ String _plus = ("generating DataClass header \'" + _cHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(dc);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(dc);
+ String _plus_4 = ("generating DataClass source \'" + _cSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(dc);
+ CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence 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();
+ CharSequence _generateIncludeGuardBegin = this._cExtensions.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();
+ CharSequence _userCode = this._procedureHelpers.userCode(dc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(dc);
+ CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("} ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ List<Attribute> _allAttributes_1 = this._roomExtensions.getAllAttributes(dc);
+ for(final Attribute a : _allAttributes_1) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals) {
+ String _name_4 = dc.getName();
+ String _plus = (_name_4 + " ");
+ String _name_5 = a.getName();
+ String _plus_1 = (_plus + _name_5);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_6 = dc.getName();
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, _name_6);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* deep copy */");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = dc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_deepCopy(");
+ String _name_8 = dc.getName();
+ _builder.append(_name_8, "");
+ _builder.append("* source, ");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, "");
+ _builder.append("* target);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_10 = dc.getName();
+ CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_10);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence 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._cExtensions.getCHeaderFileName(dc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <string.h>");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(dc, 3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_1 = dc.getName();
+ CharSequence _operationsImplementation = this._procedureHelpers.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 26daa4b46..4443dd84c 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,60 +1,60 @@
-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.core.genmodel.etricegen.Root;
-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.generic.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@Singleton
-@SuppressWarnings("all")
-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 _not = (!_isLibrary);
- if (_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.core.genmodel.etricegen.Root;
+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.generic.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@Singleton
+@SuppressWarnings("all")
+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 _not = (!_isLibrary);
+ if (_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 91dcd5e39..65d3e54b6 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,1185 +1,1185 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.common.base.Objects;
-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.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.CommunicationType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageHandler;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PortOperation;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions _cExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
- String _path = this._roomExtensions.getPath(pc);
- String path = (_generationTargetPath + _path);
- String _cHeaderFileName = this._cExtensions.getCHeaderFileName(pc);
- String _plus = ("generating ProtocolClass header \'" + _cHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this._cExtensions.getCSourceFileName(pc);
- String _plus_4 = ("generating ProtocolClass source \'" + _cSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(pc);
- CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private CharSequence 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();
- CharSequence _generateIncludeGuardBegin = this._cExtensions.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();
- CharSequence _userCode = this._procedureHelpers.userCode(pc, 1);
- _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();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.newLine();
- _builder.append("/* message IDs */");
- _builder.newLine();
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port structs and methods */");
- _builder.newLine();
- CharSequence _portClassHeader = this.portClassHeader(pc, Boolean.valueOf(false));
- _builder.append(_portClassHeader, "");
- _builder.newLineIfNotEmpty();
- CharSequence _portClassHeader_1 = this.portClassHeader(pc, Boolean.valueOf(true));
- _builder.append(_portClassHeader_1, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_equals_1) {
- _builder.append("/*--------------------- port structs and methods */");
- _builder.newLine();
- CharSequence _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
- _builder.append(_genDataDrivenPortHeaders, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_equals_2) {
- _builder.append("#error \"synchronoue protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- _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();
- CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_4 = pc.getName();
- CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_4);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- private CharSequence 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._cExtensions.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"debugging/etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(pc, 3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port methods */");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- CharSequence _portClassSource = this.portClassSource(pc, Boolean.valueOf(false));
- _builder.append(_portClassSource, "");
- _builder.newLineIfNotEmpty();
- CharSequence _portClassSource_1 = this.portClassSource(pc, Boolean.valueOf(true));
- _builder.append(_portClassSource_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_equals_1) {
- CharSequence _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
- _builder.append(_genDataDrivenPortSources, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_equals_2) {
- _builder.append("#error \"synchronous protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- return _builder;
- }
-
- private CharSequence portClassHeader(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
- List<Message> _xifexpression = null;
- if ((conj).booleanValue()) {
- List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("typedef etPort ");
- _builder.append(portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("typedef etReplPort ");
- _builder.append(replPortClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- boolean _notEquals = (!Objects.equal(_portClass, null));
- if (_notEquals) {
- {
- PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<Attribute> _attributes = _portClass_1.getAttributes();
- boolean _isEmpty = _attributes.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- _builder.append("/* variable part of PortClass (RAM) */");
- _builder.newLine();
- _builder.append("typedef struct ");
- _builder.append(portClassName, "");
- _builder.append("_var ");
- _builder.append(portClassName, "");
- _builder.append("_var; ");
- _builder.newLineIfNotEmpty();
- _builder.append("struct ");
- _builder.append(portClassName, "");
- _builder.append("_var {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
- CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
- _builder.append(_attributes_2, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("};");
- _builder.newLine();
- {
- PortClass _portClass_3 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
- for(final Attribute a : _attributes_3) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
- if (_notEquals_1) {
- String _plus = (portClassName + " ");
- String _name = a.getName();
- String _plus_1 = (_plus + _name);
- String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
- this.logger.logInfo(_plus_2);
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- boolean hasData = (!Objects.equal(_data, null));
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_1 = message.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _xifexpression_1 = _typeName;
- } else {
- _xifexpression_1 = "";
- }
- String typeName = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _and = false;
- if (!hasData) {
- _and = false;
- } else {
- boolean _or = false;
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _not_1 = (!(_type_1 instanceof PrimitiveType));
- if (_not_1) {
- _or = true;
- } else {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- boolean _isRef = _refType_2.isRef();
- _or = (_not_1 || _isRef);
- }
- _and = (hasData && _or);
- }
- if (_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _plus_3 = (", " + typeName);
- String _plus_4 = (_plus_3 + refp);
- String _plus_5 = (_plus_4 + " data");
- _xifexpression_3 = _plus_5;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _name_1 = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
- _builder.append(_messageSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _name_2 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
- _builder.append(_messageSignature_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _name_3 = message.getName();
- String _plus_6 = (", int idx" + data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _plus_6);
- _builder.append(_messageSignature_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- PortClass _portClass_4 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- boolean _notEquals_2 = (!Objects.equal(_portClass_4, null));
- if (_notEquals_2) {
- PortClass _portClass_5 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<PortOperation> _operations = _portClass_5.getOperations();
- CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, portClassName);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- PortClass _portClass_6 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<PortOperation> _operations_1 = _portClass_6.getOperations();
- CharSequence _operationsDeclaration_1 = this._procedureHelpers.operationsDeclaration(_operations_1, replPortClassName);
- _builder.append(_operationsDeclaration_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive) {
- {
- List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler h : _receiveHandlers) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- Message _msg = h.getMsg();
- String _name_4 = _msg.getName();
- _builder.append(_name_4, "");
- _builder.append("_receiveHandler(");
- _builder.append(portClassName, "");
- _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("etInt32 ");
- _builder.append(replPortClassName, "");
- _builder.append("_getReplication(const ");
- _builder.append(replPortClassName, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence genDataDrivenPortHeaders(final ProtocolClass pc) {
- CharSequence _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- return Boolean.valueOf(_notEquals);
- }
- };
- Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* data driven send port (conjugated) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- {
- for(final Message msg : sentMsgs) {
- _builder.append("\t");
- VarDecl _data = msg.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String typeName = this._typeHelpers.typeName(_type);
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression = null;
- VarDecl _data_1 = msg.getData();
- RefableType _refType_1 = _data_1.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(typeName, " ");
- _builder.append(refp, " ");
- _builder.append(" ");
- String _name = msg.getName();
- _builder.append(_name, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- String _portClassName = this._roomExtensions.getPortClassName(pc, true);
- _builder.append(_portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* data driven receive port (regular) */");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_1 = this._roomExtensions.getPortClassName(pc, true);
- _builder.append(_portClassName_1, " ");
- _builder.append("* peer;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_2 = this._roomExtensions.getPortClassName(pc, false);
- _builder.append(_portClassName_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- for(final Message message : sentMsgs) {
- VarDecl _data_2 = message.getData();
- boolean hasData = (!Objects.equal(_data_2, null));
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- if (hasData) {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- String _typeName = this._typeHelpers.typeName(_type_1);
- _xifexpression_1 = _typeName;
- } else {
- _xifexpression_1 = "";
- }
- String typeName_1 = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _and = false;
- if (!hasData) {
- _and = false;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- DataType _type_2 = _refType_3.getType();
- boolean _not = (!(_type_2 instanceof PrimitiveType));
- _and = (hasData && _not);
- }
- if (_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp_1 = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _plus = (", " + typeName_1);
- String _plus_1 = (_plus + refp_1);
- String _plus_2 = (_plus_1 + " data");
- _xifexpression_3 = _plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _portClassName_3 = this._roomExtensions.getPortClassName(pc, true);
- String _name_1 = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- String _portClassName_4 = this._roomExtensions.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
- _builder.append(_messageGetterSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence genDataDrivenPortSources(final ProtocolClass pc) {
- CharSequence _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- return Boolean.valueOf(_notEquals);
- }
- };
- Iterable<Message> messages = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- String typeName = this._typeHelpers.typeName(_type);
- _builder.newLineIfNotEmpty();
- String _xifexpression = null;
- VarDecl _data_1 = message.getData();
- RefableType _refType_1 = _data_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _not = (!(_type_1 instanceof PrimitiveType));
- if (_not) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- String _plus = (", " + typeName);
- String _plus_1 = (_plus + refp);
- String data = (_plus_1 + " data");
- _builder.newLineIfNotEmpty();
- String _portClassName = this._roomExtensions.getPortClassName(pc, true);
- String _name = message.getName();
- String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
- _builder.append(_messageSetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("self->");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = data;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_1 = this._roomExtensions.getPortClassName(pc, false);
- String _name_2 = message.getName();
- String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
- _builder.append(_messageGetterSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return self->peer->");
- String _name_3 = message.getName();
- _builder.append(_name_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence portClassSource(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
- List<Message> _xifexpression = null;
- if ((conj).booleanValue()) {
- List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- String _xifexpression_1 = null;
- if ((conj).booleanValue()) {
- _xifexpression_1 = "IN_";
- } else {
- _xifexpression_1 = "OUT_";
- }
- String dir = _xifexpression_1;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- boolean hasData = (!Objects.equal(_data, null));
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- if (hasData) {
- VarDecl _data_1 = message.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _xifexpression_2 = _typeName;
- } else {
- _xifexpression_2 = "";
- }
- String typeName = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- boolean _and = false;
- if (!hasData) {
- _and = false;
- } else {
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- boolean _isRef = _refType_1.isRef();
- _and = (hasData && _isRef);
- }
- if (_and) {
- _xifexpression_3 = "*";
- } else {
- _xifexpression_3 = "";
- }
- String refp = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _xifexpression_4 = null;
- boolean _and_1 = false;
- if (!hasData) {
- _and_1 = false;
- } else {
- boolean _or = false;
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- boolean _not = (!(_type_1 instanceof PrimitiveType));
- if (_not) {
- _or = true;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- boolean _isRef_1 = _refType_3.isRef();
- _or = (_not || _isRef_1);
- }
- _and_1 = (hasData && _or);
- }
- if (_and_1) {
- _xifexpression_4 = "*";
- } else {
- _xifexpression_4 = "";
- }
- String refpd = _xifexpression_4;
- _builder.newLineIfNotEmpty();
- String _xifexpression_5 = null;
- boolean _and_2 = false;
- boolean _and_3 = false;
- if (!hasData) {
- _and_3 = false;
- } else {
- VarDecl _data_5 = message.getData();
- RefableType _refType_4 = _data_5.getRefType();
- DataType _type_2 = _refType_4.getType();
- boolean _not_1 = (!(_type_2 instanceof PrimitiveType));
- _and_3 = (hasData && _not_1);
- }
- if (!_and_3) {
- _and_2 = false;
- } else {
- VarDecl _data_6 = message.getData();
- RefableType _refType_5 = _data_6.getRefType();
- boolean _isRef_2 = _refType_5.isRef();
- boolean _not_2 = (!_isRef_2);
- _and_2 = (_and_3 && _not_2);
- }
- if (_and_2) {
- _xifexpression_5 = "";
- } else {
- _xifexpression_5 = "&";
- }
- String refa = _xifexpression_5;
- _builder.newLineIfNotEmpty();
- String _xifexpression_6 = null;
- if (hasData) {
- String _plus = (", " + typeName);
- String _plus_1 = (_plus + refpd);
- String _plus_2 = (_plus_1 + " data");
- _xifexpression_6 = _plus_2;
- } else {
- _xifexpression_6 = "";
- }
- String data = _xifexpression_6;
- _builder.newLineIfNotEmpty();
- String _xifexpression_7 = null;
- if (hasData) {
- _xifexpression_7 = ", data";
- } else {
- _xifexpression_7 = "";
- }
- String dataCall = _xifexpression_7;
- _builder.newLineIfNotEmpty();
- MessageHandler hdlr = this._roomExtensions.getSendHandler(message, (conj).booleanValue());
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name, "", data);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(hdlr, null));
- if (_notEquals) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _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("\t");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _plus_3 = (dir + _name_3);
- String _memberInUse = this._cExtensions.memberInUse(_name_2, _plus_3);
- String _plus_4 = (typeName + refp);
- String _plus_5 = (refa + "data");
- String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _plus_4, _plus_5);
- _builder.append(_sendMessageCall, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- String _name_4 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
- _builder.append(_messageSignature_1, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals_1 = (!Objects.equal(hdlr, null));
- if (_notEquals_1) {
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name_5 = message.getName();
- _builder.append(_name_5, " ");
- _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
- _builder.append(dataCall, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}\t\t\t\t\t");
- _builder.newLine();
- } else {
- _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_6 = message.getName();
- _builder.append(_name_6, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_7 = pc.getName();
- String _name_8 = message.getName();
- String _plus_6 = (dir + _name_8);
- String _memberInUse_1 = this._cExtensions.memberInUse(_name_7, _plus_6);
- String _plus_7 = (typeName + refp);
- String _plus_8 = (refa + "data");
- String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _plus_7, _plus_8);
- _builder.append(_sendMessageCall_1, " ");
- _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();
- String _name_9 = message.getName();
- String _plus_9 = (", int idx" + data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _plus_9);
- _builder.append(_messageSignature_2, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals_2 = (!Objects.equal(hdlr, null));
- if (_notEquals_2) {
- _builder.append("\t");
- _builder.append(portClassName, " ");
- _builder.append("_");
- String _name_10 = message.getName();
- _builder.append(_name_10, " ");
- _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
- _builder.append(dataCall, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_11 = message.getName();
- _builder.append(_name_11, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- String _name_12 = pc.getName();
- String _name_13 = message.getName();
- String _plus_10 = (dir + _name_13);
- String _memberInUse_2 = this._cExtensions.memberInUse(_name_12, _plus_10);
- String _plus_11 = (typeName + refp);
- String _plus_12 = (refa + "data");
- String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _plus_11, _plus_12);
- _builder.append(_sendMessageCall_2, " ");
- _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();
- {
- PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- boolean _notEquals_3 = (!Objects.equal(_portClass, null));
- if (_notEquals_3) {
- PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<PortOperation> _operations = _portClass_1.getOperations();
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- EList<PortOperation> _operations_1 = _portClass_2.getOperations();
- CharSequence _operationsImplementation_1 = this._procedureHelpers.operationsImplementation(_operations_1, replPortClassName);
- _builder.append(_operationsImplementation_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// getReplication");
- _builder.newLine();
- _builder.append("etInt32 ");
- _builder.append(replPortClassName, "");
- _builder.append("_getReplication(const ");
- _builder.append(replPortClassName, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return ((etReplPort*)self)->size;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive) {
- CharSequence _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
- _builder.append(_genReceiveHandlers, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
- String _xifexpression = null;
- if (hasData) {
- String _plus = ("etPort_sendMessage(" + self);
- String _plus_1 = (_plus + ", ");
- String _plus_2 = (_plus_1 + msg);
- String _plus_3 = (_plus_2 + ", sizeof(");
- String _plus_4 = (_plus_3 + typeName);
- String _plus_5 = (_plus_4 + "), ");
- String _plus_6 = (_plus_5 + data);
- String _plus_7 = (_plus_6 + ");");
- _xifexpression = _plus_7;
- } else {
- String _plus_8 = ("etPort_sendMessage(" + self);
- String _plus_9 = (_plus_8 + ", ");
- String _plus_10 = (_plus_9 + msg);
- String _plus_11 = (_plus_10 + ", 0, NULL);");
- _xifexpression = _plus_11;
- }
- return _xifexpression;
- }
-
- private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
- String _plus = ("void " + className);
- String _plus_1 = (_plus + "_");
- String _plus_2 = (_plus_1 + messageName);
- String _plus_3 = (_plus_2 + methodSuffix);
- String _plus_4 = (_plus_3 + "(const ");
- String _plus_5 = (_plus_4 + className);
- String _plus_6 = (_plus_5 + "* self");
- String _plus_7 = (_plus_6 + data);
- String _plus_8 = (_plus_7 + ")");
- return _plus_8;
- }
-
- private String messageSetterSignature(final String className, final String messageName, final String data) {
- String _plus = ("void " + className);
- String _plus_1 = (_plus + "_");
- String _plus_2 = (_plus_1 + messageName);
- String _plus_3 = (_plus_2 + "_set(");
- String _plus_4 = (_plus_3 + className);
- String _plus_5 = (_plus_4 + "* self");
- String _plus_6 = (_plus_5 + data);
- String _plus_7 = (_plus_6 + ")");
- return _plus_7;
- }
-
- private String messageGetterSignature(final String className, final String messageName, final String type) {
- String _plus = (type + " ");
- String _plus_1 = (_plus + className);
- String _plus_2 = (_plus_1 + "_");
- String _plus_3 = (_plus_2 + messageName);
- String _plus_4 = (_plus_3 + "_get(const ");
- String _plus_5 = (_plus_4 + className);
- String _plus_6 = (_plus_5 + "* const self)");
- return _plus_6;
- }
-
- private CharSequence genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* receiver handlers */");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler h : _receiveHandlers) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- Message _msg = h.getMsg();
- String _name = _msg.getName();
- _builder.append(_name, "");
- _builder.append("_receiveHandler(");
- _builder.append(portClassName, "");
- _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- DetailCode _detailCode = h.getDetailCode();
- CharSequence _userCode = this._procedureHelpers.userCode(_detailCode);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* hand over the message to the actor: */");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* message names as strings for debugging (generate MSC) */");
- _builder.newLine();
- _builder.append("static const char* const ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, "");
- _builder.append("\",");
- }
- }
- {
- List<Message> _allIncomingMessages = this._roomExtensions.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.common.base.Objects;
+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.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions _cExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
+ String _path = this._roomExtensions.getPath(pc);
+ String path = (_generationTargetPath + _path);
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(pc);
+ String _plus = ("generating ProtocolClass header \'" + _cHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(pc);
+ String _plus_4 = ("generating ProtocolClass source \'" + _cSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(pc);
+ CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private CharSequence 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();
+ CharSequence _generateIncludeGuardBegin = this._cExtensions.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();
+ CharSequence _userCode = this._procedureHelpers.userCode(pc, 1);
+ _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();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ _builder.newLine();
+ _builder.append("/* message IDs */");
+ _builder.newLine();
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ CharSequence _portClassHeader = this.portClassHeader(pc, Boolean.valueOf(false));
+ _builder.append(_portClassHeader, "");
+ _builder.newLineIfNotEmpty();
+ CharSequence _portClassHeader_1 = this.portClassHeader(pc, Boolean.valueOf(true));
+ _builder.append(_portClassHeader_1, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ CharSequence _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
+ _builder.append(_genDataDrivenPortHeaders, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _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();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_4);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence 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._cExtensions.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(pc, 3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port methods */");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ CharSequence _portClassSource = this.portClassSource(pc, Boolean.valueOf(false));
+ _builder.append(_portClassSource, "");
+ _builder.newLineIfNotEmpty();
+ CharSequence _portClassSource_1 = this.portClassSource(pc, Boolean.valueOf(true));
+ _builder.append(_portClassSource_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ CharSequence _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
+ _builder.append(_genDataDrivenPortSources, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronous protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
+ List<Message> _xifexpression = null;
+ if ((conj).booleanValue()) {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals = (!Objects.equal(_portClass, null));
+ if (_notEquals) {
+ {
+ PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("/* variable part of PortClass (RAM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var ");
+ _builder.append(portClassName, "");
+ _builder.append("_var; ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
+ CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ {
+ PortClass _portClass_3 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
+ for(final Attribute a : _attributes_3) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals_1) {
+ String _plus = (portClassName + " ");
+ String _name = a.getName();
+ String _plus_1 = (_plus + _name);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean hasData = (!Objects.equal(_data, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ boolean _or = false;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _not_1 = (!(_type_1 instanceof PrimitiveType));
+ if (_not_1) {
+ _or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _or = (_not_1 || _isRef);
+ }
+ _and = (hasData && _or);
+ }
+ if (_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _plus_3 = (", " + typeName);
+ String _plus_4 = (_plus_3 + refp);
+ String _plus_5 = (_plus_4 + " data");
+ _xifexpression_3 = _plus_5;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _name_1 = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_3 = message.getName();
+ String _plus_6 = (", int idx" + data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _plus_6);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ PortClass _portClass_4 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals_2 = (!Objects.equal(_portClass_4, null));
+ if (_notEquals_2) {
+ PortClass _portClass_5 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations = _portClass_5.getOperations();
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_6 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations_1 = _portClass_6.getOperations();
+ CharSequence _operationsDeclaration_1 = this._procedureHelpers.operationsDeclaration(_operations_1, replPortClassName);
+ _builder.append(_operationsDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ {
+ List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name_4 = _msg.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenPortHeaders(final ProtocolClass pc) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ return Boolean.valueOf(_notEquals);
+ }
+ };
+ Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* data driven send port (conjugated) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ {
+ for(final Message msg : sentMsgs) {
+ _builder.append("\t");
+ VarDecl _data = msg.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String typeName = this._typeHelpers.typeName(_type);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _xifexpression = null;
+ VarDecl _data_1 = msg.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(typeName, " ");
+ _builder.append(refp, " ");
+ _builder.append(" ");
+ String _name = msg.getName();
+ _builder.append(_name, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName = this._roomExtensions.getPortClassName(pc, true);
+ _builder.append(_portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data driven receive port (regular) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this._roomExtensions.getPortClassName(pc, true);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("* peer;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_2 = this._roomExtensions.getPortClassName(pc, false);
+ _builder.append(_portClassName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ for(final Message message : sentMsgs) {
+ VarDecl _data_2 = message.getData();
+ boolean hasData = (!Objects.equal(_data_2, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName = this._typeHelpers.typeName(_type_1);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName_1 = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ boolean _not = (!(_type_2 instanceof PrimitiveType));
+ _and = (hasData && _not);
+ }
+ if (_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp_1 = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _plus = (", " + typeName_1);
+ String _plus_1 = (_plus + refp_1);
+ String _plus_2 = (_plus_1 + " data");
+ _xifexpression_3 = _plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _portClassName_3 = this._roomExtensions.getPortClassName(pc, true);
+ String _name_1 = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _portClassName_4 = this._roomExtensions.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenPortSources(final ProtocolClass pc) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ return Boolean.valueOf(_notEquals);
+ }
+ };
+ Iterable<Message> messages = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String typeName = this._typeHelpers.typeName(_type);
+ _builder.newLineIfNotEmpty();
+ String _xifexpression = null;
+ VarDecl _data_1 = message.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _not = (!(_type_1 instanceof PrimitiveType));
+ if (_not) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ String _plus = (", " + typeName);
+ String _plus_1 = (_plus + refp);
+ String data = (_plus_1 + " data");
+ _builder.newLineIfNotEmpty();
+ String _portClassName = this._roomExtensions.getPortClassName(pc, true);
+ String _name = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = data;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_1 = this._roomExtensions.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return self->peer->");
+ String _name_3 = message.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence portClassSource(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
+ List<Message> _xifexpression = null;
+ if ((conj).booleanValue()) {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if ((conj).booleanValue()) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean hasData = (!Objects.equal(_data, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_2 = _typeName;
+ } else {
+ _xifexpression_2 = "";
+ }
+ String typeName = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ _and = (hasData && _isRef);
+ }
+ if (_and) {
+ _xifexpression_3 = "*";
+ } else {
+ _xifexpression_3 = "";
+ }
+ String refp = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_4 = null;
+ boolean _and_1 = false;
+ if (!hasData) {
+ _and_1 = false;
+ } else {
+ boolean _or = false;
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ boolean _not = (!(_type_1 instanceof PrimitiveType));
+ if (_not) {
+ _or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _or = (_not || _isRef_1);
+ }
+ _and_1 = (hasData && _or);
+ }
+ if (_and_1) {
+ _xifexpression_4 = "*";
+ } else {
+ _xifexpression_4 = "";
+ }
+ String refpd = _xifexpression_4;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_5 = null;
+ boolean _and_2 = false;
+ boolean _and_3 = false;
+ if (!hasData) {
+ _and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _not_1 = (!(_type_2 instanceof PrimitiveType));
+ _and_3 = (hasData && _not_1);
+ }
+ if (!_and_3) {
+ _and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _not_2 = (!_isRef_2);
+ _and_2 = (_and_3 && _not_2);
+ }
+ if (_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
+ if (hasData) {
+ String _plus = (", " + typeName);
+ String _plus_1 = (_plus + refpd);
+ String _plus_2 = (_plus_1 + " data");
+ _xifexpression_6 = _plus_2;
+ } else {
+ _xifexpression_6 = "";
+ }
+ String data = _xifexpression_6;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_7 = null;
+ if (hasData) {
+ _xifexpression_7 = ", data";
+ } else {
+ _xifexpression_7 = "";
+ }
+ String dataCall = _xifexpression_7;
+ _builder.newLineIfNotEmpty();
+ MessageHandler hdlr = this._roomExtensions.getSendHandler(message, (conj).booleanValue());
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(hdlr, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _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("\t");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _plus_3 = (dir + _name_3);
+ String _memberInUse = this._cExtensions.memberInUse(_name_2, _plus_3);
+ String _plus_4 = (typeName + refp);
+ String _plus_5 = (refa + "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _plus_4, _plus_5);
+ _builder.append(_sendMessageCall, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_4 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(hdlr, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _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_6 = message.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_7 = pc.getName();
+ String _name_8 = message.getName();
+ String _plus_6 = (dir + _name_8);
+ String _memberInUse_1 = this._cExtensions.memberInUse(_name_7, _plus_6);
+ String _plus_7 = (typeName + refp);
+ String _plus_8 = (refa + "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _plus_7, _plus_8);
+ _builder.append(_sendMessageCall_1, " ");
+ _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();
+ String _name_9 = message.getName();
+ String _plus_9 = (", int idx" + data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _plus_9);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_2 = (!Objects.equal(hdlr, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_10 = message.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_11 = message.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_12 = pc.getName();
+ String _name_13 = message.getName();
+ String _plus_10 = (dir + _name_13);
+ String _memberInUse_2 = this._cExtensions.memberInUse(_name_12, _plus_10);
+ String _plus_11 = (typeName + refp);
+ String _plus_12 = (refa + "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _plus_11, _plus_12);
+ _builder.append(_sendMessageCall_2, " ");
+ _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();
+ {
+ PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals_3 = (!Objects.equal(_portClass, null));
+ if (_notEquals_3) {
+ PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ CharSequence _operationsImplementation_1 = this._procedureHelpers.operationsImplementation(_operations_1, replPortClassName);
+ _builder.append(_operationsImplementation_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// getReplication");
+ _builder.newLine();
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return ((etReplPort*)self)->size;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ CharSequence _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
+ _builder.append(_genReceiveHandlers, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
+ String _xifexpression = null;
+ if (hasData) {
+ String _plus = ("etPort_sendMessage(" + self);
+ String _plus_1 = (_plus + ", ");
+ String _plus_2 = (_plus_1 + msg);
+ String _plus_3 = (_plus_2 + ", sizeof(");
+ String _plus_4 = (_plus_3 + typeName);
+ String _plus_5 = (_plus_4 + "), ");
+ String _plus_6 = (_plus_5 + data);
+ String _plus_7 = (_plus_6 + ");");
+ _xifexpression = _plus_7;
+ } else {
+ String _plus_8 = ("etPort_sendMessage(" + self);
+ String _plus_9 = (_plus_8 + ", ");
+ String _plus_10 = (_plus_9 + msg);
+ String _plus_11 = (_plus_10 + ", 0, NULL);");
+ _xifexpression = _plus_11;
+ }
+ return _xifexpression;
+ }
+
+ private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
+ String _plus = ("void " + className);
+ String _plus_1 = (_plus + "_");
+ String _plus_2 = (_plus_1 + messageName);
+ String _plus_3 = (_plus_2 + methodSuffix);
+ String _plus_4 = (_plus_3 + "(const ");
+ String _plus_5 = (_plus_4 + className);
+ String _plus_6 = (_plus_5 + "* self");
+ String _plus_7 = (_plus_6 + data);
+ String _plus_8 = (_plus_7 + ")");
+ return _plus_8;
+ }
+
+ private String messageSetterSignature(final String className, final String messageName, final String data) {
+ String _plus = ("void " + className);
+ String _plus_1 = (_plus + "_");
+ String _plus_2 = (_plus_1 + messageName);
+ String _plus_3 = (_plus_2 + "_set(");
+ String _plus_4 = (_plus_3 + className);
+ String _plus_5 = (_plus_4 + "* self");
+ String _plus_6 = (_plus_5 + data);
+ String _plus_7 = (_plus_6 + ")");
+ return _plus_7;
+ }
+
+ private String messageGetterSignature(final String className, final String messageName, final String type) {
+ String _plus = (type + " ");
+ String _plus_1 = (_plus + className);
+ String _plus_2 = (_plus_1 + "_");
+ String _plus_3 = (_plus_2 + messageName);
+ String _plus_4 = (_plus_3 + "_get(const ");
+ String _plus_5 = (_plus_4 + className);
+ String _plus_6 = (_plus_5 + "* const self)");
+ return _plus_6;
+ }
+
+ private CharSequence genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* receiver handlers */");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name = _msg.getName();
+ _builder.append(_name, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ DetailCode _detailCode = h.getDetailCode();
+ CharSequence _userCode = this._procedureHelpers.userCode(_detailCode);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* hand over the message to the actor: */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("static const char* const ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.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 de6d18f93..d3ab1111b 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,117 +1,117 @@
-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.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-
-@Singleton
-@SuppressWarnings("all")
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- public CharSequence genHeaderConstants(final ExpandedActorClass xpac) {
- CharSequence _xblockexpression = null;
- {
- final ActorClass ac = xpac.getActorClass();
- List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
- int _size = _allBaseStates.size();
- List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(ac);
- int _size_1 = _allLeafStates.size();
- int _minus = (_size - _size_1);
- final int historySize = (_minus + 2);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* constant for state machine data */");
- _builder.newLine();
- _builder.append("#define ");
- String _name = ac.getName();
- String _upperCase = _name.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_HISTORY_SIZE ");
- _builder.append(historySize, "");
- _builder.newLineIfNotEmpty();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence genDataMembers(final ExpandedActorClass xpac) {
- CharSequence _xblockexpression = null;
- {
- final ActorClass ac = xpac.getActorClass();
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* state machine variables */");
- _builder.newLine();
- _builder.append("etInt16 state;");
- _builder.newLine();
- _builder.append("etInt16 history[");
- String _name = ac.getName();
- String _upperCase = _name.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_HISTORY_SIZE];");
- _builder.newLineIfNotEmpty();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence genInitialization(final ExpandedActorClass xpac) {
- CharSequence _xblockexpression = null;
- {
- final ActorClass ac = xpac.getActorClass();
- 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<");
- String _name = ac.getName();
- String _upperCase = _name.toUpperCase();
- _builder.append(_upperCase, " ");
- _builder.append("_HISTORY_SIZE; ++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();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence genExtra(final ExpandedActorClass xpac) {
- CharSequence _xblockexpression = null;
- {
- final ActorClass ac = xpac.getActorClass();
- 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();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
+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.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+
+@Singleton
+@SuppressWarnings("all")
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public CharSequence genHeaderConstants(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
+ int _size = _allBaseStates.size();
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(ac);
+ int _size_1 = _allLeafStates.size();
+ int _minus = (_size - _size_1);
+ final int historySize = (_minus + 2);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* constant for state machine data */");
+ _builder.newLine();
+ _builder.append("#define ");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_HISTORY_SIZE ");
+ _builder.append(historySize, "");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genDataMembers(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* state machine variables */");
+ _builder.newLine();
+ _builder.append("etInt16 state;");
+ _builder.newLine();
+ _builder.append("etInt16 history[");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_HISTORY_SIZE];");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genInitialization(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ 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<");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, " ");
+ _builder.append("_HISTORY_SIZE; ++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();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genExtra(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ 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();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
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 ddf22e279..c1e96c4f0 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
@@ -265,7 +265,7 @@ public class SubSystemClassGen {
_builder.newLine();
_builder.append("#include \"platform/etTimer.h\"");
_builder.newLine();
- _builder.append("#include \"etGlobalFlags.h\"");
+ _builder.append("#include \"etRuntimeConfig.h\"");
_builder.newLine();
_builder.newLine();
DetailCode _userCode3 = ssc.getUserCode3();
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 a1a5d02f7..0c8326c33 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,171 +1,171 @@
-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.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-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 _plus = (_generationTargetPath + _path);
- this.fileAccess.setOutputPath(_plus);
- String _name = sc.getName();
- String _plus_1 = (_name + "_Runner.c");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- CharSequence _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_plus_1, _generateSourceFile);
- }
- }
- }
-
- public CharSequence 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.append("#include \"platform/etPlatform.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.append("\t");
- _builder.append("etUserEntry(); /* platform specific */");
- _builder.newLine();
- _builder.append("\t");
- _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("etUserPreRun(); /* platform specific */");
- _builder.newLine();
- _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("etUserPostRun(); /* platform specific */");
- _builder.newLine();
- _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("etUserExit(); /* platform specific */");
- _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.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+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 _plus = (_generationTargetPath + _path);
+ this.fileAccess.setOutputPath(_plus);
+ String _name = sc.getName();
+ String _plus_1 = (_name + "_Runner.c");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_plus_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence 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.append("#include \"platform/etPlatform.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.append("\t");
+ _builder.append("etUserEntry(); /* platform specific */");
+ _builder.newLine();
+ _builder.append("\t");
+ _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("etUserPreRun(); /* platform specific */");
+ _builder.newLine();
+ _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("etUserPostRun(); /* platform specific */");
+ _builder.newLine();
+ _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("etUserExit(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return 0;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
index ce99ce171..904a31a43 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
@@ -1,1053 +1,1053 @@
-package org.eclipse.etrice.generator.doc.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ChoicePoint;
-import org.eclipse.etrice.core.room.CompoundProtocolClass;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.Documentation;
-import org.eclipse.etrice.core.room.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.core.room.StateGraph;
-import org.eclipse.etrice.core.room.SubProtocol;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.IRoomGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class DocGen implements IRoomGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<RoomModel> _models = root.getModels();
- for (final RoomModel model : _models) {
- {
- String path = this.roomExt.getDocGenerationTargetPath(model);
- String _name = model.getName();
- String file = (_name + ".tex");
- String _plus = ("generating LaTeX documentation: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- CharSequence _generateModelDoc = this.generateModelDoc(root, model);
- this.fileAccess.generateFile(file, _generateModelDoc);
- }
- }
- }
-
- public CharSequence generateModelDoc(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\documentclass[titlepage]{article}");
- _builder.newLine();
- _builder.append("\\usepackage{graphicx}");
- _builder.newLine();
- _builder.append("\\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry}");
- _builder.newLine();
- _builder.append("\\usepackage{nonfloat}");
- _builder.newLine();
- _builder.append("\\parindent 0pt");
- _builder.newLine();
- _builder.append("\\makeatletter");
- _builder.newLine();
- _builder.append("\\newcommand\\level[1]{%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\ifcase#1\\relax\\expandafter\\chapter\\or");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\expandafter\\section\\or");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\expandafter\\subsection\\or");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\expandafter\\subsubsection\\else");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\def\\next{\\@level{#1}}\\expandafter\\next");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\fi}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\newcommand{\\@level}[1]{%");
- _builder.newLine();
- _builder.append("\\@startsection{level#1}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{#1}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{\\z@}%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{-3.25ex\\@plus -1ex \\@minus -.2ex}%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{1.5ex \\@plus .2ex}%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{\\normalfont\\normalsize\\bfseries}}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\newdimen\\@leveldim");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\newdimen\\@dotsdim");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{\\normalfont\\normalsize");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\sbox\\z@{0}\\global\\@leveldim=\\wd\\z@");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\sbox\\z@{.}\\global\\@dotsdim=\\wd\\z@");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("} ");
- _builder.newLine();
- _builder.append("\\newcounter{level4}[subsubsection]");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\@namedef{thelevel4}{\\thesubsubsection.\\arabic{level4}}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\@namedef{level4mark}#1{}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\def\\l@section{\\@dottedtocline{1}{0pt}{\\dimexpr\\@leveldim*4+\\@dotsdim*1+6pt\\relax}}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\def\\l@subsection{\\@dottedtocline{2}{0pt}{\\dimexpr\\@leveldim*5+\\@dotsdim*2+6pt\\relax}}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\def\\l@subsubsection{\\@dottedtocline{3}{0pt}{\\dimexpr\\@leveldim*6+\\@dotsdim*3+6pt\\relax}}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\@namedef{l@level4}{\\@dottedtocline{4}{0pt}{\\dimexpr\\@leveldim*7+\\@dotsdim*4+6pt\\relax}}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\count@=4");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\def\\@ncp#1{\\number\\numexpr\\count@+#1\\relax}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\loop\\ifnum\\count@<100");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\begingroup\\edef\\x{\\endgroup");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\noexpand\\newcounter{level\\@ncp{1}}[level\\number\\count@]");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\noexpand\\@namedef{thelevel\\@ncp{1}}{%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\noexpand\\@nameuse{thelevel\\@ncp{0}}.\\noexpand\\arabic{level\\@ncp{0}}}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\noexpand\\@namedef{level\\@ncp{1}mark}####1{}%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\noexpand\\@namedef{l@level\\@ncp{1}}%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("{\\noexpand\\@dottedtocline{\\@ncp{1}}{0pt}{\\the\\dimexpr\\@leveldim*\\@ncp{5}+\\@dotsdim*\\@ncp{0}\\relax}}}%");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\x");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\advance\\count@\\@ne");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\repeat");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\makeatother");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\setcounter{secnumdepth}{100}");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("\\setcounter{tocdepth}{100}");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\title{");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(" Modeldocumentation}");
- _builder.newLineIfNotEmpty();
- _builder.append("\\date{\\today}");
- _builder.newLine();
- _builder.append("\\author{generated by eTrice}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\begin{document}");
- _builder.newLine();
- _builder.append("\\pagestyle{plain}");
- _builder.newLine();
- _builder.append("\\maketitle");
- _builder.newLine();
- _builder.append("\\tableofcontents");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\newpage");
- _builder.newLine();
- _builder.append("\\listoffigures");
- _builder.newLine();
- _builder.append("\\newpage");
- _builder.newLine();
- _builder.append("\\section{Model Description}");
- _builder.newLine();
- Documentation _docu = model.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Subsystem Description}");
- _builder.newLine();
- CharSequence _generateAllSubSysClassDocs = this.generateAllSubSysClassDocs(root, model);
- _builder.append(_generateAllSubSysClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Protocol Class Description}");
- _builder.newLine();
- CharSequence _generateAllProtocolClassDocs = this.generateAllProtocolClassDocs(root, model);
- _builder.append(_generateAllProtocolClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Data Class Description}");
- _builder.newLine();
- CharSequence _generateAllDataClassDocs = this.generateAllDataClassDocs(root, model);
- _builder.append(_generateAllDataClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Actor Class Description}");
- _builder.newLine();
- CharSequence _generateAllActorClassDocs = this.generateAllActorClassDocs(root, model);
- _builder.append(_generateAllActorClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\end{document}");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence generateAllSubSysClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<SubSystemClass> _subSystemClasses = model.getSubSystemClasses();
- for(final SubSystemClass ssc : _subSystemClasses) {
- CharSequence _generateSubSysClassDoc = this.generateSubSysClassDoc(root, model, ssc);
- _builder.append(_generateSubSysClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public CharSequence generateSubSysClassDoc(final Root root, final RoomModel model, final SubSystemClass ssc) {
- CharSequence _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _plus = (_docGenerationTargetPath + "images\\");
- String _name = ssc.getName();
- String _plus_1 = (_plus + _name);
- String filename = (_plus_1 + "_structure.jpg");
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String latexFilename = filename.replaceAll("/", "//");
- String _docGenerationTargetPath_1 = this.roomExt.getDocGenerationTargetPath(model);
- String _plus_2 = (_docGenerationTargetPath_1 + "images\\");
- String _name_1 = ssc.getName();
- String _plus_3 = (_plus_2 + _name_1);
- String filenamei = (_plus_3 + "_instanceTree.jpg");
- String _replaceAll_1 = filenamei.replaceAll("\\\\", "/");
- filenamei = _replaceAll_1;
- String latexFilenamei = filenamei.replaceAll("/", "//");
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{2}{");
- String _name_2 = ssc.getName();
- _builder.append(_name_2, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- Documentation _docu = ssc.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\level{3}{Structure}");
- _builder.newLine();
- {
- String _fileExists = this.fileExists(filename);
- boolean _equals = _fileExists.equals("true");
- if (_equals) {
- String _name_3 = ssc.getName();
- String _plus_4 = (_name_3 + " Structure");
- CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_4);
- _builder.append(_includeGraphics, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\\level{3}{Instance Tree}");
- _builder.newLine();
- {
- String _fileExists_1 = this.fileExists(filename);
- boolean _equals_1 = _fileExists_1.equals("true");
- if (_equals_1) {
- String _name_4 = ssc.getName();
- String _plus_5 = (_name_4 + " Instance Tree");
- CharSequence _includeGraphics_1 = this.includeGraphics(latexFilenamei, "0.5", _plus_5);
- _builder.append(_includeGraphics_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateAllDataClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<DataClass> _dataClasses = model.getDataClasses();
- for(final DataClass dc : _dataClasses) {
- CharSequence _generateDataClassDoc = this.generateDataClassDoc(root, dc);
- _builder.append(_generateDataClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public CharSequence generateDataClassDoc(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{2} {");
- String _name = dc.getName();
- _builder.append(_name, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- Documentation _docu = dc.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\level{3}{Attributes}");
- _builder.newLine();
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _generateAttributesDoc = this.generateAttributesDoc(_attributes);
- _builder.append(_generateAttributesDoc, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\\level{3}{Operations}");
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- CharSequence _generateOperationsDoc = this.generateOperationsDoc(_operations);
- _builder.append(_generateOperationsDoc, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence generateAllProtocolClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<GeneralProtocolClass> _protocolClasses = model.getProtocolClasses();
- for(final GeneralProtocolClass pc : _protocolClasses) {
- CharSequence _generateProtocolClassDoc = this.generateProtocolClassDoc(root, pc);
- _builder.append(_generateProtocolClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- protected CharSequence _generateProtocolClassDoc(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\t");
- _builder.append("\\level{2} {");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- Documentation _docu = pc.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\\level{3}{Incoming Messages}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\begin{tabular}[ht]{|l|l|l|}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Message & Data & Description\\\\");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message ims : _allIncomingMessages) {
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- String _name_1 = ims.getName();
- _builder.append(_name_1, " ");
- _builder.append(" & ");
- {
- VarDecl _data = ims.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = ims.getData();
- String _name_2 = _data_1.getName();
- _builder.append(_name_2, " ");
- _builder.append(" ");
- }
- }
- _builder.append(" & ");
- Documentation _docu_1 = ims.getDocu();
- CharSequence _generateDocText_1 = this.generateDocText(_docu_1);
- _builder.append(_generateDocText_1, " ");
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\end{tabular}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\level{3}{Outgoing Messages}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\begin{tabular}[ht]{|l|l|l|}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Message & Data & Description\\\\");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message oms : _allOutgoingMessages) {
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- String _name_3 = oms.getName();
- _builder.append(_name_3, " ");
- _builder.append(" & ");
- {
- VarDecl _data_2 = oms.getData();
- boolean _notEquals_1 = (!Objects.equal(_data_2, null));
- if (_notEquals_1) {
- _builder.append(" ");
- VarDecl _data_3 = oms.getData();
- String _name_4 = _data_3.getName();
- _builder.append(_name_4, " ");
- _builder.append(" ");
- }
- }
- _builder.append(" & ");
- Documentation _docu_2 = oms.getDocu();
- CharSequence _generateDocText_2 = this.generateDocText(_docu_2);
- _builder.append(_generateDocText_2, " ");
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\\end{tabular}\t\t\t");
- _builder.newLine();
- return _builder;
- }
-
- protected CharSequence _generateProtocolClassDoc(final Root root, final CompoundProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{2} {");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- Documentation _docu = pc.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\level{3}{Sub Protocols}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\\begin{tabular}[ht]{|l|l|}");
- _builder.newLine();
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("Name & Protocol\\\\");
- _builder.newLine();
- {
- EList<SubProtocol> _subProtocols = pc.getSubProtocols();
- for(final SubProtocol sub : _subProtocols) {
- _builder.append("\\hline");
- _builder.newLine();
- String _name_1 = sub.getName();
- _builder.append(_name_1, "");
- _builder.append(" & ");
- GeneralProtocolClass _protocol = sub.getProtocol();
- String _name_2 = _protocol.getName();
- _builder.append(_name_2, "");
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\\end{tabular}");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence generateAllActorClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<ActorClass> _actorClasses = model.getActorClasses();
- for(final ActorClass ac : _actorClasses) {
- CharSequence _generateActorClassDoc = this.generateActorClassDoc(root, model, ac);
- _builder.append(_generateActorClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public CharSequence generateActorClassDoc(final Root root, final RoomModel model, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _plus = (_docGenerationTargetPath + "images\\");
- String _name = ac.getName();
- String _plus_1 = (_plus + _name);
- String filename = (_plus_1 + "_structure.jpg");
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String latexFilename = filename.replaceAll("/", "//");
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{2}{");
- String _name_1 = ac.getName();
- _builder.append(_name_1, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- Documentation _docu = ac.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\level{3}{Structure}");
- _builder.newLine();
- _builder.newLine();
- {
- String _fileExists = this.fileExists(filename);
- boolean _equals = _fileExists.equals("true");
- if (_equals) {
- String _name_2 = ac.getName();
- String _plus_2 = (_name_2 + " Structure");
- CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_2);
- _builder.append(_includeGraphics, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\\level{3}{Attributes}");
- _builder.newLine();
- EList<Attribute> _attributes = ac.getAttributes();
- CharSequence _generateAttributesDoc = this.generateAttributesDoc(_attributes);
- _builder.append(_generateAttributesDoc, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\\level{3}{Operations}");
- _builder.newLine();
- EList<StandardOperation> _operations = ac.getOperations();
- CharSequence _generateOperationsDoc = this.generateOperationsDoc(_operations);
- _builder.append(_generateOperationsDoc, "");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
- if (_hasNonEmptyStateMachine) {
- _builder.append("\\level{3}{Statemachine}");
- _builder.newLine();
- CharSequence _generateFsmDoc = this.generateFsmDoc(model, ac);
- _builder.append(_generateFsmDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateFsmDoc(final RoomModel model, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _plus = (_docGenerationTargetPath + "images\\");
- String _name = ac.getName();
- String _plus_1 = (_plus + _name);
- String filename = (_plus_1 + "_behavior.jpg");
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String latexFilename = filename.replaceAll("/", "//");
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{4}{Top Level}");
- _builder.newLine();
- {
- String _fileExists = this.fileExists(filename);
- boolean _equals = _fileExists.equals("true");
- if (_equals) {
- String _name_1 = ac.getName();
- String _plus_2 = (_name_1 + " Top State");
- CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_2);
- _builder.append(_includeGraphics, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\\begin{par}");
- _builder.newLine();
- {
- StateGraph _stateMachine = ac.getStateMachine();
- EList<State> _states = _stateMachine.getStates();
- for(final State s : _states) {
- {
- Documentation _docu = s.getDocu();
- boolean _notEquals = (!Objects.equal(_docu, null));
- if (_notEquals) {
- _builder.append("\\textbf{State description} \\textit{");
- String _statePathName = this.roomExt.getStatePathName(s);
- String _replaceAll_1 = _statePathName.replaceAll("_", "\\\\_");
- _builder.append(_replaceAll_1, "");
- _builder.append("}:");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline");
- _builder.newLine();
- Documentation _docu_1 = s.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu_1);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline\\newline");
- _builder.newLine();
- }
- }
- }
- }
- _builder.newLine();
- {
- StateGraph _stateMachine_1 = ac.getStateMachine();
- EList<ChoicePoint> _chPoints = _stateMachine_1.getChPoints();
- for(final ChoicePoint c : _chPoints) {
- {
- Documentation _docu_2 = c.getDocu();
- boolean _notEquals_1 = (!Objects.equal(_docu_2, null));
- if (_notEquals_1) {
- _builder.append("\\textbf{Choicepoint description} \\textit{");
- String _name_2 = c.getName();
- _builder.append(_name_2, "");
- _builder.append("}:");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline");
- _builder.newLine();
- Documentation _docu_3 = c.getDocu();
- CharSequence _generateDocText_1 = this.generateDocText(_docu_3);
- _builder.append(_generateDocText_1, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline\\newline");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\\end{par}");
- _builder.newLine();
- _builder.newLine();
- {
- StateGraph _stateMachine_2 = ac.getStateMachine();
- EList<State> _states_1 = _stateMachine_2.getStates();
- for(final State s_1 : _states_1) {
- {
- boolean _isLeaf = this.roomExt.isLeaf(s_1);
- boolean _not = (!_isLeaf);
- if (_not) {
- CharSequence _generateStateDoc = this.generateStateDoc(model, ac, s_1);
- _builder.append(_generateStateDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateStateDoc(final RoomModel model, final ActorClass ac, final State state) {
- CharSequence _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _plus = (_docGenerationTargetPath + "images\\");
- String _name = ac.getName();
- String _plus_1 = (_plus + _name);
- String _plus_2 = (_plus_1 + "_");
- String _statePathName = this.roomExt.getStatePathName(state);
- String _plus_3 = (_plus_2 + _statePathName);
- String filename = (_plus_3 + "_behavior.jpg");
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String latexFilename = filename.replaceAll("/", "//");
- String _plus_4 = ("Gen Filename: " + filename);
- this.logger.logInfo(_plus_4);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{4}{Subgraph ");
- String _statePathName_1 = this.roomExt.getStatePathName(state);
- String _replaceAll_1 = _statePathName_1.replaceAll("_", "\\\\_");
- _builder.append(_replaceAll_1, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- {
- String _fileExists = this.fileExists(filename);
- boolean _equals = _fileExists.equals("true");
- if (_equals) {
- String _name_1 = ac.getName();
- String _plus_5 = (_name_1 + "_");
- String _statePathName_2 = this.roomExt.getStatePathName(state);
- String _plus_6 = (_plus_5 + _statePathName_2);
- CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_6);
- _builder.append(_includeGraphics, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\\begin{par}");
- _builder.newLine();
- {
- StateGraph _subgraph = state.getSubgraph();
- EList<State> _states = _subgraph.getStates();
- for(final State s : _states) {
- {
- Documentation _docu = s.getDocu();
- boolean _notEquals = (!Objects.equal(_docu, null));
- if (_notEquals) {
- _builder.append("\\textbf{State description} \\textit{");
- String _statePathName_3 = this.roomExt.getStatePathName(s);
- String _replaceAll_2 = _statePathName_3.replaceAll("_", "\\\\_");
- _builder.append(_replaceAll_2, "");
- _builder.append("}:");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline");
- _builder.newLine();
- Documentation _docu_1 = s.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu_1);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline\\newline");
- _builder.newLine();
- }
- }
- }
- }
- _builder.newLine();
- {
- StateGraph _subgraph_1 = state.getSubgraph();
- EList<ChoicePoint> _chPoints = _subgraph_1.getChPoints();
- for(final ChoicePoint c : _chPoints) {
- {
- Documentation _docu_2 = c.getDocu();
- boolean _notEquals_1 = (!Objects.equal(_docu_2, null));
- if (_notEquals_1) {
- _builder.append("\\textbf{Choicepoint description} \\textit{");
- String _name_2 = c.getName();
- _builder.append(_name_2, "");
- _builder.append("}:");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline");
- _builder.newLine();
- Documentation _docu_3 = c.getDocu();
- CharSequence _generateDocText_1 = this.generateDocText(_docu_3);
- _builder.append(_generateDocText_1, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline\\newline");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\\end{par}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- StateGraph _subgraph_2 = state.getSubgraph();
- EList<State> _states_1 = _subgraph_2.getStates();
- for(final State s_1 : _states_1) {
- {
- boolean _isLeaf = this.roomExt.isLeaf(s_1);
- boolean _not = (!_isLeaf);
- if (_not) {
- CharSequence _generateStateDoc = this.generateStateDoc(model, ac, s_1);
- _builder.append(_generateStateDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateAttributesDoc(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isEmpty = attributes.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- _builder.append("\\begin{tabular}[ht]{|l|l|l|}");
- _builder.newLine();
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("Name & Type & Description\\\\");
- _builder.newLine();
- {
- for(final Attribute at : attributes) {
- _builder.append("\\hline");
- _builder.newLine();
- String _name = at.getName();
- _builder.append(_name, "");
- _builder.append(" & ");
- RefableType _refType = at.getRefType();
- DataType _type = _refType.getType();
- String _name_1 = _type.getName();
- _builder.append(_name_1, "");
- _builder.append(" & ");
- Documentation _docu = at.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\\end{tabular}");
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- public CharSequence generateOperationsDoc(final List<StandardOperation> operations) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final StandardOperation op : operations) {
- _builder.append("\\begin{tabular}[ht]{|l|l|}");
- _builder.newLine();
- _builder.append("\\hline\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Name: & ");
- String _name = op.getName();
- _builder.append(_name, " ");
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ReturnType: & ");
- {
- RefableType _returntype = op.getReturntype();
- boolean _notEquals = (!Objects.equal(_returntype, null));
- if (_notEquals) {
- RefableType _returntype_1 = op.getReturntype();
- DataType _type = _returntype_1.getType();
- String _name_1 = _type.getName();
- _builder.append(_name_1, " ");
- } else {
- _builder.append("void");
- }
- }
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Arguments: & ");
- {
- EList<VarDecl> _arguments = op.getArguments();
- boolean _hasElements = false;
- for(final VarDecl pa : _arguments) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", " ");
- }
- String _name_2 = pa.getName();
- _builder.append(_name_2, " ");
- _builder.append(":");
- RefableType _refType = pa.getRefType();
- DataType _type_1 = _refType.getType();
- String _name_3 = _type_1.getName();
- _builder.append(_name_3, " ");
- }
- }
- _builder.append("\\\\");
- _builder.newLineIfNotEmpty();
- {
- Documentation _docu = op.getDocu();
- boolean _notEquals_1 = (!Objects.equal(_docu, null));
- if (_notEquals_1) {
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- {
- Documentation _docu_1 = op.getDocu();
- String _string = _docu_1.toString();
- int _length = _string.length();
- boolean _greaterThan = (_length > 85);
- if (_greaterThan) {
- _builder.append("\t");
- _builder.append("\\multicolumn{2} {|p{13cm}|} {");
- Documentation _docu_2 = op.getDocu();
- CharSequence _generateDocText = this.generateDocText(_docu_2);
- _builder.append(_generateDocText, " ");
- _builder.append("}\\\\");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("\\multicolumn{2} {|l|} {");
- Documentation _docu_3 = op.getDocu();
- CharSequence _generateDocText_1 = this.generateDocText(_docu_3);
- _builder.append(_generateDocText_1, " ");
- _builder.append("}\\\\");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.append("\\hline");
- _builder.newLine();
- _builder.append("\\end{tabular}");
- _builder.newLine();
- _builder.append("\\newline\\newline\\newline");
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- public CharSequence generateDocText(final Documentation doc) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _notEquals = (!Objects.equal(doc, null));
- if (_notEquals) {
- EList<String> _text = doc.getText();
- String _join = IterableExtensions.join(_text);
- _builder.append(_join, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public String fileExists(final String f) {
- File _file = new File(f);
- final File file = _file;
- final boolean exist = file.exists();
- boolean _equals = (exist == true);
- if (_equals) {
- String _plus = ("File found ! " + f);
- this.logger.logInfo(_plus);
- return "true";
- } else {
- String _plus_1 = ("File not found ! " + f);
- this.logger.logInfo(_plus_1);
- return "false";
- }
- }
-
- public CharSequence includeGraphics(final String filename, final String scale, final String caption) {
- CharSequence _xblockexpression = null;
- {
- String latexCaption = caption.replaceAll("_", "\\\\_");
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\begin{center}");
- _builder.newLine();
- _builder.append("\\includegraphics[scale=");
- _builder.append(scale, "");
- _builder.append("]{");
- _builder.append(filename, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- _builder.append("\\figcaption{");
- _builder.append(latexCaption, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- _builder.append("\\end{center}");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String irgendwas(final Root root, final ActorClass ac) {
- String _name = ac.getName();
- return (_name + ".bla");
- }
-
- public CharSequence generateProtocolClassDoc(final Root root, final GeneralProtocolClass pc) {
- if (pc instanceof CompoundProtocolClass) {
- return _generateProtocolClassDoc(root, (CompoundProtocolClass)pc);
- } else if (pc instanceof ProtocolClass) {
- return _generateProtocolClassDoc(root, (ProtocolClass)pc);
- } else {
- throw new IllegalArgumentException("Unhandled parameter types: " +
- Arrays.<Object>asList(root, pc).toString());
- }
- }
-}
+package org.eclipse.etrice.generator.doc.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ChoicePoint;
+import org.eclipse.etrice.core.room.CompoundProtocolClass;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.Documentation;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.SubProtocol;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class DocGen implements IRoomGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<RoomModel> _models = root.getModels();
+ for (final RoomModel model : _models) {
+ {
+ String path = this.roomExt.getDocGenerationTargetPath(model);
+ String _name = model.getName();
+ String file = (_name + ".tex");
+ String _plus = ("generating LaTeX documentation: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ CharSequence _generateModelDoc = this.generateModelDoc(root, model);
+ this.fileAccess.generateFile(file, _generateModelDoc);
+ }
+ }
+ }
+
+ public CharSequence generateModelDoc(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\documentclass[titlepage]{article}");
+ _builder.newLine();
+ _builder.append("\\usepackage{graphicx}");
+ _builder.newLine();
+ _builder.append("\\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry}");
+ _builder.newLine();
+ _builder.append("\\usepackage{nonfloat}");
+ _builder.newLine();
+ _builder.append("\\parindent 0pt");
+ _builder.newLine();
+ _builder.append("\\makeatletter");
+ _builder.newLine();
+ _builder.append("\\newcommand\\level[1]{%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\ifcase#1\\relax\\expandafter\\chapter\\or");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\expandafter\\section\\or");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\expandafter\\subsection\\or");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\expandafter\\subsubsection\\else");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\def\\next{\\@level{#1}}\\expandafter\\next");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\fi}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\newcommand{\\@level}[1]{%");
+ _builder.newLine();
+ _builder.append("\\@startsection{level#1}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{#1}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{\\z@}%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{-3.25ex\\@plus -1ex \\@minus -.2ex}%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{1.5ex \\@plus .2ex}%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{\\normalfont\\normalsize\\bfseries}}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\newdimen\\@leveldim");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\newdimen\\@dotsdim");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{\\normalfont\\normalsize");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\sbox\\z@{0}\\global\\@leveldim=\\wd\\z@");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\sbox\\z@{.}\\global\\@dotsdim=\\wd\\z@");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("} ");
+ _builder.newLine();
+ _builder.append("\\newcounter{level4}[subsubsection]");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\@namedef{thelevel4}{\\thesubsubsection.\\arabic{level4}}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\@namedef{level4mark}#1{}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\def\\l@section{\\@dottedtocline{1}{0pt}{\\dimexpr\\@leveldim*4+\\@dotsdim*1+6pt\\relax}}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\def\\l@subsection{\\@dottedtocline{2}{0pt}{\\dimexpr\\@leveldim*5+\\@dotsdim*2+6pt\\relax}}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\def\\l@subsubsection{\\@dottedtocline{3}{0pt}{\\dimexpr\\@leveldim*6+\\@dotsdim*3+6pt\\relax}}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\@namedef{l@level4}{\\@dottedtocline{4}{0pt}{\\dimexpr\\@leveldim*7+\\@dotsdim*4+6pt\\relax}}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\count@=4");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\def\\@ncp#1{\\number\\numexpr\\count@+#1\\relax}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\loop\\ifnum\\count@<100");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\begingroup\\edef\\x{\\endgroup");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\noexpand\\newcounter{level\\@ncp{1}}[level\\number\\count@]");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\noexpand\\@namedef{thelevel\\@ncp{1}}{%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\noexpand\\@nameuse{thelevel\\@ncp{0}}.\\noexpand\\arabic{level\\@ncp{0}}}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\noexpand\\@namedef{level\\@ncp{1}mark}####1{}%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\noexpand\\@namedef{l@level\\@ncp{1}}%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("{\\noexpand\\@dottedtocline{\\@ncp{1}}{0pt}{\\the\\dimexpr\\@leveldim*\\@ncp{5}+\\@dotsdim*\\@ncp{0}\\relax}}}%");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\x");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\advance\\count@\\@ne");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\repeat");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\makeatother");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\setcounter{secnumdepth}{100}");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("\\setcounter{tocdepth}{100}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\title{");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(" Modeldocumentation}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\date{\\today}");
+ _builder.newLine();
+ _builder.append("\\author{generated by eTrice}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\begin{document}");
+ _builder.newLine();
+ _builder.append("\\pagestyle{plain}");
+ _builder.newLine();
+ _builder.append("\\maketitle");
+ _builder.newLine();
+ _builder.append("\\tableofcontents");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\newpage");
+ _builder.newLine();
+ _builder.append("\\listoffigures");
+ _builder.newLine();
+ _builder.append("\\newpage");
+ _builder.newLine();
+ _builder.append("\\section{Model Description}");
+ _builder.newLine();
+ Documentation _docu = model.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Subsystem Description}");
+ _builder.newLine();
+ CharSequence _generateAllSubSysClassDocs = this.generateAllSubSysClassDocs(root, model);
+ _builder.append(_generateAllSubSysClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Protocol Class Description}");
+ _builder.newLine();
+ CharSequence _generateAllProtocolClassDocs = this.generateAllProtocolClassDocs(root, model);
+ _builder.append(_generateAllProtocolClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Data Class Description}");
+ _builder.newLine();
+ CharSequence _generateAllDataClassDocs = this.generateAllDataClassDocs(root, model);
+ _builder.append(_generateAllDataClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Actor Class Description}");
+ _builder.newLine();
+ CharSequence _generateAllActorClassDocs = this.generateAllActorClassDocs(root, model);
+ _builder.append(_generateAllActorClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\end{document}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence generateAllSubSysClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<SubSystemClass> _subSystemClasses = model.getSubSystemClasses();
+ for(final SubSystemClass ssc : _subSystemClasses) {
+ CharSequence _generateSubSysClassDoc = this.generateSubSysClassDoc(root, model, ssc);
+ _builder.append(_generateSubSysClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generateSubSysClassDoc(final Root root, final RoomModel model, final SubSystemClass ssc) {
+ CharSequence _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _plus = (_docGenerationTargetPath + "images\\");
+ String _name = ssc.getName();
+ String _plus_1 = (_plus + _name);
+ String filename = (_plus_1 + "_structure.jpg");
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String latexFilename = filename.replaceAll("/", "//");
+ String _docGenerationTargetPath_1 = this.roomExt.getDocGenerationTargetPath(model);
+ String _plus_2 = (_docGenerationTargetPath_1 + "images\\");
+ String _name_1 = ssc.getName();
+ String _plus_3 = (_plus_2 + _name_1);
+ String filenamei = (_plus_3 + "_instanceTree.jpg");
+ String _replaceAll_1 = filenamei.replaceAll("\\\\", "/");
+ filenamei = _replaceAll_1;
+ String latexFilenamei = filenamei.replaceAll("/", "//");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{2}{");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ Documentation _docu = ssc.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\level{3}{Structure}");
+ _builder.newLine();
+ {
+ String _fileExists = this.fileExists(filename);
+ boolean _equals = _fileExists.equals("true");
+ if (_equals) {
+ String _name_3 = ssc.getName();
+ String _plus_4 = (_name_3 + " Structure");
+ CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_4);
+ _builder.append(_includeGraphics, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\\level{3}{Instance Tree}");
+ _builder.newLine();
+ {
+ String _fileExists_1 = this.fileExists(filename);
+ boolean _equals_1 = _fileExists_1.equals("true");
+ if (_equals_1) {
+ String _name_4 = ssc.getName();
+ String _plus_5 = (_name_4 + " Instance Tree");
+ CharSequence _includeGraphics_1 = this.includeGraphics(latexFilenamei, "0.5", _plus_5);
+ _builder.append(_includeGraphics_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence generateAllDataClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<DataClass> _dataClasses = model.getDataClasses();
+ for(final DataClass dc : _dataClasses) {
+ CharSequence _generateDataClassDoc = this.generateDataClassDoc(root, dc);
+ _builder.append(_generateDataClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generateDataClassDoc(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{2} {");
+ String _name = dc.getName();
+ _builder.append(_name, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ Documentation _docu = dc.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\level{3}{Attributes}");
+ _builder.newLine();
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _generateAttributesDoc = this.generateAttributesDoc(_attributes);
+ _builder.append(_generateAttributesDoc, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\\level{3}{Operations}");
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ CharSequence _generateOperationsDoc = this.generateOperationsDoc(_operations);
+ _builder.append(_generateOperationsDoc, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence generateAllProtocolClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<GeneralProtocolClass> _protocolClasses = model.getProtocolClasses();
+ for(final GeneralProtocolClass pc : _protocolClasses) {
+ CharSequence _generateProtocolClassDoc = this.generateProtocolClassDoc(root, pc);
+ _builder.append(_generateProtocolClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ protected CharSequence _generateProtocolClassDoc(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.append("\\level{2} {");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ Documentation _docu = pc.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\\level{3}{Incoming Messages}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\begin{tabular}[ht]{|l|l|l|}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Message & Data & Description\\\\");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message ims : _allIncomingMessages) {
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_1 = ims.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" & ");
+ {
+ VarDecl _data = ims.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = ims.getData();
+ String _name_2 = _data_1.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(" ");
+ }
+ }
+ _builder.append(" & ");
+ Documentation _docu_1 = ims.getDocu();
+ CharSequence _generateDocText_1 = this.generateDocText(_docu_1);
+ _builder.append(_generateDocText_1, " ");
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\end{tabular}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\level{3}{Outgoing Messages}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\begin{tabular}[ht]{|l|l|l|}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Message & Data & Description\\\\");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message oms : _allOutgoingMessages) {
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_3 = oms.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" & ");
+ {
+ VarDecl _data_2 = oms.getData();
+ boolean _notEquals_1 = (!Objects.equal(_data_2, null));
+ if (_notEquals_1) {
+ _builder.append(" ");
+ VarDecl _data_3 = oms.getData();
+ String _name_4 = _data_3.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(" ");
+ }
+ }
+ _builder.append(" & ");
+ Documentation _docu_2 = oms.getDocu();
+ CharSequence _generateDocText_2 = this.generateDocText(_docu_2);
+ _builder.append(_generateDocText_2, " ");
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\\end{tabular}\t\t\t");
+ _builder.newLine();
+ return _builder;
+ }
+
+ protected CharSequence _generateProtocolClassDoc(final Root root, final CompoundProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{2} {");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ Documentation _docu = pc.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\level{3}{Sub Protocols}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\\begin{tabular}[ht]{|l|l|}");
+ _builder.newLine();
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("Name & Protocol\\\\");
+ _builder.newLine();
+ {
+ EList<SubProtocol> _subProtocols = pc.getSubProtocols();
+ for(final SubProtocol sub : _subProtocols) {
+ _builder.append("\\hline");
+ _builder.newLine();
+ String _name_1 = sub.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" & ");
+ GeneralProtocolClass _protocol = sub.getProtocol();
+ String _name_2 = _protocol.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\\end{tabular}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence generateAllActorClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<ActorClass> _actorClasses = model.getActorClasses();
+ for(final ActorClass ac : _actorClasses) {
+ CharSequence _generateActorClassDoc = this.generateActorClassDoc(root, model, ac);
+ _builder.append(_generateActorClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generateActorClassDoc(final Root root, final RoomModel model, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _plus = (_docGenerationTargetPath + "images\\");
+ String _name = ac.getName();
+ String _plus_1 = (_plus + _name);
+ String filename = (_plus_1 + "_structure.jpg");
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String latexFilename = filename.replaceAll("/", "//");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{2}{");
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ Documentation _docu = ac.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\level{3}{Structure}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ String _fileExists = this.fileExists(filename);
+ boolean _equals = _fileExists.equals("true");
+ if (_equals) {
+ String _name_2 = ac.getName();
+ String _plus_2 = (_name_2 + " Structure");
+ CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_2);
+ _builder.append(_includeGraphics, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\\level{3}{Attributes}");
+ _builder.newLine();
+ EList<Attribute> _attributes = ac.getAttributes();
+ CharSequence _generateAttributesDoc = this.generateAttributesDoc(_attributes);
+ _builder.append(_generateAttributesDoc, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\\level{3}{Operations}");
+ _builder.newLine();
+ EList<StandardOperation> _operations = ac.getOperations();
+ CharSequence _generateOperationsDoc = this.generateOperationsDoc(_operations);
+ _builder.append(_generateOperationsDoc, "");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\\level{3}{Statemachine}");
+ _builder.newLine();
+ CharSequence _generateFsmDoc = this.generateFsmDoc(model, ac);
+ _builder.append(_generateFsmDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence generateFsmDoc(final RoomModel model, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _plus = (_docGenerationTargetPath + "images\\");
+ String _name = ac.getName();
+ String _plus_1 = (_plus + _name);
+ String filename = (_plus_1 + "_behavior.jpg");
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String latexFilename = filename.replaceAll("/", "//");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{4}{Top Level}");
+ _builder.newLine();
+ {
+ String _fileExists = this.fileExists(filename);
+ boolean _equals = _fileExists.equals("true");
+ if (_equals) {
+ String _name_1 = ac.getName();
+ String _plus_2 = (_name_1 + " Top State");
+ CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_2);
+ _builder.append(_includeGraphics, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\\begin{par}");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = ac.getStateMachine();
+ EList<State> _states = _stateMachine.getStates();
+ for(final State s : _states) {
+ {
+ Documentation _docu = s.getDocu();
+ boolean _notEquals = (!Objects.equal(_docu, null));
+ if (_notEquals) {
+ _builder.append("\\textbf{State description} \\textit{");
+ String _statePathName = this.roomExt.getStatePathName(s);
+ String _replaceAll_1 = _statePathName.replaceAll("_", "\\\\_");
+ _builder.append(_replaceAll_1, "");
+ _builder.append("}:");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline");
+ _builder.newLine();
+ Documentation _docu_1 = s.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu_1);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline\\newline");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = ac.getStateMachine();
+ EList<ChoicePoint> _chPoints = _stateMachine_1.getChPoints();
+ for(final ChoicePoint c : _chPoints) {
+ {
+ Documentation _docu_2 = c.getDocu();
+ boolean _notEquals_1 = (!Objects.equal(_docu_2, null));
+ if (_notEquals_1) {
+ _builder.append("\\textbf{Choicepoint description} \\textit{");
+ String _name_2 = c.getName();
+ _builder.append(_name_2, "");
+ _builder.append("}:");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline");
+ _builder.newLine();
+ Documentation _docu_3 = c.getDocu();
+ CharSequence _generateDocText_1 = this.generateDocText(_docu_3);
+ _builder.append(_generateDocText_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline\\newline");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\\end{par}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_2 = ac.getStateMachine();
+ EList<State> _states_1 = _stateMachine_2.getStates();
+ for(final State s_1 : _states_1) {
+ {
+ boolean _isLeaf = this.roomExt.isLeaf(s_1);
+ boolean _not = (!_isLeaf);
+ if (_not) {
+ CharSequence _generateStateDoc = this.generateStateDoc(model, ac, s_1);
+ _builder.append(_generateStateDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence generateStateDoc(final RoomModel model, final ActorClass ac, final State state) {
+ CharSequence _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _plus = (_docGenerationTargetPath + "images\\");
+ String _name = ac.getName();
+ String _plus_1 = (_plus + _name);
+ String _plus_2 = (_plus_1 + "_");
+ String _statePathName = this.roomExt.getStatePathName(state);
+ String _plus_3 = (_plus_2 + _statePathName);
+ String filename = (_plus_3 + "_behavior.jpg");
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String latexFilename = filename.replaceAll("/", "//");
+ String _plus_4 = ("Gen Filename: " + filename);
+ this.logger.logInfo(_plus_4);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{4}{Subgraph ");
+ String _statePathName_1 = this.roomExt.getStatePathName(state);
+ String _replaceAll_1 = _statePathName_1.replaceAll("_", "\\\\_");
+ _builder.append(_replaceAll_1, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ {
+ String _fileExists = this.fileExists(filename);
+ boolean _equals = _fileExists.equals("true");
+ if (_equals) {
+ String _name_1 = ac.getName();
+ String _plus_5 = (_name_1 + "_");
+ String _statePathName_2 = this.roomExt.getStatePathName(state);
+ String _plus_6 = (_plus_5 + _statePathName_2);
+ CharSequence _includeGraphics = this.includeGraphics(latexFilename, "0.4", _plus_6);
+ _builder.append(_includeGraphics, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\\begin{par}");
+ _builder.newLine();
+ {
+ StateGraph _subgraph = state.getSubgraph();
+ EList<State> _states = _subgraph.getStates();
+ for(final State s : _states) {
+ {
+ Documentation _docu = s.getDocu();
+ boolean _notEquals = (!Objects.equal(_docu, null));
+ if (_notEquals) {
+ _builder.append("\\textbf{State description} \\textit{");
+ String _statePathName_3 = this.roomExt.getStatePathName(s);
+ String _replaceAll_2 = _statePathName_3.replaceAll("_", "\\\\_");
+ _builder.append(_replaceAll_2, "");
+ _builder.append("}:");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline");
+ _builder.newLine();
+ Documentation _docu_1 = s.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu_1);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline\\newline");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ {
+ StateGraph _subgraph_1 = state.getSubgraph();
+ EList<ChoicePoint> _chPoints = _subgraph_1.getChPoints();
+ for(final ChoicePoint c : _chPoints) {
+ {
+ Documentation _docu_2 = c.getDocu();
+ boolean _notEquals_1 = (!Objects.equal(_docu_2, null));
+ if (_notEquals_1) {
+ _builder.append("\\textbf{Choicepoint description} \\textit{");
+ String _name_2 = c.getName();
+ _builder.append(_name_2, "");
+ _builder.append("}:");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline");
+ _builder.newLine();
+ Documentation _docu_3 = c.getDocu();
+ CharSequence _generateDocText_1 = this.generateDocText(_docu_3);
+ _builder.append(_generateDocText_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline\\newline");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\\end{par}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ StateGraph _subgraph_2 = state.getSubgraph();
+ EList<State> _states_1 = _subgraph_2.getStates();
+ for(final State s_1 : _states_1) {
+ {
+ boolean _isLeaf = this.roomExt.isLeaf(s_1);
+ boolean _not = (!_isLeaf);
+ if (_not) {
+ CharSequence _generateStateDoc = this.generateStateDoc(model, ac, s_1);
+ _builder.append(_generateStateDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence generateAttributesDoc(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = attributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("\\begin{tabular}[ht]{|l|l|l|}");
+ _builder.newLine();
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("Name & Type & Description\\\\");
+ _builder.newLine();
+ {
+ for(final Attribute at : attributes) {
+ _builder.append("\\hline");
+ _builder.newLine();
+ String _name = at.getName();
+ _builder.append(_name, "");
+ _builder.append(" & ");
+ RefableType _refType = at.getRefType();
+ DataType _type = _refType.getType();
+ String _name_1 = _type.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" & ");
+ Documentation _docu = at.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\\end{tabular}");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generateOperationsDoc(final List<StandardOperation> operations) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final StandardOperation op : operations) {
+ _builder.append("\\begin{tabular}[ht]{|l|l|}");
+ _builder.newLine();
+ _builder.append("\\hline\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Name: & ");
+ String _name = op.getName();
+ _builder.append(_name, " ");
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ReturnType: & ");
+ {
+ RefableType _returntype = op.getReturntype();
+ boolean _notEquals = (!Objects.equal(_returntype, null));
+ if (_notEquals) {
+ RefableType _returntype_1 = op.getReturntype();
+ DataType _type = _returntype_1.getType();
+ String _name_1 = _type.getName();
+ _builder.append(_name_1, " ");
+ } else {
+ _builder.append("void");
+ }
+ }
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Arguments: & ");
+ {
+ EList<VarDecl> _arguments = op.getArguments();
+ boolean _hasElements = false;
+ for(final VarDecl pa : _arguments) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", " ");
+ }
+ String _name_2 = pa.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(":");
+ RefableType _refType = pa.getRefType();
+ DataType _type_1 = _refType.getType();
+ String _name_3 = _type_1.getName();
+ _builder.append(_name_3, " ");
+ }
+ }
+ _builder.append("\\\\");
+ _builder.newLineIfNotEmpty();
+ {
+ Documentation _docu = op.getDocu();
+ boolean _notEquals_1 = (!Objects.equal(_docu, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ {
+ Documentation _docu_1 = op.getDocu();
+ String _string = _docu_1.toString();
+ int _length = _string.length();
+ boolean _greaterThan = (_length > 85);
+ if (_greaterThan) {
+ _builder.append("\t");
+ _builder.append("\\multicolumn{2} {|p{13cm}|} {");
+ Documentation _docu_2 = op.getDocu();
+ CharSequence _generateDocText = this.generateDocText(_docu_2);
+ _builder.append(_generateDocText, " ");
+ _builder.append("}\\\\");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("\\multicolumn{2} {|l|} {");
+ Documentation _docu_3 = op.getDocu();
+ CharSequence _generateDocText_1 = this.generateDocText(_docu_3);
+ _builder.append(_generateDocText_1, " ");
+ _builder.append("}\\\\");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\\hline");
+ _builder.newLine();
+ _builder.append("\\end{tabular}");
+ _builder.newLine();
+ _builder.append("\\newline\\newline\\newline");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generateDocText(final Documentation doc) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _notEquals = (!Objects.equal(doc, null));
+ if (_notEquals) {
+ EList<String> _text = doc.getText();
+ String _join = IterableExtensions.join(_text);
+ _builder.append(_join, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public String fileExists(final String f) {
+ File _file = new File(f);
+ final File file = _file;
+ final boolean exist = file.exists();
+ boolean _equals = (exist == true);
+ if (_equals) {
+ String _plus = ("File found ! " + f);
+ this.logger.logInfo(_plus);
+ return "true";
+ } else {
+ String _plus_1 = ("File not found ! " + f);
+ this.logger.logInfo(_plus_1);
+ return "false";
+ }
+ }
+
+ public CharSequence includeGraphics(final String filename, final String scale, final String caption) {
+ CharSequence _xblockexpression = null;
+ {
+ String latexCaption = caption.replaceAll("_", "\\\\_");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\begin{center}");
+ _builder.newLine();
+ _builder.append("\\includegraphics[scale=");
+ _builder.append(scale, "");
+ _builder.append("]{");
+ _builder.append(filename, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\figcaption{");
+ _builder.append(latexCaption, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\end{center}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public String irgendwas(final Root root, final ActorClass ac) {
+ String _name = ac.getName();
+ return (_name + ".bla");
+ }
+
+ public CharSequence generateProtocolClassDoc(final Root root, final GeneralProtocolClass pc) {
+ if (pc instanceof CompoundProtocolClass) {
+ return _generateProtocolClassDoc(root, (CompoundProtocolClass)pc);
+ } else if (pc instanceof ProtocolClass) {
+ return _generateProtocolClassDoc(root, (ProtocolClass)pc);
+ } else {
+ throw new IllegalArgumentException("Unhandled parameter types: " +
+ Arrays.<Object>asList(root, pc).toString());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
index fd37ab880..105573221 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
@@ -1,173 +1,173 @@
-package org.eclipse.etrice.generator.doc.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.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.IRoomGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Exceptions;
-
-@Singleton
-@SuppressWarnings("all")
-public class InstanceDiagramGen implements IRoomGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<RoomModel> _models = root.getModels();
- for (final RoomModel model : _models) {
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String path = (_docGenerationTargetPath + "/images");
- this.fileAccess.setOutputPath(path);
- String file2 = "dot2jpg.bat";
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- String _name = sc.getName();
- String file = (_name + "_instanceTree.dot");
- String _plus = ("generating LaTeX documentation: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- CharSequence _generate = this.generate(root, sc, _subSystemClass);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- CharSequence _generate2jpg = this.generate2jpg(root);
- this.fileAccess.generateFile(file2, _generate2jpg);
- this.runDot2Jpg();
- }
- }
- }
-
- public CharSequence generate2jpg(final Root root) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for(final SubSystemInstance sc : _subSystemInstances) {
- _builder.append("dot -Tjpg -o ");
- String _name = sc.getName();
- _builder.append(_name, "");
- _builder.append("_instanceTree.jpg ");
- String _name_1 = sc.getName();
- _builder.append(_name_1, "");
- _builder.append("_instanceTree.dot");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public CharSequence generate(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("digraph ");
- String _name = ssi.getName();
- _builder.append(_name, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("rankdir=LR;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("node [shape=box];");
- _builder.newLine();
- _builder.append("\t");
- String _path = ssi.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- _builder.append(_pathName, " ");
- _builder.append(" [label=\"");
- String _name_1 = ssc.getName();
- _builder.append(_name_1, " ");
- _builder.append("\\n(");
- String _name_2 = ssi.getName();
- _builder.append(_name_2, " ");
- _builder.append(")\" style=filled color=yellow];");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _instances = ssi.getInstances();
- for(final ActorInstance ai : _instances) {
- _builder.append("\t");
- CharSequence _instance = this.instance(ai);
- _builder.append(_instance, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence instance(final ActorInstance ai) {
- StringConcatenation _builder = new StringConcatenation();
- EObject _eContainer = ai.eContainer();
- StructureInstance parent = ((StructureInstance) _eContainer);
- _builder.newLineIfNotEmpty();
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- _builder.append(_pathName, "");
- _builder.append(" [label=\"");
- String _name = ai.getName();
- _builder.append(_name, "");
- _builder.append("\\n(");
- ActorClass _actorClass = ai.getActorClass();
- String _name_1 = _actorClass.getName();
- _builder.append(_name_1, "");
- _builder.append(")\"];");
- _builder.newLineIfNotEmpty();
- String _path_1 = parent.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName_1, "");
- _builder.append(" -> ");
- String _path_2 = ai.getPath();
- String _pathName_2 = this.roomExt.getPathName(_path_2);
- _builder.append(_pathName_2, "");
- _builder.append("; ");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _instances = ai.getInstances();
- for(final ActorInstance sub_ai : _instances) {
- CharSequence _instance = this.instance(sub_ai);
- _builder.append(_instance, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public Process runDot2Jpg() {
- Process _xtrycatchfinallyexpression = null;
- try {
- Runtime _runtime = Runtime.getRuntime();
- Process _exec = _runtime.exec("dot2jpg.bat");
- _xtrycatchfinallyexpression = _exec;
- } catch (final Throwable _t) {
- if (_t instanceof Exception) {
- final Exception e = (Exception)_t;
- e.printStackTrace();
- } else {
- throw Exceptions.sneakyThrow(_t);
- }
- }
- return _xtrycatchfinallyexpression;
- }
-}
+package org.eclipse.etrice.generator.doc.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.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+
+@Singleton
+@SuppressWarnings("all")
+public class InstanceDiagramGen implements IRoomGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<RoomModel> _models = root.getModels();
+ for (final RoomModel model : _models) {
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String path = (_docGenerationTargetPath + "/images");
+ this.fileAccess.setOutputPath(path);
+ String file2 = "dot2jpg.bat";
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ String _name = sc.getName();
+ String file = (_name + "_instanceTree.dot");
+ String _plus = ("generating LaTeX documentation: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ CharSequence _generate = this.generate(root, sc, _subSystemClass);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ CharSequence _generate2jpg = this.generate2jpg(root);
+ this.fileAccess.generateFile(file2, _generate2jpg);
+ this.runDot2Jpg();
+ }
+ }
+ }
+
+ public CharSequence generate2jpg(final Root root) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for(final SubSystemInstance sc : _subSystemInstances) {
+ _builder.append("dot -Tjpg -o ");
+ String _name = sc.getName();
+ _builder.append(_name, "");
+ _builder.append("_instanceTree.jpg ");
+ String _name_1 = sc.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_instanceTree.dot");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generate(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("digraph ");
+ String _name = ssi.getName();
+ _builder.append(_name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("rankdir=LR;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("node [shape=box];");
+ _builder.newLine();
+ _builder.append("\t");
+ String _path = ssi.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, " ");
+ _builder.append(" [label=\"");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\\n(");
+ String _name_2 = ssi.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(")\" style=filled color=yellow];");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _instances = ssi.getInstances();
+ for(final ActorInstance ai : _instances) {
+ _builder.append("\t");
+ CharSequence _instance = this.instance(ai);
+ _builder.append(_instance, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence instance(final ActorInstance ai) {
+ StringConcatenation _builder = new StringConcatenation();
+ EObject _eContainer = ai.eContainer();
+ StructureInstance parent = ((StructureInstance) _eContainer);
+ _builder.newLineIfNotEmpty();
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(" [label=\"");
+ String _name = ai.getName();
+ _builder.append(_name, "");
+ _builder.append("\\n(");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_1 = _actorClass.getName();
+ _builder.append(_name_1, "");
+ _builder.append(")\"];");
+ _builder.newLineIfNotEmpty();
+ String _path_1 = parent.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(" -> ");
+ String _path_2 = ai.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append("; ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _instances = ai.getInstances();
+ for(final ActorInstance sub_ai : _instances) {
+ CharSequence _instance = this.instance(sub_ai);
+ _builder.append(_instance, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public Process runDot2Jpg() {
+ Process _xtrycatchfinallyexpression = null;
+ try {
+ Runtime _runtime = Runtime.getRuntime();
+ Process _exec = _runtime.exec("dot2jpg.bat");
+ _xtrycatchfinallyexpression = _exec;
+ } catch (final Throwable _t) {
+ if (_t instanceof Exception) {
+ final Exception e = (Exception)_t;
+ e.printStackTrace();
+ } else {
+ throw Exceptions.sneakyThrow(_t);
+ }
+ }
+ return _xtrycatchfinallyexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
index 28eaa6ec8..386caf0d2 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
@@ -1,41 +1,41 @@
-package org.eclipse.etrice.generator.doc.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.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.generator.doc.gen.DocGen;
-import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
-import org.eclipse.etrice.generator.generic.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@Singleton
-@SuppressWarnings("all")
-public class MainGen implements IGenerator {
- @Inject
- private InstanceDiagramGen instanceDiagramGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- @Inject
- private DocGen docGen;
-
- 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.instanceDiagramGen.doGenerate(e);
- this.docGen.doGenerate(e);
- }
-}
+package org.eclipse.etrice.generator.doc.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.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.doc.gen.DocGen;
+import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@Singleton
+@SuppressWarnings("all")
+public class MainGen implements IGenerator {
+ @Inject
+ private InstanceDiagramGen instanceDiagramGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ @Inject
+ private DocGen docGen;
+
+ 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.instanceDiagramGen.doGenerate(e);
+ this.docGen.doGenerate(e);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/.FSMtestGenerator.java._trace b/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/.FSMtestGenerator.java._trace
index bd4df5225..3804e4237 100644
--- a/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/.FSMtestGenerator.java._trace
+++ b/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/.FSMtestGenerator.java._trace
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/FSMtestGenerator.java b/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/FSMtestGenerator.java
index 85ec4254a..2e0d9715a 100644
--- a/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/FSMtestGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.fsmtest/xtend-gen/org/eclipse/etrice/generator/generator/FSMtestGenerator.java
@@ -1,11 +1,11 @@
-package org.eclipse.etrice.generator.generator;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@SuppressWarnings("all")
-public class FSMtestGenerator implements IGenerator {
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- }
-}
+package org.eclipse.etrice.generator.generator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@SuppressWarnings("all")
+public class FSMtestGenerator implements IGenerator {
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index 3671821ee..1f934316f 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -1,592 +1,592 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-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.RoomModel;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.etrice.generator.java.gen.StateMachineGen;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class ActorClassGen extends GenericActorClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions _javaExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @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._roomExtensions.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this._roomExtensions.getPath(_actorClass_1);
- String path = (_generationTargetPath + _path);
- ActorClass _actorClass_2 = xpac.getActorClass();
- String file = this._javaExtensions.getJavaFileName(_actorClass_2);
- String _plus = ("generating ActorClass implementation \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- CharSequence _generate = this.generate(root, xpac, _actorClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public CharSequence generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return Boolean.valueOf(_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
- EList<StandardOperation> _operations_1 = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return Boolean.valueOf(_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this._roomExtensions.getPackage(ac);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
- _builder.newLine();
- _builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;");
- _builder.newLine();
- _builder.newLine();
- {
- EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
- for(final RoomModel model : _referencedModels) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("import ");
- String _package_1 = this._roomExtensions.getPackage(pc);
- _builder.append(_package_1, "");
- _builder.append(".");
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("public ");
- {
- boolean _isAbstract = ac.isAbstract();
- if (_isAbstract) {
- _builder.append("abstract ");
- }
- }
- _builder.append("class ");
- String _name_2 = ac.getName();
- _builder.append(_name_2, "");
- _builder.append(" extends ");
- {
- ActorClass _base = ac.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- ActorClass _base_1 = ac.getBase();
- String _name_3 = _base_1.getName();
- _builder.append(_name_3, "");
- } else {
- _builder.append("ActorClassBase");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- ports");
- _builder.newLine();
- {
- List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
- for(final Port ep : _endPorts) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName = this._roomExtensions.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_4 = ep.getName();
- _builder.append(_name_4, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- for(final SAPRef sap : _strSAPs) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_1 = this._roomExtensions.getPortClassName(sap);
- _builder.append(_portClassName_1, " ");
- _builder.append(" ");
- String _name_5 = sap.getName();
- _builder.append(_name_5, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- services");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- for(final ServiceImplementation svc : _serviceImplementations) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_2 = this._roomExtensions.getPortClassName(svc);
- _builder.append(_portClassName_2, " ");
- _builder.append(" ");
- SPPRef _spp = svc.getSpp();
- String _name_6 = _spp.getName();
- _builder.append(_name_6, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- interface item IDs");
- _builder.newLine();
- _builder.append("\t");
- String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
- _builder.append(_genInterfaceItemConstants, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = ac.getAttributes();
- CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- construction");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_7 = ac.getName();
- _builder.append(_name_7, " ");
- _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
- _builder.newLineIfNotEmpty();
- {
- ActorClass _base_2 = ac.getBase();
- boolean _equals = Objects.equal(_base_2, null);
- if (_equals) {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr, peer_addr);");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("setClassName(\"");
- String _name_8 = ac.getName();
- _builder.append(_name_8, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_2 = ac.getAttributes();
- CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes_2, false);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own ports");
- _builder.newLine();
- {
- List<Port> _endPorts_1 = this._roomExtensions.getEndPorts(ac);
- for(final Port ep_1 : _endPorts_1) {
- _builder.append("\t\t");
- String _name_9 = ep_1.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = new ");
- String _portClassName_3 = this._roomExtensions.getPortClassName(ep_1);
- _builder.append(_portClassName_3, " ");
- _builder.append("(this, \"");
- String _name_10 = ep_1.getName();
- _builder.append(_name_10, " ");
- _builder.append("\", IFITEM_");
- String _name_11 = ep_1.getName();
- _builder.append(_name_11, " ");
- _builder.append(", ");
- {
- int _multiplicity = ep_1.getMultiplicity();
- boolean _equals_1 = (_multiplicity == 1);
- if (_equals_1) {
- _builder.append("0, ");
- }
- }
- _builder.append("port_addr[IFITEM_");
- String _name_12 = ep_1.getName();
- _builder.append(_name_12, " ");
- _builder.append("]");
- {
- int _multiplicity_1 = ep_1.getMultiplicity();
- boolean _equals_2 = (_multiplicity_1 == 1);
- if (_equals_2) {
- _builder.append("[0]");
- }
- }
- _builder.append(", peer_addr[IFITEM_");
- String _name_13 = ep_1.getName();
- _builder.append(_name_13, " ");
- _builder.append("]");
- {
- int _multiplicity_2 = ep_1.getMultiplicity();
- boolean _equals_3 = (_multiplicity_2 == 1);
- if (_equals_3) {
- _builder.append("[0]");
- }
- }
- _builder.append("); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap_1 : _strSAPs_1) {
- _builder.append("\t\t");
- String _name_14 = sap_1.getName();
- _builder.append(_name_14, " ");
- _builder.append(" = new ");
- String _portClassName_4 = this._roomExtensions.getPortClassName(sap_1);
- _builder.append(_portClassName_4, " ");
- _builder.append("(this, \"");
- String _name_15 = sap_1.getName();
- _builder.append(_name_15, " ");
- _builder.append("\", IFITEM_");
- String _name_16 = sap_1.getName();
- _builder.append(_name_16, " ");
- _builder.append(", 0, port_addr[IFITEM_");
- String _name_17 = sap_1.getName();
- _builder.append(_name_17, " ");
- _builder.append("][0], peer_addr[IFITEM_");
- String _name_18 = sap_1.getName();
- _builder.append(_name_18, " ");
- _builder.append("][0]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own service implementations");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
- _builder.append("\t\t");
- SPPRef _spp_1 = svc_1.getSpp();
- String _name_19 = _spp_1.getName();
- _builder.append(_name_19, " ");
- _builder.append(" = new ");
- String _portClassName_5 = this._roomExtensions.getPortClassName(svc_1);
- _builder.append(_portClassName_5, " ");
- _builder.append("(this, \"");
- SPPRef _spp_2 = svc_1.getSpp();
- String _name_20 = _spp_2.getName();
- _builder.append(_name_20, " ");
- _builder.append("\", IFITEM_");
- SPPRef _spp_3 = svc_1.getSpp();
- String _name_21 = _spp_3.getName();
- _builder.append(_name_21, " ");
- _builder.append(", port_addr[IFITEM_");
- SPPRef _spp_4 = svc_1.getSpp();
- String _name_22 = _spp_4.getName();
- _builder.append(_name_22, " ");
- _builder.append("], peer_addr[IFITEM_");
- SPPRef _spp_5 = svc_1.getSpp();
- String _name_23 = _spp_5.getName();
- _builder.append(_name_23, " ");
- _builder.append("]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- boolean _notEquals_1 = (!Objects.equal(ctor, null));
- if (_notEquals_1) {
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- AbstractGenerator _instance = AbstractGenerator.getInstance();
- DetailCode _detailCode = ctor.getDetailCode();
- String _translatedCode = _instance.getTranslatedCode(_detailCode);
- _builder.append(_translatedCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_3 = ac.getAttributes();
- String _name_24 = ac.getName();
- CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_3, _name_24);
- _builder.append(_attributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("//--------------------- port getters");
- _builder.newLine();
- {
- List<Port> _endPorts_2 = this._roomExtensions.getEndPorts(ac);
- for(final Port ep_2 : _endPorts_2) {
- _builder.append("\t");
- String _portClassName_6 = this._roomExtensions.getPortClassName(ep_2);
- String _name_25 = ep_2.getName();
- String _name_26 = ac.getName();
- CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_25, _name_26);
- _builder.append(_terImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
- for(final SAPRef sap_2 : _strSAPs_2) {
- _builder.append("\t");
- String _portClassName_7 = this._roomExtensions.getPortClassName(sap_2);
- String _name_27 = sap_2.getName();
- String _name_28 = ac.getName();
- CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_27, _name_28);
- _builder.append(_terImplementation_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
- _builder.append("\t");
- String _portClassName_8 = this._roomExtensions.getPortClassName(svc_2);
- SPPRef _spp_6 = svc_2.getSpp();
- String _name_29 = _spp_6.getName();
- String _name_30 = ac.getName();
- CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_29, _name_30);
- _builder.append(_terImplementation_2, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- lifecycle functions");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void init(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("initUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void start(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("startUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _overridesStop = this._roomExtensions.overridesStop(ac);
- boolean _not = (!_overridesStop);
- if (_not) {
- _builder.append("\t");
- _builder.append("public void stop(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("stopUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void destroy(){");
- _builder.newLine();
- {
- boolean _notEquals_2 = (!Objects.equal(dtor, null));
- if (_notEquals_2) {
- _builder.append("\t\t");
- String _name_31 = ac.getName();
- String _destructorCall = this._procedureHelpers.destructorCall(_name_31);
- _builder.append(_destructorCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
- if (_hasNonEmptyStateMachine) {
- _builder.append("\t");
- CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
- _builder.append(_genStateMachine, " ");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _not_1 = (!_hasStateMachine);
- if (_not_1) {
- _builder.append("\t");
- _builder.append("//--------------------- no state machine");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("handleSystemEvent(ifitem, evt, data);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void executeInitTransition(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+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.RoomModel;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.etrice.generator.java.gen.StateMachineGen;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @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._roomExtensions.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this._roomExtensions.getPath(_actorClass_1);
+ String path = (_generationTargetPath + _path);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String file = this._javaExtensions.getJavaFileName(_actorClass_2);
+ String _plus = ("generating ActorClass implementation \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ CharSequence _generate = this.generate(root, xpac, _actorClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ EList<StandardOperation> _operations_1 = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(ac);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
+ _builder.newLine();
+ _builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
+ for(final RoomModel model : _referencedModels) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("import ");
+ String _package_1 = this._roomExtensions.getPackage(pc);
+ _builder.append(_package_1, "");
+ _builder.append(".");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public ");
+ {
+ boolean _isAbstract = ac.isAbstract();
+ if (_isAbstract) {
+ _builder.append("abstract ");
+ }
+ }
+ _builder.append("class ");
+ String _name_2 = ac.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" extends ");
+ {
+ ActorClass _base = ac.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ ActorClass _base_1 = ac.getBase();
+ String _name_3 = _base_1.getName();
+ _builder.append(_name_3, "");
+ } else {
+ _builder.append("ActorClassBase");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
+ for(final Port ep : _endPorts) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName = this._roomExtensions.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_4 = ep.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ for(final SAPRef sap : _strSAPs) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName_1 = this._roomExtensions.getPortClassName(sap);
+ _builder.append(_portClassName_1, " ");
+ _builder.append(" ");
+ String _name_5 = sap.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- services");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ for(final ServiceImplementation svc : _serviceImplementations) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName_2 = this._roomExtensions.getPortClassName(svc);
+ _builder.append(_portClassName_2, " ");
+ _builder.append(" ");
+ SPPRef _spp = svc.getSpp();
+ String _name_6 = _spp.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- interface item IDs");
+ _builder.newLine();
+ _builder.append("\t");
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- construction");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_7 = ac.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
+ _builder.newLineIfNotEmpty();
+ {
+ ActorClass _base_2 = ac.getBase();
+ boolean _equals = Objects.equal(_base_2, null);
+ if (_equals) {
+ _builder.append("\t\t");
+ _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("super(parent, name, port_addr, peer_addr);");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("setClassName(\"");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<Attribute> _attributes_2 = ac.getAttributes();
+ CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes_2, false);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_1 = this._roomExtensions.getEndPorts(ac);
+ for(final Port ep_1 : _endPorts_1) {
+ _builder.append("\t\t");
+ String _name_9 = ep_1.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" = new ");
+ String _portClassName_3 = this._roomExtensions.getPortClassName(ep_1);
+ _builder.append(_portClassName_3, " ");
+ _builder.append("(this, \"");
+ String _name_10 = ep_1.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("\", IFITEM_");
+ String _name_11 = ep_1.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(", ");
+ {
+ int _multiplicity = ep_1.getMultiplicity();
+ boolean _equals_1 = (_multiplicity == 1);
+ if (_equals_1) {
+ _builder.append("0, ");
+ }
+ }
+ _builder.append("port_addr[IFITEM_");
+ String _name_12 = ep_1.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _equals_2 = (_multiplicity_1 == 1);
+ if (_equals_2) {
+ _builder.append("[0]");
+ }
+ }
+ _builder.append(", peer_addr[IFITEM_");
+ String _name_13 = ep_1.getName();
+ _builder.append(_name_13, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_2 = ep_1.getMultiplicity();
+ boolean _equals_3 = (_multiplicity_2 == 1);
+ if (_equals_3) {
+ _builder.append("[0]");
+ }
+ }
+ _builder.append("); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
+ for(final SAPRef sap_1 : _strSAPs_1) {
+ _builder.append("\t\t");
+ String _name_14 = sap_1.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(" = new ");
+ String _portClassName_4 = this._roomExtensions.getPortClassName(sap_1);
+ _builder.append(_portClassName_4, " ");
+ _builder.append("(this, \"");
+ String _name_15 = sap_1.getName();
+ _builder.append(_name_15, " ");
+ _builder.append("\", IFITEM_");
+ String _name_16 = sap_1.getName();
+ _builder.append(_name_16, " ");
+ _builder.append(", 0, port_addr[IFITEM_");
+ String _name_17 = sap_1.getName();
+ _builder.append(_name_17, " ");
+ _builder.append("][0], peer_addr[IFITEM_");
+ String _name_18 = sap_1.getName();
+ _builder.append(_name_18, " ");
+ _builder.append("][0]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own service implementations");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
+ _builder.append("\t\t");
+ SPPRef _spp_1 = svc_1.getSpp();
+ String _name_19 = _spp_1.getName();
+ _builder.append(_name_19, " ");
+ _builder.append(" = new ");
+ String _portClassName_5 = this._roomExtensions.getPortClassName(svc_1);
+ _builder.append(_portClassName_5, " ");
+ _builder.append("(this, \"");
+ SPPRef _spp_2 = svc_1.getSpp();
+ String _name_20 = _spp_2.getName();
+ _builder.append(_name_20, " ");
+ _builder.append("\", IFITEM_");
+ SPPRef _spp_3 = svc_1.getSpp();
+ String _name_21 = _spp_3.getName();
+ _builder.append(_name_21, " ");
+ _builder.append(", port_addr[IFITEM_");
+ SPPRef _spp_4 = svc_1.getSpp();
+ String _name_22 = _spp_4.getName();
+ _builder.append(_name_22, " ");
+ _builder.append("], peer_addr[IFITEM_");
+ SPPRef _spp_5 = svc_1.getSpp();
+ String _name_23 = _spp_5.getName();
+ _builder.append(_name_23, " ");
+ _builder.append("]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ boolean _notEquals_1 = (!Objects.equal(ctor, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// user defined constructor body");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ DetailCode _detailCode = ctor.getDetailCode();
+ String _translatedCode = _instance.getTranslatedCode(_detailCode);
+ _builder.append(_translatedCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_3 = ac.getAttributes();
+ String _name_24 = ac.getName();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_3, _name_24);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("//--------------------- port getters");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_2 = this._roomExtensions.getEndPorts(ac);
+ for(final Port ep_2 : _endPorts_2) {
+ _builder.append("\t");
+ String _portClassName_6 = this._roomExtensions.getPortClassName(ep_2);
+ String _name_25 = ep_2.getName();
+ String _name_26 = ac.getName();
+ CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_25, _name_26);
+ _builder.append(_terImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
+ for(final SAPRef sap_2 : _strSAPs_2) {
+ _builder.append("\t");
+ String _portClassName_7 = this._roomExtensions.getPortClassName(sap_2);
+ String _name_27 = sap_2.getName();
+ String _name_28 = ac.getName();
+ CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_27, _name_28);
+ _builder.append(_terImplementation_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
+ _builder.append("\t");
+ String _portClassName_8 = this._roomExtensions.getPortClassName(svc_2);
+ SPPRef _spp_6 = svc_2.getSpp();
+ String _name_29 = _spp_6.getName();
+ String _name_30 = ac.getName();
+ CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_29, _name_30);
+ _builder.append(_terImplementation_2, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- lifecycle functions");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void init(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("initUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void start(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("startUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _overridesStop = this._roomExtensions.overridesStop(ac);
+ boolean _not = (!_overridesStop);
+ if (_not) {
+ _builder.append("\t");
+ _builder.append("public void stop(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("stopUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void destroy(){");
+ _builder.newLine();
+ {
+ boolean _notEquals_2 = (!Objects.equal(dtor, null));
+ if (_notEquals_2) {
+ _builder.append("\t\t");
+ String _name_31 = ac.getName();
+ String _destructorCall = this._procedureHelpers.destructorCall(_name_31);
+ _builder.append(_destructorCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\t");
+ CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
+ _builder.append(_genStateMachine, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _hasStateMachine = xpac.hasStateMachine();
+ boolean _not_1 = (!_hasStateMachine);
+ if (_not_1) {
+ _builder.append("\t");
+ _builder.append("//--------------------- no state machine");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("handleSystemEvent(ifitem, evt, data);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void executeInitTransition(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
index a187baa53..5105f319a 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -1,460 +1,460 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ComplexType;
-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.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions _javaExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
- String _path = this._roomExtensions.getPath(dc);
- String path = (_generationTargetPath + _path);
- String file = this._javaExtensions.getJavaFileName(dc);
- String _plus = ("generating DataClass implementation \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- CharSequence _generate = this.generate(root, dc);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public CharSequence generate(final Root root, final DataClass dc) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return Boolean.valueOf(_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this._roomExtensions.getPackage(dc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<RoomModel> models = root.getReferencedModels(dc);
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(dc, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = dc.getName();
- _builder.append(_name_1, "");
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- _builder.append(" extends ");
- DataClass _base_1 = dc.getBase();
- String _name_2 = _base_1.getName();
- _builder.append(_name_2, "");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_2 = dc.getAttributes();
- String _name_3 = dc.getName();
- CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
- _builder.append(_attributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<StandardOperation> _operations_1 = dc.getOperations();
- String _name_4 = dc.getName();
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations_1, _name_4);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// default constructor");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_5 = dc.getName();
- _builder.append(_name_5, " ");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_3 = dc.getAttributes();
- CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes_3, true);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals_1 = (!Objects.equal(ctor, null));
- if (_notEquals_1) {
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- {
- DetailCode _detailCode = ctor.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String l : _commands) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(l, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// constructor using fields");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_6 = dc.getName();
- _builder.append(_name_6, " ");
- _builder.append("(");
- String _argList = this.argList(dc);
- _builder.append(_argList, " ");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- {
- DataClass _base_2 = dc.getBase();
- boolean _notEquals_2 = (!Objects.equal(_base_2, null));
- if (_notEquals_2) {
- _builder.append("\t\t");
- _builder.append("super(");
- DataClass _base_3 = dc.getBase();
- String _paramList = this.paramList(_base_3);
- _builder.append(_paramList, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("super();");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- {
- EList<Attribute> _attributes_4 = dc.getAttributes();
- for(final Attribute a : _attributes_4) {
- _builder.append("\t\t");
- _builder.append("this.");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append(" = ");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// deep copy");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
- _builder.append(" deepCopy() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _name_10 = dc.getName();
- _builder.append(_name_10, " ");
- _builder.append(" copy = new ");
- String _name_11 = dc.getName();
- _builder.append(_name_11, " ");
- _builder.append("();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _deepCopy = this.deepCopy(dc);
- _builder.append(_deepCopy, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return copy;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String paramList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _paramList = this.paramList(_attributes);
- String _string = _paramList.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- if (_notEquals_1) {
- String _plus_1 = (", " + result);
- result = _plus_1;
- }
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence paramList(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final Attribute a : attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- String _name = a.getName();
- _builder.append(_name, "");
- }
- }
- return _builder;
- }
-
- public String argList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _argList = this._procedureHelpers.argList(_attributes);
- String _string = _argList.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- if (_notEquals_1) {
- String _plus_1 = (", " + result);
- result = _plus_1;
- }
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public String deepCopy(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _deepCopy = this.deepCopy(_attributes);
- String _string = _deepCopy.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence deepCopy(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Attribute a : attributes) {
- {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof ComplexType)) {
- _builder.append("if (");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("!=null) {");
- _builder.newLineIfNotEmpty();
- {
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- _builder.append("\t");
- _builder.append("copy.");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = ");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append(".deepCopy();");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("copy.");
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append("[i] = ");
- String _name_5 = a.getName();
- _builder.append(_name_5, " ");
- _builder.append("[i].deepCopy();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- } else {
- {
- int _size_1 = a.getSize();
- boolean _equals_1 = (_size_1 == 0);
- if (_equals_1) {
- _builder.append("copy.");
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append(" = ");
- String _name_7 = a.getName();
- _builder.append(_name_7, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- String _name_8 = a.getName();
- _builder.append(_name_8, "");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("copy.");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append("[i] = ");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append("[i];");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ComplexType;
+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.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
+ String _path = this._roomExtensions.getPath(dc);
+ String path = (_generationTargetPath + _path);
+ String file = this._javaExtensions.getJavaFileName(dc);
+ String _plus = ("generating DataClass implementation \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ CharSequence _generate = this.generate(root, dc);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final DataClass dc) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(dc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<RoomModel> models = root.getReferencedModels(dc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(dc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = dc.getName();
+ _builder.append(_name_1, "");
+ {
+ DataClass _base = dc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ _builder.append(" extends ");
+ DataClass _base_1 = dc.getBase();
+ String _name_2 = _base_1.getName();
+ _builder.append(_name_2, "");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_2 = dc.getAttributes();
+ String _name_3 = dc.getName();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<StandardOperation> _operations_1 = dc.getOperations();
+ String _name_4 = dc.getName();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations_1, _name_4);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// default constructor");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes_3, true);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(ctor, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// user defined constructor body");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = ctor.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String l : _commands) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(l, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructor using fields");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_6 = dc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(");
+ String _argList = this.argList(dc);
+ _builder.append(_argList, " ");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ {
+ DataClass _base_2 = dc.getBase();
+ boolean _notEquals_2 = (!Objects.equal(_base_2, null));
+ if (_notEquals_2) {
+ _builder.append("\t\t");
+ _builder.append("super(");
+ DataClass _base_3 = dc.getBase();
+ String _paramList = this.paramList(_base_3);
+ _builder.append(_paramList, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("super();");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ EList<Attribute> _attributes_4 = dc.getAttributes();
+ for(final Attribute a : _attributes_4) {
+ _builder.append("\t\t");
+ _builder.append("this.");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(" = ");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" deepCopy() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(" copy = new ");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ String _deepCopy = this.deepCopy(dc);
+ _builder.append(_deepCopy, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return copy;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public String paramList(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _paramList = this.paramList(_attributes);
+ String _string = _paramList.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ if (_notEquals_1) {
+ String _plus_1 = (", " + result);
+ result = _plus_1;
+ }
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence paramList(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasElements = false;
+ for(final Attribute a : attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ String _name = a.getName();
+ _builder.append(_name, "");
+ }
+ }
+ return _builder;
+ }
+
+ public String argList(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _argList = this._procedureHelpers.argList(_attributes);
+ String _string = _argList.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ if (_notEquals_1) {
+ String _plus_1 = (", " + result);
+ result = _plus_1;
+ }
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public String deepCopy(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _deepCopy = this.deepCopy(_attributes);
+ String _string = _deepCopy.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence deepCopy(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Attribute a : attributes) {
+ {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof ComplexType)) {
+ _builder.append("if (");
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("!=null) {");
+ _builder.newLineIfNotEmpty();
+ {
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = ");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(".deepCopy();");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".length;i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_4 = a.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("[i] = ");
+ String _name_5 = a.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("[i].deepCopy();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ {
+ int _size_1 = a.getSize();
+ boolean _equals_1 = (_size_1 == 0);
+ if (_equals_1) {
+ _builder.append("copy.");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, "");
+ _builder.append(" = ");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("for (int i=0;i<");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, "");
+ _builder.append(".length;i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("[i] = ");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("[i];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 0fb47b010..5380b8500 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -1,144 +1,144 @@
-package org.eclipse.etrice.generator.java.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.core.room.VarDecl;
-import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.util.Pair;
-
-@Singleton
-@SuppressWarnings("all")
-public class JavaExtensions implements ILanguageExtension {
- @Inject
- private AbstractTransitionChainGenerator chainGenerator;
-
- public String getTypedDataDefinition(final Message m) {
- VarDecl _data = m.getData();
- return this.chainGenerator.generateTypedData(_data);
- }
-
- public String getJavaFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + ".java");
- return _plus;
- }
-
- public String accessLevelPrivate() {
- return "private ";
- }
-
- public String accessLevelProtected() {
- return "protected ";
- }
-
- public String accessLevelPublic() {
- return "public ";
- }
-
- public String memberAccess() {
- return "this.";
- }
-
- public String selfPointer(final String classname, final boolean hasArgs) {
- return "";
- }
-
- public String selfPointer(final boolean hasArgs) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- return "";
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- return member;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _plus = (namespace + ".");
- return (_plus + member);
- }
-
- public boolean usesInheritance() {
- return true;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Pair<String,String> entry : entries) {
- _builder.append("public static final int ");
- String _first = entry.getFirst();
- _builder.append(_first, "");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- String _string = _builder.toString();
- return _string;
- }
-
- public String booleanConstant(final boolean b) {
- String _string = Boolean.valueOf(b).toString();
- return _string;
- }
-
- public String pointerLiteral() {
- return "";
- }
-
- public String nullPointer() {
- return "null";
- }
-
- public String voidPointer() {
- return "Object";
- }
-
- public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
- String _plus = (type + " ");
- String _plus_1 = (_plus + name);
- String _plus_2 = (_plus_1 + "[]");
- return _plus_2;
- }
-
- public String constructorName(final String cls) {
- return cls;
- }
-
- public String destructorName(final String cls) {
- String _plus = (cls + "_dtor");
- return _plus;
- }
-
- public String constructorReturnType() {
- return "";
- }
-
- public String destructorReturnType() {
- return "void";
- }
-
- public String toCharArrayExpr(final String s) {
- String _plus = ("\"" + s);
- String _plus_1 = (_plus + "\".toCharArray()");
- return _plus_1;
- }
-
- public String superCall(final String baseClassName, final String method, final String args) {
- String _plus = ("super." + method);
- String _plus_1 = (_plus + "(");
- String _plus_2 = (_plus_1 + args);
- String _plus_3 = (_plus_2 + ");");
- return _plus_3;
- }
-}
+package org.eclipse.etrice.generator.java.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.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+
+@Singleton
+@SuppressWarnings("all")
+public class JavaExtensions implements ILanguageExtension {
+ @Inject
+ private AbstractTransitionChainGenerator chainGenerator;
+
+ public String getTypedDataDefinition(final Message m) {
+ VarDecl _data = m.getData();
+ return this.chainGenerator.generateTypedData(_data);
+ }
+
+ public String getJavaFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _plus = (_name + ".java");
+ return _plus;
+ }
+
+ public String accessLevelPrivate() {
+ return "private ";
+ }
+
+ public String accessLevelProtected() {
+ return "protected ";
+ }
+
+ public String accessLevelPublic() {
+ return "public ";
+ }
+
+ public String memberAccess() {
+ return "this.";
+ }
+
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ return "";
+ }
+
+ public String selfPointer(final boolean hasArgs) {
+ return "";
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ return "";
+ }
+
+ public String memberInDeclaration(final String namespace, final String member) {
+ return member;
+ }
+
+ public String memberInUse(final String namespace, final String member) {
+ String _plus = (namespace + ".");
+ return (_plus + member);
+ }
+
+ public boolean usesInheritance() {
+ return true;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Pair<String,String> entry : entries) {
+ _builder.append("public static final int ");
+ String _first = entry.getFirst();
+ _builder.append(_first, "");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _string = Boolean.valueOf(b).toString();
+ return _string;
+ }
+
+ public String pointerLiteral() {
+ return "";
+ }
+
+ public String nullPointer() {
+ return "null";
+ }
+
+ public String voidPointer() {
+ return "Object";
+ }
+
+ public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
+ String _plus = (type + " ");
+ String _plus_1 = (_plus + name);
+ String _plus_2 = (_plus_1 + "[]");
+ return _plus_2;
+ }
+
+ public String constructorName(final String cls) {
+ return cls;
+ }
+
+ public String destructorName(final String cls) {
+ String _plus = (cls + "_dtor");
+ return _plus;
+ }
+
+ public String constructorReturnType() {
+ return "";
+ }
+
+ public String destructorReturnType() {
+ return "void";
+ }
+
+ public String toCharArrayExpr(final String s) {
+ String _plus = ("\"" + s);
+ String _plus_1 = (_plus + "\".toCharArray()");
+ return _plus_1;
+ }
+
+ public String superCall(final String baseClassName, final String method, final String args) {
+ String _plus = ("super." + method);
+ String _plus_1 = (_plus + "(");
+ String _plus_2 = (_plus_1 + args);
+ String _plus_3 = (_plus_2 + ");");
+ return _plus_3;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
index fba8b068e..632b5e21e 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
@@ -1,60 +1,60 @@
-package org.eclipse.etrice.generator.java.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.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.generator.generic.PrepareFileSystem;
-import org.eclipse.etrice.generator.java.gen.ActorClassGen;
-import org.eclipse.etrice.generator.java.gen.DataClassGen;
-import org.eclipse.etrice.generator.java.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.java.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.java.gen.SubSystemRunnerGen;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@Singleton
-@SuppressWarnings("all")
-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 _not = (!_isLibrary);
- if (_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
+package org.eclipse.etrice.generator.java.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.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.etrice.generator.java.gen.ActorClassGen;
+import org.eclipse.etrice.generator.java.gen.DataClassGen;
+import org.eclipse.etrice.generator.java.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.java.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.java.gen.SubSystemRunnerGen;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@Singleton
+@SuppressWarnings("all")
+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 _not = (!_isLibrary);
+ if (_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
index 7b2090992..ca310c140 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -1,790 +1,790 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.Attribute;
-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.MessageHandler;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PortOperation;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.DataClassGen;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions _javaExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private DataClassGen _dataClassGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
- String _path = this._roomExtensions.getPath(pc);
- String path = (_generationTargetPath + _path);
- String file = this._javaExtensions.getJavaFileName(pc);
- String _plus = ("generating ProtocolClass implementation \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- CharSequence _generate = this.generate(root, pc);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public CharSequence generate(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this._roomExtensions.getPackage(pc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import java.util.ArrayList;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Message;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
- _builder.newLine();
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(pc, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<RoomModel> models = root.getReferencedModels(pc);
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("// message IDs");
- _builder.newLine();
- _builder.append("\t");
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("private static String messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_2 = m.getName();
- _builder.append(_name_2, " ");
- _builder.append("\",");
- }
- }
- _builder.append(" ");
- {
- List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\"");
- String _name_3 = m_1.getName();
- _builder.append(_name_3, " ");
- _builder.append("\",");
- }
- }
- _builder.append("\"MAX\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public String getMessageString(int msg_id) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("// id out of range");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("else{");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return messageStrings[msg_id];");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _portClass = this.portClass(pc, Boolean.valueOf(false));
- _builder.append(_portClass, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- CharSequence _portClass_1 = this.portClass(pc, Boolean.valueOf(true));
- _builder.append(_portClass_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence portClass(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- PortClass pclass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
- String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("// port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(portClassName, "");
- _builder.append(" extends PortBase {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(pclass, null));
- if (_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- CharSequence _userCode_1 = this._procedureHelpers.userCode(_userCode);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("// constructors");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(portClassName, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("this(actor, name, localId, 0, addr, peerAddress);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService.getInstance().addPortInstance(this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(portClassName, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(actor, name, localId, idx, addr, peerAddress);");
- _builder.newLine();
- {
- boolean _notEquals_1 = (!Objects.equal(pclass, null));
- if (_notEquals_1) {
- _builder.append("\t\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes, true);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("DebuggingService.getInstance().addPortInstance(this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receive(Message m) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("if (!(m instanceof EventMessage))");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("return;");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("EventMessage msg = (EventMessage) m;");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("System.out.println(\"unknown\");");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
- _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
- {
- boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive) {
- _builder.append("\t\t\t\t");
- _builder.append("switch (msg.getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- Message _msg = hdlr.getMsg();
- String _codeName = this._roomExtensions.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("default:");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("if (msg instanceof EventWithDataMessage)");
- _builder.newLine();
- _builder.append("\t\t\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);");
- _builder.newLine();
- {
- boolean _handlesReceive_1 = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive_1) {
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _notEquals_2 = (!Objects.equal(pclass, null));
- if (_notEquals_2) {
- _builder.append("\t");
- EList<Attribute> _attributes_1 = pclass.getAttributes();
- CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
- _builder.append(_attributes_2, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("// TODO JH: Avoid collision attr getters/setter <-> user operations");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_3 = pclass.getAttributes();
- CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_3, null);
- _builder.append(_attributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// sent messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this._roomExtensions.getOutgoing(pc, (conj).booleanValue());
- for(final Message m : _outgoing) {
- _builder.append("\t");
- CharSequence _sendMessage = this.sendMessage(m, (conj).booleanValue());
- _builder.append(_sendMessage, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// replicated port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(replPortClassName, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private ArrayList<");
- _builder.append(portClassName, " ");
- _builder.append("> ports;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private int replication;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(replPortClassName, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, Address[] addr,");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("Address[] peerAddress) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("replication = addr==null? 0:addr.length;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("ports = new ArrayList<");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append(".");
- _builder.append(portClassName, " ");
- _builder.append(">(replication);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("ports.add(new ");
- _builder.append(portClassName, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t\t");
- _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public int getReplication() {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return replication;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public int getIndexOf(InterfaceItemBase ifitem){");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ifitem.getIdx();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(portClassName, " ");
- _builder.append(" get(int i) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return ports.get(i);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- if ((conj).booleanValue()) {
- _builder.append("\t");
- _builder.append("// incoming messages");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t");
- CharSequence _messageSignature = this.messageSignature(m_1);
- _builder.append(_messageSignature, " ");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("ports.get(i).");
- CharSequence _messageCall = this.messageCall(m_1);
- _builder.append(_messageCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
- for(final Message m_2 : _allOutgoingMessages) {
- _builder.append("\t");
- CharSequence _messageSignature_1 = this.messageSignature(m_2);
- _builder.append(_messageSignature_1, " ");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("ports.get(i).");
- CharSequence _messageCall_1 = this.messageCall(m_2);
- _builder.append(_messageCall_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence messageSignature(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isPriv = m.isPriv();
- if (_isPriv) {
- _builder.append("private");
- } else {
- _builder.append("public");
- }
- }
- _builder.append(" void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_1 = _data_2.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public CharSequence messageSignatureExplicit(final Message m) {
- CharSequence _xblockexpression = null;
- {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- DataClass dc = ((DataClass) _type);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("public void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- String _argList = this._dataClassGen.argList(dc);
- _builder.append(_argList, "");
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public CharSequence sendMessage(final Message m, final boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "IN";
- } else {
- _xifexpression = "OUT";
- }
- String dir = _xifexpression;
- MessageHandler hdlr = this._roomExtensions.getSendHandler(m, conj);
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _messageSignature = this.messageSignature(m);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(hdlr, null));
- if (_notEquals) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("if (messageStrings[ ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name = m.getName();
- _builder.append(_name, " ");
- _builder.append("] != \"timerTick\"){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_1 = m.getName();
- _builder.append(_name_1, " ");
- _builder.append("]);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (getPeerAddress()!=null)");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- {
- VarDecl _data = m.getData();
- boolean _equals = Objects.equal(_data, null);
- if (_equals) {
- _builder.append("getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_2 = m.getName();
- _builder.append(_name_2, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- } else {
- _builder.append("getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_3 = m.getName();
- _builder.append(_name_3, " ");
- _builder.append(", ");
- VarDecl _data_1 = m.getData();
- String _name_4 = _data_1.getName();
- _builder.append(_name_4, " ");
- {
- boolean _and = false;
- VarDecl _data_2 = m.getData();
- RefableType _refType = _data_2.getRefType();
- boolean _isRef = _refType.isRef();
- boolean _not = (!_isRef);
- if (!_not) {
- _and = false;
- } else {
- VarDecl _data_3 = m.getData();
- RefableType _refType_1 = _data_3.getRefType();
- DataType _type = _refType_1.getType();
- boolean _not_1 = (!(_type instanceof PrimitiveType));
- _and = (_not && _not_1);
- }
- if (_and) {
- _builder.append(".deepCopy()");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("}");
- _builder.newLine();
- {
- boolean _and_1 = false;
- VarDecl _data_4 = m.getData();
- boolean _notEquals_1 = (!Objects.equal(_data_4, null));
- if (!_notEquals_1) {
- _and_1 = false;
- } else {
- VarDecl _data_5 = m.getData();
- RefableType _refType_2 = _data_5.getRefType();
- DataType _type_1 = _refType_2.getType();
- _and_1 = (_notEquals_1 && (_type_1 instanceof DataClass));
- }
- if (_and_1) {
- CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m);
- _builder.append(_messageSignatureExplicit, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_5 = m.getName();
- _builder.append(_name_5, " ");
- _builder.append("(new ");
- VarDecl _data_6 = m.getData();
- RefableType _refType_3 = _data_6.getRefType();
- DataType _type_2 = _refType_3.getType();
- String _name_6 = _type_2.getName();
- _builder.append(_name_6, " ");
- _builder.append("(");
- VarDecl _data_7 = m.getData();
- RefableType _refType_4 = _data_7.getRefType();
- DataType _type_3 = _refType_4.getType();
- String _paramList = this._dataClassGen.paramList(((DataClass) _type_3));
- _builder.append(_paramList, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+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.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.DataClassGen;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private DataClassGen _dataClassGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
+ String _path = this._roomExtensions.getPath(pc);
+ String path = (_generationTargetPath + _path);
+ String file = this._javaExtensions.getJavaFileName(pc);
+ String _plus = ("generating ProtocolClass implementation \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ CharSequence _generate = this.generate(root, pc);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(pc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import java.util.ArrayList;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Message;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(pc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<RoomModel> models = root.getReferencedModels(pc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// message IDs");
+ _builder.newLine();
+ _builder.append("\t");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private static String messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append(" ");
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_3 = m_1.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public String getMessageString(int msg_id) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("// id out of range");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return messageStrings[msg_id];");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _portClass = this.portClass(pc, Boolean.valueOf(false));
+ _builder.append(_portClass, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _portClass_1 = this.portClass(pc, Boolean.valueOf(true));
+ _builder.append(_portClass_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence portClass(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ PortClass pclass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("// port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(portClassName, "");
+ _builder.append(" extends PortBase {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(pclass, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ DetailCode _userCode = pclass.getUserCode();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(_userCode);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("// constructors");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("this(actor, name, localId, 0, addr, peerAddress);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("DebuggingService.getInstance().addPortInstance(this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(actor, name, localId, idx, addr, peerAddress);");
+ _builder.newLine();
+ {
+ boolean _notEquals_1 = (!Objects.equal(pclass, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t");
+ EList<Attribute> _attributes = pclass.getAttributes();
+ CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes, true);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("DebuggingService.getInstance().addPortInstance(this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receive(Message m) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("if (!(m instanceof EventMessage))");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("return;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("EventMessage msg = (EventMessage) m;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("System.out.println(\"unknown\");");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ _builder.append("\t\t\t\t");
+ _builder.append("switch (msg.getEvtId()) {");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler hdlr : _receiveHandlers) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ Message _msg = hdlr.getMsg();
+ String _codeName = this._roomExtensions.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("default:");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("if (msg instanceof EventWithDataMessage)");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);");
+ _builder.newLine();
+ {
+ boolean _handlesReceive_1 = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive_1) {
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _notEquals_2 = (!Objects.equal(pclass, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ EList<Attribute> _attributes_1 = pclass.getAttributes();
+ CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// TODO JH: Avoid collision attr getters/setter <-> user operations");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_3 = pclass.getAttributes();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_3, null);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<PortOperation> _operations = pclass.getOperations();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// sent messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing = this._roomExtensions.getOutgoing(pc, (conj).booleanValue());
+ for(final Message m : _outgoing) {
+ _builder.append("\t");
+ CharSequence _sendMessage = this.sendMessage(m, (conj).booleanValue());
+ _builder.append(_sendMessage, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// replicated port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(replPortClassName, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private ArrayList<");
+ _builder.append(portClassName, " ");
+ _builder.append("> ports;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private int replication;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, Address[] addr,");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("Address[] peerAddress) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("replication = addr==null? 0:addr.length;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports = new ArrayList<");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append(".");
+ _builder.append(portClassName, " ");
+ _builder.append(">(replication);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("ports.add(new ");
+ _builder.append(portClassName, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int getReplication() {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return replication;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int getIndexOf(InterfaceItemBase ifitem){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return ifitem.getIdx();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append(" get(int i) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return ports.get(i);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("\t");
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\t");
+ CharSequence _messageSignature = this.messageSignature(m_1);
+ _builder.append(_messageSignature, " ");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("ports.get(i).");
+ CharSequence _messageCall = this.messageCall(m_1);
+ _builder.append(_messageCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ _builder.append("\t");
+ CharSequence _messageSignature_1 = this.messageSignature(m_2);
+ _builder.append(_messageSignature_1, " ");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("ports.get(i).");
+ CharSequence _messageCall_1 = this.messageCall(m_2);
+ _builder.append(_messageCall_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence messageSignature(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isPriv = m.isPriv();
+ if (_isPriv) {
+ _builder.append("private");
+ } else {
+ _builder.append("public");
+ }
+ }
+ _builder.append(" void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_1 = _data_2.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public CharSequence messageSignatureExplicit(final Message m) {
+ CharSequence _xblockexpression = null;
+ {
+ VarDecl _data = m.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ DataClass dc = ((DataClass) _type);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("public void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ String _argList = this._dataClassGen.argList(dc);
+ _builder.append(_argList, "");
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public CharSequence sendMessage(final Message m, final boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ if (conj) {
+ _xifexpression = "IN";
+ } else {
+ _xifexpression = "OUT";
+ }
+ String dir = _xifexpression;
+ MessageHandler hdlr = this._roomExtensions.getSendHandler(m, conj);
+ StringConcatenation _builder = new StringConcatenation();
+ CharSequence _messageSignature = this.messageSignature(m);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(hdlr, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("if (messageStrings[ ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name = m.getName();
+ _builder.append(_name, " ");
+ _builder.append("] != \"timerTick\"){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (getPeerAddress()!=null)");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ VarDecl _data = m.getData();
+ boolean _equals = Objects.equal(_data, null);
+ if (_equals) {
+ _builder.append("getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ } else {
+ _builder.append("getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_3 = m.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(", ");
+ VarDecl _data_1 = m.getData();
+ String _name_4 = _data_1.getName();
+ _builder.append(_name_4, " ");
+ {
+ boolean _and = false;
+ VarDecl _data_2 = m.getData();
+ RefableType _refType = _data_2.getRefType();
+ boolean _isRef = _refType.isRef();
+ boolean _not = (!_isRef);
+ if (!_not) {
+ _and = false;
+ } else {
+ VarDecl _data_3 = m.getData();
+ RefableType _refType_1 = _data_3.getRefType();
+ DataType _type = _refType_1.getType();
+ boolean _not_1 = (!(_type instanceof PrimitiveType));
+ _and = (_not && _not_1);
+ }
+ if (_and) {
+ _builder.append(".deepCopy()");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _and_1 = false;
+ VarDecl _data_4 = m.getData();
+ boolean _notEquals_1 = (!Objects.equal(_data_4, null));
+ if (!_notEquals_1) {
+ _and_1 = false;
+ } else {
+ VarDecl _data_5 = m.getData();
+ RefableType _refType_2 = _data_5.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ _and_1 = (_notEquals_1 && (_type_1 instanceof DataClass));
+ }
+ if (_and_1) {
+ CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m);
+ _builder.append(_messageSignatureExplicit, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_5 = m.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("(new ");
+ VarDecl _data_6 = m.getData();
+ RefableType _refType_3 = _data_6.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ String _name_6 = _type_2.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(");
+ VarDecl _data_7 = m.getData();
+ RefableType _refType_4 = _data_7.getRefType();
+ DataType _type_3 = _refType_4.getType();
+ String _paramList = this._dataClassGen.paramList(((DataClass) _type_3));
+ _builder.append(_paramList, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
index bb397d606..8c76867d7 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
@@ -1,81 +1,81 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-
-@Singleton
-@SuppressWarnings("all")
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- public CharSequence genExtra(final ExpandedActorClass xpac) {
- CharSequence _xblockexpression = null;
- {
- final ActorClass ac = xpac.getActorClass();
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("// state names");
- _builder.newLine();
- _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
- {
- List<State> _allBaseStatesLeavesLast = this._roomExtensions.getAllBaseStatesLeavesLast(ac);
- boolean _hasElements = false;
- for(final State state : _allBaseStatesLeavesLast) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", "");
- }
- _builder.append("\"");
- String _statePathName = this._roomExtensions.getStatePathName(state);
- _builder.append(_statePathName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// history");
- _builder.newLine();
- _builder.append("protected int history[] = {NO_STATE,NO_STATE");
- {
- List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
- for(final State state_1 : _allBaseStates) {
- _builder.append(",NO_STATE");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("private void setState(int new_state) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("this.state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+
+@Singleton
+@SuppressWarnings("all")
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public CharSequence genExtra(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("// state names");
+ _builder.newLine();
+ _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
+ {
+ List<State> _allBaseStatesLeavesLast = this._roomExtensions.getAllBaseStatesLeavesLast(ac);
+ boolean _hasElements = false;
+ for(final State state : _allBaseStatesLeavesLast) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", "");
+ }
+ _builder.append("\"");
+ String _statePathName = this._roomExtensions.getStatePathName(state);
+ _builder.append(_statePathName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// history");
+ _builder.newLine();
+ _builder.append("protected int history[] = {NO_STATE,NO_STATE");
+ {
+ List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
+ for(final State state_1 : _allBaseStates) {
+ _builder.append(",NO_STATE");
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("private void setState(int new_state) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("this.state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
index 7703de03c..062f0cc4f 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
@@ -1,910 +1,910 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.LiteralArray;
-import org.eclipse.etrice.core.config.PortInstanceConfig;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.LogicalThread;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions _javaExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ConfigExtension _configExtension;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @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._roomExtensions.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this._roomExtensions.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String file = this._javaExtensions.getJavaFileName(_subSystemClass_2);
- String _plus = ("generating SubSystemClass implementation: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- CharSequence _generate = this.generate(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this._roomExtensions.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.newLine();
- EList<RoomModel> models = root.getReferencedModels(cc);
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(cc, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = comp.getName();
- _builder.append(_name_1, "");
- _builder.append(" extends SubSystemClassBase{");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_2 = comp.getName();
- _builder.append(_name_2, " ");
- _builder.append("(IRTObject parent, String name) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(parent, name);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateMessageServices(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
- _builder.newLine();
- {
- EList<LogicalThread> _threads = cc.getThreads();
- for(final LogicalThread thread : _threads) {
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
- EList<LogicalThread> _threads_1 = cc.getThreads();
- int _indexOf = _threads_1.indexOf(thread);
- int _plus = (_indexOf + 1);
- _builder.append(_plus, " ");
- _builder.append(", 0),\"MessageService_");
- String _name_3 = thread.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", ");
- int _prio = thread.getPrio();
- _builder.append(_prio, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateActors(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// all addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// Addresses for the Subsystem Systemport");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- int _maxObjId = comp.getMaxObjId();
- Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
- for(final Indexed<ActorInstance> ai : _indexed) {
- _builder.append("\t\t");
- _builder.append("Address addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
- ActorInstance _value = ai.getValue();
- int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
- _builder.append(_indexOf_1, " ");
- _builder.append(" = new Address(0,0,");
- int _index1 = ai.getIndex1();
- _builder.append(_index1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
- for(final ActorInstance ai_1 : _allContainedInstances_2) {
- _builder.append("\t\t");
- _builder.append("// actor instance ");
- String _path = ai_1.getPath();
- _builder.append(_path, " ");
- _builder.append(" itself => Systemport Address");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_1 = ai_1.getPath();
- String _pathName = this._roomExtensions.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append(" = new Address(0,");
- int _threadId = ai_1.getThreadId();
- _builder.append(_threadId, " ");
- _builder.append(",");
- int _objId = ai_1.getObjId();
- _builder.append(_objId, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// interface items of ");
- String _path_2 = ai_1.getPath();
- _builder.append(_path_2, " ");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _isReplicated = pi.isReplicated();
- if (_isReplicated) {
- {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers) {
- _builder.append("\t\t");
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int i = _peers_1.indexOf(peer);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_3 = pi.getPath();
- String _pathName_1 = this._roomExtensions.getPathName(_path_3);
- _builder.append(_pathName_1, " ");
- _builder.append("_");
- _builder.append(i, " ");
- _builder.append(" = new Address(0,");
- int _threadId_1 = pi.getThreadId();
- _builder.append(_threadId_1, " ");
- _builder.append(",");
- int _objId_1 = pi.getObjId();
- int _plus_1 = (_objId_1 + i);
- _builder.append(_plus_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_4 = pi.getPath();
- String _pathName_2 = this._roomExtensions.getPathName(_path_4);
- _builder.append(_pathName_2, " ");
- _builder.append(" = new Address(0,");
- int _threadId_2 = ai_1.getThreadId();
- _builder.append(_threadId_2, " ");
- _builder.append(",");
- int _objId_2 = pi.getObjId();
- _builder.append(_objId_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// instantiate all actor instances");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("instances = new ActorClassBase[");
- EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
- int _size = _allContainedInstances_3.size();
- _builder.append(_size, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
- for(final ActorInstance ai_2 : _allContainedInstances_4) {
- _builder.append("\t\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
- int _indexOf_2 = _allContainedInstances_5.indexOf(ai_2);
- _builder.append(_indexOf_2, " ");
- _builder.append("] = new ");
- ActorClass _actorClass = ai_2.getActorClass();
- String _name_4 = _actorClass.getName();
- _builder.append(_name_4, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- {
- EObject _eContainer = ai_2.eContainer();
- if ((_eContainer instanceof SubSystemInstance)) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("this,");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
- EObject _eContainer_1 = ai_2.eContainer();
- int _indexOf_3 = _allContainedInstances_6.indexOf(_eContainer_1);
- _builder.append(_indexOf_3, " ");
- _builder.append("],");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\"");
- String _name_5 = ai_2.getName();
- _builder.append(_name_5, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// own interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_");
- String _path_5 = ai_2.getPath();
- String _pathName_3 = this._roomExtensions.getPathName(_path_5);
- _builder.append(_pathName_3, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
- boolean _hasElements = false;
- for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _isReplicated_1 = pi_1.isReplicated();
- if (_isReplicated_1) {
- {
- EList<InterfaceItemInstance> _peers_2 = pi_1.getPeers();
- boolean _isEmpty_1 = _peers_2.isEmpty();
- if (_isEmpty_1) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
- boolean _hasElements_1 = false;
- for(final InterfaceItemInstance peer_1 : _peers_3) {
- if (!_hasElements_1) {
- _hasElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_6 = pi_1.getPath();
- String _pathName_4 = this._roomExtensions.getPathName(_path_6);
- _builder.append(_pathName_4, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- int _indexOf_4 = _peers_4.indexOf(peer_1);
- _builder.append(_indexOf_4, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_7 = pi_1.getPath();
- String _pathName_5 = this._roomExtensions.getPathName(_path_7);
- _builder.append(_pathName_5, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// peer interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
- int _indexOf_5 = _allContainedInstances_7.indexOf(ai_2);
- _builder.append(_indexOf_5, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
- boolean _not_1 = (!_isEmpty_2);
- if (_not_1) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
- boolean _hasElements_2 = false;
- for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
- if (!_hasElements_2) {
- _hasElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _and = false;
- boolean _isReplicated_2 = pi_2.isReplicated();
- if (!_isReplicated_2) {
- _and = false;
- } else {
- EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
- boolean _isEmpty_3 = _peers_5.isEmpty();
- _and = (_isReplicated_2 && _isEmpty_3);
- }
- if (_and) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
- boolean _isEmpty_4 = _peers_6.isEmpty();
- if (_isEmpty_4) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- {
- EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
- boolean _hasElements_3 = false;
- for(final InterfaceItemInstance pp : _peers_7) {
- if (!_hasElements_3) {
- _hasElements_3 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _isReplicated_3 = pp.isReplicated();
- if (_isReplicated_3) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_8 = pp.getPath();
- String _pathName_6 = this._roomExtensions.getPathName(_path_8);
- _builder.append(_pathName_6, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _indexOf_6 = _peers_8.indexOf(pi_2);
- _builder.append(_indexOf_6, " ");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_9 = pp.getPath();
- String _pathName_7 = this._roomExtensions.getPathName(_path_9);
- _builder.append(_pathName_7, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("); ");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// apply instance attribute configurations");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
- for(final ActorInstance ai_3 : _allContainedInstances_8) {
- _builder.append("\t\t");
- List<AttrInstanceConfig> attrConfigs = this._configExtension.getConfigAttributes(ai_3);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- List<PortInstanceConfig> portConfigs = this._configExtension.getConfigPorts(ai_3);
- _builder.newLineIfNotEmpty();
- {
- boolean _or = false;
- boolean _isEmpty_5 = attrConfigs.isEmpty();
- boolean _not_2 = (!_isEmpty_5);
- if (_not_2) {
- _or = true;
- } else {
- boolean _isEmpty_6 = portConfigs.isEmpty();
- boolean _not_3 = (!_isEmpty_6);
- _or = (_not_2 || _not_3);
- }
- if (_or) {
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- String aiName = "inst";
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- ActorClass _actorClass_1 = ai_3.getActorClass();
- String _name_6 = _actorClass_1.getName();
- _builder.append(_name_6, " ");
- _builder.append(" ");
- _builder.append(aiName, " ");
- _builder.append(" = (");
- ActorClass _actorClass_2 = ai_3.getActorClass();
- String _name_7 = _actorClass_2.getName();
- _builder.append(_name_7, " ");
- _builder.append(") instances[");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_7 = _allContainedInstances_9.indexOf(ai_3);
- _builder.append(_indexOf_7, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- {
- for(final AttrInstanceConfig attrConfig : attrConfigs) {
- _builder.append("\t\t");
- _builder.append("\t");
- Attribute a = attrConfig.getAttribute();
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- LiteralArray _value_1 = attrConfig.getValue();
- String value = this._configExtension.stringValue(_value_1, a);
- _builder.newLineIfNotEmpty();
- {
- boolean _isArray = this._configExtension.isArray(a);
- boolean _not_4 = (!_isArray);
- if (_not_4) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(aiName, " ");
- _builder.append(".");
- String _name_8 = a.getName();
- ActorClass _actorClass_3 = ai_3.getActorClass();
- String _name_9 = _actorClass_3.getName();
- CharSequence _invokeSetter = this._procedureHelpers.invokeSetter(_name_8, _name_9, value);
- _builder.append(_invokeSetter, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _startsWith = value.startsWith("{");
- if (_startsWith) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(aiName, " ");
- _builder.append(".");
- String _name_10 = a.getName();
- ActorClass _actorClass_4 = ai_3.getActorClass();
- String _name_11 = _actorClass_4.getName();
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String _plus_2 = ("new " + _typeName);
- String _plus_3 = (_plus_2 + "[]");
- String _plus_4 = (_plus_3 + value);
- CharSequence _invokeSetter_1 = this._procedureHelpers.invokeSetter(_name_10, _name_11, _plus_4);
- _builder.append(_invokeSetter_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, " ");
- _builder.append("[] array = ");
- _builder.append(aiName, " ");
- _builder.append(".");
- String _name_12 = a.getName();
- ActorClass _actorClass_5 = ai_3.getActorClass();
- String _name_13 = _actorClass_5.getName();
- CharSequence _invokeGetter = this._procedureHelpers.invokeGetter(_name_12, _name_13);
- _builder.append(_invokeGetter, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- int _size_1 = a.getSize();
- _builder.append(_size_1, " ");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("array[i] = ");
- _builder.append(value, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- {
- for(final PortInstanceConfig portConfig : portConfigs) {
- _builder.append("\t\t");
- _builder.append("\t");
- InterfaceItem item = portConfig.getItem();
- _builder.newLineIfNotEmpty();
- {
- EList<AttrInstanceConfig> _attributes = portConfig.getAttributes();
- for(final AttrInstanceConfig attrConfig_1 : _attributes) {
- _builder.append("\t\t");
- _builder.append("\t");
- Attribute a_1 = attrConfig_1.getAttribute();
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- LiteralArray _value_2 = attrConfig_1.getValue();
- String value_1 = this._configExtension.stringValue(_value_2, a_1);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- String _plus_5 = (aiName + ".");
- String _name_14 = item.getName();
- String _portClassName = this._roomExtensions.getPortClassName(item);
- CharSequence _invokeGetter_1 = this._procedureHelpers.invokeGetter(_name_14, _portClassName);
- String refToItem = (_plus_5 + _invokeGetter_1);
- _builder.newLineIfNotEmpty();
- {
- boolean _isArray_1 = this._configExtension.isArray(a_1);
- boolean _not_5 = (!_isArray_1);
- if (_not_5) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(refToItem, " ");
- _builder.append(".");
- String _name_15 = a_1.getName();
- String _portClassName_1 = this._roomExtensions.getPortClassName(item);
- CharSequence _invokeSetter_2 = this._procedureHelpers.invokeSetter(_name_15, _portClassName_1, value_1);
- _builder.append(_invokeSetter_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _startsWith_1 = value_1.startsWith("{");
- if (_startsWith_1) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(refToItem, " ");
- _builder.append(".");
- String _name_16 = a_1.getName();
- ActorClass _actorClass_6 = ai_3.getActorClass();
- String _name_17 = _actorClass_6.getName();
- RefableType _refType_2 = a_1.getRefType();
- DataType _type_2 = _refType_2.getType();
- String _typeName_2 = this._typeHelpers.typeName(_type_2);
- String _plus_6 = ("new " + _typeName_2);
- String _plus_7 = (_plus_6 + "[]");
- String _plus_8 = (_plus_7 + value_1);
- CharSequence _invokeSetter_3 = this._procedureHelpers.invokeSetter(_name_16, _name_17, _plus_8);
- _builder.append(_invokeSetter_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- RefableType _refType_3 = a_1.getRefType();
- DataType _type_3 = _refType_3.getType();
- String _typeName_3 = this._typeHelpers.typeName(_type_3);
- _builder.append(_typeName_3, " ");
- _builder.append("[] array = ");
- _builder.append(refToItem, " ");
- _builder.append(".");
- String _name_18 = a_1.getName();
- ActorClass _actorClass_7 = ai_3.getActorClass();
- String _name_19 = _actorClass_7.getName();
- CharSequence _invokeGetter_2 = this._procedureHelpers.invokeGetter(_name_18, _name_19);
- _builder.append(_invokeGetter_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- int _size_2 = a_1.getSize();
- _builder.append(_size_2, " ");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("array[i] = ");
- _builder.append(value_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// create the subsystem system port\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("0, //local ID");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// own addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
- boolean _hasElements_4 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_10) {
- if (!_hasElements_4) {
- _hasElements_4 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
- _builder.append(_indexOf_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// peer addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
- boolean _hasElements_5 = false;
- for(final ActorInstance ai_5 : _allContainedInstances_12) {
- if (!_hasElements_5) {
- _hasElements_5 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_");
- String _path_10 = ai_5.getPath();
- String _pathName_8 = this._roomExtensions.getPathName(_path_10);
- _builder.append(_pathName_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("});");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.LiteralArray;
+import org.eclipse.etrice.core.config.PortInstanceConfig;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.LogicalThread;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.Indexed;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ConfigExtension _configExtension;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @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._roomExtensions.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this._roomExtensions.getPath(_subSystemClass_1);
+ String path = (_generationTargetPath + _path);
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String file = this._javaExtensions.getJavaFileName(_subSystemClass_2);
+ String _plus = ("generating SubSystemClass implementation: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ CharSequence _generate = this.generate(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.newLine();
+ _builder.newLine();
+ EList<RoomModel> models = root.getReferencedModels(cc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(cc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = comp.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" extends SubSystemClassBase{");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_2 = comp.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("(IRTObject parent, String name) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(parent, name);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void instantiateMessageServices(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
+ _builder.newLine();
+ {
+ EList<LogicalThread> _threads = cc.getThreads();
+ for(final LogicalThread thread : _threads) {
+ _builder.append("\t\t");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
+ EList<LogicalThread> _threads_1 = cc.getThreads();
+ int _indexOf = _threads_1.indexOf(thread);
+ int _plus = (_indexOf + 1);
+ _builder.append(_plus, " ");
+ _builder.append(", 0),\"MessageService_");
+ String _name_3 = thread.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", ");
+ int _prio = thread.getPrio();
+ _builder.append(_prio, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void instantiateActors(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// all addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// Addresses for the Subsystem Systemport");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ int _maxObjId = comp.getMaxObjId();
+ Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
+ for(final Indexed<ActorInstance> ai : _indexed) {
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
+ ActorInstance _value = ai.getValue();
+ int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
+ _builder.append(_indexOf_1, " ");
+ _builder.append(" = new Address(0,0,");
+ int _index1 = ai.getIndex1();
+ _builder.append(_index1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_2) {
+ _builder.append("\t\t");
+ _builder.append("// actor instance ");
+ String _path = ai_1.getPath();
+ _builder.append(_path, " ");
+ _builder.append(" itself => Systemport Address");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_1 = ai_1.getPath();
+ String _pathName = this._roomExtensions.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId = ai_1.getThreadId();
+ _builder.append(_threadId, " ");
+ _builder.append(",");
+ int _objId = ai_1.getObjId();
+ _builder.append(_objId, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("// interface items of ");
+ String _path_2 = ai_1.getPath();
+ _builder.append(_path_2, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers) {
+ _builder.append("\t\t");
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int i = _peers_1.indexOf(peer);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_3 = pi.getPath();
+ String _pathName_1 = this._roomExtensions.getPathName(_path_3);
+ _builder.append(_pathName_1, " ");
+ _builder.append("_");
+ _builder.append(i, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId_1 = pi.getThreadId();
+ _builder.append(_threadId_1, " ");
+ _builder.append(",");
+ int _objId_1 = pi.getObjId();
+ int _plus_1 = (_objId_1 + i);
+ _builder.append(_plus_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_4 = pi.getPath();
+ String _pathName_2 = this._roomExtensions.getPathName(_path_4);
+ _builder.append(_pathName_2, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId_2 = ai_1.getThreadId();
+ _builder.append(_threadId_2, " ");
+ _builder.append(",");
+ int _objId_2 = pi.getObjId();
+ _builder.append(_objId_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// instantiate all actor instances");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("instances = new ActorClassBase[");
+ EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
+ int _size = _allContainedInstances_3.size();
+ _builder.append(_size, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_4) {
+ _builder.append("\t\t");
+ _builder.append("instances[");
+ EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
+ int _indexOf_2 = _allContainedInstances_5.indexOf(ai_2);
+ _builder.append(_indexOf_2, " ");
+ _builder.append("] = new ");
+ ActorClass _actorClass = ai_2.getActorClass();
+ String _name_4 = _actorClass.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ {
+ EObject _eContainer = ai_2.eContainer();
+ if ((_eContainer instanceof SubSystemInstance)) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("this,");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("instances[");
+ EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
+ EObject _eContainer_1 = ai_2.eContainer();
+ int _indexOf_3 = _allContainedInstances_6.indexOf(_eContainer_1);
+ _builder.append(_indexOf_3, " ");
+ _builder.append("],");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\"");
+ String _name_5 = ai_2.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\",");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// own interface item addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("new Address[][] {{addr_item_");
+ String _path_5 = ai_2.getPath();
+ String _pathName_3 = this._roomExtensions.getPathName(_path_5);
+ _builder.append(_pathName_3, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
+ boolean _hasElements = false;
+ for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _isReplicated_1 = pi_1.isReplicated();
+ if (_isReplicated_1) {
+ {
+ EList<InterfaceItemInstance> _peers_2 = pi_1.getPeers();
+ boolean _isEmpty_1 = _peers_2.isEmpty();
+ if (_isEmpty_1) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
+ boolean _hasElements_1 = false;
+ for(final InterfaceItemInstance peer_1 : _peers_3) {
+ if (!_hasElements_1) {
+ _hasElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_6 = pi_1.getPath();
+ String _pathName_4 = this._roomExtensions.getPathName(_path_6);
+ _builder.append(_pathName_4, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
+ int _indexOf_4 = _peers_4.indexOf(peer_1);
+ _builder.append(_indexOf_4, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_7 = pi_1.getPath();
+ String _pathName_5 = this._roomExtensions.getPathName(_path_7);
+ _builder.append(_pathName_5, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("},");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// peer interface item addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("new Address[][] {{addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
+ int _indexOf_5 = _allContainedInstances_7.indexOf(ai_2);
+ _builder.append(_indexOf_5, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
+ boolean _not_1 = (!_isEmpty_2);
+ if (_not_1) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
+ boolean _hasElements_2 = false;
+ for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
+ if (!_hasElements_2) {
+ _hasElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _and = false;
+ boolean _isReplicated_2 = pi_2.isReplicated();
+ if (!_isReplicated_2) {
+ _and = false;
+ } else {
+ EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
+ boolean _isEmpty_3 = _peers_5.isEmpty();
+ _and = (_isReplicated_2 && _isEmpty_3);
+ }
+ if (_and) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
+ boolean _isEmpty_4 = _peers_6.isEmpty();
+ if (_isEmpty_4) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ {
+ EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
+ boolean _hasElements_3 = false;
+ for(final InterfaceItemInstance pp : _peers_7) {
+ if (!_hasElements_3) {
+ _hasElements_3 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _isReplicated_3 = pp.isReplicated();
+ if (_isReplicated_3) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_8 = pp.getPath();
+ String _pathName_6 = this._roomExtensions.getPathName(_path_8);
+ _builder.append(_pathName_6, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
+ int _indexOf_6 = _peers_8.indexOf(pi_2);
+ _builder.append(_indexOf_6, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_9 = pp.getPath();
+ String _pathName_7 = this._roomExtensions.getPathName(_path_9);
+ _builder.append(_pathName_7, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("); ");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// apply instance attribute configurations");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_3 : _allContainedInstances_8) {
+ _builder.append("\t\t");
+ List<AttrInstanceConfig> attrConfigs = this._configExtension.getConfigAttributes(ai_3);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ List<PortInstanceConfig> portConfigs = this._configExtension.getConfigPorts(ai_3);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _or = false;
+ boolean _isEmpty_5 = attrConfigs.isEmpty();
+ boolean _not_2 = (!_isEmpty_5);
+ if (_not_2) {
+ _or = true;
+ } else {
+ boolean _isEmpty_6 = portConfigs.isEmpty();
+ boolean _not_3 = (!_isEmpty_6);
+ _or = (_not_2 || _not_3);
+ }
+ if (_or) {
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String aiName = "inst";
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ ActorClass _actorClass_1 = ai_3.getActorClass();
+ String _name_6 = _actorClass_1.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(" ");
+ _builder.append(aiName, " ");
+ _builder.append(" = (");
+ ActorClass _actorClass_2 = ai_3.getActorClass();
+ String _name_7 = _actorClass_2.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(") instances[");
+ EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
+ int _indexOf_7 = _allContainedInstances_9.indexOf(ai_3);
+ _builder.append(_indexOf_7, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ {
+ for(final AttrInstanceConfig attrConfig : attrConfigs) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ Attribute a = attrConfig.getAttribute();
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ LiteralArray _value_1 = attrConfig.getValue();
+ String value = this._configExtension.stringValue(_value_1, a);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isArray = this._configExtension.isArray(a);
+ boolean _not_4 = (!_isArray);
+ if (_not_4) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ String _name_8 = a.getName();
+ ActorClass _actorClass_3 = ai_3.getActorClass();
+ String _name_9 = _actorClass_3.getName();
+ CharSequence _invokeSetter = this._procedureHelpers.invokeSetter(_name_8, _name_9, value);
+ _builder.append(_invokeSetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _startsWith = value.startsWith("{");
+ if (_startsWith) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ String _name_10 = a.getName();
+ ActorClass _actorClass_4 = ai_3.getActorClass();
+ String _name_11 = _actorClass_4.getName();
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String _plus_2 = ("new " + _typeName);
+ String _plus_3 = (_plus_2 + "[]");
+ String _plus_4 = (_plus_3 + value);
+ CharSequence _invokeSetter_1 = this._procedureHelpers.invokeSetter(_name_10, _name_11, _plus_4);
+ _builder.append(_invokeSetter_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, " ");
+ _builder.append("[] array = ");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ String _name_12 = a.getName();
+ ActorClass _actorClass_5 = ai_3.getActorClass();
+ String _name_13 = _actorClass_5.getName();
+ CharSequence _invokeGetter = this._procedureHelpers.invokeGetter(_name_12, _name_13);
+ _builder.append(_invokeGetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ int _size_1 = a.getSize();
+ _builder.append(_size_1, " ");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("array[i] = ");
+ _builder.append(value, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ {
+ for(final PortInstanceConfig portConfig : portConfigs) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ InterfaceItem item = portConfig.getItem();
+ _builder.newLineIfNotEmpty();
+ {
+ EList<AttrInstanceConfig> _attributes = portConfig.getAttributes();
+ for(final AttrInstanceConfig attrConfig_1 : _attributes) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ Attribute a_1 = attrConfig_1.getAttribute();
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ LiteralArray _value_2 = attrConfig_1.getValue();
+ String value_1 = this._configExtension.stringValue(_value_2, a_1);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String _plus_5 = (aiName + ".");
+ String _name_14 = item.getName();
+ String _portClassName = this._roomExtensions.getPortClassName(item);
+ CharSequence _invokeGetter_1 = this._procedureHelpers.invokeGetter(_name_14, _portClassName);
+ String refToItem = (_plus_5 + _invokeGetter_1);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isArray_1 = this._configExtension.isArray(a_1);
+ boolean _not_5 = (!_isArray_1);
+ if (_not_5) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(refToItem, " ");
+ _builder.append(".");
+ String _name_15 = a_1.getName();
+ String _portClassName_1 = this._roomExtensions.getPortClassName(item);
+ CharSequence _invokeSetter_2 = this._procedureHelpers.invokeSetter(_name_15, _portClassName_1, value_1);
+ _builder.append(_invokeSetter_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _startsWith_1 = value_1.startsWith("{");
+ if (_startsWith_1) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(refToItem, " ");
+ _builder.append(".");
+ String _name_16 = a_1.getName();
+ ActorClass _actorClass_6 = ai_3.getActorClass();
+ String _name_17 = _actorClass_6.getName();
+ RefableType _refType_2 = a_1.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_2 = this._typeHelpers.typeName(_type_2);
+ String _plus_6 = ("new " + _typeName_2);
+ String _plus_7 = (_plus_6 + "[]");
+ String _plus_8 = (_plus_7 + value_1);
+ CharSequence _invokeSetter_3 = this._procedureHelpers.invokeSetter(_name_16, _name_17, _plus_8);
+ _builder.append(_invokeSetter_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ RefableType _refType_3 = a_1.getRefType();
+ DataType _type_3 = _refType_3.getType();
+ String _typeName_3 = this._typeHelpers.typeName(_type_3);
+ _builder.append(_typeName_3, " ");
+ _builder.append("[] array = ");
+ _builder.append(refToItem, " ");
+ _builder.append(".");
+ String _name_18 = a_1.getName();
+ ActorClass _actorClass_7 = ai_3.getActorClass();
+ String _name_19 = _actorClass_7.getName();
+ CharSequence _invokeGetter_2 = this._procedureHelpers.invokeGetter(_name_18, _name_19);
+ _builder.append(_invokeGetter_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ int _size_2 = a_1.getSize();
+ _builder.append(_size_2, " ");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("array[i] = ");
+ _builder.append(value_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// create the subsystem system port\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("0, //local ID");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("// own addresses");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("new Address[]{");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
+ boolean _hasElements_4 = false;
+ for(final ActorInstance ai_4 : _allContainedInstances_10) {
+ if (!_hasElements_4) {
+ _hasElements_4 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
+ int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
+ _builder.append(_indexOf_8, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("},");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("// peer addresses");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("new Address[]{");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
+ boolean _hasElements_5 = false;
+ for(final ActorInstance ai_5 : _allContainedInstances_12) {
+ if (!_hasElements_5) {
+ _hasElements_5 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_");
+ String _path_10 = ai_5.getPath();
+ String _pathName_8 = this._roomExtensions.getPathName(_path_10);
+ _builder.append(_pathName_8, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("});");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
index 99ffe08aa..27337ee77 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
@@ -1,151 +1,151 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-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 _plus = (_generationTargetPath + _path);
- this.fileAccess.setOutputPath(_plus);
- String _name = sc.getName();
- String _plus_1 = (_name + "Runner.java");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- CharSequence _generate = this.generate(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_plus_1, _generate);
- }
- }
- }
-
- public CharSequence generate(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
- 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 = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = ssc.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class ");
- String _name_2 = ssc.getName();
- String _plus = (_name_2 + "Runner");
- _builder.append(_plus, "");
- _builder.append(" extends SubSystemRunnerBase {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("static ");
- String _name_3 = ssc.getName();
- _builder.append(_name_3, " ");
- _builder.append(" main_component = new ");
- String _name_4 = ssc.getName();
- _builder.append(_name_4, " ");
- _builder.append("(null, \"");
- String _name_5 = ssc.getName();
- _builder.append(_name_5, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _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.append("\t");
- _builder.append("public static void main(String[] args) {");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(\"*** T H E B E G I N ***\");");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.init(); // lifecycle init");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.start(); // lifecycle start");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// application runs until quit ");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("waitForQuit();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// end the lifecycle");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.stop(); // lifecycle stop");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.destroy(); // lifecycle destroy");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(\"*** T H E E N D ***\");");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+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 _plus = (_generationTargetPath + _path);
+ this.fileAccess.setOutputPath(_plus);
+ String _name = sc.getName();
+ String _plus_1 = (_name + "Runner.java");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ CharSequence _generate = this.generate(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_plus_1, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
+ 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 = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_2 = ssc.getName();
+ String _plus = (_name_2 + "Runner");
+ _builder.append(_plus, "");
+ _builder.append(" extends SubSystemRunnerBase {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("static ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" main_component = new ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(null, \"");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _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.append("\t");
+ _builder.append("public static void main(String[] args) {");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"*** T H E B E G I N ***\");");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.init(); // lifecycle init");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.start(); // lifecycle start");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// application runs until quit ");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("waitForQuit();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// end the lifecycle");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.stop(); // lifecycle stop");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.destroy(); // lifecycle destroy");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"*** T H E E N D ***\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
index 08b4c2bd3..87c02e90f 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
@@ -14,47 +14,47 @@
collection of convenience functions for code generation
*/
-package org.eclipse.etrice.generator.generic
-
-import com.google.inject.Singleton
-import java.io.File
-import java.util.ArrayList
-import java.util.List
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.etrice.core.genmodel.etricegen.ActiveTrigger
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedRefinedState
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance
-import org.eclipse.etrice.core.genmodel.etricegen.PortInstance
-import org.eclipse.etrice.core.genmodel.etricegen.SAPInstance
-import org.eclipse.etrice.core.genmodel.etricegen.ServiceImplInstance
-import org.eclipse.etrice.core.genmodel.etricegen.TransitionChain
-import org.eclipse.etrice.core.room.ActorClass
-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.ExternalPort
-import org.eclipse.etrice.core.room.InitialTransition
-import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.core.room.MessageHandler
-import org.eclipse.etrice.core.room.Port
-import org.eclipse.etrice.core.room.PortClass
-import org.eclipse.etrice.core.room.ProtocolClass
-import org.eclipse.etrice.core.room.RoomClass
-import org.eclipse.etrice.core.room.RoomModel
-import org.eclipse.etrice.core.room.SAPRef
-import org.eclipse.etrice.core.room.SPPRef
-import org.eclipse.etrice.core.room.ServiceImplementation
-import org.eclipse.etrice.core.room.SimpleState
-import org.eclipse.etrice.core.room.State
-import org.eclipse.etrice.core.room.StateGraph
-import org.eclipse.etrice.core.room.Transition
-import org.eclipse.etrice.core.room.TransitionPoint
-import org.eclipse.etrice.core.room.Trigger
-
-import static org.eclipse.etrice.generator.base.CodegenHelpers.*
-
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+package org.eclipse.etrice.generator.generic
+
+import com.google.inject.Singleton
+import java.io.File
+import java.util.ArrayList
+import java.util.List
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.etrice.core.genmodel.etricegen.ActiveTrigger
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedRefinedState
+import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance
+import org.eclipse.etrice.core.genmodel.etricegen.PortInstance
+import org.eclipse.etrice.core.genmodel.etricegen.SAPInstance
+import org.eclipse.etrice.core.genmodel.etricegen.ServiceImplInstance
+import org.eclipse.etrice.core.genmodel.etricegen.TransitionChain
+import org.eclipse.etrice.core.room.ActorClass
+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.ExternalPort
+import org.eclipse.etrice.core.room.InitialTransition
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.MessageHandler
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.PortClass
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.RoomClass
+import org.eclipse.etrice.core.room.RoomModel
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
+import org.eclipse.etrice.core.room.ServiceImplementation
+import org.eclipse.etrice.core.room.SimpleState
+import org.eclipse.etrice.core.room.State
+import org.eclipse.etrice.core.room.StateGraph
+import org.eclipse.etrice.core.room.Transition
+import org.eclipse.etrice.core.room.TransitionPoint
+import org.eclipse.etrice.core.room.Trigger
+
+import static org.eclipse.etrice.generator.base.CodegenHelpers.*
+
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class RoomExtensions {
@@ -577,4 +577,4 @@ class RoomExtensions {
return result;
}
-}
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
index e930c7ba2..6a491eda3 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
@@ -1,270 +1,270 @@
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.config.ActorClassConfig;
-import org.eclipse.etrice.core.config.ActorInstanceConfig;
-import org.eclipse.etrice.core.config.AttrClassConfig;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.BooleanLiteral;
-import org.eclipse.etrice.core.config.IntLiteral;
-import org.eclipse.etrice.core.config.Literal;
-import org.eclipse.etrice.core.config.LiteralArray;
-import org.eclipse.etrice.core.config.PortClassConfig;
-import org.eclipse.etrice.core.config.PortInstanceConfig;
-import org.eclipse.etrice.core.config.ProtocolClassConfig;
-import org.eclipse.etrice.core.config.RealLiteral;
-import org.eclipse.etrice.core.config.StringLiteral;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.LiteralType;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.generator.base.ConfigHelper;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class ConfigExtension {
- @Inject
- private ILanguageExtension languageExt;
-
- public String getInitValue(final Attribute a) {
- String value = this.getConfigDefaultValue(a);
- boolean _equals = Objects.equal(value, null);
- if (_equals) {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- value = _defaultValueLiteral;
- }
- return value;
- }
-
- public String getConfigDefaultValue(final Attribute attr) {
- EObject _eContainer = attr.eContainer();
- if ((_eContainer instanceof ActorClass)) {
- EObject _eContainer_1 = attr.eContainer();
- ActorClass ac = ((ActorClass) _eContainer_1);
- ActorClassConfig _classConfig = this.getClassConfig(ac);
- EList<AttrClassConfig> _attributes = _classConfig==null?(EList<AttrClassConfig>)null:_classConfig.getAttributes();
- return _attributes==null?(String)null:this.getConfigValue(_attributes, attr);
- } else {
- EObject _eContainer_2 = attr.eContainer();
- if ((_eContainer_2 instanceof PortClass)) {
- EObject _eContainer_3 = attr.eContainer();
- PortClass pc = ((PortClass) _eContainer_3);
- EObject _eContainer_4 = pc.eContainer();
- ProtocolClass protocol = ((ProtocolClass) _eContainer_4);
- ProtocolClassConfig prcConfig = this.getProtocolConfig(((ProtocolClass) protocol));
- PortClass _regular = protocol.getRegular();
- boolean _equals = pc.equals(_regular);
- if (_equals) {
- PortClassConfig _regular_1 = prcConfig==null?(PortClassConfig)null:prcConfig.getRegular();
- EList<AttrClassConfig> _attributes_1 = _regular_1==null?(EList<AttrClassConfig>)null:_regular_1.getAttributes();
- return _attributes_1==null?(String)null:this.getConfigValue(_attributes_1, attr);
- } else {
- PortClassConfig _conjugated = prcConfig==null?(PortClassConfig)null:prcConfig.getConjugated();
- EList<AttrClassConfig> _attributes_2 = _conjugated==null?(EList<AttrClassConfig>)null:_conjugated.getAttributes();
- return _attributes_2==null?(String)null:this.getConfigValue(_attributes_2, attr);
- }
- }
- }
- return null;
- }
-
- public String getConfigValue(final List<AttrClassConfig> attrConfigs, final Attribute attr) {
- final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
- public Boolean apply(final AttrClassConfig attrConfig) {
- Attribute _attribute = attrConfig.getAttribute();
- boolean _equals = _attribute.equals(attr);
- return Boolean.valueOf(_equals);
- }
- };
- AttrClassConfig _findFirst = IterableExtensions.<AttrClassConfig>findFirst(attrConfigs, _function);
- LiteralArray _value = _findFirst==null?(LiteralArray)null:_findFirst.getValue();
- String _stringValue = _value==null?(String)null:this.stringValue(_value, attr);
- return _stringValue;
- }
-
- public ActorClassConfig getClassConfig(final ActorClass ac) {
- ActorClassConfig _get = ConfigHelper.actorMap.get(ac);
- return _get;
- }
-
- public ProtocolClassConfig getProtocolConfig(final ProtocolClass prc) {
- ProtocolClassConfig _get = ConfigHelper.protocolMap.get(prc);
- return _get;
- }
-
- public String stringValue(final LiteralArray literalArray, final Attribute attr) {
- String string = "";
- boolean _and = false;
- boolean _isArray = this.isArray(attr);
- if (!_isArray) {
- _and = false;
- } else {
- EList<Literal> _literals = literalArray.getLiterals();
- int _size = _literals.size();
- boolean _greaterThan = (_size > 1);
- _and = (_isArray && _greaterThan);
- }
- if (_and) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("{ ");
- {
- EList<Literal> _literals_1 = literalArray.getLiterals();
- for(final Literal literal : _literals_1) {
- String _stringValue = this.stringValue(literal);
- _builder.append(_stringValue, "");
- _builder.append(", ");
- }
- }
- String _plus = (string + _builder.toString());
- string = _plus;
- int _length = string.length();
- int _minus = (_length - 2);
- String _substring = string.substring(0, _minus);
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append(" ");
- _builder_1.append("}");
- String _plus_1 = (_substring + _builder_1.toString());
- string = _plus_1;
- } else {
- EList<Literal> _literals_2 = literalArray.getLiterals();
- Literal _get = _literals_2.get(0);
- String _stringValue_1 = this.stringValue(_get);
- string = _stringValue_1;
- }
- return string;
- }
-
- private String stringValue(final Literal literal) {
- String _switchResult = null;
- boolean _matched = false;
- if (!_matched) {
- if (literal instanceof BooleanLiteral) {
- final BooleanLiteral _booleanLiteral = (BooleanLiteral)literal;
- _matched=true;
- boolean _isIsTrue = _booleanLiteral.isIsTrue();
- String _string = Boolean.valueOf(_isIsTrue).toString();
- _switchResult = _string;
- }
- }
- if (!_matched) {
- if (literal instanceof IntLiteral) {
- final IntLiteral _intLiteral = (IntLiteral)literal;
- _matched=true;
- int _value = _intLiteral.getValue();
- String _string = Integer.valueOf(_value).toString();
- _switchResult = _string;
- }
- }
- if (!_matched) {
- if (literal instanceof RealLiteral) {
- final RealLiteral _realLiteral = (RealLiteral)literal;
- _matched=true;
- double _value = _realLiteral.getValue();
- String _string = Double.valueOf(_value).toString();
- _switchResult = _string;
- }
- }
- if (!_matched) {
- if (literal instanceof StringLiteral) {
- final StringLiteral _stringLiteral = (StringLiteral)literal;
- _matched=true;
- String _xblockexpression = null;
- {
- String _value = _stringLiteral.getValue();
- String value = _value.toString();
- String _xifexpression = null;
- int _length = value.length();
- boolean _equals = (_length == 1);
- if (_equals) {
- String _plus = ("\'" + value);
- String _plus_1 = (_plus + "\'");
- _xifexpression = _plus_1;
- } else {
- String _charArrayExpr = this.languageExt.toCharArrayExpr(value);
- _xifexpression = _charArrayExpr;
- }
- _xblockexpression = (_xifexpression);
- }
- _switchResult = _xblockexpression;
- }
- }
- return _switchResult;
- }
-
- public boolean isArray(final Attribute attr) {
- boolean _xblockexpression = false;
- {
- boolean isChar = false;
- RefableType _refType = attr.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof PrimitiveType)) {
- RefableType _refType_1 = attr.getRefType();
- DataType _type_1 = _refType_1.getType();
- PrimitiveType primitive = ((PrimitiveType) _type_1);
- LiteralType _type_2 = primitive.getType();
- boolean _equals = Objects.equal(_type_2, LiteralType.CHAR);
- isChar = _equals;
- }
- boolean _and = false;
- boolean _not = (!isChar);
- if (!_not) {
- _and = false;
- } else {
- int _size = attr.getSize();
- boolean _greaterThan = (_size > 0);
- _and = (_not && _greaterThan);
- }
- _xblockexpression = (_and);
- }
- return _xblockexpression;
- }
-
- public List<AttrInstanceConfig> getConfigAttributes(final ActorInstance ai) {
- ArrayList<AttrInstanceConfig> _arrayList = new ArrayList<AttrInstanceConfig>();
- ArrayList<AttrInstanceConfig> attrConfigs = _arrayList;
- String _path = ai.getPath();
- ActorInstanceConfig config = ConfigHelper.instanceMap.get(_path);
- boolean _notEquals = (!Objects.equal(config, null));
- if (_notEquals) {
- EList<AttrInstanceConfig> _attributes = config.getAttributes();
- for (final AttrInstanceConfig attrConfig : _attributes) {
- LiteralArray _value = attrConfig.getValue();
- boolean _notEquals_1 = (!Objects.equal(_value, null));
- if (_notEquals_1) {
- attrConfigs.add(attrConfig);
- }
- }
- }
- return attrConfigs;
- }
-
- public List<PortInstanceConfig> getConfigPorts(final ActorInstance ai) {
- ArrayList<PortInstanceConfig> _arrayList = new ArrayList<PortInstanceConfig>();
- ArrayList<PortInstanceConfig> portConfigs = _arrayList;
- String _path = ai.getPath();
- ActorInstanceConfig config = ConfigHelper.instanceMap.get(_path);
- boolean _notEquals = (!Objects.equal(config, null));
- if (_notEquals) {
- EList<PortInstanceConfig> _ports = config.getPorts();
- for (final PortInstanceConfig portConfig : _ports) {
- portConfigs.add(portConfig);
- }
- }
- return portConfigs;
- }
-}
+package org.eclipse.etrice.generator.generic;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.config.ActorClassConfig;
+import org.eclipse.etrice.core.config.ActorInstanceConfig;
+import org.eclipse.etrice.core.config.AttrClassConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.BooleanLiteral;
+import org.eclipse.etrice.core.config.IntLiteral;
+import org.eclipse.etrice.core.config.Literal;
+import org.eclipse.etrice.core.config.LiteralArray;
+import org.eclipse.etrice.core.config.PortClassConfig;
+import org.eclipse.etrice.core.config.PortInstanceConfig;
+import org.eclipse.etrice.core.config.ProtocolClassConfig;
+import org.eclipse.etrice.core.config.RealLiteral;
+import org.eclipse.etrice.core.config.StringLiteral;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.LiteralType;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.generator.base.ConfigHelper;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ConfigExtension {
+ @Inject
+ private ILanguageExtension languageExt;
+
+ public String getInitValue(final Attribute a) {
+ String value = this.getConfigDefaultValue(a);
+ boolean _equals = Objects.equal(value, null);
+ if (_equals) {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ value = _defaultValueLiteral;
+ }
+ return value;
+ }
+
+ public String getConfigDefaultValue(final Attribute attr) {
+ EObject _eContainer = attr.eContainer();
+ if ((_eContainer instanceof ActorClass)) {
+ EObject _eContainer_1 = attr.eContainer();
+ ActorClass ac = ((ActorClass) _eContainer_1);
+ ActorClassConfig _classConfig = this.getClassConfig(ac);
+ EList<AttrClassConfig> _attributes = _classConfig==null?(EList<AttrClassConfig>)null:_classConfig.getAttributes();
+ return _attributes==null?(String)null:this.getConfigValue(_attributes, attr);
+ } else {
+ EObject _eContainer_2 = attr.eContainer();
+ if ((_eContainer_2 instanceof PortClass)) {
+ EObject _eContainer_3 = attr.eContainer();
+ PortClass pc = ((PortClass) _eContainer_3);
+ EObject _eContainer_4 = pc.eContainer();
+ ProtocolClass protocol = ((ProtocolClass) _eContainer_4);
+ ProtocolClassConfig prcConfig = this.getProtocolConfig(((ProtocolClass) protocol));
+ PortClass _regular = protocol.getRegular();
+ boolean _equals = pc.equals(_regular);
+ if (_equals) {
+ PortClassConfig _regular_1 = prcConfig==null?(PortClassConfig)null:prcConfig.getRegular();
+ EList<AttrClassConfig> _attributes_1 = _regular_1==null?(EList<AttrClassConfig>)null:_regular_1.getAttributes();
+ return _attributes_1==null?(String)null:this.getConfigValue(_attributes_1, attr);
+ } else {
+ PortClassConfig _conjugated = prcConfig==null?(PortClassConfig)null:prcConfig.getConjugated();
+ EList<AttrClassConfig> _attributes_2 = _conjugated==null?(EList<AttrClassConfig>)null:_conjugated.getAttributes();
+ return _attributes_2==null?(String)null:this.getConfigValue(_attributes_2, attr);
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getConfigValue(final List<AttrClassConfig> attrConfigs, final Attribute attr) {
+ final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig attrConfig) {
+ Attribute _attribute = attrConfig.getAttribute();
+ boolean _equals = _attribute.equals(attr);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ AttrClassConfig _findFirst = IterableExtensions.<AttrClassConfig>findFirst(attrConfigs, _function);
+ LiteralArray _value = _findFirst==null?(LiteralArray)null:_findFirst.getValue();
+ String _stringValue = _value==null?(String)null:this.stringValue(_value, attr);
+ return _stringValue;
+ }
+
+ public ActorClassConfig getClassConfig(final ActorClass ac) {
+ ActorClassConfig _get = ConfigHelper.actorMap.get(ac);
+ return _get;
+ }
+
+ public ProtocolClassConfig getProtocolConfig(final ProtocolClass prc) {
+ ProtocolClassConfig _get = ConfigHelper.protocolMap.get(prc);
+ return _get;
+ }
+
+ public String stringValue(final LiteralArray literalArray, final Attribute attr) {
+ String string = "";
+ boolean _and = false;
+ boolean _isArray = this.isArray(attr);
+ if (!_isArray) {
+ _and = false;
+ } else {
+ EList<Literal> _literals = literalArray.getLiterals();
+ int _size = _literals.size();
+ boolean _greaterThan = (_size > 1);
+ _and = (_isArray && _greaterThan);
+ }
+ if (_and) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("{ ");
+ {
+ EList<Literal> _literals_1 = literalArray.getLiterals();
+ for(final Literal literal : _literals_1) {
+ String _stringValue = this.stringValue(literal);
+ _builder.append(_stringValue, "");
+ _builder.append(", ");
+ }
+ }
+ String _plus = (string + _builder.toString());
+ string = _plus;
+ int _length = string.length();
+ int _minus = (_length - 2);
+ String _substring = string.substring(0, _minus);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append(" ");
+ _builder_1.append("}");
+ String _plus_1 = (_substring + _builder_1.toString());
+ string = _plus_1;
+ } else {
+ EList<Literal> _literals_2 = literalArray.getLiterals();
+ Literal _get = _literals_2.get(0);
+ String _stringValue_1 = this.stringValue(_get);
+ string = _stringValue_1;
+ }
+ return string;
+ }
+
+ private String stringValue(final Literal literal) {
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (literal instanceof BooleanLiteral) {
+ final BooleanLiteral _booleanLiteral = (BooleanLiteral)literal;
+ _matched=true;
+ boolean _isIsTrue = _booleanLiteral.isIsTrue();
+ String _string = Boolean.valueOf(_isIsTrue).toString();
+ _switchResult = _string;
+ }
+ }
+ if (!_matched) {
+ if (literal instanceof IntLiteral) {
+ final IntLiteral _intLiteral = (IntLiteral)literal;
+ _matched=true;
+ int _value = _intLiteral.getValue();
+ String _string = Integer.valueOf(_value).toString();
+ _switchResult = _string;
+ }
+ }
+ if (!_matched) {
+ if (literal instanceof RealLiteral) {
+ final RealLiteral _realLiteral = (RealLiteral)literal;
+ _matched=true;
+ double _value = _realLiteral.getValue();
+ String _string = Double.valueOf(_value).toString();
+ _switchResult = _string;
+ }
+ }
+ if (!_matched) {
+ if (literal instanceof StringLiteral) {
+ final StringLiteral _stringLiteral = (StringLiteral)literal;
+ _matched=true;
+ String _xblockexpression = null;
+ {
+ String _value = _stringLiteral.getValue();
+ String value = _value.toString();
+ String _xifexpression = null;
+ int _length = value.length();
+ boolean _equals = (_length == 1);
+ if (_equals) {
+ String _plus = ("\'" + value);
+ String _plus_1 = (_plus + "\'");
+ _xifexpression = _plus_1;
+ } else {
+ String _charArrayExpr = this.languageExt.toCharArrayExpr(value);
+ _xifexpression = _charArrayExpr;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ _switchResult = _xblockexpression;
+ }
+ }
+ return _switchResult;
+ }
+
+ public boolean isArray(final Attribute attr) {
+ boolean _xblockexpression = false;
+ {
+ boolean isChar = false;
+ RefableType _refType = attr.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof PrimitiveType)) {
+ RefableType _refType_1 = attr.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ PrimitiveType primitive = ((PrimitiveType) _type_1);
+ LiteralType _type_2 = primitive.getType();
+ boolean _equals = Objects.equal(_type_2, LiteralType.CHAR);
+ isChar = _equals;
+ }
+ boolean _and = false;
+ boolean _not = (!isChar);
+ if (!_not) {
+ _and = false;
+ } else {
+ int _size = attr.getSize();
+ boolean _greaterThan = (_size > 0);
+ _and = (_not && _greaterThan);
+ }
+ _xblockexpression = (_and);
+ }
+ return _xblockexpression;
+ }
+
+ public List<AttrInstanceConfig> getConfigAttributes(final ActorInstance ai) {
+ ArrayList<AttrInstanceConfig> _arrayList = new ArrayList<AttrInstanceConfig>();
+ ArrayList<AttrInstanceConfig> attrConfigs = _arrayList;
+ String _path = ai.getPath();
+ ActorInstanceConfig config = ConfigHelper.instanceMap.get(_path);
+ boolean _notEquals = (!Objects.equal(config, null));
+ if (_notEquals) {
+ EList<AttrInstanceConfig> _attributes = config.getAttributes();
+ for (final AttrInstanceConfig attrConfig : _attributes) {
+ LiteralArray _value = attrConfig.getValue();
+ boolean _notEquals_1 = (!Objects.equal(_value, null));
+ if (_notEquals_1) {
+ attrConfigs.add(attrConfig);
+ }
+ }
+ }
+ return attrConfigs;
+ }
+
+ public List<PortInstanceConfig> getConfigPorts(final ActorInstance ai) {
+ ArrayList<PortInstanceConfig> _arrayList = new ArrayList<PortInstanceConfig>();
+ ArrayList<PortInstanceConfig> portConfigs = _arrayList;
+ String _path = ai.getPath();
+ ActorInstanceConfig config = ConfigHelper.instanceMap.get(_path);
+ boolean _notEquals = (!Objects.equal(config, null));
+ if (_notEquals) {
+ EList<PortInstanceConfig> _ports = config.getPorts();
+ for (final PortInstanceConfig portConfig : _ports) {
+ portConfigs.add(portConfig);
+ }
+ }
+ return portConfigs;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
index fb9ff2024..c7e15e886 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
@@ -1,90 +1,90 @@
-package org.eclipse.etrice.generator.generic;
-
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.util.Tuples;
-
-@SuppressWarnings("all")
-public class GenericActorClassGenerator {
- @Inject
- private ILanguageExtension langExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- public String genInterfaceItemConstants(final ExpandedActorClass xpac, final ActorClass ac) {
- List<Port> _xifexpression = null;
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
- List<Port> _endPorts = this.roomExt.getEndPorts(ac);
- _xifexpression = _endPorts;
- } else {
- List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
- _xifexpression = _allEndPorts;
- }
- List<Port> endPorts = _xifexpression;
- List<SAPRef> _xifexpression_1 = null;
- boolean _usesInheritance_1 = this.langExt.usesInheritance();
- if (_usesInheritance_1) {
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- _xifexpression_1 = _strSAPs;
- } else {
- List<SAPRef> _allSAPs = this.roomExt.getAllSAPs(ac);
- _xifexpression_1 = _allSAPs;
- }
- List<SAPRef> strSAPs = _xifexpression_1;
- List<ServiceImplementation> _xifexpression_2 = null;
- boolean _usesInheritance_2 = this.langExt.usesInheritance();
- if (_usesInheritance_2) {
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- _xifexpression_2 = _serviceImplementations;
- } else {
- List<ServiceImplementation> _allServiceImplementations = this.roomExt.getAllServiceImplementations(ac);
- _xifexpression_2 = _allServiceImplementations;
- }
- List<ServiceImplementation> svcImpls = _xifexpression_2;
- ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
- ArrayList<Pair<String,String>> list = _arrayList;
- for (final Port ep : endPorts) {
- String _name = ep.getName();
- String _plus = ("IFITEM_" + _name);
- int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep);
- int _plus_1 = (1 + _interfaceItemLocalId);
- String _string = Integer.valueOf(_plus_1).toString();
- Pair<String,String> _pair = Tuples.<String, String>pair(_plus, _string);
- list.add(_pair);
- }
- for (final SAPRef sap : strSAPs) {
- String _name_1 = sap.getName();
- String _plus_2 = ("IFITEM_" + _name_1);
- int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap);
- int _plus_3 = (1 + _interfaceItemLocalId_1);
- String _string_1 = Integer.valueOf(_plus_3).toString();
- Pair<String,String> _pair_1 = Tuples.<String, String>pair(_plus_2, _string_1);
- list.add(_pair_1);
- }
- for (final ServiceImplementation svc : svcImpls) {
- SPPRef _spp = svc.getSpp();
- String _name_2 = _spp.getName();
- String _plus_4 = ("IFITEM_" + _name_2);
- SPPRef _spp_1 = svc.getSpp();
- int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_1);
- int _plus_5 = (1 + _interfaceItemLocalId_2);
- String _string_2 = Integer.valueOf(_plus_5).toString();
- Pair<String,String> _pair_2 = Tuples.<String, String>pair(_plus_4, _string_2);
- list.add(_pair_2);
- }
- return this.langExt.genEnumeration("interface_items", list);
- }
-}
+package org.eclipse.etrice.generator.generic;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+
+@SuppressWarnings("all")
+public class GenericActorClassGenerator {
+ @Inject
+ private ILanguageExtension langExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public String genInterfaceItemConstants(final ExpandedActorClass xpac, final ActorClass ac) {
+ List<Port> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ List<Port> _endPorts = this.roomExt.getEndPorts(ac);
+ _xifexpression = _endPorts;
+ } else {
+ List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
+ _xifexpression = _allEndPorts;
+ }
+ List<Port> endPorts = _xifexpression;
+ List<SAPRef> _xifexpression_1 = null;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ _xifexpression_1 = _strSAPs;
+ } else {
+ List<SAPRef> _allSAPs = this.roomExt.getAllSAPs(ac);
+ _xifexpression_1 = _allSAPs;
+ }
+ List<SAPRef> strSAPs = _xifexpression_1;
+ List<ServiceImplementation> _xifexpression_2 = null;
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ if (_usesInheritance_2) {
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ _xifexpression_2 = _serviceImplementations;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations = this.roomExt.getAllServiceImplementations(ac);
+ _xifexpression_2 = _allServiceImplementations;
+ }
+ List<ServiceImplementation> svcImpls = _xifexpression_2;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ for (final Port ep : endPorts) {
+ String _name = ep.getName();
+ String _plus = ("IFITEM_" + _name);
+ int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep);
+ int _plus_1 = (1 + _interfaceItemLocalId);
+ String _string = Integer.valueOf(_plus_1).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_plus, _string);
+ list.add(_pair);
+ }
+ for (final SAPRef sap : strSAPs) {
+ String _name_1 = sap.getName();
+ String _plus_2 = ("IFITEM_" + _name_1);
+ int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap);
+ int _plus_3 = (1 + _interfaceItemLocalId_1);
+ String _string_1 = Integer.valueOf(_plus_3).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_plus_2, _string_1);
+ list.add(_pair_1);
+ }
+ for (final ServiceImplementation svc : svcImpls) {
+ SPPRef _spp = svc.getSpp();
+ String _name_2 = _spp.getName();
+ String _plus_4 = ("IFITEM_" + _name_2);
+ SPPRef _spp_1 = svc.getSpp();
+ int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_1);
+ int _plus_5 = (1 + _interfaceItemLocalId_2);
+ String _string_2 = Integer.valueOf(_plus_5).toString();
+ Pair<String,String> _pair_2 = Tuples.<String, String>pair(_plus_4, _string_2);
+ list.add(_pair_2);
+ }
+ return this.langExt.genEnumeration("interface_items", list);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
index 66a2003d5..01364a614 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
@@ -1,119 +1,119 @@
-package org.eclipse.etrice.generator.generic;
-
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.etrice.core.room.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.util.Tuples;
-
-@SuppressWarnings("all")
-public class GenericProtocolClassGenerator {
- @Inject
- private ILanguageExtension langExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- public String genMessageIDs(final ProtocolClass pc) {
- int offset = 0;
- ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
- ArrayList<Pair<String,String>> list = _arrayList;
- String _name = pc.getName();
- String _memberInDeclaration = this.langExt.memberInDeclaration(_name, "MSG_MIN");
- String _string = Integer.valueOf(offset).toString();
- Pair<String,String> _pair = Tuples.<String, String>pair(_memberInDeclaration, _string);
- list.add(_pair);
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for (final Message msg : _allOutgoingMessages) {
- {
- int _plus = (offset + 1);
- offset = _plus;
- String _name_1 = pc.getName();
- String _name_2 = msg.getName();
- String _plus_1 = ("OUT_" + _name_2);
- String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _plus_1);
- String _string_1 = Integer.valueOf(offset).toString();
- Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
- list.add(_pair_1);
- }
- }
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for (final Message msg_1 : _allIncomingMessages) {
- {
- int _plus = (offset + 1);
- offset = _plus;
- String _name_1 = pc.getName();
- String _name_2 = msg_1.getName();
- String _plus_1 = ("IN_" + _name_2);
- String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _plus_1);
- String _string_1 = Integer.valueOf(offset).toString();
- Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
- list.add(_pair_1);
- }
- }
- int _plus = (offset + 1);
- offset = _plus;
- String _name_1 = pc.getName();
- String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, "MSG_MAX");
- String _string_1 = Integer.valueOf(offset).toString();
- Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
- list.add(_pair_1);
- String _name_2 = pc.getName();
- String _memberInDeclaration_2 = this.langExt.memberInDeclaration(_name_2, "msg_ids");
- return this.langExt.genEnumeration(_memberInDeclaration_2, list);
- }
-
- public String getMessageID(final MessageFromIf mif) {
- Message _message = mif.getMessage();
- InterfaceItem _from = mif.getFrom();
- return this.getMessageID(_message, _from);
- }
-
- public String getMessageID(final Message msg, final InterfaceItem item) {
- if ((item instanceof Port)) {
- Port p = ((Port) item);
- String _xifexpression = null;
- boolean _isConjugated = p.isConjugated();
- if (_isConjugated) {
- _xifexpression = "OUT_";
- } else {
- _xifexpression = "IN_";
- }
- String direction = _xifexpression;
- GeneralProtocolClass _protocol = p.getProtocol();
- String _name = _protocol.getName();
- String _name_1 = msg.getName();
- String _plus = (direction + _name_1);
- return this.langExt.memberInUse(_name, _plus);
- } else {
- if ((item instanceof SAPRef)) {
- SAPRef sap = ((SAPRef) item);
- ProtocolClass _protocol_1 = sap.getProtocol();
- String _name_2 = _protocol_1.getName();
- String _name_3 = msg.getName();
- String _plus_1 = ("OUT_" + _name_3);
- return this.langExt.memberInUse(_name_2, _plus_1);
- } else {
- if ((item instanceof SPPRef)) {
- SPPRef spp = ((SPPRef) item);
- ProtocolClass _protocol_2 = spp.getProtocol();
- String _name_4 = _protocol_2.getName();
- String _name_5 = msg.getName();
- String _plus_2 = ("IN_" + _name_5);
- return this.langExt.memberInUse(_name_4, _plus_2);
- }
- }
- }
- return "unknown interface item";
- }
-}
+package org.eclipse.etrice.generator.generic;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+
+@SuppressWarnings("all")
+public class GenericProtocolClassGenerator {
+ @Inject
+ private ILanguageExtension langExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public String genMessageIDs(final ProtocolClass pc) {
+ int offset = 0;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ String _name = pc.getName();
+ String _memberInDeclaration = this.langExt.memberInDeclaration(_name, "MSG_MIN");
+ String _string = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_memberInDeclaration, _string);
+ list.add(_pair);
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for (final Message msg : _allOutgoingMessages) {
+ {
+ int _plus = (offset + 1);
+ offset = _plus;
+ String _name_1 = pc.getName();
+ String _name_2 = msg.getName();
+ String _plus_1 = ("OUT_" + _name_2);
+ String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _plus_1);
+ String _string_1 = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
+ list.add(_pair_1);
+ }
+ }
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for (final Message msg_1 : _allIncomingMessages) {
+ {
+ int _plus = (offset + 1);
+ offset = _plus;
+ String _name_1 = pc.getName();
+ String _name_2 = msg_1.getName();
+ String _plus_1 = ("IN_" + _name_2);
+ String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _plus_1);
+ String _string_1 = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair_1