summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjung2012-04-22 16:02:29 (EDT)
committertjung2012-04-22 16:02:29 (EDT)
commit23c680ff9c5567d0f8ed1237ab3ed7b03471f07f (patch)
tree34dcbaa456edebb16c1575e497ea161ac1b4d5b1
parentaae84264e45e5da09665bf0090d46e9ff6eafa27 (diff)
downloadorg.eclipse.etrice-23c680ff9c5567d0f8ed1237ab3ed7b03471f07f.zip
org.eclipse.etrice-23c680ff9c5567d0f8ed1237ab3ed7b03471f07f.tar.gz
org.eclipse.etrice-23c680ff9c5567d0f8ed1237ab3ed7b03471f07f.tar.bz2
[generator.c] send and receive handler implemented first step
-rw-r--r--features/org.eclipse.etrice.feature/feature.xml8
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend94
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend22
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java1570
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java236
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java506
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java122
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java2199
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java206
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java1443
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java344
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java2034
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java340
-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.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java565
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java481
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java131
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java122
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java1668
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java152
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java1274
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java304
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java93
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java131
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java1336
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java705
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java65
27 files changed, 10844 insertions, 5389 deletions
diff --git a/features/org.eclipse.etrice.feature/feature.xml b/features/org.eclipse.etrice.feature/feature.xml
index 0c03a2a..d0bc0c8 100644
--- a/features/org.eclipse.etrice.feature/feature.xml
+++ b/features/org.eclipse.etrice.feature/feature.xml
@@ -195,8 +195,7 @@ http://www.eclipse.org/legal/epl-v10.html
fragment="true"
unpack="false"/>
- <plugin
-<<<<<<< HEAD
+ <plugin
id="org.eclipse.etrice.generator.c"
download-size="0"
install-size="0"
@@ -204,10 +203,7 @@ http://www.eclipse.org/legal/epl-v10.html
unpack="false"/>
<plugin
- id="org.eclipse.etrice.generator.launch.c"
-=======
- id="org.eclipse.etrice.etunit.converter"
->>>>>>> 21ce8b7a3b5c5996810a8e7b914ee2b97a2f0803
+ id="org.eclipse.etrice.generator.launch.c"
download-size="0"
install-size="0"
version="0.0.0"
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index 030ff4f..dd9773f 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -149,6 +149,16 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«messageSignature(replPortClassName, message.name, "_broadcast", data)»;
«messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
«ENDFOR»
+
+ «IF (pc.getPortClass(conj) != null)»
+ «helpers.operationsDeclaration(pc.getPortClass(conj).operations, portClassName)»
+ «helpers.operationsDeclaration(pc.getPortClass(conj).operations, replPortClassName)»
+ «ENDIF»
+
+ «IF pc.handlesReceive(conj)»
+ void «portClassName»_handleReceive(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «ENDIF»
+
'''
}
@@ -216,32 +226,64 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«var refpd = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
«var refa = if (hasData && (!(message.data.refType.type instanceof PrimitiveType))&&(!(message.data.refType.ref))) "" else "&"»
«var data = if (hasData) ", "+typeName+refpd+" data" else ""»
+ «var hdlr = message.getSendHandler(conj)»
«messageSignature(portClassName, message.name, "", data)» {
- ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
- if (self->receiveMessageFunc!=NULL) {
- «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
- ET_MSC_LOGGER_SYNC_EXIT
+ «IF hdlr != null»
+ «FOR command : hdlr.detailCode.commands» «command»
+ «ENDFOR»
+ «ELSE»
+ ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
+ if (self->receiveMessageFunc!=NULL) {
+ «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
}
«messageSignature(replPortClassName, message.name, "_broadcast", data)» {
- int i;
- ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
- for (i=0; i<self->size; ++i) {
- «sendMessageCall(hasData, "(etPort*)(&self->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
- ET_MSC_LOGGER_SYNC_EXIT
+ «IF hdlr != null»
+ int i;
+ for (i=0; i<self->size; ++i) {
+ «portClassName»_«message.name»((«portClassName»*)&self->ports[i]«data»);
+ }
+ «ELSE»
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ for (i=0; i<self->size; ++i) {
+ «sendMessageCall(hasData, "(etPort*)(&self->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
}
«messageSignature(replPortClassName, message.name, "", ", int idx"+data)» {
- ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
- if (0<=idx && idx<self->size) {
- «sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
- }
- ET_MSC_LOGGER_SYNC_EXIT
+ «IF hdlr != null»
+ «portClassName»_«message.name»((«portClassName»*)&self->ports[idx]«data»);
+ «ELSE»
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ if (0<=idx && idx<self->size) {
+ «sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
}
«ENDFOR»
+
+ «IF (pc.getPortClass(conj) != null)»
+ «helpers.operationsImplementation(pc.getPortClass(conj).operations, portClassName)»
+ «helpers.operationsImplementation(pc.getPortClass(conj).operations, replPortClassName)»
+ «ENDIF»
+
+ // getReplication
+ etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
+ return self->size;
+ }
+
+ «IF pc.handlesReceive(conj)»
+ «genReceiveHandlers(pc,conj)»
+ «ENDIF»
+
'''
}
@@ -280,6 +322,26 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// '''
// }
+ def private genReceiveHandlers(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+
+ '''
+ /* receiver handlers */
+ void «portClassName»_handleReceive(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
+ switch (msg->evtID){
+ «FOR h:getReceiveHandlers(pc,conj)»
+ case «pc.name»_«h.msg.codeName»:
+ «userCode(h.detailCode)»
+ break;
+ «ENDFOR»
+ default:receiveMessageFunc(actor, self, msg);
+ break;
+ }
+ }
+ '''}
+
+
def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
««« TODO: make this optional or different for smaller footprint
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 2d1da8c..833b68a 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
@@ -372,7 +372,7 @@ class SubSystemClassGen {
var comma = if (idx<pi.peers.size-1) "," else ""
result = result +
"{&"+ai.path.getPathName()+", "
- +ai.actorClass.name+"_ReceiveMessage, "
+ +ai.actorClass.name+"_receiveMessage, "
+"&msgService_Thread1, "
+p.objId+", "
+(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.interfaceItem)+1)+", "
@@ -405,19 +405,29 @@ class SubSystemClassGen {
«IF pi.replicated»
«FOR peer: pi.peers»
case «pi.objId+pi.peers.indexOf(peer)»:
- etPort_receive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
- break;
+ «IF (pi.interfaceItem.protocol. handlesReceive(pi.isConjugated()))»
+ «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated())»_handleReceive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»],msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ «ELSE»
+ //etPort_receive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
+ «ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
+ «ENDIF»
+ break;
«ENDFOR»
«ELSE»
case «pi.objId»:
- etPort_receive(&«ai.path.pathName»_const.«pi.name», msg);
- break;
+ «IF (pi.interfaceItem.protocol. handlesReceive(pi.isConjugated()))»
+ «pi.interfaceItem.protocol.getPortClassName(pi.isConjugated())»_handleReceive((etPort*)&«ai.path.pathName»_const.«pi.name»,msg,(void*)&«ai.path.pathName»,«ai.actorClass.name»_receiveMessage);
+ «ELSE»
+ //etPort_receive(&«ai.path.pathName»_const.«pi.name», msg);
+ «ai.actorClass.name»_receiveMessage((void*)&«ai.path.pathName»,(etPort*)&«ai.path.pathName»_const.«pi.name», msg);
+ «ENDIF»
+ break;
«ENDIF»
«ENDFOR»
«ENDFOR»
default:
- etLogger_logErrorF("MessageService_Thread1_ReceiveMessage: address %d does not exist ", msg->address);
+ etLogger_logErrorF("MessageService_Thread1_receiveMessage: address %d does not exist ", msg->address);
break;
}
ET_MSC_LOGGER_SYNC_EXIT
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 729a8f9..f166b46 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,785 +1,785 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.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.DetailCode;
-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.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.c.gen.StateMachineGen;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ActorClassGen extends GenericActorClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private StateMachineGen stateMachineGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
- for (final ExpandedActorClass xpac : _xpActorClasses) {
- {
- ActorClass _actorClass = xpac.getActorClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this.roomExt.getPath(_actorClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3);
- ActorClass _actorClass_4 = xpac.getActorClass();
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- boolean _hasBehaviorAnnotation = this.hasBehaviorAnnotation(xpac, "BehaviorManual");
- if (_hasBehaviorAnnotation) {
- ActorClass _actorClass_5 = xpac.getActorClass();
- String _name = _actorClass_5.getName();
- String _operator_plus_5 = StringExtensions.operator_plus("omitting ActorClass source for \'", _name);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' since @BehaviorManual is specified");
- this.logger.logInfo(_operator_plus_6);
- } else {
- {
- ActorClass _actorClass_6 = xpac.getActorClass();
- String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_6);
- String _operator_plus_7 = StringExtensions.operator_plus("generating ActorClass source \'", _cSourceFileName);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\' in \'");
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, path);
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\'");
- this.logger.logInfo(_operator_plus_10);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_7 = xpac.getActorClass();
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_7);
- ActorClass _actorClass_8 = xpac.getActorClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
- }
- }
-
- private boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
- ActorClass _actorClass = xpac.getActorClass();
- EList<Annotation> _annotations = _actorClass.getAnnotations();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_annotations, null);
- if (_operator_notEquals) {
- ActorClass _actorClass_1 = xpac.getActorClass();
- EList<Annotation> _annotations_1 = _actorClass_1.getAnnotations();
- final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
- public Boolean apply(final Annotation e) {
- String _name = e.getName();
- boolean _operator_equals = ObjectExtensions.operator_equals(_name, annotation);
- return ((Boolean)_operator_equals);
- }
- };
- Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_annotations_1, _function);
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_findFirst, null);
- if (_operator_notEquals_1) {
- return true;
- }
- }
- return false;
- }
-
- private StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _xblockexpression = null;
- {
- List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
- final Function1<Port,Boolean> _function = new Function1<Port,Boolean>() {
- public Boolean apply(final Port p) {
- ProtocolClass _protocol = p.getProtocol();
- CommunicationType _commType = _protocol.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- return ((Boolean)_operator_equals);
- }
- };
- Iterable<Port> _filter = IterableExtensions.<Port>filter(_allEndPorts, _function);
- Iterable<Port> eventPorts = _filter;
- List<Port> _allEndPorts_1 = this.roomExt.getAllEndPorts(ac);
- final Function1<Port,Boolean> _function_1 = new Function1<Port,Boolean>() {
- public Boolean apply(final Port p) {
- boolean _operator_and = false;
- ProtocolClass _protocol = p.getProtocol();
- CommunicationType _commType = _protocol.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.DATA_DRIVEN);
- if (!_operator_equals) {
- _operator_and = false;
- } else {
- boolean _isConjugated = p.isConjugated();
- _operator_and = BooleanExtensions.operator_and(_operator_equals, _isConjugated);
- }
- return ((Boolean)_operator_and);
- }
- };
- Iterable<Port> _filter_1 = IterableExtensions.<Port>filter(_allEndPorts_1, _function_1);
- Iterable<Port> sendPorts = _filter_1;
- List<Port> _allEndPorts_2 = this.roomExt.getAllEndPorts(ac);
- final Function1<Port,Boolean> _function_2 = new Function1<Port,Boolean>() {
- public Boolean apply(final Port p) {
- boolean _operator_and = false;
- ProtocolClass _protocol = p.getProtocol();
- CommunicationType _commType = _protocol.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.DATA_DRIVEN);
- if (!_operator_equals) {
- _operator_and = false;
- } else {
- boolean _isConjugated = p.isConjugated();
- boolean _operator_not = BooleanExtensions.operator_not(_isConjugated);
- _operator_and = BooleanExtensions.operator_and(_operator_equals, _operator_not);
- }
- return ((Boolean)_operator_and);
- }
- };
- Iterable<Port> _filter_2 = IterableExtensions.<Port>filter(_allEndPorts_2, _function_2);
- Iterable<Port> recvPorts = _filter_2;
- ActorCommunicationType _commType = ac.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.DATA_DRIVEN);
- boolean dataDriven = _operator_equals;
- ActorCommunicationType _commType_1 = ac.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.ASYNCHRONOUS);
- boolean async = _operator_equals_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of ActorClass ");
- String _name = xpac.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = xpac.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"messaging/etMessage.h\"");
- _builder.newLine();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("#include \"");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("typedef struct ");
- String _name_4 = xpac.getName();
- _builder.append(_name_4, "");
- _builder.append(" ");
- String _name_5 = xpac.getName();
- _builder.append(_name_5, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* const part of ActorClass (ROM) */");
- _builder.newLine();
- {
- boolean _operator_and = false;
- boolean _operator_and_1 = false;
- boolean _operator_and_2 = false;
- boolean _isEmpty = IterableExtensions.isEmpty(eventPorts);
- if (!_isEmpty) {
- _operator_and_2 = false;
- } else {
- boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
- _operator_and_2 = BooleanExtensions.operator_and(_isEmpty, _isEmpty_1);
- }
- if (!_operator_and_2) {
- _operator_and_1 = false;
- } else {
- List<SAPRef> _allSAPs = this.roomExt.getAllSAPs(ac);
- boolean _isEmpty_2 = _allSAPs.isEmpty();
- _operator_and_1 = BooleanExtensions.operator_and(_operator_and_2, _isEmpty_2);
- }
- if (!_operator_and_1) {
- _operator_and = false;
- } else {
- List<ServiceImplementation> _allServiceImplementations = this.roomExt.getAllServiceImplementations(ac);
- boolean _isEmpty_3 = _allServiceImplementations.isEmpty();
- _operator_and = BooleanExtensions.operator_and(_operator_and_1, _isEmpty_3);
- }
- if (_operator_and) {
- _builder.append("/* this actor class has no ports and thus no constant data */");
- _builder.newLine();
- } else {
- _builder.append("typedef struct ");
- String _name_6 = xpac.getName();
- _builder.append(_name_6, "");
- _builder.append("_const {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* simple ports */");
- _builder.newLine();
- {
- for(final Port ep : eventPorts) {
- {
- int _multiplicity = ep.getMultiplicity();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- if (_operator_equals_2) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName = this.roomExt.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_7 = ep.getName();
- _builder.append(_name_7, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* data receive ports */");
- _builder.newLine();
- {
- for(final Port ep_1 : recvPorts) {
- {
- int _multiplicity_1 = ep_1.getMultiplicity();
- boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
- if (_operator_equals_3) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_1 = this.roomExt.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.roomExt.getAllSAPs(ac);
- for(final SAPRef sap : _allSAPs_1) {
- _builder.append("\t");
- _builder.append("const ");
- String _portClassName_2 = this.roomExt.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.roomExt.getAllEndPorts(ac);
- for(final Port ep_2 : _allEndPorts_3) {
- {
- int _multiplicity_2 = ep_2.getMultiplicity();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity_2), ((Integer)1));
- if (_operator_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.roomExt.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 = xpac.getName();
- _builder.append(_name_12, "");
- _builder.append("_const;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine) {
- _builder.newLine();
- StringConcatenation _genHeaderConstants = this.stateMachineGen.genHeaderConstants(xpac, ac);
- _builder.append(_genHeaderConstants, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("/* variable part of ActorClass (RAM) */");
- _builder.newLine();
- _builder.append("struct ");
- String _name_13 = xpac.getName();
- _builder.append(_name_13, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_and_3 = false;
- boolean _operator_and_4 = false;
- boolean _operator_and_5 = false;
- boolean _isEmpty_4 = IterableExtensions.isEmpty(eventPorts);
- if (!_isEmpty_4) {
- _operator_and_5 = false;
- } else {
- boolean _isEmpty_5 = IterableExtensions.isEmpty(recvPorts);
- _operator_and_5 = BooleanExtensions.operator_and(_isEmpty_4, _isEmpty_5);
- }
- if (!_operator_and_5) {
- _operator_and_4 = false;
- } else {
- List<SAPRef> _allSAPs_2 = this.roomExt.getAllSAPs(ac);
- boolean _isEmpty_6 = _allSAPs_2.isEmpty();
- _operator_and_4 = BooleanExtensions.operator_and(_operator_and_5, _isEmpty_6);
- }
- if (!_operator_and_4) {
- _operator_and_3 = false;
- } else {
- List<ServiceImplementation> _allServiceImplementations_2 = this.roomExt.getAllServiceImplementations(ac);
- boolean _isEmpty_7 = _allServiceImplementations_2.isEmpty();
- _operator_and_3 = BooleanExtensions.operator_and(_operator_and_4, _isEmpty_7);
- }
- boolean _operator_not = BooleanExtensions.operator_not(_operator_and_3);
- if (_operator_not) {
- _builder.append("\t");
- _builder.append("const ");
- String _name_14 = xpac.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 _operator_equals_4 = ObjectExtensions.operator_equals(((Integer)_multiplicity_3), ((Integer)1));
- if (_operator_equals_4) {
- _builder.append("\t");
- String _portClassName_3 = this.roomExt.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.roomExt.getAllAttributes(ac);
- StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
- _builder.append(_attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- List<Attribute> _allAttributes_1 = this.roomExt.getAllAttributes(ac);
- for(final Attribute a : _allAttributes_1) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
- if (_operator_notEquals_1) {
- String _name_16 = ac.getName();
- String _operator_plus = StringExtensions.operator_plus(_name_16, " ");
- String _name_17 = a.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name_17);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
- this.logger.logInfo(_operator_plus_2);
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine_1 = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine_1) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- StringConcatenation _genDataMembers = this.stateMachineGen.genDataMembers(xpac, ac);
- _builder.append(_genDataMembers, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_18 = xpac.getName();
- _builder.append(_name_18, "");
- _builder.append("_init(");
- String _name_19 = xpac.getName();
- _builder.append(_name_19, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("void ");
- String _name_20 = xpac.getName();
- _builder.append(_name_20, "");
- _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- boolean _operator_or = false;
- if (dataDriven) {
- _operator_or = true;
- } else {
- _operator_or = BooleanExtensions.operator_or(dataDriven, async);
- }
- if (_operator_or) {
- _builder.append("void ");
- String _name_21 = xpac.getName();
- _builder.append(_name_21, "");
- _builder.append("_execute(");
- String _name_22 = xpac.getName();
- _builder.append(_name_22, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- EList<StandardOperation> _operations = ac.getOperations();
- String _name_23 = ac.getName();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, _name_23);
- _builder.append(_operationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_24 = xpac.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_24);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _xblockexpression = null;
- {
- ActorCommunicationType _commType = ac.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.ASYNCHRONOUS);
- boolean async = _operator_equals;
- ActorCommunicationType _commType_1 = ac.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
- boolean eventDriven = _operator_equals_1;
- ActorCommunicationType _commType_2 = ac.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, ActorCommunicationType.DATA_DRIVEN);
- boolean dataDriven = _operator_equals_2;
- boolean _operator_or = false;
- if (async) {
- _operator_or = true;
- } else {
- _operator_or = BooleanExtensions.operator_or(async, eventDriven);
- }
- boolean handleEvents = _operator_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 = xpac.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"modelbase/etActor.h\"");
- _builder.newLine();
- _builder.append("#include \"debugging/etLogger.h\"");
- _builder.newLine();
- _builder.append("#include \"debugging/etMSCLogger.h\"");
- _builder.newLine();
- _builder.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.stdExt.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName_1, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode3 = ac.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* interface item IDs */");
- _builder.newLine();
- String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
- _builder.append(_genInterfaceItemConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine) {
- StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
- _builder.append(_genStateMachine, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("void ");
- String _name_1 = xpac.getName();
- _builder.append(_name_1, "");
- _builder.append("_init(");
- String _name_2 = xpac.getName();
- _builder.append(_name_2, "");
- _builder.append("* self){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_3 = xpac.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", \"init\")");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine_1 = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine_1) {
- _builder.append("\t");
- StringConcatenation _genInitialization = this.stateMachineGen.genInitialization(xpac, ac);
- _builder.append(_genInitialization, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_4 = xpac.getName();
- _builder.append(_name_4, "");
- _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_5 = xpac.getName();
- _builder.append(_name_5, " ");
- _builder.append("\", \"_receiveMessage\")");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine_2 = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine_2) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("receiveEvent(self");
- {
- 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 _operator_or_1 = false;
- if (dataDriven) {
- _operator_or_1 = true;
- } else {
- _operator_or_1 = BooleanExtensions.operator_or(dataDriven, async);
- }
- if (_operator_or_1) {
- _builder.append("void ");
- String _name_6 = xpac.getName();
- _builder.append(_name_6, "");
- _builder.append("_execute(");
- String _name_7 = xpac.getName();
- _builder.append(_name_7, "");
- _builder.append("* self) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_8 = xpac.getName();
- _builder.append(_name_8, " ");
- _builder.append("\", \"_execute\")");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine_3 = this.roomExt.hasNonEmptyStateMachine(xpac);
- if (_hasNonEmptyStateMachine_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();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(ac);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _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.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.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.DetailCode;
+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.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.c.gen.StateMachineGen;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private StateMachineGen stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this.roomExt.getPath(_actorClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ boolean _hasBehaviorAnnotation = this.hasBehaviorAnnotation(xpac, "BehaviorManual");
+ if (_hasBehaviorAnnotation) {
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _name = _actorClass_5.getName();
+ String _operator_plus_5 = StringExtensions.operator_plus("omitting ActorClass source for \'", _name);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' since @BehaviorManual is specified");
+ this.logger.logInfo(_operator_plus_6);
+ } else {
+ {
+ ActorClass _actorClass_6 = xpac.getActorClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_6);
+ String _operator_plus_7 = StringExtensions.operator_plus("generating ActorClass source \'", _cSourceFileName);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\' in \'");
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, path);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\'");
+ this.logger.logInfo(_operator_plus_10);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_7 = xpac.getActorClass();
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_7);
+ ActorClass _actorClass_8 = xpac.getActorClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+ }
+ }
+
+ private boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
+ ActorClass _actorClass = xpac.getActorClass();
+ EList<Annotation> _annotations = _actorClass.getAnnotations();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_annotations, null);
+ if (_operator_notEquals) {
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ EList<Annotation> _annotations_1 = _actorClass_1.getAnnotations();
+ final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
+ public Boolean apply(final Annotation e) {
+ String _name = e.getName();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_name, annotation);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_annotations_1, _function);
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_findFirst, null);
+ if (_operator_notEquals_1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ ProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ Iterable<Port> _filter = IterableExtensions.<Port>filter(_allEndPorts, _function);
+ Iterable<Port> eventPorts = _filter;
+ List<Port> _allEndPorts_1 = this.roomExt.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function_1 = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ boolean _operator_and = false;
+ ProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.DATA_DRIVEN);
+ if (!_operator_equals) {
+ _operator_and = false;
+ } else {
+ boolean _isConjugated = p.isConjugated();
+ _operator_and = BooleanExtensions.operator_and(_operator_equals, _isConjugated);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<Port> _filter_1 = IterableExtensions.<Port>filter(_allEndPorts_1, _function_1);
+ Iterable<Port> sendPorts = _filter_1;
+ List<Port> _allEndPorts_2 = this.roomExt.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function_2 = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ boolean _operator_and = false;
+ ProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.DATA_DRIVEN);
+ if (!_operator_equals) {
+ _operator_and = false;
+ } else {
+ boolean _isConjugated = p.isConjugated();
+ boolean _operator_not = BooleanExtensions.operator_not(_isConjugated);
+ _operator_and = BooleanExtensions.operator_and(_operator_equals, _operator_not);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<Port> _filter_2 = IterableExtensions.<Port>filter(_allEndPorts_2, _function_2);
+ Iterable<Port> recvPorts = _filter_2;
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.DATA_DRIVEN);
+ boolean dataDriven = _operator_equals;
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.ASYNCHRONOUS);
+ boolean async = _operator_equals_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ActorClass ");
+ String _name = xpac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = xpac.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessage.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = ac.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ String _name_4 = xpac.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = xpac.getName();
+ _builder.append(_name_5, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* const part of ActorClass (ROM) */");
+ _builder.newLine();
+ {
+ boolean _operator_and = false;
+ boolean _operator_and_1 = false;
+ boolean _operator_and_2 = false;
+ boolean _isEmpty = IterableExtensions.isEmpty(eventPorts);
+ if (!_isEmpty) {
+ _operator_and_2 = false;
+ } else {
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
+ _operator_and_2 = BooleanExtensions.operator_and(_isEmpty, _isEmpty_1);
+ }
+ if (!_operator_and_2) {
+ _operator_and_1 = false;
+ } else {
+ List<SAPRef> _allSAPs = this.roomExt.getAllSAPs(ac);
+ boolean _isEmpty_2 = _allSAPs.isEmpty();
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_and_2, _isEmpty_2);
+ }
+ if (!_operator_and_1) {
+ _operator_and = false;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations = this.roomExt.getAllServiceImplementations(ac);
+ boolean _isEmpty_3 = _allServiceImplementations.isEmpty();
+ _operator_and = BooleanExtensions.operator_and(_operator_and_1, _isEmpty_3);
+ }
+ if (_operator_and) {
+ _builder.append("/* this actor class has no ports and thus no constant data */");
+ _builder.newLine();
+ } else {
+ _builder.append("typedef struct ");
+ String _name_6 = xpac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_const {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* simple ports */");
+ _builder.newLine();
+ {
+ for(final Port ep : eventPorts) {
+ {
+ int _multiplicity = ep.getMultiplicity();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_equals_2) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName = this.roomExt.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_7 = ep.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* data receive ports */");
+ _builder.newLine();
+ {
+ for(final Port ep_1 : recvPorts) {
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
+ if (_operator_equals_3) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this.roomExt.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.roomExt.getAllSAPs(ac);
+ for(final SAPRef sap : _allSAPs_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_2 = this.roomExt.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.roomExt.getAllEndPorts(ac);
+ for(final Port ep_2 : _allEndPorts_3) {
+ {
+ int _multiplicity_2 = ep_2.getMultiplicity();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity_2), ((Integer)1));
+ if (_operator_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.roomExt.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 = xpac.getName();
+ _builder.append(_name_12, "");
+ _builder.append("_const;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.newLine();
+ StringConcatenation _genHeaderConstants = this.stateMachineGen.genHeaderConstants(xpac, ac);
+ _builder.append(_genHeaderConstants, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* variable part of ActorClass (RAM) */");
+ _builder.newLine();
+ _builder.append("struct ");
+ String _name_13 = xpac.getName();
+ _builder.append(_name_13, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_and_3 = false;
+ boolean _operator_and_4 = false;
+ boolean _operator_and_5 = false;
+ boolean _isEmpty_4 = IterableExtensions.isEmpty(eventPorts);
+ if (!_isEmpty_4) {
+ _operator_and_5 = false;
+ } else {
+ boolean _isEmpty_5 = IterableExtensions.isEmpty(recvPorts);
+ _operator_and_5 = BooleanExtensions.operator_and(_isEmpty_4, _isEmpty_5);
+ }
+ if (!_operator_and_5) {
+ _operator_and_4 = false;
+ } else {
+ List<SAPRef> _allSAPs_2 = this.roomExt.getAllSAPs(ac);
+ boolean _isEmpty_6 = _allSAPs_2.isEmpty();
+ _operator_and_4 = BooleanExtensions.operator_and(_operator_and_5, _isEmpty_6);
+ }
+ if (!_operator_and_4) {
+ _operator_and_3 = false;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations_2 = this.roomExt.getAllServiceImplementations(ac);
+ boolean _isEmpty_7 = _allServiceImplementations_2.isEmpty();
+ _operator_and_3 = BooleanExtensions.operator_and(_operator_and_4, _isEmpty_7);
+ }
+ boolean _operator_not = BooleanExtensions.operator_not(_operator_and_3);
+ if (_operator_not) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_14 = xpac.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 _operator_equals_4 = ObjectExtensions.operator_equals(((Integer)_multiplicity_3), ((Integer)1));
+ if (_operator_equals_4) {
+ _builder.append("\t");
+ String _portClassName_3 = this.roomExt.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.roomExt.getAllAttributes(ac);
+ StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ List<Attribute> _allAttributes_1 = this.roomExt.getAllAttributes(ac);
+ for(final Attribute a : _allAttributes_1) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
+ if (_operator_notEquals_1) {
+ String _name_16 = ac.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name_16, " ");
+ String _name_17 = a.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name_17);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
+ this.logger.logInfo(_operator_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine_1 = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine_1) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genDataMembers = this.stateMachineGen.genDataMembers(xpac, ac);
+ _builder.append(_genDataMembers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_18 = xpac.getName();
+ _builder.append(_name_18, "");
+ _builder.append("_init(");
+ String _name_19 = xpac.getName();
+ _builder.append(_name_19, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_20 = xpac.getName();
+ _builder.append(_name_20, "");
+ _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _operator_or = false;
+ if (dataDriven) {
+ _operator_or = true;
+ } else {
+ _operator_or = BooleanExtensions.operator_or(dataDriven, async);
+ }
+ if (_operator_or) {
+ _builder.append("void ");
+ String _name_21 = xpac.getName();
+ _builder.append(_name_21, "");
+ _builder.append("_execute(");
+ String _name_22 = xpac.getName();
+ _builder.append(_name_22, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ EList<StandardOperation> _operations = ac.getOperations();
+ String _name_23 = ac.getName();
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, _name_23);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = ac.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_24 = xpac.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_24);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _xblockexpression = null;
+ {
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ boolean async = _operator_equals;
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ boolean eventDriven = _operator_equals_1;
+ ActorCommunicationType _commType_2 = ac.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ boolean dataDriven = _operator_equals_2;
+ boolean _operator_or = false;
+ if (async) {
+ _operator_or = true;
+ } else {
+ _operator_or = BooleanExtensions.operator_or(async, eventDriven);
+ }
+ boolean handleEvents = _operator_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 = xpac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etActor.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.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.stdExt.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName_1, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode3 = ac.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* interface item IDs */");
+ _builder.newLine();
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine) {
+ StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
+ _builder.append(_genStateMachine, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = xpac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_init(");
+ String _name_2 = xpac.getName();
+ _builder.append(_name_2, "");
+ _builder.append("* self){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_3 = xpac.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", \"init\")");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine_1 = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine_1) {
+ _builder.append("\t");
+ StringConcatenation _genInitialization = this.stateMachineGen.genInitialization(xpac, ac);
+ _builder.append(_genInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = xpac.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_5 = xpac.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\", \"_receiveMessage\")");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine_2 = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self");
+ {
+ 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 _operator_or_1 = false;
+ if (dataDriven) {
+ _operator_or_1 = true;
+ } else {
+ _operator_or_1 = BooleanExtensions.operator_or(dataDriven, async);
+ }
+ if (_operator_or_1) {
+ _builder.append("void ");
+ String _name_6 = xpac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_execute(");
+ String _name_7 = xpac.getName();
+ _builder.append(_name_7, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_8 = xpac.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("\", \"_execute\")");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine_3 = this.roomExt.hasNonEmptyStateMachine(xpac);
+ if (_hasNonEmptyStateMachine_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();
+ StringConcatenation _operationsImplementation = this.helpers.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
new file mode 100644
index 0000000..65a3c04
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -0,0 +1,236 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class CExtensions implements ILanguageExtension {
+ @Inject
+ private AbstractTransitionChainGenerator chainGenerator;
+
+ public String getTypedDataDefinition(final Message m) {
+ String _generateTypedData = this.chainGenerator.generateTypedData(m);
+ return _generateTypedData;
+ }
+
+ public String accessLevelPrivate() {
+ return "static ";
+ }
+
+ public String accessLevelProtected() {
+ return "static ";
+ }
+
+ public String accessLevelPublic() {
+ return "";
+ }
+
+ public String memberAccess() {
+ return "self->";
+ }
+
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "* self, ";
+ } else {
+ _xifexpression = "* self";
+ }
+ String _operator_plus = StringExtensions.operator_plus(classname, _xifexpression);
+ return _operator_plus;
+ }
+
+ public String selfPointer(final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "self, ";
+ } else {
+ _xifexpression = "self";
+ }
+ return _xifexpression;
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ String _operator_plus = StringExtensions.operator_plus(classname, "_");
+ return _operator_plus;
+ }
+
+ public String memberInDeclaration(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, "_");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
+ return _operator_plus_1;
+ }
+
+ public String memberInUse(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, "_");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
+ return _operator_plus_1;
+ }
+
+ /**
+ * TODO: move specific code elsewhere
+ */
+ public String getCHeaderFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".h");
+ return _operator_plus;
+ }
+
+ public String getCSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".c");
+ return _operator_plus;
+ }
+
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_Inst.h");
+ return _operator_plus;
+ }
+
+ public String getDispSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_Disp.h");
+ return _operator_plus;
+ }
+
+ public StringConcatenation getIncludeGuardString(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("_");
+ String _upperCase = filename.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_H_");
+ return _builder;
+ }
+
+ public StringConcatenation generateIncludeGuardBegin(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#ifndef ");
+ StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#define ");
+ StringConcatenation _includeGuardString_1 = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString_1, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation generateIncludeGuardEnd(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#endif /* ");
+ StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public boolean usesInheritance() {
+ return false;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ String _xblockexpression = null;
+ {
+ boolean _isEmpty = entries.isEmpty();
+ if (_isEmpty) {
+ return "/* empty enum not generated */";
+ }
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("enum ");
+ _builder.append(name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean hasAnyElements = false;
+ for(final Pair<String,String> entry : entries) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _first = entry.getFirst();
+ _builder.append(_first, " ");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ String _string = _builder.toString();
+ _xblockexpression = (_string);
+ }
+ return _xblockexpression;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _xifexpression = null;
+ if (b) {
+ _xifexpression = "TRUE";
+ } else {
+ _xifexpression = "FALSE";
+ }
+ return _xifexpression;
+ }
+
+ public String 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 _operator_plus = StringExtensions.operator_plus(type, "* ");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "[");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ((Integer)size));
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "]");
+ _xifexpression = _operator_plus_4;
+ } else {
+ String _operator_plus_5 = StringExtensions.operator_plus(type, " ");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, name);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, "[");
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)size));
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, "]");
+ _xifexpression = _operator_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";
+ }
+}
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 37e83eb..82faec7 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,253 +1,253 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
- String _path = this.roomExt.getPath(dc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this.stdExt.getCSourceFileName(dc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = dc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = dc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
- StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
- _builder.append(_attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("} ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- List<Attribute> _allAttributes_1 = this.roomExt.getAllAttributes(dc);
- for(final Attribute a : _allAttributes_1) {
- {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
- if (_operator_notEquals) {
- String _name_4 = dc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name_4, " ");
- String _name_5 = a.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name_5);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
- this.logger.logInfo(_operator_plus_2);
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_6 = dc.getName();
- StringConcatenation _operationsDeclaration = this.helpers.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();
- DetailCode _userCode2 = dc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_10 = dc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_10);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include <string.h>");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = dc.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_1 = dc.getName();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_1);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// deep copy");
- _builder.newLine();
- _builder.append("void ");
- String _name_2 = dc.getName();
- _builder.append(_name_2, "");
- _builder.append("_deepCopy(");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- _builder.append("* source, ");
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
- _builder.append("* target) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("memcpy(target, source, sizeof(");
- String _name_5 = dc.getName();
- _builder.append(_name_5, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
+ String _path = this.roomExt.getPath(dc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(dc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = dc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = dc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
+ StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("} ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ List<Attribute> _allAttributes_1 = this.roomExt.getAllAttributes(dc);
+ for(final Attribute a : _allAttributes_1) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
+ if (_operator_notEquals) {
+ String _name_4 = dc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name_4, " ");
+ String _name_5 = a.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name_5);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
+ this.logger.logInfo(_operator_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_6 = dc.getName();
+ StringConcatenation _operationsDeclaration = this.helpers.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();
+ DetailCode _userCode2 = dc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_10 = dc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_10);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <string.h>");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = dc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_1 = dc.getName();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_1);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = dc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_deepCopy(");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("* source, ");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("* target) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("memcpy(target, source, sizeof(");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
index 83d65c2..817f2df 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
@@ -1,61 +1,61 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.generator.c.gen.ActorClassGen;
-import org.eclipse.etrice.generator.c.gen.DataClassGen;
-import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
- if (_operator_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.generator.c.gen.ActorClassGen;
+import org.eclipse.etrice.generator.c.gen.DataClassGen;
+import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
+ if (_operator_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 522afb1..453ce84 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,999 +1,1200 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.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.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.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @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.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this.stdExt.getCSourceFileName(pc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(pc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = pc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"modelbase/etPort.h\"");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_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();
- StringConcatenation _portClassHeader = this.portClassHeader(pc, ((Boolean)false));
- _builder.append(_portClassHeader, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _portClassHeader_1 = this.portClassHeader(pc, ((Boolean)true));
- _builder.append(_portClassHeader_1, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- _builder.append("/*--------------------- port structs and methods */");
- _builder.newLine();
- StringConcatenation _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
- _builder.append(_genDataDrivenPortHeaders, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_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();
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_4 = pc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- private StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"debugging/etMSCLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = pc.getUserCode3();
- StringConcatenation _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- port methods */");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
- if (_operator_equals) {
- StringConcatenation _portClassSource = this.portClassSource(pc, ((Boolean)false));
- _builder.append(_portClassSource, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _portClassSource_1 = this.portClassSource(pc, ((Boolean)true));
- _builder.append(_portClassSource_1, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_1 = pc.getCommType();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
- if (_operator_equals_1) {
- StringConcatenation _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
- _builder.append(_genDataDrivenPortSources, "");
- _builder.newLineIfNotEmpty();
- } else {
- CommunicationType _commType_2 = pc.getCommType();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
- if (_operator_equals_2) {
- _builder.append("#error \"synchronoue protocols not implemented yet\"");
- _builder.newLine();
- }
- }
- }
- }
- return _builder;
- }
-
- private StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("typedef etPort ");
- _builder.append(portClassName, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("typedef etReplPort ");
- _builder.append(replPortClassName, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- for(final Message message : messages) {
- _builder.append("\t");
- VarDecl _data = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- boolean hasData = _operator_notEquals;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- 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();
- _builder.append("\t");
- String _xifexpression_2 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- boolean _operator_or = false;
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _operator_or = true;
- } else {
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- boolean _isRef = _refType_2.isRef();
- _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef);
- }
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
- }
- if (_operator_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _xifexpression_3 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_3 = _operator_plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name, "", data);
- _builder.append(_messageSignature, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_1 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_1, "_broadcast", data);
- _builder.append(_messageSignature_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_2 = message.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_2, "", _operator_plus_3);
- _builder.append(_messageSignature_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private StringConcatenation genDataDrivenPortHeaders(final ProtocolClass pc) {
- StringConcatenation _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- return ((Boolean)_operator_notEquals);
- }
- };
- Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- Iterable<Message> sentMsgs = _filter;
- 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);
- String typeName = _typeName;
- _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.roomExt.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.roomExt.getPortClassName(pc, true);
- _builder.append(_portClassName_1, " ");
- _builder.append("* peer;");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
- _builder.append(_portClassName_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- for(final Message message : sentMsgs) {
- VarDecl _data_2 = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data_2, null);
- boolean hasData = _operator_notEquals;
- _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_1 = this._typeHelpers.typeName(_type_1);
- _xifexpression_1 = _typeName_1;
- } else {
- _xifexpression_1 = "";
- }
- String typeName_1 = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _xifexpression_2 = null;
- boolean _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- DataType _type_2 = _refType_3.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
- }
- if (_operator_and) {
- _xifexpression_2 = "*";
- } else {
- _xifexpression_2 = "";
- }
- String refp_1 = _xifexpression_2;
- _builder.newLineIfNotEmpty();
- String _xifexpression_3 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName_1);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp_1);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_3 = _operator_plus_2;
- } else {
- _xifexpression_3 = "";
- }
- String data = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _portClassName_3 = this.roomExt.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.roomExt.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 StringConcatenation genDataDrivenPortSources(final ProtocolClass pc) {
- StringConcatenation _xblockexpression = null;
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
- public Boolean apply(final Message m) {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- return ((Boolean)_operator_notEquals);
- }
- };
- Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- Iterable<Message> messages = _filter;
- 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);
- String typeName = _typeName;
- _builder.newLineIfNotEmpty();
- String _xifexpression = null;
- VarDecl _data_1 = message.getData();
- RefableType _refType_1 = _data_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _xifexpression = "*";
- } else {
- _xifexpression = "";
- }
- String refp = _xifexpression;
- _builder.newLineIfNotEmpty();
- String _xifexpression_1 = null;
- VarDecl _data_2 = message.getData();
- RefableType _refType_2 = _data_2.getRefType();
- DataType _type_2 = _refType_2.getType();
- if ((_type_2 instanceof PrimitiveType)) {
- _xifexpression_1 = "&";
- } else {
- _xifexpression_1 = "";
- }
- String refa = _xifexpression_1;
- _builder.newLineIfNotEmpty();
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- String data = _operator_plus_2;
- _builder.newLineIfNotEmpty();
- String _portClassName = this.roomExt.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.roomExt.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 StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- List<Message> _xifexpression = null;
- if (conj) {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- _xifexpression = _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- _xifexpression = _allOutgoingMessages;
- }
- List<Message> messages = _xifexpression;
- String _xifexpression_1 = null;
- if (conj) {
- _xifexpression_1 = "IN_";
- } else {
- _xifexpression_1 = "OUT_";
- }
- String dir = _xifexpression_1;
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Message message : messages) {
- VarDecl _data = message.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- boolean hasData = _operator_notEquals;
- _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 _operator_and = false;
- if (!hasData) {
- _operator_and = false;
- } else {
- VarDecl _data_2 = message.getData();
- RefableType _refType_1 = _data_2.getRefType();
- boolean _isRef = _refType_1.isRef();
- _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
- }
- if (_operator_and) {
- _xifexpression_3 = "*";
- } else {
- _xifexpression_3 = "";
- }
- String refp = _xifexpression_3;
- _builder.newLineIfNotEmpty();
- String _xifexpression_4 = null;
- boolean _operator_and_1 = false;
- if (!hasData) {
- _operator_and_1 = false;
- } else {
- boolean _operator_or = false;
- VarDecl _data_3 = message.getData();
- RefableType _refType_2 = _data_3.getRefType();
- DataType _type_1 = _refType_2.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- if (_operator_not) {
- _operator_or = true;
- } else {
- VarDecl _data_4 = message.getData();
- RefableType _refType_3 = _data_4.getRefType();
- boolean _isRef_1 = _refType_3.isRef();
- _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
- }
- _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
- }
- if (_operator_and_1) {
- _xifexpression_4 = "*";
- } else {
- _xifexpression_4 = "";
- }
- String refpd = _xifexpression_4;
- _builder.newLineIfNotEmpty();
- String _xifexpression_5 = null;
- boolean _operator_and_2 = false;
- boolean _operator_and_3 = false;
- if (!hasData) {
- _operator_and_3 = false;
- } else {
- VarDecl _data_5 = message.getData();
- RefableType _refType_4 = _data_5.getRefType();
- DataType _type_2 = _refType_4.getType();
- boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
- _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
- }
- if (!_operator_and_3) {
- _operator_and_2 = false;
- } else {
- VarDecl _data_6 = message.getData();
- RefableType _refType_5 = _data_6.getRefType();
- boolean _isRef_2 = _refType_5.isRef();
- boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
- _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
- }
- if (_operator_and_2) {
- _xifexpression_5 = "";
- } else {
- _xifexpression_5 = "&";
- }
- String refa = _xifexpression_5;
- _builder.newLineIfNotEmpty();
- String _xifexpression_6 = null;
- if (hasData) {
- String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_6 = _operator_plus_2;
- } else {
- _xifexpression_6 = "";
- }
- String data = _xifexpression_6;
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name = message.getName();
- String _messageSignature = this.messageSignature(portClassName, _name, "", data);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(portClassName, " ");
- _builder.append("\", \"");
- String _name_1 = message.getName();
- _builder.append(_name_1, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (self->receiveMessageFunc!=NULL) {");
- _builder.newLine();
- _builder.append("\t\t");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
- String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
- String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
- _builder.append(_sendMessageCall, " ");
- _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_4 = message.getName();
- String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
- _builder.append(_messageSignature_1, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_5 = message.getName();
- _builder.append(_name_5, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (i=0; i<self->size; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- String _name_6 = pc.getName();
- String _name_7 = message.getName();
- String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_7);
- String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_6);
- String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_1 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[i])", _memberInUse_1, _operator_plus_7, _operator_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_8 = message.getName();
- String _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_8, "", _operator_plus_9);
- _builder.append(_messageSignature_2, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- _builder.append(replPortClassName, " ");
- _builder.append("\", \"");
- String _name_9 = message.getName();
- _builder.append(_name_9, " ");
- _builder.append("\")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (0<=idx && idx<self->size) {");
- _builder.newLine();
- _builder.append("\t\t");
- String _name_10 = pc.getName();
- String _name_11 = message.getName();
- String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_11);
- String _memberInUse_2 = this.stdExt.memberInUse(_name_10, _operator_plus_10);
- String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
- String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_2 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_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();
- }
- }
- _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 _operator_plus = StringExtensions.operator_plus("etPort_sendMessage(", self);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ", ");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, msg);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ", sizeof(");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, typeName);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "), ");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ");");
- _xifexpression = _operator_plus_7;
- } else {
- String _operator_plus_8 = StringExtensions.operator_plus("etPort_sendMessage(", self);
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, ", ");
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, msg);
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", 0, NULL);");
- _xifexpression = _operator_plus_11;
- }
- return _xifexpression;
- }
-
- private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
- String _operator_plus = StringExtensions.operator_plus("void ", className);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, methodSuffix);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "(const ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* self");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, data);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ")");
- return _operator_plus_8;
- }
-
- private String messageSetterSignature(final String className, final String messageName, final String data) {
- String _operator_plus = StringExtensions.operator_plus("void ", className);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "_set(");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, className);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "* self");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ")");
- return _operator_plus_7;
- }
-
- private String messageGetterSignature(final String className, final String messageName, final String type) {
- String _operator_plus = StringExtensions.operator_plus(type, " ");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, className);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, messageName);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_get(const ");
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* const self)");
- return _operator_plus_6;
- }
-
- private StringConcatenation messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- private StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* message names as strings for debugging (generate MSC) */");
- _builder.newLine();
- _builder.append("static const char* ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, "");
- _builder.append("\",");
- }
- }
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\"");
- String _name_2 = m_1.getName();
- _builder.append(_name_2, "");
- _builder.append("\", ");
- }
- }
- _builder.append("\"MAX\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("const char* ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("_getMessageString(int msg_id) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (msg_id<");
- String _name_4 = pc.getName();
- _builder.append(_name_4, " ");
- _builder.append("_MSG_MIN || msg_id>");
- String _name_5 = pc.getName();
- _builder.append(_name_5, " ");
- _builder.append("_MSG_MAX+1){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("/* id out of range */");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("else{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return ");
- String _name_6 = pc.getName();
- _builder.append(_name_6, " ");
- _builder.append("_messageStrings[msg_id];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.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.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @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.roomExt.getGenerationTargetPath(pc);
+ String _path = this.roomExt.getPath(pc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(pc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(pc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etPort.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = pc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_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();
+ StringConcatenation _portClassHeader = this.portClassHeader(pc, ((Boolean)false));
+ _builder.append(_portClassHeader, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _portClassHeader_1 = this.portClassHeader(pc, ((Boolean)true));
+ _builder.append(_portClassHeader_1, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ StringConcatenation _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
+ _builder.append(_genDataDrivenPortHeaders, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_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();
+ DetailCode _userCode2 = pc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = pc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port methods */");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_equals) {
+ StringConcatenation _portClassSource = this.portClassSource(pc, ((Boolean)false));
+ _builder.append(_portClassSource, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _portClassSource_1 = this.portClassSource(pc, ((Boolean)true));
+ _builder.append(_portClassSource_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ StringConcatenation _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
+ _builder.append(_genDataDrivenPortSources, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final Message message : messages) {
+ _builder.append("\t");
+ VarDecl _data = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ boolean hasData = _operator_notEquals;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ 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();
+ _builder.append("\t");
+ String _xifexpression_2 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ boolean _operator_or = false;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef);
+ }
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
+ }
+ if (_operator_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_3 = _operator_plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_1 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_1, "_broadcast", data);
+ _builder.append(_messageSignature_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_2 = message.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_2, "", _operator_plus_3);
+ _builder.append(_messageSignature_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals_1) {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ StringConcatenation _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName);
+ _builder.append(_operationsDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_handleReceive(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genDataDrivenPortHeaders(final ProtocolClass pc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ return ((Boolean)_operator_notEquals);
+ }
+ };
+ Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ Iterable<Message> sentMsgs = _filter;
+ 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);
+ String typeName = _typeName;
+ _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.roomExt.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.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("* peer;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
+ _builder.append(_portClassName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ for(final Message message : sentMsgs) {
+ VarDecl _data_2 = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data_2, null);
+ boolean hasData = _operator_notEquals;
+ _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_1 = this._typeHelpers.typeName(_type_1);
+ _xifexpression_1 = _typeName_1;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName_1 = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
+ }
+ if (_operator_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp_1 = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName_1);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp_1);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_3 = _operator_plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _portClassName_3 = this.roomExt.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.roomExt.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 StringConcatenation genDataDrivenPortSources(final ProtocolClass pc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ return ((Boolean)_operator_notEquals);
+ }
+ };
+ Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ Iterable<Message> messages = _filter;
+ 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);
+ String typeName = _typeName;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression = null;
+ VarDecl _data_1 = message.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_2 = _data_2.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ if ((_type_2 instanceof PrimitiveType)) {
+ _xifexpression_1 = "&";
+ } else {
+ _xifexpression_1 = "";
+ }
+ String refa = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ String data = _operator_plus_2;
+ _builder.newLineIfNotEmpty();
+ String _portClassName = this.roomExt.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.roomExt.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 StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if (conj) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ boolean hasData = _operator_notEquals;
+ _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 _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
+ }
+ if (_operator_and) {
+ _xifexpression_3 = "*";
+ } else {
+ _xifexpression_3 = "";
+ }
+ String refp = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_4 = null;
+ boolean _operator_and_1 = false;
+ if (!hasData) {
+ _operator_and_1 = false;
+ } else {
+ boolean _operator_or = false;
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
+ }
+ _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
+ }
+ if (_operator_and_1) {
+ _xifexpression_4 = "*";
+ } else {
+ _xifexpression_4 = "";
+ }
+ String refpd = _xifexpression_4;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_5 = null;
+ boolean _operator_and_2 = false;
+ boolean _operator_and_3 = false;
+ if (!hasData) {
+ _operator_and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
+ }
+ if (!_operator_and_3) {
+ _operator_and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
+ _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
+ }
+ if (_operator_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_6 = _operator_plus_2;
+ } else {
+ _xifexpression_6 = "";
+ }
+ String data = _xifexpression_6;
+ _builder.newLineIfNotEmpty();
+ MessageHandler _sendHandler = this.roomExt.getSendHandler(message, conj);
+ MessageHandler hdlr = _sendHandler;
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_1) {
+ _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("if (self->receiveMessageFunc!=NULL) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
+ String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
+ String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
+ _builder.append(_sendMessageCall, " ");
+ _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_4 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_2) {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<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("((");
+ _builder.append(portClassName, " ");
+ _builder.append("*)&self->ports[i]");
+ _builder.append(data, " ");
+ _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<self->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_7 = pc.getName();
+ String _name_8 = message.getName();
+ String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_8);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_7, _operator_plus_6);
+ String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[i])", _memberInUse_1, _operator_plus_7, _operator_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 _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _operator_plus_9);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_3) {
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_10 = message.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("((");
+ _builder.append(portClassName, " ");
+ _builder.append("*)&self->ports[idx]");
+ _builder.append(data, " ");
+ _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<self->size) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_12 = pc.getName();
+ String _name_13 = message.getName();
+ String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_13);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_12, _operator_plus_10);
+ String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_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.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals_4) {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ StringConcatenation _operationsImplementation_1 = this.helpers.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 self->size;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ StringConcatenation _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 _operator_plus = StringExtensions.operator_plus("etPort_sendMessage(", self);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ", ");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, msg);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ", sizeof(");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, typeName);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "), ");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ");");
+ _xifexpression = _operator_plus_7;
+ } else {
+ String _operator_plus_8 = StringExtensions.operator_plus("etPort_sendMessage(", self);
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, ", ");
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, msg);
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", 0, NULL);");
+ _xifexpression = _operator_plus_11;
+ }
+ return _xifexpression;
+ }
+
+ private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
+ String _operator_plus = StringExtensions.operator_plus("void ", className);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, methodSuffix);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "(const ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* self");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, data);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ")");
+ return _operator_plus_8;
+ }
+
+ private String messageSetterSignature(final String className, final String messageName, final String data) {
+ String _operator_plus = StringExtensions.operator_plus("void ", className);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "_set(");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, className);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "* self");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ")");
+ return _operator_plus_7;
+ }
+
+ private String messageGetterSignature(final String className, final String messageName, final String type) {
+ String _operator_plus = StringExtensions.operator_plus(type, " ");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, className);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, messageName);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_get(const ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* const self)");
+ return _operator_plus_6;
+ }
+
+ private StringConcatenation messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ private StringConcatenation genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* receiver handlers */");
+ _builder.newLine();
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_handleReceive(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("switch (msg->evtID){");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("\t");
+ _builder.append("case ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _codeName = this.roomExt.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ DetailCode _detailCode = h.getDetailCode();
+ StringConcatenation _userCode = this.helpers.userCode(_detailCode);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("default:receiveMessageFunc(actor, self, msg);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("static const char* ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\", ");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (msg_id<");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_MSG_MIN || msg_id>");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_MSG_MAX+1){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("/* id out of range */");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_messageStrings[msg_id];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
index e54d9a3..dcaf983 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,103 +1,103 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- public StringConcatenation genHeaderConstants(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _xblockexpression = null;
- {
- List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(xpac);
- int _size = _allBaseStates.size();
- List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
- int _size_1 = _allLeafStates.size();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_operator_minus), ((Integer)2));
- int historySize = _operator_plus;
- 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 StringConcatenation genDataMembers(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* state machine variables */");
- _builder.newLine();
- _builder.append("etInt16 state;");
- _builder.newLine();
- _builder.append("etInt16 history[");
- String _name = ac.getName();
- String _upperCase = _name.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_HISTORY_SIZE];");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation genInitialization(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("self->state = STATE_TOP;");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int i;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("for (i=0; i<");
- 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();
- return _builder;
- }
-
- public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- String _accessLevelPrivate = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate, "");
- _builder.append("void setState(");
- String _name = ac.getName();
- _builder.append(_name, "");
- _builder.append("* self, int new_state) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("self->state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public StringConcatenation genHeaderConstants(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(xpac);
+ int _size = _allBaseStates.size();
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
+ int _size_1 = _allLeafStates.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_operator_minus), ((Integer)2));
+ int historySize = _operator_plus;
+ 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 StringConcatenation genDataMembers(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* state machine variables */");
+ _builder.newLine();
+ _builder.append("etInt16 state;");
+ _builder.newLine();
+ _builder.append("etInt16 history[");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_HISTORY_SIZE];");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation genInitialization(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("self->state = STATE_TOP;");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<");
+ 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();
+ return _builder;
+ }
+
+ public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void setState(");
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append("* self, int new_state) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
new file mode 100644
index 0000000..9d7bcf1
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -0,0 +1,1443 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashMap;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
+import org.eclipse.etrice.generator.etricegen.PortInstance;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance ssi : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(_subSystemClass_2);
+ String file = _cHeaderFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass declaration: \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generateHeaderFile);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_4);
+ file = _cSourceFileName;
+ String _operator_plus_5 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
+ this.fileAccess.generateFile(file, _generateSourceFile);
+ SubSystemClass _subSystemClass_6 = ssi.getSubSystemClass();
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_6);
+ file = _instSourceFileName;
+ String _operator_plus_9 = StringExtensions.operator_plus("generating SubSystemClass instance file: \'", file);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\' in \'");
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, path);
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "\'");
+ this.logger.logInfo(_operator_plus_12);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_7 = ssi.getSubSystemClass();
+ StringConcatenation _generateInstanceFile = this.generateInstanceFile(root, ssi, _subSystemClass_7);
+ this.fileAccess.generateFile(file, _generateInstanceFile);
+ SubSystemClass _subSystemClass_8 = ssi.getSubSystemClass();
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_8);
+ file = _dispSourceFileName;
+ String _operator_plus_13 = StringExtensions.operator_plus("generating SubSystemClass dispatcher file: \'", file);
+ String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, "\' in \'");
+ String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, path);
+ String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, "\'");
+ this.logger.logInfo(_operator_plus_16);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_9 = ssi.getSubSystemClass();
+ StringConcatenation _generateDispatcherFile = this.generateDispatcherFile(root, ssi, _subSystemClass_9);
+ this.fileAccess.generateFile(file, _generateDispatcherFile);
+ }
+ }
+ }
+
+ private StringConcatenation generateHeaderFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = ssc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode1 = ssc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* lifecycle functions");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* init -> start -> run (loop) -> stop -> destroy");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_init(void);\t\t/* lifecycle init \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_start(void);\t/* lifecycle start \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_run(void);\t\t/* lifecycle run \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("_stop(void); \t/* lifecycle stop\t */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_destroy(void); \t/* lifecycle destroy */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = ssc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_shutdown(void); /* shutdown the dispatcher loop */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = ssc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_8 = ssc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_8);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(ssc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* include instances for all classes */");
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(ssc);
+ _builder.append(_instSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"");
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(ssc);
+ _builder.append(_dispSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"platform/etTimer.h\"");
+ _builder.newLine();
+ _builder.append("#include \"etGlobalFlags.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = ssc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data for SubSysten ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef struct ");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("char *name;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("volatile int shutdownRequest;");
+ _builder.newLine();
+ _builder.append("} ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("static ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("Inst = {\"");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("\",0};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = ssc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_initActorInstances(void);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_8 = ssc.getName();
+ _builder.append(_name_8, "");
+ _builder.append("_constructActorInstances(void);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_9 = ssc.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_init(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"init\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_init\", ");
+ String _name_10 = ssc.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* construct all actors */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_11 = ssc.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("_constructActorInstances();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* initialization of all message services */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_Thread1_receiveMessage);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* init all actors */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_12 = ssc.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("_initActorInstances();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_13 = ssc.getName();
+ _builder.append(_name_13, "");
+ _builder.append("_start(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"start\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_start\", ");
+ String _name_14 = ssc.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_15 = ssc.getName();
+ _builder.append(_name_15, "");
+ _builder.append("_run(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"run\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#ifdef ET_RUNTIME_ENDLESS");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("while(!(");
+ String _name_16 = ssc.getName();
+ _builder.append(_name_16, " ");
+ _builder.append("Inst.shutdownRequest)){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("if (etTimer_executeNeeded()){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("etMessageService_execute(&msgService_Thread1);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ StringConcatenation _generateDatadrivenExecutes = this.generateDatadrivenExecutes(root, ssi);
+ _builder.append(_generateDatadrivenExecutes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("uint32 loopCounter = 0;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("while(!(");
+ String _name_17 = ssc.getName();
+ _builder.append(_name_17, " ");
+ _builder.append("Inst.shutdownRequest)){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("if (etTimer_executeNeeded()){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("etMessageService_execute(&msgService_Thread1);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ StringConcatenation _generateDatadrivenExecutes_1 = this.generateDatadrivenExecutes(root, ssi);
+ _builder.append(_generateDatadrivenExecutes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("etLogger_logInfo(\"Execute\");");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("if (loopCounter++ > ET_RUNTIME_MAXLOOP){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#endif");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_18 = ssc.getName();
+ _builder.append(_name_18, "");
+ _builder.append("_stop(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"stop\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_stop\", ");
+ String _name_19 = ssc.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_20 = ssc.getName();
+ _builder.append(_name_20, "");
+ _builder.append("_destroy(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"destroy\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_destroy\", ");
+ String _name_21 = ssc.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ Iterable<ActorInstance> _reverseView = ListExtensions.<ActorInstance>reverseView(_allContainedInstances);
+ for(final ActorInstance ai : _reverseView) {
+ {
+ ActorClass _actorClass = ai.getActorClass();
+ EList<StandardOperation> _operations = _actorClass.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return ((Boolean)_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ boolean _isEmpty = IterableExtensions.isEmpty(_filter);
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("\t");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_22 = _actorClass_1.getName();
+ _builder.append(_name_22, " ");
+ _builder.append("_dtor(&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_23 = ssc.getName();
+ _builder.append(_name_23, "");
+ _builder.append("_shutdown(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"shutdown\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_shutdown\", ");
+ String _name_24 = ssc.getName();
+ _builder.append(_name_24, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_25 = ssc.getName();
+ _builder.append(_name_25, " ");
+ _builder.append("Inst.shutdownRequest = 1;");
+ _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_26 = ssc.getName();
+ _builder.append(_name_26, "");
+ _builder.append("_constructActorInstances(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_27 = ssc.getName();
+ _builder.append(_name_27, " ");
+ _builder.append("\", \"constructActorInstances\")");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ {
+ ActorClass _actorClass_2 = ai_1.getActorClass();
+ EList<StandardOperation> _operations_1 = _actorClass_2.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return ((Boolean)_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(_filter_1);
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
+ if (_operator_not_1) {
+ _builder.append("\t");
+ ActorClass _actorClass_3 = ai_1.getActorClass();
+ String _name_28 = _actorClass_3.getName();
+ _builder.append(_name_28, " ");
+ _builder.append("_ctor(&");
+ String _path_1 = ai_1.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_29 = ssc.getName();
+ _builder.append(_name_29, "");
+ _builder.append("_initActorInstances(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_30 = ssc.getName();
+ _builder.append(_name_30, " ");
+ _builder.append("\", \"initActorInstances\")");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_2) {
+ _builder.append("\t");
+ ActorClass _actorClass_4 = ai_2.getActorClass();
+ String _name_31 = _actorClass_4.getName();
+ _builder.append(_name_31, " ");
+ _builder.append("_init(&");
+ String _path_2 = ai_2.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation generateInstanceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Instance File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - instantiation of all actor instances and port instances");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* - configuration of data and connection of ports");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessageService.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etMemory.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* instantiation of message services */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* MessageService for Thread1 */");
+ _builder.newLine();
+ _builder.append("static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];");
+ _builder.newLine();
+ _builder.append("static etMessageService msgService_Thread1;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* include all used ActorClasses */");
+ _builder.newLine();
+ {
+ EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
+ for(final ActorClass actorClass : _usedActorClasses) {
+ _builder.append("#include \"");
+ String _name_1 = actorClass.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* include all used ProtcolClasses */");
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for(final ProtocolClass protocolClass : _usedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_2 = protocolClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* declarations of all ActorClass instances (const and variable structs) */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* forward declaration of variable actor structs */");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("static ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" ");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ _builder.newLine();
+ _builder.append("/* instance ");
+ String _path_1 = ai_1.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/* no ports/saps/services - nothing to initialize statically */");
+ _builder.newLine();
+ } else {
+ StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_1);
+ _builder.append(_genActorInstanceInitializer, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation genActorInstanceInitializer(final Root root, final ActorInstance ai) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String instName = _pathName;
+ ArrayList<InterfaceItemInstance> _arrayList = new ArrayList<InterfaceItemInstance>();
+ ArrayList<InterfaceItemInstance> replPorts = _arrayList;
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ final Function1<InterfaceItemInstance,Boolean> _function = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ boolean _isReplicated = e.isReplicated();
+ return ((Boolean)_isReplicated);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances, _function);
+ CollectionExtensions.<InterfaceItemInstance>addAll(replPorts, _filter);
+ final Function1<InterfaceItemInstance,Boolean> _function_1 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ EList<InterfaceItemInstance> _peers = e.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ return ((Boolean)_operator_not);
+ }
+ };
+ InterfaceItemInstance _findFirst = IterableExtensions.<InterfaceItemInstance>findFirst(replPorts, _function_1);
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_findFirst, null);
+ boolean haveReplSubPorts = _operator_notEquals;
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai.getOrderedIfItemInstances();
+ final Function1<InterfaceItemInstance,Boolean> _function_2 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ boolean _isSimple = e.isSimple();
+ return ((Boolean)_isSimple);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_1 = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances_1, _function_2);
+ Iterable<InterfaceItemInstance> simplePorts = _filter_1;
+ ArrayList<InterfaceItemInstance> _arrayList_1 = new ArrayList<InterfaceItemInstance>();
+ ArrayList<InterfaceItemInstance> eventPorts = _arrayList_1;
+ final Function1<InterfaceItemInstance,Boolean> _function_3 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ InterfaceItem _interfaceItem = p.getInterfaceItem();
+ ProtocolClass _protocol = _interfaceItem.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_2 = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_3);
+ Iterable<InterfaceItemInstance> _union = this.roomExt.<InterfaceItemInstance>union(_filter_2, replPorts);
+ CollectionExtensions.<InterfaceItemInstance>addAll(eventPorts, _union);
+ final Function1<InterfaceItemInstance,Boolean> _function_4 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ InterfaceItem _interfaceItem = p.getInterfaceItem();
+ ProtocolClass _protocol = _interfaceItem.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.DATA_DRIVEN);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_3 = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_4);
+ Iterable<InterfaceItemInstance> dataPorts = _filter_3;
+ final Function1<InterfaceItemInstance,Boolean> _function_5 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ boolean _operator_and = false;
+ if (!(p instanceof PortInstance)) {
+ _operator_and = false;
+ } else {
+ Port _port = ((PortInstance) p).getPort();
+ boolean _isConjugated = _port.isConjugated();
+ boolean _operator_not = BooleanExtensions.operator_not(_isConjugated);
+ _operator_and = BooleanExtensions.operator_and((p instanceof PortInstance), _operator_not);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_4 = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_5);
+ Iterable<InterfaceItemInstance> recvPorts = _filter_4;
+ final Function1<InterfaceItemInstance,Boolean> _function_6 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ boolean _operator_and = false;
+ if (!(p instanceof PortInstance)) {
+ _operator_and = false;
+ } else {
+ Port _port = ((PortInstance) p).getPort();
+ boolean _isConjugated = _port.isConjugated();
+ _operator_and = BooleanExtensions.operator_and((p instanceof PortInstance), _isConjugated);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_5 = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_6);
+ Iterable<InterfaceItemInstance> sendPorts = _filter_5;
+ HashMap<InterfaceItemInstance,Integer> _hashMap = new HashMap<InterfaceItemInstance,Integer>();
+ HashMap<InterfaceItemInstance,Integer> offsets = _hashMap;
+ int offset = 0;
+ for (final InterfaceItemInstance p : replPorts) {
+ {
+ offsets.put(p, ((Integer)offset));
+ EList<InterfaceItemInstance> _peers = p.getPeers();
+ int _size = _peers.size();
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)_size));
+ offset = _operator_plus;
+ }
+ }
+ String _xifexpression = null;
+ if (haveReplSubPorts) {
+ String _operator_plus_1 = StringExtensions.operator_plus(instName, "_repl_sub_ports");
+ _xifexpression = _operator_plus_1;
+ } else {
+ _xifexpression = "NULL";
+ }
+ String replSubPortsArray = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ if (haveReplSubPorts) {
+ _builder.append("static const etReplSubPort ");
+ _builder.append(replSubPortsArray, "");
+ _builder.append("[");
+ _builder.append(offset, "");
+ _builder.append("] = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, index} */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements = false;
+ for(final InterfaceItemInstance pi : replPorts) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi);
+ _builder.append(_genReplSubPortInitializers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _operator_and = false;
+ boolean _isEmpty = eventPorts.isEmpty();
+ if (!_isEmpty) {
+ _operator_and = false;
+ } else {
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
+ _operator_and = BooleanExtensions.operator_and(_isEmpty, _isEmpty_1);
+ }
+ boolean _operator_not = BooleanExtensions.operator_not(_operator_and);
+ if (_operator_not) {
+ _builder.append("static const ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ _builder.append(_name, "");
+ _builder.append("_const ");
+ _builder.append(instName, "");
+ _builder.append("_const = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements_1 = false;
+ for(final InterfaceItemInstance pi_1 : eventPorts) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _isSimple = pi_1.isSimple();
+ if (_isSimple) {
+ _builder.append("\t");
+ String _genPortInitializer = this.genPortInitializer(root, ai, pi_1);
+ _builder.append(_genPortInitializer, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("{");
+ EList<InterfaceItemInstance> _peers_1 = pi_1.getPeers();
+ int _size_1 = _peers_1.size();
+ _builder.append(_size_1, " ");
+ _builder.append(", ");
+ _builder.append(replSubPortsArray, " ");
+ _builder.append("+");
+ Integer _get = offsets.get(pi_1);
+ _builder.append(_get, " ");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ {
+ boolean _operator_and_1 = false;
+ boolean _isEmpty_2 = eventPorts.isEmpty();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_2);
+ if (!_operator_not_1) {
+ _operator_and_1 = false;
+ } else {
+ boolean _isEmpty_3 = IterableExtensions.isEmpty(recvPorts);
+ boolean _operator_not_2 = BooleanExtensions.operator_not(_isEmpty_3);
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_not_1, _operator_not_2);
+ }
+ if (_operator_and_1) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* data receive ports */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements_2 = false;
+ for(final InterfaceItemInstance pi_2 : recvPorts) {
+ if (!hasAnyElements_2) {
+ hasAnyElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _genRecvPortInitializer = this.genRecvPortInitializer(root, ai, pi_2);
+ _builder.append(_genRecvPortInitializer, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("static ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_1 = _actorClass_1.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" ");
+ _builder.append(instName, "");
+ _builder.append(" = {&");
+ _builder.append(instName, "");
+ _builder.append("_const};");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String genPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
+ String _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ if (_isEmpty) {
+ _xifexpression = "NULL";
+ } else {
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_receiveMessage");
+ _xifexpression = _operator_plus;
+ }
+ String recvMsg = _xifexpression;
+ int _xifexpression_1 = (int) 0;
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ boolean _isEmpty_1 = _peers_1.isEmpty();
+ if (_isEmpty_1) {
+ _xifexpression_1 = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ InterfaceItemInstance _get = _peers_2.get(0);
+ int _objId = _get.getObjId();
+ _xifexpression_1 = _objId;
+ }
+ int objId = _xifexpression_1;
+ int _xifexpression_2 = (int) 0;
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ boolean _isEmpty_2 = _peers_3.isEmpty();
+ if (_isEmpty_2) {
+ _xifexpression_2 = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ InterfaceItemInstance _get_1 = _peers_4.get(0);
+ EList<InterfaceItemInstance> _peers_5 = _get_1.getPeers();
+ int _indexOf = _peers_5.indexOf(pi);
+ _xifexpression_2 = _indexOf;
+ }
+ int idx = _xifexpression_2;
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _operator_plus_1 = StringExtensions.operator_plus("{&", _pathName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, recvMsg);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, ", ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
+ int _operator_plus_6 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_operator_plus_6));
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
+ int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, "} /* Port ");
+ String _name_1 = pi.getName();
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, _name_1);
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, " */");
+ _xblockexpression = (_operator_plus_13);
+ }
+ return _xblockexpression;
+ }
+
+ private String genRecvPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
+ String _xblockexpression = null;
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ if (_isEmpty) {
+ return "{NULL}";
+ }
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ InterfaceItemInstance _get = _peers_1.get(0);
+ InterfaceItemInstance peer = _get;
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ InterfaceItemInstance _get_1 = _peers_2.get(0);
+ EObject _eContainer = _get_1.eContainer();
+ ActorInstance peerInst = ((ActorInstance) _eContainer);
+ String _path = peerInst.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String instName = _pathName;
+ String _operator_plus = StringExtensions.operator_plus("{&", instName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
+ String _name = peer.getName();
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _name);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "}");
+ _xblockexpression = (_operator_plus_3);
+ }
+ return _xblockexpression;
+ }
+
+ private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
+ String result = "";
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for (final InterfaceItemInstance p : _peers) {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(p);
+ int idx = _indexOf;
+ String _xifexpression = null;
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _size = _peers_2.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
+ boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)idx), ((Integer)_operator_minus));
+ if (_operator_lessThan) {
+ _xifexpression = ",";
+ } else {
+ _xifexpression = "";
+ }
+ String comma = _xifexpression;
+ String _operator_plus = StringExtensions.operator_plus(result, "{&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _pathName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_receiveMessage, ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
+ int _objId = p.getObjId();
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_objId));
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
+ int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, ", ");
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ((Integer)idx));
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "}");
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, comma);
+ String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, " /* Repl Sub Port ");
+ String _name_1 = pi.getName();
+ String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, _name_1);
+ String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, " idx +");
+ String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, ((Integer)idx));
+ String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, "*/\n");
+ result = _operator_plus_18;
+ }
+ }
+ return result;
+ }
+
+ private StringConcatenation generateDispatcherFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Dispatcher File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - one generated dispatcher for each MessageService (Thread)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessageReceiver.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_Thread1\", \"receiveMessage\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("switch(msg->address){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("\t\t");
+ _builder.append("/* interface items of ");
+ String _path = ai.getPath();
+ _builder.append(_path, " ");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ final Function1<InterfaceItemInstance,Boolean> _function = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ InterfaceItem _interfaceItem = p.getInterfaceItem();
+ ProtocolClass _protocol = _interfaceItem.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances, _function);
+ for(final InterfaceItemInstance pi : _filter) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId = pi.getObjId();
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(peer);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_objId), ((Integer)_indexOf));
+ _builder.append(_operator_plus, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ {
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ ProtocolClass _protocol = _interfaceItem.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ boolean _handlesReceive = this.roomExt.handlesReceive(_protocol, _isConjugated);
+ if (_handlesReceive) {
+ _builder.append("\t\t");
+ InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
+ ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ String _portClassName = this.roomExt.getPortClassName(_protocol_1, _isConjugated_1);
+ _builder.append(_portClassName, " ");
+ _builder.append("_handleReceive((etPort*)&");
+ String _path_1 = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append("_const.");
+ String _name_1 = pi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_1 = _peers_2.indexOf(peer);
+ _builder.append(_indexOf_1, " ");
+ _builder.append("],msg,(void*)&");
+ String _path_2 = ai.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_1, " ");
+ _builder.append(",");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_2 = _actorClass.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("_receiveMessage);");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("//etPort_receive((etPort*)&");
+ String _path_3 = ai.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_2, " ");
+ _builder.append("_const.");
+ String _name_3 = pi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ int _indexOf_2 = _peers_3.indexOf(peer);
+ _builder.append(_indexOf_2, " ");
+ _builder.append("], msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_4 = _actorClass_1.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_4 = ai.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_4);
+ _builder.append(_pathName_3, " ");
+ _builder.append(",(etPort*)&");
+ String _path_5 = ai.getPath();
+ String _pathName_4 = this.roomExt.getPathName(_path_5);
+ _builder.append(_pathName_4, " ");
+ _builder.append("_const.");
+ String _name_5 = pi.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ int _indexOf_3 = _peers_4.indexOf(peer);
+ _builder.append(_indexOf_3, " ");
+ _builder.append("], msg);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId_1 = pi.getObjId();
+ _builder.append(_objId_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ {
+ InterfaceItem _interfaceItem_2 = pi.getInterfaceItem();
+ ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol();
+ boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
+ boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_2, _isConjugated_2);
+ if (_handlesReceive_1) {
+ _builder.append("\t\t");
+ InterfaceItem _interfaceItem_3 = pi.getInterfaceItem();
+ ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol();
+ boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
+ String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("_handleReceive((etPort*)&");
+ String _path_6 = ai.getPath();
+ String _pathName_5 = this.roomExt.getPathName(_path_6);
+ _builder.append(_pathName_5, " ");
+ _builder.append("_const.");
+ String _name_6 = pi.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(",msg,(void*)&");
+ String _path_7 = ai.getPath();
+ String _pathName_6 = this.roomExt.getPathName(_path_7);
+ _builder.append(_pathName_6, " ");
+ _builder.append(",");
+ ActorClass _actorClass_2 = ai.getActorClass();
+ String _name_7 = _actorClass_2.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("_receiveMessage);");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("//etPort_receive(&");
+ String _path_8 = ai.getPath();
+ String _pathName_7 = this.roomExt.getPathName(_path_8);
+ _builder.append(_pathName_7, " ");
+ _builder.append("_const.");
+ String _name_8 = pi.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ ActorClass _actorClass_3 = ai.getActorClass();
+ String _name_9 = _actorClass_3.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_9 = ai.getPath();
+ String _pathName_8 = this.roomExt.getPathName(_path_9);
+ _builder.append(_pathName_8, " ");
+ _builder.append(",(etPort*)&");
+ String _path_10 = ai.getPath();
+ String _pathName_9 = this.roomExt.getPathName(_path_10);
+ _builder.append(_pathName_9, " ");
+ _builder.append("_const.");
+ String _name_10 = pi.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("default:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("etLogger_logErrorF(\"MessageService_Thread1_receiveMessage: address %d does not exist \", msg->address);");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation generateDatadrivenExecutes(final Root root, final SubSystemInstance ssi) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ {
+ boolean _operator_or = false;
+ ActorClass _actorClass = ai.getActorClass();
+ ActorCommunicationType _commType = _actorClass.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ if (_operator_equals) {
+ _operator_or = true;
+ } else {
+ ActorClass _actorClass_1 = ai.getActorClass();
+ ActorCommunicationType _commType_1 = _actorClass_1.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.DATA_DRIVEN);
+ _operator_or = BooleanExtensions.operator_or(_operator_equals, _operator_equals_1);
+ }
+ if (_operator_or) {
+ ActorClass _actorClass_2 = ai.getActorClass();
+ String _name = _actorClass_2.getName();
+ _builder.append(_name, "");
+ _builder.append("_execute(&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
index 1e5f170..1cc0bbd 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,172 +1,172 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- this.fileAccess.setOutputPath(_operator_plus);
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "_Runner.c");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_operator_plus_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* this class contains the main function running component ");
- String _name = ssi.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = ssi.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _name_2 = ssi.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"debugging/etLogger.h\"");
- _builder.newLine();
- _builder.append("#include \"debugging/etMSCLogger.h\"");
- _builder.newLine();
- _builder.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.room.SubSystemClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ this.fileAccess.setOutputPath(_operator_plus);
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "_Runner.c");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_operator_plus_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssi.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _name_2 = ssi.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.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 5982914..6f67258 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,1017 +1,1017 @@
-package org.eclipse.etrice.generator.doc.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.File;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-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.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.Documentation;
-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.SubSystemClass;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.base.IRoomGenerator;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class 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 _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String path = _docGenerationTargetPath;
- String _name = model.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".tex");
- String file = _operator_plus;
- String _operator_plus_1 = StringExtensions.operator_plus("generating LaTeX documentation: \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- StringConcatenation _generateModelDoc = this.generateModelDoc(root, model);
- this.fileAccess.generateFile(file, _generateModelDoc);
- }
- }
- }
-
- public StringConcatenation 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();
- StringConcatenation _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Subsystem Description}");
- _builder.newLine();
- StringConcatenation _generateAllSubSysClassDocs = this.generateAllSubSysClassDocs(root, model);
- _builder.append(_generateAllSubSysClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Protocol Class Description}");
- _builder.newLine();
- StringConcatenation _generateAllProtocolClassDocs = this.generateAllProtocolClassDocs(root, model);
- _builder.append(_generateAllProtocolClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Data Class Description}");
- _builder.newLine();
- StringConcatenation _generateAllDataClassDocs = this.generateAllDataClassDocs(root, model);
- _builder.append(_generateAllDataClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\section{Actor Class Description}");
- _builder.newLine();
- StringConcatenation _generateAllActorClassDocs = this.generateAllActorClassDocs(root, model);
- _builder.append(_generateAllActorClassDocs, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\end{document}");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateAllSubSysClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<SubSystemClass> _subSystemClasses = model.getSubSystemClasses();
- for(final SubSystemClass ssc : _subSystemClasses) {
- StringConcatenation _generateSubSysClassDoc = this.generateSubSysClassDoc(root, model, ssc);
- _builder.append(_generateSubSysClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public StringConcatenation generateSubSysClassDoc(final Root root, final RoomModel model, final SubSystemClass ssc) {
- StringConcatenation _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
- String _name = ssc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_structure.jpg");
- String filename = _operator_plus_2;
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String _replaceAll_1 = filename.replaceAll("/", "//");
- String latexFilename = _replaceAll_1;
- String _docGenerationTargetPath_1 = this.roomExt.getDocGenerationTargetPath(model);
- String _operator_plus_3 = StringExtensions.operator_plus(_docGenerationTargetPath_1, "images\\");
- String _name_1 = ssc.getName();
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, _name_1);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "_instanceTree.jpg");
- String filenamei = _operator_plus_5;
- String _replaceAll_2 = filenamei.replaceAll("\\\\", "/");
- filenamei = _replaceAll_2;
- String _replaceAll_3 = filenamei.replaceAll("/", "//");
- String latexFilenamei = _replaceAll_3;
- 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();
- StringConcatenation _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 _operator_plus_6 = StringExtensions.operator_plus(_name_3, " Structure");
- StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_6);
- _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 _operator_plus_7 = StringExtensions.operator_plus(_name_4, " Instance Tree");
- StringConcatenation _includeGraphics_1 = this.includeGraphics(latexFilenamei, "0.5", _operator_plus_7);
- _builder.append(_includeGraphics_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation generateAllDataClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<DataClass> _dataClasses = model.getDataClasses();
- for(final DataClass dc : _dataClasses) {
- StringConcatenation _generateDataClassDoc = this.generateDataClassDoc(root, dc);
- _builder.append(_generateDataClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public StringConcatenation 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();
- StringConcatenation _generateDocText = this.generateDocText(_docu);
- _builder.append(_generateDocText, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\\level{3}{Attributes}");
- _builder.newLine();
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _generateAttributesDoc = this.generateAttributesDoc(_attributes);
- _builder.append(_generateAttributesDoc, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\\level{3}{Operations}");
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- StringConcatenation _generateOperationsDoc = this.generateOperationsDoc(_operations);
- _builder.append(_generateOperationsDoc, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation generateAllProtocolClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<ProtocolClass> _protocolClasses = model.getProtocolClasses();
- for(final ProtocolClass pc : _protocolClasses) {
- StringConcatenation _generateProtocolClassDoc = this.generateProtocolClassDoc(root, pc);
- _builder.append(_generateProtocolClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public StringConcatenation 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();
- StringConcatenation _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_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();
- StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_2, null);
- if (_operator_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();
- StringConcatenation _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;
- }
-
- public StringConcatenation generateAllActorClassDocs(final Root root, final RoomModel model) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<ActorClass> _actorClasses = model.getActorClasses();
- for(final ActorClass ac : _actorClasses) {
- StringConcatenation _generateActorClassDoc = this.generateActorClassDoc(root, model, ac);
- _builder.append(_generateActorClassDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public StringConcatenation generateActorClassDoc(final Root root, final RoomModel model, final ActorClass ac) {
- StringConcatenation _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
- String _name = ac.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_structure.jpg");
- String filename = _operator_plus_2;
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String _replaceAll_1 = filename.replaceAll("/", "//");
- String latexFilename = _replaceAll_1;
- 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();
- StringConcatenation _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 _operator_plus_3 = StringExtensions.operator_plus(_name_2, " Structure");
- StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_3);
- _builder.append(_includeGraphics, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\\level{3}{Attributes}");
- _builder.newLine();
- EList<Attribute> _attributes = ac.getAttributes();
- StringConcatenation _generateAttributesDoc = this.generateAttributesDoc(_attributes);
- _builder.append(_generateAttributesDoc, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\\level{3}{Operations}");
- _builder.newLine();
- EList<StandardOperation> _operations = ac.getOperations();
- StringConcatenation _generateOperationsDoc = this.generateOperationsDoc(_operations);
- _builder.append(_generateOperationsDoc, "");
- _builder.newLineIfNotEmpty();
- {
- boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(ac);
- if (_hasNonEmptyStateMachine) {
- _builder.append("\\level{3}{Statemachine}");
- _builder.newLine();
- StringConcatenation _generateFsmDoc = this.generateFsmDoc(model, ac);
- _builder.append(_generateFsmDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation generateFsmDoc(final RoomModel model, final ActorClass ac) {
- StringConcatenation _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
- String _name = ac.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_behavior.jpg");
- String filename = _operator_plus_2;
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String _replaceAll_1 = filename.replaceAll("/", "//");
- String latexFilename = _replaceAll_1;
- 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 _operator_plus_3 = StringExtensions.operator_plus(_name_1, " Top State");
- StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_3);
- _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_docu, null);
- if (_operator_notEquals) {
- _builder.append("\\textbf{State description} \\textit{");
- String _statePathName = this.roomExt.getStatePathName(s);
- String _replaceAll_2 = _statePathName.replaceAll("_", "\\\\_");
- _builder.append(_replaceAll_2, "");
- _builder.append("}:");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline");
- _builder.newLine();
- Documentation _docu_1 = s.getDocu();
- StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_docu_2, null);
- if (_operator_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();
- StringConcatenation _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 _operator_not = BooleanExtensions.operator_not(_isLeaf);
- if (_operator_not) {
- StringConcatenation _generateStateDoc = this.generateStateDoc(model, ac, s_1);
- _builder.append(_generateStateDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation generateStateDoc(final RoomModel model, final ActorClass ac, final State state) {
- StringConcatenation _xblockexpression = null;
- {
- String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
- String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
- String _name = ac.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
- String _statePathName = this.roomExt.getStatePathName(state);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _statePathName);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_behavior.jpg");
- String filename = _operator_plus_4;
- String _replaceAll = filename.replaceAll("\\\\", "/");
- filename = _replaceAll;
- String _replaceAll_1 = filename.replaceAll("/", "//");
- String latexFilename = _replaceAll_1;
- String _operator_plus_5 = StringExtensions.operator_plus("Gen Filename: ", filename);
- this.logger.logInfo(_operator_plus_5);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\\level{4}{Subgraph ");
- String _statePathName_1 = this.roomExt.getStatePathName(state);
- String _replaceAll_2 = _statePathName_1.replaceAll("_", "\\\\_");
- _builder.append(_replaceAll_2, "");
- _builder.append("}");
- _builder.newLineIfNotEmpty();
- {
- String _fileExists = this.fileExists(filename);
- boolean _equals = _fileExists.equals("true");
- if (_equals) {
- String _name_1 = ac.getName();
- String _operator_plus_6 = StringExtensions.operator_plus(_name_1, "_");
- String _statePathName_2 = this.roomExt.getStatePathName(state);
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, _statePathName_2);
- StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_7);
- _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_docu, null);
- if (_operator_notEquals) {
- _builder.append("\\textbf{State description} \\textit{");
- String _statePathName_3 = this.roomExt.getStatePathName(s);
- String _replaceAll_3 = _statePathName_3.replaceAll("_", "\\\\_");
- _builder.append(_replaceAll_3, "");
- _builder.append("}:");
- _builder.newLineIfNotEmpty();
- _builder.append("\\newline");
- _builder.newLine();
- Documentation _docu_1 = s.getDocu();
- StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_docu_2, null);
- if (_operator_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();
- StringConcatenation _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 _operator_not = BooleanExtensions.operator_not(_isLeaf);
- if (_operator_not) {
- StringConcatenation _generateStateDoc = this.generateStateDoc(model, ac, s_1);
- _builder.append(_generateStateDoc, "");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation generateAttributesDoc(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isEmpty = attributes.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_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();
- StringConcatenation _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 StringConcatenation 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 _operator_notEquals = ObjectExtensions.operator_notEquals(_returntype, null);
- if (_operator_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 hasAnyElements = false;
- for(final VarDecl pa : _arguments) {
- if (!hasAnyElements) {
- hasAnyElements = 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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_docu, null);
- if (_operator_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 _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_length), ((Integer)85));
- if (_operator_greaterThan) {
- _builder.append("\t");
- _builder.append("\\multicolumn{2} {|p{13cm}|} {");
- Documentation _docu_2 = op.getDocu();
- StringConcatenation _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();
- StringConcatenation _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 StringConcatenation generateDocText(final Documentation doc) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(doc, null);
- if (_operator_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;
- boolean _exists = file.exists();
- final boolean exist = _exists;
- boolean _operator_equals = ObjectExtensions.operator_equals(((Boolean)exist), ((Boolean)true));
- if (_operator_equals) {
- {
- String _operator_plus = StringExtensions.operator_plus("File found ! ", f);
- this.logger.logInfo(_operator_plus);
- return "true";
- }
- } else {
- {
- String _operator_plus_1 = StringExtensions.operator_plus("File not found ! ", f);
- this.logger.logInfo(_operator_plus_1);
- return "false";
- }
- }
- }
-
- public StringConcatenation includeGraphics(final String filename, final String scale, final String caption) {
- StringConcatenation _xblockexpression = null;
- {
- String _replaceAll = caption.replaceAll("_", "\\\\_");
- String latexCaption = _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();
- String _operator_plus = StringExtensions.operator_plus(_name, ".bla");
- return _operator_plus;
- }
-}
+package org.eclipse.etrice.generator.doc.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.io.File;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+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.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.Documentation;
+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.SubSystemClass;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class 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 _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String path = _docGenerationTargetPath;
+ String _name = model.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".tex");
+ String file = _operator_plus;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating LaTeX documentation: \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ StringConcatenation _generateModelDoc = this.generateModelDoc(root, model);
+ this.fileAccess.generateFile(file, _generateModelDoc);
+ }
+ }
+ }
+
+ public StringConcatenation 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();
+ StringConcatenation _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Subsystem Description}");
+ _builder.newLine();
+ StringConcatenation _generateAllSubSysClassDocs = this.generateAllSubSysClassDocs(root, model);
+ _builder.append(_generateAllSubSysClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Protocol Class Description}");
+ _builder.newLine();
+ StringConcatenation _generateAllProtocolClassDocs = this.generateAllProtocolClassDocs(root, model);
+ _builder.append(_generateAllProtocolClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Data Class Description}");
+ _builder.newLine();
+ StringConcatenation _generateAllDataClassDocs = this.generateAllDataClassDocs(root, model);
+ _builder.append(_generateAllDataClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\section{Actor Class Description}");
+ _builder.newLine();
+ StringConcatenation _generateAllActorClassDocs = this.generateAllActorClassDocs(root, model);
+ _builder.append(_generateAllActorClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\end{document}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateAllSubSysClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<SubSystemClass> _subSystemClasses = model.getSubSystemClasses();
+ for(final SubSystemClass ssc : _subSystemClasses) {
+ StringConcatenation _generateSubSysClassDoc = this.generateSubSysClassDoc(root, model, ssc);
+ _builder.append(_generateSubSysClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation generateSubSysClassDoc(final Root root, final RoomModel model, final SubSystemClass ssc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
+ String _name = ssc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_structure.jpg");
+ String filename = _operator_plus_2;
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String _replaceAll_1 = filename.replaceAll("/", "//");
+ String latexFilename = _replaceAll_1;
+ String _docGenerationTargetPath_1 = this.roomExt.getDocGenerationTargetPath(model);
+ String _operator_plus_3 = StringExtensions.operator_plus(_docGenerationTargetPath_1, "images\\");
+ String _name_1 = ssc.getName();
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, _name_1);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "_instanceTree.jpg");
+ String filenamei = _operator_plus_5;
+ String _replaceAll_2 = filenamei.replaceAll("\\\\", "/");
+ filenamei = _replaceAll_2;
+ String _replaceAll_3 = filenamei.replaceAll("/", "//");
+ String latexFilenamei = _replaceAll_3;
+ 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();
+ StringConcatenation _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 _operator_plus_6 = StringExtensions.operator_plus(_name_3, " Structure");
+ StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_6);
+ _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 _operator_plus_7 = StringExtensions.operator_plus(_name_4, " Instance Tree");
+ StringConcatenation _includeGraphics_1 = this.includeGraphics(latexFilenamei, "0.5", _operator_plus_7);
+ _builder.append(_includeGraphics_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation generateAllDataClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<DataClass> _dataClasses = model.getDataClasses();
+ for(final DataClass dc : _dataClasses) {
+ StringConcatenation _generateDataClassDoc = this.generateDataClassDoc(root, dc);
+ _builder.append(_generateDataClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation 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();
+ StringConcatenation _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\level{3}{Attributes}");
+ _builder.newLine();
+ EList<Attribute> _attributes = dc.getAttributes();
+ StringConcatenation _generateAttributesDoc = this.generateAttributesDoc(_attributes);
+ _builder.append(_generateAttributesDoc, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\\level{3}{Operations}");
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ StringConcatenation _generateOperationsDoc = this.generateOperationsDoc(_operations);
+ _builder.append(_generateOperationsDoc, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation generateAllProtocolClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<ProtocolClass> _protocolClasses = model.getProtocolClasses();
+ for(final ProtocolClass pc : _protocolClasses) {
+ StringConcatenation _generateProtocolClassDoc = this.generateProtocolClassDoc(root, pc);
+ _builder.append(_generateProtocolClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation 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();
+ StringConcatenation _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_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();
+ StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_2, null);
+ if (_operator_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();
+ StringConcatenation _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;
+ }
+
+ public StringConcatenation generateAllActorClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<ActorClass> _actorClasses = model.getActorClasses();
+ for(final ActorClass ac : _actorClasses) {
+ StringConcatenation _generateActorClassDoc = this.generateActorClassDoc(root, model, ac);
+ _builder.append(_generateActorClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation generateActorClassDoc(final Root root, final RoomModel model, final ActorClass ac) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
+ String _name = ac.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_structure.jpg");
+ String filename = _operator_plus_2;
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String _replaceAll_1 = filename.replaceAll("/", "//");
+ String latexFilename = _replaceAll_1;
+ 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();
+ StringConcatenation _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 _operator_plus_3 = StringExtensions.operator_plus(_name_2, " Structure");
+ StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_3);
+ _builder.append(_includeGraphics, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\\level{3}{Attributes}");
+ _builder.newLine();
+ EList<Attribute> _attributes = ac.getAttributes();
+ StringConcatenation _generateAttributesDoc = this.generateAttributesDoc(_attributes);
+ _builder.append(_generateAttributesDoc, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\\level{3}{Operations}");
+ _builder.newLine();
+ EList<StandardOperation> _operations = ac.getOperations();
+ StringConcatenation _generateOperationsDoc = this.generateOperationsDoc(_operations);
+ _builder.append(_generateOperationsDoc, "");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\\level{3}{Statemachine}");
+ _builder.newLine();
+ StringConcatenation _generateFsmDoc = this.generateFsmDoc(model, ac);
+ _builder.append(_generateFsmDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation generateFsmDoc(final RoomModel model, final ActorClass ac) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
+ String _name = ac.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_behavior.jpg");
+ String filename = _operator_plus_2;
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String _replaceAll_1 = filename.replaceAll("/", "//");
+ String latexFilename = _replaceAll_1;
+ 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 _operator_plus_3 = StringExtensions.operator_plus(_name_1, " Top State");
+ StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_3);
+ _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_docu, null);
+ if (_operator_notEquals) {
+ _builder.append("\\textbf{State description} \\textit{");
+ String _statePathName = this.roomExt.getStatePathName(s);
+ String _replaceAll_2 = _statePathName.replaceAll("_", "\\\\_");
+ _builder.append(_replaceAll_2, "");
+ _builder.append("}:");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline");
+ _builder.newLine();
+ Documentation _docu_1 = s.getDocu();
+ StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_docu_2, null);
+ if (_operator_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();
+ StringConcatenation _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 _operator_not = BooleanExtensions.operator_not(_isLeaf);
+ if (_operator_not) {
+ StringConcatenation _generateStateDoc = this.generateStateDoc(model, ac, s_1);
+ _builder.append(_generateStateDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation generateStateDoc(final RoomModel model, final ActorClass ac, final State state) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "images\\");
+ String _name = ac.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
+ String _statePathName = this.roomExt.getStatePathName(state);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _statePathName);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_behavior.jpg");
+ String filename = _operator_plus_4;
+ String _replaceAll = filename.replaceAll("\\\\", "/");
+ filename = _replaceAll;
+ String _replaceAll_1 = filename.replaceAll("/", "//");
+ String latexFilename = _replaceAll_1;
+ String _operator_plus_5 = StringExtensions.operator_plus("Gen Filename: ", filename);
+ this.logger.logInfo(_operator_plus_5);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\level{4}{Subgraph ");
+ String _statePathName_1 = this.roomExt.getStatePathName(state);
+ String _replaceAll_2 = _statePathName_1.replaceAll("_", "\\\\_");
+ _builder.append(_replaceAll_2, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ {
+ String _fileExists = this.fileExists(filename);
+ boolean _equals = _fileExists.equals("true");
+ if (_equals) {
+ String _name_1 = ac.getName();
+ String _operator_plus_6 = StringExtensions.operator_plus(_name_1, "_");
+ String _statePathName_2 = this.roomExt.getStatePathName(state);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, _statePathName_2);
+ StringConcatenation _includeGraphics = this.includeGraphics(latexFilename, "0.4", _operator_plus_7);
+ _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_docu, null);
+ if (_operator_notEquals) {
+ _builder.append("\\textbf{State description} \\textit{");
+ String _statePathName_3 = this.roomExt.getStatePathName(s);
+ String _replaceAll_3 = _statePathName_3.replaceAll("_", "\\\\_");
+ _builder.append(_replaceAll_3, "");
+ _builder.append("}:");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\newline");
+ _builder.newLine();
+ Documentation _docu_1 = s.getDocu();
+ StringConcatenation _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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_docu_2, null);
+ if (_operator_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();
+ StringConcatenation _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 _operator_not = BooleanExtensions.operator_not(_isLeaf);
+ if (_operator_not) {
+ StringConcatenation _generateStateDoc = this.generateStateDoc(model, ac, s_1);
+ _builder.append(_generateStateDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation generateAttributesDoc(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = attributes.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_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();
+ StringConcatenation _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 StringConcatenation 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 _operator_notEquals = ObjectExtensions.operator_notEquals(_returntype, null);
+ if (_operator_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 hasAnyElements = false;
+ for(final VarDecl pa : _arguments) {
+ if (!hasAnyElements) {
+ hasAnyElements = 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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_docu, null);
+ if (_operator_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 _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_length), ((Integer)85));
+ if (_operator_greaterThan) {
+ _builder.append("\t");
+ _builder.append("\\multicolumn{2} {|p{13cm}|} {");
+ Documentation _docu_2 = op.getDocu();
+ StringConcatenation _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();
+ StringConcatenation _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 StringConcatenation generateDocText(final Documentation doc) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(doc, null);
+ if (_operator_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;
+ boolean _exists = file.exists();
+ final boolean exist = _exists;
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Boolean)exist), ((Boolean)true));
+ if (_operator_equals) {
+ {
+ String _operator_plus = StringExtensions.operator_plus("File found ! ", f);
+ this.logger.logInfo(_operator_plus);
+ return "true";
+ }
+ } else {
+ {
+ String _operator_plus_1 = StringExtensions.operator_plus("File not found ! ", f);
+ this.logger.logInfo(_operator_plus_1);
+ return "false";
+ }
+ }
+ }
+
+ public StringConcatenation includeGraphics(final String filename, final String scale, final String caption) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _replaceAll = caption.replaceAll("_", "\\\\_");
+ String latexCaption = _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();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".bla");
+ return _operator_plus;
+ }
+}
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 127d7dd..46946bc 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,170 +1,170 @@
-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.room.ActorClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.base.IRoomGenerator;
-import org.eclipse.etrice.generator.etricegen.ActorInstance;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.StructureInstance;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class 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 _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "/images");
- String path = _operator_plus;
- this.fileAccess.setOutputPath(path);
- String file2 = "dot2jpg.bat";
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "_instanceTree.dot");
- String file = _operator_plus_1;
- String _operator_plus_2 = StringExtensions.operator_plus("generating LaTeX documentation: \'", file);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "\' in \'");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, path);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "\'");
- this.logger.logInfo(_operator_plus_5);
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, sc, _subSystemClass);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- StringConcatenation _generate2jpg = this.generate2jpg(root);
- this.fileAccess.generateFile(file2, _generate2jpg);
- this.runDot2Jpg();
- }
- }
- }
-
- public StringConcatenation 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 StringConcatenation 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");
- StringConcatenation _instance = this.instance(ai);
- _builder.append(_instance, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation 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) {
- StringConcatenation _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 Exception e) {
- e.printStackTrace();
- }
- 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.room.ActorClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.StructureInstance;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class 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 _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, "/images");
+ String path = _operator_plus;
+ this.fileAccess.setOutputPath(path);
+ String file2 = "dot2jpg.bat";
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "_instanceTree.dot");
+ String file = _operator_plus_1;
+ String _operator_plus_2 = StringExtensions.operator_plus("generating LaTeX documentation: \'", file);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "\' in \'");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, path);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "\'");
+ this.logger.logInfo(_operator_plus_5);
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ StringConcatenation _generate = this.generate(root, sc, _subSystemClass);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ StringConcatenation _generate2jpg = this.generate2jpg(root);
+ this.fileAccess.generateFile(file2, _generate2jpg);
+ this.runDot2Jpg();
+ }
+ }
+ }
+
+ public StringConcatenation 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 StringConcatenation 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");
+ StringConcatenation _instance = this.instance(ai);
+ _builder.append(_instance, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation 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) {
+ StringConcatenation _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 Exception e) {
+ e.printStackTrace();
+ }
+ 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 881a712..5db8d7e 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.generator.doc.gen.DocGen;
-import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.generic.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@SuppressWarnings("all")
-@Singleton
-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.generator.doc.gen.DocGen;
+import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@SuppressWarnings("all")
+@Singleton
+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.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
new file mode 100644
index 0000000..46e00fb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -0,0 +1,565 @@
+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.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.ILogger;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+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.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.etrice.generator.java.gen.StateMachineGen;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private StateMachineGen stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this.roomExt.getPath(_actorClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _javaFileName = this.stdExt.getJavaFileName(_actorClass_2);
+ String file = _javaFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass implementation \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ StringConcatenation _generate = this.generate(root, xpac, _actorClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _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)_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ StandardOperation _head = IterableExtensions.<StandardOperation>head(_filter);
+ final StandardOperation ctor = _head;
+ 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)_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
+ final StandardOperation dtor = _head_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this.roomExt.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.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.roomExt.getPackage(pc);
+ _builder.append(_package_1, "");
+ _builder.append(".");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = ac.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_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");
+ DetailCode _userCode2 = ac.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts = this.roomExt.getEndPorts(ac);
+ for(final Port ep : _endPorts) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName = this.roomExt.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.roomExt.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.roomExt.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();
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ StringConcatenation _operationsImplementation = this.helpers.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 _operator_equals = ObjectExtensions.operator_equals(_base_2, null);
+ if (_operator_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();
+ StringConcatenation _attributeInitialization = this.helpers.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.roomExt.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.roomExt.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 _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_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 _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
+ if (_operator_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 _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_2), ((Integer)1));
+ if (_operator_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.roomExt.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.roomExt.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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(ctor, null);
+ if (_operator_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.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.roomExt.overridesStop(ac);
+ boolean _operator_not = BooleanExtensions.operator_not(_overridesStop);
+ if (_operator_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 _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dtor, null);
+ if (_operator_notEquals_2) {
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ DetailCode _detailCode_1 = dtor.getDetailCode();
+ EList<String> _commands_1 = _detailCode_1.getCommands();
+ for(final String l_1 : _commands_1) {
+ _builder.append("\t\t");
+ _builder.append(l_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\t");
+ StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
+ _builder.append(_genStateMachine, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _hasStateMachine = xpac.hasStateMachine();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_hasStateMachine);
+ if (_operator_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
new file mode 100644
index 0000000..29995c3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -0,0 +1,481 @@
+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.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.base.ILogger;
+import org.eclipse.etrice.generator.etricegen.Root;
+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.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
+ String _path = this.roomExt.getPath(dc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _javaFileName = this.stdExt.getJavaFileName(dc);
+ String file = _javaFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass implementation \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ StringConcatenation _generate = this.generate(root, dc);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final DataClass dc) {
+ StringConcatenation _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)_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ StandardOperation _head = IterableExtensions.<StandardOperation>head(_filter);
+ final StandardOperation ctor = _head;
+ EList<StandardOperation> _operations_1 = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return ((Boolean)_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
+ final StandardOperation dtor = _head_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(dc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<RoomModel> _referencedModels = root.getReferencedModels(dc);
+ EList<RoomModel> models = _referencedModels;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = dc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _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 _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_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");
+ DetailCode _userCode2 = dc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = dc.getAttributes();
+ StringConcatenation _attributes_1 = this.helpers.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();
+ StringConcatenation _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<StandardOperation> _operations_2 = dc.getOperations();
+ String _name_4 = dc.getName();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _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();
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_3, true);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(ctor, null);
+ if (_operator_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 _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base_2, null);
+ if (_operator_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 _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
+ Boolean _xwhileexpression = _operator_notEquals;
+ while (_xwhileexpression) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ StringConcatenation _paramList = this.paramList(_attributes);
+ String _string = _paramList.toString();
+ String _operator_plus = StringExtensions.operator_plus(_string, result);
+ result = _operator_plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
+ if (_operator_notEquals_1) {
+ String _operator_plus_1 = StringExtensions.operator_plus(", ", result);
+ result = _operator_plus_1;
+ }
+ }
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dc, null);
+ _xwhileexpression = _operator_notEquals_2;
+ }
+ return result;
+ }
+
+ public StringConcatenation paramList(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean hasAnyElements = false;
+ for(final Attribute a : attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = 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 _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
+ Boolean _xwhileexpression = _operator_notEquals;
+ while (_xwhileexpression) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ StringConcatenation _argList = this.helpers.argList(_attributes);
+ String _string = _argList.toString();
+ String _operator_plus = StringExtensions.operator_plus(_string, result);
+ result = _operator_plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
+ if (_operator_notEquals_1) {
+ String _operator_plus_1 = StringExtensions.operator_plus(", ", result);
+ result = _operator_plus_1;
+ }
+ }
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dc, null);
+ _xwhileexpression = _operator_notEquals_2;
+ }
+ return result;
+ }
+
+ public String deepCopy(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
+ Boolean _xwhileexpression = _operator_notEquals;
+ while (_xwhileexpression) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ StringConcatenation _deepCopy = this.deepCopy(_attributes);
+ String _string = _deepCopy.toString();
+ String _operator_plus = StringExtensions.operator_plus(_string, result);
+ result = _operator_plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ }
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
+ _xwhileexpression = _operator_notEquals_1;
+ }
+ return result;
+ }
+
+ public StringConcatenation 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 _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
+ if (_operator_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 _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_1), ((Integer)0));
+ if (_operator_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
new file mode 100644
index 0000000..b23dc20
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -0,0 +1,131 @@
+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.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class JavaExtensions implements ILanguageExtension {
+ @Inject
+ private AbstractTransitionChainGenerator chainGenerator;
+
+ public String getTypedDataDefinition(final Message m) {
+ String _generateTypedData = this.chainGenerator.generateTypedData(m);
+ return _generateTypedData;
+ }
+
+ public String getJavaFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".java");
+ return _operator_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 _operator_plus = StringExtensions.operator_plus(namespace, ".");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
+ return _operator_plus_1;
+ }
+
+ 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)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 _operator_plus = StringExtensions.operator_plus(type, " ");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "[]");
+ return _operator_plus_2;
+ }
+
+ public String constructorName(final String cls) {
+ return cls;
+ }
+
+ public String destructorName(final String cls) {
+ String _operator_plus = StringExtensions.operator_plus(cls, "_dtor");
+ return _operator_plus;
+ }
+
+ public String constructorReturnType() {
+ return "";
+ }
+
+ public String destructorReturnType() {
+ return "void";
+ }
+}
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 090f20e..04fc3d5 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,61 +1,61 @@
-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.generator.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;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
- if (_operator_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
+package org.eclipse.etrice.generator.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.generator.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;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
+ if (_operator_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.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 7fb08aa..974c94e 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,834 +1,834 @@
-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.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.base.ILogger;
-import org.eclipse.etrice.generator.etricegen.Root;
-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.JavaExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @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.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _javaFileName = this.stdExt.getJavaFileName(pc);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass implementation \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- StringConcatenation _generate = this.generate(root, pc);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.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();
- DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<RoomModel> _referencedModels = root.getReferencedModels(pc);
- EList<RoomModel> models = _referencedModels;
- _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");
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("private static String messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this.roomExt.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.roomExt.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");
- StringConcatenation _portClass = this.portClass(pc, ((Boolean)false));
- _builder.append(_portClass, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- StringConcatenation _portClass_1 = this.portClass(pc, ((Boolean)true));
- _builder.append(_portClass_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation portClass(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pclass = _portClass;
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- 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 _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- StringConcatenation _userCode_1 = this.helpers.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("super(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();
- _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.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- _builder.append("\t\t\t\t");
- _builder.append("switch (msg.getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- Message _msg = hdlr.getMsg();
- String _codeName = this.roomExt.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.roomExt.handlesReceive(pc, conj);
- 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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _operationsImplementation = this.helpers.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.roomExt.getOutgoing(pc, conj);
- for(final Message m : _outgoing) {
- _builder.append("\t");
- StringConcatenation _sendMessage = this.sendMessage(m, conj);
- _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) {
- _builder.append("\t");
- _builder.append("// incoming messages");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t");
- StringConcatenation _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).");
- StringConcatenation _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.roomExt.getAllOutgoingMessages(pc);
- for(final Message m_2 : _allOutgoingMessages) {
- _builder.append("\t");
- StringConcatenation _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).");
- StringConcatenation _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 StringConcatenation 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 _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _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 StringConcatenation messageSignatureExplicit(final Message m) {
- StringConcatenation _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("(");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- DataClass _base_1 = dc.getBase();
- String _typeName = this._typeHelpers.typeName(_base_1);
- _builder.append(_typeName, "");
- _builder.append(" _super, ");
- }
- }
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, "");
- {
- int _size = a.getSize();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- if (_operator_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public StringConcatenation sendMessage(final Message m, final boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "IN";
- } else {
- _xifexpression = "OUT";
- }
- String dir = _xifexpression;
- MessageHandler _sendHandler = this.roomExt.getSendHandler(m, conj);
- MessageHandler hdlr = _sendHandler;
- StringConcatenation _builder = new StringConcatenation();
- StringConcatenation _messageSignature = this.messageSignature(m);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_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 _operator_equals = ObjectExtensions.operator_equals(_data, null);
- if (_operator_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 _operator_and = false;
- VarDecl _data_2 = m.getData();
- RefableType _refType = _data_2.getRefType();
- boolean _isRef = _refType.isRef();
- boolean _operator_not = BooleanExtensions.operator_not(_isRef);
- if (!_operator_not) {
- _operator_and = false;
- } else {
- VarDecl _data_3 = m.getData();
- RefableType _refType_1 = _data_3.getRefType();
- DataType _type = _refType_1.getType();
- boolean _operator_not_1 = BooleanExtensions.operator_not((_type instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(_operator_not, _operator_not_1);
- }
- if (_operator_and) {
- _builder.append(".deepCopy()");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("}");
- _builder.newLine();
- {
- boolean _operator_and_1 = false;
- VarDecl _data_4 = m.getData();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_4, null);
- if (!_operator_notEquals_1) {
- _operator_and_1 = false;
- } else {
- VarDecl _data_5 = m.getData();
- RefableType _refType_2 = _data_5.getRefType();
- DataType _type_1 = _refType_2.getType();
- _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_1, (_type_1 instanceof DataClass));
- }
- if (_operator_and_1) {
- StringConcatenation _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();
- DataClass _base = ((DataClass) _type_3).getBase();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals_2) {
- _builder.append("_super, ");
- }
- }
- {
- VarDecl _data_8 = m.getData();
- RefableType _refType_5 = _data_8.getRefType();
- DataType _type_4 = _refType_5.getType();
- EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", " ");
- }
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _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.emf.common.util.EList;
+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.base.ILogger;
+import org.eclipse.etrice.generator.etricegen.Root;
+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.JavaExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @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.roomExt.getGenerationTargetPath(pc);
+ String _path = this.roomExt.getPath(pc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _javaFileName = this.stdExt.getJavaFileName(pc);
+ String file = _javaFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass implementation \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ StringConcatenation _generate = this.generate(root, pc);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this.roomExt.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();
+ DetailCode _userCode1 = pc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<RoomModel> _referencedModels = root.getReferencedModels(pc);
+ EList<RoomModel> models = _referencedModels;
+ _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");
+ DetailCode _userCode2 = pc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private static String messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.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.roomExt.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");
+ StringConcatenation _portClass = this.portClass(pc, ((Boolean)false));
+ _builder.append(_portClass, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ StringConcatenation _portClass_1 = this.portClass(pc, ((Boolean)true));
+ _builder.append(_portClass_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation portClass(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ PortClass pclass = _portClass;
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ 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 _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ DetailCode _userCode = pclass.getUserCode();
+ StringConcatenation _userCode_1 = this.helpers.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("super(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();
+ _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.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ _builder.append("\t\t\t\t");
+ _builder.append("switch (msg.getEvtId()) {");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler hdlr : _receiveHandlers) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ Message _msg = hdlr.getMsg();
+ String _codeName = this.roomExt.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.roomExt.handlesReceive(pc, conj);
+ 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 _operator_notEquals_1 = ObjectExtensions.operator_notEquals(pclass, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t");
+ EList<Attribute> _attributes = pclass.getAttributes();
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<PortOperation> _operations = pclass.getOperations();
+ StringConcatenation _operationsImplementation = this.helpers.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.roomExt.getOutgoing(pc, conj);
+ for(final Message m : _outgoing) {
+ _builder.append("\t");
+ StringConcatenation _sendMessage = this.sendMessage(m, conj);
+ _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) {
+ _builder.append("\t");
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\t");
+ StringConcatenation _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).");
+ StringConcatenation _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.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ _builder.append("\t");
+ StringConcatenation _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).");
+ StringConcatenation _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 StringConcatenation 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 _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _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 StringConcatenation messageSignatureExplicit(final Message m) {
+ StringConcatenation _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("(");
+ {
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ DataClass _base_1 = dc.getBase();
+ String _typeName = this._typeHelpers.typeName(_base_1);
+ _builder.append(_typeName, "");
+ _builder.append(" _super, ");
+ }
+ }
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ boolean hasAnyElements = false;
+ for(final Attribute a : _attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size = a.getSize();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
+ if (_operator_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public StringConcatenation sendMessage(final Message m, final boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ if (conj) {
+ _xifexpression = "IN";
+ } else {
+ _xifexpression = "OUT";
+ }
+ String dir = _xifexpression;
+ MessageHandler _sendHandler = this.roomExt.getSendHandler(m, conj);
+ MessageHandler hdlr = _sendHandler;
+ StringConcatenation _builder = new StringConcatenation();
+ StringConcatenation _messageSignature = this.messageSignature(m);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_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 _operator_equals = ObjectExtensions.operator_equals(_data, null);
+ if (_operator_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 _operator_and = false;
+ VarDecl _data_2 = m.getData();
+ RefableType _refType = _data_2.getRefType();
+ boolean _isRef = _refType.isRef();
+ boolean _operator_not = BooleanExtensions.operator_not(_isRef);
+ if (!_operator_not) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_3 = m.getData();
+ RefableType _refType_1 = _data_3.getRefType();
+ DataType _type = _refType_1.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type instanceof PrimitiveType));
+ _operator_and = BooleanExtensions.operator_and(_operator_not, _operator_not_1);
+ }
+ if (_operator_and) {
+ _builder.append(".deepCopy()");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _operator_and_1 = false;
+ VarDecl _data_4 = m.getData();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_4, null);
+ if (!_operator_notEquals_1) {
+ _operator_and_1 = false;
+ } else {
+ VarDecl _data_5 = m.getData();
+ RefableType _refType_2 = _data_5.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_1, (_type_1 instanceof DataClass));
+ }
+ if (_operator_and_1) {
+ StringConcatenation _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();
+ DataClass _base = ((DataClass) _type_3).getBase();
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals_2) {
+ _builder.append("_super, ");
+ }
+ }
+ {
+ VarDecl _data_8 = m.getData();
+ RefableType _refType_5 = _data_8.getRefType();
+ DataType _type_4 = _refType_5.getType();
+ EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
+ boolean hasAnyElements = false;
+ for(final Attribute a : _attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", " ");
+ }
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ }
+ }
+ _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 37bfe72..a8daf13 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,76 +1,76 @@
-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.ActorClass;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
- 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 hasAnyElements = false;
- for(final State state : _allBaseStatesLeavesLast) {
- if (!hasAnyElements) {
- hasAnyElements = 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();
- 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.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
+ 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 hasAnyElements = false;
+ for(final State state : _allBaseStatesLeavesLast) {
+ if (!hasAnyElements) {
+ hasAnyElements = 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();
+ return _builder;
+ }
+}
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 237e297..f627afe 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,637 +1,637 @@
-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.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.LogicalThread;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.etricegen.ActorInstance;
-import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-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.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance ssi : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String _javaFileName = this.stdExt.getJavaFileName(_subSystemClass_2);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _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.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> _referencedModels = root.getReferencedModels(cc);
- EList<RoomModel> models = _referencedModels;
- _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();
- DetailCode _userCode1 = cc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _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");
- DetailCode _userCode2 = cc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _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 _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
- _builder.append(_operator_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.roomExt.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 _indexOf_2 = _peers_1.indexOf(peer);
- int i = _indexOf_2;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_3 = pi.getPath();
- String _pathName_1 = this.roomExt.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 _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_objId_1), ((Integer)i));
- _builder.append(_operator_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.roomExt.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_3 = _allContainedInstances_5.indexOf(ai_2);
- _builder.append(_indexOf_3, " ");
- _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_4 = _allContainedInstances_6.indexOf(_eContainer_1);
- _builder.append(_indexOf_4, " ");
- _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.roomExt.getPathName(_path_5);
- _builder.append(_pathName_3, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
- boolean hasAnyElements = false;
- for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
- if (!hasAnyElements) {
- hasAnyElements = 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 hasAnyElements_1 = false;
- for(final InterfaceItemInstance peer_1 : _peers_3) {
- if (!hasAnyElements_1) {
- hasAnyElements_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.roomExt.getPathName(_path_6);
- _builder.append(_pathName_4, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- int _indexOf_5 = _peers_4.indexOf(peer_1);
- _builder.append(_indexOf_5, " ");
- _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.roomExt.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_6 = _allContainedInstances_7.indexOf(ai_2);
- _builder.append(_indexOf_6, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_2);
- if (_operator_not_1) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
- boolean hasAnyElements_2 = false;
- for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
- if (!hasAnyElements_2) {
- hasAnyElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _operator_and = false;
- boolean _isReplicated_2 = pi_2.isReplicated();
- if (!_isReplicated_2) {
- _operator_and = false;
- } else {
- EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
- boolean _isEmpty_3 = _peers_5.isEmpty();
- _operator_and = BooleanExtensions.operator_and(_isReplicated_2, _isEmpty_3);
- }
- if (_operator_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 hasAnyElements_3 = false;
- for(final InterfaceItemInstance pp : _peers_7) {
- if (!hasAnyElements_3) {
- hasAnyElements_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.roomExt.getPathName(_path_8);
- _builder.append(_pathName_6, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _indexOf_7 = _peers_8.indexOf(pi_2);
- _builder.append(_indexOf_7, " ");
- _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.roomExt.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.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_8 = comp.getAllContainedInstances();
- boolean hasAnyElements_4 = false;
- for(final ActorInstance ai_3 : _allContainedInstances_8) {
- if (!hasAnyElements_4) {
- hasAnyElements_4 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_9.indexOf(ai_3);
- _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_10 = comp.getAllContainedInstances();
- boolean hasAnyElements_5 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_10) {
- if (!hasAnyElements_5) {
- hasAnyElements_5 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_");
- String _path_10 = ai_4.getPath();
- String _pathName_8 = this.roomExt.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 org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.LogicalThread;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.base.Indexed;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
+import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+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.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance ssi : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _javaFileName = this.stdExt.getJavaFileName(_subSystemClass_2);
+ String file = _javaFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ StringConcatenation _generate = this.generate(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _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.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> _referencedModels = root.getReferencedModels(cc);
+ EList<RoomModel> models = _referencedModels;
+ _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();
+ DetailCode _userCode1 = cc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _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");
+ DetailCode _userCode2 = cc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _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 _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
+ _builder.append(_operator_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.roomExt.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 _indexOf_2 = _peers_1.indexOf(peer);
+ int i = _indexOf_2;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_3 = pi.getPath();
+ String _pathName_1 = this.roomExt.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 _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_objId_1), ((Integer)i));
+ _builder.append(_operator_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.roomExt.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_3 = _allContainedInstances_5.indexOf(ai_2);
+ _builder.append(_indexOf_3, " ");
+ _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_4 = _allContainedInstances_6.indexOf(_eContainer_1);
+ _builder.append(_indexOf_4, " ");
+ _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.roomExt.getPathName(_path_5);
+ _builder.append(_pathName_3, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
+ boolean hasAnyElements = false;
+ for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
+ if (!hasAnyElements) {
+ hasAnyElements = 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 hasAnyElements_1 = false;
+ for(final InterfaceItemInstance peer_1 : _peers_3) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_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.roomExt.getPathName(_path_6);
+ _builder.append(_pathName_4, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
+ int _indexOf_5 = _peers_4.indexOf(peer_1);
+ _builder.append(_indexOf_5, " ");
+ _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.roomExt.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_6 = _allContainedInstances_7.indexOf(ai_2);
+ _builder.append(_indexOf_6, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_2);
+ if (_operator_not_1) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
+ boolean hasAnyElements_2 = false;
+ for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
+ if (!hasAnyElements_2) {
+ hasAnyElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _operator_and = false;
+ boolean _isReplicated_2 = pi_2.isReplicated();
+ if (!_isReplicated_2) {
+ _operator_and = false;
+ } else {
+ EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
+ boolean _isEmpty_3 = _peers_5.isEmpty();
+ _operator_and = BooleanExtensions.operator_and(_isReplicated_2, _isEmpty_3);
+ }
+ if (_operator_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 hasAnyElements_3 = false;
+ for(final InterfaceItemInstance pp : _peers_7) {
+ if (!hasAnyElements_3) {
+ hasAnyElements_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.roomExt.getPathName(_path_8);
+ _builder.append(_pathName_6, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
+ int _indexOf_7 = _peers_8.indexOf(pi_2);
+ _builder.append(_indexOf_7, " ");
+ _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.roomExt.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.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_8 = comp.getAllContainedInstances();
+ boolean hasAnyElements_4 = false;
+ for(final ActorInstance ai_3 : _allContainedInstances_8) {
+ if (!hasAnyElements_4) {
+ hasAnyElements_4 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
+ int _indexOf_8 = _allContainedInstances_9.indexOf(ai_3);
+ _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_10 = comp.getAllContainedInstances();
+ boolean hasAnyElements_5 = false;
+ for(final ActorInstance ai_4 : _allContainedInstances_10) {
+ if (!hasAnyElements_5) {
+ hasAnyElements_5 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_");
+ String _path_10 = ai_4.getPath();
+ String _pathName_8 = this.roomExt.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 8d26247..e0fa223 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,152 +1,152 @@
-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.room.SubSystemClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- this.fileAccess.setOutputPath(_operator_plus);
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "Runner.java");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_operator_plus_1, _generate);
- }
- }
- }
-
- public StringConcatenation 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 _operator_plus = StringExtensions.operator_plus(_name_2, "Runner");
- _builder.append(_operator_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.room.SubSystemClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ this.fileAccess.setOutputPath(_operator_plus);
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "Runner.java");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ StringConcatenation _generate = this.generate(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_operator_plus_1, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation 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 _operator_plus = StringExtensions.operator_plus(_name_2, "Runner");
+ _builder.append(_operator_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/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
new file mode 100644
index 0000000..73b8b18
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
@@ -0,0 +1,93 @@
+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.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.etricegen.ExpandedActorClass;
+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;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@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 _operator_plus = StringExtensions.operator_plus("IFITEM_", _name);
+ int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep);
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)1), ((Integer)_interfaceItemLocalId));
+ String _string = ((Integer)_operator_plus_1).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_operator_plus, _string);
+ list.add(_pair);
+ }
+ for (final SAPRef sap : strSAPs) {
+ String _name_1 = sap.getName();
+ String _operator_plus_2 = StringExtensions.operator_plus("IFITEM_", _name_1);
+ int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap);
+ int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)1), ((Integer)_interfaceItemLocalId_1));
+ String _string_1 = ((Integer)_operator_plus_3).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_operator_plus_2, _string_1);
+ list.add(_pair_1);
+ }
+ for (final ServiceImplementation svc : svcImpls) {
+ SPPRef _spp = svc.getSpp();
+ String _name_2 = _spp.getName();
+ String _operator_plus_4 = StringExtensions.operator_plus("IFITEM_", _name_2);
+ SPPRef _spp_1 = svc.getSpp();
+ int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_1);
+ int _operator_plus_5 = IntegerExtensions.operator_plus(((Integer)1), ((Integer)_interfaceItemLocalId_2));
+ String _string_2 = ((Integer)_operator_plus_5).toString();
+ Pair<String,String> _pair_2 = Tuples.<String, String>pair(_operator_plus_4, _string_2);
+ list.add(_pair_2);
+ }
+ String _genEnumeration = this.langExt.genEnumeration("interface_items", list);
+ return _genEnumeration;
+ }
+}
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
new file mode 100644
index 0000000..fe94348
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
@@ -0,0 +1,131 @@
+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.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;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@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)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 _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+ offset = _operator_plus;
+ String _name_1 = pc.getName();
+ String _name_2 = msg.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus("OUT_", _name_2);
+ String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _operator_plus_1);
+ String _string_1 = ((Integer)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 _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+ offset = _operator_plus_2;
+ String _name_3 = pc.getName();
+ String _name_4 = msg_1.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus("IN_", _name_4);
+ String _memberInDeclaration_2 = this.langExt.memberInDeclaration(_name_3, _operator_plus_3);
+ String _string_2 = ((Integer)offset).toString();
+ Pair<String,String> _pair_2 = Tuples.<String, String>pair(_memberInDeclaration_2, _string_2);
+ list.add(_pair_2);
+ }
+ }
+ int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+ offset = _operator_plus_4;
+ String _name_5 = pc.getName();
+ String _memberInDeclaration_3 = this.langExt.memberInDeclaration(_name_5, "MSG_MAX");
+ String _string_3 = ((Integer)offset).toString();
+ Pair<String,String> _pair_3 = Tuples.<String, String>pair(_memberInDeclaration_3, _string_3);
+ list.add(_pair_3);
+ String _name_6 = pc.getName();
+ String _memberInDeclaration_4 = this.langExt.memberInDeclaration(_name_6, "msg_ids");
+ String _genEnumeration = this.langExt.genEnumeration(_memberInDeclaration_4, list);
+ return _genEnumeration;
+ }
+
+ public String getMessageID(final MessageFromIf mif) {
+ Message _message = mif.getMessage();
+ InterfaceItem _from = mif.getFrom();
+ String _messageID = this.getMessageID(_message, _from);
+ return _messageID;
+ }
+
+ 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;
+ ProtocolClass _protocol = p.getProtocol();
+ String _name = _protocol.getName();
+ String _name_1 = msg.getName();
+ String _operator_plus = StringExtensions.operator_plus(direction, _name_1);
+ String _memberInUse = this.langExt.memberInUse(_name, _operator_plus);
+ return _memberInUse;
+ }
+ } 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 _operator_plus_1 = StringExtensions.operator_plus("OUT_", _name_3);
+ String _memberInUse_1 = this.langExt.memberInUse(_name_2, _operator_plus_1);
+ return _memberInUse_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 _operator_plus_2 = StringExtensions.operator_plus("IN_", _name_5);
+ String _memberInUse_2 = this.langExt.memberInUse(_name_4, _operator_plus_2);
+ return _memberInUse_2;
+ }
+ }
+ }
+ }
+ return "unknown interface item";
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
new file mode 100644
index 0000000..64018e6
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
@@ -0,0 +1,1336 @@
+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.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Guard;
+import org.eclipse.etrice.core.room.GuardedTransition;
+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.NonInitialTransition;
+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.Trigger;
+import org.eclipse.etrice.core.room.TriggeredTransition;
+import org.eclipse.etrice.generator.base.CodegenHelpers;
+import org.eclipse.etrice.generator.base.DetailCodeTranslator;
+import org.eclipse.etrice.generator.base.ITranslationProvider;
+import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.TransitionChain;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+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;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+public class GenericStateMachineGenerator {
+ @Inject
+ protected ILanguageExtension langExt;
+
+ @Inject
+ protected RoomExtensions roomExt;
+
+ @Inject
+ protected GenericProtocolClassGenerator pcGen;
+
+ @Inject
+ protected AbstractTransitionChainGenerator languageGen;
+
+ @Inject
+ protected ITranslationProvider translator;
+
+ private String genStateIdConstants(final ExpandedActorClass xpac, final ActorClass ac) {
+ int _xifexpression = (int) 0;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
+ _xifexpression = _numberOfInheritedBaseStates;
+ } else {
+ _xifexpression = 0;
+ }
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)2), ((Integer)_xifexpression));
+ int offset = _operator_plus;
+ List<State> _xifexpression_1 = null;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ StateGraph _stateMachine = ac.getStateMachine();
+ List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
+ _xifexpression_1 = _baseStateList;
+ } else {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_1);
+ _xifexpression_1 = _baseStateList_1;
+ }
+ List<State> baseStates = _xifexpression_1;
+ ArrayList<State> _leafStatesLast = this.roomExt.getLeafStatesLast(baseStates);
+ baseStates = _leafStatesLast;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ boolean _operator_not = BooleanExtensions.operator_not(_usesInheritance_2);
+ if (_operator_not) {
+ {
+ Pair<String,String> _pair = Tuples.<String, String>pair("NO_STATE", "0");
+ list.add(_pair);
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair("STATE_TOP", "1");
+ list.add(_pair_1);
+ }
+ }
+ for (final State state : baseStates) {
+ {
+ String _stateId = this.roomExt.getStateId(state);
+ String _string = ((Integer)offset).toString();
+ Pair<String,String> _pair_2 = Tuples.<String, String>pair(_stateId, _string);
+ list.add(_pair_2);
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+ offset = _operator_plus_1;
+ }
+ }
+ String _genEnumeration = this.langExt.genEnumeration("state_ids", list);
+ return _genEnumeration;
+ }
+
+ private String genTransitionChainConstants(final ExpandedActorClass xpac, final ActorClass ac) {
+ EList<TransitionChain> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
+ _xifexpression = _ownTransitionChains;
+ } else {
+ EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
+ _xifexpression = _transitionChains;
+ }
+ EList<TransitionChain> chains = _xifexpression;
+ int _xifexpression_1 = (int) 0;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
+ int _size = _transitionChains_1.size();
+ int _size_1 = chains.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
+ _xifexpression_1 = _operator_minus;
+ } else {
+ _xifexpression_1 = 0;
+ }
+ int offset = _xifexpression_1;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ for (final TransitionChain chain : chains) {
+ {
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+ offset = _operator_plus;
+ String _chainId = this.roomExt.getChainId(chain);
+ String _string = ((Integer)offset).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_chainId, _string);
+ list.add(_pair);
+ }
+ }
+ String _genEnumeration = this.langExt.genEnumeration("chain_ids", list);
+ return _genEnumeration;
+ }
+
+ private String genTriggerConstants(final ExpandedActorClass xpac, final ActorClass ac) {
+ EList<MessageFromIf> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
+ _xifexpression = _ownTriggers;
+ } else {
+ EList<MessageFromIf> _triggers = xpac.getTriggers();
+ _xifexpression = _triggers;
+ }
+ EList<MessageFromIf> triggers = _xifexpression;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ Pair<String,String> _pair = Tuples.<String, String>pair("POLLING", "0");
+ list.add(_pair);
+ for (final MessageFromIf mif : triggers) {
+ String _triggerCodeName = xpac.getTriggerCodeName(mif);
+ InterfaceItem _from = mif.getFrom();
+ String _name = _from.getName();
+ String _operator_plus = StringExtensions.operator_plus("IFITEM_", _name);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, " + EVT_SHIFT*");
+ String _messageID = this.pcGen.getMessageID(mif);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _messageID);
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_triggerCodeName, _operator_plus_2);
+ list.add(_pair_1);
+ }
+ String _genEnumeration = this.langExt.genEnumeration("triggers", list);
+ return _genEnumeration;
+ }
+
+ public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _xblockexpression = null;
+ {
+ this.translator.setActorClass(ac);
+ DetailCodeTranslator _detailCodeTranslator = new DetailCodeTranslator(ac, this.translator);
+ DetailCodeTranslator dct = _detailCodeTranslator;
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ boolean async = _operator_equals;
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ boolean eventDriven = _operator_equals_1;
+ ActorCommunicationType _commType_2 = ac.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ boolean dataDriven = _operator_equals_2;
+ boolean _operator_or = false;
+ if (async) {
+ _operator_or = true;
+ } else {
+ _operator_or = BooleanExtensions.operator_or(async, eventDriven);
+ }
+ boolean handleEvents = _operator_or;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* state IDs */");
+ _builder.newLine();
+ String _genStateIdConstants = this.genStateIdConstants(xpac, ac);
+ _builder.append(_genStateIdConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* transition chains */");
+ _builder.newLine();
+ String _genTransitionChainConstants = this.genTransitionChainConstants(xpac, ac);
+ _builder.append(_genTransitionChainConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* triggers */");
+ _builder.newLine();
+ String _genTriggerConstants = this.genTriggerConstants(xpac, ac);
+ _builder.append(_genTriggerConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ StringConcatenation _genExtra = this.genExtra(xpac, ac);
+ _builder.append(_genExtra, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* Entry and Exit Codes */");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ List<State> _stateList = this.roomExt.getStateList(_stateMachine);
+ for(final State state : _stateList) {
+ {
+ boolean _operator_or_1 = false;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ boolean _operator_not = BooleanExtensions.operator_not(_usesInheritance);
+ if (_operator_not) {
+ _operator_or_1 = true;
+ } else {
+ boolean _isOwnObject = xpac.isOwnObject(state);
+ _operator_or_1 = BooleanExtensions.operator_or(_operator_not, _isOwnObject);
+ }
+ if (_operator_or_1) {
+ {
+ boolean _hasEntryCode = this.roomExt.hasEntryCode(state);
+ if (_hasEntryCode) {
+ String _accessLevelProtected = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ _builder.append("void ");
+ String _entryCodeOperationName = CodegenHelpers.getEntryCodeOperationName(state);
+ _builder.append(_entryCodeOperationName, "");
+ _builder.append("(");
+ String _name = ac.getName();
+ String _selfPointer = this.langExt.selfPointer(_name, false);
+ _builder.append(_selfPointer, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _entryCode = this.roomExt.getEntryCode(xpac, state, dct);
+ _builder.append(_entryCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _hasExitCode = this.roomExt.hasExitCode(state);
+ if (_hasExitCode) {
+ String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_1, "");
+ _builder.append("void ");
+ String _exitCodeOperationName = CodegenHelpers.getExitCodeOperationName(state);
+ _builder.append(_exitCodeOperationName, "");
+ _builder.append("(");
+ String _name_1 = ac.getName();
+ String _selfPointer_1 = this.langExt.selfPointer(_name_1, false);
+ _builder.append(_selfPointer_1, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _exitCode = this.roomExt.getExitCode(xpac, state, dct);
+ _builder.append(_exitCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _hasDoCode = this.roomExt.hasDoCode(state);
+ if (_hasDoCode) {
+ _builder.append("static void ");
+ String _doCodeOperationName = CodegenHelpers.getDoCodeOperationName(state);
+ _builder.append(_doCodeOperationName, "");
+ _builder.append("(");
+ String _name_2 = ac.getName();
+ String _selfPointer_2 = this.langExt.selfPointer(_name_2, false);
+ _builder.append(_selfPointer_2, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _doCode = this.roomExt.getDoCode(xpac, state, dct);
+ _builder.append(_doCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* Action Codes */");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_1);
+ for(final Transition tr : _transitionList) {
+ {
+ boolean _operator_and = false;
+ boolean _isOwnObject_1 = xpac.isOwnObject(tr);
+ if (!_isOwnObject_1) {
+ _operator_and = false;
+ } else {
+ boolean _hasActionCode = this.roomExt.hasActionCode(tr);
+ _operator_and = BooleanExtensions.operator_and(_isOwnObject_1, _hasActionCode);
+ }
+ if (_operator_and) {
+ TransitionChain _chain = xpac.getChain(tr);
+ Transition _transition = _chain.getTransition();
+ Transition start = _transition;
+ _builder.newLineIfNotEmpty();
+ boolean _operator_and_1 = false;
+ if (!(start instanceof NonInitialTransition)) {
+ _operator_and_1 = false;
+ } else {
+ boolean _operator_not_1 = BooleanExtensions.operator_not((start instanceof GuardedTransition));
+ _operator_and_1 = BooleanExtensions.operator_and((start instanceof NonInitialTransition), _operator_not_1);
+ }
+ boolean hasArgs = _operator_and_1;
+ _builder.newLineIfNotEmpty();
+ String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_2, "");
+ _builder.append("void ");
+ String _actionCodeOperationName = CodegenHelpers.getActionCodeOperationName(tr);
+ _builder.append(_actionCodeOperationName, "");
+ _builder.append("(");
+ String _name_3 = ac.getName();
+ String _selfPointer_3 = this.langExt.selfPointer(_name_3, hasArgs);
+ _builder.append(_selfPointer_3, "");
+ {
+ if (hasArgs) {
+ _builder.append("InterfaceItemBase ifitem");
+ String _generateArgumentList = this.languageGen.generateArgumentList(xpac, tr);
+ _builder.append(_generateArgumentList, "");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _actionCode = this.roomExt.getActionCode(xpac, tr, dct);
+ _builder.append(_actionCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls exit codes while exiting from the current state to one of its");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* parent states while remembering the history");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param current - the current state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param to - the final parent state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void exitTo(");
+ String _name_4 = ac.getName();
+ String _selfPointer_4 = this.langExt.selfPointer(_name_4, true);
+ _builder.append(_selfPointer_4, "");
+ _builder.append("int current, int to, boolean handler) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("while (current!=to) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (current) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine_2);
+ for(final State state_1 : _baseStateList) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId = this.roomExt.getStateId(state_1);
+ _builder.append(_stateId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_1);
+ if (_hasExitCode_1) {
+ _builder.append("if (!handler) ");
+ String _exitCodeOperationName_1 = CodegenHelpers.getExitCodeOperationName(state_1);
+ _builder.append(_exitCodeOperationName_1, " ");
+ _builder.append("(");
+ String _selfPointer_5 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_5, " ");
+ _builder.append(");");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ String _memberAccess = this.langExt.memberAccess();
+ _builder.append(_memberAccess, " ");
+ _builder.append("history[");
+ String _parentStateId = CodegenHelpers.getParentStateId(state_1);
+ _builder.append(_parentStateId, " ");
+ _builder.append("] = ");
+ String _stateId_1 = this.roomExt.getStateId(state_1);
+ _builder.append(_stateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("current = ");
+ String _parentStateId_1 = CodegenHelpers.getParentStateId(state_1);
+ _builder.append(_parentStateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param chain - the chain ID");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param generic_data - the generic data pointer");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return the ID of the final state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_1, "");
+ _builder.append("int executeTransitionChain(");
+ String _name_5 = ac.getName();
+ String _selfPointer_6 = this.langExt.selfPointer(_name_5, true);
+ _builder.append(_selfPointer_6, "");
+ _builder.append("int chain");
+ {
+ if (handleEvents) {
+ _builder.append(", InterfaceItemBase ifitem, ");
+ String _voidPointer = this.langExt.voidPointer();
+ _builder.append(_voidPointer, "");
+ _builder.append(" generic_data");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("switch (chain) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
+ EList<TransitionChain> allchains = _transitionChains;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final TransitionChain tc : allchains) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ String _chainId = this.roomExt.getChainId(tc);
+ _builder.append(_chainId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String _generateExecuteChain = this.languageGen.generateExecuteChain(xpac, tc, dct);
+ _builder.append(_generateExecuteChain, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return NO_STATE;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param state - the state which is entered");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry code is executed if not handler");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return - the ID of the final leaf state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate_2 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_2, "");
+ _builder.append("int enterHistory(");
+ String _name_6 = ac.getName();
+ String _selfPointer_7 = this.langExt.selfPointer(_name_6, true);
+ _builder.append(_selfPointer_7, "");
+ _builder.append("int state, boolean handler, boolean skip_entry) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("while (");
+ String _booleanConstant = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant, " ");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_3 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
+ for(final State state_2 : _baseStateList_1) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_2 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_2, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_2);
+ if (_hasEntryCode_1) {
+ _builder.append("if (!(skip_entry || handler)) ");
+ String _entryCodeOperationName_1 = CodegenHelpers.getEntryCodeOperationName(state_2);
+ _builder.append(_entryCodeOperationName_1, " ");
+ _builder.append("(");
+ String _selfPointer_8 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_8, " ");
+ _builder.append(");");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isLeaf = this.roomExt.isLeaf(state_2);
+ if (_isLeaf) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// in leaf state: return state id");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("return ");
+ String _stateId_3 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// state has a sub graph");
+ _builder.newLine();
+ {
+ StateGraph _subgraph = state_2.getSubgraph();
+ boolean _hasInitTransition = this.roomExt.hasInitTransition(_subgraph);
+ if (_hasInitTransition) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// with init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("if (");
+ String _memberAccess_1 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_1, " ");
+ _builder.append("history[");
+ String _stateId_4 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_4, " ");
+ _builder.append("]==NO_STATE) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StateGraph _subgraph_1 = state_2.getSubgraph();
+ Transition _initTransition = this.roomExt.getInitTransition(_subgraph_1);
+ Transition sub_initt = _initTransition;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = executeTransitionChain(");
+ String _selfPointer_9 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_9, " ");
+ TransitionChain _chain_1 = xpac.getChain(sub_initt);
+ String _chainId_1 = this.roomExt.getChainId(_chain_1);
+ _builder.append(_chainId_1, " ");
+ {
+ if (handleEvents) {
+ _builder.append(", ");
+ String _nullPointer = this.langExt.nullPointer();
+ _builder.append(_nullPointer, " ");
+ _builder.append(", ");
+ String _nullPointer_1 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_1, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = ");
+ String _memberAccess_2 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_2, " ");
+ _builder.append("history[");
+ String _stateId_5 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_5, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// without init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("state = ");
+ String _memberAccess_3 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_3, " ");
+ _builder.append("history[");
+ String _stateId_6 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_6, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("case STATE_TOP:");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("state = ");
+ String _memberAccess_4 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_4, " ");
+ _builder.append("history[STATE_TOP];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("skip_entry = ");
+ String _booleanConstant_1 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ String _accessLevelPublic = this.langExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic, "");
+ } else {
+ String _accessLevelPrivate_3 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_3, "");
+ }
+ }
+ _builder.append("void executeInitTransition(");
+ String _name_7 = ac.getName();
+ String _selfPointer_10 = this.langExt.selfPointer(_name_7, false);
+ _builder.append(_selfPointer_10, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ StateGraph _stateMachine_4 = xpac.getStateMachine();
+ Transition _initTransition_1 = this.roomExt.getInitTransition(_stateMachine_4);
+ Transition initt = _initTransition_1;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int chain = ");
+ TransitionChain _chain_2 = xpac.getChain(initt);
+ String _chainId_2 = this.roomExt.getChainId(_chain_2);
+ _builder.append(_chainId_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int next = executeTransitionChain(");
+ String _selfPointer_11 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_11, " ");
+ _builder.append("chain");
+ {
+ if (handleEvents) {
+ _builder.append(", ");
+ String _nullPointer_2 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_2, " ");
+ _builder.append(", ");
+ String _nullPointer_3 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_3, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("next = enterHistory(");
+ String _selfPointer_12 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_12, " ");
+ _builder.append("next, ");
+ String _booleanConstant_2 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_2, " ");
+ _builder.append(", ");
+ String _booleanConstant_3 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_3, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("setState(");
+ String _selfPointer_13 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_13, " ");
+ _builder.append("next);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* receiveEvent contains the main implementation of the FSM */");
+ _builder.newLine();
+ {
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ if (_usesInheritance_2) {
+ String _accessLevelPublic_1 = this.langExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic_1, "");
+ } else {
+ String _accessLevelPrivate_4 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_4, "");
+ }
+ }
+ _builder.append("void receiveEvent(");
+ String _name_8 = ac.getName();
+ String _selfPointer_14 = this.langExt.selfPointer(_name_8, handleEvents);
+ _builder.append(_selfPointer_14, "");
+ {
+ if (handleEvents) {
+ _builder.append("InterfaceItemBase ifitem, int evt, ");
+ String _voidPointer_1 = this.langExt.voidPointer();
+ _builder.append(_voidPointer_1, "");
+ _builder.append(" generic_data");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ {
+ if (async) {
+ _builder.append("\t");
+ _builder.append("int trigger = (ifitem==");
+ String _nullPointer_4 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_4, " ");
+ _builder.append(")? POLLING : ");
+ {
+ boolean _usesInheritance_3 = this.langExt.usesInheritance();
+ if (_usesInheritance_3) {
+ _builder.append("ifitem.getLocalId()");
+ } else {
+ _builder.append("ifitem->localId");
+ }
+ }
+ _builder.append(" + EVT_SHIFT*evt;");
+ _builder.newLineIfNotEmpty();
+ } else {
+ if (eventDriven) {
+ _builder.append("\t");
+ _builder.append("int trigger = ");
+ {
+ boolean _usesInheritance_4 = this.langExt.usesInheritance();
+ if (_usesInheritance_4) {
+ _builder.append("ifitem.getLocalId()");
+ } else {
+ _builder.append("ifitem->localId");
+ }
+ }
+ _builder.append(" + EVT_SHIFT*evt;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("int chain = NOT_CAUGHT;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int catching_state = NO_STATE;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean is_handler = ");
+ String _booleanConstant_4 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_4, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("boolean skip_entry = ");
+ String _booleanConstant_5 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_5, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if (handleEvents) {
+ _builder.append("\t");
+ _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genStateSwitch = this.genStateSwitch(xpac, dct);
+ _builder.append(_genStateSwitch, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ StringConcatenation _genStateSwitch_1 = this.genStateSwitch(xpac, dct);
+ _builder.append(_genStateSwitch_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("if (chain != NOT_CAUGHT) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("exitTo(");
+ String _selfPointer_15 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_15, " ");
+ String _memberAccess_5 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_5, " ");
+ _builder.append("state, catching_state, is_handler);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("int next = executeTransitionChain(");
+ String _selfPointer_16 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_16, " ");
+ _builder.append("chain");
+ {
+ if (handleEvents) {
+ _builder.append(", ifitem, generic_data");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("next = enterHistory(");
+ String _selfPointer_17 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_17, " ");
+ _builder.append("next, is_handler, skip_entry);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("setState(");
+ String _selfPointer_18 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_18, " ");
+ _builder.append("next);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.append("// END of generated code for FSM");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genStateSwitch(final ExpandedActorClass xpac, final DetailCodeTranslator dct) {
+ StringConcatenation _xblockexpression = null;
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ ActorCommunicationType _commType = _actorClass.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ boolean async = _operator_equals;
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ ActorCommunicationType _commType_1 = _actorClass_1.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ boolean eventDriven = _operator_equals_1;
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ ActorCommunicationType _commType_2 = _actorClass_2.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ boolean dataDriven = _operator_equals_2;
+ boolean _operator_or = false;
+ if (async) {
+ _operator_or = true;
+ } else {
+ _operator_or = BooleanExtensions.operator_or(async, eventDriven);
+ }
+ boolean handleEvents = _operator_or;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("switch (");
+ String _memberAccess = this.langExt.memberAccess();
+ _builder.append(_memberAccess, "");
+ _builder.append("state) {");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine);
+ for(final State state : _leafStateList) {
+ _builder.append("\t");
+ _builder.append("case ");
+ String _stateId = this.roomExt.getStateId(state);
+ _builder.append(_stateId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ {
+ if (async) {
+ _builder.append("\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state);
+ EList<ActiveTrigger> atlist = _activeTriggers;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty = atlist.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("case POLLING:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genDataDrivenTriggers = this.genDataDrivenTriggers(xpac, state, dct);
+ _builder.append(_genDataDrivenTriggers, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genEventDrivenTriggers = this.genEventDrivenTriggers(xpac, state, atlist, dct);
+ _builder.append(_genEventDrivenTriggers, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ if (dataDriven) {
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genDataDrivenTriggers_1 = this.genDataDrivenTriggers(xpac, state, dct);
+ _builder.append(_genDataDrivenTriggers_1, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ if (eventDriven) {
+ _builder.append("\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> _activeTriggers_1 = xpac.getActiveTriggers(state);
+ EList<ActiveTrigger> atlist_1 = _activeTriggers_1;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty_1 = atlist_1.isEmpty();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
+ if (_operator_not_1) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StringConcatenation _genEventDrivenTriggers_1 = this.genEventDrivenTriggers(xpac, state, atlist_1, dct);
+ _builder.append(_genEventDrivenTriggers_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genDataDrivenTriggers(final ExpandedActorClass xpac, final State state, final DetailCodeTranslator dct) {
+ StringConcatenation _builder = new StringConcatenation();
+ StringConcatenation _genDoCodes = this.genDoCodes(state);
+ _builder.append(_genDoCodes, "");
+ _builder.newLineIfNotEmpty();
+ List<Transition> _outgoingTransitionsHierarchical = this.roomExt.getOutgoingTransitionsHierarchical(xpac, state);
+ final Function1<Transition,Boolean> _function = new Function1<Transition,Boolean>() {
+ public Boolean apply(final Transition t) {
+ return ((Boolean)(t instanceof GuardedTransition));
+ }
+ };
+ Iterable<Transition> _filter = IterableExtensions.<Transition>filter(_outgoingTransitionsHierarchical, _function);
+ Iterable<Transition> transitions = _filter;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final Transition tr : transitions) {
+ _builder.append("if (");
+ DetailCode _guard = ((GuardedTransition) tr).getGuard();
+ String _translateDetailCode = dct.translateDetailCode(_guard);
+ _builder.append(_translateDetailCode, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ TransitionChain _chain = xpac.getChain(tr);
+ TransitionChain chain = _chain;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId = this.roomExt.getChainId(chain);
+ _builder.append(_chainId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("catching_state = ");
+ String _contextId = this.roomExt.getContextId(chain);
+ _builder.append(_contextId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = TRUE;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = TRUE;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ {
+ Transition _last = IterableExtensions.<Transition>last(transitions);
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(tr, _last);
+ if (_operator_notEquals) {
+ _builder.append("else ");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private StringConcatenation genEventDrivenTriggers(final ExpandedActorClass xpac, final State state, final List<ActiveTrigger> atlist, final DetailCodeTranslator dct) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final ActiveTrigger at : atlist) {
+ _builder.append("case ");
+ String _trigger = at.getTrigger();
+ String _triggerCodeName = xpac.getTriggerCodeName(_trigger);
+ _builder.append(_triggerCodeName, "");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
+ boolean needData = _hasGuard;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("{ ");
+ Message _msg = at.getMsg();
+ String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
+ _builder.append(_typedDataDefinition, " ");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ boolean hasAnyElements = false;
+ for(final TriggeredTransition tt : _transitions) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(" else ", " ");
+ }
+ _builder.append("\t");
+ TransitionChain _chain = xpac.getChain(tt);
+ TransitionChain chain = _chain;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ Transition _transition = chain.getTransition();
+ String _trigger_1 = at.getTrigger();
+ StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac, dct);
+ _builder.append(_guard, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId = this.roomExt.getChainId(chain);
+ _builder.append(_chainId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("catching_state = ");
+ String _contextId = this.roomExt.getContextId(chain);
+ _builder.append(_contextId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = ");
+ String _booleanConstant = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant, " ");
+ _builder.append(";");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = ");
+ String _booleanConstant_1 = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant_1, " ");
+ _builder.append(";");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("}");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+
+ private StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac, final DetailCodeTranslator dct) {
+ StringConcatenation _xblockexpression = null;
+ {
+ EList<Trigger> _triggers = tt.getTriggers();
+ final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
+ public Boolean apply(final Trigger e) {
+ boolean _isMatching = ac.isMatching(e, trigger);
+ return ((Boolean)_isMatching);
+ }
+ };
+ Trigger _findFirst = IterableExtensions.<Trigger>findFirst(_triggers, _function);
+ Trigger tr = _findFirst;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasGuard = this.roomExt.hasGuard(tr);
+ if (_hasGuard) {
+ _builder.append("if (");
+ Guard _guard = tr.getGuard();
+ DetailCode _guard_1 = _guard.getGuard();
+ String _translateDetailCode = dct.translateDetailCode(_guard_1);
+ _builder.append(_translateDetailCode, "");
+ _builder.append(")");
+