Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen')
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java1106
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java832
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java136
-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.java1802
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java1743
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java1266
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java304
8 files changed, 3655 insertions, 3656 deletions
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index 93f5cefa2..0b9b4bb78 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -1,553 +1,553 @@
-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.Message;
-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.StateMachine;
-import org.eclipse.etrice.core.room.VarDecl;
-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.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-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.IntegerExtensions;
-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 {
- @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 _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.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.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();
- {
- List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
- for(final Port ep_1 : _endPorts_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_7 = ep_1.getName();
- _builder.append(_name_7, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap_1 : _strSAPs_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_8 = sap_1.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1);
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1));
- _builder.append(_operator_plus_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- SPPRef _spp_1 = svc_1.getSpp();
- String _name_9 = _spp_1.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = ");
- SPPRef _spp_2 = svc_1.getSpp();
- int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_2), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = ac.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<StandardOperation> _operations = ac.getOperations();
- String _name_10 = ac.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_10);
- _builder.append(_OperationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- construction");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_11 = ac.getName();
- _builder.append(_name_11, " ");
- _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_12 = ac.getName();
- _builder.append(_name_12, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_1 = ac.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_1);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own ports");
- _builder.newLine();
- {
- List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
- for(final Port ep_2 : _endPorts_2) {
- _builder.append("\t\t");
- String _name_13 = ep_2.getName();
- _builder.append(_name_13, " ");
- _builder.append(" = new ");
- String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
- _builder.append(_portClassName_3, " ");
- _builder.append("(this, \"");
- String _name_14 = ep_2.getName();
- _builder.append(_name_14, " ");
- _builder.append("\", IFITEM_");
- String _name_15 = ep_2.getName();
- _builder.append(_name_15, " ");
- _builder.append(", ");
- {
- int _multiplicity = ep_2.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_16 = ep_2.getName();
- _builder.append(_name_16, " ");
- _builder.append("]");
- {
- int _multiplicity_1 = ep_2.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_17 = ep_2.getName();
- _builder.append(_name_17, " ");
- _builder.append("]");
- {
- int _multiplicity_2 = ep_2.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.append("// own saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
- for(final SAPRef sap_2 : _strSAPs_2) {
- _builder.append("\t\t");
- String _name_18 = sap_2.getName();
- _builder.append(_name_18, " ");
- _builder.append(" = new ");
- String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
- _builder.append(_portClassName_4, " ");
- _builder.append("(this, \"");
- String _name_19 = sap_2.getName();
- _builder.append(_name_19, " ");
- _builder.append("\", IFITEM_");
- String _name_20 = sap_2.getName();
- _builder.append(_name_20, " ");
- _builder.append(", 0, port_addr[IFITEM_");
- String _name_21 = sap_2.getName();
- _builder.append(_name_21, " ");
- _builder.append("][0], peer_addr[IFITEM_");
- String _name_22 = sap_2.getName();
- _builder.append(_name_22, " ");
- _builder.append("][0]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("// own service implementations");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
- _builder.append("\t\t");
- SPPRef _spp_3 = svc_2.getSpp();
- String _name_23 = _spp_3.getName();
- _builder.append(_name_23, " ");
- _builder.append(" = new ");
- String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
- _builder.append(_portClassName_5, " ");
- _builder.append("(this, \"");
- SPPRef _spp_4 = svc_2.getSpp();
- String _name_24 = _spp_4.getName();
- _builder.append(_name_24, " ");
- _builder.append("\", IFITEM_");
- SPPRef _spp_5 = svc_2.getSpp();
- String _name_25 = _spp_5.getName();
- _builder.append(_name_25, " ");
- _builder.append(", port_addr[IFITEM_");
- SPPRef _spp_6 = svc_2.getSpp();
- String _name_26 = _spp_6.getName();
- _builder.append(_name_26, " ");
- _builder.append("], peer_addr[IFITEM_");
- SPPRef _spp_7 = svc_2.getSpp();
- String _name_27 = _spp_7.getName();
- _builder.append(_name_27, " ");
- _builder.append("]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _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();
- _builder.append("\t\t");
- _builder.append("destroyUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.newLine();
- {
- StateMachine _stateMachine = ac.getStateMachine();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_stateMachine, null);
- if (_operator_notEquals_1) {
- _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();
- return _builder;
- }
-
- public StringConcatenation msgArgs(final Message msg) {
- StringConcatenation _builder = new StringConcatenation();
- {
- VarDecl _data = msg.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = msg.getData();
- String _defaultValue = this._typeHelpers.defaultValue(_data_1);
- _builder.append(_defaultValue, "");
- }
- }
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+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.StateGraph;
+import org.eclipse.etrice.core.room.VarDecl;
+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.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+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.IntegerExtensions;
+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 {
+ @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 _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.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.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();
+ {
+ List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_1 : _endPorts_1) {
+ _builder.append("\t");
+ _builder.append("protected static final int IFITEM_");
+ String _name_7 = ep_1.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(" = ");
+ int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ _builder.append(_operator_plus, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
+ for(final SAPRef sap_1 : _strSAPs_1) {
+ _builder.append("\t");
+ _builder.append("protected static final int IFITEM_");
+ String _name_8 = sap_1.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(" = ");
+ int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1);
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1));
+ _builder.append(_operator_plus_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
+ _builder.append("\t");
+ _builder.append("protected static final int IFITEM_");
+ SPPRef _spp_1 = svc_1.getSpp();
+ String _name_9 = _spp_1.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" = ");
+ SPPRef _spp_2 = svc_1.getSpp();
+ int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2);
+ int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_2), ((Integer)1));
+ _builder.append(_operator_plus_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
+ _builder.append(_Attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<StandardOperation> _operations = ac.getOperations();
+ String _name_10 = ac.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_10);
+ _builder.append(_OperationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- construction");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_11 = ac.getName();
+ _builder.append(_name_11, " ");
+ _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_12 = ac.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<Attribute> _attributes_1 = ac.getAttributes();
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_1);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_2 : _endPorts_2) {
+ _builder.append("\t\t");
+ String _name_13 = ep_2.getName();
+ _builder.append(_name_13, " ");
+ _builder.append(" = new ");
+ String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
+ _builder.append(_portClassName_3, " ");
+ _builder.append("(this, \"");
+ String _name_14 = ep_2.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("\", IFITEM_");
+ String _name_15 = ep_2.getName();
+ _builder.append(_name_15, " ");
+ _builder.append(", ");
+ {
+ int _multiplicity = ep_2.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_16 = ep_2.getName();
+ _builder.append(_name_16, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_1 = ep_2.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_17 = ep_2.getName();
+ _builder.append(_name_17, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_2 = ep_2.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.append("// own saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
+ for(final SAPRef sap_2 : _strSAPs_2) {
+ _builder.append("\t\t");
+ String _name_18 = sap_2.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(" = new ");
+ String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
+ _builder.append(_portClassName_4, " ");
+ _builder.append("(this, \"");
+ String _name_19 = sap_2.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("\", IFITEM_");
+ String _name_20 = sap_2.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(", 0, port_addr[IFITEM_");
+ String _name_21 = sap_2.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("][0], peer_addr[IFITEM_");
+ String _name_22 = sap_2.getName();
+ _builder.append(_name_22, " ");
+ _builder.append("][0]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("// own service implementations");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
+ _builder.append("\t\t");
+ SPPRef _spp_3 = svc_2.getSpp();
+ String _name_23 = _spp_3.getName();
+ _builder.append(_name_23, " ");
+ _builder.append(" = new ");
+ String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
+ _builder.append(_portClassName_5, " ");
+ _builder.append("(this, \"");
+ SPPRef _spp_4 = svc_2.getSpp();
+ String _name_24 = _spp_4.getName();
+ _builder.append(_name_24, " ");
+ _builder.append("\", IFITEM_");
+ SPPRef _spp_5 = svc_2.getSpp();
+ String _name_25 = _spp_5.getName();
+ _builder.append(_name_25, " ");
+ _builder.append(", port_addr[IFITEM_");
+ SPPRef _spp_6 = svc_2.getSpp();
+ String _name_26 = _spp_6.getName();
+ _builder.append(_name_26, " ");
+ _builder.append("], peer_addr[IFITEM_");
+ SPPRef _spp_7 = svc_2.getSpp();
+ String _name_27 = _spp_7.getName();
+ _builder.append(_name_27, " ");
+ _builder.append("]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _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();
+ _builder.append("\t\t");
+ _builder.append("destroyUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}\t");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = ac.getStateMachine();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_stateMachine, null);
+ if (_operator_notEquals_1) {
+ _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();
+ return _builder;
+ }
+
+ public StringConcatenation msgArgs(final Message msg) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ VarDecl _data = msg.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ VarDecl _data_1 = msg.getData();
+ String _defaultValue = this._typeHelpers.defaultValue(_data_1);
+ _builder.append(_defaultValue, "");
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
index 72b95f5fe..491ab4c25 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -1,416 +1,416 @@
-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.generator.base.ILogger;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-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.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 _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 = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_1 = dc.getAttributes();
- String _name_3 = dc.getName();
- StringConcatenation _AttributeSettersGettersImplementation = this.helpers.AttributeSettersGettersImplementation(_attributes_1, _name_3);
- _builder.append(_AttributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_4 = dc.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _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_2 = dc.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_2);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _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_1 = ObjectExtensions.operator_notEquals(_base_2, null);
- if (_operator_notEquals_1) {
- _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_3 = dc.getAttributes();
- for(final Attribute a : _attributes_3) {
- _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();
- return _builder;
- }
-
- 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)) {
- {
- int _size = a.getSize();
- boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
- if (_operator_equals) {
- _builder.append("copy.");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append(" = ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- _builder.append(".deepCopy();");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- int _size_1 = a.getSize();
- _builder.append(_size_1, "");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("copy.");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append("[i] = ");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append("[i].deepCopy();");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- {
- int _size_2 = a.getSize();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_2), ((Integer)0));
- if (_operator_equals_1) {
- _builder.append("copy.");
- String _name_4 = a.getName();
- _builder.append(_name_4, "");
- _builder.append(" = ");
- String _name_5 = a.getName();
- _builder.append(_name_5, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- int _size_3 = a.getSize();
- _builder.append(_size_3, "");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("copy.");
- String _name_6 = a.getName();
- _builder.append(_name_6, " ");
- _builder.append("[i] = ");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append("[i];");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.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.generator.base.ILogger;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+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.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 _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 = this.helpers.Attributes(_attributes);
+ _builder.append(_Attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_1 = dc.getAttributes();
+ String _name_3 = dc.getName();
+ StringConcatenation _AttributeSettersGettersImplementation = this.helpers.AttributeSettersGettersImplementation(_attributes_1, _name_3);
+ _builder.append(_AttributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_4 = dc.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _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_2 = dc.getAttributes();
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_2);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ _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_1 = ObjectExtensions.operator_notEquals(_base_2, null);
+ if (_operator_notEquals_1) {
+ _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_3 = dc.getAttributes();
+ for(final Attribute a : _attributes_3) {
+ _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();
+ return _builder;
+ }
+
+ 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)) {
+ {
+ int _size = a.getSize();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
+ if (_operator_equals) {
+ _builder.append("copy.");
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append(" = ");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".deepCopy();");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("for (int i=0;i<");
+ int _size_1 = a.getSize();
+ _builder.append(_size_1, "");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("[i] = ");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("[i].deepCopy();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ {
+ int _size_2 = a.getSize();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_2), ((Integer)0));
+ if (_operator_equals_1) {
+ _builder.append("copy.");
+ String _name_4 = a.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" = ");
+ String _name_5 = a.getName();
+ _builder.append(_name_5, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, "");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("[i] = ");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("[i];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index fafe79b1a..91db89536 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -1,68 +1,68 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class JavaExtensions implements ILanguageExtension {
- @Inject
- private LanguageGenerator languageGen;
-
- public String getTypedDataDefinition(final Message m) {
- String _typedData = this.languageGen.getTypedData(m);
- return _typedData;
- }
-
- 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 int argumentCount) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- return "";
- }
-
- public String outMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus("OUT_", messagename);
- return _operator_plus;
- }
-
- public String inMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus("IN_", messagename);
- return _operator_plus;
- }
-
- public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
- String _executeChain = this.languageGen.getExecuteChain(ac, tc);
- return _executeChain;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.TransitionChain;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class JavaExtensions implements ILanguageExtension {
+ @Inject
+ private LanguageGenerator languageGen;
+
+ public String getTypedDataDefinition(final Message m) {
+ String _typedData = this.languageGen.getTypedData(m);
+ return _typedData;
+ }
+
+ 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 int argumentCount) {
+ return "";
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ return "";
+ }
+
+ public String outMessageId(final String classname, final String messagename) {
+ String _operator_plus = StringExtensions.operator_plus("OUT_", messagename);
+ return _operator_plus;
+ }
+
+ public String inMessageId(final String classname, final String messagename) {
+ String _operator_plus = StringExtensions.operator_plus("IN_", messagename);
+ return _operator_plus;
+ }
+
+ public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
+ String _executeChain = this.languageGen.getExecuteChain(ac, tc);
+ return _executeChain;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.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 b52095047..c2e9efeed 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.extensions.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.extensions.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 016542f0b..4b4c10a6b 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,901 +1,901 @@
-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.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-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.IntegerExtensions;
-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 {
- @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");
- _builder.append("// TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// error if msgID <= MSG_MIN");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public static final int MSG_MIN = 0; ");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//IDs for outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message message : _allOutgoingMessages) {
- _builder.append("\t");
- _builder.append("public static final int ");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _outMessageId = this.stdExt.outMessageId(_name_2, _name_3);
- _builder.append(_outMessageId, " ");
- _builder.append(" = ");
- List<Message> _allOutgoingMessages_1 = this.roomExt.getAllOutgoingMessages(pc);
- int _indexOf = _allOutgoingMessages_1.indexOf(message);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//IDs for incoming messages");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message message_1 : _allIncomingMessages) {
- _builder.append("\t");
- _builder.append("public static final int ");
- String _name_4 = pc.getName();
- String _name_5 = message_1.getName();
- String _inMessageId = this.stdExt.inMessageId(_name_4, _name_5);
- _builder.append(_inMessageId, " ");
- _builder.append(" = ");
- List<Message> _allIncomingMessages_1 = this.roomExt.getAllIncomingMessages(pc);
- int _indexOf_1 = _allIncomingMessages_1.indexOf(message_1);
- List<Message> _allOutgoingMessages_2 = this.roomExt.getAllOutgoingMessages(pc);
- int _size = _allOutgoingMessages_2.size();
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)_size));
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_operator_plus_1), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//error if msgID >= MSG_MAX");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public static final int MSG_MAX = ");
- List<Message> _allOutgoingMessages_3 = this.roomExt.getAllOutgoingMessages(pc);
- int _size_1 = _allOutgoingMessages_3.size();
- List<Message> _allIncomingMessages_2 = this.roomExt.getAllIncomingMessages(pc);
- int _size_2 = _allIncomingMessages_2.size();
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_size_1), ((Integer)_size_2));
- int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)_operator_plus_3), ((Integer)1));
- _builder.append(_operator_plus_4, " ");
- _builder.append("; ");
- _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_4 = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages_4) {
- _builder.append("\"");
- String _name_6 = m.getName();
- _builder.append(_name_6, " ");
- _builder.append("\",");
- }
- }
- _builder.append(" ");
- {
- List<Message> _allIncomingMessages_3 = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages_3) {
- _builder.append("\"");
- String _name_7 = m_1.getName();
- _builder.append(_name_7, " ");
- _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 _builder = new StringConcatenation();
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String name = _portClassName;
- _builder.newLineIfNotEmpty();
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pclass = _portClass;
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(name, "");
- _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 = this.helpers.UserCode(_userCode);
- _builder.append(_UserCode, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("// constructors");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(name, " ");
- _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(name, " ");
- _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("// TODOTS: model switch for activation");
- _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 = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, name);
- _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(name, "");
- _builder.append("Repl {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private ArrayList<");
- _builder.append(name, " ");
- _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(name, " ");
- _builder.append("Repl(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.length;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("ports = new ArrayList<");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append(".");
- _builder.append(name, " ");
- _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(name, " ");
- _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(name, " ");
- _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();
- return _builder;
- }
-
- 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("\t");
- _builder.append("// TODOTS: model switch for activation");
- _builder.newLine();
- _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.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+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.IntegerExtensions;
+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 {
+ @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");
+ _builder.append("// TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// error if msgID <= MSG_MIN");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public static final int MSG_MIN = 0; ");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//IDs for outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message message : _allOutgoingMessages) {
+ _builder.append("\t");
+ _builder.append("public static final int ");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _outMessageId = this.stdExt.outMessageId(_name_2, _name_3);
+ _builder.append(_outMessageId, " ");
+ _builder.append(" = ");
+ List<Message> _allOutgoingMessages_1 = this.roomExt.getAllOutgoingMessages(pc);
+ int _indexOf = _allOutgoingMessages_1.indexOf(message);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
+ _builder.append(_operator_plus, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("//IDs for incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message message_1 : _allIncomingMessages) {
+ _builder.append("\t");
+ _builder.append("public static final int ");
+ String _name_4 = pc.getName();
+ String _name_5 = message_1.getName();
+ String _inMessageId = this.stdExt.inMessageId(_name_4, _name_5);
+ _builder.append(_inMessageId, " ");
+ _builder.append(" = ");
+ List<Message> _allIncomingMessages_1 = this.roomExt.getAllIncomingMessages(pc);
+ int _indexOf_1 = _allIncomingMessages_1.indexOf(message_1);
+ List<Message> _allOutgoingMessages_2 = this.roomExt.getAllOutgoingMessages(pc);
+ int _size = _allOutgoingMessages_2.size();
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)_size));
+ int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_operator_plus_1), ((Integer)1));
+ _builder.append(_operator_plus_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("//error if msgID >= MSG_MAX");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public static final int MSG_MAX = ");
+ List<Message> _allOutgoingMessages_3 = this.roomExt.getAllOutgoingMessages(pc);
+ int _size_1 = _allOutgoingMessages_3.size();
+ List<Message> _allIncomingMessages_2 = this.roomExt.getAllIncomingMessages(pc);
+ int _size_2 = _allIncomingMessages_2.size();
+ int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_size_1), ((Integer)_size_2));
+ int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)_operator_plus_3), ((Integer)1));
+ _builder.append(_operator_plus_4, " ");
+ _builder.append("; ");
+ _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_4 = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages_4) {
+ _builder.append("\"");
+ String _name_6 = m.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append(" ");
+ {
+ List<Message> _allIncomingMessages_3 = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages_3) {
+ _builder.append("\"");
+ String _name_7 = m_1.getName();
+ _builder.append(_name_7, " ");
+ _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 _builder = new StringConcatenation();
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String name = _portClassName;
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ PortClass pclass = _portClass;
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(name, "");
+ _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 = this.helpers.UserCode(_userCode);
+ _builder.append(_UserCode, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("// constructors");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(name, " ");
+ _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(name, " ");
+ _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("// TODOTS: model switch for activation");
+ _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 = this.helpers.Attributes(_attributes);
+ _builder.append(_Attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<PortOperation> _operations = pclass.getOperations();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, name);
+ _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(name, "");
+ _builder.append("Repl {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private ArrayList<");
+ _builder.append(name, " ");
+ _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(name, " ");
+ _builder.append("Repl(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.length;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports = new ArrayList<");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append(".");
+ _builder.append(name, " ");
+ _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(name, " ");
+ _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(name, " ");
+ _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();
+ return _builder;
+ }
+
+ 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("\t");
+ _builder.append("// TODOTS: model switch for activation");
+ _builder.newLine();
+ _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 1304fe233..70ea09bb1 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,872 +1,871 @@
-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.DetailCode;
-import org.eclipse.etrice.core.room.Guard;
-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.StateMachine;
-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.etricegen.ActiveTrigger;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.extensions.RoomNameProv;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-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.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class StateMachineGen {
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private LanguageGenerator languageGen;
-
- public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.append("// START of generated code for FSM");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// State IDs for FSM");
- _builder.newLine();
- int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
- int offset = _numberOfInheritedBaseStates;
- _builder.newLineIfNotEmpty();
- StateMachine _stateMachine = ac.getStateMachine();
- List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
- List<State> baseStates = _baseStateList;
- _builder.newLineIfNotEmpty();
- {
- for(final State state : baseStates) {
- _builder.append("protected static final int ");
- String _stateId = this.roomExt.getStateId(state);
- _builder.append(_stateId, "");
- _builder.append(" = ");
- int _indexOf = baseStates.indexOf(state);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)2));
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_operator_plus), ((Integer)offset));
- _builder.append(_operator_plus_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
- {
- List<State> _allBaseStates = this.roomExt.getAllBaseStates(ac);
- boolean hasAnyElements = false;
- for(final State state_1 : _allBaseStates) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\"");
- String _statePathName = this.roomExt.getStatePathName(state_1);
- _builder.append(_statePathName, " ");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// history");
- _builder.newLine();
- _builder.append("// TODOHRR: history defined in ActorClassBase, init in constructor");
- _builder.newLine();
- _builder.append("//\t\thistory = new int[5];");
- _builder.newLine();
- _builder.append("//\t\tfor (int i = 0; i < history.length; i++) {");
- _builder.newLine();
- _builder.append("//\t\t\thistory[i] = NO_STATE;");
- _builder.newLine();
- _builder.append("//\t\t}");
- _builder.newLine();
- _builder.append("protected int history[] = {NO_STATE,NO_STATE");
- {
- List<State> _allBaseStates_1 = this.roomExt.getAllBaseStates(ac);
- for(final State state_2 : _allBaseStates_1) {
- _builder.append(",NO_STATE");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
- List<TransitionChain> chains = _ownTransitionChains;
- _builder.newLineIfNotEmpty();
- EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
- int _size = _transitionChains.size();
- int _size_1 = chains.size();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
- int offset_tc = _operator_minus;
- _builder.newLineIfNotEmpty();
- _builder.append("// transition chains");
- _builder.newLine();
- {
- for(final TransitionChain tc : chains) {
- _builder.append("protected static final int ");
- String _chainId = this.roomExt.getChainId(tc);
- _builder.append(_chainId, "");
- _builder.append(" = ");
- int _indexOf_1 = chains.indexOf(tc);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)1));
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_operator_plus_2), ((Integer)offset_tc));
- _builder.append(_operator_plus_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
- EList<MessageFromIf> triggers = _ownTriggers;
- _builder.newLineIfNotEmpty();
- _builder.append("// triggers for FSM");
- _builder.newLine();
- {
- for(final MessageFromIf mif : triggers) {
- _builder.append("protected static final int ");
- String _triggerCodeName = xpac.getTriggerCodeName(mif);
- _builder.append(_triggerCodeName, "");
- _builder.append(" = IFITEM_");
- InterfaceItem _from = mif.getFrom();
- String _name = _from.getName();
- _builder.append(_name, "");
- _builder.append(" + EVT_SHIFT*");
- String _messageID = xpac.getMessageID(mif);
- _builder.append(_messageID, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// receiveEvent contains the main implementation of the FSM");
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;");
- _builder.newLine();
- _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 = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean skip_entry = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateMachine _stateMachine_1 = xpac.getStateMachine();
- List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_1);
- for(final State state_3 : _leafStateList) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_1 = this.roomExt.getStateId(state_3);
- _builder.append(_stateId_1, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state_3);
- EList<ActiveTrigger> atlist = _activeTriggers;
- _builder.newLineIfNotEmpty();
- {
- boolean _isEmpty = atlist.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("switch(trigger) {");
- _builder.newLine();
- {
- for(final ActiveTrigger at : atlist) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- String _trigger = at.getTrigger();
- String _triggerCodeName_1 = xpac.getTriggerCodeName(_trigger);
- _builder.append(_triggerCodeName_1, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
- boolean needData = _hasGuard;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- if (needData) {
- _builder.append("{ ");
- Message _msg = at.getMsg();
- String _typedDataDefinition = this._typeHelpers.getTypedDataDefinition(_msg);
- _builder.append(_typedDataDefinition, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<TriggeredTransition> _transitions = at.getTransitions();
- boolean hasAnyElements_1 = false;
- for(final TriggeredTransition tt : _transitions) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(" else ", " ");
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- TransitionChain _chain = xpac.getChain(tt);
- TransitionChain chain = _chain;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- Transition _transition = chain.getTransition();
- String _trigger_1 = at.getTrigger();
- StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac);
- _builder.append(_guard, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("chain = ");
- String _chainId_1 = this.roomExt.getChainId(chain);
- _builder.append(_chainId_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _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\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- boolean _isHandler = chain.isHandler();
- if (_isHandler) {
- _builder.append("is_handler = true;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- boolean _isSkipEntry = chain.isSkipEntry();
- if (_isSkipEntry) {
- _builder.append("skip_entry = true;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- if (needData) {
- _builder.append("}");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _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("\t");
- _builder.append("if (chain != NOT_CAUGHT) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("exitTo(state, catching_state, is_handler);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int next = executeTransitionChain(chain, ifitem, generic_data);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("next = enterHistory(next, is_handler, skip_entry);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _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("// TODOTS: model switch for activation");
- _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();
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void executeInitTransition() {");
- _builder.newLine();
- _builder.append("\t");
- StateMachine _stateMachine_2 = xpac.getStateMachine();
- Transition _initTransition = this.roomExt.getInitTransition(_stateMachine_2);
- Transition initt = _initTransition;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int chain = ");
- TransitionChain _chain_1 = xpac.getChain(initt);
- String _chainId_2 = this.roomExt.getChainId(_chain_1);
- _builder.append(_chainId_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int next = executeTransitionChain(chain, null, null);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("next = enterHistory(next, false, false);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _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();
- _builder.append("private void exitTo(int current, int to, boolean handler) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (current!=to) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (current) {");
- _builder.newLine();
- {
- StateMachine _stateMachine_3 = xpac.getStateMachine();
- List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
- for(final State state_4 : _baseStateList_1) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_2 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_2, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasExitCode = this.roomExt.hasExitCode(state_4);
- if (_hasExitCode) {
- _builder.append("if (!handler) ");
- String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state_4);
- _builder.append(_exitCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("history[");
- String _parentStateId = RoomNameProv.getParentStateId(state_4);
- _builder.append(_parentStateId, " ");
- _builder.append("] = ");
- String _stateId_3 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("current = ");
- String _parentStateId_1 = RoomNameProv.getParentStateId(state_4);
- _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.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();
- _builder.append("private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("switch (chain) {");
- _builder.newLine();
- _builder.append("\t\t");
- EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
- EList<TransitionChain> allchains = _transitionChains_1;
- _builder.newLineIfNotEmpty();
- {
- for(final TransitionChain tc_1 : allchains) {
- _builder.append("\t\t");
- _builder.append("case ");
- String _chainId_3 = this.roomExt.getChainId(tc_1);
- _builder.append(_chainId_3, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- String _executeChainCode = this.stdExt.getExecuteChainCode(xpac, tc_1);
- _builder.append(_executeChainCode, " ");
- _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.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();
- _builder.append("private int enterHistory(int state, boolean handler, boolean skip_entry) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (true) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateMachine _stateMachine_4 = xpac.getStateMachine();
- List<State> _baseStateList_2 = this.roomExt.getBaseStateList(_stateMachine_4);
- for(final State state_5 : _baseStateList_2) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_4 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_4, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasEntryCode = this.roomExt.hasEntryCode(state_5);
- if (_hasEntryCode) {
- _builder.append("if (!(skip_entry || handler)) ");
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state_5);
- _builder.append(_entryCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- boolean _isLeaf = this.roomExt.isLeaf(state_5);
- 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_5 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_5, " ");
- _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_5.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 (history[");
- String _stateId_6 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_6, " ");
- _builder.append("]==NO_STATE) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- StateGraph _subgraph_1 = state_5.getSubgraph();
- Transition _initTransition_1 = this.roomExt.getInitTransition(_subgraph_1);
- Transition sub_initt = _initTransition_1;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = executeTransitionChain(");
- TransitionChain _chain_2 = xpac.getChain(sub_initt);
- String _chainId_4 = this.roomExt.getChainId(_chain_2);
- _builder.append(_chainId_4, " ");
- _builder.append(", null, null);");
- _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 = history[");
- String _stateId_7 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_7, " ");
- _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 = history[");
- String _stateId_8 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_8, " ");
- _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 = history[STATE_TOP];");
- _builder.newLine();
- _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 = false;");
- _builder.newLine();
- _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();
- _builder.append("//*** Entry and Exit Codes");
- _builder.newLine();
- {
- StateMachine _stateMachine_5 = xpac.getStateMachine();
- List<State> _stateList = this.roomExt.getStateList(_stateMachine_5);
- for(final State state_6 : _stateList) {
- {
- boolean _isOwnObject = xpac.isOwnObject(state_6);
- if (_isOwnObject) {
- {
- boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_6);
- if (_hasEntryCode_1) {
- _builder.append("protected void ");
- String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_6);
- _builder.append(_entryCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _entryCode = this.roomExt.getEntryCode(xpac, state_6);
- _builder.append(_entryCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- {
- boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_6);
- if (_hasExitCode_1) {
- _builder.append("protected void ");
- String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_6);
- _builder.append(_exitCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _exitCode = this.roomExt.getExitCode(xpac, state_6);
- _builder.append(_exitCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("//*** Action Codes");
- _builder.newLine();
- {
- StateMachine _stateMachine_6 = xpac.getStateMachine();
- List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_6);
- 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) {
- _builder.append("protected void ");
- String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
- _builder.append(_actionCodeOperationName, "");
- _builder.append("(");
- {
- if ((tr instanceof NonInitialTransition)) {
- _builder.append("InterfaceItemBase ifitem");
- String _argumentList = this.languageGen.getArgumentList(xpac, tr);
- _builder.append(_argumentList, "");
- }
- }
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _actionCode = this.roomExt.getActionCode(xpac, tr);
- _builder.append(_actionCode, " ");
- _builder.newLineIfNotEmpty();
- _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();
- return _builder;
- }
-
- protected StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- 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;
- _builder.newLineIfNotEmpty();
- {
- boolean _hasGuard = this.roomExt.hasGuard(tr);
- if (_hasGuard) {
- _builder.append("if (");
- Guard _guard = tr.getGuard();
- DetailCode _guard_1 = _guard.getGuard();
- String _code = ac.getCode(_guard_1);
- _builder.append(_code, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- protected StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* error */");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
- if (tt instanceof TriggeredTransition) {
- return _guard((TriggeredTransition)tt, trigger, ac);
- } else {
- return _guard(tt, trigger, ac);
- }
- }
-}
+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.DetailCode;
+import org.eclipse.etrice.core.room.Guard;
+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.etricegen.ActiveTrigger;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.TransitionChain;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.extensions.RoomNameProv;
+import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+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.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class StateMachineGen {
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private LanguageGenerator languageGen;
+
+ public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.append("// START of generated code for FSM");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// State IDs for FSM");
+ _builder.newLine();
+ int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
+ int offset = _numberOfInheritedBaseStates;
+ _builder.newLineIfNotEmpty();
+ StateGraph _stateMachine = ac.getStateMachine();
+ List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
+ List<State> baseStates = _baseStateList;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final State state : baseStates) {
+ _builder.append("protected static final int ");
+ String _stateId = this.roomExt.getStateId(state);
+ _builder.append(_stateId, "");
+ _builder.append(" = ");
+ int _indexOf = baseStates.indexOf(state);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)2));
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_operator_plus), ((Integer)offset));
+ _builder.append(_operator_plus_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
+ {
+ List<State> _allBaseStates = this.roomExt.getAllBaseStates(ac);
+ boolean hasAnyElements = false;
+ for(final State state_1 : _allBaseStates) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\"");
+ String _statePathName = this.roomExt.getStatePathName(state_1);
+ _builder.append(_statePathName, " ");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// history");
+ _builder.newLine();
+ _builder.append("// TODOHRR: history defined in ActorClassBase, init in constructor");
+ _builder.newLine();
+ _builder.append("//\t\thistory = new int[5];");
+ _builder.newLine();
+ _builder.append("//\t\tfor (int i = 0; i < history.length; i++) {");
+ _builder.newLine();
+ _builder.append("//\t\t\thistory[i] = NO_STATE;");
+ _builder.newLine();
+ _builder.append("//\t\t}");
+ _builder.newLine();
+ _builder.append("protected int history[] = {NO_STATE,NO_STATE");
+ {
+ List<State> _allBaseStates_1 = this.roomExt.getAllBaseStates(ac);
+ for(final State state_2 : _allBaseStates_1) {
+ _builder.append(",NO_STATE");
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
+ List<TransitionChain> chains = _ownTransitionChains;
+ _builder.newLineIfNotEmpty();
+ EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
+ int _size = _transitionChains.size();
+ int _size_1 = chains.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
+ int offset_tc = _operator_minus;
+ _builder.newLineIfNotEmpty();
+ _builder.append("// transition chains");
+ _builder.newLine();
+ {
+ for(final TransitionChain tc : chains) {
+ _builder.append("protected static final int ");
+ String _chainId = this.roomExt.getChainId(tc);
+ _builder.append(_chainId, "");
+ _builder.append(" = ");
+ int _indexOf_1 = chains.indexOf(tc);
+ int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)1));
+ int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_operator_plus_2), ((Integer)offset_tc));
+ _builder.append(_operator_plus_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
+ EList<MessageFromIf> triggers = _ownTriggers;
+ _builder.newLineIfNotEmpty();
+ _builder.append("// triggers for FSM");
+ _builder.newLine();
+ {
+ for(final MessageFromIf mif : triggers) {
+ _builder.append("protected static final int ");
+ String _triggerCodeName = xpac.getTriggerCodeName(mif);
+ _builder.append(_triggerCodeName, "");
+ _builder.append(" = IFITEM_");
+ InterfaceItem _from = mif.getFrom();
+ String _name = _from.getName();
+ _builder.append(_name, "");
+ _builder.append(" + EVT_SHIFT*");
+ String _messageID = xpac.getMessageID(mif);
+ _builder.append(_messageID, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// receiveEvent contains the main implementation of the FSM");
+ _builder.newLine();
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;");
+ _builder.newLine();
+ _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 = false;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean skip_entry = false;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_1);
+ for(final State state_3 : _leafStateList) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_1 = this.roomExt.getStateId(state_3);
+ _builder.append(_stateId_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state_3);
+ EList<ActiveTrigger> atlist = _activeTriggers;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty = atlist.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ {
+ for(final ActiveTrigger at : atlist) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ String _trigger = at.getTrigger();
+ String _triggerCodeName_1 = xpac.getTriggerCodeName(_trigger);
+ _builder.append(_triggerCodeName_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
+ boolean needData = _hasGuard;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("{ ");
+ Message _msg = at.getMsg();
+ String _typedDataDefinition = this._typeHelpers.getTypedDataDefinition(_msg);
+ _builder.append(_typedDataDefinition, " ");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ boolean hasAnyElements_1 = false;
+ for(final TriggeredTransition tt : _transitions) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(" else ", " ");
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ TransitionChain _chain = xpac.getChain(tt);
+ TransitionChain chain = _chain;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ Transition _transition = chain.getTransition();
+ String _trigger_1 = at.getTrigger();
+ StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac);
+ _builder.append(_guard, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId_1 = this.roomExt.getChainId(chain);
+ _builder.append(_chainId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _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\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = true;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = true;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("}");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _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("\t");
+ _builder.append("if (chain != NOT_CAUGHT) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("exitTo(state, catching_state, is_handler);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("int next = executeTransitionChain(chain, ifitem, generic_data);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("next = enterHistory(next, is_handler, skip_entry);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("setState(next);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _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("// TODOTS: model switch for activation");
+ _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();
+ _builder.newLine();
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("public void executeInitTransition() {");
+ _builder.newLine();
+ _builder.append("\t");
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ Transition _initTransition = this.roomExt.getInitTransition(_stateMachine_2);
+ Transition initt = _initTransition;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int chain = ");
+ TransitionChain _chain_1 = xpac.getChain(initt);
+ String _chainId_2 = this.roomExt.getChainId(_chain_1);
+ _builder.append(_chainId_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int next = executeTransitionChain(chain, null, null);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("next = enterHistory(next, false, false);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("setState(next);");
+ _builder.newLine();
+ _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();
+ _builder.append("private void exitTo(int current, int to, boolean handler) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("while (current!=to) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (current) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_3 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
+ for(final State state_4 : _baseStateList_1) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_2 = this.roomExt.getStateId(state_4);
+ _builder.append(_stateId_2, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasExitCode = this.roomExt.hasExitCode(state_4);
+ if (_hasExitCode) {
+ _builder.append("if (!handler) ");
+ String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state_4);
+ _builder.append(_exitCodeOperationName, " ");
+ _builder.append("();");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("history[");
+ String _parentStateId = RoomNameProv.getParentStateId(state_4);
+ _builder.append(_parentStateId, " ");
+ _builder.append("] = ");
+ String _stateId_3 = this.roomExt.getStateId(state_4);
+ _builder.append(_stateId_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("current = ");
+ String _parentStateId_1 = RoomNameProv.getParentStateId(state_4);
+ _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.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();
+ _builder.append("private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("switch (chain) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
+ EList<TransitionChain> allchains = _transitionChains_1;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final TransitionChain tc_1 : allchains) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ String _chainId_3 = this.roomExt.getChainId(tc_1);
+ _builder.append(_chainId_3, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String _executeChainCode = this.stdExt.getExecuteChainCode(xpac, tc_1);
+ _builder.append(_executeChainCode, " ");
+ _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.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();
+ _builder.append("private int enterHistory(int state, boolean handler, boolean skip_entry) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("while (true) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_4 = xpac.getStateMachine();
+ List<State> _baseStateList_2 = this.roomExt.getBaseStateList(_stateMachine_4);
+ for(final State state_5 : _baseStateList_2) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_4 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_4, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasEntryCode = this.roomExt.hasEntryCode(state_5);
+ if (_hasEntryCode) {
+ _builder.append("if (!(skip_entry || handler)) ");
+ String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state_5);
+ _builder.append(_entryCodeOperationName, " ");
+ _builder.append("();");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isLeaf = this.roomExt.isLeaf(state_5);
+ 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_5 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_5, " ");
+ _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_5.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 (history[");
+ String _stateId_6 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_6, " ");
+ _builder.append("]==NO_STATE) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StateGraph _subgraph_1 = state_5.getSubgraph();
+ Transition _initTransition_1 = this.roomExt.getInitTransition(_subgraph_1);
+ Transition sub_initt = _initTransition_1;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = executeTransitionChain(");
+ TransitionChain _chain_2 = xpac.getChain(sub_initt);
+ String _chainId_4 = this.roomExt.getChainId(_chain_2);
+ _builder.append(_chainId_4, " ");
+ _builder.append(", null, null);");
+ _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 = history[");
+ String _stateId_7 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_7, " ");
+ _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 = history[");
+ String _stateId_8 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_8, " ");
+ _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 = history[STATE_TOP];");
+ _builder.newLine();
+ _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 = false;");
+ _builder.newLine();
+ _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();
+ _builder.append("//*** Entry and Exit Codes");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_5 = xpac.getStateMachine();
+ List<State> _stateList = this.roomExt.getStateList(_stateMachine_5);
+ for(final State state_6 : _stateList) {
+ {
+ boolean _isOwnObject = xpac.isOwnObject(state_6);
+ if (_isOwnObject) {
+ {
+ boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_6);
+ if (_hasEntryCode_1) {
+ _builder.append("protected void ");
+ String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_6);
+ _builder.append(_entryCodeOperationName_1, "");
+ _builder.append("() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _entryCode = this.roomExt.getEntryCode(xpac, state_6);
+ _builder.append(_entryCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_6);
+ if (_hasExitCode_1) {
+ _builder.append("protected void ");
+ String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_6);
+ _builder.append(_exitCodeOperationName_1, "");
+ _builder.append("() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _exitCode = this.roomExt.getExitCode(xpac, state_6);
+ _builder.append(_exitCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("//*** Action Codes");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_6 = xpac.getStateMachine();
+ List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_6);
+ 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) {
+ _builder.append("protected void ");
+ String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
+ _builder.append(_actionCodeOperationName, "");
+ _builder.append("(");
+ {
+ if ((tr instanceof NonInitialTransition)) {
+ _builder.append("InterfaceItemBase ifitem");
+ String _argumentList = this.languageGen.getArgumentList(xpac, tr);
+ _builder.append(_argumentList, "");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _actionCode = this.roomExt.getActionCode(xpac, tr);
+ _builder.append(_actionCode, " ");
+ _builder.newLineIfNotEmpty();
+ _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();
+ return _builder;
+ }
+
+ protected StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ 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;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasGuard = this.roomExt.hasGuard(tr);
+ if (_hasGuard) {
+ _builder.append("if (");
+ Guard _guard = tr.getGuard();
+ DetailCode _guard_1 = _guard.getGuard();
+ String _code = ac.getCode(_guard_1);
+ _builder.append(_code, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ protected StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* error */");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
+ if (tt instanceof TriggeredTransition) {
+ return _guard((TriggeredTransition)tt, trigger, ac);
+ } else {
+ return _guard(tt, trigger, ac);
+ }
+ }
+}
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 ed97d4a4c..852a87265 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,633 +1,633 @@
-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.ServiceImplInstance;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-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.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 _operator_or = false;
- if ((pi instanceof ServiceImplInstance)) {
- _operator_or = true;
- } else {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- int _size = _peers.size();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- _operator_or = BooleanExtensions.operator_or((pi instanceof ServiceImplInstance), _operator_greaterThan);
- }
- if (_operator_or) {
- {
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers_1) {
- _builder.append("\t\t");
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- int _indexOf_2 = _peers_2.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_1 = _allContainedInstances_3.size();
- _builder.append(_size_1, " ");
- _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(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- boolean _operator_or_1 = false;
- if ((pi_1 instanceof ServiceImplInstance)) {
- _operator_or_1 = true;
- } else {
- EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
- int _size_2 = _peers_3.size();
- boolean _operator_greaterThan_1 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_2), ((Integer)1));
- _operator_or_1 = BooleanExtensions.operator_or((pi_1 instanceof ServiceImplInstance), _operator_greaterThan_1);
- }
- if (_operator_or_1) {
- {
- EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- boolean hasAnyElements_1 = false;
- for(final InterfaceItemInstance peer_1 : _peers_4) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\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_5 = pi_1.getPeers();
- int _indexOf_5 = _peers_5.indexOf(peer_1);
- _builder.append(_indexOf_5, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("\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");
- _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_1 = _orderedIfItemInstances_3.isEmpty();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
- 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(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- boolean _operator_and = false;
- boolean _operator_not_2 = BooleanExtensions.operator_not((pi_2 instanceof ServiceImplInstance));
- if (!_operator_not_2) {
- _operator_and = false;
- } else {
- EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
- boolean _isEmpty_2 = _peers_6.isEmpty();
- _operator_and = BooleanExtensions.operator_and(_operator_not_2, _isEmpty_2);
- }
- if (_operator_and) {
- _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 _operator_or_2 = false;
- if ((pp instanceof ServiceImplInstance)) {
- _operator_or_2 = true;
- } else {
- EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _size_3 = _peers_8.size();
- boolean _operator_greaterThan_2 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_3), ((Integer)1));
- _operator_or_2 = BooleanExtensions.operator_or((pp instanceof ServiceImplInstance), _operator_greaterThan_2);
- }
- if (_operator_or_2) {
- _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_9 = pp.getPeers();
- int _indexOf_7 = _peers_9.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.ServiceImplInstance;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+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.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 _operator_or = false;
+ if ((pi instanceof ServiceImplInstance)) {
+ _operator_or = true;
+ } else {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ int _size = _peers.size();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
+ _operator_or = BooleanExtensions.operator_or((pi instanceof ServiceImplInstance), _operator_greaterThan);
+ }
+ if (_operator_or) {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers_1) {
+ _builder.append("\t\t");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_2 = _peers_2.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_1 = _allContainedInstances_3.size();
+ _builder.append(_size_1, " ");
+ _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(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ boolean _operator_or_1 = false;
+ if ((pi_1 instanceof ServiceImplInstance)) {
+ _operator_or_1 = true;
+ } else {
+ EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
+ int _size_2 = _peers_3.size();
+ boolean _operator_greaterThan_1 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_2), ((Integer)1));
+ _operator_or_1 = BooleanExtensions.operator_or((pi_1 instanceof ServiceImplInstance), _operator_greaterThan_1);
+ }
+ if (_operator_or_1) {
+ {
+ EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
+ boolean hasAnyElements_1 = false;
+ for(final InterfaceItemInstance peer_1 : _peers_4) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\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_5 = pi_1.getPeers();
+ int _indexOf_5 = _peers_5.indexOf(peer_1);
+ _builder.append(_indexOf_5, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\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");
+ _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_1 = _orderedIfItemInstances_3.isEmpty();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
+ 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(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ boolean _operator_and = false;
+ boolean _operator_not_2 = BooleanExtensions.operator_not((pi_2 instanceof ServiceImplInstance));
+ if (!_operator_not_2) {
+ _operator_and = false;
+ } else {
+ EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
+ boolean _isEmpty_2 = _peers_6.isEmpty();
+ _operator_and = BooleanExtensions.operator_and(_operator_not_2, _isEmpty_2);
+ }
+ if (_operator_and) {
+ _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 _operator_or_2 = false;
+ if ((pp instanceof ServiceImplInstance)) {
+ _operator_or_2 = true;
+ } else {
+ EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
+ int _size_3 = _peers_8.size();
+ boolean _operator_greaterThan_2 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_3), ((Integer)1));
+ _operator_or_2 = BooleanExtensions.operator_or((pp instanceof ServiceImplInstance), _operator_greaterThan_2);
+ }
+ if (_operator_or_2) {
+ _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_9 = pp.getPeers();
+ int _indexOf_7 = _peers_9.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 d7cecf26f..023e9118c 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.extensions.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- this.fileAccess.setOutputPath(_operator_plus);
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "Runner.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.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ this.fileAccess.setOutputPath(_operator_plus);
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "Runner.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;
+ }
+}

Back to the top