Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.java/xtend-gen/org')
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java565
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java481
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java127
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java61
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java834
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java76
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java637
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java152
8 files changed, 0 insertions, 2933 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
deleted file mode 100644
index 9d77ed940..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ /dev/null
@@ -1,565 +0,0 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.etrice.generator.java.gen.StateMachineGen;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ActorClassGen extends GenericActorClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private StateMachineGen stateMachineGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
- for (final ExpandedActorClass xpac : _xpActorClasses) {
- {
- ActorClass _actorClass = xpac.getActorClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this.roomExt.getPath(_actorClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _javaFileName = this.stdExt.getJavaFileName(_actorClass_2);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass implementation \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- StringConcatenation _generate = this.generate(root, xpac, _actorClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _xblockexpression = null;
- {
- EList<StandardOperation> _operations = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return ((Boolean)_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- StandardOperation _head = IterableExtensions.<StandardOperation>head(_filter);
- final StandardOperation ctor = _head;
- EList<StandardOperation> _operations_1 = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return ((Boolean)_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
- final StandardOperation dtor = _head_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(ac);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
- _builder.newLine();
- _builder.newLine();
- {
- EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
- for(final RoomModel model : _referencedModels) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("import ");
- String _package_1 = this.roomExt.getPackage(pc);
- _builder.append(_package_1, "");
- _builder.append(".");
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("public ");
- {
- boolean _isAbstract = ac.isAbstract();
- if (_isAbstract) {
- _builder.append("abstract ");
- }
- }
- _builder.append("class ");
- String _name_2 = ac.getName();
- _builder.append(_name_2, "");
- _builder.append(" extends ");
- {
- ActorClass _base = ac.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- ActorClass _base_1 = ac.getBase();
- String _name_3 = _base_1.getName();
- _builder.append(_name_3, "");
- } else {
- _builder.append("ActorClassBase");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- ports");
- _builder.newLine();
- {
- List<Port> _endPorts = this.roomExt.getEndPorts(ac);
- for(final Port ep : _endPorts) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName = this.roomExt.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_4 = ep.getName();
- _builder.append(_name_4, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- for(final SAPRef sap : _strSAPs) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_1 = this.roomExt.getPortClassName(sap);
- _builder.append(_portClassName_1, " ");
- _builder.append(" ");
- String _name_5 = sap.getName();
- _builder.append(_name_5, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- services");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- for(final ServiceImplementation svc : _serviceImplementations) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_2 = this.roomExt.getPortClassName(svc);
- _builder.append(_portClassName_2, " ");
- _builder.append(" ");
- SPPRef _spp = svc.getSpp();
- String _name_6 = _spp.getName();
- _builder.append(_name_6, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- interface item IDs");
- _builder.newLine();
- _builder.append("\t");
- String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
- _builder.append(_genInterfaceItemConstants, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = ac.getAttributes();
- StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(ac);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- construction");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_7 = ac.getName();
- _builder.append(_name_7, " ");
- _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
- _builder.newLineIfNotEmpty();
- {
- ActorClass _base_2 = ac.getBase();
- boolean _operator_equals = ObjectExtensions.operator_equals(_base_2, null);
- if (_operator_equals) {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr, peer_addr);");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("setClassName(\"");
- String _name_8 = ac.getName();
- _builder.append(_name_8, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_2 = ac.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_2, false);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own ports");
- _builder.newLine();
- {
- List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
- for(final Port ep_1 : _endPorts_1) {
- _builder.append("\t\t");
- String _name_9 = ep_1.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = new ");
- String _portClassName_3 = this.roomExt.getPortClassName(ep_1);
- _builder.append(_portClassName_3, " ");
- _builder.append("(this, \"");
- String _name_10 = ep_1.getName();
- _builder.append(_name_10, " ");
- _builder.append("\", IFITEM_");
- String _name_11 = ep_1.getName();
- _builder.append(_name_11, " ");
- _builder.append(", ");
- {
- int _multiplicity = ep_1.getMultiplicity();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- if (_operator_equals_1) {
- _builder.append("0, ");
- }
- }
- _builder.append("port_addr[IFITEM_");
- String _name_12 = ep_1.getName();
- _builder.append(_name_12, " ");
- _builder.append("]");
- {
- int _multiplicity_1 = ep_1.getMultiplicity();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
- if (_operator_equals_2) {
- _builder.append("[0]");
- }
- }
- _builder.append(", peer_addr[IFITEM_");
- String _name_13 = ep_1.getName();
- _builder.append(_name_13, " ");
- _builder.append("]");
- {
- int _multiplicity_2 = ep_1.getMultiplicity();
- boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_2), ((Integer)1));
- if (_operator_equals_3) {
- _builder.append("[0]");
- }
- }
- _builder.append("); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap_1 : _strSAPs_1) {
- _builder.append("\t\t");
- String _name_14 = sap_1.getName();
- _builder.append(_name_14, " ");
- _builder.append(" = new ");
- String _portClassName_4 = this.roomExt.getPortClassName(sap_1);
- _builder.append(_portClassName_4, " ");
- _builder.append("(this, \"");
- String _name_15 = sap_1.getName();
- _builder.append(_name_15, " ");
- _builder.append("\", IFITEM_");
- String _name_16 = sap_1.getName();
- _builder.append(_name_16, " ");
- _builder.append(", 0, port_addr[IFITEM_");
- String _name_17 = sap_1.getName();
- _builder.append(_name_17, " ");
- _builder.append("][0], peer_addr[IFITEM_");
- String _name_18 = sap_1.getName();
- _builder.append(_name_18, " ");
- _builder.append("][0]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own service implementations");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
- _builder.append("\t\t");
- SPPRef _spp_1 = svc_1.getSpp();
- String _name_19 = _spp_1.getName();
- _builder.append(_name_19, " ");
- _builder.append(" = new ");
- String _portClassName_5 = this.roomExt.getPortClassName(svc_1);
- _builder.append(_portClassName_5, " ");
- _builder.append("(this, \"");
- SPPRef _spp_2 = svc_1.getSpp();
- String _name_20 = _spp_2.getName();
- _builder.append(_name_20, " ");
- _builder.append("\", IFITEM_");
- SPPRef _spp_3 = svc_1.getSpp();
- String _name_21 = _spp_3.getName();
- _builder.append(_name_21, " ");
- _builder.append(", port_addr[IFITEM_");
- SPPRef _spp_4 = svc_1.getSpp();
- String _name_22 = _spp_4.getName();
- _builder.append(_name_22, " ");
- _builder.append("], peer_addr[IFITEM_");
- SPPRef _spp_5 = svc_1.getSpp();
- String _name_23 = _spp_5.getName();
- _builder.append(_name_23, " ");
- _builder.append("]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(ctor, null);
- if (_operator_notEquals_1) {
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- {
- DetailCode _detailCode = ctor.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String l : _commands) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(l, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- lifecycle functions");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void init(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("initUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void start(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("startUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _overridesStop = this.roomExt.overridesStop(ac);
- boolean _operator_not = BooleanExtensions.operator_not(_overridesStop);
- if (_operator_not) {
- _builder.append("\t");
- _builder.append("public void stop(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("stopUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void destroy(){");
- _builder.newLine();
- {
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dtor, null);
- if (_operator_notEquals_2) {
- _builder.append("\t\t");
- _builder.newLine();
- {
- DetailCode _detailCode_1 = dtor.getDetailCode();
- EList<String> _commands_1 = _detailCode_1.getCommands();
- for(final String l_1 : _commands_1) {
- _builder.append("\t\t");
- _builder.append(l_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(ac);
- if (_hasNonEmptyStateMachine) {
- _builder.append("\t");
- StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
- _builder.append(_genStateMachine, " ");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_hasStateMachine);
- if (_operator_not_1) {
- _builder.append("\t");
- _builder.append("//--------------------- no state machine");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("handleSystemEvent(ifitem, evt, data);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void executeInitTransition(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
deleted file mode 100644
index 4c36e415f..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ /dev/null
@@ -1,481 +0,0 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ComplexType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.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.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers typeHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
- String _path = this.roomExt.getPath(dc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _javaFileName = this.stdExt.getJavaFileName(dc);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass implementation \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- StringConcatenation _generate = this.generate(root, dc);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final DataClass dc) {
- StringConcatenation _xblockexpression = null;
- {
- EList<StandardOperation> _operations = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return ((Boolean)_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- StandardOperation _head = IterableExtensions.<StandardOperation>head(_filter);
- final StandardOperation ctor = _head;
- EList<StandardOperation> _operations_1 = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return ((Boolean)_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
- final StandardOperation dtor = _head_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(dc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<RoomModel> _referencedModels = root.getReferencedModels(dc);
- EList<RoomModel> models = _referencedModels;
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = dc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = dc.getName();
- _builder.append(_name_1, "");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- _builder.append(" extends ");
- DataClass _base_1 = dc.getBase();
- String _name_2 = _base_1.getName();
- _builder.append(_name_2, "");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = dc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_2 = dc.getAttributes();
- String _name_3 = dc.getName();
- StringConcatenation _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
- _builder.append(_attributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_4 = dc.getName();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_4);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// default constructor");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_5 = dc.getName();
- _builder.append(_name_5, " ");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_3 = dc.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_3, true);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(ctor, null);
- if (_operator_notEquals_1) {
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- {
- DetailCode _detailCode = ctor.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String l : _commands) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(l, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// constructor using fields");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_6 = dc.getName();
- _builder.append(_name_6, " ");
- _builder.append("(");
- String _argList = this.argList(dc);
- _builder.append(_argList, " ");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- {
- DataClass _base_2 = dc.getBase();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base_2, null);
- if (_operator_notEquals_2) {
- _builder.append("\t\t");
- _builder.append("super(");
- DataClass _base_3 = dc.getBase();
- String _paramList = this.paramList(_base_3);
- _builder.append(_paramList, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("super();");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- {
- EList<Attribute> _attributes_4 = dc.getAttributes();
- for(final Attribute a : _attributes_4) {
- _builder.append("\t\t");
- _builder.append("this.");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append(" = ");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// deep copy");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
- _builder.append(" deepCopy() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _name_10 = dc.getName();
- _builder.append(_name_10, " ");
- _builder.append(" copy = new ");
- String _name_11 = dc.getName();
- _builder.append(_name_11, " ");
- _builder.append("();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _deepCopy = this.deepCopy(dc);
- _builder.append(_deepCopy, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return copy;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String paramList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
- Boolean _xwhileexpression = _operator_notEquals;
- while (_xwhileexpression) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _paramList = this.paramList(_attributes);
- String _string = _paramList.toString();
- String _operator_plus = StringExtensions.operator_plus(_string, result);
- result = _operator_plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
- if (_operator_notEquals_1) {
- String _operator_plus_1 = StringExtensions.operator_plus(", ", result);
- result = _operator_plus_1;
- }
- }
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dc, null);
- _xwhileexpression = _operator_notEquals_2;
- }
- return result;
- }
-
- public StringConcatenation paramList(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean hasAnyElements = false;
- for(final Attribute a : attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- String _name = a.getName();
- _builder.append(_name, "");
- }
- }
- return _builder;
- }
-
- public String argList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
- Boolean _xwhileexpression = _operator_notEquals;
- while (_xwhileexpression) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _argList = this.helpers.argList(_attributes);
- String _string = _argList.toString();
- String _operator_plus = StringExtensions.operator_plus(_string, result);
- result = _operator_plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
- if (_operator_notEquals_1) {
- String _operator_plus_1 = StringExtensions.operator_plus(", ", result);
- result = _operator_plus_1;
- }
- }
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(dc, null);
- _xwhileexpression = _operator_notEquals_2;
- }
- return result;
- }
-
- public String deepCopy(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
- Boolean _xwhileexpression = _operator_notEquals;
- while (_xwhileexpression) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _deepCopy = this.deepCopy(_attributes);
- String _string = _deepCopy.toString();
- String _operator_plus = StringExtensions.operator_plus(_string, result);
- result = _operator_plus;
- DataClass _base = dc.getBase();
- dc = _base;
- }
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(dc, null);
- _xwhileexpression = _operator_notEquals_1;
- }
- return result;
- }
-
- public StringConcatenation deepCopy(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Attribute a : attributes) {
- {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof ComplexType)) {
- _builder.append("if (");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("!=null) {");
- _builder.newLineIfNotEmpty();
- {
- int _size = a.getSize();
- boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
- if (_operator_equals) {
- _builder.append("\t");
- _builder.append("copy.");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = ");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append(".deepCopy();");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("copy.");
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append("[i] = ");
- String _name_5 = a.getName();
- _builder.append(_name_5, " ");
- _builder.append("[i].deepCopy();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- } else {
- {
- int _size_1 = a.getSize();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_size_1), ((Integer)0));
- if (_operator_equals_1) {
- _builder.append("copy.");
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append(" = ");
- String _name_7 = a.getName();
- _builder.append(_name_7, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- String _name_8 = a.getName();
- _builder.append(_name_8, "");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("copy.");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append("[i] = ");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append("[i];");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
deleted file mode 100644
index 9019aa02f..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class JavaExtensions implements ILanguageExtension {
- @Inject
- private AbstractLanguageGenerator 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 boolean hasArgs) {
- return "";
- }
-
- public String selfPointer(final boolean hasArgs) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- return "";
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- return member;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _operator_plus = StringExtensions.operator_plus(namespace, ".");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- public boolean usesInheritance() {
- return true;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Pair<String,String> entry : entries) {
- _builder.append("public static final int ");
- String _first = entry.getFirst();
- _builder.append(_first, "");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- String _string = _builder.toString();
- return _string;
- }
-
- public String booleanConstant(final boolean b) {
- String _string = ((Boolean)b).toString();
- return _string;
- }
-
- public String nullPointer() {
- return "null";
- }
-
- public String voidPointer() {
- return "Object";
- }
-
- public String arrayDeclaration(final String type, final int size, final String name) {
- String _operator_plus = StringExtensions.operator_plus(type, " ");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, name);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "[]");
- return _operator_plus_2;
- }
-
- public String constructorName(final String cls) {
- return cls;
- }
-
- public String destructorName(final String cls) {
- String _operator_plus = StringExtensions.operator_plus(cls, "_dtor");
- return _operator_plus;
- }
-
- public String constructorReturnType() {
- return "";
- }
-
- public String destructorReturnType() {
- return "void";
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
deleted file mode 100644
index c2e9efeed..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
+++ /dev/null
@@ -1,61 +0,0 @@
-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
deleted file mode 100644
index f38ca6669..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ /dev/null
@@ -1,834 +0,0 @@
-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.GenericProtocolClassGenerator;
-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.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _javaFileName = this.stdExt.getJavaFileName(pc);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass implementation \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- StringConcatenation _generate = this.generate(root, pc);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(pc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import java.util.ArrayList;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Message;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<RoomModel> _referencedModels = root.getReferencedModels(pc);
- EList<RoomModel> models = _referencedModels;
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("// message IDs");
- _builder.newLine();
- _builder.append("\t");
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("private static String messageStrings[] = {\"MIN\", ");
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\"");
- String _name_2 = m.getName();
- _builder.append(_name_2, " ");
- _builder.append("\",");
- }
- }
- _builder.append(" ");
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\"");
- String _name_3 = m_1.getName();
- _builder.append(_name_3, " ");
- _builder.append("\",");
- }
- }
- _builder.append("\"MAX\"};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public String getMessageString(int msg_id) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("// id out of range");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("else{");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return messageStrings[msg_id];");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- StringConcatenation _portClass = this.portClass(pc, ((Boolean)false));
- _builder.append(_portClass, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- StringConcatenation _portClass_1 = this.portClass(pc, ((Boolean)true));
- _builder.append(_portClass_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation portClass(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pclass = _portClass;
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
- String replPortClassName = _portClassName_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("// port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(portClassName, "");
- _builder.append(" extends PortBase {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("// constructors");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(portClassName, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(actor, name, localId, 0, addr, peerAddress);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService.getInstance().addPortInstance(this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(portClassName, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(actor, name, localId, idx, addr, peerAddress);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService.getInstance().addPortInstance(this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receive(Message m) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("if (!(m instanceof EventMessage))");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("return;");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("EventMessage msg = (EventMessage) m;");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("System.out.println(\"unknown\");");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
- _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- _builder.append("\t\t\t\t");
- _builder.append("switch (msg.getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- Message _msg = hdlr.getMsg();
- String _codeName = this.roomExt.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("default:");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("if (msg instanceof EventWithDataMessage)");
- _builder.newLine();
- _builder.append("\t\t\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);");
- _builder.newLine();
- {
- boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive_1) {
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// sent messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, conj);
- for(final Message m : _outgoing) {
- _builder.append("\t");
- StringConcatenation _sendMessage = this.sendMessage(m, conj);
- _builder.append(_sendMessage, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// replicated port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(replPortClassName, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private ArrayList<");
- _builder.append(portClassName, " ");
- _builder.append("> ports;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private int replication;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(replPortClassName, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, Address[] addr,");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("Address[] peerAddress) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("replication = addr==null? 0:addr.length;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("ports = new ArrayList<");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append(".");
- _builder.append(portClassName, " ");
- _builder.append(">(replication);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("ports.add(new ");
- _builder.append(portClassName, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t\t");
- _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public int getReplication() {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return replication;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public int getIndexOf(InterfaceItemBase ifitem){");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ifitem.getIdx();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(portClassName, " ");
- _builder.append(" get(int i) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return ports.get(i);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- if (conj) {
- _builder.append("\t");
- _builder.append("// incoming messages");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t");
- StringConcatenation _messageSignature = this.messageSignature(m_1);
- _builder.append(_messageSignature, " ");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("ports.get(i).");
- StringConcatenation _messageCall = this.messageCall(m_1);
- _builder.append(_messageCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m_2 : _allOutgoingMessages) {
- _builder.append("\t");
- StringConcatenation _messageSignature_1 = this.messageSignature(m_2);
- _builder.append(_messageSignature_1, " ");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("ports.get(i).");
- StringConcatenation _messageCall_1 = this.messageCall(m_2);
- _builder.append(_messageCall_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation messageSignature(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isPriv = m.isPriv();
- if (_isPriv) {
- _builder.append("private");
- } else {
- _builder.append("public");
- }
- }
- _builder.append(" void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_1 = _data_2.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public StringConcatenation messageSignatureExplicit(final Message m) {
- StringConcatenation _xblockexpression = null;
- {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- DataClass dc = ((DataClass) _type);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("public void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- DataClass _base_1 = dc.getBase();
- String _typeName = this._typeHelpers.typeName(_base_1);
- _builder.append(_typeName, "");
- _builder.append(" _super, ");
- }
- }
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, "");
- {
- int _size = a.getSize();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- if (_operator_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public StringConcatenation messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public StringConcatenation sendMessage(final Message m, final boolean conj) {
- StringConcatenation _xblockexpression = null;
- {
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "IN";
- } else {
- _xifexpression = "OUT";
- }
- String dir = _xifexpression;
- MessageHandler _sendHandler = this.roomExt.getSendHandler(m, conj);
- MessageHandler hdlr = _sendHandler;
- StringConcatenation _builder = new StringConcatenation();
- StringConcatenation _messageSignature = this.messageSignature(m);
- _builder.append(_messageSignature, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(hdlr, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("if (messageStrings[ ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name = m.getName();
- _builder.append(_name, " ");
- _builder.append("] != \"timerTick\"){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_1 = m.getName();
- _builder.append(_name_1, " ");
- _builder.append("]);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (getPeerAddress()!=null)");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- {
- VarDecl _data = m.getData();
- boolean _operator_equals = ObjectExtensions.operator_equals(_data, null);
- if (_operator_equals) {
- _builder.append("getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_2 = m.getName();
- _builder.append(_name_2, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- } else {
- _builder.append("getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), ");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_3 = m.getName();
- _builder.append(_name_3, " ");
- _builder.append(", ");
- VarDecl _data_1 = m.getData();
- String _name_4 = _data_1.getName();
- _builder.append(_name_4, " ");
- {
- boolean _operator_and = false;
- VarDecl _data_2 = m.getData();
- RefableType _refType = _data_2.getRefType();
- boolean _isRef = _refType.isRef();
- boolean _operator_not = BooleanExtensions.operator_not(_isRef);
- if (!_operator_not) {
- _operator_and = false;
- } else {
- VarDecl _data_3 = m.getData();
- RefableType _refType_1 = _data_3.getRefType();
- DataType _type = _refType_1.getType();
- boolean _operator_not_1 = BooleanExtensions.operator_not((_type instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(_operator_not, _operator_not_1);
- }
- if (_operator_and) {
- _builder.append(".deepCopy()");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("}");
- _builder.newLine();
- {
- boolean _operator_and_1 = false;
- VarDecl _data_4 = m.getData();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_4, null);
- if (!_operator_notEquals_1) {
- _operator_and_1 = false;
- } else {
- VarDecl _data_5 = m.getData();
- RefableType _refType_2 = _data_5.getRefType();
- DataType _type_1 = _refType_2.getType();
- _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_1, (_type_1 instanceof DataClass));
- }
- if (_operator_and_1) {
- StringConcatenation _messageSignatureExplicit = this.messageSignatureExplicit(m);
- _builder.append(_messageSignatureExplicit, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_5 = m.getName();
- _builder.append(_name_5, " ");
- _builder.append("(new ");
- VarDecl _data_6 = m.getData();
- RefableType _refType_3 = _data_6.getRefType();
- DataType _type_2 = _refType_3.getType();
- String _name_6 = _type_2.getName();
- _builder.append(_name_6, " ");
- _builder.append("(");
- {
- VarDecl _data_7 = m.getData();
- RefableType _refType_4 = _data_7.getRefType();
- DataType _type_3 = _refType_4.getType();
- DataClass _base = ((DataClass) _type_3).getBase();
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals_2) {
- _builder.append("_super, ");
- }
- }
- {
- VarDecl _data_8 = m.getData();
- RefableType _refType_5 = _data_8.getRefType();
- DataType _type_4 = _refType_5.getType();
- EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
- boolean hasAnyElements = false;
- for(final Attribute a : _attributes) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(", ", " ");
- }
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
deleted file mode 100644
index 0f9fe70ea..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("// state names");
- _builder.newLine();
- _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
- {
- List<State> _allBaseStatesLeavesLast = this._roomExtensions.getAllBaseStatesLeavesLast(ac);
- boolean hasAnyElements = false;
- for(final State state : _allBaseStatesLeavesLast) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", "");
- }
- _builder.append("\"");
- String _statePathName = this._roomExtensions.getStatePathName(state);
- _builder.append(_statePathName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// history");
- _builder.newLine();
- _builder.append("protected int history[] = {NO_STATE,NO_STATE");
- {
- List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
- for(final State state_1 : _allBaseStates) {
- _builder.append(",NO_STATE");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("private void setState(int new_state) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("this.state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
deleted file mode 100644
index c8b7f4296..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ /dev/null
@@ -1,637 +0,0 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.LogicalThread;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.etricegen.ActorInstance;
-import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.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.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance ssi : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String _javaFileName = this.stdExt.getJavaFileName(_subSystemClass_2);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.newLine();
- EList<RoomModel> _referencedModels = root.getReferencedModels(cc);
- EList<RoomModel> models = _referencedModels;
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = cc.getUserCode1();
- StringConcatenation _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = comp.getName();
- _builder.append(_name_1, "");
- _builder.append(" extends SubSystemClassBase{");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = cc.getUserCode2();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_2 = comp.getName();
- _builder.append(_name_2, " ");
- _builder.append("(IRTObject parent, String name) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(parent, name);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateMessageServices(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
- _builder.newLine();
- {
- EList<LogicalThread> _threads = cc.getThreads();
- for(final LogicalThread thread : _threads) {
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
- EList<LogicalThread> _threads_1 = cc.getThreads();
- int _indexOf = _threads_1.indexOf(thread);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(", 0),\"MessageService_");
- String _name_3 = thread.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", ");
- int _prio = thread.getPrio();
- _builder.append(_prio, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateActors(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// all addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// Addresses for the Subsystem Systemport");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- int _maxObjId = comp.getMaxObjId();
- Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
- for(final Indexed<ActorInstance> ai : _indexed) {
- _builder.append("\t\t");
- _builder.append("Address addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
- ActorInstance _value = ai.getValue();
- int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
- _builder.append(_indexOf_1, " ");
- _builder.append(" = new Address(0,0,");
- int _index1 = ai.getIndex1();
- _builder.append(_index1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
- for(final ActorInstance ai_1 : _allContainedInstances_2) {
- _builder.append("\t\t");
- _builder.append("// actor instance ");
- String _path = ai_1.getPath();
- _builder.append(_path, " ");
- _builder.append(" itself => Systemport Address");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_1 = ai_1.getPath();
- String _pathName = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append(" = new Address(0,");
- int _threadId = ai_1.getThreadId();
- _builder.append(_threadId, " ");
- _builder.append(",");
- int _objId = ai_1.getObjId();
- _builder.append(_objId, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// interface items of ");
- String _path_2 = ai_1.getPath();
- _builder.append(_path_2, " ");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _isReplicated = pi.isReplicated();
- if (_isReplicated) {
- {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers) {
- _builder.append("\t\t");
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int _indexOf_2 = _peers_1.indexOf(peer);
- int i = _indexOf_2;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_3 = pi.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_3);
- _builder.append(_pathName_1, " ");
- _builder.append("_");
- _builder.append(i, " ");
- _builder.append(" = new Address(0,");
- int _threadId_1 = pi.getThreadId();
- _builder.append(_threadId_1, " ");
- _builder.append(",");
- int _objId_1 = pi.getObjId();
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_objId_1), ((Integer)i));
- _builder.append(_operator_plus_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_4 = pi.getPath();
- String _pathName_2 = this.roomExt.getPathName(_path_4);
- _builder.append(_pathName_2, " ");
- _builder.append(" = new Address(0,");
- int _threadId_2 = ai_1.getThreadId();
- _builder.append(_threadId_2, " ");
- _builder.append(",");
- int _objId_2 = pi.getObjId();
- _builder.append(_objId_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// instantiate all actor instances");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("instances = new ActorClassBase[");
- EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
- int _size = _allContainedInstances_3.size();
- _builder.append(_size, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
- for(final ActorInstance ai_2 : _allContainedInstances_4) {
- _builder.append("\t\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
- int _indexOf_3 = _allContainedInstances_5.indexOf(ai_2);
- _builder.append(_indexOf_3, " ");
- _builder.append("] = new ");
- ActorClass _actorClass = ai_2.getActorClass();
- String _name_4 = _actorClass.getName();
- _builder.append(_name_4, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- {
- EObject _eContainer = ai_2.eContainer();
- if ((_eContainer instanceof SubSystemInstance)) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("this,");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
- EObject _eContainer_1 = ai_2.eContainer();
- int _indexOf_4 = _allContainedInstances_6.indexOf(_eContainer_1);
- _builder.append(_indexOf_4, " ");
- _builder.append("],");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\"");
- String _name_5 = ai_2.getName();
- _builder.append(_name_5, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// own interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_");
- String _path_5 = ai_2.getPath();
- String _pathName_3 = this.roomExt.getPathName(_path_5);
- _builder.append(_pathName_3, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
- boolean hasAnyElements = false;
- for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _isReplicated_1 = pi_1.isReplicated();
- if (_isReplicated_1) {
- {
- EList<InterfaceItemInstance> _peers_2 = pi_1.getPeers();
- boolean _isEmpty_1 = _peers_2.isEmpty();
- if (_isEmpty_1) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
- boolean hasAnyElements_1 = false;
- for(final InterfaceItemInstance peer_1 : _peers_3) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_6 = pi_1.getPath();
- String _pathName_4 = this.roomExt.getPathName(_path_6);
- _builder.append(_pathName_4, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- int _indexOf_5 = _peers_4.indexOf(peer_1);
- _builder.append(_indexOf_5, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_7 = pi_1.getPath();
- String _pathName_5 = this.roomExt.getPathName(_path_7);
- _builder.append(_pathName_5, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// peer interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
- int _indexOf_6 = _allContainedInstances_7.indexOf(ai_2);
- _builder.append(_indexOf_6, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_2);
- if (_operator_not_1) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
- boolean hasAnyElements_2 = false;
- for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
- if (!hasAnyElements_2) {
- hasAnyElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _operator_and = false;
- boolean _isReplicated_2 = pi_2.isReplicated();
- if (!_isReplicated_2) {
- _operator_and = false;
- } else {
- EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
- boolean _isEmpty_3 = _peers_5.isEmpty();
- _operator_and = BooleanExtensions.operator_and(_isReplicated_2, _isEmpty_3);
- }
- if (_operator_and) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
- boolean _isEmpty_4 = _peers_6.isEmpty();
- if (_isEmpty_4) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- {
- EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
- boolean hasAnyElements_3 = false;
- for(final InterfaceItemInstance pp : _peers_7) {
- if (!hasAnyElements_3) {
- hasAnyElements_3 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _isReplicated_3 = pp.isReplicated();
- if (_isReplicated_3) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_8 = pp.getPath();
- String _pathName_6 = this.roomExt.getPathName(_path_8);
- _builder.append(_pathName_6, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _indexOf_7 = _peers_8.indexOf(pi_2);
- _builder.append(_indexOf_7, " ");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_9 = pp.getPath();
- String _pathName_7 = this.roomExt.getPathName(_path_9);
- _builder.append(_pathName_7, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("); ");
- _builder.newLine();
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// create the subsystem system port\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("0, //local ID");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// own addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
- boolean hasAnyElements_4 = false;
- for(final ActorInstance ai_3 : _allContainedInstances_8) {
- if (!hasAnyElements_4) {
- hasAnyElements_4 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_9.indexOf(ai_3);
- _builder.append(_indexOf_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// peer addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
- boolean hasAnyElements_5 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_10) {
- if (!hasAnyElements_5) {
- hasAnyElements_5 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_");
- String _path_10 = ai_4.getPath();
- String _pathName_8 = this.roomExt.getPathName(_path_10);
- _builder.append(_pathName_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("});");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
deleted file mode 100644
index 023e9118c..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
+++ /dev/null
@@ -1,152 +0,0 @@
-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