diff options
author | Henrik Rentz-Reichert | 2017-11-10 10:22:25 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2017-11-10 19:57:25 +0000 |
commit | b5b1401f30884bdc6c160f8500e3f29b6566c481 (patch) | |
tree | e4c3f9027ac047ac2e25922801a1bb6eb7d5bbd9 | |
parent | 2e9666c1b52cef7d82be927d14e6dc8b57587a81 (diff) | |
download | org.eclipse.etrice-b5b1401f30884bdc6c160f8500e3f29b6566c481.tar.gz org.eclipse.etrice-b5b1401f30884bdc6c160f8500e3f29b6566c481.tar.xz org.eclipse.etrice-b5b1401f30884bdc6c160f8500e3f29b6566c481.zip |
Bug 511330 - [core.genmodel.fsm] introduce simplified generator model
for state machines
* bug fix in ui.behavior tests
Change-Id: I0ee471ae6b0e7502ba2dbf63f9ec46b33d0610e6
108 files changed, 1000 insertions, 28860 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/.antlr-generator-3.2.0-patch.jar b/plugins/org.eclipse.etrice.core.common/.antlr-generator-3.2.0-patch.jar Binary files differdeleted file mode 100644 index 90516fd7a..000000000 --- a/plugins/org.eclipse.etrice.core.common/.antlr-generator-3.2.0-patch.jar +++ /dev/null diff --git a/plugins/org.eclipse.etrice.core.common/src-gen/org/eclipse/etrice/core/common/validation/AbstractBaseTestJavaValidator.java b/plugins/org.eclipse.etrice.core.common/src-gen/org/eclipse/etrice/core/common/validation/AbstractBaseTestJavaValidator.java new file mode 100644 index 000000000..22e4381f0 --- /dev/null +++ b/plugins/org.eclipse.etrice.core.common/src-gen/org/eclipse/etrice/core/common/validation/AbstractBaseTestJavaValidator.java @@ -0,0 +1,20 @@ +/* + * generated by Xtext + */ +package org.eclipse.etrice.core.common.validation; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EPackage; + +public class AbstractBaseTestJavaValidator extends org.eclipse.etrice.core.common.validation.BaseJavaValidator { + + @Override + protected List<EPackage> getEPackages() { + List<EPackage> result = new ArrayList<EPackage>(); + result.add(org.eclipse.etrice.core.common.basetest.BasetestPackage.eINSTANCE); + return result; + } + +} diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseTestJavaValidator.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseTestJavaValidator.java new file mode 100644 index 000000000..d6cf6b653 --- /dev/null +++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseTestJavaValidator.java @@ -0,0 +1,19 @@ +/* + * generated by Xtext + */ +package org.eclipse.etrice.core.common.validation; + +/** + * This class contains custom validation rules. + * + * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation + */ +public class BaseTestJavaValidator extends BaseJavaValidator { + +// @Check +// public void checkGreetingStartsWithCapital(Greeting greeting) { +// if (!Character.isUpperCase(greeting.getName().charAt(0))) { +// warning("Name should start with a capital", MyDslPackage.Literals.GREETING__NAME); +// } +// } +} diff --git a/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java b/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java deleted file mode 100644 index 7510e4031..000000000 --- a/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2014 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * hrentz (initial contribution) - */ -package org.eclipse.etrice.core.common.validation; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.xtend.lib.Property; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.Pure; - -/** - * @author hrentz - */ -@SuppressWarnings("all") -public class ValidationHelpers { - public static class NamedObject { - @Property - private String _name; - - @Property - private EObject _obj; - - @Property - private EStructuralFeature _feature; - - public NamedObject(final String name, final EObject obj, final EStructuralFeature feature) { - this.setName(name); - this.setObj(obj); - this.setFeature(feature); - } - - @Pure - public String getName() { - return this._name; - } - - public void setName(final String name) { - this._name = name; - } - - @Pure - public EObject getObj() { - return this._obj; - } - - public void setObj(final EObject obj) { - this._obj = obj; - } - - @Pure - public EStructuralFeature getFeature() { - return this._feature; - } - - public void setFeature(final EStructuralFeature feature) { - this._feature = feature; - } - } - - public static class NamedObjectList extends ArrayList<ValidationHelpers.NamedObject> { - public void addAll(final List<? extends EObject> items, final EStructuralFeature feature) { - final Consumer<EObject> _function = (EObject it) -> { - Object _eGet = it.eGet(feature); - ValidationHelpers.NamedObject _namedObject = new ValidationHelpers.NamedObject(((String) _eGet), it, feature); - this.add(_namedObject); - }; - items.forEach(_function); - } - } - - public static Iterable<ValidationHelpers.NamedObject> removeUniques(final List<ValidationHelpers.NamedObject> items) { - Iterable<ValidationHelpers.NamedObject> _xblockexpression = null; - { - final Set<String> allOfName = CollectionLiterals.<String>newHashSet(); - final Set<String> duplicateNames = CollectionLiterals.<String>newHashSet(); - for (final ValidationHelpers.NamedObject i : items) { - String _name = i.getName(); - boolean _contains = allOfName.contains(_name); - if (_contains) { - String _name_1 = i.getName(); - duplicateNames.add(_name_1); - } else { - String _name_2 = i.getName(); - allOfName.add(_name_2); - } - } - final Function1<ValidationHelpers.NamedObject, Boolean> _function = (ValidationHelpers.NamedObject i_1) -> { - String _name_3 = i_1.getName(); - return Boolean.valueOf(duplicateNames.contains(_name_3)); - }; - _xblockexpression = IterableExtensions.<ValidationHelpers.NamedObject>filter(items, _function); - } - return _xblockexpression; - } - - public static Iterable<ValidationHelpers.NamedObject> inSameResource(final Iterable<ValidationHelpers.NamedObject> items, final Resource resource) { - final Function1<ValidationHelpers.NamedObject, Boolean> _function = (ValidationHelpers.NamedObject i) -> { - EObject _obj = i.getObj(); - Resource _eResource = _obj.eResource(); - return Boolean.valueOf(Objects.equal(_eResource, resource)); - }; - return IterableExtensions.<ValidationHelpers.NamedObject>filter(items, _function); - } - - /** - * Visitor for inheritance, safeguards from null, eProxy and circular issues. - * - * @param start EObject, may be null - * @param function return null to exit - */ - public static <E extends EObject> void saveRecursiveVisitor(final E start, final Function<E, E> function) { - final Set<E> visited = CollectionLiterals.<E>newHashSet(); - E next = start; - while ((((!Objects.equal(next, null)) && (!next.eIsProxy())) && visited.add(next))) { - E _apply = function.apply(next); - next = _apply; - } - } -} diff --git a/plugins/org.eclipse.etrice.core.etphys/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.etphys).launch b/plugins/org.eclipse.etrice.core.etphys/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.etphys).launch index c74036855..994bfa4b9 100644 --- a/plugins/org.eclipse.etrice.core.etphys/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.etphys).launch +++ b/plugins/org.eclipse.etrice.core.etphys/.launch/Generate Language Infrastructure (org.eclipse.etrice.core.etphys).launch @@ -11,15 +11,12 @@ <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> <listEntry value="org.eclipse.debug.ui.launchGroup.run"/> </listAttribute> -<<<<<<< HEAD -======= <listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5" javaProject="org.eclipse.etrice.core.etphys" path="1" type="4"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="org.eclipse.etrice.core.etphys"/> </runtimeClasspathEntry> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/org.eclipse.etrice.core.room/.antlr-generator-3.2.0.jar" path="3" type="2"/> "/> </listAttribute> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> ->>>>>>> refs/remotes/origin/CGenPhysical <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/org/eclipse/etrice/core/etphys/GenerateETPhys.mwe2"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.etrice.core.etphys"/> diff --git a/plugins/org.eclipse.etrice.core.fsm/.antlr-generator-3.2.0-patch.jar b/plugins/org.eclipse.etrice.core.fsm/.antlr-generator-3.2.0-patch.jar Binary files differdeleted file mode 100644 index 90516fd7a..000000000 --- a/plugins/org.eclipse.etrice.core.fsm/.antlr-generator-3.2.0-patch.jar +++ /dev/null diff --git a/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java b/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java deleted file mode 100644 index c2e739c5d..000000000 --- a/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2014 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert - */ -package org.eclipse.etrice.core.fsm.postprocessing; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.etrice.core.common.postprocessing.PostprocessingHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.GeneratedMetamodel; - -@SuppressWarnings("all") -public class ImplPostprocessor { - public boolean process(final GeneratedMetamodel metamodel) { - boolean _xblockexpression = false; - { - final EPackage fsmPackage = metamodel.getEPackage(); - final EClass state = PostprocessingHelpers.getClass(fsmPackage, "State"); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("return (this instanceof <%org.eclipse.etrice.core.fsm.fSM.SimpleState%>)? ((SimpleState)this).getName() :(this instanceof <%org.eclipse.etrice.core.fsm.fSM.RefinedState%>)? (((RefinedState)this).getTarget()==null? \"\":((RefinedState)this).getTarget().getName()) :\"\";"); - PostprocessingHelpers.addOperation(state, "getName", EcorePackage.Literals.ESTRING, Integer.valueOf(1), _builder.toString()); - final EClass stateGraphItem = PostprocessingHelpers.getClass(fsmPackage, "StateGraphItem"); - EClassifier _eClassifier = EcorePackage.eINSTANCE.getEClassifier("EString"); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if (this instanceof <%org.eclipse.etrice.core.fsm.fSM.State%>) "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("return ((State)this).getName();"); - _builder_1.newLine(); - _builder_1.append("else if (this instanceof <%org.eclipse.etrice.core.fsm.fSM.TrPoint%>)"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("return ((TrPoint)this).getName();"); - _builder_1.newLine(); - _builder_1.append("else if (this instanceof <%org.eclipse.etrice.core.fsm.fSM.ChoicePoint%>)"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("return ((ChoicePoint)this).getName();"); - _builder_1.newLine(); - _builder_1.append("else if (this instanceof <%org.eclipse.etrice.core.fsm.fSM.Transition%>)"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("return ((Transition)this).getName();"); - _builder_1.newLine(); - _builder_1.append("else if (this instanceof <%org.eclipse.etrice.core.fsm.fSM.RefinedTransition%>)"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("return ((RefinedTransition)this).getTarget().getName();"); - _builder_1.newLine(); - _builder_1.append("return \"\";"); - _builder_1.newLine(); - PostprocessingHelpers.addOperation(stateGraphItem, "getName", _eClassifier, Integer.valueOf(1), _builder_1.toString()); - final EClass ifItem = PostprocessingHelpers.getClass(fsmPackage, "AbstractInterfaceItem"); - EClassifier _eClassifier_1 = EcorePackage.eINSTANCE.getEClassifier("EString"); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("return getName();"); - _builder_2.newLine(); - PostprocessingHelpers.addOperation(ifItem, "getDisplayName", _eClassifier_1, Integer.valueOf(1), _builder_2.toString()); - PostprocessingHelpers.addOperation(ifItem, "getSemantics", fsmPackage.getEClassifier("ProtocolSemantics")); - PostprocessingHelpers.addOperation(ifItem, "getAllIncomingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), null); - PostprocessingHelpers.addOperation(ifItem, "getAllOutgoingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), null); - PostprocessingHelpers.addOperation(ifItem, "isEventDriven", EcorePackage.Literals.EBOOLEAN, Integer.valueOf(1), "return true;"); - final EClass itemOwner = PostprocessingHelpers.addClass(fsmPackage, "IInterfaceItemOwner"); - itemOwner.setAbstract(true); - itemOwner.setInterface(true); - PostprocessingHelpers.addOperation(itemOwner, "getAbstractInterfaceItems", fsmPackage.getEClassifier("AbstractInterfaceItem"), Integer.valueOf((-1)), null); - PostprocessingHelpers.addOperation(itemOwner, "getAllAbstractInterfaceItems", fsmPackage.getEClassifier("AbstractInterfaceItem"), Integer.valueOf((-1)), null); - final EClass comp = PostprocessingHelpers.getClass(fsmPackage, "ModelComponent"); - _xblockexpression = comp.getESuperTypes().add(itemOwner); - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.core.genmodel.fsm/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/build.gradle b/plugins/org.eclipse.etrice.core.genmodel.fsm/build.gradle index 47043d9b8..de215b325 100644 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/build.gradle +++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/build.gradle @@ -11,7 +11,7 @@ dependencies { sourceSets { main { java { - srcDirs = ['src'] + srcDirs = ['src', 'src-gen', 'xtend-gen'] } } }
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/build.properties b/plugins/org.eclipse.etrice.core.genmodel.fsm/build.properties index 9e7a79cd1..45705e5a9 100644 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/build.properties +++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/build.properties @@ -1,5 +1,3 @@ -# - bin.includes = .,\ model/,\ META-INF/,\ diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.xtend b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.xtend index ba6fd869a..66f5adfff 100644 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.xtend +++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.xtend @@ -34,23 +34,23 @@ class FsmGenChecker { } private static def void checkLink(Link it, ILogger logger) { - if (transition==null) { + if (transition===null) { logger.logError("graph doesn't point to ROOM transition") } else if (transition.eIsProxy) { logger.logError("unresolved ROOM transition") } - else if (transition.eContainer==null) { + else if (transition.eContainer===null) { logger.logError("dangling ROOM transition") } - else if (target==null) { + else if (target===null) { logger.logError("link without target") } - else if (source==null && transition instanceof NonInitialTransition) { + else if (source===null && transition instanceof NonInitialTransition) { logger.logError("non-initial link without source") } - if (source!=null) { + if (source!==null) { checkLinkEnd(it, it.source, logger) } checkLinkEnd(it, it.target, logger) @@ -77,19 +77,19 @@ class FsmGenChecker { } private static def void checkNode(Node it, ILogger logger) { - if (stateGraphNode==null) { + if (stateGraphNode===null) { logger.logError("graph doesn't point to ROOM state graph node") } else if (stateGraphNode.eIsProxy) { logger.logError("unresolved ROOM graph node") } - else if (stateGraphNode.eContainer==null) { + else if (stateGraphNode.eContainer===null) { logger.logError("dangling ROOM graph node") } - else if (stateGraphNode.getName()==null) { + else if (stateGraphNode.getName()===null) { logger.logError("ROOM graph node without name") } - else if (graph==null) { + else if (graph===null) { logger.logError("node isn't contained in a graph") } @@ -109,13 +109,13 @@ class FsmGenChecker { } private static def void checkGraph(Graph it, ILogger logger) { - if (stateGraph==null) { + if (stateGraph===null) { logger.logError("graph doesn't point to ROOM state graph") } else if (stateGraph.eIsProxy) { logger.logError("unresolved ROOM graph") } - else if (stateGraph.eContainer==null) { + else if (stateGraph.eContainer===null) { logger.logError("dangling ROOM graph") } } diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.java deleted file mode 100644 index f277d3950..000000000 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.java +++ /dev/null @@ -1,323 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm; - -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Injector; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.function.Consumer; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.ChoicePoint; -import org.eclipse.etrice.core.fsm.fSM.ChoicepointTerminal; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition; -import org.eclipse.etrice.core.fsm.fSM.RefinedState; -import org.eclipse.etrice.core.fsm.fSM.RefinedTransition; -import org.eclipse.etrice.core.fsm.fSM.SimpleState; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraph; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.StateTerminal; -import org.eclipse.etrice.core.fsm.fSM.SubStateTrPointTerminal; -import org.eclipse.etrice.core.fsm.fSM.TrPoint; -import org.eclipse.etrice.core.fsm.fSM.TrPointTerminal; -import org.eclipse.etrice.core.fsm.fSM.Transition; -import org.eclipse.etrice.core.fsm.util.FSMHelpers; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.FsmGenFactory; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@SuppressWarnings("all") -public class BasicFsmGenBuilder { - @Inject - @Extension - protected FSMHelpers fsmHelpers; - - protected final FsmGenFactory factory = FsmGenFactory.eINSTANCE; - - private int inheritanceLevel = 0; - - public BasicFsmGenBuilder(final Injector injector) { - injector.injectMembers(this); - } - - protected BasicFsmGenBuilder() { - } - - public GraphContainer createTransformedModel(final ModelComponent mc) { - return this.createContainer(mc); - } - - private GraphContainer createContainer(final ModelComponent mc) { - final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(mc); - final GraphContainer _result; - synchronized (_createCache_createContainer) { - if (_createCache_createContainer.containsKey(_cacheKey)) { - return _createCache_createContainer.get(_cacheKey); - } - GraphContainer _createGraphContainer = this.factory.createGraphContainer(); - _result = _createGraphContainer; - _createCache_createContainer.put(_cacheKey, _result); - } - _init_createContainer(_result, mc); - return _result; - } - - private final HashMap<ArrayList<?>, GraphContainer> _createCache_createContainer = CollectionLiterals.newHashMap(); - - private void _init_createContainer(final GraphContainer it, final ModelComponent mc) { - it.setComponent(mc); - it.setGraph(this.createStateMachine(mc)); - } - - private Graph createStateMachine(final ModelComponent mc) { - Graph _xblockexpression = null; - { - final StateGraph superFSM = this.fsmHelpers.getSuperStateMachine(mc); - Graph _xifexpression = null; - if ((superFSM != null)) { - Graph _xblockexpression_1 = null; - { - final Graph baseGraph = this.createStateMachine(this.fsmHelpers.getModelComponent(superFSM)); - this.inheritanceLevel++; - _xblockexpression_1 = this.mergeGraph(baseGraph, this.fsmHelpers.getActualStateMachine(mc)); - } - _xifexpression = _xblockexpression_1; - } else { - Graph _xifexpression_1 = null; - StateGraph _actualStateMachine = this.fsmHelpers.getActualStateMachine(mc); - boolean _tripleNotEquals = (_actualStateMachine != null); - if (_tripleNotEquals) { - StateGraph _actualStateMachine_1 = this.fsmHelpers.getActualStateMachine(mc); - Graph _createGraph = null; - if (_actualStateMachine_1!=null) { - _createGraph=this.createGraph(_actualStateMachine_1); - } - _xifexpression_1 = _createGraph; - } - _xifexpression = _xifexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - private Graph mergeGraph(final Graph graph, final StateGraph sg) { - final Consumer<Node> _function = new Consumer<Node>() { - @Override - public void accept(final Node it) { - it.setInherited(true); - } - }; - graph.getNodes().forEach(_function); - final Consumer<Link> _function_1 = new Consumer<Link>() { - @Override - public void accept(final Link it) { - it.setInherited(true); - } - }; - graph.getLinks().forEach(_function_1); - this.createContents(graph, sg); - graph.setStateGraph(sg); - return graph; - } - - private Graph createGraph(final StateGraph sg) { - final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(sg); - final Graph _result; - synchronized (_createCache_createGraph) { - if (_createCache_createGraph.containsKey(_cacheKey)) { - return _createCache_createGraph.get(_cacheKey); - } - Graph _createGraph = this.factory.createGraph(); - _result = _createGraph; - _createCache_createGraph.put(_cacheKey, _result); - } - _init_createGraph(_result, sg); - return _result; - } - - private final HashMap<ArrayList<?>, Graph> _createCache_createGraph = CollectionLiterals.newHashMap(); - - private void _init_createGraph(final Graph it, final StateGraph sg) { - it.setStateGraph(sg); - this.createContents(it, sg); - } - - private void createContents(final Graph graph, final StateGraph sg) { - final Function1<ChoicePoint, Node> _function = new Function1<ChoicePoint, Node>() { - @Override - public Node apply(final ChoicePoint it) { - return BasicFsmGenBuilder.this.createNode(it); - } - }; - graph.getNodes().addAll(ListExtensions.<ChoicePoint, Node>map(sg.getChPoints(), _function)); - final Function1<TrPoint, Node> _function_1 = new Function1<TrPoint, Node>() { - @Override - public Node apply(final TrPoint it) { - return BasicFsmGenBuilder.this.createNode(it); - } - }; - graph.getNodes().addAll(ListExtensions.<TrPoint, Node>map(sg.getTrPoints(), _function_1)); - final Function1<SimpleState, Node> _function_2 = new Function1<SimpleState, Node>() { - @Override - public Node apply(final SimpleState it) { - return BasicFsmGenBuilder.this.createNode(it); - } - }; - Iterables.<Node>addAll(graph.getNodes(), IterableExtensions.<SimpleState, Node>map(Iterables.<SimpleState>filter(sg.getStates(), SimpleState.class), _function_2)); - final Function1<Transition, Link> _function_3 = new Function1<Transition, Link>() { - @Override - public Link apply(final Transition it) { - return BasicFsmGenBuilder.this.createLink(it); - } - }; - graph.getLinks().addAll(ListExtensions.<Transition, Link>map(sg.getTransitions(), _function_3)); - final Consumer<RefinedState> _function_4 = new Consumer<RefinedState>() { - @Override - public void accept(final RefinedState it) { - BasicFsmGenBuilder.this.handleRefinedState(it); - } - }; - Iterables.<RefinedState>filter(sg.getStates(), RefinedState.class).forEach(_function_4); - final Consumer<RefinedTransition> _function_5 = new Consumer<RefinedTransition>() { - @Override - public void accept(final RefinedTransition it) { - BasicFsmGenBuilder.this.handleRefinedTransition(it); - } - }; - sg.getRefinedTransitions().forEach(_function_5); - } - - private void handleRefinedState(final RefinedState s) { - final Node refinedNode = this.createNode(this.fsmHelpers.getFinalTarget(s)); - StateGraph _subgraph = s.getSubgraph(); - boolean _tripleNotEquals = (_subgraph != null); - if (_tripleNotEquals) { - Graph _subgraph_1 = refinedNode.getSubgraph(); - boolean _tripleNotEquals_1 = (_subgraph_1 != null); - if (_tripleNotEquals_1) { - this.mergeGraph(refinedNode.getSubgraph(), s.getSubgraph()); - } else { - refinedNode.setSubgraph(this.createGraph(s.getSubgraph())); - } - } - final Node target = refinedNode; - target.setStateGraphNode(s); - } - - private void handleRefinedTransition(final RefinedTransition t) { - Link _createLink = this.createLink(t.getTarget()); - _createLink.setTransition(t); - } - - private Link createLink(final Transition tr) { - final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(tr); - final Link _result; - synchronized (_createCache_createLink) { - if (_createCache_createLink.containsKey(_cacheKey)) { - return _createCache_createLink.get(_cacheKey); - } - Link _createLink = this.factory.createLink(); - _result = _createLink; - _createCache_createLink.put(_cacheKey, _result); - } - _init_createLink(_result, tr); - return _result; - } - - private final HashMap<ArrayList<?>, Link> _createCache_createLink = CollectionLiterals.newHashMap(); - - private void _init_createLink(final Link it, final Transition tr) { - it.setTransition(tr); - Node _xifexpression = null; - if ((tr instanceof NonInitialTransition)) { - _xifexpression = this.createNode(((NonInitialTransition)tr).getFrom()); - } - it.setSource(_xifexpression); - it.setTarget(this.createNode(tr.getTo())); - } - - private Node _createNode(final StateGraphNode s) { - final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(s); - final Node _result; - synchronized (_createCache_createNode) { - if (_createCache_createNode.containsKey(_cacheKey)) { - return _createCache_createNode.get(_cacheKey); - } - Node _createNode = this.factory.createNode(); - _result = _createNode; - _createCache_createNode.put(_cacheKey, _result); - } - _init_createNode(_result, s); - return _result; - } - - private final HashMap<ArrayList<?>, Node> _createCache_createNode = CollectionLiterals.newHashMap(); - - private void _init_createNode(final Node it, final StateGraphNode s) { - it.setStateGraphNode(s); - it.setInheritanceLevel(this.inheritanceLevel); - Graph _xifexpression = null; - if ((s instanceof State)) { - StateGraph _subgraph = ((State)s).getSubgraph(); - Graph _createGraph = null; - if (_subgraph!=null) { - _createGraph=this.createGraph(_subgraph); - } - _xifexpression = _createGraph; - } - it.setSubgraph(_xifexpression); - } - - private Node _createNode(final ChoicepointTerminal tt) { - return this.createNode(tt.getCp()); - } - - private Node _createNode(final TrPointTerminal tt) { - return this.createNode(tt.getTrPoint()); - } - - private Node _createNode(final StateTerminal tt) { - return this.createNode(tt.getState()); - } - - private Node _createNode(final SubStateTrPointTerminal tt) { - return this.createNode(tt.getTrPoint()); - } - - private Node createNode(final EObject tt) { - if (tt instanceof ChoicepointTerminal) { - return _createNode((ChoicepointTerminal)tt); - } else if (tt instanceof StateGraphNode) { - return _createNode((StateGraphNode)tt); - } else if (tt instanceof StateTerminal) { - return _createNode((StateTerminal)tt); - } else if (tt instanceof SubStateTrPointTerminal) { - return _createNode((SubStateTrPointTerminal)tt); - } else if (tt instanceof TrPointTerminal) { - return _createNode((TrPointTerminal)tt); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " + - Arrays.<Object>asList(tt).toString()); - } - } -} diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.java deleted file mode 100644 index a1b424ebd..000000000 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.java +++ /dev/null @@ -1,291 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * hrr@protos.de (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm; - -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Injector; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.etrice.core.fsm.fSM.FSMPackage; -import org.eclipse.etrice.core.fsm.fSM.MessageFromIf; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.fsm.fSM.TransitionPoint; -import org.eclipse.etrice.core.fsm.fSM.Trigger; -import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition; -import org.eclipse.etrice.core.genmodel.fsm.BasicFsmGenBuilder; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.ICommonDataCalculator; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -import org.eclipse.etrice.core.genmodel.fsm.TriggerExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.CommonTrigger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.FsmGenFactory; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; - -@SuppressWarnings("all") -public class ExtendedFsmGenBuilder extends BasicFsmGenBuilder { - @Inject - @Extension - protected ICommonDataCalculator _iCommonDataCalculator; - - @Inject - @Extension - protected TriggerExtensions _triggerExtensions; - - protected IDiagnostician validator; - - private final FsmGenFactory factory = FsmGenFactory.eINSTANCE; - - public ExtendedFsmGenBuilder(final Injector injector, final IDiagnostician validator) { - super(); - injector.injectMembers(this); - this.validator = validator; - } - - /** - * computes the available triggers for all leaf states - */ - public GraphContainer withTriggersInStates(final GraphContainer gc) { - boolean _isInitializedTriggersInStates = gc.isInitializedTriggersInStates(); - boolean _not = (!_isInitializedTriggersInStates); - if (_not) { - Graph _graph = gc.getGraph(); - boolean _tripleNotEquals = (_graph != null); - if (_tripleNotEquals) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - Graph _subgraph = it.getSubgraph(); - return Boolean.valueOf((_subgraph == null)); - } - }; - final Procedure1<Node> _function_1 = new Procedure1<Node>() { - @Override - public void apply(final Node it) { - ExtendedFsmGenBuilder.this.computeTriggers(it); - } - }; - IteratorExtensions.<Node>forEach(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(gc.getGraph()), _function), _function_1); - } - gc.setInitializedTriggersInStates(true); - } - return gc; - } - - /** - * determines all transition chain heads of all transitions - */ - public GraphContainer withChainHeads(final GraphContainer gc) { - boolean _isInitializedChainHeads = gc.isInitializedChainHeads(); - boolean _not = (!_isInitializedChainHeads); - if (_not) { - Graph _graph = gc.getGraph(); - boolean _tripleNotEquals = (_graph != null); - if (_tripleNotEquals) { - final Procedure1<Link> _function = new Procedure1<Link>() { - @Override - public void apply(final Link it) { - ExtendedFsmGenBuilder.this.followChain(it, it); - } - }; - IteratorExtensions.<Link>forEach(FsmGenExtensions.getAllChainHeads(gc.getGraph()), _function); - } - gc.setInitializedChainHeads(true); - } - return gc; - } - - /** - * calculates and stores the common data. Prerequisite is the computation of the - * chain heads, which is performed if not done already. - */ - public GraphContainer withCommonData(final GraphContainer gc) { - boolean _isInitializedChainHeads = gc.isInitializedChainHeads(); - boolean _not = (!_isInitializedChainHeads); - if (_not) { - this.withChainHeads(gc); - } - boolean _isInitializedCommonData = gc.isInitializedCommonData(); - boolean _not_1 = (!_isInitializedCommonData); - if (_not_1) { - Graph _graph = gc.getGraph(); - boolean _tripleNotEquals = (_graph != null); - if (_tripleNotEquals) { - final Procedure1<Link> _function = new Procedure1<Link>() { - @Override - public void apply(final Link it) { - it.setCommonData(ExtendedFsmGenBuilder.this._iCommonDataCalculator.calculateCommonData(it)); - } - }; - IteratorExtensions.<Link>forEach(FsmGenExtensions.getAllLinks(gc.getGraph()), _function); - } - gc.setInitializedCommonData(true); - } - return gc; - } - - private void followChain(final Link l, final Link head) { - TransitionBase _transition = head.getTransition(); - boolean _not = (!(_transition instanceof TriggeredTransition)); - if (_not) { - l.setIfitemTriggered(false); - } - l.getChainHeads().add(head); - final StateGraphNode target = l.getTarget().getStateGraphNode(); - if (((target instanceof State) || (target instanceof TransitionPoint))) { - return; - } else { - EList<Link> _outgoing = l.getTarget().getOutgoing(); - for (final Link next : _outgoing) { - this.followChain(next, head); - } - } - } - - private void computeTriggers(final Node s) { - final LinkedHashMap<String, CommonTrigger> caughtTriggers = CollectionLiterals.<String, CommonTrigger>newLinkedHashMap(); - this.computeTriggersRecursive(s, caughtTriggers); - s.getCaughtTriggers().clear(); - s.getCaughtTriggers().addAll(caughtTriggers.values()); - } - - private void computeTriggersRecursive(final Node s, final HashMap<String, CommonTrigger> caughtTriggers) { - this.computeTriggers(IterableExtensions.<Link>toList(FsmGenExtensions.getOutgoingTriggeredTransitionLinks(s)), caughtTriggers); - final Function1<Node, Iterable<Link>> _function = new Function1<Node, Iterable<Link>>() { - @Override - public Iterable<Link> apply(final Node it) { - return FsmGenExtensions.getOutgoingTriggeredTransitionLinks(it); - } - }; - final List<Link> trPointTransitions = IterableExtensions.<Link>toList(Iterables.<Link>concat(IterableExtensions.<Node, Iterable<Link>>map(FsmGenExtensions.getTransitionPointNodes(s.getGraph()), _function))); - this.computeTriggers(trPointTransitions, caughtTriggers); - boolean _isTopLevel = FsmGenExtensions.isTopLevel(s.getGraph()); - boolean _not = (!_isTopLevel); - if (_not) { - this.computeTriggersRecursive(FsmGenExtensions.getParentState(s), caughtTriggers); - } - } - - private void computeTriggers(final List<Link> sameLevelLinks, final HashMap<String, CommonTrigger> caughtTriggers) { - final HashMap<TransitionBase, Link> trans2link = CollectionLiterals.<TransitionBase, Link>newHashMap(); - final Consumer<Link> _function = new Consumer<Link>() { - @Override - public void accept(final Link it) { - trans2link.put(it.getTransition(), it); - } - }; - sameLevelLinks.forEach(_function); - for (final Link l : sameLevelLinks) { - TransitionBase _transition = l.getTransition(); - EList<Trigger> _triggers = ((TriggeredTransition) _transition).getTriggers(); - for (final Trigger tr : _triggers) { - { - final boolean triggerHasGuard = this.fsmHelpers.hasGuard(tr); - EList<MessageFromIf> _msgFromIfPairs = tr.getMsgFromIfPairs(); - for (final MessageFromIf mif : _msgFromIfPairs) { - { - final String tag = this._triggerExtensions.getTriggerTag(mif); - CommonTrigger ct = caughtTriggers.get(tag); - if ((ct == null)) { - ct = this.createCommonTrigger(l, mif, tag); - ct.setHasGuard(triggerHasGuard); - caughtTriggers.put(tag, ct); - } else { - final Function1<Link, EList<Trigger>> _function_1 = new Function1<Link, EList<Trigger>>() { - @Override - public EList<Trigger> apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return ((TriggeredTransition) _transition).getTriggers(); - } - }; - final Function1<Trigger, Boolean> _function_2 = new Function1<Trigger, Boolean>() { - @Override - public Boolean apply(final Trigger it) { - return Boolean.valueOf((ExtendedFsmGenBuilder.this.hasMatchingTrigger(it, tag) && (!ExtendedFsmGenBuilder.this.fsmHelpers.hasGuard(it)))); - } - }; - Trigger _head = IterableExtensions.<Trigger>head(IterableExtensions.<Trigger>filter(Iterables.<Trigger>concat(ListExtensions.<Link, EList<Trigger>>map(ct.getLinks(), _function_1)), _function_2)); - EObject _eContainer = null; - if (_head!=null) { - _eContainer=_head.eContainer(); - } - final TriggeredTransition unguarded = ((TriggeredTransition) _eContainer); - if ((unguarded != null)) { - final Link unguardedLink = trans2link.get(unguarded); - boolean _contains = sameLevelLinks.contains(unguardedLink); - if (_contains) { - if (triggerHasGuard) { - final int idx = ct.getLinks().indexOf(unguardedLink); - ct.setHasGuard(triggerHasGuard); - ct.getLinks().add(idx, l); - } else { - this.validationError("Transitions with same trigger on same level have to be guarded!", l.getTransition(), FSMPackage.eINSTANCE.getTriggeredTransition_Triggers()); - } - } - } else { - ct.getLinks().add(l); - } - } - } - } - } - } - } - } - - private boolean hasMatchingTrigger(final Trigger trig, final String tag) { - EList<MessageFromIf> _msgFromIfPairs = trig.getMsgFromIfPairs(); - for (final MessageFromIf mifp2 : _msgFromIfPairs) { - { - final String tr2 = this._triggerExtensions.getTriggerTag(mifp2); - boolean _equals = tr2.equals(tag); - if (_equals) { - return true; - } - } - } - return false; - } - - private CommonTrigger createCommonTrigger(final Link l, final MessageFromIf mif, final String tag) { - final CommonTrigger it = this.factory.createCommonTrigger(); - it.setTrigger(tag); - it.setIfitem(mif.getFrom()); - it.setMsg(mif.getMessage()); - it.getLinks().add(l); - return it; - } - - protected void validationError(final String msg, final EObject obj, final EStructuralFeature feature) { - this.validationError(msg, obj, feature, IDiagnostician.INSIGNIFICANT_INDEX); - } - - protected void validationError(final String msg, final EObject obj, final EStructuralFeature feature, final int idx) { - this.validator.error(msg, obj, feature, idx); - } -} diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.java deleted file mode 100644 index 50e6b61ee..000000000 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/FsmGenChecker.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterators; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraph; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.TrPoint; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; - -@SuppressWarnings("all") -public class FsmGenChecker { - public static void check(final GraphContainer gc, final ILogger logger) { - final Procedure1<Graph> _function = new Procedure1<Graph>() { - @Override - public void apply(final Graph it) { - FsmGenChecker.checkGraph(it, logger); - } - }; - IteratorExtensions.<Graph>forEach(Iterators.<Graph>filter(gc.eAllContents(), Graph.class), _function); - final Procedure1<Node> _function_1 = new Procedure1<Node>() { - @Override - public void apply(final Node it) { - FsmGenChecker.checkNode(it, logger); - } - }; - IteratorExtensions.<Node>forEach(Iterators.<Node>filter(gc.eAllContents(), Node.class), _function_1); - final Procedure1<Link> _function_2 = new Procedure1<Link>() { - @Override - public void apply(final Link it) { - FsmGenChecker.checkLink(it, logger); - } - }; - IteratorExtensions.<Link>forEach(Iterators.<Link>filter(gc.eAllContents(), Link.class), _function_2); - } - - private static void checkLink(final Link it, final ILogger logger) { - TransitionBase _transition = it.getTransition(); - boolean _equals = Objects.equal(_transition, null); - if (_equals) { - logger.logError("graph doesn\'t point to ROOM transition"); - } else { - boolean _eIsProxy = it.getTransition().eIsProxy(); - if (_eIsProxy) { - logger.logError("unresolved ROOM transition"); - } else { - EObject _eContainer = it.getTransition().eContainer(); - boolean _equals_1 = Objects.equal(_eContainer, null); - if (_equals_1) { - logger.logError("dangling ROOM transition"); - } else { - Node _target = it.getTarget(); - boolean _equals_2 = Objects.equal(_target, null); - if (_equals_2) { - logger.logError("link without target"); - } else { - if ((Objects.equal(it.getSource(), null) && (it.getTransition() instanceof NonInitialTransition))) { - logger.logError("non-initial link without source"); - } - } - } - } - } - Node _source = it.getSource(); - boolean _notEquals = (!Objects.equal(_source, null)); - if (_notEquals) { - FsmGenChecker.checkLinkEnd(it, it.getSource(), logger); - } - FsmGenChecker.checkLinkEnd(it, it.getTarget(), logger); - } - - private static void checkLinkEnd(final Link link, final Node node, final ILogger logger) { - EObject _eContainer = node.eContainer(); - EObject _eContainer_1 = link.eContainer(); - boolean _equals = Objects.equal(_eContainer, _eContainer_1); - if (_equals) { - return; - } else { - StateGraphNode _stateGraphNode = node.getStateGraphNode(); - boolean _not = (!(_stateGraphNode instanceof TrPoint)); - if (_not) { - logger.logError("subgraph item is not transition point"); - } else { - EObject _eContainer_2 = node.eContainer().eContainer(); - boolean _not_1 = (!(_eContainer_2 instanceof Node)); - if (_not_1) { - logger.logError("subgraph item is in unexpected container"); - } else { - EObject _eContainer_3 = node.eContainer().eContainer(); - StateGraphNode _stateGraphNode_1 = ((Node) _eContainer_3).getStateGraphNode(); - boolean _not_2 = (!(_stateGraphNode_1 instanceof State)); - if (_not_2) { - logger.logError("subgraph item is in unexpected container"); - } else { - EObject _eContainer_4 = node.eContainer().eContainer().eContainer(); - EObject _eContainer_5 = link.eContainer(); - boolean _notEquals = (!Objects.equal(_eContainer_4, _eContainer_5)); - if (_notEquals) { - logger.logError("subgraph item is in unexpected container"); - } - } - } - } - } - } - - private static void checkNode(final Node it, final ILogger logger) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - boolean _equals = Objects.equal(_stateGraphNode, null); - if (_equals) { - logger.logError("graph doesn\'t point to ROOM state graph node"); - } else { - boolean _eIsProxy = it.getStateGraphNode().eIsProxy(); - if (_eIsProxy) { - logger.logError("unresolved ROOM graph node"); - } else { - EObject _eContainer = it.getStateGraphNode().eContainer(); - boolean _equals_1 = Objects.equal(_eContainer, null); - if (_equals_1) { - logger.logError("dangling ROOM graph node"); - } else { - String _name = it.getStateGraphNode().getName(); - boolean _equals_2 = Objects.equal(_name, null); - if (_equals_2) { - logger.logError("ROOM graph node without name"); - } else { - Graph _graph = it.getGraph(); - boolean _equals_3 = Objects.equal(_graph, null); - if (_equals_3) { - logger.logError("node isn\'t contained in a graph"); - } - } - } - } - } - EList<Link> _incoming = it.getIncoming(); - for (final Link l : _incoming) { - StateGraphNode _stateGraphNode_1 = l.getTarget().getStateGraphNode(); - StateGraphNode _stateGraphNode_2 = it.getStateGraphNode(); - boolean _notEquals = (!Objects.equal(_stateGraphNode_1, _stateGraphNode_2)); - if (_notEquals) { - logger.logError("ROOM target node of an incoming transition must be myself"); - } - } - EList<Link> _outgoing = it.getOutgoing(); - for (final Link l_1 : _outgoing) { - StateGraphNode _stateGraphNode_3 = l_1.getSource().getStateGraphNode(); - StateGraphNode _stateGraphNode_4 = it.getStateGraphNode(); - boolean _notEquals_1 = (!Objects.equal(_stateGraphNode_3, _stateGraphNode_4)); - if (_notEquals_1) { - logger.logError("ROOM source node of an outgoing transition must be myself"); - } - } - } - - private static void checkGraph(final Graph it, final ILogger logger) { - StateGraph _stateGraph = it.getStateGraph(); - boolean _equals = Objects.equal(_stateGraph, null); - if (_equals) { - logger.logError("graph doesn\'t point to ROOM state graph"); - } else { - boolean _eIsProxy = it.getStateGraph().eIsProxy(); - if (_eIsProxy) { - logger.logError("unresolved ROOM graph"); - } else { - EObject _eContainer = it.getStateGraph().eContainer(); - boolean _equals_1 = Objects.equal(_eContainer, null); - if (_equals_1) { - logger.logError("dangling ROOM graph"); - } - } - } - } -} diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/FsmGenExtensions.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/FsmGenExtensions.java deleted file mode 100644 index 76ea3c4b3..000000000 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/FsmGenExtensions.java +++ /dev/null @@ -1,540 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Iterators; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.CPBranchTransition; -import org.eclipse.etrice.core.fsm.fSM.ChoicePoint; -import org.eclipse.etrice.core.fsm.fSM.ContinuationTransition; -import org.eclipse.etrice.core.fsm.fSM.DetailCode; -import org.eclipse.etrice.core.fsm.fSM.EntryPoint; -import org.eclipse.etrice.core.fsm.fSM.ExitPoint; -import org.eclipse.etrice.core.fsm.fSM.GuardedTransition; -import org.eclipse.etrice.core.fsm.fSM.InitialTransition; -import org.eclipse.etrice.core.fsm.fSM.RefinedTransition; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.TrPoint; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.fsm.fSM.TransitionPoint; -import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphItem; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@SuppressWarnings("all") -public class FsmGenExtensions { - public static String _getName(final Node nd) { - return nd.getStateGraphNode().getName(); - } - - public static String _getName(final Link l) { - return l.getTransition().getName(); - } - - public static Iterable<Node> getStateNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof State)); - } - }; - return IterableExtensions.<Node>filter(g.getNodes(), _function); - } - - public static Iterator<Node> getAllNodes(final Graph g) { - return Iterators.<Node>filter(g.eAllContents(), Node.class); - } - - public static Iterator<Node> getAllStateNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof State)); - } - }; - return IteratorExtensions.<Node>filter(FsmGenExtensions.getAllNodes(g), _function); - } - - public static Iterable<Node> getChoicePointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof ChoicePoint)); - } - }; - return IterableExtensions.<Node>filter(g.getNodes(), _function); - } - - public static Iterator<Node> getAllChoicePointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof ChoicePoint)); - } - }; - return IteratorExtensions.<Node>filter(FsmGenExtensions.getAllNodes(g), _function); - } - - public static Iterable<Node> getTrPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof TrPoint)); - } - }; - return IterableExtensions.<Node>filter(g.getNodes(), _function); - } - - public static Iterator<Node> getAllTrPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof TrPoint)); - } - }; - return IteratorExtensions.<Node>filter(FsmGenExtensions.getAllNodes(g), _function); - } - - public static Iterable<Node> getTransitionPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof TransitionPoint)); - } - }; - return IterableExtensions.<Node>filter(g.getNodes(), _function); - } - - public static Iterator<Node> getAllTransitionPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof TransitionPoint)); - } - }; - return IteratorExtensions.<Node>filter(FsmGenExtensions.getAllNodes(g), _function); - } - - public static Iterable<Node> getEntryPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof EntryPoint)); - } - }; - return IterableExtensions.<Node>filter(g.getNodes(), _function); - } - - public static Iterator<Node> getAllEntryPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof EntryPoint)); - } - }; - return IteratorExtensions.<Node>filter(FsmGenExtensions.getAllNodes(g), _function); - } - - public static Iterable<Node> getExitPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof ExitPoint)); - } - }; - return IterableExtensions.<Node>filter(g.getNodes(), _function); - } - - public static Iterator<Node> getAllExitPointNodes(final Graph g) { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof ExitPoint)); - } - }; - return IteratorExtensions.<Node>filter(FsmGenExtensions.getAllNodes(g), _function); - } - - public static Iterable<State> getStates(final Graph g) { - final Function1<Node, StateGraphNode> _function = new Function1<Node, StateGraphNode>() { - @Override - public StateGraphNode apply(final Node it) { - return it.getStateGraphNode(); - } - }; - return Iterables.<State>filter(IterableExtensions.<Node, StateGraphNode>map(FsmGenExtensions.getStateNodes(g), _function), State.class); - } - - public static Iterator<State> getAllStates(final Graph g) { - final Function1<Node, StateGraphNode> _function = new Function1<Node, StateGraphNode>() { - @Override - public StateGraphNode apply(final Node it) { - return it.getStateGraphNode(); - } - }; - return Iterators.<State>filter(IteratorExtensions.<Node, StateGraphNode>map(FsmGenExtensions.getAllStateNodes(g), _function), State.class); - } - - public static Iterable<ChoicePoint> getChoicePoints(final Graph g) { - final Function1<Node, StateGraphNode> _function = new Function1<Node, StateGraphNode>() { - @Override - public StateGraphNode apply(final Node it) { - return it.getStateGraphNode(); - } - }; - return Iterables.<ChoicePoint>filter(IterableExtensions.<Node, StateGraphNode>map(FsmGenExtensions.getChoicePointNodes(g), _function), ChoicePoint.class); - } - - public static Iterable<TrPoint> getTrPoints(final Graph g) { - final Function1<Node, StateGraphNode> _function = new Function1<Node, StateGraphNode>() { - @Override - public StateGraphNode apply(final Node it) { - return it.getStateGraphNode(); - } - }; - return Iterables.<TrPoint>filter(IterableExtensions.<Node, StateGraphNode>map(FsmGenExtensions.getTrPointNodes(g), _function), TrPoint.class); - } - - public static InitialTransition getInitialTransition(final Graph g) { - final Function1<Link, TransitionBase> _function = new Function1<Link, TransitionBase>() { - @Override - public TransitionBase apply(final Link it) { - return it.getTransition(); - } - }; - return IterableExtensions.<InitialTransition>head(Iterables.<InitialTransition>filter(ListExtensions.<Link, TransitionBase>map(g.getLinks(), _function), InitialTransition.class)); - } - - public static Iterator<Link> getAllLinks(final Graph g) { - return Iterators.<Link>filter(g.eAllContents(), Link.class); - } - - public static Iterator<Link> getAllInitialTranisitionLinks(final Graph g) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof InitialTransition)); - } - }; - return IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(g), _function); - } - - public static Iterator<Link> getAllTriggeredTranisitionLinks(final Graph g) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof TriggeredTransition)); - } - }; - return IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(g), _function); - } - - public static Iterator<Link> getAllContinuationTranisitionLinks(final Graph g) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof ContinuationTransition)); - } - }; - return IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(g), _function); - } - - public static Iterator<Link> getAllCPBranchTranisitionLinks(final Graph g) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof CPBranchTransition)); - } - }; - return IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(g), _function); - } - - /** - * returns all links whose transitions are chain heads - * - * @param g a graph - * @return all deeply contained links that are chain heads - * - * @see #isChainHead(Link)) - */ - public static Iterator<Link> getAllChainHeads(final Graph g) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - return Boolean.valueOf(FsmGenExtensions.isChainHead(it)); - } - }; - return IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(g), _function); - } - - /** - * @param l a link - * @return {@code true} if the transition associated with this link is a chain head - * - * @see #isChainHead(TransitionBase)) - */ - public static boolean isChainHead(final Link l) { - return FsmGenExtensions.isChainHead(l.getTransition()); - } - - /** - * the head of a transition chain is an initial, a guarded or a triggered transition - * - * @param l a link - * @return {@code true} if this transition is of one of the above types - */ - public static boolean isChainHead(final TransitionBase t) { - boolean _xifexpression = false; - if ((t instanceof RefinedTransition)) { - _xifexpression = FsmGenExtensions.isChainHead(((RefinedTransition)t).getTarget()); - } else { - _xifexpression = (((t instanceof InitialTransition) || - (t instanceof GuardedTransition)) || - (t instanceof TriggeredTransition)); - } - return _xifexpression; - } - - public static Iterable<Link> getOutgoingTriggeredTransitionLinks(final Node s) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof TriggeredTransition)); - } - }; - return IterableExtensions.<Link>filter(s.getOutgoing(), _function); - } - - public static Iterable<TriggeredTransition> getOutgoingTriggeredTransitions(final Node s) { - final Function1<Link, TransitionBase> _function = new Function1<Link, TransitionBase>() { - @Override - public TransitionBase apply(final Link it) { - return it.getTransition(); - } - }; - return Iterables.<TriggeredTransition>filter(IterableExtensions.<Link, TransitionBase>map(FsmGenExtensions.getOutgoingTriggeredTransitionLinks(s), _function), TriggeredTransition.class); - } - - public static List<TransitionBase> getOutgoingTransitionsHierarchically(final Node s) { - final Function1<Link, TransitionBase> _function = new Function1<Link, TransitionBase>() { - @Override - public TransitionBase apply(final Link it) { - return it.getTransition(); - } - }; - return ListExtensions.<Link, TransitionBase>map(FsmGenExtensions.getOutgoingLinksHierarchically(s), _function); - } - - public static ArrayList<Link> getOutgoingLinksHierarchically(final Node s) { - final ArrayList<Link> result = CollectionLiterals.<Link>newArrayList(); - Node current = s; - while ((current != null)) { - { - result.addAll(s.getOutgoing()); - final Function1<Node, EList<Link>> _function = new Function1<Node, EList<Link>>() { - @Override - public EList<Link> apply(final Node it) { - return it.getOutgoing(); - } - }; - Iterables.<Link>addAll(result, Iterables.<Link>concat(IterableExtensions.<Node, EList<Link>>map(FsmGenExtensions.getTransitionPointNodes(s.getGraph()), _function))); - current = FsmGenExtensions.getParentState(current); - } - } - return result; - } - - public static boolean isTopLevel(final Graph g) { - boolean _xifexpression = false; - if ((g != null)) { - EObject _eContainer = g.eContainer(); - _xifexpression = (_eContainer instanceof GraphContainer); - } else { - _xifexpression = true; - } - return _xifexpression; - } - - public static boolean isEmpty(final Graph g) { - return ((g == null) || (g.getNodes().isEmpty() && g.getLinks().isEmpty())); - } - - public static boolean isLeaf(final Node n) { - Graph _subgraph = n.getSubgraph(); - return (_subgraph == null); - } - - public static boolean isTopLevel(final Node n) { - return FsmGenExtensions.isTopLevel(n.getGraph()); - } - - public static Node getParentState(final Node n) { - Node _xifexpression = null; - boolean _isTopLevel = FsmGenExtensions.isTopLevel(n); - if (_isTopLevel) { - _xifexpression = null; - } else { - EObject _eContainer = n.getGraph().eContainer(); - _xifexpression = ((Node) _eContainer); - } - return _xifexpression; - } - - public static Link getChoicepointDefaultBranch(final Node n) { - StateGraphNode _stateGraphNode = n.getStateGraphNode(); - boolean _not = (!(_stateGraphNode instanceof ChoicePoint)); - if (_not) { - return null; - } - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof ContinuationTransition)); - } - }; - return IterableExtensions.<Link>head(IterableExtensions.<Link>filter(n.getOutgoing(), _function)); - } - - public static Node getParentState(final Link l) { - Node _xifexpression = null; - boolean _isTopLevel = FsmGenExtensions.isTopLevel(l.getGraph()); - if (_isTopLevel) { - _xifexpression = null; - } else { - EObject _eContainer = l.getGraph().eContainer(); - _xifexpression = ((Node) _eContainer); - } - return _xifexpression; - } - - public static boolean isHandler(final Link l) { - boolean _xblockexpression = false; - { - final StateGraphNode sourceNode = l.getSource().getStateGraphNode(); - boolean _xifexpression = false; - if ((sourceNode instanceof TransitionPoint)) { - _xifexpression = ((TransitionPoint)sourceNode).isHandler(); - } else { - _xifexpression = false; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - public static List<DetailCode> getAllDetailCodes(final Graph graph) { - final ArrayList<DetailCode> detailCodes = CollectionLiterals.<DetailCode>newArrayList(); - if ((graph != null)) { - final Function1<Link, TransitionBase> _function = new Function1<Link, TransitionBase>() { - @Override - public TransitionBase apply(final Link it) { - return it.getTransition(); - } - }; - final Iterator<TransitionBase> allTransitions = IteratorExtensions.<Link, TransitionBase>map(FsmGenExtensions.getAllLinks(graph), _function); - final Function1<TransitionBase, DetailCode> _function_1 = new Function1<TransitionBase, DetailCode>() { - @Override - public DetailCode apply(final TransitionBase it) { - return it.getAction(); - } - }; - List<DetailCode> _list = IteratorExtensions.<DetailCode>toList(IteratorExtensions.<TransitionBase, DetailCode>map(allTransitions, _function_1)); - Iterables.<DetailCode>addAll(detailCodes, _list); - final Function1<Node, StateGraphNode> _function_2 = new Function1<Node, StateGraphNode>() { - @Override - public StateGraphNode apply(final Node it) { - return it.getStateGraphNode(); - } - }; - final Iterator<State> allStates = Iterators.<State>filter(IteratorExtensions.<Node, StateGraphNode>map(FsmGenExtensions.getAllStateNodes(graph), _function_2), State.class); - final Function1<State, DetailCode> _function_3 = new Function1<State, DetailCode>() { - @Override - public DetailCode apply(final State it) { - return it.getEntryCode(); - } - }; - List<DetailCode> _list_1 = IteratorExtensions.<DetailCode>toList(IteratorExtensions.<State, DetailCode>map(allStates, _function_3)); - Iterables.<DetailCode>addAll(detailCodes, _list_1); - final Function1<State, DetailCode> _function_4 = new Function1<State, DetailCode>() { - @Override - public DetailCode apply(final State it) { - return it.getDoCode(); - } - }; - List<DetailCode> _list_2 = IteratorExtensions.<DetailCode>toList(IteratorExtensions.<State, DetailCode>map(allStates, _function_4)); - Iterables.<DetailCode>addAll(detailCodes, _list_2); - final Function1<State, DetailCode> _function_5 = new Function1<State, DetailCode>() { - @Override - public DetailCode apply(final State it) { - return it.getExitCode(); - } - }; - List<DetailCode> _list_3 = IteratorExtensions.<DetailCode>toList(IteratorExtensions.<State, DetailCode>map(allStates, _function_5)); - Iterables.<DetailCode>addAll(detailCodes, _list_3); - } - return detailCodes; - } - - public static Link getLinkFor(final GraphContainer gc, final TransitionBase t) { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition == t)); - } - }; - return IteratorExtensions.<Link>findFirst(FsmGenExtensions.getAllLinks(gc.getGraph()), _function); - } - - public static String getName(final GraphItem l) { - if (l instanceof Link) { - return _getName((Link)l); - } else if (l instanceof Node) { - return _getName((Node)l); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " + - Arrays.<Object>asList(l).toString()); - } - } -} diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/TriggerExtensions.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/TriggerExtensions.java deleted file mode 100644 index dc45ccf27..000000000 --- a/plugins/org.eclipse.etrice.core.genmodel.fsm/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/TriggerExtensions.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.fsm.fSM.MessageFromIf; -import org.eclipse.etrice.core.fsm.fSM.Trigger; -import org.eclipse.etrice.core.fsm.naming.FSMNameProvider; -import org.eclipse.xtext.xbase.lib.Extension; - -@SuppressWarnings("all") -public class TriggerExtensions { - public static String TRIGGER_SEP = "#"; - - @Inject - @Extension - protected FSMNameProvider _fSMNameProvider; - - public String getTriggerTag(final MessageFromIf it) { - String _name = it.getFrom().getName(); - String _plus = (_name + TriggerExtensions.TRIGGER_SEP); - String _messageName = this._fSMNameProvider.getMessageName(it.getMessage()); - return (_plus + _messageName); - } - - public boolean isMatching(final Trigger trig, final String trigstr) { - EList<MessageFromIf> _msgFromIfPairs = trig.getMsgFromIfPairs(); - for (final MessageFromIf mif : _msgFromIfPairs) { - { - final String tr = this.getTriggerTag(mif); - boolean _equals = Objects.equal(tr, trigstr); - if (_equals) { - return true; - } - } - } - return false; - } -} diff --git a/plugins/org.eclipse.etrice.core.room.ui/xtend-gen/org/eclipse/etrice/core/ui/quickfix/DetailCodeIndentHelper.java b/plugins/org.eclipse.etrice.core.room.ui/xtend-gen/org/eclipse/etrice/core/ui/quickfix/DetailCodeIndentHelper.java deleted file mode 100644 index b934e19b5..000000000 --- a/plugins/org.eclipse.etrice.core.room.ui/xtend-gen/org/eclipse/etrice/core/ui/quickfix/DetailCodeIndentHelper.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.eclipse.etrice.core.ui.quickfix; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.jface.text.IRegion; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.ui.editor.model.IXtextDocument; -import org.eclipse.xtext.util.Strings; -import org.eclipse.xtext.validation.Issue; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IntegerRange; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure2; - -@SuppressWarnings("all") -public class DetailCodeIndentHelper { - /** - * Converts the issued multi line string to single line strings - * - line with least indentation is adjusted to first line - * - lines are enclosed with " or ' - * - lines get editor indentation of first line - * - - */ - public static String convertToSingleLines(final IXtextDocument document, final Issue issue) { - try { - final IRegion issuedRegion = document.getLineInformationOfOffset((issue.getOffset()).intValue()); - final String firstEditorLine = document.get(issuedRegion.getOffset(), issuedRegion.getLength()); - final String editorIndent = Strings.getLeadingWhiteSpace(firstEditorLine); - final String editorString = document.get((issue.getOffset()).intValue(), (issue.getLength()).intValue()); - final String mark = Character.valueOf(editorString.charAt(0)).toString(); - final List<String> editorLines = Strings.split(editorString, Strings.newLine()); - int _size = editorLines.size(); - boolean _lessEqualsThan = (_size <= 1); - if (_lessEqualsThan) { - return editorString; - } - final Function1<String, Integer> _function = (String it) -> { - return Integer.valueOf(DetailCodeIndentHelper.countIndent(it)); - }; - final int minIndent = DetailCodeIndentHelper.countIndent(IterableExtensions.<String>head(IterableExtensions.<String, Integer>sortBy(IterableExtensions.<String>tail(editorLines), _function))); - final ArrayList<String> newEditorLines = new ArrayList<String>(); - final Procedure2<String, Integer> _function_1 = (String line, Integer lineCount) -> { - String _xifexpression = null; - if (((lineCount).intValue() != 0)) { - _xifexpression = (editorIndent + mark); - } - String front = _xifexpression; - int _countIndent = DetailCodeIndentHelper.countIndent(line); - int indentCount = (_countIndent - minIndent); - String _xifexpression_1 = null; - if ((((lineCount).intValue() != 0) && (indentCount > 0))) { - StringConcatenation _builder = new StringConcatenation(); - { - IntegerRange _upTo = new IntegerRange(1, indentCount); - for(final Integer i : _upTo) { - _builder.append("\t"); - } - } - _xifexpression_1 = _builder.toString(); - } - String indent = _xifexpression_1; - String noneWSLine = Strings.removeLeadingWhitespace(line); - String _xifexpression_2 = null; - int _size_1 = editorLines.size(); - int _minus = (_size_1 - 1); - boolean _notEquals = ((lineCount).intValue() != _minus); - if (_notEquals) { - _xifexpression_2 = mark; - } - String end = _xifexpression_2; - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append(front); - _builder_1.append(indent); - _builder_1.append(noneWSLine); - _builder_1.append(end); - String newEditorLine = _builder_1.toString(); - newEditorLines.add(newEditorLine); - }; - IterableExtensions.<String>forEach(editorLines, _function_1); - return Strings.concat(Strings.newLine(), newEditorLines); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } - - private static int countIndent(final String line) { - return Strings.getLeadingWhiteSpace(line).replace("\t", " ").replace(" ", "\t").replaceAll("!\\t", "").length(); - } -} diff --git a/plugins/org.eclipse.etrice.core.room/build.gradle b/plugins/org.eclipse.etrice.core.room/build.gradle index 65c27312e..6d3b73f35 100644 --- a/plugins/org.eclipse.etrice.core.room/build.gradle +++ b/plugins/org.eclipse.etrice.core.room/build.gradle @@ -5,6 +5,7 @@ apply from: "$rootDir/gradle/publish.gradle" dependencies { compile project(':plugins:org.eclipse.etrice.core.common') compile project(':plugins:org.eclipse.etrice.core.fsm') + compile project(':plugins:org.eclipse.etrice.core.genmodel.fsm') runtime project(':plugins:org.eclipse.etrice.abstractexec.behavior') compile "org.eclipse.platform:org.eclipse.core.runtime:$core_runtime_version" diff --git a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/room/util/CommonDataCalculator.java b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/room/util/CommonDataCalculator.java deleted file mode 100644 index 54d284670..000000000 --- a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/room/util/CommonDataCalculator.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.room.util; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.MessageFromIf; -import org.eclipse.etrice.core.fsm.fSM.RefinedTransition; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.fsm.fSM.Trigger; -import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition; -import org.eclipse.etrice.core.genmodel.fsm.ICommonDataCalculator; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.RefableType; -import org.eclipse.etrice.core.room.RoomFactory; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@SuppressWarnings("all") -public class CommonDataCalculator implements ICommonDataCalculator { - private RoomHelpers roomHelpers = new RoomHelpers(); - - @Override - public EObject calculateCommonData(final Link l) { - boolean _isIfitemTriggered = l.isIfitemTriggered(); - boolean _not = (!_isIfitemTriggered); - if (_not) { - return null; - } else { - final Function1<Link, TransitionBase> _function = (Link it) -> { - return CommonDataCalculator.realTransition(it.getTransition()); - }; - Iterable<TriggeredTransition> transitions = Iterables.<TriggeredTransition>filter(ListExtensions.<Link, TransitionBase>map(l.getChainHeads(), _function), TriggeredTransition.class); - final Function1<TriggeredTransition, EList<Trigger>> _function_1 = (TriggeredTransition it) -> { - return it.getTriggers(); - }; - final Iterable<Trigger> triggers = Iterables.<Trigger>concat(IterableExtensions.<TriggeredTransition, EList<Trigger>>map(transitions, _function_1)); - final Function1<Trigger, EList<MessageFromIf>> _function_2 = (Trigger it) -> { - return it.getMsgFromIfPairs(); - }; - final Function1<MessageFromIf, VarDecl> _function_3 = (MessageFromIf it) -> { - EObject _message = it.getMessage(); - return ((Message) _message).getData(); - }; - final Iterable<VarDecl> varDeclarations = IterableExtensions.<MessageFromIf, VarDecl>map(Iterables.<MessageFromIf>concat(IterableExtensions.<Trigger, EList<MessageFromIf>>map(triggers, _function_2)), _function_3); - final Function1<VarDecl, DataType> _function_4 = (VarDecl it) -> { - RefableType _refType = null; - if (it!=null) { - _refType=it.getRefType(); - } - DataType _type = null; - if (_refType!=null) { - _type=_refType.getType(); - } - return _type; - }; - final Set<DataType> allData = IterableExtensions.<DataType>toSet(IterableExtensions.<VarDecl, DataType>map(varDeclarations, _function_4)); - int _size = allData.size(); - boolean _equals = (_size == 1); - if (_equals) { - return IterableExtensions.<VarDecl>head(varDeclarations); - } else { - final Function1<VarDecl, RefableType> _function_5 = (VarDecl it) -> { - RefableType _refType = null; - if (it!=null) { - _refType=it.getRefType(); - } - return _refType; - }; - final List<RefableType> types = IterableExtensions.<RefableType>toList(IterableExtensions.<VarDecl, RefableType>map(varDeclarations, _function_5)); - final RefableType rt = this.roomHelpers.getLastCommonSuperType(types); - boolean _notEquals = (!Objects.equal(rt, null)); - if (_notEquals) { - final VarDecl vd = RoomFactory.eINSTANCE.createVarDecl(); - vd.setName("data"); - vd.setRefType(rt); - return vd; - } - } - } - return null; - } - - private static TransitionBase realTransition(final TransitionBase t) { - TransitionBase tr = t; - while ((tr instanceof RefinedTransition)) { - tr = ((RefinedTransition)tr).getTarget(); - } - return tr; - } -} diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java deleted file mode 100644 index 8e8605f0e..000000000 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java +++ /dev/null @@ -1,1218 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - * Thomas Schuetz (changed for C code generator) - */ -package org.eclipse.etrice.generator.c.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType; -import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.GeneralProtocolClass; -import org.eclipse.etrice.core.room.InterfaceItem; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.Operation; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.PortOperation; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.SAP; -import org.eclipse.etrice.core.room.ServiceImplementation; -import org.eclipse.etrice.core.room.StandardOperation; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.generator.c.Main; -import org.eclipse.etrice.generator.c.gen.CExtensions; -import org.eclipse.etrice.generator.c.gen.StateMachineGen; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.GenericActorClassGenerator; -import org.eclipse.etrice.generator.generic.ILanguageExtension; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class ActorClassGen extends GenericActorClassGenerator { - @Inject - @Extension - protected RoomExtensions _roomExtensions; - - @Inject - @Extension - protected CExtensions _cExtensions; - - @Inject - @Extension - protected ProcedureHelpers _procedureHelpers; - - @Inject - @Extension - protected StateMachineGen _stateMachineGen; - - @Inject - protected ILanguageExtension langExt; - - @Inject - protected IGeneratorFileIo fileIO; - - @Inject - protected ILogger logger; - - public void doGenerate(final Root root) { - final Function1<ActorClass, ExpandedActorClass> _function = (ActorClass it) -> { - return root.getExpandedActorClass(it); - }; - List<ExpandedActorClass> _map = ListExtensions.<ActorClass, ExpandedActorClass>map(root.getActorClasses(), _function); - for (final ExpandedActorClass xpac : _map) { - { - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(xpac.getActorClass()); - String _path = this._roomExtensions.getPath(xpac.getActorClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(xpac.getActorClass()); - String _path_1 = this._roomExtensions.getPath(xpac.getActorClass()); - final String infopath = (_generationInfoPath + _path_1); - String file = this._cExtensions.getCHeaderFileName(xpac.getActorClass()); - this.fileIO.generateFile("generating ActorClass header", path, infopath, file, this.generateHeaderFile(root, xpac)); - file = this._cExtensions.getCUtilsFileName(xpac.getActorClass()); - this.fileIO.generateFile("generating ActorClass utils", path, infopath, file, this.generateUtilsFile(root, xpac)); - boolean _isBehaviorAnnotationPresent = this._roomHelpers.isBehaviorAnnotationPresent(xpac.getActorClass(), "BehaviorManual"); - if (_isBehaviorAnnotationPresent) { - String _name = xpac.getActorClass().getName(); - String _plus = ("omitting ActorClass source for \'" + _name); - String _plus_1 = (_plus + "\' since @BehaviorManual is specified"); - this.logger.logInfo(_plus_1); - } else { - file = this._cExtensions.getCSourceFileName(xpac.getActorClass()); - this.fileIO.generateFile("generating ActorClass source", path, infopath, file, this.generateSourceFile(root, xpac)); - } - } - } - } - - protected CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - final Function1<Port, Boolean> _function = (Port p) -> { - GeneralProtocolClass _protocol = p.getProtocol(); - CommunicationType _commType = ((ProtocolClass) _protocol).getCommType(); - return Boolean.valueOf(Objects.equal(_commType, CommunicationType.EVENT_DRIVEN)); - }; - final Iterable<Port> eventPorts = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function); - final Function1<Port, Boolean> _function_1 = (Port p) -> { - return Boolean.valueOf((Objects.equal(((ProtocolClass) p.getProtocol()).getCommType(), CommunicationType.DATA_DRIVEN) && p.isConjugated())); - }; - final Iterable<Port> sendPorts = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function_1); - final Function1<Port, Boolean> _function_2 = (Port p) -> { - return Boolean.valueOf((Objects.equal(((ProtocolClass) p.getProtocol()).getCommType(), CommunicationType.DATA_DRIVEN) && (!p.isConjugated()))); - }; - final Iterable<Port> recvPorts = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function_2); - ComponentCommunicationType _commType = ac.getCommType(); - final boolean dataDriven = Objects.equal(_commType, ComponentCommunicationType.DATA_DRIVEN); - ComponentCommunicationType _commType_1 = ac.getCommType(); - final boolean async = Objects.equal(_commType_1, ComponentCommunicationType.ASYNCHRONOUS); - final boolean hasConstData = ((!(((IterableExtensions.isEmpty(eventPorts) && IterableExtensions.isEmpty(recvPorts)) && this._roomHelpers.getAllSAPs(ac).isEmpty()) && this._roomHelpers.getAllServiceImplementations(ac).isEmpty())) || Main.getSettings().isGenerateMSCInstrumentation()); - final boolean isEmptyStateGraph = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - final boolean hasVarData = (!(((IterableExtensions.isEmpty(sendPorts) && this._roomHelpers.getAllAttributes(ac).isEmpty()) && isEmptyStateGraph) && (!hasConstData))); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of ActorClass "); - String _name = ac.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(ac); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"etDatatypes.h\""); - _builder.newLine(); - _builder.append("#include \"messaging/etMessage.h\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* include all referenced room classes */"); - _builder.newLine(); - { - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac); - EList<EnumerationType> _referencedEnumClasses = root.getReferencedEnumClasses(ac); - Iterable<DataType> _plus = Iterables.<DataType>concat(_referencedDataClasses, _referencedEnumClasses); - EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac); - final Function1<RoomClass, String> _function_3 = (RoomClass it) -> { - return it.getName(); - }; - List<RoomClass> _sortBy = IterableExtensions.<RoomClass, String>sortBy(Iterables.<RoomClass>concat(_plus, _referencedProtocolClasses), _function_3); - for(final RoomClass rc : _sortBy) { - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(rc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(ac, 1, true); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("typedef struct "); - String _name_1 = ac.getName(); - _builder.append(_name_1); - _builder.append(" "); - String _name_2 = ac.getName(); - _builder.append(_name_2); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* const part of ActorClass (ROM) */"); - _builder.newLine(); - { - if (hasConstData) { - _builder.append("typedef struct "); - String _name_3 = ac.getName(); - _builder.append(_name_3); - _builder.append("_const {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("const char* instName;"); - _builder.newLine(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("/* simple ports */"); - _builder.newLine(); - { - for(final Port ep : eventPorts) { - { - int _multiplicity = ep.getMultiplicity(); - boolean _equals = (_multiplicity == 1); - if (_equals) { - _builder.append("\t"); - _builder.append("const "); - String _portClassName = this._roomExtensions.getPortClassName(ep); - _builder.append(_portClassName, "\t"); - _builder.append(" "); - String _name_4 = ep.getName(); - _builder.append(_name_4, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* data receive ports */"); - _builder.newLine(); - { - for(final Port ep_1 : recvPorts) { - { - int _multiplicity_1 = ep_1.getMultiplicity(); - boolean _equals_1 = (_multiplicity_1 == 1); - if (_equals_1) { - _builder.append("\t"); - _builder.append("const "); - String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1); - _builder.append(_portClassName_1, "\t"); - _builder.append(" "); - String _name_5 = ep_1.getName(); - _builder.append(_name_5, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* saps */"); - _builder.newLine(); - { - List<SAP> _allSAPs = this._roomHelpers.getAllSAPs(ac); - for(final SAP sap : _allSAPs) { - _builder.append("\t"); - _builder.append("const "); - String _portClassName_2 = this._roomExtensions.getPortClassName(sap); - _builder.append(_portClassName_2, "\t"); - _builder.append(" "); - String _name_6 = sap.getName(); - _builder.append(_name_6, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* replicated ports */"); - _builder.newLine(); - { - List<Port> _allEndPorts = this._roomHelpers.getAllEndPorts(ac); - for(final Port ep_2 : _allEndPorts) { - { - int _multiplicity_2 = ep_2.getMultiplicity(); - boolean _notEquals = (_multiplicity_2 != 1); - if (_notEquals) { - _builder.append("\t"); - _builder.append("const etReplPort "); - String _name_7 = ep_2.getName(); - _builder.append(_name_7, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* services */"); - _builder.newLine(); - { - List<ServiceImplementation> _allServiceImplementations = this._roomHelpers.getAllServiceImplementations(ac); - for(final ServiceImplementation svc : _allServiceImplementations) { - _builder.append("\t"); - _builder.append("const etReplPort "); - String _name_8 = svc.getSpp().getName(); - _builder.append(_name_8, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("} "); - String _name_9 = ac.getName(); - _builder.append(_name_9); - _builder.append("_const;"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("/* this actor class has no ports and thus no constant data */"); - _builder.newLine(); - } - } - _builder.newLine(); - { - if ((!isEmptyStateGraph)) { - _builder.newLine(); - CharSequence _genHeaderConstants = this._stateMachineGen.genHeaderConstants(xpac); - _builder.append(_genHeaderConstants); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* variable part of ActorClass (RAM) */"); - _builder.newLine(); - { - if (hasVarData) { - _builder.append("struct "); - String _name_10 = ac.getName(); - _builder.append(_name_10); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - if (hasConstData) { - _builder.append("\t"); - _builder.append("const "); - String _name_11 = ac.getName(); - _builder.append(_name_11, "\t"); - _builder.append("_const* const constData;"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("/* data send ports */"); - _builder.newLine(); - { - for(final Port ep_3 : sendPorts) { - { - int _multiplicity_3 = ep_3.getMultiplicity(); - boolean _equals_2 = (_multiplicity_3 == 1); - if (_equals_2) { - _builder.append("\t"); - String _portClassName_3 = this._roomExtensions.getPortClassName(ep_3); - _builder.append(_portClassName_3, "\t"); - _builder.append(" "); - String _name_12 = ep_3.getName(); - _builder.append(_name_12, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - CharSequence _attributes = this._procedureHelpers.attributes(this._roomHelpers.getAllAttributes(ac)); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if ((!isEmptyStateGraph)) { - _builder.newLine(); - _builder.append("\t"); - CharSequence _genDataMembers = this._stateMachineGen.genDataMembers(xpac); - _builder.append(_genDataMembers, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - } else { - _builder.append("struct "); - String _name_13 = ac.getName(); - _builder.append(_name_13); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("/* This actor class has no data at all."); - _builder.newLine(); - _builder.append("\t "); - _builder.append("But the private actor instance data is passed to all life cycle functions."); - _builder.newLine(); - _builder.append("\t "); - _builder.append("By introducing the dummy data we keep this case simple"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("*/"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("int dummy;"); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("void "); - String _name_14 = ac.getName(); - _builder.append(_name_14); - _builder.append("_init("); - String _name_15 = ac.getName(); - _builder.append(_name_15); - _builder.append("* self);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("void "); - String _name_16 = ac.getName(); - _builder.append(_name_16); - _builder.append("_receiveMessage(void* self, const void* ifitem, const etMessage* msg);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if ((dataDriven || async)) { - _builder.append("void "); - String _name_17 = ac.getName(); - _builder.append(_name_17); - _builder.append("_execute("); - String _name_18 = ac.getName(); - _builder.append(_name_18); - _builder.append("* self);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - String _userStructorsDeclaration = this._procedureHelpers.userStructorsDeclaration(ac); - _builder.append(_userStructorsDeclaration); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(this._roomHelpers.getLatestOperations(ac), ac.getName()); - _builder.append(_operationsDeclaration); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2, true); - _builder.append(_userCode_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(ac); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - protected CharSequence generateUtilsFile(final Root root, final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - final Function1<Port, Boolean> _function = (Port p) -> { - GeneralProtocolClass _protocol = p.getProtocol(); - CommunicationType _commType = ((ProtocolClass) _protocol).getCommType(); - return Boolean.valueOf(Objects.equal(_commType, CommunicationType.EVENT_DRIVEN)); - }; - final Iterable<Port> eventPorts = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function); - final Function1<Port, Boolean> _function_1 = (Port it) -> { - int _multiplicity = it.getMultiplicity(); - return Boolean.valueOf((_multiplicity != 1)); - }; - final Iterable<Port> replEventPorts = IterableExtensions.<Port>filter(eventPorts, _function_1); - final Function1<Port, Boolean> _function_2 = (Port p) -> { - return Boolean.valueOf(((Objects.equal(((ProtocolClass) p.getProtocol()).getCommType(), CommunicationType.DATA_DRIVEN) && p.isConjugated()) && (p.getMultiplicity() == 1))); - }; - final Iterable<Port> sendPorts = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function_2); - final Function1<Port, Boolean> _function_3 = (Port p) -> { - return Boolean.valueOf(((Objects.equal(((ProtocolClass) p.getProtocol()).getCommType(), CommunicationType.DATA_DRIVEN) && (!p.isConjugated())) && (p.getMultiplicity() == 1))); - }; - final Iterable<Port> recvPorts = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function_3); - final Function1<InterfaceItem, Boolean> _function_4 = (InterfaceItem p) -> { - return Boolean.valueOf(((!Objects.equal(this._roomHelpers.getPortClass(p), null)) && (this._roomHelpers.getPortClass(p).getOperations().size() > 0))); - }; - final Iterable<InterfaceItem> portsWithOperations = IterableExtensions.<InterfaceItem>filter(this._roomHelpers.getAllInterfaceItems(ac), _function_4); - EObject _eContainer = ac.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "_"); - String _plus = (_replaceAll + "_"); - String _name = ac.getName(); - String _plus_1 = (_plus + _name); - final String filename = (_plus_1 + "_Utils"); - 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("* Utils File of ActorClass "); - String _name_1 = ac.getName(); - _builder.append(_name_1, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(filename); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(ac); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* access macros for ports, operations and attributes"); - _builder.newLine(); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* simple event ports */"); - _builder.newLine(); - { - final Function1<Port, Boolean> _function_5 = (Port it) -> { - int _multiplicity = it.getMultiplicity(); - return Boolean.valueOf((_multiplicity == 1)); - }; - Iterable<Port> _filter = IterableExtensions.<Port>filter(eventPorts, _function_5); - for(final Port ep : _filter) { - { - List<Message> _outgoing = this._roomHelpers.getOutgoing(ep); - for(final Message msg : _outgoing) { - String _xifexpression = null; - VarDecl _data = msg.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - _xifexpression = "data"; - } else { - _xifexpression = ""; - } - final String data1 = _xifexpression; - _builder.newLineIfNotEmpty(); - String _xifexpression_1 = null; - VarDecl _data_1 = msg.getData(); - boolean _notEquals_1 = (!Objects.equal(_data_1, null)); - if (_notEquals_1) { - _xifexpression_1 = ", data"; - } else { - _xifexpression_1 = ""; - } - final String data2 = _xifexpression_1; - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_2 = ep.getName(); - _builder.append(_name_2); - _builder.append("_"); - String _name_3 = msg.getName(); - _builder.append(_name_3); - _builder.append("("); - _builder.append(data1); - _builder.append(") "); - String _portClassName = this._roomExtensions.getPortClassName(ep); - _builder.append(_portClassName); - _builder.append("_"); - String _name_4 = msg.getName(); - _builder.append(_name_4); - _builder.append("(&self->constData->"); - String _name_5 = ep.getName(); - _builder.append(_name_5); - _builder.append(data2); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("/* data receive ports */"); - _builder.newLine(); - { - for(final Port ep_1 : recvPorts) { - { - List<Message> _incoming = this._roomHelpers.getIncoming(ep_1); - for(final Message msg_1 : _incoming) { - _builder.append("#define "); - String _name_6 = ep_1.getName(); - _builder.append(_name_6); - _builder.append("_"); - String _name_7 = msg_1.getName(); - _builder.append(_name_7); - _builder.append(" "); - String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1); - _builder.append(_portClassName_1); - _builder.append("_"); - String _name_8 = msg_1.getName(); - _builder.append(_name_8); - _builder.append("_get(&self->constData->"); - String _name_9 = ep_1.getName(); - _builder.append(_name_9); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("/* data send ports */"); - _builder.newLine(); - { - for(final Port ep_2 : sendPorts) { - { - List<Message> _outgoing_1 = this._roomHelpers.getOutgoing(ep_2); - for(final Message msg_2 : _outgoing_1) { - String _xifexpression_2 = null; - VarDecl _data_2 = msg_2.getData(); - boolean _notEquals_2 = (!Objects.equal(_data_2, null)); - if (_notEquals_2) { - _xifexpression_2 = "data"; - } else { - _xifexpression_2 = ""; - } - final String data1_1 = _xifexpression_2; - _builder.newLineIfNotEmpty(); - String _xifexpression_3 = null; - VarDecl _data_3 = msg_2.getData(); - boolean _notEquals_3 = (!Objects.equal(_data_3, null)); - if (_notEquals_3) { - _xifexpression_3 = ", data"; - } else { - _xifexpression_3 = ""; - } - final String data2_1 = _xifexpression_3; - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_10 = ep_2.getName(); - _builder.append(_name_10); - _builder.append("_"); - String _name_11 = msg_2.getName(); - _builder.append(_name_11); - _builder.append("("); - _builder.append(data1_1); - _builder.append(") "); - String _portClassName_2 = this._roomExtensions.getPortClassName(ep_2); - _builder.append(_portClassName_2); - _builder.append("_"); - String _name_12 = msg_2.getName(); - _builder.append(_name_12); - _builder.append("_set(&self->"); - String _name_13 = ep_2.getName(); - _builder.append(_name_13); - _builder.append(data2_1); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("/* saps */"); - _builder.newLine(); - { - List<SAP> _allSAPs = this._roomHelpers.getAllSAPs(ac); - for(final SAP sap : _allSAPs) { - { - List<Message> _outgoing_2 = this._roomHelpers.getOutgoing(sap); - for(final Message msg_3 : _outgoing_2) { - String _xifexpression_4 = null; - VarDecl _data_4 = msg_3.getData(); - boolean _notEquals_4 = (!Objects.equal(_data_4, null)); - if (_notEquals_4) { - _xifexpression_4 = "data"; - } else { - _xifexpression_4 = ""; - } - final String data1_2 = _xifexpression_4; - _builder.newLineIfNotEmpty(); - String _xifexpression_5 = null; - VarDecl _data_5 = msg_3.getData(); - boolean _notEquals_5 = (!Objects.equal(_data_5, null)); - if (_notEquals_5) { - _xifexpression_5 = ", data"; - } else { - _xifexpression_5 = ""; - } - final String data2_2 = _xifexpression_5; - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_14 = sap.getName(); - _builder.append(_name_14); - _builder.append("_"); - String _name_15 = msg_3.getName(); - _builder.append(_name_15); - _builder.append("("); - _builder.append(data1_2); - _builder.append(") "); - String _portClassName_3 = this._roomExtensions.getPortClassName(sap); - _builder.append(_portClassName_3); - _builder.append("_"); - String _name_16 = msg_3.getName(); - _builder.append(_name_16); - _builder.append("(&self->constData->"); - String _name_17 = sap.getName(); - _builder.append(_name_17); - _builder.append(data2_2); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("/* replicated event ports */"); - _builder.newLine(); - { - boolean _isEmpty = IterableExtensions.isEmpty(replEventPorts); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("#define ifitem_index (((etReplSubPort*)ifitem)->index)"); - _builder.newLine(); - } - } - { - for(final Port ep_3 : replEventPorts) { - { - List<Message> _outgoing_3 = this._roomHelpers.getOutgoing(ep_3); - for(final Message msg_4 : _outgoing_3) { - String _xifexpression_6 = null; - VarDecl _data_6 = msg_4.getData(); - boolean _notEquals_6 = (!Objects.equal(_data_6, null)); - if (_notEquals_6) { - _xifexpression_6 = "data"; - } else { - _xifexpression_6 = ""; - } - final String data1_3 = _xifexpression_6; - _builder.newLineIfNotEmpty(); - String _xifexpression_7 = null; - VarDecl _data_7 = msg_4.getData(); - boolean _notEquals_7 = (!Objects.equal(_data_7, null)); - if (_notEquals_7) { - _xifexpression_7 = ", data"; - } else { - _xifexpression_7 = ""; - } - final String data2_3 = _xifexpression_7; - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_18 = ep_3.getName(); - _builder.append(_name_18); - _builder.append("_"); - String _name_19 = msg_4.getName(); - _builder.append(_name_19); - _builder.append("_broadcast("); - _builder.append(data1_3); - _builder.append(") "); - String _portClassName_4 = this._roomExtensions.getPortClassName(ep_3); - _builder.append(_portClassName_4); - _builder.append("_"); - String _name_20 = msg_4.getName(); - _builder.append(_name_20); - _builder.append("_broadcast(&self->constData->"); - String _name_21 = ep_3.getName(); - _builder.append(_name_21); - _builder.append(data2_3); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_22 = ep_3.getName(); - _builder.append(_name_22); - _builder.append("_"); - String _name_23 = msg_4.getName(); - _builder.append(_name_23); - _builder.append("(idx"); - _builder.append(data2_3); - _builder.append(") "); - String _portClassName_5 = this._roomExtensions.getPortClassName(ep_3); - _builder.append(_portClassName_5); - _builder.append("_"); - String _name_24 = msg_4.getName(); - _builder.append(_name_24); - _builder.append("(&self->constData->"); - String _name_25 = ep_3.getName(); - _builder.append(_name_25); - _builder.append(", idx"); - _builder.append(data2_3); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("/* services */"); - _builder.newLine(); - { - List<ServiceImplementation> _allServiceImplementations = this._roomHelpers.getAllServiceImplementations(ac); - for(final ServiceImplementation svc : _allServiceImplementations) { - { - List<Message> _outgoing_4 = this._roomHelpers.getOutgoing(svc.getSpp()); - for(final Message msg_5 : _outgoing_4) { - String _xifexpression_8 = null; - VarDecl _data_8 = msg_5.getData(); - boolean _notEquals_8 = (!Objects.equal(_data_8, null)); - if (_notEquals_8) { - _xifexpression_8 = "data"; - } else { - _xifexpression_8 = ""; - } - final String data1_4 = _xifexpression_8; - _builder.newLineIfNotEmpty(); - String _xifexpression_9 = null; - VarDecl _data_9 = msg_5.getData(); - boolean _notEquals_9 = (!Objects.equal(_data_9, null)); - if (_notEquals_9) { - _xifexpression_9 = ", data"; - } else { - _xifexpression_9 = ""; - } - final String data2_4 = _xifexpression_9; - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_26 = svc.getSpp().getName(); - _builder.append(_name_26); - _builder.append("_"); - String _name_27 = msg_5.getName(); - _builder.append(_name_27); - _builder.append("_broadcast("); - _builder.append(data1_4); - _builder.append(") "); - String _portClassName_6 = this._roomExtensions.getPortClassName(svc.getSpp()); - _builder.append(_portClassName_6); - _builder.append("_"); - String _name_28 = msg_5.getName(); - _builder.append(_name_28); - _builder.append("_broadcast(&self->constData->"); - String _name_29 = svc.getSpp().getName(); - _builder.append(_name_29); - _builder.append(data2_4); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_30 = svc.getSpp().getName(); - _builder.append(_name_30); - _builder.append("_"); - String _name_31 = msg_5.getName(); - _builder.append(_name_31); - _builder.append("(idx"); - _builder.append(data2_4); - _builder.append(") "); - String _portClassName_7 = this._roomExtensions.getPortClassName(svc.getSpp()); - _builder.append(_portClassName_7); - _builder.append("_"); - String _name_32 = msg_5.getName(); - _builder.append(_name_32); - _builder.append("(&self->constData->"); - String _name_33 = svc.getSpp().getName(); - _builder.append(_name_33); - _builder.append(", idx"); - _builder.append(data2_4); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("/* operations */"); - _builder.newLine(); - { - List<StandardOperation> _latestOperations = this._roomHelpers.getLatestOperations(ac); - for(final StandardOperation op : _latestOperations) { - final CharSequence args = this.argList(op); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_34 = op.getName(); - _builder.append(_name_34); - _builder.append("("); - _builder.append(args); - _builder.append(") "); - String _name_35 = ac.getName(); - _builder.append(_name_35); - _builder.append("_"); - String _name_36 = op.getName(); - _builder.append(_name_36); - _builder.append("(self"); - { - boolean _isEmpty_1 = op.getArguments().isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - _builder.append(", "); - _builder.append(args); - } - } - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* attributes */"); - _builder.newLine(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(ac); - for(final Attribute a : _allAttributes) { - _builder.append("#define "); - String _name_37 = a.getName(); - _builder.append(_name_37); - _builder.append(" (self->"); - String _name_38 = a.getName(); - _builder.append(_name_38); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* port operations */"); - _builder.newLine(); - { - for(final InterfaceItem p : portsWithOperations) { - { - EList<PortOperation> _operations = this._roomHelpers.getPortClass(p).getOperations(); - for(final PortOperation op_1 : _operations) { - final CharSequence args_1 = this.argList(op_1); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_39 = p.getName(); - _builder.append(_name_39); - _builder.append("_"); - String _name_40 = op_1.getName(); - _builder.append(_name_40); - _builder.append("("); - _builder.append(args_1); - _builder.append(") "); - String _portClassName_8 = this._roomExtensions.getPortClassName(p); - _builder.append(_portClassName_8); - _builder.append("_"); - String _name_41 = op_1.getName(); - _builder.append(_name_41); - _builder.append("(("); - String _portClassName_9 = this._roomExtensions.getPortClassName(p); - _builder.append(_portClassName_9); - _builder.append("*)&self->constData->"); - String _name_42 = p.getName(); - _builder.append(_name_42); - { - boolean _isEmpty_2 = op_1.getArguments().isEmpty(); - boolean _not_2 = (!_isEmpty_2); - if (_not_2) { - _builder.append(", "); - _builder.append(args_1); - } - } - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(filename); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence argList(final Operation op) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<VarDecl> _arguments = op.getArguments(); - boolean _hasElements = false; - for(final VarDecl a : _arguments) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _name = a.getName(); - _builder.append(_name); - } - } - return _builder; - } - - protected CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - ComponentCommunicationType _commType = ac.getCommType(); - final boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS); - ComponentCommunicationType _commType_1 = ac.getCommType(); - final boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN); - ComponentCommunicationType _commType_2 = ac.getCommType(); - final boolean dataDriven = Objects.equal(_commType_2, ComponentCommunicationType.DATA_DRIVEN); - final boolean handleEvents = (async || eventDriven); - final boolean isEmptyStateGraph = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of ActorClass "); - String _name = ac.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cHeaderFileName = this._cExtensions.getCHeaderFileName(ac); - _builder.append(_cHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"modelbase/etActor.h\""); - _builder.newLine(); - _builder.append("#include \"debugging/etLogger.h\""); - _builder.newLine(); - _builder.append("#include \"debugging/etMSCLogger.h\""); - _builder.newLine(); - _builder.append("#include \"etUnit/etUnit.h\""); - _builder.newLine(); - _builder.append("#include \"base/etMemory.h\""); - _builder.newLine(); - _builder.newLine(); - { - EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac); - for(final ProtocolClass pc : _referencedProtocolClasses) { - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(pc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("#include \""); - String _cUtilsFileName = this._cExtensions.getCUtilsFileName(ac); - _builder.append(_cUtilsFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(ac, 3, true); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* interface item IDs */"); - _builder.newLine(); - String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac); - _builder.append(_genInterfaceItemConstants); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if ((!isEmptyStateGraph)) { - CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac.getGraphContainer()); - _builder.append(_genStateMachine); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("void "); - String _name_1 = ac.getName(); - _builder.append(_name_1); - _builder.append("_init("); - String _name_2 = ac.getName(); - _builder.append(_name_2); - _builder.append("* self){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - String _name_3 = ac.getName(); - _builder.append(_name_3, "\t"); - _builder.append("\", \"init\")"); - _builder.newLineIfNotEmpty(); - { - if ((!isEmptyStateGraph)) { - _builder.append("\t"); - CharSequence _genInitialization = this._stateMachineGen.genInitialization(xpac); - _builder.append(_genInitialization, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - String _name_4 = ac.getName(); - _builder.append(_name_4); - _builder.append("_receiveMessage(void* self, const void* ifitem, const etMessage* msg){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - String _name_5 = ac.getName(); - _builder.append(_name_5, "\t"); - _builder.append("\", \"_receiveMessage\")"); - _builder.newLineIfNotEmpty(); - { - if ((!isEmptyStateGraph)) { - { - if (handleEvents) { - _builder.append("\t"); - String _operationScope = this.langExt.operationScope(ac.getName(), false); - _builder.append(_operationScope, "\t"); - _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - String _operationScope_1 = this.langExt.operationScope(ac.getName(), false); - _builder.append(_operationScope_1, "\t"); - _builder.append("receiveEventInternal(self);"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - if ((dataDriven || async)) { - _builder.append("void "); - String _name_6 = ac.getName(); - _builder.append(_name_6); - _builder.append("_execute("); - String _name_7 = ac.getName(); - _builder.append(_name_7); - _builder.append("* self) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - String _name_8 = ac.getName(); - _builder.append(_name_8, "\t"); - _builder.append("\", \"_execute\")"); - _builder.newLineIfNotEmpty(); - { - if ((!isEmptyStateGraph)) { - _builder.newLine(); - { - if (handleEvents) { - _builder.append("\t"); - String _operationScope_2 = this.langExt.operationScope(ac.getName(), false); - _builder.append(_operationScope_2, "\t"); - _builder.append("receiveEvent(self, NULL, 0, NULL);"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - String _operationScope_3 = this.langExt.operationScope(ac.getName(), false); - _builder.append(_operationScope_3, "\t"); - _builder.append("receiveEventInternal(self);"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - String _userStructorsImplementation = this._procedureHelpers.userStructorsImplementation(ac); - _builder.append(_userStructorsImplementation); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(this._roomHelpers.getLatestOperations(ac), ac.getName()); - _builder.append(_operationsImplementation); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java deleted file mode 100644 index 23e59b4b8..000000000 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java +++ /dev/null @@ -1,760 +0,0 @@ -/** - * Copyright (c) 2010 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * Thomas Schuetz (changed for C code generator) - */ -package org.eclipse.etrice.generator.c.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.common.base.LiteralType; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -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.EnumLiteral; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.ExternalType; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.PrimitiveType; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase; -import org.eclipse.etrice.generator.generic.ILanguageExtension; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.util.Pair; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; - -@Singleton -@SuppressWarnings("all") -public class CExtensions implements ILanguageExtension { - @Inject - protected IDiagnostician diagnostician; - - @Inject - @Extension - protected RoomHelpers _roomHelpers; - - @Override - public String getTypedDataDefinition(final EObject msg) { - String _xifexpression = null; - if ((msg instanceof Message)) { - _xifexpression = this.generateArglistAndTypedData(((Message) msg).getData())[ILanguageExtensionBase.TypedDataKind.DECLARATION_AND_INITIALIZATION.ordinal()]; - } else { - _xifexpression = ""; - } - return _xifexpression; - } - - @Override - public String accessLevelPrivate() { - return "static "; - } - - @Override - public String accessLevelProtected() { - return "static "; - } - - @Override - public String accessLevelPublic() { - return ""; - } - - @Override - public String memberAccess() { - return "self->"; - } - - @Override - public String selfPointer(final String classname, final boolean hasArgs) { - String _xifexpression = null; - if (hasArgs) { - _xifexpression = "* self, "; - } else { - _xifexpression = "* self"; - } - return (classname + _xifexpression); - } - - @Override - public String selfPointer(final boolean hasArgs) { - String _xifexpression = null; - if (hasArgs) { - _xifexpression = "self, "; - } else { - _xifexpression = "self"; - } - return _xifexpression; - } - - @Override - public String scopeSeparator() { - return ""; - } - - @Override - public String operationScope(final String classname, final boolean isDeclaration) { - return (classname + "_"); - } - - @Override - public String memberInDeclaration(final String namespace, final String member) { - return ((namespace + "_") + member); - } - - @Override - public String memberInUse(final String namespace, final String member) { - return ((namespace + "_") + member); - } - - /** - * TODO: move specific code elsewhere - */ - public String getCHeaderFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + ".h"); - } - - public String getCSourceFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + ".c"); - } - - public String getCUtilsFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + "_Utils.h"); - } - - public String getInstSourceFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + "_Inst.h"); - } - - public String getDispSourceFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + "_Disp.h"); - } - - public String getCHeaderFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _name = nr.getName(); - String _plus = (_name + "_"); - String _name_1 = ssi.getName(); - String _plus_1 = (_plus + _name_1); - return (_plus_1 + ".h"); - } - - public String getCSourceFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _name = nr.getName(); - String _plus = (_name + "_"); - String _name_1 = ssi.getName(); - String _plus_1 = (_plus + _name_1); - return (_plus_1 + ".c"); - } - - public String getInstSourceFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _name = nr.getName(); - String _plus = (_name + "_"); - String _name_1 = ssi.getName(); - String _plus_1 = (_plus + _name_1); - return (_plus_1 + "_Inst.h"); - } - - public String getDispSourceFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _name = nr.getName(); - String _plus = (_name + "_"); - String _name_1 = ssi.getName(); - String _plus_1 = (_plus + _name_1); - return (_plus_1 + "_Disp.h"); - } - - public CharSequence getIncludeGuardString(final String filename) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("_"); - String _upperCase = filename.toUpperCase(); - _builder.append(_upperCase); - _builder.append("_H_"); - return _builder; - } - - public CharSequence generateIncludeGuardBegin(final RoomClass rc) { - CharSequence _xblockexpression = null; - { - EObject _eContainer = rc.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "_"); - String _plus = (_replaceAll + "_"); - String _name = rc.getName(); - final String filename = (_plus + _name); - _xblockexpression = this.generateIncludeGuardBegin(filename); - } - return _xblockexpression; - } - - public CharSequence generateIncludeGuardEnd(final RoomClass rc) { - CharSequence _xblockexpression = null; - { - EObject _eContainer = rc.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "_"); - String _plus = (_replaceAll + "_"); - String _name = rc.getName(); - final String filename = (_plus + _name); - _xblockexpression = this.generateIncludeGuardEnd(filename); - } - return _xblockexpression; - } - - public CharSequence generateIncludeGuardBegin(final String filename) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("#ifndef "); - CharSequence _includeGuardString = this.getIncludeGuardString(filename); - _builder.append(_includeGuardString); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename); - _builder.append(_includeGuardString_1); - _builder.newLineIfNotEmpty(); - return _builder; - } - - public CharSequence generateIncludeGuardEnd(final String filename) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("#endif /* "); - CharSequence _includeGuardString = this.getIncludeGuardString(filename); - _builder.append(_includeGuardString); - _builder.append(" */"); - _builder.newLineIfNotEmpty(); - return _builder; - } - - @Override - public boolean usesInheritance() { - return false; - } - - @Override - public boolean usesPointers() { - return true; - } - - @Override - public String genEnumeration(final String name, final List<Pair<String, String>> entries) { - String _xblockexpression = null; - { - boolean _isEmpty = entries.isEmpty(); - if (_isEmpty) { - return "/* empty enum not generated */"; - } - StringConcatenation _builder = new StringConcatenation(); - _builder.append("enum "); - _builder.append(name); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - boolean _hasElements = false; - for(final Pair<String, String> entry : entries) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - String _first = entry.getFirst(); - _builder.append(_first, "\t"); - _builder.append(" = "); - String _second = entry.getSecond(); - _builder.append(_second, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - @Override - public String booleanConstant(final boolean b) { - String _xifexpression = null; - if (b) { - _xifexpression = "ET_TRUE"; - } else { - _xifexpression = "ET_FALSE"; - } - return _xifexpression; - } - - @Override - public String pointerLiteral() { - return "*"; - } - - @Override - public String nullPointer() { - return "NULL"; - } - - @Override - public String voidPointer() { - return "void*"; - } - - @Override - public String arrayType(final String type, final int size, final boolean isRef) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(type); - { - if (isRef) { - _builder.append("*"); - } - } - _builder.newLineIfNotEmpty(); - return _builder.toString(); - } - - @Override - public String arrayDeclaration(final String type, final int size, final boolean isRef, final String name) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(type); - { - if (isRef) { - _builder.append("*"); - } - } - _builder.append(" "); - _builder.append(name); - _builder.append("["); - _builder.append(size); - _builder.append("]"); - _builder.newLineIfNotEmpty(); - return _builder.toString(); - } - - @Override - public String superCall(final String baseClassName, final String method, final String args) { - return ""; - } - - @Override - public String toValueLiteral(final PrimitiveType type, final String value) { - String _switchResult = null; - String _targetName = type.getTargetName(); - boolean _matched = false; - if ((type.getTargetName().equals("char") && (value.length() == 1))) { - _matched=true; - _switchResult = (("\'" + value) + "\'"); - } - if (!_matched) { - LiteralType _type = type.getType(); - boolean _equals = Objects.equal(_type, LiteralType.CHAR); - if (_equals) { - _matched=true; - _switchResult = (("\"" + value) + "\""); - } - } - if (!_matched) { - if ((value.contains(",") || value.contains("{"))) { - _matched=true; - String _xblockexpression = null; - { - String[] singleValues = value.replace("{", "").replace("}", "").trim().split(","); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{ "); - { - boolean _hasElements = false; - for(final String v : singleValues) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _valueLiteral = this.toValueLiteral(type, v.trim()); - _builder.append(_valueLiteral); - } - } - _builder.append(" }"); - _xblockexpression = _builder.toString(); - } - _switchResult = _xblockexpression; - } - } - if (!_matched) { - if (Objects.equal(_targetName, "boolean")) { - _matched=true; - String _xifexpression = null; - boolean _equals_1 = value.equals("true"); - if (_equals_1) { - _xifexpression = "ET_TRUE"; - } else { - _xifexpression = "ET_FALSE"; - } - _switchResult = _xifexpression; - } - } - if (!_matched) { - _switchResult = value; - } - return _switchResult; - } - - @Override - public String toEnumLiteral(final EnumerationType type, final String value) { - String _xifexpression = null; - if ((value.contains(",") || value.contains("{"))) { - String _xblockexpression = null; - { - String[] singleValues = value.replace("{", "").replace("}", "").trim().split(","); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{ "); - { - boolean _hasElements = false; - for(final String v : singleValues) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _convertStringEnumLiteral = this.convertStringEnumLiteral(type, v.trim()); - _builder.append(_convertStringEnumLiteral); - } - } - _builder.append(" }"); - _xblockexpression = _builder.toString(); - } - _xifexpression = _xblockexpression; - } else { - _xifexpression = this.convertStringEnumLiteral(type, value); - } - return _xifexpression; - } - - private String convertStringEnumLiteral(final EnumerationType type, final String value) { - String v = value; - boolean _startsWith = v.startsWith(type.getName()); - if (_startsWith) { - int _length = type.getName().length(); - int _plus = (_length + 1); - v = v.substring(_plus); - } - EList<EnumLiteral> _literals = type.getLiterals(); - for (final EnumLiteral l : _literals) { - boolean _equals = l.getName().equals(v); - if (_equals) { - String _name = type.getName(); - String _plus_1 = (_name + "_"); - String _name_1 = l.getName(); - return (_plus_1 + _name_1); - } - } - return null; - } - - @Override - public String defaultValue(final DataType dt) { - String _switchResult = null; - boolean _matched = false; - if (dt instanceof PrimitiveType) { - _matched=true; - _switchResult = this.toValueLiteral(((PrimitiveType)dt), ((PrimitiveType)dt).getDefaultValueLiteral()); - } - if (!_matched) { - if (dt instanceof EnumerationType) { - _matched=true; - _switchResult = this.getDefaultValue(((EnumerationType)dt)); - } - } - if (!_matched) { - if (dt instanceof ExternalType) { - _matched=true; - String _xblockexpression = null; - { - String _defaultValueLiteral = ((ExternalType)dt).getDefaultValueLiteral(); - boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null)); - if (_notEquals) { - return ((ExternalType)dt).getDefaultValueLiteral(); - } - String _name = ((ExternalType)dt).getName(); - String _plus = ("external type " + _name); - String _plus_1 = (_plus + "has no default initialization"); - this.diagnostician.error(_plus_1, ((ExternalType)dt).eContainer(), ((ExternalType)dt).eContainingFeature()); - _xblockexpression = ""; - } - _switchResult = _xblockexpression; - } - } - if (!_matched) { - if (dt instanceof DataClass) { - _matched=true; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{"); - _builder.newLine(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(((DataClass)dt)); - boolean _hasElements = false; - for(final Attribute att : _allAttributes) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - String _initializationWithDefaultValues = this.initializationWithDefaultValues(att); - _builder.append(_initializationWithDefaultValues, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("}"); - _builder.newLine(); - _switchResult = _builder.toString(); - } - } - return _switchResult; - } - - public String getDefaultValue(final EnumerationType type) { - String _xifexpression = null; - boolean _isEmpty = type.getLiterals().isEmpty(); - if (_isEmpty) { - _xifexpression = ""; - } else { - _xifexpression = this.getCastedValue(type.getLiterals().get(0)); - } - return _xifexpression; - } - - @Override - public String initializationWithDefaultValues(final DataType dt, final int size) { - String _xblockexpression = null; - { - final String dv = this.defaultValue(dt); - _xblockexpression = this.initializer(dv, size); - } - return _xblockexpression; - } - - private String initializer(final String dv, final int size) { - String _xifexpression = null; - if ((size > 1)) { - String _xblockexpression = null; - { - String res = "{"; - int i = 0; - while ((i < size)) { - { - res = (res + dv); - i = (i + 1); - if ((i < size)) { - res = (res + ","); - } - } - } - _xblockexpression = (res + "}"); - } - _xifexpression = _xblockexpression; - } else { - _xifexpression = dv; - } - return _xifexpression; - } - - public String initializationWithDefaultValues(final Attribute att) { - String _xblockexpression = null; - { - final String dv = att.getDefaultValueLiteral(); - String _xifexpression = null; - boolean _notEquals = (!Objects.equal(dv, null)); - if (_notEquals) { - String _xifexpression_1 = null; - boolean _startsWith = dv.startsWith("{"); - if (_startsWith) { - _xifexpression_1 = dv; - } else { - _xifexpression_1 = this.initializer(dv, att.getSize()); - } - _xifexpression = _xifexpression_1; - } else { - String _xifexpression_2 = null; - boolean _isRef = att.getType().isRef(); - if (_isRef) { - _xifexpression_2 = this.initializer("NULL", att.getSize()); - } else { - _xifexpression_2 = this.initializationWithDefaultValues(att.getType().getType(), att.getSize()); - } - _xifexpression = _xifexpression_2; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String[] generateArglistAndTypedData(final EObject d) { - if ((Objects.equal(d, null) || (!(d instanceof VarDecl)))) { - return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class)); - } - final VarDecl data = ((VarDecl) d); - boolean _equals = Objects.equal(data, null); - if (_equals) { - return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class)); - } - String _xifexpression = null; - DataType _type = data.getRefType().getType(); - if ((_type instanceof PrimitiveType)) { - DataType _type_1 = data.getRefType().getType(); - _xifexpression = ((PrimitiveType) _type_1).getTargetName(); - } else { - String _xifexpression_1 = null; - DataType _type_2 = data.getRefType().getType(); - if ((_type_2 instanceof EnumerationType)) { - DataType _type_3 = data.getRefType().getType(); - _xifexpression_1 = this.getTargetType(((EnumerationType) _type_3)); - } else { - String _xifexpression_2 = null; - DataType _type_4 = data.getRefType().getType(); - if ((_type_4 instanceof ExternalType)) { - DataType _type_5 = data.getRefType().getType(); - _xifexpression_2 = ((ExternalType) _type_5).getTargetName(); - } else { - _xifexpression_2 = data.getRefType().getType().getName(); - } - _xifexpression_1 = _xifexpression_2; - } - _xifexpression = _xifexpression_1; - } - String typeName = _xifexpression; - String _xifexpression_3 = null; - DataType _type_6 = data.getRefType().getType(); - if ((_type_6 instanceof PrimitiveType)) { - String _xblockexpression = null; - { - DataType _type_7 = data.getRefType().getType(); - final String ct = ((PrimitiveType) _type_7).getCastName(); - String _xifexpression_4 = null; - if (((!Objects.equal(ct, null)) && (!ct.isEmpty()))) { - _xifexpression_4 = ct; - } else { - _xifexpression_4 = typeName; - } - _xblockexpression = _xifexpression_4; - } - _xifexpression_3 = _xblockexpression; - } else { - String _xifexpression_4 = null; - DataType _type_7 = data.getRefType().getType(); - if ((_type_7 instanceof EnumerationType)) { - DataType _type_8 = data.getRefType().getType(); - _xifexpression_4 = this.getCastType(((EnumerationType) _type_8)); - } else { - _xifexpression_4 = typeName; - } - _xifexpression_3 = _xifexpression_4; - } - String castTypeName = _xifexpression_3; - castTypeName = (castTypeName + "*"); - String deRef = "*"; - final boolean isRef = data.getRefType().isRef(); - final boolean isPrim = ((data.getRefType().getType() instanceof PrimitiveType) || (data.getRefType().getType() instanceof EnumerationType)); - if (isRef) { - typeName = (typeName + "*"); - castTypeName = (castTypeName + "*"); - } else { - if ((!isPrim)) { - typeName = (typeName + "*"); - deRef = ""; - } - } - final String dataArg = (", " + ILanguageExtension.GENERIC_DATA_NAME); - final String typedData = (((((((typeName + " ") + ILanguageExtension.GENERIC_DATA_NAME) + " = ") + deRef) + "((") + castTypeName) + ") generic_data__et);\n"); - final String typedArgList = (((", " + typeName) + " ") + ILanguageExtension.GENERIC_DATA_NAME); - return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(dataArg, typedData, typedArgList), String.class)); - } - - public String getIncludePath(final RoomClass rc) { - EObject _eContainer = rc.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "/"); - String _plus = ("\"" + _replaceAll); - String _plus_1 = (_plus + "/"); - String _cHeaderFileName = this.getCHeaderFileName(rc); - String _plus_2 = (_plus_1 + _cHeaderFileName); - return (_plus_2 + "\""); - } - - public String getUtilsIncludePath(final RoomClass rc) { - EObject _eContainer = rc.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "/"); - String _plus = ("\"" + _replaceAll); - String _plus_1 = (_plus + "/"); - String _cUtilsFileName = this.getCUtilsFileName(rc); - String _plus_2 = (_plus_1 + _cUtilsFileName); - return (_plus_2 + "\""); - } - - @Override - public String getTargetType(final EnumerationType type) { - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = type.getPrimitiveType().getTargetName(); - } else { - _xifexpression = type.getName(); - } - return _xifexpression; - } - - @Override - public String getCastedValue(final EnumLiteral literal) { - String _xblockexpression = null; - { - EObject _eContainer = literal.eContainer(); - final EnumerationType type = ((EnumerationType) _eContainer); - final String cast = this.getTargetType(type); - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _equals = Objects.equal(_primitiveType, null); - if (_equals) { - _xifexpression = Long.toString(literal.getLiteralValue()); - } else { - String _string = Long.toString(literal.getLiteralValue()); - String _plus = ((("((" + cast) + ")") + _string); - _xifexpression = (_plus + ")"); - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String getCastType(final EnumerationType type) { - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = type.getPrimitiveType().getCastName(); - } else { - _xifexpression = type.getName(); - } - return _xifexpression; - } - - @Override - public String makeOverridable() { - return ""; - } -} diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java deleted file mode 100644 index 2dc2a444b..000000000 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java +++ /dev/null @@ -1,388 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - * Thomas Schuetz (changed for C code generator) - */ -package org.eclipse.etrice.generator.c.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -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.EnumerationType; -import org.eclipse.etrice.core.room.Operation; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.StandardOperation; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.c.gen.CExtensions; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@Singleton -@SuppressWarnings("all") -public class DataClassGen { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private CExtensions _cExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private ProcedureHelpers _procedureHelpers; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - EList<DataClass> _dataClasses = root.getDataClasses(); - for (final DataClass dc : _dataClasses) { - { - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc); - String _path = this._roomExtensions.getPath(dc); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(dc); - String _path_1 = this._roomExtensions.getPath(dc); - final String infopath = (_generationInfoPath + _path_1); - String file = this._cExtensions.getCHeaderFileName(dc); - this.fileIO.generateFile("generating DataClass header", path, infopath, file, this.generateHeaderFile(root, dc)); - file = this._cExtensions.getCUtilsFileName(dc); - this.fileIO.generateFile("generating ProtocolClass utils", path, infopath, file, this.generateUtilsFile(root, dc)); - file = this._cExtensions.getCSourceFileName(dc); - this.fileIO.generateFile("generating DataClass source", path, infopath, file, this.generateSourceFile(root, dc)); - } - } - } - - public CharSequence generateHeaderFile(final Root root, final DataClass dc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of DataClass "); - String _name = dc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* "); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(dc); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"etDatatypes.h\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* include all referenced room classes */"); - _builder.newLine(); - { - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc); - EList<EnumerationType> _referencedEnumClasses = root.getReferencedEnumClasses(dc); - final Function1<DataType, String> _function = (DataType it) -> { - return it.getName(); - }; - List<DataType> _sortBy = IterableExtensions.<DataType, String>sortBy(Iterables.<DataType>concat(_referencedDataClasses, _referencedEnumClasses), _function); - for(final DataType rc : _sortBy) { - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(rc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(dc, 1); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.newLine(); - _builder.append("typedef struct {"); - _builder.newLine(); - _builder.append("\t"); - CharSequence _attributes = this._procedureHelpers.attributes(this._roomHelpers.getAllAttributes(dc)); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("} "); - String _name_1 = dc.getName(); - _builder.append(_name_1); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(dc); - for(final Attribute a : _allAttributes) { - { - String _defaultValueLiteral = a.getDefaultValueLiteral(); - boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null)); - if (_notEquals) { - String _name_2 = dc.getName(); - String _plus = (_name_2 + " "); - String _name_3 = a.getName(); - String _plus_1 = (_plus + _name_3); - String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C"); - this.logger.logInfo(_plus_2); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.newLine(); - CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(dc.getOperations(), dc.getName()); - _builder.append(_operationsDeclaration); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* deep copy */"); - _builder.newLine(); - _builder.append("void "); - String _name_4 = dc.getName(); - _builder.append(_name_4); - _builder.append("_deepCopy("); - String _name_5 = dc.getName(); - _builder.append(_name_5); - _builder.append("* source, "); - String _name_6 = dc.getName(); - _builder.append(_name_6); - _builder.append("* target);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2); - _builder.append(_userCode_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(dc); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - return _builder; - } - - private CharSequence generateUtilsFile(final Root root, final DataClass dc) { - CharSequence _xblockexpression = null; - { - EObject _eContainer = dc.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "_"); - String _plus = (_replaceAll + "_"); - String _name = dc.getName(); - String _plus_1 = (_plus + _name); - final String filename = (_plus_1 + "_Utils"); - 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("* Utils File of DataClass "); - String _name_1 = dc.getName(); - _builder.append(_name_1, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* "); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(filename); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(dc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* access macros for operations and attributes"); - _builder.newLine(); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* operations */"); - _builder.newLine(); - { - List<StandardOperation> _allOperations = this._roomHelpers.getAllOperations(dc); - for(final StandardOperation op : _allOperations) { - final CharSequence args = this.argList(op); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name_2 = op.getName(); - _builder.append(_name_2); - _builder.append("("); - _builder.append(args); - _builder.append(") "); - String _name_3 = dc.getName(); - _builder.append(_name_3); - _builder.append("_"); - String _name_4 = op.getName(); - _builder.append(_name_4); - _builder.append("(self"); - { - boolean _isEmpty = op.getArguments().isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append(", "); - _builder.append(args); - } - } - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* attributes */"); - _builder.newLine(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(dc); - for(final Attribute a : _allAttributes) { - _builder.append("#define "); - String _name_5 = a.getName(); - _builder.append(_name_5); - _builder.append(" (self->"); - String _name_6 = a.getName(); - _builder.append(_name_6); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(filename); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence argList(final Operation op) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<VarDecl> _arguments = op.getArguments(); - boolean _hasElements = false; - for(final VarDecl a : _arguments) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _name = a.getName(); - _builder.append(_name); - } - } - return _builder; - } - - public CharSequence generateSourceFile(final Root root, final DataClass dc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of DataClass "); - String _name = dc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* "); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include <string.h>"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cHeaderFileName = this._cExtensions.getCHeaderFileName(dc); - _builder.append(_cHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.append("#include \""); - String _cUtilsFileName = this._cExtensions.getCUtilsFileName(dc); - _builder.append(_cUtilsFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(dc, 3); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.newLine(); - CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(dc.getOperations(), dc.getName()); - _builder.append(_operationsImplementation); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("void "); - String _name_1 = dc.getName(); - _builder.append(_name_1); - _builder.append("_deepCopy("); - String _name_2 = dc.getName(); - _builder.append(_name_2); - _builder.append("* source, "); - String _name_3 = dc.getName(); - _builder.append(_name_3); - _builder.append("* target) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("memcpy(target, source, sizeof("); - String _name_4 = dc.getName(); - _builder.append(_name_4, "\t"); - _builder.append("));"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.newLine(); - return _builder; - } -} diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java deleted file mode 100644 index 9a4e24a41..000000000 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java +++ /dev/null @@ -1,2516 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - * Thomas Schuetz (changed for C code generator) - */ -package org.eclipse.etrice.generator.c.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.common.base.LiteralType; -import org.eclipse.etrice.core.common.converter.TimeConverter; -import org.eclipse.etrice.core.etmap.util.ETMapUtil; -import org.eclipse.etrice.core.etphys.eTPhys.ExecMode; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.etphys.eTPhys.PhysicalThread; -import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.PortInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.GeneralProtocolClass; -import org.eclipse.etrice.core.room.InterfaceItem; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.MessageHandler; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.PrimitiveType; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.SAP; -import org.eclipse.etrice.core.room.SPP; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.c.Main; -import org.eclipse.etrice.generator.c.gen.CExtensions; -import org.eclipse.etrice.generator.c.gen.Initialization; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.fsm.base.IntelligentSeparator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IntegerRange; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@Singleton -@SuppressWarnings("all") -public class NodeGen { - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private CExtensions _cExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private TypeHelpers _typeHelpers; - - @Inject - @Extension - private ProcedureHelpers helpers; - - @Inject - private IGeneratorFileIo fileIO; - - @Inject - private Initialization attrInitGenAddon; - - @Inject - private IDiagnostician diagnostician; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - Collection<NodeRef> _nodeRefs = ETMapUtil.getNodeRefs(); - for (final NodeRef nr : _nodeRefs) { - List<String> _subSystemInstancePaths = ETMapUtil.getSubSystemInstancePaths(nr); - for (final String instpath : _subSystemInstancePaths) { - { - StructureInstance _instance = root.getInstance(instpath); - final SubSystemInstance ssi = ((SubSystemInstance) _instance); - boolean _notEquals = (!Objects.equal(ssi, null)); - if (_notEquals) { - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(ssi.getSubSystemClass()); - String _path = this._roomExtensions.getPath(ssi.getSubSystemClass()); - final String filepath = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(ssi.getSubSystemClass()); - String _path_1 = this._roomExtensions.getPath(ssi.getSubSystemClass()); - final String infopath = (_generationInfoPath + _path_1); - String file = this._cExtensions.getCHeaderFileName(nr, ssi); - this.checkDataPorts(ssi); - final Set<PhysicalThread> usedThreads = ETMapUtil.getUsedThreads(nr, ssi); - this.fileIO.generateFile("generating Node declaration", filepath, infopath, file, this.generateHeaderFile(root, ssi)); - file = this._cExtensions.getCSourceFileName(nr, ssi); - this.fileIO.generateFile("generating Node implementation", filepath, infopath, file, this.generateSourceFile(root, ssi, usedThreads)); - file = this._cExtensions.getInstSourceFileName(nr, ssi); - this.fileIO.generateFile("generating Node instance file", filepath, infopath, file, this.generateInstanceFile(root, ssi, usedThreads)); - file = this._cExtensions.getDispSourceFileName(nr, ssi); - this.fileIO.generateFile("generating Node dispatcher file", filepath, infopath, file, this.generateDispatcherFile(root, ssi, usedThreads)); - } - } - } - } - } - - private CharSequence generateHeaderFile(final Root root, final SubSystemInstance ssi) { - CharSequence _xblockexpression = null; - { - final NodeRef nr = ETMapUtil.getNodeRef(ssi); - final SubSystemClass ssc = ssi.getSubSystemClass(); - String _name = nr.getName(); - String _plus = (_name + "_"); - String _name_1 = ssi.getName(); - final String clsname = (_plus + _name_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of Node "); - String _name_2 = nr.getName(); - _builder.append(_name_2, " "); - _builder.append(" with SubSystem "); - String _name_3 = ssi.getName(); - _builder.append(_name_3, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(clsname); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"etDatatypes.h\""); - _builder.newLine(); - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(ssc.getUserCode1()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* lifecycle functions"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* init -> start -> run (loop) -> stop -> destroy"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_init(void);\t\t/* lifecycle init \t */"); - _builder.newLineIfNotEmpty(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_start(void);\t/* lifecycle start \t */"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_run(etBool runAsTest);\t\t/* lifecycle run \t */"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_stop(void); \t/* lifecycle stop\t */"); - _builder.newLineIfNotEmpty(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_destroy(void); \t/* lifecycle destroy */"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_shutdown(void); /* shutdown the dispatcher loop */"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode_1 = this.helpers.userCode(ssc.getUserCode2()); - _builder.append(_userCode_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(clsname); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateSourceFile(final Root root, final SubSystemInstance ssi, final Collection<PhysicalThread> usedThreads) { - CharSequence _xblockexpression = null; - { - final NodeRef nr = ETMapUtil.getNodeRef(ssi); - final SubSystemClass ssc = ssi.getSubSystemClass(); - String _name = nr.getName(); - String _plus = (_name + "_"); - String _name_1 = ssi.getName(); - final String clsname = (_plus + _name_1); - final Function1<PhysicalThread, Boolean> _function = (PhysicalThread t) -> { - return Boolean.valueOf(usedThreads.contains(t)); - }; - final Iterable<PhysicalThread> threads = IterableExtensions.<PhysicalThread>filter(nr.getType().getThreads(), _function); - final boolean logData = (Main.getSettings().isGenerateDataInstrumentation() && this._roomHelpers.isAnnotationPresent(ssc.getAnnotations(), "DataLogging")); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of Node "); - String _name_2 = nr.getName(); - _builder.append(_name_2, " "); - _builder.append(" with SubSystem "); - String _name_3 = ssi.getName(); - _builder.append(_name_3, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include <stdio.h>"); - _builder.newLine(); - _builder.append("#include <string.h>"); - _builder.newLine(); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cHeaderFileName = this._cExtensions.getCHeaderFileName(nr, ssi); - _builder.append(_cHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"debugging/etLogger.h\""); - _builder.newLine(); - _builder.append("#include \"debugging/etMSCLogger.h\""); - _builder.newLine(); - _builder.append("#include \"debugging/etDataLogger.h\""); - _builder.newLine(); - _builder.append("#include \"messaging/etSystemProtocol.h\""); - _builder.newLine(); - _builder.append("#include \"osal/etTimer.h\""); - _builder.newLine(); - _builder.append("#include \"osal/etSema.h\""); - _builder.newLine(); - _builder.append("#include \"runtime/etRuntime.h\""); - _builder.newLine(); - _builder.append("#include \"etRuntimeConfig.h\""); - _builder.newLine(); - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(ssc.getUserCode3()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* data for Node "); - String _name_4 = nr.getName(); - _builder.append(_name_4); - _builder.append(" with SubSystem "); - String _name_5 = ssi.getName(); - _builder.append(_name_5); - _builder.append(" */"); - _builder.newLineIfNotEmpty(); - _builder.append("typedef struct "); - _builder.append(clsname); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("char *name;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("volatile int shutdownRequest;"); - _builder.newLine(); - _builder.append("} "); - _builder.append(clsname); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("static "); - _builder.append(clsname); - _builder.append(" "); - _builder.append(clsname); - _builder.append("Inst = {\""); - _builder.append(clsname); - _builder.append("\", 0};"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_initActorInstances(void);"); - _builder.newLineIfNotEmpty(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_constructActorInstances(void);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* include instances for all classes */"); - _builder.newLine(); - _builder.append("#include \""); - String _instSourceFileName = this._cExtensions.getInstSourceFileName(nr, ssi); - _builder.append(_instSourceFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.append("#include \""); - String _dispSourceFileName = this._cExtensions.getDispSourceFileName(nr, ssi); - _builder.append(_dispSourceFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_initMessageServices(void) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"initMessageServices\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("etTime interval;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("/* initialization of all message services */"); - _builder.newLine(); - { - final Function1<PhysicalThread, Long> _function_1 = (PhysicalThread it) -> { - long _prio = it.getPrio(); - return Long.valueOf((-_prio)); - }; - List<PhysicalThread> _sortBy = IterableExtensions.<PhysicalThread, Long>sortBy(threads, _function_1); - for(final PhysicalThread thread : _sortBy) { - { - if ((Objects.equal(thread.getExecmode(), ExecMode.POLLED) || Objects.equal(thread.getExecmode(), ExecMode.MIXED))) { - _builder.append("\t\t"); - _builder.append("interval.sec = "); - long _split = TimeConverter.split(thread.getTime(), TimeConverter.SEC, true); - _builder.append(_split, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("interval.nSec = "); - long _split_1 = TimeConverter.split(thread.getTime(), TimeConverter.MILLI_SEC, false); - _builder.append(_split_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("etMessageService_init("); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("&msgService_"); - String _name_6 = thread.getName(); - _builder.append(_name_6, "\t\t\t"); - _builder.append(","); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("msgBuffer_"); - String _name_7 = thread.getName(); - _builder.append(_name_7, "\t\t\t"); - _builder.append(","); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - String _upperCase = thread.getName().toUpperCase(); - _builder.append(_upperCase, "\t\t\t"); - _builder.append("_POOL_SIZE,"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - String _upperCase_1 = thread.getName().toUpperCase(); - _builder.append(_upperCase_1, "\t\t\t"); - _builder.append("_BLOCK_SIZE,"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - int _stacksize = thread.getStacksize(); - _builder.append(_stacksize, "\t\t\t"); - _builder.append(","); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - long _prio = thread.getPrio(); - _builder.append(_prio, "\t\t\t"); - _builder.append(","); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("interval,"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("MsgDispatcher_"); - String _name_8 = thread.getName(); - _builder.append(_name_8, "\t\t\t"); - _builder.append("_receiveMessage,"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("EXECMODE_"); - String _upperCase_2 = thread.getExecmode().toString().toUpperCase(); - _builder.append(_upperCase_2, "\t\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_startMessageServices(void) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"startMessageServices\")"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - final Function1<PhysicalThread, Long> _function_2 = (PhysicalThread it) -> { - long _prio_1 = it.getPrio(); - return Long.valueOf((-_prio_1)); - }; - List<PhysicalThread> _sortBy_1 = IterableExtensions.<PhysicalThread, Long>sortBy(threads, _function_2); - for(final PhysicalThread thread_1 : _sortBy_1) { - _builder.append("\t"); - _builder.append("etMessageService_start(&msgService_"); - String _name_9 = thread_1.getName(); - _builder.append(_name_9, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_stopMessageServices(void) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"stopMessageServices\")"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - for(final PhysicalThread thread_2 : threads) { - _builder.append("\t"); - _builder.append("etMessageService_stop(&msgService_"); - String _name_10 = thread_2.getName(); - _builder.append(_name_10, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_destroyMessageServices(void) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"destroyMessageServices\")"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - for(final PhysicalThread thread_3 : threads) { - _builder.append("\t"); - _builder.append("etMessageService_destroy(&msgService_"); - String _name_11 = thread_3.getName(); - _builder.append(_name_11, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_init(void) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"init\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("etLogger_logInfoF(\"%s_init\", "); - _builder.append(clsname, "\t"); - _builder.append("Inst.name);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* construct all actors */"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("_constructActorInstances();"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* initialization of all message services */"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("_initMessageServices();"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* init all actors */"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("_initActorInstances();"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if (logData) { - { - for(final PhysicalThread thread_4 : threads) { - _builder.append("\t"); - _builder.append("MsgDispatcher_"); - String _name_12 = thread_4.getName(); - _builder.append(_name_12, "\t"); - _builder.append("_logDataHeaders();"); - _builder.newLineIfNotEmpty(); - } - } - { - for(final PhysicalThread thread_5 : threads) { - _builder.append("\t"); - _builder.append("MsgDispatcher_"); - String _name_13 = thread_5.getName(); - _builder.append(_name_13, "\t"); - _builder.append("_logData();"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_start(void) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"start\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("etLogger_logInfoF(\"%s_start\", "); - _builder.append(clsname, "\t"); - _builder.append("Inst.name);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("_startMessageServices();"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_run(etBool runAsTest) {"); - _builder.newLineIfNotEmpty(); - _builder.append("#ifdef ET_RUNNER_ACTIVATE"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"run\")"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("if (runAsTest) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("etSema_waitForWakeup(etRuntime_getTerminateSemaphore());"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("else {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("printf(\"type quit to exit\\n\");"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("fflush(stdout);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("while (ET_TRUE) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("char line[64];"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("if (fgets(line, 64, stdin) != NULL) {"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("if (strncmp(line, \"quit\", 4)==0)"); - _builder.newLine(); - _builder.append("\t\t\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("#endif"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_stop(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"stop\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("etLogger_logInfoF(\"%s_stop\", "); - _builder.append(clsname, "\t"); - _builder.append("Inst.name);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("_stopMessageServices();"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_destroy(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"destroy\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("etLogger_logInfoF(\"%s_destroy\", "); - _builder.append(clsname, "\t"); - _builder.append("Inst.name);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances(); - for(final ActorInstance ai : _allContainedInstances) { - _builder.append("\t"); - ActorClass _actorClass = ai.getActorClass(); - String _pathName = this._roomExtensions.getPathName(ai.getPath()); - String _plus_1 = ("&" + _pathName); - String _invokeUserStructor = this.helpers.invokeUserStructor(_actorClass, _plus_1, false); - _builder.append(_invokeUserStructor, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("_destroyMessageServices();"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("_shutdown(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"shutdown\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("etLogger_logInfoF(\"%s_shutdown\", "); - _builder.append(clsname, "\t"); - _builder.append("Inst.name);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append(clsname, "\t"); - _builder.append("Inst.shutdownRequest = 1;"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_constructActorInstances(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"constructActorInstances\")"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances(); - for(final ActorInstance ai_1 : _allContainedInstances_1) { - _builder.append("\t"); - ActorClass _actorClass_1 = ai_1.getActorClass(); - String _pathName_1 = this._roomExtensions.getPathName(ai_1.getPath()); - String _plus_2 = ("&" + _pathName_1); - String _invokeUserStructor_1 = this.helpers.invokeUserStructor(_actorClass_1, _plus_2, true); - _builder.append(_invokeUserStructor_1, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("static void "); - _builder.append(clsname); - _builder.append("_initActorInstances(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(clsname, "\t"); - _builder.append("\", \"initActorInstances\")"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances(); - for(final ActorInstance ai_2 : _allContainedInstances_2) { - _builder.append("\t"); - String _name_14 = ai_2.getActorClass().getName(); - _builder.append(_name_14, "\t"); - _builder.append("_init(&"); - String _pathName_2 = this._roomExtensions.getPathName(ai_2.getPath()); - _builder.append(_pathName_2, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateInstanceFile(final Root root, final SubSystemInstance ssi, final Collection<PhysicalThread> usedThreads) { - CharSequence _xblockexpression = null; - { - final NodeRef nr = ETMapUtil.getNodeRef(ssi); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Instance File of Node "); - String _name = nr.getName(); - _builder.append(_name, " "); - _builder.append(" with SubSystem "); - String _name_1 = ssi.getName(); - _builder.append(_name_1, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* - instantiation of all actor instances and port instances"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* - configuration of data and connection of ports"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \"messaging/etMessageService.h\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* include all referenced room classes */"); - _builder.newLine(); - { - EList<ActorClass> _referencedActorClasses = root.getReferencedActorClasses(ssi.getSubSystemClass()); - EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ssi.getSubSystemClass()); - final Function1<RoomClass, String> _function = (RoomClass it) -> { - return it.getName(); - }; - List<RoomClass> _sortBy = IterableExtensions.<RoomClass, String>sortBy(Iterables.<RoomClass>concat(_referencedActorClasses, _referencedProtocolClasses), _function); - for(final RoomClass dc : _sortBy) { - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(dc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* instantiation of message services and message buffers */"); - _builder.newLine(); - { - final Function1<PhysicalThread, Boolean> _function_1 = (PhysicalThread t) -> { - return Boolean.valueOf(usedThreads.contains(t)); - }; - Iterable<PhysicalThread> _filter = IterableExtensions.<PhysicalThread>filter(nr.getType().getThreads(), _function_1); - for(final PhysicalThread thread : _filter) { - _builder.append("/* "); - String _name_2 = thread.getName(); - _builder.append(_name_2); - _builder.append(" */"); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _upperCase = thread.getName().toUpperCase(); - _builder.append(_upperCase); - _builder.append("_POOL_SIZE\t\t"); - int _msgpoolsize = thread.getMsgpoolsize(); - _builder.append(_msgpoolsize); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _upperCase_1 = thread.getName().toUpperCase(); - _builder.append(_upperCase_1); - _builder.append("_BLOCK_SIZE\t"); - int _msgblocksize = thread.getMsgblocksize(); - _builder.append(_msgblocksize); - _builder.newLineIfNotEmpty(); - _builder.append("static uint8 msgBuffer_"); - String _name_3 = thread.getName(); - _builder.append(_name_3); - _builder.append("["); - String _upperCase_2 = thread.getName().toUpperCase(); - _builder.append(_upperCase_2); - _builder.append("_POOL_SIZE * "); - String _upperCase_3 = thread.getName().toUpperCase(); - _builder.append(_upperCase_3); - _builder.append("_BLOCK_SIZE];"); - _builder.newLineIfNotEmpty(); - _builder.append("static etMessageService msgService_"); - String _name_4 = thread.getName(); - _builder.append(_name_4); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* declarations of all ActorClass instances (const and variable structs) */"); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* forward declaration of variable actor structs */"); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances(); - for(final ActorInstance ai : _allContainedInstances) { - _builder.append("static "); - String _name_5 = ai.getActorClass().getName(); - _builder.append(_name_5); - _builder.append(" "); - String _pathName = this._roomExtensions.getPathName(ai.getPath()); - _builder.append(_pathName); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* forward declaration of variable port structs */"); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances(); - for(final ActorInstance ai_1 : _allContainedInstances_1) { - { - boolean _isEmpty = ai_1.getOrderedIfItemInstances().isEmpty(); - if (_isEmpty) { - _builder.append("/* nothing to do */"); - _builder.newLine(); - } else { - { - EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances(); - for(final InterfaceItemInstance pi : _orderedIfItemInstances) { - { - PortClass _portClass = this._roomExtensions.getPortClass(pi.getProtocol(), this._roomExtensions.isConjugated(pi)); - EList<Attribute> _attributes = null; - if (_portClass!=null) { - _attributes=_portClass.getAttributes(); - } - int _size = 0; - if (_attributes!=null) { - _size=_attributes.size(); - } - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("static "); - String _portClassName = this._roomExtensions.getPortClassName(pi.getProtocol(), this._roomExtensions.isConjugated(pi)); - _builder.append(_portClassName); - _builder.append("_var "); - String _pathName_1 = this._roomExtensions.getPathName(pi.getPath()); - _builder.append(_pathName_1); - _builder.append("_var"); - { - boolean _isReplicated = pi.isReplicated(); - if (_isReplicated) { - _builder.append("["); - int _size_1 = pi.getPeers().size(); - _builder.append(_size_1); - _builder.append("]"); - } - } - _builder.append("={"); - _builder.newLineIfNotEmpty(); - { - int _xifexpression = (int) 0; - int _size_2 = pi.getPeers().size(); - boolean _equals = (_size_2 == 0); - if (_equals) { - _xifexpression = 1; - } else { - _xifexpression = pi.getPeers().size(); - } - IntegerRange _upTo = new IntegerRange(1, _xifexpression); - boolean _hasElements = false; - for(final Integer i : _upTo) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", "\t"); - } - _builder.append("\t"); - CharSequence _generateAttributeInit = this.attrInitGenAddon.generateAttributeInit(pi, this._roomHelpers.getPortClass(pi.getInterfaceItem()).getAttributes()); - _builder.append(_generateAttributeInit, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t\t\t\t\t"); - } - } - _builder.append("};"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - } - } - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances(); - for(final ActorInstance ai_2 : _allContainedInstances_2) { - _builder.newLine(); - _builder.append("/* instance "); - String _pathName_2 = this._roomExtensions.getPathName(ai_2.getPath()); - _builder.append(_pathName_2); - _builder.append(" */"); - _builder.newLineIfNotEmpty(); - { - if (((!Main.getSettings().isGenerateMSCInstrumentation()) && ai_2.getOrderedIfItemInstances().isEmpty())) { - _builder.append("/* no ports/saps/services - nothing to initialize statically */"); - _builder.newLine(); - } else { - CharSequence _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_2); - _builder.append(_genActorInstanceInitializer); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genActorInstanceInitializer(final Root root, final ActorInstance ai) { - CharSequence _xblockexpression = null; - { - final String instName = this._roomExtensions.getPathName(ai.getPath()); - final ArrayList<InterfaceItemInstance> replEventItems = new ArrayList<InterfaceItemInstance>(); - final Function1<InterfaceItemInstance, Boolean> _function = (InterfaceItemInstance e) -> { - return Boolean.valueOf(e.isReplicated()); - }; - Iterables.<InterfaceItemInstance>addAll(replEventItems, IterableExtensions.<InterfaceItemInstance>filter(ai.getOrderedIfItemInstances(), _function)); - final Function1<InterfaceItemInstance, Boolean> _function_1 = (InterfaceItemInstance e) -> { - boolean _isEmpty = e.getPeers().isEmpty(); - return Boolean.valueOf((!_isEmpty)); - }; - InterfaceItemInstance _findFirst = IterableExtensions.<InterfaceItemInstance>findFirst(replEventItems, _function_1); - final boolean haveReplSubItems = (!Objects.equal(_findFirst, null)); - final Function1<InterfaceItemInstance, Boolean> _function_2 = (InterfaceItemInstance i) -> { - InterfaceItem _interfaceItem = i.getInterfaceItem(); - return Boolean.valueOf((_interfaceItem instanceof Port)); - }; - final Iterable<InterfaceItemInstance> replEventPorts = IterableExtensions.<InterfaceItemInstance>filter(replEventItems, _function_2); - final Function1<InterfaceItemInstance, Boolean> _function_3 = (InterfaceItemInstance i) -> { - InterfaceItem _interfaceItem = i.getInterfaceItem(); - return Boolean.valueOf((_interfaceItem instanceof SPP)); - }; - final Iterable<InterfaceItemInstance> replEventSPPs = IterableExtensions.<InterfaceItemInstance>filter(replEventItems, _function_3); - final Function1<InterfaceItemInstance, Boolean> _function_4 = (InterfaceItemInstance e) -> { - return Boolean.valueOf(e.isSimple()); - }; - final Iterable<InterfaceItemInstance> simplePorts = IterableExtensions.<InterfaceItemInstance>filter(ai.getOrderedIfItemInstances(), _function_4); - final ArrayList<InterfaceItemInstance> simpleEventItems = new ArrayList<InterfaceItemInstance>(); - final Function1<InterfaceItemInstance, Boolean> _function_5 = (InterfaceItemInstance p) -> { - CommunicationType _commType = p.getProtocol().getCommType(); - return Boolean.valueOf(Objects.equal(_commType, CommunicationType.EVENT_DRIVEN)); - }; - Iterables.<InterfaceItemInstance>addAll(simpleEventItems, IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_5)); - final Function1<InterfaceItemInstance, Boolean> _function_6 = (InterfaceItemInstance i) -> { - InterfaceItem _interfaceItem = i.getInterfaceItem(); - return Boolean.valueOf((_interfaceItem instanceof Port)); - }; - final Iterable<InterfaceItemInstance> simpleEventPorts = IterableExtensions.<InterfaceItemInstance>filter(simpleEventItems, _function_6); - final Function1<InterfaceItemInstance, Boolean> _function_7 = (InterfaceItemInstance i) -> { - InterfaceItem _interfaceItem = i.getInterfaceItem(); - return Boolean.valueOf((_interfaceItem instanceof SAP)); - }; - final Iterable<InterfaceItemInstance> simpleEventSAPs = IterableExtensions.<InterfaceItemInstance>filter(simpleEventItems, _function_7); - final Function1<InterfaceItemInstance, Boolean> _function_8 = (InterfaceItemInstance p) -> { - CommunicationType _commType = p.getProtocol().getCommType(); - return Boolean.valueOf(Objects.equal(_commType, CommunicationType.DATA_DRIVEN)); - }; - final Iterable<InterfaceItemInstance> dataPorts = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_8); - final Function1<InterfaceItemInstance, Boolean> _function_9 = (InterfaceItemInstance p) -> { - return Boolean.valueOf(((p instanceof PortInstance) && (!((PortInstance) p).getPort().isConjugated()))); - }; - final Iterable<InterfaceItemInstance> recvPorts = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_9); - final Function1<InterfaceItemInstance, Boolean> _function_10 = (InterfaceItemInstance p) -> { - return Boolean.valueOf(((p instanceof PortInstance) && ((PortInstance) p).getPort().isConjugated())); - }; - final Iterable<InterfaceItemInstance> sendPorts = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_10); - final HashMap<InterfaceItemInstance, Integer> offsets = new HashMap<InterfaceItemInstance, Integer>(); - int offset = 0; - for (final InterfaceItemInstance p : replEventItems) { - { - offsets.put(p, Integer.valueOf(offset)); - int _size = p.getPeers().size(); - int _plus = (offset + _size); - offset = _plus; - } - } - String _xifexpression = null; - if (haveReplSubItems) { - _xifexpression = (instName + "_repl_sub_ports"); - } else { - _xifexpression = "NULL"; - } - String replSubPortsArray = _xifexpression; - final boolean haveConstData = ((((!simpleEventItems.isEmpty()) || (!IterableExtensions.isEmpty(recvPorts))) || (!replEventItems.isEmpty())) || Main.getSettings().isGenerateMSCInstrumentation()); - final IntelligentSeparator sep = new IntelligentSeparator(","); - String _xifexpression_1 = null; - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _xifexpression_1 = "/*const*/"; - } else { - _xifexpression_1 = "const"; - } - final String const_ = _xifexpression_1; - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - CharSequence _genPeerPortArrays = this.genPeerPortArrays(root, ai); - _builder.append(_genPeerPortArrays); - _builder.newLineIfNotEmpty(); - } - } - { - if (haveReplSubItems) { - _builder.append("static const etReplSubPort "); - _builder.append(replSubPortsArray); - _builder.append("["); - _builder.append(offset); - _builder.append("] = {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("/* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */"); - _builder.newLine(); - { - final Function1<InterfaceItemInstance, Boolean> _function_11 = (InterfaceItemInstance e) -> { - boolean _isEmpty = e.getPeers().isEmpty(); - return Boolean.valueOf((!_isEmpty)); - }; - Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(replEventItems, _function_11); - boolean _hasElements = false; - for(final InterfaceItemInstance pi : _filter) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi); - _builder.append(_genReplSubPortInitializers, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - } - } - { - if (haveConstData) { - _builder.append("static "); - _builder.append(const_); - _builder.append(" "); - String _name = ai.getActorClass().getName(); - _builder.append(_name); - _builder.append("_const "); - _builder.append(instName); - _builder.append("_const = {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("\t"); - _builder.append(sep, "\t"); - _builder.append("\""); - String _path = ai.getPath(); - _builder.append(_path, "\t"); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("/* Ports: {varData, msgService, peerAddress, localId} */"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* simple ports */"); - _builder.newLine(); - { - for(final InterfaceItemInstance pi_1 : simpleEventPorts) { - _builder.append("\t"); - _builder.append(sep, "\t"); - String _genPortInitializer = this.genPortInitializer(root, ai, pi_1); - _builder.append(_genPortInitializer, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* data receive ports */"); - _builder.newLine(); - { - for(final InterfaceItemInstance pi_2 : recvPorts) { - _builder.append("\t"); - _builder.append(sep, "\t"); - String _genRecvPortInitializer = this.genRecvPortInitializer(root, ai, pi_2); - _builder.append(_genRecvPortInitializer, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* saps */"); - _builder.newLine(); - { - for(final InterfaceItemInstance pi_3 : simpleEventSAPs) { - _builder.append("\t"); - _builder.append(sep, "\t"); - String _genPortInitializer_1 = this.genPortInitializer(root, ai, pi_3); - _builder.append(_genPortInitializer_1, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* replicated ports */"); - _builder.newLine(); - { - for(final InterfaceItemInstance pi_4 : replEventPorts) { - _builder.append("\t"); - _builder.append(sep, "\t"); - _builder.append("{"); - int _size = pi_4.getPeers().size(); - _builder.append(_size, "\t"); - _builder.append(", "); - _builder.append(replSubPortsArray, "\t"); - _builder.append("+"); - Integer _get = offsets.get(pi_4); - _builder.append(_get, "\t"); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* services */"); - _builder.newLine(); - { - for(final InterfaceItemInstance pi_5 : replEventSPPs) { - _builder.append("\t"); - _builder.append(sep, "\t"); - _builder.append("{"); - int _size_1 = pi_5.getPeers().size(); - _builder.append(_size_1, "\t"); - _builder.append(", "); - _builder.append(replSubPortsArray, "\t"); - _builder.append("+"); - Integer _get_1 = offsets.get(pi_5); - _builder.append(_get_1, "\t"); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - } - } - _builder.append("static "); - String _name_1 = ai.getActorClass().getName(); - _builder.append(_name_1); - _builder.append(" "); - _builder.append(instName); - _builder.append(" = {"); - _builder.newLineIfNotEmpty(); - { - if (haveConstData) { - _builder.append("\t"); - _builder.append("&"); - _builder.append(instName, "\t"); - _builder.append("_const,"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("/* data send ports */"); - _builder.newLine(); - { - for(final InterfaceItemInstance pi_6 : sendPorts) { - _builder.append("\t"); - CharSequence _genSendPortInitializer = this.genSendPortInitializer(pi_6); - _builder.append(_genSendPortInitializer, "\t"); - _builder.append(","); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* attributes */"); - _builder.newLine(); - _builder.append("\t"); - CharSequence _generateAttributeInit = this.attrInitGenAddon.generateAttributeInit(ai, this._roomHelpers.getAllAttributes(ai.getActorClass())); - _builder.append(_generateAttributeInit, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* state and history are initialized in init function */"); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genPeerPortArrays(final Root root, final ActorInstance ai) { - CharSequence _xblockexpression = null; - { - final Function1<InterfaceItemInstance, Boolean> _function = (InterfaceItemInstance e) -> { - return Boolean.valueOf((e.isSimple() && (e instanceof PortInstance))); - }; - final Function1<InterfaceItemInstance, PortInstance> _function_1 = (InterfaceItemInstance inst) -> { - return ((PortInstance) inst); - }; - final Iterable<PortInstance> simplePorts = IterableExtensions.<InterfaceItemInstance, PortInstance>map(IterableExtensions.<InterfaceItemInstance>filter(ai.getOrderedIfItemInstances(), _function), _function_1); - final Function1<PortInstance, Boolean> _function_2 = (PortInstance p) -> { - return Boolean.valueOf((p.getPort().isConjugated() && Objects.equal(p.getProtocol().getCommType(), CommunicationType.DATA_DRIVEN))); - }; - final Iterable<PortInstance> sendPorts = IterableExtensions.<PortInstance>filter(simplePorts, _function_2); - final Function1<PortInstance, Boolean> _function_3 = (PortInstance p) -> { - final Function1<Message, Boolean> _function_4 = (Message m) -> { - return Boolean.valueOf((this._typeHelpers.isEnumeration(m.getData().getRefType().getType()) || this._typeHelpers.isBoolean(m.getData().getRefType().getType()))); - }; - boolean _isEmpty = IterableExtensions.isEmpty(IterableExtensions.<Message>filter(this._roomHelpers.getOutgoing(p.getPort()), _function_4)); - return Boolean.valueOf((!_isEmpty)); - }; - final Iterable<PortInstance> loggedPorts = IterableExtensions.<PortInstance>filter(sendPorts, _function_3); - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isEmpty = IterableExtensions.isEmpty(loggedPorts); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE"); - _builder.newLine(); - { - for(final PortInstance pi : loggedPorts) { - _builder.append("static const char* "); - String _pathName = this._roomExtensions.getPathName(pi.getPath()); - _builder.append(_pathName); - _builder.append("_peers["); - int _size = pi.getPeers().size(); - int _plus = (_size + 1); - _builder.append(_plus); - _builder.append("] = {"); - _builder.newLineIfNotEmpty(); - { - EList<InterfaceItemInstance> _peers = pi.getPeers(); - for(final InterfaceItemInstance peer : _peers) { - _builder.append("\t"); - _builder.append("\""); - EObject _eContainer = peer.eContainer(); - String _path = ((ActorInstance) _eContainer).getPath(); - _builder.append(_path, "\t"); - _builder.append("\","); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("NULL"); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - } - } - _builder.append("#endif"); - _builder.newLine(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String genPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) { - String _xblockexpression = null; - { - int _xifexpression = (int) 0; - boolean _isEmpty = pi.getPeers().isEmpty(); - if (_isEmpty) { - _xifexpression = 0; - } else { - _xifexpression = pi.getPeers().get(0).getObjId(); - } - final int objId = _xifexpression; - int _xifexpression_1 = (int) 0; - boolean _isEmpty_1 = pi.getPeers().isEmpty(); - if (_isEmpty_1) { - _xifexpression_1 = 0; - } else { - _xifexpression_1 = pi.getPeers().get(0).getPeers().indexOf(pi); - } - final int idx = _xifexpression_1; - String _xifexpression_2 = null; - boolean _isEmpty_2 = pi.getPeers().isEmpty(); - if (_isEmpty_2) { - _xifexpression_2 = "NULL"; - } else { - EObject _eContainer = pi.getPeers().get(0).eContainer(); - String _name = ETMapUtil.getMappedThread(((ActorInstance) _eContainer)).getThread().getName(); - _xifexpression_2 = ("&msgService_" + _name); - } - final String msgSvc = _xifexpression_2; - String myInst = ""; - String peerInst = ""; - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - EObject _eContainer_1 = pi.eContainer(); - String _path = ((ActorInstance) _eContainer_1).getPath(); - String _plus = ("\n#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE\n,\"" + _path); - String _plus_1 = (_plus + "\","); - myInst = _plus_1; - String _xifexpression_3 = null; - boolean _isEmpty_3 = pi.getPeers().isEmpty(); - boolean _not = (!_isEmpty_3); - if (_not) { - EObject _eContainer_2 = pi.getPeers().get(0).eContainer(); - String _path_1 = ((ActorInstance) _eContainer_2).getPath(); - String _plus_2 = ("\"" + _path_1); - _xifexpression_3 = (_plus_2 + "\"\n#endif\n"); - } else { - _xifexpression_3 = "\n#endif\n"; - } - peerInst = _xifexpression_3; - } - String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi); - String _plus_3 = ("{" + _interfaceItemInstanceData); - String _plus_4 = (_plus_3 + ", "); - String _plus_5 = (_plus_4 + msgSvc); - String _plus_6 = (_plus_5 + ", "); - String _plus_7 = (_plus_6 + Integer.valueOf((objId + idx))); - String _plus_8 = (_plus_7 + "+BASE_ADDRESS, "); - int _interfaceItemLocalId = root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.getInterfaceItem()); - int _plus_9 = (_interfaceItemLocalId + 1); - String _plus_10 = (_plus_8 + Integer.valueOf(_plus_9)); - String _plus_11 = (_plus_10 + myInst); - String _plus_12 = (_plus_11 + peerInst); - String _plus_13 = (_plus_12 + "} /* Port "); - String _name_1 = pi.getName(); - String _plus_14 = (_plus_13 + _name_1); - _xblockexpression = (_plus_14 + " */"); - } - return _xblockexpression; - } - - private CharSequence genSendPortInitializer(final InterfaceItemInstance pi) { - CharSequence _xblockexpression = null; - { - GeneralProtocolClass _protocol = ((PortInstance) pi).getPort().getProtocol(); - final ProtocolClass pc = ((ProtocolClass) _protocol); - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - Iterable<Message> messages = IterableExtensions.<Message>filter(this._roomHelpers.getAllIncomingMessages(pc), _function); - final Function1<Message, Boolean> _function_1 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isEnumeration(m.getData().getRefType().getType())); - }; - final Iterable<Message> enumMsgs = IterableExtensions.<Message>filter(messages, _function_1); - final Function1<Message, Boolean> _function_2 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isBoolean(m.getData().getRefType().getType())); - }; - final Iterable<Message> boolMsgs = IterableExtensions.<Message>filter(messages, _function_2); - final boolean usesMSC = (Main.getSettings().isGenerateMSCInstrumentation() && (!(IterableExtensions.isEmpty(enumMsgs) && IterableExtensions.isEmpty(boolMsgs)))); - EObject _eContainer = pi.eContainer(); - final String instName = ((ActorInstance) _eContainer).getPath(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{"); - _builder.newLine(); - { - EList<Message> _incomingMessages = pc.getIncomingMessages(); - boolean _hasElements = false; - for(final Message m : _incomingMessages) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - String _defaultValue = this._cExtensions.defaultValue(m.getData().getRefType().getType()); - _builder.append(_defaultValue, "\t"); - _builder.newLineIfNotEmpty(); - } - } - { - if (usesMSC) { - _builder.append("\t"); - _builder.append("#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(", \""); - _builder.append(instName, "\t\t"); - _builder.append("\","); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - String _pathName = this._roomExtensions.getPathName(pi.getPath()); - _builder.append(_pathName, "\t\t"); - _builder.append("_peers"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("#endif"); - _builder.newLine(); - } - } - _builder.append("} /* send port "); - String _name = pi.getName(); - _builder.append(_name); - _builder.append(" */"); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String getInterfaceItemInstanceData(final InterfaceItemInstance pi) { - PortClass _portClass = this._roomExtensions.getPortClass(pi.getProtocol(), this._roomExtensions.isConjugated(pi)); - boolean _equals = Objects.equal(_portClass, null); - if (_equals) { - return "NULL"; - } - boolean _isEmpty = this._roomExtensions.getPortClass(pi.getProtocol(), this._roomExtensions.isConjugated(pi)).getAttributes().isEmpty(); - if (_isEmpty) { - return "NULL"; - } else { - String _pathName = this._roomExtensions.getPathName(pi.getPath()); - String _plus = ("&" + _pathName); - return (_plus + "_var"); - } - } - - private String genRecvPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) { - String _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(this._roomHelpers.getIncoming(pi.getInterfaceItem()), _function); - final Function1<Message, Boolean> _function_1 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isEnumeration(m.getData().getRefType().getType())); - }; - final Iterable<Message> enumMsgs = IterableExtensions.<Message>filter(sentMsgs, _function_1); - final Function1<Message, Boolean> _function_2 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isBoolean(m.getData().getRefType().getType())); - }; - final Iterable<Message> boolMsgs = IterableExtensions.<Message>filter(sentMsgs, _function_2); - final boolean usesMSC = (Main.getSettings().isGenerateMSCInstrumentation() && (!(IterableExtensions.isEmpty(enumMsgs) && IterableExtensions.isEmpty(boolMsgs)))); - String enumVal = ""; - if (usesMSC) { - String _path = ai.getPath(); - String _plus = ("\n, \"" + _path); - String _plus_1 = (_plus + "\""); - enumVal = _plus_1; - for (final Message msg : enumMsgs) { - String _defaultValue = this._cExtensions.defaultValue(msg.getData().getRefType().getType()); - String _plus_2 = ((enumVal + "\n, ") + _defaultValue); - enumVal = _plus_2; - } - for (final Message msg_1 : boolMsgs) { - String _defaultValue_1 = this._cExtensions.defaultValue(msg_1.getData().getRefType().getType()); - String _plus_3 = ((enumVal + "\n, ") + _defaultValue_1); - enumVal = _plus_3; - } - enumVal = (("\n#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE" + enumVal) + "\n#endif\n"); - } - boolean _isEmpty = pi.getPeers().isEmpty(); - if (_isEmpty) { - return (("{NULL" + enumVal) + "}"); - } - InterfaceItemInstance peer = pi.getPeers().get(0); - EObject _eContainer = pi.getPeers().get(0).eContainer(); - ActorInstance peerInst = ((ActorInstance) _eContainer); - String instName = this._roomExtensions.getPathName(peerInst.getPath()); - String _name = peer.getName(); - String _plus_4 = ((("{&" + instName) + ".") + _name); - String _plus_5 = (_plus_4 + enumVal); - _xblockexpression = (_plus_5 + "}"); - } - return _xblockexpression; - } - - private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) { - String result = ""; - String _xifexpression = null; - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - EObject _eContainer = pi.eContainer(); - String _path = ((ActorInstance) _eContainer).getPath(); - String _plus = ("\n#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE\n,\"" + _path); - _xifexpression = (_plus + "\"\n"); - } else { - _xifexpression = ""; - } - final String myInst = _xifexpression; - EList<InterfaceItemInstance> _peers = pi.getPeers(); - for (final InterfaceItemInstance p : _peers) { - { - final int idx = pi.getPeers().indexOf(p); - String _xifexpression_1 = null; - int _size = pi.getPeers().size(); - int _minus = (_size - 1); - boolean _lessThan = (idx < _minus); - if (_lessThan) { - _xifexpression_1 = ","; - } else { - _xifexpression_1 = ""; - } - final String comma = _xifexpression_1; - EObject _eContainer_1 = p.eContainer(); - final String thread = ETMapUtil.getMappedThread(((ActorInstance) _eContainer_1)).getThread().getName(); - String iiiD = this.getInterfaceItemInstanceData(pi); - String _xifexpression_2 = null; - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - EObject _eContainer_2 = p.eContainer(); - String _path_1 = ((ActorInstance) _eContainer_2).getPath(); - String _plus_1 = (",\"" + _path_1); - _xifexpression_2 = (_plus_1 + "\"\n#endif\n"); - } else { - _xifexpression_2 = ""; - } - final String peerInst = _xifexpression_2; - String _xifexpression_3 = null; - boolean _equals = iiiD.equals("NULL"); - if (_equals) { - _xifexpression_3 = (iiiD + ","); - } else { - _xifexpression_3 = (((iiiD + "[") + Integer.valueOf(idx)) + "],"); - } - iiiD = _xifexpression_3; - int _objId = p.getObjId(); - String _plus_2 = ((((((result + - "{{") + iiiD) + "&msgService_") + thread) + ", ") + Integer.valueOf(_objId)); - String _plus_3 = (_plus_2 + "+BASE_ADDRESS, "); - int _interfaceItemLocalId = root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.getInterfaceItem()); - int _plus_4 = (_interfaceItemLocalId + 1); - String _plus_5 = (_plus_3 + Integer.valueOf(_plus_4)); - String _plus_6 = (_plus_5 + myInst); - String _plus_7 = (_plus_6 + peerInst); - String _plus_8 = (_plus_7 + "},"); - String _plus_9 = (_plus_8 + Integer.valueOf(idx)); - String _plus_10 = (_plus_9 + "}"); - String _plus_11 = (_plus_10 + comma); - String _plus_12 = (_plus_11 + " /* Repl Sub Port "); - String _name = pi.getName(); - String _plus_13 = (_plus_12 + _name); - String _plus_14 = (_plus_13 + " idx +"); - String _plus_15 = (_plus_14 + Integer.valueOf(idx)); - String _plus_16 = (_plus_15 + "*/\n"); - result = _plus_16; - } - } - return result; - } - - private CharSequence generateDispatcherFile(final Root root, final SubSystemInstance ssi, final Collection<PhysicalThread> usedThreads) { - CharSequence _xblockexpression = null; - { - final NodeRef nr = ETMapUtil.getNodeRef(ssi); - final boolean logData = (Main.getSettings().isGenerateDataInstrumentation() && this._roomHelpers.isAnnotationPresent(ssi.getSubSystemClass().getAnnotations(), "DataLogging")); - ArrayList<PortInstance> _xifexpression = null; - if (logData) { - _xifexpression = this.loggedPorts(ssi); - } else { - _xifexpression = CollectionLiterals.<PortInstance>newArrayList(); - } - final ArrayList<PortInstance> loggedPorts = _xifexpression; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Dispatcher File of Node "); - String _name = nr.getName(); - _builder.append(_name, " "); - _builder.append(" with SubSystem "); - String _name_1 = ssi.getName(); - _builder.append(_name_1, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* contains a generated message dispatcher (receiveMessage) for each MessageService (Thread)"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \"messaging/etMessageReceiver.h\""); - _builder.newLine(); - _builder.append("#include \"debugging/etLogger.h\""); - _builder.newLine(); - _builder.append("#include \"debugging/etMSCLogger.h\""); - _builder.newLine(); - _builder.newLine(); - { - final Function1<PhysicalThread, Boolean> _function = (PhysicalThread t) -> { - return Boolean.valueOf(usedThreads.contains(t)); - }; - Iterable<PhysicalThread> _filter = IterableExtensions.<PhysicalThread>filter(nr.getType().getThreads(), _function); - boolean _hasElements = false; - for(final PhysicalThread thread : _filter) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate("\n", ""); - } - final Function1<ActorInstance, Boolean> _function_1 = (ActorInstance ai) -> { - PhysicalThread _thread = ETMapUtil.getMappedThread(ai).getThread(); - return Boolean.valueOf(Objects.equal(_thread, thread)); - }; - final Iterable<ActorInstance> instancesOnThread = IterableExtensions.<ActorInstance>filter(ssi.getAllContainedInstances(), _function_1); - _builder.newLineIfNotEmpty(); - final Function1<ActorInstance, Boolean> _function_2 = (ActorInstance ai) -> { - return Boolean.valueOf((Objects.equal(ai.getActorClass().getCommType(), ComponentCommunicationType.EVENT_DRIVEN) || Objects.equal(ai.getActorClass().getCommType(), ComponentCommunicationType.ASYNCHRONOUS))); - }; - final Iterable<ActorInstance> dispatchedInstances = IterableExtensions.<ActorInstance>filter(instancesOnThread, _function_2); - _builder.newLineIfNotEmpty(); - final Function1<ActorInstance, Boolean> _function_3 = (ActorInstance ai) -> { - return Boolean.valueOf((Objects.equal(ai.getActorClass().getCommType(), ComponentCommunicationType.DATA_DRIVEN) || Objects.equal(ai.getActorClass().getCommType(), ComponentCommunicationType.ASYNCHRONOUS))); - }; - final Iterable<ActorInstance> executedInstances = IterableExtensions.<ActorInstance>filter(instancesOnThread, _function_3); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - int _size = IterableExtensions.size(executedInstances); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* generated execute function for all cyclic execute calls for the async or datadriven actor instances of thread \""); - String _name_2 = thread.getName(); - _builder.append(_name_2, " "); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.append("static void MsgDispatcher_"); - String _name_3 = thread.getName(); - _builder.append(_name_3); - _builder.append("_poll(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_"); - String _name_4 = thread.getName(); - _builder.append(_name_4, "\t"); - _builder.append("\", \"execute\")"); - _builder.newLineIfNotEmpty(); - { - for(final ActorInstance ai : executedInstances) { - _builder.append("\t"); - String _name_5 = ai.getActorClass().getName(); - _builder.append(_name_5, "\t"); - _builder.append("_execute((void*)&"); - String _pathName = this._roomExtensions.getPathName(ai.getPath()); - _builder.append(_pathName, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - { - if (logData) { - _builder.append("static void MsgDispatcher_"); - String _name_6 = thread.getName(); - _builder.append(_name_6); - _builder.append("_logDataHeaders(void){"); - _builder.newLineIfNotEmpty(); - { - for(final PortInstance pi : loggedPorts) { - _builder.append("\t"); - _builder.append("ET_DATA_LOGGER_LOG_STRING(\""); - String _path = pi.getPath(); - _builder.append(_path, "\t"); - _builder.append("\")"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.append("static void MsgDispatcher_"); - String _name_7 = thread.getName(); - _builder.append(_name_7); - _builder.append("_logData(void){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_DATA_LOGGER_NEW_ROW"); - _builder.newLine(); - { - for(final PortInstance pi_1 : loggedPorts) { - _builder.append("\t"); - String _createLoggerCall = this.createLoggerCall(pi_1); - _builder.append(_createLoggerCall, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("}"); - _builder.newLine(); - } - } - } - } - _builder.newLine(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* generated dispatch function for all messages for the thread \""); - String _name_8 = thread.getName(); - _builder.append(_name_8, " "); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.append("static etBool MsgDispatcher_"); - String _name_9 = thread.getName(); - _builder.append(_name_9); - _builder.append("_receiveMessage(const etMessage* msg){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_"); - String _name_10 = thread.getName(); - _builder.append(_name_10, "\t"); - _builder.append("\", \"receiveMessage\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("switch(msg->address){"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("case MESSAGESERVICE_ADDRESS:"); - _builder.newLine(); - { - boolean _isEmpty = IterableExtensions.isEmpty(executedInstances); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("\t\t\t"); - _builder.append("if (msg->evtID == etSystemProtocol_IN_poll) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("MsgDispatcher_"); - String _name_11 = thread.getName(); - _builder.append(_name_11, "\t\t\t\t"); - _builder.append("_poll();"); - _builder.newLineIfNotEmpty(); - { - if (logData) { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("MsgDispatcher_"); - String _name_12 = thread.getName(); - _builder.append(_name_12, "\t\t\t\t"); - _builder.append("_logData();"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("else"); - _builder.newLine(); - } - } - _builder.append("\t\t\t"); - _builder.append("if (msg->evtID == etSystemProtocol_IN_terminate)"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("return ET_FALSE;"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - { - for(final ActorInstance ai_1 : dispatchedInstances) { - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("/* interface items of "); - String _path_1 = ai_1.getPath(); - _builder.append(_path_1, "\t\t"); - _builder.append(" */"); - _builder.newLineIfNotEmpty(); - { - final Function1<InterfaceItemInstance, Boolean> _function_4 = (InterfaceItemInstance p) -> { - CommunicationType _commType = p.getProtocol().getCommType(); - return Boolean.valueOf(Objects.equal(_commType, CommunicationType.EVENT_DRIVEN)); - }; - Iterable<InterfaceItemInstance> _filter_1 = IterableExtensions.<InterfaceItemInstance>filter(ai_1.getOrderedIfItemInstances(), _function_4); - for(final InterfaceItemInstance pi_2 : _filter_1) { - { - boolean _isReplicated = pi_2.isReplicated(); - if (_isReplicated) { - { - EList<InterfaceItemInstance> _peers = pi_2.getPeers(); - for(final InterfaceItemInstance peer : _peers) { - _builder.append("\t\t"); - _builder.append("case "); - int _objId = pi_2.getObjId(); - int _indexOf = pi_2.getPeers().indexOf(peer); - int _plus = (_objId + _indexOf); - _builder.append(_plus, "\t\t"); - _builder.append("+BASE_ADDRESS:"); - _builder.newLineIfNotEmpty(); - { - boolean _handlesReceive = this._roomExtensions.handlesReceive(pi_2.getProtocol(), this._roomExtensions.isConjugated(pi_2)); - if (_handlesReceive) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("switch (msg->evtID){"); - _builder.newLine(); - { - List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pi_2.getProtocol(), this._roomExtensions.isConjugated(pi_2)); - for(final MessageHandler h : _receiveHandlers) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("case "); - String _name_13 = pi_2.getProtocol().getName(); - _builder.append(_name_13, "\t\t\t\t"); - _builder.append("_"); - String _codeName = this._roomExtensions.getCodeName(h.getMsg()); - _builder.append(_codeName, "\t\t\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - String _portClassName = this._roomExtensions.getPortClassName(pi_2.getProtocol(), this._roomExtensions.isConjugated(pi_2)); - _builder.append(_portClassName, "\t\t\t\t\t"); - _builder.append("_"); - String _name_14 = h.getMsg().getName(); - _builder.append(_name_14, "\t\t\t\t\t"); - _builder.append("_receiveHandler((etPort *)&"); - String _pathName_1 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_1, "\t\t\t\t\t"); - _builder.append("_const."); - String _name_15 = pi_2.getName(); - _builder.append(_name_15, "\t\t\t\t\t"); - _builder.append(".ports["); - int _indexOf_1 = pi_2.getPeers().indexOf(peer); - _builder.append(_indexOf_1, "\t\t\t\t\t"); - _builder.append("],msg,(void*)&"); - String _pathName_2 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_2, "\t\t\t\t\t"); - _builder.append(","); - String _name_16 = ai_1.getActorClass().getName(); - _builder.append(_name_16, "\t\t\t\t\t"); - _builder.append("_receiveMessage);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("default: "); - String _name_17 = ai_1.getActorClass().getName(); - _builder.append(_name_17, "\t\t\t\t"); - _builder.append("_receiveMessage((void*)&"); - String _pathName_3 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_3, "\t\t\t\t"); - _builder.append(",(etPort*)&"); - String _pathName_4 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_4, "\t\t\t\t"); - _builder.append("_const."); - String _name_18 = pi_2.getName(); - _builder.append(_name_18, "\t\t\t\t"); - _builder.append(".ports["); - int _indexOf_2 = pi_2.getPeers().indexOf(peer); - _builder.append(_indexOf_2, "\t\t\t\t"); - _builder.append("], msg);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_IN("); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - String _pathName_5 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_5, "\t\t\t\t"); - _builder.append("_const."); - String _name_19 = pi_2.getName(); - _builder.append(_name_19, "\t\t\t\t"); - _builder.append(".ports["); - int _indexOf_3 = pi_2.getPeers().indexOf(peer); - _builder.append(_indexOf_3, "\t\t\t\t"); - _builder.append("].port.peerInstName,"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - String _name_20 = pi_2.getProtocol().getName(); - _builder.append(_name_20, "\t\t\t\t"); - _builder.append("_getMessageString(msg->evtID),"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - String _pathName_6 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_6, "\t\t\t\t"); - _builder.append("_const."); - String _name_21 = pi_2.getName(); - _builder.append(_name_21, "\t\t\t\t"); - _builder.append(".ports["); - int _indexOf_4 = pi_2.getPeers().indexOf(peer); - _builder.append(_indexOf_4, "\t\t\t\t"); - _builder.append("].port.myInstName"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(")"); - _builder.newLine(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - String _name_22 = ai_1.getActorClass().getName(); - _builder.append(_name_22, "\t\t\t"); - _builder.append("_receiveMessage((void*)&"); - String _pathName_7 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_7, "\t\t\t"); - _builder.append(",&"); - String _pathName_8 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_8, "\t\t\t"); - _builder.append("_const."); - String _name_23 = pi_2.getName(); - _builder.append(_name_23, "\t\t\t"); - _builder.append(".ports["); - int _indexOf_5 = pi_2.getPeers().indexOf(peer); - _builder.append(_indexOf_5, "\t\t\t"); - _builder.append("].port, msg);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - } else { - _builder.append("\t\t"); - _builder.append("case "); - int _objId_1 = pi_2.getObjId(); - _builder.append(_objId_1, "\t\t"); - _builder.append("+BASE_ADDRESS:"); - _builder.newLineIfNotEmpty(); - { - boolean _handlesReceive_1 = this._roomExtensions.handlesReceive(pi_2.getProtocol(), this._roomExtensions.isConjugated(pi_2)); - if (_handlesReceive_1) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("switch (msg->evtID){"); - _builder.newLine(); - { - List<MessageHandler> _receiveHandlers_1 = this._roomExtensions.getReceiveHandlers(pi_2.getProtocol(), this._roomExtensions.isConjugated(pi_2)); - for(final MessageHandler h_1 : _receiveHandlers_1) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("case "); - String _name_24 = pi_2.getProtocol().getName(); - _builder.append(_name_24, "\t\t\t\t"); - _builder.append("_"); - String _codeName_1 = this._roomExtensions.getCodeName(h_1.getMsg()); - _builder.append(_codeName_1, "\t\t\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - String _portClassName_1 = this._roomExtensions.getPortClassName(pi_2.getProtocol(), this._roomExtensions.isConjugated(pi_2)); - _builder.append(_portClassName_1, "\t\t\t\t\t"); - _builder.append("_"); - String _name_25 = h_1.getMsg().getName(); - _builder.append(_name_25, "\t\t\t\t\t"); - _builder.append("_receiveHandler((etPort *)&"); - String _pathName_9 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_9, "\t\t\t\t\t"); - _builder.append("_const."); - String _name_26 = pi_2.getName(); - _builder.append(_name_26, "\t\t\t\t\t"); - _builder.append(",msg,(void*)&"); - String _pathName_10 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_10, "\t\t\t\t\t"); - _builder.append(","); - String _name_27 = ai_1.getActorClass().getName(); - _builder.append(_name_27, "\t\t\t\t\t"); - _builder.append("_receiveMessage);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("default: "); - String _name_28 = ai_1.getActorClass().getName(); - _builder.append(_name_28, "\t\t\t\t"); - _builder.append("_receiveMessage((void*)&"); - String _pathName_11 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_11, "\t\t\t\t"); - _builder.append(",(etPort*)&"); - String _pathName_12 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_12, "\t\t\t\t"); - _builder.append("_const."); - String _name_29 = pi_2.getName(); - _builder.append(_name_29, "\t\t\t\t"); - _builder.append(", msg);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_IN("); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("((etPort*)&"); - String _pathName_13 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_13, "\t\t\t\t"); - _builder.append("_const."); - String _name_30 = pi_2.getName(); - _builder.append(_name_30, "\t\t\t\t"); - _builder.append(")->peerInstName,"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - String _name_31 = pi_2.getProtocol().getName(); - _builder.append(_name_31, "\t\t\t\t"); - _builder.append("_getMessageString(msg->evtID),"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("((etPort*)&"); - String _pathName_14 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_14, "\t\t\t\t"); - _builder.append("_const."); - String _name_32 = pi_2.getName(); - _builder.append(_name_32, "\t\t\t\t"); - _builder.append(")->myInstName"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(")"); - _builder.newLine(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - String _name_33 = ai_1.getActorClass().getName(); - _builder.append(_name_33, "\t\t\t"); - _builder.append("_receiveMessage((void*)&"); - String _pathName_15 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_15, "\t\t\t"); - _builder.append(",(etPort*)&"); - String _pathName_16 = this._roomExtensions.getPathName(ai_1.getPath()); - _builder.append(_pathName_16, "\t\t\t"); - _builder.append("_const."); - String _name_34 = pi_2.getName(); - _builder.append(_name_34, "\t\t\t"); - _builder.append(", msg);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - } - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("etLogger_logErrorF(\"MessageService_"); - String _name_35 = thread.getName(); - _builder.append(_name_35, "\t\t\t"); - _builder.append("_receiveMessage: address %d does not exist \", msg->address);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("return ET_TRUE;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String createLoggerCall(final PortInstance pi) { - String _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - return Boolean.valueOf(((!Objects.equal(m.getData(), null)) && this._typeHelpers.isEnumerationOrPrimitive(m.getData().getRefType().getType()))); - }; - final Message msg = ((Message[])Conversions.unwrapArray(IterableExtensions.<Message>filter(pi.getProtocol().getIncomingMessages(), _function), Message.class))[0]; - EObject _eContainer = pi.eContainer(); - final ActorInstance ai = ((ActorInstance) _eContainer); - String _pathName = this._roomExtensions.getPathName(ai.getPath()); - String _plus = (_pathName + "."); - String _name = pi.getName(); - String _plus_1 = (_plus + _name); - String _plus_2 = (_plus_1 + "."); - String _name_1 = msg.getName(); - final String data = (_plus_2 + _name_1); - LiteralType _xifexpression = null; - DataType _type = msg.getData().getRefType().getType(); - if ((_type instanceof EnumerationType)) { - _xifexpression = LiteralType.INT; - } else { - DataType _type_1 = msg.getData().getRefType().getType(); - _xifexpression = ((PrimitiveType) _type_1).getType(); - } - final LiteralType type = _xifexpression; - String _switchResult = null; - if (type != null) { - switch (type) { - case BOOL: - _switchResult = (("ET_DATA_LOGGER_LOG_BOOL((int)" + data) + ")"); - break; - case CHAR: - _switchResult = (("ET_DATA_LOGGER_LOG_INT((int)" + data) + ")"); - break; - case INT: - _switchResult = (("ET_DATA_LOGGER_LOG_INT((int)" + data) + ")"); - break; - case REAL: - _switchResult = (("ET_DATA_LOGGER_LOG_DOUBLE((double)" + data) + ")"); - break; - default: - _switchResult = "internal error: unknown primitive type"; - break; - } - } else { - _switchResult = "internal error: unknown primitive type"; - } - _xblockexpression = _switchResult; - } - return _xblockexpression; - } - - private ArrayList<PortInstance> loggedPorts(final SubSystemInstance ssi) { - final ArrayList<PortInstance> result = CollectionLiterals.<PortInstance>newArrayList(); - boolean _isAnnotationPresent = this._roomHelpers.isAnnotationPresent(ssi.getSubSystemClass().getAnnotations(), "DataLogging"); - if (_isAnnotationPresent) { - this.logger.logInfo("Data Logging is configured by annotation"); - final String filters = this._roomHelpers.getAttribute(ssi.getSubSystemClass().getAnnotations(), "DataLogging", "pathlist"); - final String[] filterList = filters.split(","); - for (final String filter : filterList) { - this.logger.logInfo((" filter: " + filter)); - } - final ArrayList<String> notLogged = CollectionLiterals.<String>newArrayList(); - this.logger.logInfo(" logged ports:"); - TreeIterator<EObject> iter = ssi.eAllContents(); - while (iter.hasNext()) { - { - final EObject obj = iter.next(); - if ((obj instanceof PortInstance)) { - final PortInstance pi = ((PortInstance) obj); - boolean _isRelay = this._roomHelpers.isRelay(pi.getPort()); - boolean _not = (!_isRelay); - if (_not) { - CommunicationType _commType = pi.getProtocol().getCommType(); - boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN); - if (_equals) { - boolean _isConjugated = pi.getPort().isConjugated(); - if (_isConjugated) { - final String path = pi.getPath(); - boolean matched = false; - boolean primitive = false; - for (final String filter_1 : filterList) { - boolean _matches = path.matches(filter_1); - if (_matches) { - matched = true; - final Function1<Message, Boolean> _function = (Message m) -> { - return Boolean.valueOf(((!Objects.equal(m.getData(), null)) && this._typeHelpers.isEnumerationOrPrimitive(m.getData().getRefType().getType()))); - }; - boolean _isEmpty = IterableExtensions.isEmpty(IterableExtensions.<Message>filter(pi.getProtocol().getIncomingMessages(), _function)); - boolean _not_1 = (!_isEmpty); - if (_not_1) { - result.add(pi); - primitive = true; - String _path = pi.getPath(); - String _plus = (" data driven port " + _path); - String _plus_1 = (_plus + " (matched "); - String _plus_2 = (_plus_1 + filter_1); - String _plus_3 = (_plus_2 + ")"); - this.logger.logInfo(_plus_3); - } - } - } - if ((!primitive)) { - if (matched) { - String _path_1 = pi.getPath(); - String _plus_4 = (" data driven port " + _path_1); - String _plus_5 = (_plus_4 + " (matched but contains no primitive data)"); - notLogged.add(_plus_5); - } else { - String _path_2 = pi.getPath(); - String _plus_6 = (" data driven port " + _path_2); - String _plus_7 = (_plus_6 + " (no match found)"); - notLogged.add(_plus_7); - } - } - } else { - String _path_3 = pi.getPath(); - String _plus_8 = (" data driven port " + _path_3); - String _plus_9 = (_plus_8 + " (receive port)"); - notLogged.add(_plus_9); - } - } - } - } - } - } - this.logger.logInfo(" NOT logged ports:"); - for (final String nl : notLogged) { - this.logger.logInfo(nl); - } - } - return result; - } - - private void checkDataPorts(final SubSystemInstance comp) { - final HashSet<String> found = new HashSet<String>(); - EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances(); - for (final ActorInstance ai : _allContainedInstances) { - { - final int thread = ai.getThreadId(); - EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances(); - for (final InterfaceItemInstance pi : _orderedIfItemInstances) { - CommunicationType _commType = pi.getProtocol().getCommType(); - boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN); - if (_equals) { - EList<InterfaceItemInstance> _peers = pi.getPeers(); - for (final InterfaceItemInstance peer : _peers) { - { - EObject _eContainer = peer.eContainer(); - final ActorInstance peer_ai = ((ActorInstance) _eContainer); - final int peer_thread = peer_ai.getThreadId(); - if ((thread != peer_thread)) { - final String path = pi.getPath(); - final String ppath = peer.getPath(); - String _xifexpression = null; - int _compareTo = path.compareTo(ppath); - boolean _lessThan = (_compareTo < 0); - if (_lessThan) { - _xifexpression = ((path + " and ") + ppath); - } else { - _xifexpression = ((ppath + " and ") + path); - } - final String pair = _xifexpression; - boolean _contains = found.contains(pair); - boolean _not = (!_contains); - if (_not) { - found.add(pair); - this.diagnostician.error((pair + ": data ports placed on different threads (not supported yet)"), - pi.getInterfaceItem(), pi.getInterfaceItem().eContainingFeature()); - } - } - } - } - } - } - } - } - } -} diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java deleted file mode 100644 index ffe24c515..000000000 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java +++ /dev/null @@ -1,1428 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - * Thomas Schuetz (changed for C code generator) - */ -package org.eclipse.etrice.generator.c.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.MessageHandler; -import org.eclipse.etrice.core.room.Operation; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.PortOperation; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.generator.base.AbstractGenerator; -import org.eclipse.etrice.generator.c.Main; -import org.eclipse.etrice.generator.c.gen.CExtensions; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class ProtocolClassGen extends GenericProtocolClassGenerator { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private CExtensions _cExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private ProcedureHelpers _procedureHelpers; - - @Inject - @Extension - private TypeHelpers _typeHelpers; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - EList<ProtocolClass> _protocolClasses = root.getProtocolClasses(); - for (final ProtocolClass pc : _protocolClasses) { - { - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc); - String _path = this._roomExtensions.getPath(pc); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(pc); - String _path_1 = this._roomExtensions.getPath(pc); - final String infopath = (_generationInfoPath + _path_1); - String file = this._cExtensions.getCHeaderFileName(pc); - this.fileIO.generateFile("generating ProtocolClass header", path, infopath, file, this.generateHeaderFile(root, pc)); - file = this._cExtensions.getCUtilsFileName(pc); - this.fileIO.generateFile("generating ProtocolClass utils", path, infopath, file, this.generateUtilsFile(root, pc)); - file = this._cExtensions.getCSourceFileName(pc); - this.fileIO.generateFile("generating ProtocolClass source", path, infopath, file, this.generateSourceFile(root, pc)); - } - } - } - - private CharSequence generateHeaderFile(final Root root, final ProtocolClass pc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of ProtocolClass "); - String _name = pc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* "); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(pc); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"etDatatypes.h\""); - _builder.newLine(); - _builder.append("#include \"modelbase/etPort.h\""); - _builder.newLine(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(pc, 1); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* include all referenced room classes */"); - _builder.newLine(); - { - EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(pc); - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc); - Iterable<RoomClass> _plus = Iterables.<RoomClass>concat(_referencedProtocolClasses, _referencedDataClasses); - EList<EnumerationType> _referencedEnumClasses = root.getReferencedEnumClasses(pc); - final Function1<RoomClass, String> _function = (RoomClass it) -> { - return it.getName(); - }; - List<RoomClass> _sortBy = IterableExtensions.<RoomClass, String>sortBy(Iterables.<RoomClass>concat(_plus, _referencedEnumClasses), _function); - for(final RoomClass dc : _sortBy) { - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(dc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - CommunicationType _commType = pc.getCommType(); - boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN); - if (_equals) { - _builder.newLine(); - _builder.append("/* message IDs */"); - _builder.newLine(); - String _genMessageIDs = this.genMessageIDs(pc); - _builder.append(_genMessageIDs); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/*--------------------- port structs and methods */"); - _builder.newLine(); - CharSequence _portClassHeader = this.portClassHeader(pc, Boolean.valueOf(false)); - _builder.append(_portClassHeader); - _builder.newLineIfNotEmpty(); - CharSequence _portClassHeader_1 = this.portClassHeader(pc, Boolean.valueOf(true)); - _builder.append(_portClassHeader_1); - _builder.newLineIfNotEmpty(); - } else { - CommunicationType _commType_1 = pc.getCommType(); - boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN); - if (_equals_1) { - _builder.append("/*--------------------- port structs and methods */"); - _builder.newLine(); - CharSequence _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc); - _builder.append(_genDataDrivenPortHeaders); - _builder.newLineIfNotEmpty(); - } else { - CommunicationType _commType_2 = pc.getCommType(); - boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS); - if (_equals_2) { - _builder.append("#error \"synchronoue protocols not implemented yet\""); - _builder.newLine(); - } - } - } - } - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("/*--------------------- debug helpers */"); - _builder.newLine(); - _builder.newLine(); - _builder.append("/* get message string for message id */"); - _builder.newLine(); - _builder.append("const char* "); - String _name_1 = pc.getName(); - _builder.append(_name_1); - _builder.append("_getMessageString(int msg_id);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2); - _builder.append(_userCode_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(pc); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - return _builder; - } - - private CharSequence generateUtilsFile(final Root root, final ProtocolClass pc) { - CharSequence _xblockexpression = null; - { - EObject _eContainer = pc.eContainer(); - String _replaceAll = ((RoomModel) _eContainer).getName().replaceAll("\\.", "_"); - String _plus = (_replaceAll + "_"); - String _name = pc.getName(); - String _plus_1 = (_plus + _name); - final String filename = (_plus_1 + "_Utils"); - 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("* Utils File of ProtocolClass "); - String _name_1 = pc.getName(); - _builder.append(_name_1, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* "); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(filename); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - ProtocolClass _base = pc.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - _builder.append("// include base class utils"); - _builder.newLine(); - _builder.append("#include "); - String _utilsIncludePath = this._cExtensions.getUtilsIncludePath(pc.getBase()); - _builder.append(_utilsIncludePath); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _builder.append("#include "); - String _includePath = this._cExtensions.getIncludePath(pc); - _builder.append(_includePath); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* access macros for operations and attributes"); - _builder.newLine(); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateUtilsFile = this.generateUtilsFile(pc, false); - _builder.append(_generateUtilsFile); - _builder.newLineIfNotEmpty(); - CharSequence _generateUtilsFile_1 = this.generateUtilsFile(pc, true); - _builder.append(_generateUtilsFile_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(filename); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateUtilsFile(final ProtocolClass pc, final boolean conj) { - CharSequence _xblockexpression = null; - { - final PortClass portClass = this._roomExtensions.getPortClass(pc, conj); - final String portClassName = this._roomExtensions.getPortClassName(pc, conj); - StringConcatenation _builder = new StringConcatenation(); - { - boolean _notEquals = (!Objects.equal(portClass, null)); - if (_notEquals) { - _builder.append("/* "); - { - if (conj) { - _builder.append("conjugate"); - } else { - _builder.append("regular"); - } - } - _builder.append(" port class */"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* operations */"); - _builder.newLine(); - { - EList<PortOperation> _operations = portClass.getOperations(); - for(final PortOperation op : _operations) { - final CharSequence args = this.argList(op); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _name = op.getName(); - _builder.append(_name); - _builder.append("("); - _builder.append(args); - _builder.append(") "); - _builder.append(portClassName); - _builder.append("_"); - String _name_1 = op.getName(); - _builder.append(_name_1); - _builder.append("(self"); - { - boolean _isEmpty = op.getArguments().isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append(", "); - _builder.append(args); - } - } - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* attributes */"); - _builder.newLine(); - { - EList<Attribute> _attributes = portClass.getAttributes(); - for(final Attribute a : _attributes) { - _builder.append("#define "); - String _name_2 = a.getName(); - _builder.append(_name_2); - _builder.append(" ((("); - _builder.append(portClassName); - _builder.append("_var*)(self->varData))->"); - String _name_3 = a.getName(); - _builder.append(_name_3); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence argList(final Operation op) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<VarDecl> _arguments = op.getArguments(); - boolean _hasElements = false; - for(final VarDecl a : _arguments) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _name = a.getName(); - _builder.append(_name); - } - } - return _builder; - } - - private CharSequence generateSourceFile(final Root root, final ProtocolClass pc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of ProtocolClass "); - String _name = pc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("* "); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cHeaderFileName = this._cExtensions.getCHeaderFileName(pc); - _builder.append(_cHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.append("#include \"debugging/etMSCLogger.h\""); - _builder.newLine(); - _builder.append("#include \""); - String _cUtilsFileName = this._cExtensions.getCUtilsFileName(pc); - _builder.append(_cUtilsFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(pc, 3); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/*--------------------- port methods */"); - _builder.newLine(); - { - CommunicationType _commType = pc.getCommType(); - boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN); - if (_equals) { - CharSequence _portClassSource = this.portClassSource(pc, Boolean.valueOf(false)); - _builder.append(_portClassSource); - _builder.newLineIfNotEmpty(); - CharSequence _portClassSource_1 = this.portClassSource(pc, Boolean.valueOf(true)); - _builder.append(_portClassSource_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("/*--------------------- debug helpers */"); - _builder.newLine(); - CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc); - _builder.append(_generateDebugHelpersImplementation); - _builder.newLineIfNotEmpty(); - } - } - } else { - CommunicationType _commType_1 = pc.getCommType(); - boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN); - if (_equals_1) { - CharSequence _genDataDrivenPortSources = this.genDataDrivenPortSources(pc); - _builder.append(_genDataDrivenPortSources); - _builder.newLineIfNotEmpty(); - } else { - CommunicationType _commType_2 = pc.getCommType(); - boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS); - if (_equals_2) { - _builder.append("#error \"synchronous protocols not implemented yet\""); - _builder.newLine(); - } - } - } - } - return _builder; - } - - private CharSequence portClassHeader(final ProtocolClass pc, final Boolean conj) { - CharSequence _xblockexpression = null; - { - String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue()); - String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true); - List<Message> _xifexpression = null; - if ((conj).booleanValue()) { - _xifexpression = this._roomHelpers.getAllIncomingMessages(pc); - } else { - _xifexpression = this._roomHelpers.getAllOutgoingMessages(pc); - } - List<Message> messages = _xifexpression; - final List<PortClass> allPortClasses = this._roomExtensions.getAllPortClasses(pc, (conj).booleanValue()); - final Function1<PortClass, EList<Attribute>> _function = (PortClass p) -> { - return p.getAttributes(); - }; - final List<Attribute> allAttributes = IterableExtensions.<Attribute>toList(Iterables.<Attribute>concat(ListExtensions.<PortClass, EList<Attribute>>map(allPortClasses, _function))); - final Function1<PortClass, EList<PortOperation>> _function_1 = (PortClass p) -> { - return p.getOperations(); - }; - final List<PortOperation> allOperations = IterableExtensions.<PortOperation>toList(Iterables.<PortOperation>concat(ListExtensions.<PortClass, EList<PortOperation>>map(allPortClasses, _function_1))); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("typedef etPort "); - _builder.append(portClassName); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("typedef etReplPort "); - _builder.append(replPortClassName); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - boolean _isEmpty = allAttributes.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("/* variable part of PortClass (RAM) */"); - _builder.newLine(); - _builder.append("typedef struct "); - _builder.append(portClassName); - _builder.append("_var "); - _builder.append(portClassName); - _builder.append("_var; "); - _builder.newLineIfNotEmpty(); - _builder.append("struct "); - _builder.append(portClassName); - _builder.append("_var {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _attributes = this._procedureHelpers.attributes(allAttributes); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("};"); - _builder.newLine(); - { - for(final Attribute a : allAttributes) { - { - String _defaultValueLiteral = a.getDefaultValueLiteral(); - boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null)); - if (_notEquals) { - String _name = a.getName(); - String _plus = ((portClassName + " ") + _name); - String _plus_1 = (_plus + ": Attribute initialization not supported in C"); - this.logger.logInfo(_plus_1); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - _builder.newLine(); - { - for(final Message message : messages) { - VarDecl _data = message.getData(); - boolean hasData = (!Objects.equal(_data, null)); - _builder.newLineIfNotEmpty(); - String _xifexpression_1 = null; - if (hasData) { - _xifexpression_1 = this._typeHelpers.typeName(message.getData().getRefType().getType()); - } else { - _xifexpression_1 = ""; - } - String typeName = _xifexpression_1; - _builder.newLineIfNotEmpty(); - String _xifexpression_2 = null; - if ((hasData && ((!this._typeHelpers.isEnumerationOrPrimitive(message.getData().getRefType().getType())) || message.getData().getRefType().isRef()))) { - _xifexpression_2 = "*"; - } else { - _xifexpression_2 = ""; - } - String refp = _xifexpression_2; - _builder.newLineIfNotEmpty(); - String _xifexpression_3 = null; - if (hasData) { - _xifexpression_3 = (((", " + typeName) + refp) + " data"); - } else { - _xifexpression_3 = ""; - } - String data = _xifexpression_3; - _builder.newLineIfNotEmpty(); - String _messageSignature = this.messageSignature(portClassName, message.getName(), "", data); - _builder.append(_messageSignature); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - String _messageSignature_1 = this.messageSignature(replPortClassName, message.getName(), "_broadcast", data); - _builder.append(_messageSignature_1); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - String _messageSignature_2 = this.messageSignature(replPortClassName, message.getName(), "", (", int idx" + data)); - _builder.append(_messageSignature_2); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - boolean _isEmpty_1 = allOperations.isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(allOperations, portClassName); - _builder.append(_operationsDeclaration); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - boolean _handlesReceiveIncludingSuper = this._roomExtensions.handlesReceiveIncludingSuper(pc, (conj).booleanValue()); - if (_handlesReceiveIncludingSuper) { - { - List<MessageHandler> _receiveHandlersIncludingSuper = this._roomExtensions.getReceiveHandlersIncludingSuper(pc, (conj).booleanValue()); - for(final MessageHandler h : _receiveHandlersIncludingSuper) { - _builder.append("void "); - _builder.append(portClassName); - _builder.append("_"); - String _name_1 = h.getMsg().getName(); - _builder.append(_name_1); - _builder.append("_receiveHandler("); - _builder.append(portClassName); - _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("etInt32 "); - _builder.append(replPortClassName); - _builder.append("_getReplication(const "); - _builder.append(replPortClassName); - _builder.append("* self);"); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genDataDrivenPortHeaders(final ProtocolClass pc) { - CharSequence _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(this._roomHelpers.getAllIncomingMessages(pc), _function); - final Function1<Message, Boolean> _function_1 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isEnumeration(m.getData().getRefType().getType())); - }; - final Iterable<Message> enumMsgs = IterableExtensions.<Message>filter(sentMsgs, _function_1); - final Function1<Message, Boolean> _function_2 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isBoolean(m.getData().getRefType().getType())); - }; - final Iterable<Message> boolMsgs = IterableExtensions.<Message>filter(sentMsgs, _function_2); - final boolean usesMSC = (Main.getSettings().isGenerateMSCInstrumentation() && (!(IterableExtensions.isEmpty(enumMsgs) && IterableExtensions.isEmpty(boolMsgs)))); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* data driven send port (conjugated) */"); - _builder.newLine(); - _builder.append("typedef struct "); - String _portClassName = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - for(final Message msg : sentMsgs) { - _builder.append("\t"); - String typeName = this._typeHelpers.typeName(msg.getData().getRefType().getType()); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _xifexpression = null; - boolean _isRef = msg.getData().getRefType().isRef(); - if (_isRef) { - _xifexpression = "*"; - } else { - _xifexpression = ""; - } - String refp = _xifexpression; - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append(typeName, "\t"); - _builder.append(refp, "\t"); - _builder.append(" "); - String _name = msg.getName(); - _builder.append(_name, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - { - if (usesMSC) { - _builder.append("\t"); - _builder.append("#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("const char* instName;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("const char** peerNames;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("#endif"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - String _portClassName_1 = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName_1); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* data driven receive port (regular) */"); - _builder.newLine(); - _builder.append("typedef struct "); - String _portClassName_2 = this._roomExtensions.getPortClassName(pc, false); - _builder.append(_portClassName_2); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("const "); - String _portClassName_3 = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName_3, "\t"); - _builder.append("* peer;"); - _builder.newLineIfNotEmpty(); - { - if (usesMSC) { - _builder.append("\t"); - _builder.append("#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("const char* instName;"); - _builder.newLine(); - { - for(final Message msg_1 : enumMsgs) { - _builder.append("\t"); - _builder.append("\t"); - String typeName_1 = this._typeHelpers.typeName(msg_1.getData().getRefType().getType()); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - String _xifexpression_1 = null; - boolean _isRef_1 = msg_1.getData().getRefType().isRef(); - if (_isRef_1) { - _xifexpression_1 = "*"; - } else { - _xifexpression_1 = ""; - } - String refp_1 = _xifexpression_1; - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(typeName_1, "\t\t"); - _builder.append(refp_1, "\t\t"); - _builder.append(" "); - String _name_1 = msg_1.getName(); - _builder.append(_name_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - { - for(final Message msg_2 : boolMsgs) { - _builder.append("\t"); - _builder.append("\t"); - String typeName_2 = this._typeHelpers.typeName(msg_2.getData().getRefType().getType()); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - String _xifexpression_2 = null; - boolean _isRef_2 = msg_2.getData().getRefType().isRef(); - if (_isRef_2) { - _xifexpression_2 = "*"; - } else { - _xifexpression_2 = ""; - } - String refp_2 = _xifexpression_2; - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(typeName_2, "\t\t"); - _builder.append(refp_2, "\t\t"); - _builder.append(" "); - String _name_2 = msg_2.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("#endif"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - String _portClassName_4 = this._roomExtensions.getPortClassName(pc, false); - _builder.append(_portClassName_4); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - for(final Message message : sentMsgs) { - VarDecl _data = message.getData(); - boolean hasData = (!Objects.equal(_data, null)); - _builder.newLineIfNotEmpty(); - String _xifexpression_3 = null; - if (hasData) { - _xifexpression_3 = this._typeHelpers.typeName(message.getData().getRefType().getType()); - } else { - _xifexpression_3 = ""; - } - String typeName_3 = _xifexpression_3; - _builder.newLineIfNotEmpty(); - String _xifexpression_4 = null; - if ((hasData && (!this._typeHelpers.isEnumerationOrPrimitive(message.getData().getRefType().getType())))) { - _xifexpression_4 = "*"; - } else { - _xifexpression_4 = ""; - } - String refp_3 = _xifexpression_4; - _builder.newLineIfNotEmpty(); - String _xifexpression_5 = null; - if (hasData) { - _xifexpression_5 = (((", " + typeName_3) + refp_3) + " data"); - } else { - _xifexpression_5 = ""; - } - String data = _xifexpression_5; - _builder.newLineIfNotEmpty(); - String _messageSetterSignature = this.messageSetterSignature(this._roomExtensions.getPortClassName(pc, true), message.getName(), data); - _builder.append(_messageSetterSignature); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - String _messageGetterSignature = this.messageGetterSignature(this._roomExtensions.getPortClassName(pc, false), message.getName(), typeName_3); - _builder.append(_messageGetterSignature); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genDataDrivenPortSources(final ProtocolClass pc) { - CharSequence _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - Iterable<Message> messages = IterableExtensions.<Message>filter(this._roomHelpers.getAllIncomingMessages(pc), _function); - final Function1<Message, Boolean> _function_1 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isEnumeration(m.getData().getRefType().getType())); - }; - final Iterable<Message> enumMsgs = IterableExtensions.<Message>filter(messages, _function_1); - final Function1<Message, Boolean> _function_2 = (Message m) -> { - return Boolean.valueOf(this._typeHelpers.isBoolean(m.getData().getRefType().getType())); - }; - final Iterable<Message> boolMsgs = IterableExtensions.<Message>filter(messages, _function_2); - final boolean usesMSC = (Main.getSettings().isGenerateMSCInstrumentation() && (!(IterableExtensions.isEmpty(enumMsgs) && IterableExtensions.isEmpty(boolMsgs)))); - StringConcatenation _builder = new StringConcatenation(); - { - for(final Message message : messages) { - String typeName = this._typeHelpers.typeName(message.getData().getRefType().getType()); - _builder.newLineIfNotEmpty(); - String _xifexpression = null; - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(message.getData().getRefType().getType()); - boolean _not = (!_isEnumerationOrPrimitive); - if (_not) { - _xifexpression = "*"; - } else { - _xifexpression = ""; - } - String refp = _xifexpression; - _builder.newLineIfNotEmpty(); - String data = (((", " + typeName) + refp) + " data"); - _builder.newLineIfNotEmpty(); - String _messageSetterSignature = this.messageSetterSignature(this._roomExtensions.getPortClassName(pc, true), message.getName(), data); - _builder.append(_messageSetterSignature); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - if ((usesMSC && IterableExtensions.<Message>exists(enumMsgs, ((Function1<Message, Boolean>) (Message m) -> { - return Boolean.valueOf(Objects.equal(m, message)); - })))) { - _builder.append("\t"); - _builder.append("#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("const char** peerName;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("for (peerName=self->peerNames; *peerName!=NULL; ++peerName) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_OUT(self->instName, "); - String _name = message.getData().getRefType().getType().getName(); - _builder.append(_name, "\t\t\t\t"); - _builder.append("_getLiteralName(data), *peerName)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t\t\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_IN(self->instName, "); - String _name_1 = message.getData().getRefType().getType().getName(); - _builder.append(_name_1, "\t\t\t\t"); - _builder.append("_getLiteralName(data), *peerName)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("#endif"); - _builder.newLine(); - } - } - { - if ((usesMSC && IterableExtensions.<Message>exists(boolMsgs, ((Function1<Message, Boolean>) (Message m) -> { - return Boolean.valueOf(Objects.equal(m, message)); - })))) { - _builder.append("\t"); - _builder.append("#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("const char** peerName;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("for (peerName=self->peerNames; *peerName!=NULL; ++peerName) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_OUT(self->instName, data?\"true\":\"false\", *peerName)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_IN(self->instName, data?\"true\":\"false\", *peerName)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("#endif"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("self->"); - String _name_2 = message.getName(); - _builder.append(_name_2, "\t"); - _builder.append(" = "); - _builder.append(refp, "\t"); - _builder.append("data;"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - String _messageGetterSignature = this.messageGetterSignature(this._roomExtensions.getPortClassName(pc, false), message.getName(), typeName); - _builder.append(_messageGetterSignature); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return self->peer->"); - String _name_3 = message.getName(); - _builder.append(_name_3, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence portClassSource(final ProtocolClass pc, final Boolean conj) { - CharSequence _xblockexpression = null; - { - final List<PortClass> allPortClasses = this._roomExtensions.getAllPortClasses(pc, (conj).booleanValue()); - final String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue()); - final String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true); - List<Message> _xifexpression = null; - if ((conj).booleanValue()) { - _xifexpression = this._roomHelpers.getAllIncomingMessages(pc); - } else { - _xifexpression = this._roomHelpers.getAllOutgoingMessages(pc); - } - final List<Message> messages = _xifexpression; - String _xifexpression_1 = null; - if ((conj).booleanValue()) { - _xifexpression_1 = "IN_"; - } else { - _xifexpression_1 = "OUT_"; - } - final String dir = _xifexpression_1; - StringConcatenation _builder = new StringConcatenation(); - { - for(final Message message : messages) { - VarDecl _data = message.getData(); - boolean hasData = (!Objects.equal(_data, null)); - _builder.newLineIfNotEmpty(); - String _xifexpression_2 = null; - if (hasData) { - _xifexpression_2 = this._typeHelpers.typeName(message.getData().getRefType().getType()); - } else { - _xifexpression_2 = ""; - } - String typeName = _xifexpression_2; - _builder.newLineIfNotEmpty(); - String _xifexpression_3 = null; - if ((hasData && message.getData().getRefType().isRef())) { - _xifexpression_3 = "*"; - } else { - _xifexpression_3 = ""; - } - String refp = _xifexpression_3; - _builder.newLineIfNotEmpty(); - String _xifexpression_4 = null; - if ((hasData && ((!this._typeHelpers.isEnumerationOrPrimitive(message.getData().getRefType().getType())) || message.getData().getRefType().isRef()))) { - _xifexpression_4 = "*"; - } else { - _xifexpression_4 = ""; - } - String refpd = _xifexpression_4; - _builder.newLineIfNotEmpty(); - String _xifexpression_5 = null; - if (((hasData && (!this._typeHelpers.isEnumerationOrPrimitive(message.getData().getRefType().getType()))) && (!message.getData().getRefType().isRef()))) { - _xifexpression_5 = ""; - } else { - _xifexpression_5 = "&"; - } - String refa = _xifexpression_5; - _builder.newLineIfNotEmpty(); - String _xifexpression_6 = null; - if (hasData) { - _xifexpression_6 = (((", " + typeName) + refpd) + " data__et"); - } else { - _xifexpression_6 = ""; - } - String data = _xifexpression_6; - _builder.newLineIfNotEmpty(); - String _xifexpression_7 = null; - if (hasData) { - _xifexpression_7 = ", data__et"; - } else { - _xifexpression_7 = ""; - } - String dataCall = _xifexpression_7; - _builder.newLineIfNotEmpty(); - MessageHandler hdlr = this._roomExtensions.getSendHandler(message, (conj).booleanValue()); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _messageSignature = this.messageSignature(portClassName, message.getName(), "", data); - _builder.append(_messageSignature); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - boolean _notEquals = (!Objects.equal(hdlr, null)); - if (_notEquals) { - _builder.append("\t"); - String _translatedCode = AbstractGenerator.getInstance().getTranslatedCode(hdlr.getDetailCode()); - _builder.append(_translatedCode, "\t"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(portClassName, "\t"); - _builder.append("\", \""); - String _name = message.getName(); - _builder.append(_name, "\t"); - _builder.append("\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - String _name_1 = pc.getName(); - String _name_2 = message.getName(); - String _plus = (dir + _name_2); - String _sendMessageCall = this.sendMessageCall(hasData, "self", this._cExtensions.memberInUse(_name_1, _plus), (typeName + refp), (refa + "data__et")); - _builder.append(_sendMessageCall, "\t\t"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, \""); - String _name_3 = message.getName(); - _builder.append(_name_3, "\t\t"); - _builder.append("\", self->peerInstName)"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - String _messageSignature_1 = this.messageSignature(replPortClassName, message.getName(), "_broadcast", data); - _builder.append(_messageSignature_1); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - boolean _notEquals_1 = (!Objects.equal(hdlr, null)); - if (_notEquals_1) { - _builder.append("\t"); - _builder.append("int i;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(portClassName, "\t\t"); - _builder.append("_"); - String _name_4 = message.getName(); - _builder.append(_name_4, "\t\t"); - _builder.append("(&((etReplPort*)self)->ports[i].port"); - _builder.append(dataCall, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}\t\t\t\t\t"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("int i;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(replPortClassName, "\t"); - _builder.append("\", \""); - String _name_5 = message.getName(); - _builder.append(_name_5, "\t"); - _builder.append("\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - String _name_6 = pc.getName(); - String _name_7 = message.getName(); - String _plus_1 = (dir + _name_7); - String _sendMessageCall_1 = this.sendMessageCall(hasData, "(&((etReplPort*)self)->ports[i].port)", this._cExtensions.memberInUse(_name_6, _plus_1), (typeName + refp), (refa + "data__et")); - _builder.append(_sendMessageCall_1, "\t\t"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, \""); - String _name_8 = message.getName(); - _builder.append(_name_8, "\t\t"); - _builder.append("\", ((etReplPort*)self)->ports[i].port.peerInstName)"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - String _messageSignature_2 = this.messageSignature(replPortClassName, message.getName(), "", (", int idx__et" + data)); - _builder.append(_messageSignature_2); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - boolean _notEquals_2 = (!Objects.equal(hdlr, null)); - if (_notEquals_2) { - _builder.append("\t"); - _builder.append(portClassName, "\t"); - _builder.append("_"); - String _name_9 = message.getName(); - _builder.append(_name_9, "\t"); - _builder.append("(&((etReplPort*)self)->ports[idx__et].port"); - _builder.append(dataCall, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\""); - _builder.append(replPortClassName, "\t"); - _builder.append("\", \""); - String _name_10 = message.getName(); - _builder.append(_name_10, "\t"); - _builder.append("\")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if (0<=idx__et && idx__et<((etReplPort*)self)->size) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - String _name_11 = pc.getName(); - String _name_12 = message.getName(); - String _plus_2 = (dir + _name_12); - String _sendMessageCall_2 = this.sendMessageCall(hasData, "(&((etReplPort*)self)->ports[idx__et].port)", this._cExtensions.memberInUse(_name_11, _plus_2), (typeName + refp), (refa + "data__et")); - _builder.append(_sendMessageCall_2, "\t\t"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, \""); - String _name_13 = message.getName(); - _builder.append(_name_13, "\t\t"); - _builder.append("\", ((etReplPort*)self)->ports[idx__et].port.peerInstName)"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_SYNC_EXIT"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - } - } - { - boolean _isEmpty = allPortClasses.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("/* begin "); - _builder.append(portClassName); - _builder.append(" specific (including base classes) */"); - _builder.newLineIfNotEmpty(); - { - for(final PortClass p : allPortClasses) { - CharSequence _userCode = this._procedureHelpers.userCode(p.getUserCode()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - for(final PortClass p_1 : allPortClasses) { - CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(p_1.getOperations(), portClassName); - _builder.append(_operationsImplementation); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("/* end "); - _builder.append(portClassName); - _builder.append(" specific (including base classes) */"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - } - } - _builder.append("etInt32 "); - _builder.append(replPortClassName); - _builder.append("_getReplication(const "); - _builder.append(replPortClassName); - _builder.append("* self) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return ((etReplPort*)self)->size;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue()); - if (_handlesReceive) { - CharSequence _genReceiveHandlers = this.genReceiveHandlers(pc, conj); - _builder.append(_genReceiveHandlers); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String sendMessageCall(final boolean hasData, final String selfPtr, final String msg, final String typeName, final String data) { - String _xifexpression = null; - if (hasData) { - _xifexpression = (((((((("etPort_sendMessage(" + selfPtr) + ", ") + msg) + ", sizeof(") + typeName) + "), ") + data) + ");"); - } else { - _xifexpression = (((("etPort_sendMessage(" + selfPtr) + ", ") + msg) + ", 0, NULL);"); - } - return _xifexpression; - } - - private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) { - return ((((((((("void " + className) + "_") + messageName) + methodSuffix) + "(const ") + className) + "* self") + data) + ")"); - } - - private String messageSetterSignature(final String className, final String messageName, final String data) { - return (((((((("void " + className) + "_") + messageName) + "_set(") + className) + "* self") + data) + ")"); - } - - private String messageGetterSignature(final String className, final String messageName, final String type) { - return (((((((type + " ") + className) + "_") + messageName) + "_get(const ") + className) + "* const self)"); - } - - private CharSequence genReceiveHandlers(final ProtocolClass pc, final Boolean conj) { - CharSequence _xblockexpression = null; - { - String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue()); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* receiver handlers */"); - _builder.newLine(); - { - List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue()); - for(final MessageHandler h : _receiveHandlers) { - _builder.append("void "); - _builder.append(portClassName); - _builder.append("_"); - String _name = h.getMsg().getName(); - _builder.append(_name); - _builder.append("_receiveHandler("); - _builder.append(portClassName); - _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _translatedCode = AbstractGenerator.getInstance().getTranslatedCode(h.getDetailCode()); - _builder.append(_translatedCode, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("/* hand over the message to the actor: */"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.newLine(); - _builder.append("/* message names as strings for debugging (generate MSC) */"); - _builder.newLine(); - _builder.append("static const char* const "); - String _name = pc.getName(); - _builder.append(_name); - _builder.append("_messageStrings[] = {\"MIN\", "); - { - List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc); - for(final Message m : _allOutgoingMessages) { - _builder.append("\""); - String _name_1 = m.getName(); - _builder.append(_name_1); - _builder.append("\","); - } - } - { - List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc); - for(final Message m_1 : _allIncomingMessages) { - _builder.append("\""); - String _name_2 = m_1.getName(); - _builder.append(_name_2); - _builder.append("\", "); - } - } - _builder.append("\"MAX\"};"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("const char* "); - String _name_3 = pc.getName(); - _builder.append(_name_3); - _builder.append("_getMessageString(int msg_id) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if (msg_id<"); - String _name_4 = pc.getName(); - _builder.append(_name_4, "\t"); - _builder.append("_MSG_MIN || msg_id>"); - String _name_5 = pc.getName(); - _builder.append(_name_5, "\t"); - _builder.append("_MSG_MAX+1){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("/* id out of range */"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return \"Message ID out of range\";"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("else{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return "); - String _name_6 = pc.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append("_messageStrings[msg_id];"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - return _builder; - } -} diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java deleted file mode 100644 index ab2ca76cf..000000000 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java +++ /dev/null @@ -1,225 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.c.gen; - -import com.google.common.collect.Iterators; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.generator.c.Main; -import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; - -@Singleton -@SuppressWarnings("all") -public class StateMachineGen extends GenericStateMachineGenerator { - @Inject - @Extension - private RoomExtensions _roomExtensions; - - public CharSequence genHeaderConstants(final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - final Function1<Node, Boolean> _function = (Node it) -> { - boolean _isInherited = it.isInherited(); - return Boolean.valueOf((!_isInherited)); - }; - int _size = IteratorExtensions.size(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(xpac.getGraphContainer().getGraph()), _function)); - final Function1<Node, Boolean> _function_1 = (Node it) -> { - return Boolean.valueOf(FsmGenExtensions.isLeaf(it)); - }; - int _size_1 = IteratorExtensions.size(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(xpac.getGraphContainer().getGraph()), _function_1)); - int _minus = (_size - _size_1); - final int historySize = (_minus + 2); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* constant for state machine data */"); - _builder.newLine(); - _builder.append("#define "); - String _upperCase = ac.getName().toUpperCase(); - _builder.append(_upperCase); - _builder.append("_HISTORY_SIZE "); - _builder.append(historySize); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - public CharSequence genDataMembers(final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* state machine variables */"); - _builder.newLine(); - _builder.append("etInt16 state;"); - _builder.newLine(); - _builder.append("etInt16 history["); - String _upperCase = ac.getName().toUpperCase(); - _builder.append(_upperCase); - _builder.append("_HISTORY_SIZE];"); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - public CharSequence genInitialization(final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("self->state = STATE_TOP;"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("int i;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("for (i=0; i<"); - String _upperCase = ac.getName().toUpperCase(); - _builder.append(_upperCase, "\t"); - _builder.append("_HISTORY_SIZE; ++i)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("self->history[i] = NO_STATE;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - String _operationScope = this.langExt.operationScope(ac.getName(), false); - _builder.append(_operationScope); - _builder.append("executeInitTransition(self);"); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - /** - * @param generateImplementation NOT used - */ - @Override - public CharSequence genExtra(final GraphContainer gc, final boolean generateImplementation) { - CharSequence _xblockexpression = null; - { - final ModelComponent mc = gc.getComponent(); - final Function1<Node, StateGraphNode> _function = (Node it) -> { - return it.getStateGraphNode(); - }; - final List<State> allStates = IteratorExtensions.<State>toList(Iterators.<State>filter(IteratorExtensions.<Node, StateGraphNode>map(FsmGenExtensions.getAllStateNodes(gc.getGraph()), _function), State.class)); - final Iterable<State> states = this._roomExtensions.getLeafStatesLast(allStates); - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("/* state names */"); - _builder.newLine(); - _builder.append("static char* stateStrings[] = {\"<no state>\",\"<top>\","); - { - boolean _hasElements = false; - for(final State state : states) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", ""); - } - _builder.append("\""); - String _genStatePathName = this._codegenHelpers.getGenStatePathName(state); - _builder.append(_genStatePathName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - String _accessLevelPrivate = this.langExt.accessLevelPrivate(); - _builder.append(_accessLevelPrivate); - _builder.append("void setState("); - String _componentName = mc.getComponentName(); - _builder.append(_componentName); - _builder.append("* self, "); - String _stateType = this.stateType(); - _builder.append(_stateType); - _builder.append(" new_state) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("self->state = new_state;"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t"); - _builder.append("ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state])"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate(); - _builder.append(_accessLevelPrivate_1); - String _stateType_1 = this.stateType(); - _builder.append(_stateType_1); - _builder.append(" getState("); - String _componentName_1 = mc.getComponentName(); - _builder.append(_componentName_1); - _builder.append("* self) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return self->state;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - @Override - public String stateType() { - return "etInt16"; - } - - @Override - public String boolType() { - return "etBool"; - } - - @Override - public CharSequence markVariableUsed(final String varname) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("((void)trigger__et);\t/* avoids unused warning */"); - _builder.newLine(); - return _builder; - } - - @Override - public String unreachableReturn() { - return "/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"; - } -} diff --git a/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java b/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java deleted file mode 100644 index b0567c415..000000000 --- a/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java +++ /dev/null @@ -1,444 +0,0 @@ -/** - * Copyright (c) 2012 Juergen Haug - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Juergen Haug - */ -package org.eclipse.etrice.generator.config; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.function.Consumer; -import org.eclipse.emf.common.EMFPlugin; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.etrice.core.ConfigStandaloneSetup; -import org.eclipse.etrice.core.common.base.BooleanLiteral; -import org.eclipse.etrice.core.common.base.IntLiteral; -import org.eclipse.etrice.core.common.base.Literal; -import org.eclipse.etrice.core.common.base.NumberLiteral; -import org.eclipse.etrice.core.common.base.RealLiteral; -import org.eclipse.etrice.core.common.base.StringLiteral; -import org.eclipse.etrice.core.config.AttrClassConfig; -import org.eclipse.etrice.core.config.AttrInstanceConfig; -import org.eclipse.etrice.core.config.ConfigValue; -import org.eclipse.etrice.core.config.ConfigValueArray; -import org.eclipse.etrice.core.config.DynamicConfig; -import org.eclipse.etrice.core.config.EnumConfigValue; -import org.eclipse.etrice.core.config.LiteralConfigValue; -import org.eclipse.etrice.core.config.SubSystemConfig; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.generator.base.IDataConfiguration; -import org.eclipse.etrice.generator.config.util.DataConfigurationHelper; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.scoping.impl.ImportUriResolver; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@SuppressWarnings("all") -public class DataConfiguration implements IDataConfiguration { - @Inject - @Extension - protected DataConfigurationHelper _dataConfigurationHelper; - - @Inject - protected ILogger logger; - - @Inject - protected ImportUriResolver uriResolver; - - @Override - public void doSetup() { - if ((!EMFPlugin.IS_ECLIPSE_RUNNING)) { - ConfigStandaloneSetup.doSetup(); - } - } - - @Override - public boolean setResources(final ResourceSet resource, final ILogger logger) { - return this._dataConfigurationHelper.setConfigModels(resource, logger); - } - - @Override - public String getAttrClassConfigValue(final ActorClass actor, final List<Attribute> path) { - AttrClassConfig _attrClassConfig = this.getAttrClassConfig(actor, path); - ConfigValueArray _value = null; - if (_attrClassConfig!=null) { - _value=_attrClassConfig.getValue(); - } - String _stringExpr = null; - if (_value!=null) { - _stringExpr=this.toStringExpr(_value); - } - return _stringExpr; - } - - @Override - public String getAttrClassConfigMaxValue(final ActorClass actor, final List<Attribute> path) { - AttrClassConfig _attrClassConfig = this.getAttrClassConfig(actor, path); - NumberLiteral _max = null; - if (_attrClassConfig!=null) { - _max=_attrClassConfig.getMax(); - } - String _stringExpr = null; - if (_max!=null) { - _stringExpr=this.toStringExpr(_max); - } - return _stringExpr; - } - - @Override - public String getAttrClassConfigMinValue(final ActorClass actor, final List<Attribute> path) { - AttrClassConfig _attrClassConfig = this.getAttrClassConfig(actor, path); - NumberLiteral _min = null; - if (_attrClassConfig!=null) { - _min=_attrClassConfig.getMin(); - } - String _stringExpr = null; - if (_min!=null) { - _stringExpr=this.toStringExpr(_min); - } - return _stringExpr; - } - - private AttrClassConfig getAttrClassConfig(final ActorClass actor, final List<Attribute> path) { - AttrClassConfig _xblockexpression = null; - { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/"); - String _name = actor.getName(); - _builder.append(_name); - _builder.append("/"); - String _stringPath = this.toStringPath(path); - _builder.append(_stringPath); - String id = _builder.toString(); - _xblockexpression = this._dataConfigurationHelper.actorClassAttrMap.get(id); - } - return _xblockexpression; - } - - @Override - public String getAttrClassConfigValue(final ProtocolClass pc, final boolean regular, final List<Attribute> path) { - String _xblockexpression = null; - { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/"); - String _name = pc.getName(); - _builder.append(_name); - _builder.append("/"); - { - if (regular) { - _builder.append("regular"); - } else { - _builder.append("conjugated"); - } - } - _builder.append("/"); - String _stringPath = this.toStringPath(path); - _builder.append(_stringPath); - String id = _builder.toString(); - AttrClassConfig _get = this._dataConfigurationHelper.protocolClassAttrMap.get(id); - ConfigValueArray _value = null; - if (_get!=null) { - _value=_get.getValue(); - } - String _stringExpr = null; - if (_value!=null) { - _stringExpr=this.toStringExpr(_value); - } - _xblockexpression = _stringExpr; - } - return _xblockexpression; - } - - private String toStringPath(final List<Attribute> path) { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _hasElements = false; - for(final Attribute a : path) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate("/", ""); - } - String _name = a.getName(); - _builder.append(_name); - } - } - return _builder.toString(); - } - - @Override - public String getAttrInstanceConfigValue(final ActorInstance ai, final List<Attribute> path) { - String _xblockexpression = null; - { - String _path = ai.getPath(); - String _plus = (_path + "/"); - String _stringPath = this.toStringPath(path); - String id = (_plus + _stringPath); - AttrInstanceConfig _get = this._dataConfigurationHelper.actorInstanceAttrMap.get(id); - ConfigValueArray _value = null; - if (_get!=null) { - _value=_get.getValue(); - } - String _stringExpr = null; - if (_value!=null) { - _stringExpr=this.toStringExpr(_value); - } - _xblockexpression = _stringExpr; - } - return _xblockexpression; - } - - @Override - public String getAttrInstanceConfigValue(final InterfaceItemInstance item, final List<Attribute> path) { - String _path = item.getPath(); - String _plus = (_path + "/"); - String _stringPath = this.toStringPath(path); - String _plus_1 = (_plus + _stringPath); - AttrInstanceConfig _get = this._dataConfigurationHelper.actorInstanceAttrMap.get(_plus_1); - ConfigValueArray _value = null; - if (_get!=null) { - _value=_get.getValue(); - } - String _stringExpr = null; - if (_value!=null) { - _stringExpr=this.toStringExpr(_value); - } - return _stringExpr; - } - - @Override - public long getPollingTimerUser(final SubSystemInstance subsystem) { - long _xblockexpression = (long) 0; - { - SubSystemConfig _config = this.getConfig(subsystem); - DynamicConfig _dynConfig = null; - if (_config!=null) { - _dynConfig=_config.getDynConfig(); - } - final DynamicConfig dynConf = _dynConfig; - long _xifexpression = (long) 0; - boolean _equals = Objects.equal(dynConf, null); - if (_equals) { - _xifexpression = 0; - } else { - _xifexpression = dynConf.getPolling(); - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String getUserCode1(final SubSystemInstance subsystem) { - SubSystemConfig _config = this.getConfig(subsystem); - DynamicConfig _dynConfig = null; - if (_config!=null) { - _dynConfig=_config.getDynConfig(); - } - DynamicConfig dynConfig = _dynConfig; - String _xifexpression = null; - String _filePath = null; - if (dynConfig!=null) { - _filePath=dynConfig.getFilePath(); - } - boolean _notEquals = (!Objects.equal(_filePath, null)); - if (_notEquals) { - _xifexpression = "import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;"; - } else { - String _userCode1 = null; - if (dynConfig!=null) { - _userCode1=dynConfig.getUserCode1(); - } - _xifexpression = _userCode1; - } - return _xifexpression; - } - - @Override - public String getUserCode2(final SubSystemInstance subsystem) { - SubSystemConfig _config = this.getConfig(subsystem); - DynamicConfig _dynConfig = null; - if (_config!=null) { - _dynConfig=_config.getDynConfig(); - } - DynamicConfig dynConfig = _dynConfig; - String _xifexpression = null; - String _filePath = null; - if (dynConfig!=null) { - _filePath=dynConfig.getFilePath(); - } - boolean _notEquals = (!Objects.equal(_filePath, null)); - if (_notEquals) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("new ConfigSourceFile(\""); - String _filePath_1 = dynConfig.getFilePath(); - _builder.append(_filePath_1); - _builder.append("\")"); - _xifexpression = _builder.toString(); - } else { - String _userCode2 = null; - if (dynConfig!=null) { - _userCode2=dynConfig.getUserCode2(); - } - _xifexpression = _userCode2; - } - return _xifexpression; - } - - @Override - public List<Attribute> getDynConfigReadAttributes(final ActorInstance ai) { - final ArrayList<Attribute> result = new ArrayList<Attribute>(); - List<AttrInstanceConfig> configs = this._dataConfigurationHelper.dynActorInstanceAttrMap.get(ai.getPath()); - if (configs!=null) { - final Consumer<AttrInstanceConfig> _function = (AttrInstanceConfig c) -> { - boolean _isReadOnly = c.isReadOnly(); - if (_isReadOnly) { - result.add(c.getAttribute()); - } - }; - configs.forEach(_function); - } - return result; - } - - @Override - public List<Attribute> getDynConfigWriteAttributes(final ActorInstance ai) { - final ArrayList<Attribute> result = new ArrayList<Attribute>(); - List<AttrInstanceConfig> configs = this._dataConfigurationHelper.dynActorInstanceAttrMap.get(ai.getPath()); - if (configs!=null) { - final Consumer<AttrInstanceConfig> _function = (AttrInstanceConfig c) -> { - boolean _isReadOnly = c.isReadOnly(); - boolean _not = (!_isReadOnly); - if (_not) { - result.add(c.getAttribute()); - } - }; - configs.forEach(_function); - } - return result; - } - - @Override - public boolean hasVariableService(final SubSystemInstance subsystem) { - SubSystemConfig _config = this.getConfig(subsystem); - DynamicConfig _dynConfig = null; - if (_config!=null) { - _dynConfig=_config.getDynConfig(); - } - return (!Objects.equal(_dynConfig, null)); - } - - private String toStringExpr(final ConfigValueArray literal) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<ConfigValue> _values = literal.getValues(); - boolean _hasElements = false; - for(final ConfigValue l : _values) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", ""); - } - String _stringExpr = this.toStringExpr(l); - _builder.append(_stringExpr); - } - } - return _builder.toString(); - } - - private String toStringExpr(final ConfigValue configValue) { - String _switchResult = null; - boolean _matched = false; - if (configValue instanceof LiteralConfigValue) { - _matched=true; - _switchResult = this.toStringExpr(((LiteralConfigValue)configValue).getValue()); - } - if (!_matched) { - if (configValue instanceof EnumConfigValue) { - _matched=true; - _switchResult = ((EnumConfigValue)configValue).getValue().getFullName(); - } - } - return _switchResult; - } - - private String toStringExpr(final Literal literal) { - String _switchResult = null; - boolean _matched = false; - if (literal instanceof BooleanLiteral) { - _matched=true; - _switchResult = Boolean.valueOf(((BooleanLiteral)literal).isIsTrue()).toString(); - } - if (!_matched) { - if (literal instanceof IntLiteral) { - _matched=true; - _switchResult = Long.valueOf(((IntLiteral)literal).getValue()).toString(); - } - } - if (!_matched) { - if (literal instanceof RealLiteral) { - _matched=true; - _switchResult = Double.valueOf(((RealLiteral)literal).getValue()).toString(); - } - } - if (!_matched) { - if (literal instanceof StringLiteral) { - _matched=true; - _switchResult = ((StringLiteral)literal).getValue().toString(); - } - } - return _switchResult; - } - - private SubSystemConfig getConfig(final SubSystemInstance cc) { - return this._dataConfigurationHelper.subSystemConfigMap.get(cc.getPath()); - } - - @Override - public List<Attribute> getDynConfigReadAttributes(final ActorClass actor) { - final HashSet<Attribute> result = new HashSet<Attribute>(); - final List<AttrInstanceConfig> configs = this._dataConfigurationHelper.dynActorClassAttrMap.get(actor); - if (configs!=null) { - final Consumer<AttrInstanceConfig> _function = (AttrInstanceConfig c) -> { - boolean _isReadOnly = c.isReadOnly(); - if (_isReadOnly) { - result.add(c.getAttribute()); - } - }; - configs.forEach(_function); - } - return IterableExtensions.<Attribute>toList(result); - } - - @Override - public List<Attribute> getDynConfigWriteAttributes(final ActorClass actor) { - final HashSet<Attribute> result = new HashSet<Attribute>(); - final List<AttrInstanceConfig> configs = this._dataConfigurationHelper.dynActorClassAttrMap.get(actor); - if (configs!=null) { - final Consumer<AttrInstanceConfig> _function = (AttrInstanceConfig c) -> { - boolean _isReadOnly = c.isReadOnly(); - boolean _not = (!_isReadOnly); - if (_not) { - result.add(c.getAttribute()); - } - }; - configs.forEach(_function); - } - return IterableExtensions.<Attribute>toList(result); - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java deleted file mode 100644 index 39e1004cb..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java +++ /dev/null @@ -1,1094 +0,0 @@ -/** - * Copyright (c) 2011 Draeger Medical GmbH (http://www.draeger.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Peter Karlitschek (initial contribution) - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType; -import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.Wire; -import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.SAP; -import org.eclipse.etrice.core.room.SPP; -import org.eclipse.etrice.core.room.ServiceImplementation; -import org.eclipse.etrice.generator.cpp.Main; -import org.eclipse.etrice.generator.cpp.gen.CppExtensions; -import org.eclipse.etrice.generator.cpp.gen.Initialization; -import org.eclipse.etrice.generator.cpp.gen.StateMachineGen; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.GenericActorClassGenerator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class ActorClassGen extends GenericActorClassGenerator { - @Inject - protected IGeneratorFileIo fileIO; - - @Inject - @Extension - protected CppExtensions _cppExtensions; - - @Inject - @Extension - protected RoomExtensions _roomExtensions; - - @Inject - @Extension - protected ProcedureHelpers _procedureHelpers; - - @Inject - protected Initialization initHelper; - - @Inject - @Extension - protected StateMachineGen _stateMachineGen; - - @Inject - @Extension - protected FileSystemHelpers _fileSystemHelpers; - - public void doGenerate(final Root root) { - final Map<ActorClass, WiredActorClass> ac2wired = CollectionLiterals.<ActorClass, WiredActorClass>newHashMap(); - final Consumer<WiredActorClass> _function = (WiredActorClass it) -> { - ac2wired.put(it.getActorClass(), it); - }; - Iterables.<WiredActorClass>filter(root.getWiredInstances(), WiredActorClass.class).forEach(_function); - final Function1<ActorClass, Boolean> _function_1 = (ActorClass it) -> { - return Boolean.valueOf(this._fileSystemHelpers.isValidGenerationLocation(it)); - }; - final Function1<ActorClass, ExpandedActorClass> _function_2 = (ActorClass it) -> { - return root.getExpandedActorClass(it); - }; - Iterable<ExpandedActorClass> _map = IterableExtensions.<ActorClass, ExpandedActorClass>map(IterableExtensions.<ActorClass>filter(root.getActorClasses(), _function_1), _function_2); - for (final ExpandedActorClass xpac : _map) { - { - final WiredActorClass wired = ac2wired.get(xpac.getActorClass()); - final boolean manualBehavior = this._roomHelpers.isBehaviorAnnotationPresent(xpac.getActorClass(), "BehaviorManual"); - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(xpac.getActorClass()); - String _path = this._roomExtensions.getPath(xpac.getActorClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(xpac.getActorClass()); - String _path_1 = this._roomExtensions.getPath(xpac.getActorClass()); - final String infopath = (_generationInfoPath + _path_1); - String _xifexpression = null; - if (manualBehavior) { - _xifexpression = "Abstract"; - } else { - _xifexpression = ""; - } - String file = _xifexpression; - String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(xpac.getActorClass()); - String _plus = (file + _cppHeaderFileName); - this.fileIO.generateFile("generating ActorClass declaration", path, infopath, _plus, this.generateHeaderFile(root, xpac, wired, manualBehavior)); - String _cppSourceFileName = this._cppExtensions.getCppSourceFileName(xpac.getActorClass()); - String _plus_1 = (file + _cppSourceFileName); - this.fileIO.generateFile("generating ActorClass implementation", path, infopath, _plus_1, this.generateSourceFile(root, xpac, wired, manualBehavior)); - } - } - } - - protected CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac, final WiredActorClass wired, final boolean manualBehavior) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - String _xifexpression = null; - if (manualBehavior) { - String _name = ac.getName(); - _xifexpression = ("Abstract" + _name); - } else { - _xifexpression = ac.getName(); - } - final String clsname = _xifexpression; - String _elvis = null; - ActorClass _actorBase = ac.getActorBase(); - String _name_1 = null; - if (_actorBase!=null) { - _name_1=_actorBase.getName(); - } - if (_name_1 != null) { - _elvis = _name_1; - } else { - _elvis = "etRuntime::ActorClassBase"; - } - final String rtBaseClassName = _elvis; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of ActorClass "); - _builder.append(clsname, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(ac, ""); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/etDatatypesCpp.hpp\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/IRTObject.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/PortBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/ReplicatedActorClassBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/InterfaceItemBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/SubSystemClassBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/Address.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/IMessageReceiver.h\""); - _builder.newLine(); - _builder.append("#include \"common/debugging/DebuggingService.h\""); - _builder.newLine(); - _builder.newLine(); - { - EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac); - for(final ProtocolClass pc : _referencedProtocolClasses) { - _builder.append("#include \""); - String _path = this._roomExtensions.getPath(pc); - _builder.append(_path); - String _name_2 = pc.getName(); - _builder.append(_name_2); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - { - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac); - for(final DataClass dc : _referencedDataClasses) { - _builder.append("#include \""); - String _path_1 = this._roomExtensions.getPath(dc); - _builder.append(_path_1); - String _name_3 = dc.getName(); - _builder.append(_name_3); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - ActorClass _actorBase_1 = ac.getActorBase(); - boolean _equals = Objects.equal(_actorBase_1, null); - if (_equals) { - _builder.append("#include \"common/modelbase/ActorClassBase.h\""); - _builder.newLine(); - } else { - _builder.append("#include \""); - String _path_2 = this._roomExtensions.getPath(ac.getActorBase()); - _builder.append(_path_2); - String _name_4 = ac.getActorBase().getName(); - _builder.append(_name_4); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - { - EList<ActorRef> _actorRefs = ac.getActorRefs(); - for(final ActorRef ar : _actorRefs) { - _builder.append("#include \""); - String _actorIncludePath = this._cppExtensions.getActorIncludePath(ar.getType()); - _builder.append(_actorIncludePath); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(ac.getUserCode1()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("using namespace etRuntime;"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this._cppExtensions.generateNamespaceBegin(ac); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("class "); - _builder.append(clsname); - _builder.append(" : public "); - _builder.append(rtBaseClassName); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- ports"); - _builder.newLine(); - { - List<Port> _endPorts = this._roomHelpers.getEndPorts(ac); - for(final Port ep : _endPorts) { - _builder.append("\t\t"); - String _portClassName = this._roomExtensions.getPortClassName(ep); - _builder.append(_portClassName, "\t\t"); - _builder.append(" "); - String _name_5 = ep.getName(); - _builder.append(_name_5, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- sub actors"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_1 = ac.getActorRefs(); - for(final ActorRef sub : _actorRefs_1) { - { - int _multiplicity = sub.getMultiplicity(); - boolean _greaterThan = (_multiplicity > 1); - if (_greaterThan) { - _builder.append("\t\t"); - _builder.append("Replicated"); - String _implementationClassName = this._cppExtensions.getImplementationClassName(sub.getType()); - _builder.append(_implementationClassName, "\t\t"); - _builder.append(" "); - String _name_6 = sub.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t\t"); - String _implementationClassName_1 = this._cppExtensions.getImplementationClassName(sub.getType()); - _builder.append(_implementationClassName_1, "\t\t"); - _builder.append(" "); - String _name_7 = sub.getName(); - _builder.append(_name_7, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- saps"); - _builder.newLine(); - { - EList<SAP> _serviceAccessPoints = ac.getServiceAccessPoints(); - for(final SAP sap : _serviceAccessPoints) { - _builder.append("\t\t"); - String _portClassName_1 = this._roomExtensions.getPortClassName(sap); - _builder.append(_portClassName_1, "\t\t"); - _builder.append(" "); - String _name_8 = sap.getName(); - _builder.append(_name_8, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- services"); - _builder.newLine(); - { - EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations(); - for(final ServiceImplementation svc : _serviceImplementations) { - _builder.append("\t\t"); - String _portClassName_2 = this._roomExtensions.getPortClassName(svc); - _builder.append(_portClassName_2, "\t\t"); - _builder.append(" "); - String _name_9 = svc.getSpp().getName(); - _builder.append(_name_9, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- interface item IDs"); - _builder.newLine(); - _builder.append("\t\t"); - String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac); - _builder.append(_genInterfaceItemConstants, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - CharSequence _attributes = this._procedureHelpers.attributes(ac.getAttributes()); - _builder.append(_attributes, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(ac.getOperations(), ac.getName()); - _builder.append(_operationsDeclaration, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- construction"); - _builder.newLine(); - _builder.append("\t\t"); - String _name_10 = ac.getName(); - _builder.append(_name_10, "\t\t"); - _builder.append("(etRuntime::IRTObject* parent, const String& name);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("void initialize(void);"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t\t"); - _builder.append("void setProbesActive(bool recursive, bool active);"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- port getters"); - _builder.newLine(); - _builder.append("\t\t"); - final Function1<Port, CharSequence> _function = (Port it) -> { - String _portClassName_3 = this._roomExtensions.getPortClassName(it); - String _plus = (_portClassName_3 + "&"); - return this._procedureHelpers.getterImplementation(_plus, it.getName(), clsname); - }; - String _join = IterableExtensions.join(ListExtensions.<Port, CharSequence>map(this._roomHelpers.getEndPorts(ac), _function), this._roomExtensions.NEWLINE); - _builder.append(_join, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - final Function1<SAP, CharSequence> _function_1 = (SAP it) -> { - String _portClassName_3 = this._roomExtensions.getPortClassName(it); - String _plus = (_portClassName_3 + "&"); - return this._procedureHelpers.getterImplementation(_plus, it.getName(), clsname); - }; - String _join_1 = IterableExtensions.join(ListExtensions.<SAP, CharSequence>map(ac.getServiceAccessPoints(), _function_1), this._roomExtensions.NEWLINE); - _builder.append(_join_1, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - final Function1<ServiceImplementation, CharSequence> _function_2 = (ServiceImplementation it) -> { - String _portClassName_3 = this._roomExtensions.getPortClassName(it); - String _plus = (_portClassName_3 + "&"); - return this._procedureHelpers.getterImplementation(_plus, it.getSpp().getName(), clsname); - }; - String _join_2 = IterableExtensions.join(ListExtensions.<ServiceImplementation, CharSequence>map(ac.getServiceImplementations(), _function_2), this._roomExtensions.NEWLINE); - _builder.append(_join_2, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("//--------------------- lifecycle functions"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void destroy();"); - _builder.newLine(); - _builder.newLine(); - { - boolean _hasNonEmptyStateMachine = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine) { - _builder.append("\t\t"); - CharSequence _genStateMachineConstants = this._stateMachineGen.genStateMachineConstants(xpac.getGraphContainer()); - _builder.append(_genStateMachineConstants, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - CharSequence _genStateMachineMethods = this._stateMachineGen.genStateMachineMethods(xpac.getGraphContainer(), false); - _builder.append(_genStateMachineMethods, "\t\t"); - _builder.newLineIfNotEmpty(); - { - ComponentCommunicationType _commType = ac.getCommType(); - boolean _equals_1 = Objects.equal(_commType, ComponentCommunicationType.DATA_DRIVEN); - if (_equals_1) { - _builder.append("\t\t"); - _builder.append("void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* generic_data);"); - _builder.newLine(); - } - } - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("\t\t"); - _builder.append("virtual void receive(const etRuntime::Message* msg);"); - _builder.newLine(); - } - } - } else { - boolean _isEmpty = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - if (_isEmpty) { - _builder.append("\t\t"); - _builder.append("//--------------------- no state machine"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void executeInitTransition() {}"); - _builder.newLine(); - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - CharSequence _userCode_1 = this._procedureHelpers.userCode(ac.getUserCode2()); - _builder.append(_userCode_1, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - _builder.append("class Replicated"); - _builder.append(clsname); - _builder.append(" : public ReplicatedActorClassBase {"); - _builder.newLineIfNotEmpty(); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("Replicated"); - _builder.append(clsname, "\t"); - _builder.append("(IRTObject* parent, const String& name) :"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("ReplicatedActorClassBase(parent, name) {}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("protected:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ActorClassBase* createActor(IRTObject* parent, const String& name) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return new "); - _builder.append(clsname, "\t\t"); - _builder.append("(parent, name);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceEnd = this._cppExtensions.generateNamespaceEnd(ac); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(ac, ""); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateConstructorInitalizerList(final ActorClass ac) { - CharSequence _xblockexpression = null; - { - @Extension - final Initialization initHelper = this.initHelper; - ArrayList<CharSequence> initList = CollectionLiterals.<CharSequence>newArrayList(); - StringConcatenation _builder = new StringConcatenation(); - String _elvis = null; - ActorClass _actorBase = ac.getActorBase(); - String _name = null; - if (_actorBase!=null) { - _name=_actorBase.getName(); - } - if (_name != null) { - _elvis = _name; - } else { - _elvis = "ActorClassBase"; - } - _builder.append(_elvis); - _builder.append("(parent, name)"); - initList.add(_builder.toString()); - final Function1<Port, String> _function = (Port it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name_1 = it.getName(); - _builder_1.append(_name_1); - _builder_1.append("(this, \""); - String _name_2 = it.getName(); - _builder_1.append(_name_2); - _builder_1.append("\", IFITEM_"); - String _name_3 = it.getName(); - _builder_1.append(_name_3); - _builder_1.append(")"); - return _builder_1.toString(); - }; - List<String> _map = ListExtensions.<Port, String>map(this._roomHelpers.getEndPorts(ac), _function); - Iterables.<CharSequence>addAll(initList, _map); - final Function1<ActorRef, String> _function_1 = (ActorRef it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name_1 = it.getName(); - _builder_1.append(_name_1); - _builder_1.append("(this, \""); - String _name_2 = it.getName(); - _builder_1.append(_name_2); - _builder_1.append("\")"); - return _builder_1.toString(); - }; - List<String> _map_1 = ListExtensions.<ActorRef, String>map(ac.getActorRefs(), _function_1); - Iterables.<CharSequence>addAll(initList, _map_1); - final Function1<SAP, String> _function_2 = (SAP it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name_1 = it.getName(); - _builder_1.append(_name_1); - _builder_1.append("(this, \""); - String _name_2 = it.getName(); - _builder_1.append(_name_2); - _builder_1.append("\", IFITEM_"); - String _name_3 = it.getName(); - _builder_1.append(_name_3); - _builder_1.append(")"); - return _builder_1.toString(); - }; - List<String> _map_2 = ListExtensions.<SAP, String>map(ac.getServiceAccessPoints(), _function_2); - Iterables.<CharSequence>addAll(initList, _map_2); - final Function1<ServiceImplementation, String> _function_3 = (ServiceImplementation it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name_1 = it.getSpp().getName(); - _builder_1.append(_name_1); - _builder_1.append("(this, \""); - String _name_2 = it.getSpp().getName(); - _builder_1.append(_name_2); - _builder_1.append("\", IFITEM_"); - String _name_3 = it.getSpp().getName(); - _builder_1.append(_name_3); - _builder_1.append(")"); - return _builder_1.toString(); - }; - List<String> _map_3 = ListExtensions.<ServiceImplementation, String>map(ac.getServiceImplementations(), _function_3); - Iterables.<CharSequence>addAll(initList, _map_3); - final Function1<Attribute, String> _function_4 = (Attribute it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name_1 = it.getName(); - _builder_1.append(_name_1); - _builder_1.append("("); - String _initializerListValue = initHelper.getInitializerListValue(it); - _builder_1.append(_initializerListValue); - _builder_1.append(")"); - return _builder_1.toString(); - }; - List<String> _map_4 = ListExtensions.<Attribute, String>map(ac.getAttributes(), _function_4); - Iterables.<CharSequence>addAll(initList, _map_4); - _xblockexpression = initHelper.generateCtorInitializerList(initList); - } - return _xblockexpression; - } - - protected CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac, final WiredActorClass wired, final boolean manualBehavior) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - String _xifexpression = null; - if (manualBehavior) { - String _name = ac.getName(); - _xifexpression = ("Abstract" + _name); - } else { - _xifexpression = ac.getName(); - } - final String clsname = _xifexpression; - String _elvis = null; - ActorClass _actorBase = ac.getActorBase(); - String _name_1 = null; - if (_actorBase!=null) { - _name_1=_actorBase.getName(); - } - if (_name_1 != null) { - _elvis = _name_1; - } else { - _elvis = "ActorClassBase"; - } - final String rtBaseClassName = _elvis; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of ActorClass "); - String _name_2 = ac.getName(); - _builder.append(_name_2, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(ac); - _builder.append(_cppHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/messaging/RTObject.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/RTServices.h\""); - _builder.newLine(); - _builder.append("#include \"common/debugging/DebuggingService.h\""); - _builder.newLine(); - _builder.append("#include \"common/debugging/MSCFunctionObject.h\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("using namespace etRuntime;"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this._cppExtensions.generateNamespaceBegin(ac); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(ac.getUserCode3()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append(clsname); - _builder.append("::"); - _builder.append(clsname); - _builder.append("(etRuntime::IRTObject* parent, const String& name)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(ac); - _builder.append(_generateConstructorInitalizerList, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"Constructor\");"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.newLine(); - { - boolean _hasNonEmptyStateMachine = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine) { - _builder.append("\t"); - _builder.append("for (int i = 0; i < s_numberOfStates; i++) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("history[i] = NO_STATE;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("setClassName(\""); - String _name_3 = ac.getName(); - _builder.append(_name_3, "\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// sub actors"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs = ac.getActorRefs(); - for(final ActorRef sub : _actorRefs) { - { - int _multiplicity = sub.getMultiplicity(); - boolean _greaterThan = (_multiplicity > 1); - if (_greaterThan) { - _builder.append("\t"); - String _name_4 = sub.getName(); - _builder.append(_name_4, "\t"); - _builder.append(".createSubActors("); - int _multiplicity_1 = sub.getMultiplicity(); - _builder.append(_multiplicity_1, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - CharSequence _genExtraInitializers = this.initHelper.genExtraInitializers(ac.getAttributes()); - _builder.append(_genExtraInitializers, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _userStructorBody = this._procedureHelpers.userStructorBody(ac, true); - _builder.append(_userStructorBody, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - String _name_5 = ac.getName(); - _builder.append(_name_5); - _builder.append("::initialize() {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"initialize()\");"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_1 = ac.getActorRefs(); - for(final ActorRef sub_1 : _actorRefs_1) { - { - int _multiplicity_2 = sub_1.getMultiplicity(); - boolean _greaterThan_1 = (_multiplicity_2 > 1); - if (_greaterThan_1) { - _builder.append("\t"); - _builder.append("for (int i=0; i<"); - int _multiplicity_3 = sub_1.getMultiplicity(); - _builder.append(_multiplicity_3, "\t"); - _builder.append("; ++i) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addMessageActorCreate(*this, "); - String _name_6 = sub_1.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append(".getSubActor(i)->getName());"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addMessageActorCreate(*this, \""); - String _name_7 = sub_1.getName(); - _builder.append(_name_7, "\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ActorClassBase::initialize();"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_2 = ac.getActorRefs(); - for(final ActorRef sub_2 : _actorRefs_2) { - _builder.append("\t"); - String _name_8 = sub_2.getName(); - _builder.append(_name_8, "\t"); - _builder.append(".initialize();"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// wiring"); - _builder.newLine(); - { - EList<Wire> _wires = wired.getWires(); - for(final Wire wire : _wires) { - _builder.append("\t"); - String _xifexpression_1 = null; - boolean _isDataDriven = wire.isDataDriven(); - if (_isDataDriven) { - _xifexpression_1 = "DataPortBase"; - } else { - _xifexpression_1 = "InterfaceItemBase"; - } - _builder.append(_xifexpression_1, "\t"); - _builder.append("::connect(this, \""); - String _join = IterableExtensions.join(wire.getPath1(), "/"); - _builder.append(_join, "\t"); - _builder.append("\", \""); - String _join_1 = IterableExtensions.join(wire.getPath2(), "/"); - _builder.append(_join_1, "\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("\t"); - _builder.append("// activate polling for data-driven communication"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(getThread())->addPollingMessageReceiver(*this);"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("void "); - String _name_9 = ac.getName(); - _builder.append(_name_9); - _builder.append("::setProbesActive(bool recursive, bool active) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addPortInstance(m_RTSystemPort);"); - _builder.newLine(); - { - int _size = ac.getActorRefs().size(); - boolean _greaterThan_2 = (_size > 0); - if (_greaterThan_2) { - _builder.append("\t"); - _builder.append("if(recursive) {"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_3 = ac.getActorRefs(); - for(final ActorRef sub_3 : _actorRefs_3) { - _builder.append("\t"); - _builder.append("\t"); - String _name_10 = sub_3.getName(); - _builder.append(_name_10, "\t\t"); - _builder.append(".setProbesActive(recursive, active);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - { - List<Port> _endPorts = this._roomHelpers.getEndPorts(ac); - for(final Port ep : _endPorts) { - { - boolean _isDataDriven_1 = this._roomHelpers.isDataDriven(ep); - boolean _not = (!_isDataDriven_1); - if (_not) { - { - boolean _isReplicated = ep.isReplicated(); - if (_isReplicated) { - _builder.append("\t"); - _builder.append("for(int i = 0; i < "); - String _name_11 = ep.getName(); - _builder.append(_name_11, "\t"); - _builder.append(".getNInterfaceItems(); i++)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addPortInstance(*("); - String _name_12 = ep.getName(); - _builder.append(_name_12, "\t\t"); - _builder.append(".getInterfaceItem(i)));"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addPortInstance("); - String _name_13 = ep.getName(); - _builder.append(_name_13, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - { - EList<SAP> _serviceAccessPoints = ac.getServiceAccessPoints(); - for(final SAP sap : _serviceAccessPoints) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addPortInstance("); - String _name_14 = sap.getName(); - _builder.append(_name_14, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - { - EList<SPP> _serviceProvisionPoints = ac.getServiceProvisionPoints(); - for(final SPP spp : _serviceProvisionPoints) { - _builder.append("\t"); - _builder.append("for(int i = 0; i < "); - String _name_15 = spp.getName(); - _builder.append(_name_15, "\t"); - _builder.append(".getNInterfaceItems(); i++)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("DebuggingService::getInstance().addPortInstance(*("); - String _name_16 = spp.getName(); - _builder.append(_name_16, "\t\t\t"); - _builder.append(".getInterfaceItem(i)));"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("void "); - String _name_17 = ac.getName(); - _builder.append(_name_17); - _builder.append("::destroy(){"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_3 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_3) { - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"destroy()\");"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - String _userStructorBody_1 = this._procedureHelpers.userStructorBody(ac, false); - _builder.append(_userStructorBody_1, "\t"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_4 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_4) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addMessageActorDestroy(*this);"); - _builder.newLine(); - } - } - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("\t"); - _builder.append("RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(getThread())->removePollingMessageReceiver(*this);"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append(rtBaseClassName, "\t"); - _builder.append("::destroy();"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac.getOperations(), ac.getName()); - _builder.append(_operationsImplementation); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - boolean _hasNonEmptyStateMachine_1 = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine_1) { - CharSequence _genStateMachineMethods = this._stateMachineGen.genStateMachineMethods(xpac.getGraphContainer(), true); - _builder.append(_genStateMachineMethods); - _builder.newLineIfNotEmpty(); - { - ComponentCommunicationType _commType = ac.getCommType(); - boolean _equals = Objects.equal(_commType, ComponentCommunicationType.DATA_DRIVEN); - if (_equals) { - _builder.append("void "); - String _name_18 = ac.getName(); - _builder.append(_name_18); - _builder.append("::receiveEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("handleSystemEvent(ifitem, evt, generic_data);"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("void "); - String _name_19 = ac.getName(); - _builder.append(_name_19); - _builder.append("::receive(const Message* msg) {"); - _builder.newLineIfNotEmpty(); - { - ComponentCommunicationType _commType_1 = ac.getCommType(); - boolean _equals_1 = Objects.equal(_commType_1, ComponentCommunicationType.ASYNCHRONOUS); - if (_equals_1) { - _builder.append("\t"); - _builder.append("receiveEvent(0, -1, 0);"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("receiveEventInternal();"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - } - } - } else { - boolean _isEmpty = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - if (_isEmpty) { - _builder.append("//--------------------- no state machine"); - _builder.newLine(); - _builder.append("void "); - String _name_20 = ac.getName(); - _builder.append(_name_20); - _builder.append("::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("handleSystemEvent(ifitem, evt, data);"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - } - _builder.newLine(); - String _generateNamespaceEnd = this._cppExtensions.generateNamespaceEnd(ac); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java deleted file mode 100644 index d29b527d7..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java +++ /dev/null @@ -1,525 +0,0 @@ -/** - * Copyright (c) 2012 Juergen Haug - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Juergen Haug - * Peter Karlitschek - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase; -import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.ExternalType; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.PrimitiveType; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.base.IDataConfiguration; -import org.eclipse.etrice.generator.cpp.gen.CppExtensions; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.StringExtensions; - -@SuppressWarnings("all") -public class ConfigGenAddon { - @Inject - @Extension - private CppExtensions stdExt; - - @Inject - @Extension - private TypeHelpers typeHelpers; - - @Inject - @Extension - private ProcedureHelpers helpers; - - @Inject - private IDataConfiguration dataConfigExt; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - public CharSequence genActorInstanceConfig(final ActorInstance ai, final String aiVariableName) { - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(ai.getActorClass()); - for(final Attribute a : _allAttributes) { - String _applyInstanceConfig = this.applyInstanceConfig(ai, aiVariableName, this._roomExtensions.<Attribute>union(new ArrayList<Attribute>(), a)); - _builder.append(_applyInstanceConfig); - _builder.newLineIfNotEmpty(); - } - } - { - EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances(); - for(final InterfaceItemInstance pi : _orderedIfItemInstances) { - PortClass _portClass = this._roomHelpers.getPortClass(pi.getInterfaceItem()); - EList<Attribute> _attributes = null; - if (_portClass!=null) { - _attributes=_portClass.getAttributes(); - } - EList<Attribute> attribs = _attributes; - _builder.newLineIfNotEmpty(); - { - boolean _notEquals = (!Objects.equal(attribs, null)); - if (_notEquals) { - { - for(final Attribute a_1 : attribs) { - CharSequence _invokeGetter = this.helpers.invokeGetter(pi.getName(), null); - String _plus = ((aiVariableName + ".") + _invokeGetter); - String _applyInstanceConfig_1 = this.applyInstanceConfig(pi, _plus, this._roomExtensions.<Attribute>union(new ArrayList<Attribute>(), a_1)); - _builder.append(_applyInstanceConfig_1); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - return _builder; - } - - private String applyInstanceConfig(final InstanceBase instance, final String invokes, final List<Attribute> path) { - String _xblockexpression = null; - { - Attribute a = IterableExtensions.<Attribute>last(path); - DataType aType = a.getType().getType(); - String _xifexpression = null; - boolean _isPrimitive = this.typeHelpers.isPrimitive(aType); - if (_isPrimitive) { - String _xblockexpression_1 = null; - { - String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance); - String _xifexpression_1 = null; - boolean _equals = Objects.equal(value, null); - if (_equals) { - StringConcatenation _builder = new StringConcatenation(); - _xifexpression_1 = _builder.toString(); - } else { - String _xifexpression_2 = null; - if (((a.getSize() == 0) || this.typeHelpers.isCharacterType(aType))) { - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append(invokes); - _builder_1.append("."); - CharSequence _invokeSetter = this.helpers.invokeSetter(a.getName(), null, this.stdExt.toValueLiteral(((PrimitiveType) aType), value)); - _builder_1.append(_invokeSetter); - _builder_1.append(";"); - _xifexpression_2 = _builder_1.toString(); - } else { - String _xifexpression_3 = null; - int _size = a.getSize(); - int _size_1 = ((List<String>)Conversions.doWrapArray(value.split(","))).size(); - boolean _equals_1 = (_size == _size_1); - if (_equals_1) { - String _xblockexpression_2 = null; - { - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("{ "); - { - String[] _split = value.split(","); - boolean _hasElements = false; - for(final String s : _split) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder_2.appendImmediate(", ", ""); - } - String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), s.trim()); - _builder_2.append(_valueLiteral); - } - } - _builder_2.append(" }"); - String arrayExpr = _builder_2.toString(); - StringConcatenation _builder_3 = new StringConcatenation(); - _builder_3.append(invokes); - _builder_3.append("."); - StringConcatenation _builder_4 = new StringConcatenation(); - _builder_4.append("new "); - String _typeName = this.typeHelpers.typeName(aType); - _builder_4.append(_typeName); - _builder_4.append("[] "); - _builder_4.append(arrayExpr); - CharSequence _invokeSetter_1 = this.helpers.invokeSetter(a.getName(), null, _builder_4.toString()); - _builder_3.append(_invokeSetter_1); - _builder_3.append(";"); - _xblockexpression_2 = _builder_3.toString(); - } - _xifexpression_3 = _xblockexpression_2; - } else { - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("{"); - _builder_2.newLine(); - _builder_2.append("\t"); - String _typeName = this.typeHelpers.typeName(aType); - _builder_2.append(_typeName, "\t"); - _builder_2.append("[] array = "); - _builder_2.append(invokes, "\t"); - _builder_2.append("."); - CharSequence _invokeGetter = this.helpers.invokeGetter(a.getName(), null); - _builder_2.append(_invokeGetter, "\t"); - _builder_2.append(";"); - _builder_2.newLineIfNotEmpty(); - _builder_2.append("\t"); - _builder_2.append("for (int i=0;i<"); - int _size_2 = a.getSize(); - _builder_2.append(_size_2, "\t"); - _builder_2.append(";i++){"); - _builder_2.newLineIfNotEmpty(); - _builder_2.append("\t\t"); - _builder_2.append("array[i] = "); - String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), value); - _builder_2.append(_valueLiteral, "\t\t"); - _builder_2.append(";"); - _builder_2.newLineIfNotEmpty(); - _builder_2.append("}"); - _xifexpression_3 = _builder_2.toString(); - } - _xifexpression_2 = _xifexpression_3; - } - _xifexpression_1 = _xifexpression_2; - } - _xblockexpression_1 = _xifexpression_1; - } - _xifexpression = _xblockexpression_1; - } else { - String _xifexpression_1 = null; - boolean _isDataClass = this.typeHelpers.isDataClass(aType); - if (_isDataClass) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<Attribute> _attributes = ((DataClass) aType).getAttributes(); - for(final Attribute e : _attributes) { - CharSequence _invokeGetter = this.helpers.invokeGetter(a.getName(), null); - String _plus = ((invokes + ".") + _invokeGetter); - String _applyInstanceConfig = this.applyInstanceConfig(instance, _plus, this._roomExtensions.<Attribute>union(path, e)); - _builder.append(_applyInstanceConfig); - _builder.newLineIfNotEmpty(); - } - } - _xifexpression_1 = _builder.toString(); - } - _xifexpression = _xifexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - public CharSequence genDynConfigGetterSetter(final ActorClass ac) { - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac); - for(final Attribute a : _dynConfigReadAttributes) { - _builder.append("public "); - String _typeName = this.typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName); - { - int _size = a.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("[]"); - } - } - _builder.append(" get"); - String _firstUpper = StringExtensions.toFirstUpper(a.getName()); - _builder.append(_firstUpper); - _builder.append("(){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if(lock_"); - String _name = a.getName(); - _builder.append(_name, "\t"); - _builder.append(" == null)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("return "); - String _name_1 = a.getName(); - _builder.append(_name_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("synchronized(lock_"); - String _name_2 = a.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("return "); - String _name_3 = a.getName(); - _builder.append(_name_3, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("public void set"); - String _firstUpper_1 = StringExtensions.toFirstUpper(a.getName()); - _builder.append(_firstUpper_1); - _builder.append("("); - String _typeName_1 = this.typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName_1); - { - int _size_1 = a.getSize(); - boolean _greaterThan_1 = (_size_1 > 0); - if (_greaterThan_1) { - _builder.append("[]"); - } - } - _builder.append(" "); - String _name_4 = a.getName(); - _builder.append(_name_4); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if(lock_"); - String _name_5 = a.getName(); - _builder.append(_name_5, "\t"); - _builder.append(" == null)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("this."); - String _name_6 = a.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append(" = "); - String _name_7 = a.getName(); - _builder.append(_name_7, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("synchronized(lock_"); - String _name_8 = a.getName(); - _builder.append(_name_8, "\t\t"); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("this."); - String _name_9 = a.getName(); - _builder.append(_name_9, "\t\t\t"); - _builder.append(" = "); - String _name_10 = a.getName(); - _builder.append(_name_10, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("public DynConfigLock get"); - String _firstUpper_2 = StringExtensions.toFirstUpper(a.getName()); - _builder.append(_firstUpper_2); - _builder.append("Lock(){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return lock_"); - String _name_11 = a.getName(); - _builder.append(_name_11, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("}\t"); - _builder.newLine(); - } - } - { - List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac); - for(final Attribute a_1 : _dynConfigWriteAttributes) { - _builder.append("public void setAndWrite"); - String _firstUpper_3 = StringExtensions.toFirstUpper(a_1.getName()); - _builder.append(_firstUpper_3); - _builder.append("("); - String _typeName_2 = this.typeHelpers.typeName(a_1.getType().getType()); - _builder.append(_typeName_2); - { - int _size_2 = a_1.getSize(); - boolean _greaterThan_2 = (_size_2 > 0); - if (_greaterThan_2) { - _builder.append("[]"); - } - } - _builder.append(" "); - String _name_12 = a_1.getName(); - _builder.append(_name_12); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("set"); - String _firstUpper_4 = StringExtensions.toFirstUpper(a_1.getName()); - _builder.append(_firstUpper_4, "\t\t"); - _builder.append("("); - String _name_13 = a_1.getName(); - _builder.append(_name_13, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("variableService.write(this.getInstancePath()+\"/"); - String _name_14 = a_1.getName(); - _builder.append(_name_14, "\t\t"); - _builder.append("\", "); - String _name_15 = a_1.getName(); - _builder.append(_name_15, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - return _builder; - } - - public String genMinMaxConstants(final ActorClass ac) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<Attribute> _attributes = ac.getAttributes(); - for(final Attribute a : _attributes) { - String _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, a.getName(), this._roomExtensions.<Attribute>union(new ArrayList<Attribute>(), a)); - _builder.append(_genMinMaxConstantsRec); - _builder.newLineIfNotEmpty(); - } - } - String result = _builder.toString(); - int _length = result.length(); - boolean _notEquals = (_length != 0); - if (_notEquals) { - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("//--------------------- Attribute Specifications"); - String _plus = (result + _builder_1); - result = _plus; - } - return result; - } - - private String genMinMaxConstantsRec(final ActorClass ac, final String varNamePath, final List<Attribute> path) { - String _xblockexpression = null; - { - String temp = ((String) null); - String _xifexpression = null; - boolean _isDataClass = this.typeHelpers.isDataClass(IterableExtensions.<Attribute>last(path).getType().getType()); - if (_isDataClass) { - StringConcatenation _builder = new StringConcatenation(); - { - DataType _type = IterableExtensions.<Attribute>last(path).getType().getType(); - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(((DataClass) _type)); - for(final Attribute e : _allAttributes) { - String _name = e.getName(); - String _plus = ((varNamePath + "_") + _name); - String _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus, this._roomExtensions.<Attribute>union(path, e)); - _builder.append(_genMinMaxConstantsRec); - _builder.newLineIfNotEmpty(); - } - } - _xifexpression = _builder.toString(); - } else { - String _xifexpression_1 = null; - DataType _type_1 = IterableExtensions.<Attribute>last(path).getType().getType(); - if ((_type_1 instanceof ExternalType)) { - _xifexpression_1 = null; - } else { - String _xifexpression_2 = null; - DataType _type_2 = IterableExtensions.<Attribute>last(path).getType().getType(); - if ((_type_2 instanceof EnumerationType)) { - _xifexpression_2 = null; - } else { - String _xblockexpression_1 = null; - { - DataType _type_3 = IterableExtensions.<Attribute>last(path).getType().getType(); - PrimitiveType aType = ((PrimitiveType) _type_3); - StringConcatenation _builder_1 = new StringConcatenation(); - { - boolean _notEquals = (!Objects.equal((temp = this.dataConfigExt.getAttrClassConfigMinValue(ac, path)), null)); - if (_notEquals) { - _builder_1.append("public static "); - String _minMaxType = this.getMinMaxType(aType); - _builder_1.append(_minMaxType); - _builder_1.append(" MIN_"); - _builder_1.append(varNamePath); - _builder_1.append(" = "); - String _valueLiteral = this.stdExt.toValueLiteral(aType, temp); - _builder_1.append(_valueLiteral); - _builder_1.append(";"); - _builder_1.newLineIfNotEmpty(); - } - } - { - boolean _notEquals_1 = (!Objects.equal((temp = this.dataConfigExt.getAttrClassConfigMaxValue(ac, path)), null)); - if (_notEquals_1) { - _builder_1.append("public static "); - String _minMaxType_1 = this.getMinMaxType(aType); - _builder_1.append(_minMaxType_1); - _builder_1.append(" MAX_"); - _builder_1.append(varNamePath); - _builder_1.append(" = "); - String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, temp); - _builder_1.append(_valueLiteral_1); - _builder_1.append(";"); - _builder_1.newLineIfNotEmpty(); - } - } - _xblockexpression_1 = _builder_1.toString(); - } - _xifexpression_2 = _xblockexpression_1; - } - _xifexpression_1 = _xifexpression_2; - } - _xifexpression = _xifexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - private String getMinMaxType(final PrimitiveType type) { - String _switchResult = null; - String _typeName = this.typeHelpers.typeName(type); - if (_typeName != null) { - switch (_typeName) { - case "byte": - _switchResult = "int"; - break; - case "short": - _switchResult = "int"; - break; - case "float": - _switchResult = "double"; - break; - default: - _switchResult = this.typeHelpers.typeName(type); - break; - } - } else { - _switchResult = this.typeHelpers.typeName(type); - } - return _switchResult; - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java deleted file mode 100644 index 079407806..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java +++ /dev/null @@ -1,581 +0,0 @@ -/** - * Copyright (c) 2010 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * Peter Karlitschek - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.Collections; -import java.util.List; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.common.base.KeyValue; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.EnumLiteral; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.ExternalType; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.PrimitiveType; -import org.eclipse.etrice.core.room.RefableType; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase; -import org.eclipse.etrice.generator.generic.ILanguageExtension; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.util.Pair; -import org.eclipse.xtext.util.Strings; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@Singleton -@SuppressWarnings("all") -public class CppExtensions implements ILanguageExtension { - @Inject - private IDiagnostician diagnostician; - - @Inject - @Extension - private TypeHelpers _typeHelpers; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Override - public String getTypedDataDefinition(final EObject msg) { - return this.generateArglistAndTypedData(((Message) msg).getData())[ILanguageExtensionBase.TypedDataKind.DECLARATION_AND_INITIALIZATION.ordinal()]; - } - - public String getCppHeaderFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + ".h"); - } - - public String getCppSourceFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + ".cpp"); - } - - public String getCppClassName(final NodeRef nr, final SubSystemInstance ssi) { - String _name = nr.getName(); - String _plus = ("Node_" + _name); - String _plus_1 = (_plus + "_"); - String _name_1 = ssi.getName(); - return (_plus_1 + _name_1); - } - - public String getCppHeaderFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _cppClassName = this.getCppClassName(nr, ssi); - return (_cppClassName + ".h"); - } - - public String getCppSourceFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _cppClassName = this.getCppClassName(nr, ssi); - return (_cppClassName + ".cpp"); - } - - @Override - public String accessLevelPrivate() { - return ""; - } - - @Override - public String accessLevelProtected() { - return ""; - } - - @Override - public String accessLevelPublic() { - return ""; - } - - @Override - public String memberAccess() { - return "this->"; - } - - @Override - public String selfPointer(final String classname, final boolean hasArgs) { - return ""; - } - - @Override - public String selfPointer(final boolean hasArgs) { - return ""; - } - - @Override - public String scopeSeparator() { - return "::"; - } - - @Override - public String operationScope(final String classname, final boolean isDeclaration) { - String _xifexpression = null; - if (isDeclaration) { - _xifexpression = ""; - } else { - _xifexpression = (classname + "::"); - } - return _xifexpression; - } - - @Override - public String memberInDeclaration(final String namespace, final String member) { - return member; - } - - @Override - public String memberInUse(final String namespace, final String member) { - return ((namespace + ".") + member); - } - - @Override - public boolean usesInheritance() { - return true; - } - - @Override - public boolean usesPointers() { - return true; - } - - @Override - public String genEnumeration(final String name, final List<Pair<String, String>> entries) { - String _xblockexpression = null; - { - boolean _isEmpty = entries.isEmpty(); - if (_isEmpty) { - return ""; - } - StringConcatenation _builder = new StringConcatenation(); - _builder.append("typedef enum {"); - _builder.newLine(); - { - boolean _hasElements = false; - for(final Pair<String, String> entry : entries) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - String _first = entry.getFirst(); - _builder.append(_first, "\t"); - _builder.append(" = "); - String _second = entry.getSecond(); - _builder.append(_second, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("} "); - _builder.append(name); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - @Override - public String booleanConstant(final boolean b) { - return Boolean.valueOf(b).toString(); - } - - @Override - public String pointerLiteral() { - return "*"; - } - - @Override - public String nullPointer() { - return "0"; - } - - @Override - public String voidPointer() { - return "void*"; - } - - @Override - public String arrayType(final String type, final int size, final boolean isRef) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("StaticArray<"); - _builder.append(type); - { - if (isRef) { - _builder.append("*"); - } - } - _builder.append(", "); - _builder.append(size); - _builder.append(">"); - return _builder.toString(); - } - - @Override - public String arrayDeclaration(final String type, final int size, final boolean isRef, final String name) { - String _arrayType = this.arrayType(type, size, isRef); - String _plus = (_arrayType + " "); - return (_plus + name); - } - - public String getIncludeGuardString(final RoomClass roomClass, final String appendSegments) { - String[] _split = this._roomExtensions.getPackage(roomClass).split("\\."); - String _name = roomClass.getName(); - Iterable<String> _plus = Iterables.<String>concat(((Iterable<? extends String>)Conversions.doWrapArray(_split)), Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_name))); - String[] _split_1 = appendSegments.split("\\."); - final Function1<String, Boolean> _function = (String it) -> { - boolean _isEmpty = it.isEmpty(); - return Boolean.valueOf((!_isEmpty)); - }; - String _upperCase = IterableExtensions.join(IterableExtensions.<String>filter(Iterables.<String>concat(_plus, ((Iterable<? extends String>)Conversions.doWrapArray(_split_1))), _function), "_").toUpperCase(); - String _plus_1 = ("_" + _upperCase); - return (_plus_1 + "_H_"); - } - - public CharSequence generateIncludeGuardBegin(final RoomClass roomClass, final String appendSegments) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("#ifndef "); - String _includeGuardString = this.getIncludeGuardString(roomClass, appendSegments); - _builder.append(_includeGuardString); - _builder.newLineIfNotEmpty(); - _builder.append("#define "); - String _includeGuardString_1 = this.getIncludeGuardString(roomClass, appendSegments); - _builder.append(_includeGuardString_1); - _builder.newLineIfNotEmpty(); - return _builder; - } - - public CharSequence generateIncludeGuardEnd(final RoomClass roomClass, final String appendSegments) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("#endif /* "); - String _includeGuardString = this.getIncludeGuardString(roomClass, appendSegments); - _builder.append(_includeGuardString); - _builder.append(" */"); - return _builder; - } - - public String generateNamespaceBegin(final RoomClass roomClass) { - return ""; - } - - public String generateNamespaceEnd(final RoomClass roomClass) { - return ""; - } - - @Override - public String superCall(final String baseClassName, final String method, final String arguments) { - return (((((baseClassName + "::") + method) + "(") + arguments) + ");"); - } - - @Override - public String toValueLiteral(final PrimitiveType type, final String value) { - throw new UnsupportedOperationException("TODO Config for Cpp"); - } - - @Override - public String toEnumLiteral(final EnumerationType type, final String value) { - throw new UnsupportedOperationException("TODO Config for Cpp"); - } - - @Override - public String defaultValue(final DataType dt) { - String _switchResult = null; - final DataType it = dt; - boolean _matched = false; - if (it instanceof PrimitiveType) { - _matched=true; - _switchResult = ((PrimitiveType)it).getDefaultValueLiteral(); - } - if (!_matched) { - if (it instanceof EnumerationType) { - _matched=true; - String _xblockexpression = null; - { - this.diagnostician.error("Enumeration not supported", dt, null); - _xblockexpression = "/* TODO */"; - } - _switchResult = _xblockexpression; - } - } - if (!_matched) { - if (it instanceof ExternalType) { - _matched=true; - _switchResult = ((ExternalType)it).getDefaultValueLiteral(); - } - } - return _switchResult; - } - - public String getDefaultValue(final EnumerationType type) { - String _xifexpression = null; - boolean _isEmpty = type.getLiterals().isEmpty(); - if (_isEmpty) { - _xifexpression = ""; - } else { - _xifexpression = this.getCastedValue(type.getLiterals().get(0)); - } - return _xifexpression; - } - - @Override - public String initializationWithDefaultValues(final DataType dt, final int size) { - String _xblockexpression = null; - { - final String dv = this.defaultValue(dt); - String _xifexpression = null; - if ((size > 1)) { - String _xblockexpression_1 = null; - { - String res = "{"; - int i = 0; - while ((i < size)) { - { - res = (res + dv); - i = (i + 1); - if ((i < size)) { - res = (res + ","); - } - } - } - _xblockexpression_1 = (res + "}"); - } - _xifexpression = _xblockexpression_1; - } else { - _xifexpression = dv; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String[] generateArglistAndTypedData(final EObject d) { - if ((Objects.equal(d, null) || (!(d instanceof VarDecl)))) { - return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class)); - } - final VarDecl data = ((VarDecl) d); - String _switchResult = null; - DataType _type = data.getRefType().getType(); - final DataType it = _type; - boolean _matched = false; - if (it instanceof PrimitiveType) { - boolean _isEmpty = Strings.isEmpty(((PrimitiveType)it).getCastName()); - boolean _not = (!_isEmpty); - if (_not) { - _matched=true; - _switchResult = ((PrimitiveType)it).getCastName(); - } - } - if (!_matched) { - if (it instanceof EnumerationType) { - _matched=true; - _switchResult = this.getCastType(((EnumerationType)it)); - } - } - if (!_matched) { - _switchResult = this._typeHelpers.typeName(it); - } - final String castExpr = (_switchResult + "*"); - String _typeName = this._typeHelpers.typeName(data.getRefType().getType()); - String _switchResult_1 = null; - RefableType _refType = data.getRefType(); - final RefableType it_1 = _refType; - boolean _matched_1 = false; - boolean _isRef = it_1.isRef(); - if (_isRef) { - _matched_1=true; - _switchResult_1 = "*"; - } - if (!_matched_1) { - boolean _isPrimitive = this._typeHelpers.isPrimitive(it_1.getType()); - if (_isPrimitive) { - _matched_1=true; - _switchResult_1 = ""; - } - } - if (!_matched_1) { - _switchResult_1 = "&"; - } - final String typeExpr = (_typeName + _switchResult_1); - String _xifexpression = null; - boolean _isRef_1 = data.getRefType().isRef(); - boolean _not = (!_isRef_1); - if (_not) { - _xifexpression = "*"; - } else { - _xifexpression = ""; - } - String deRef = _xifexpression; - StringConcatenation _builder = new StringConcatenation(); - _builder.append(", "); - _builder.append(ILanguageExtension.GENERIC_DATA_NAME); - final String dataArg = _builder.toString(); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append(typeExpr); - _builder_1.append(" "); - _builder_1.append(ILanguageExtension.GENERIC_DATA_NAME); - _builder_1.append(" = "); - _builder_1.append(deRef); - _builder_1.append("(static_cast<"); - _builder_1.append(castExpr); - _builder_1.append(">(generic_data__et));"); - final String typedData = (_builder_1.toString() + this._roomExtensions.NEWLINE); - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append(", "); - _builder_2.append(typeExpr); - _builder_2.append(" "); - _builder_2.append(ILanguageExtension.GENERIC_DATA_NAME); - final String typedArgList = _builder_2.toString(); - return new String[] { dataArg, typedData, typedArgList }; - } - - @Override - public String getTargetType(final EnumerationType type) { - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = type.getPrimitiveType().getTargetName(); - } else { - _xifexpression = type.getName(); - } - return _xifexpression; - } - - @Override - public String getCastedValue(final EnumLiteral literal) { - String _xblockexpression = null; - { - EObject _eContainer = literal.eContainer(); - final EnumerationType type = ((EnumerationType) _eContainer); - final String cast = this.getTargetType(type); - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = Long.toString(literal.getLiteralValue()); - } else { - String _string = Long.toString(literal.getLiteralValue()); - String _plus = ((("((" + cast) + ")") + _string); - _xifexpression = (_plus + ")"); - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String getCastType(final EnumerationType type) { - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = type.getPrimitiveType().getCastName(); - } else { - _xifexpression = type.getName(); - } - return _xifexpression; - } - - @Override - public String makeOverridable() { - return "virtual "; - } - - /** - * check if there is an ImplementationSubclass annotation and return its fully qualified name or the actor class name - */ - public String getImplementationClassName(final ActorClass ac) { - String _xblockexpression = null; - { - final List<KeyValue> attributes = this._roomHelpers.getAttributes(ac, "ImplementationSubclass"); - String _xifexpression = null; - boolean _isEmpty = attributes.isEmpty(); - if (_isEmpty) { - _xifexpression = ac.getName(); - } else { - final Function1<KeyValue, Boolean> _function = (KeyValue it) -> { - String _key = it.getKey(); - return Boolean.valueOf(Objects.equal(_key, "fqnClassName")); - }; - _xifexpression = this._roomHelpers.literalToString(IterableExtensions.<KeyValue>head(IterableExtensions.<KeyValue>filter(attributes, _function)).getValue()); - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - /** - * check if there is an ImplementationSubclass annotation. If it also has an includePath use it. - * If there is not includePath, use the class name as base file name. - * If there is no annotation use the default path. - */ - public String getActorIncludePath(final ActorClass ac) { - String _xblockexpression = null; - { - final List<KeyValue> attributes = this._roomHelpers.getAttributes(ac, "ImplementationSubclass"); - String _xifexpression = null; - boolean _isEmpty = attributes.isEmpty(); - if (_isEmpty) { - String _path = this._roomExtensions.getPath(ac); - String _name = ac.getName(); - String _plus = (_path + _name); - _xifexpression = (_plus + ".h"); - } else { - String _xblockexpression_1 = null; - { - final Function1<KeyValue, Boolean> _function = (KeyValue it) -> { - String _key = it.getKey(); - return Boolean.valueOf(Objects.equal(_key, "includePath")); - }; - final Iterable<KeyValue> path = IterableExtensions.<KeyValue>filter(attributes, _function); - String _xifexpression_1 = null; - boolean _isEmpty_1 = IterableExtensions.isEmpty(path); - if (_isEmpty_1) { - String _xblockexpression_2 = null; - { - final Function1<KeyValue, Boolean> _function_1 = (KeyValue it) -> { - String _key = it.getKey(); - return Boolean.valueOf(Objects.equal(_key, "fqnClassName")); - }; - final String baseName = IterableExtensions.<String>last(((Iterable<String>)Conversions.doWrapArray(this._roomHelpers.literalToString(IterableExtensions.<KeyValue>head(IterableExtensions.<KeyValue>filter(attributes, _function_1)).getValue()).split("::")))); - _xblockexpression_2 = (baseName + ".h"); - } - _xifexpression_1 = _xblockexpression_2; - } else { - _xifexpression_1 = this._roomHelpers.literalToString(IterableExtensions.<KeyValue>head(path).getValue()); - } - _xblockexpression_1 = _xifexpression_1; - } - _xifexpression = _xblockexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java deleted file mode 100644 index eb5cf13b8..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java +++ /dev/null @@ -1,623 +0,0 @@ -/** - * Copyright (c) 2011 Draeger Medical GmbH (http://www.draeger.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Peter Karlitschek (initial contribution) - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -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.RoomModel; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.cpp.gen.CppExtensions; -import org.eclipse.etrice.generator.cpp.gen.CppProcedureHelpers; -import org.eclipse.etrice.generator.cpp.gen.Initialization; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.generator.JavaIoFileSystemAccess; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class DataClassGen { - @Inject - @Extension - private JavaIoFileSystemAccess fileAccess; - - @Inject - @Extension - private CppExtensions stdExt; - - @Inject - @Extension - private RoomExtensions roomExt; - - @Inject - @Extension - private CppProcedureHelpers helpers; - - @Inject - private Initialization initHelper; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - this.logger.logInfo("generating code"); - EList<DataClass> _dataClasses = root.getDataClasses(); - for (final DataClass dc : _dataClasses) { - { - String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc); - String _path = this.roomExt.getPath(dc); - String path = (_generationTargetPath + _path); - String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc); - String _plus = ("generating DataClass header \'" + _cppHeaderFileName); - String _plus_1 = (_plus + "\' in \'"); - String _plus_2 = (_plus_1 + path); - String _plus_3 = (_plus_2 + "\'"); - this.logger.logInfo(_plus_3); - this.fileAccess.setOutputPath(path); - this.fileAccess.generateFile(this.stdExt.getCppHeaderFileName(dc), this.generateHeaderFile(root, dc)); - String _cppSourceFileName = this.stdExt.getCppSourceFileName(dc); - String _plus_4 = ("generating DataClass source \'" + _cppSourceFileName); - String _plus_5 = (_plus_4 + "\' in \'"); - String _plus_6 = (_plus_5 + path); - String _plus_7 = (_plus_6 + "\'"); - this.logger.logInfo(_plus_7); - this.fileAccess.setOutputPath(path); - this.fileAccess.generateFile(this.stdExt.getCppSourceFileName(dc), this.generateSourceFile(root, dc)); - } - } - } - - public CharSequence generateHeaderFile(final Root root, final DataClass dc) { - StringConcatenation _builder = new StringConcatenation(); - CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(dc, ""); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/etDatatypesCpp.hpp\""); - _builder.newLine(); - { - DataClass _base = dc.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - _builder.append("#include \""); - String _path = this.roomExt.getPath(dc.getBase()); - _builder.append(_path); - String _name = dc.getBase().getName(); - _builder.append(_name); - _builder.append(".h\""); - } - } - _builder.newLineIfNotEmpty(); - { - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc); - for(final DataClass classes : _referencedDataClasses) { - _builder.append("#include \""); - String _path_1 = this.roomExt.getPath(classes); - _builder.append(_path_1); - String _name_1 = classes.getName(); - _builder.append(_name_1); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - { - EList<RoomModel> _referencedModels = root.getReferencedModels(dc); - for(final RoomModel model : _referencedModels) { - { - EList<DataClass> _dataClasses = model.getDataClasses(); - for(final DataClass classes_1 : _dataClasses) { - _builder.append("#include \""); - String _path_2 = this.roomExt.getPath(classes_1); - _builder.append(_path_2); - String _name_2 = classes_1.getName(); - _builder.append(_name_2); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(dc.getUserCode1()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("using namespace etRuntime; // TODO JH remove"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this.stdExt.generateNamespaceBegin(dc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("class "); - String _name_3 = dc.getName(); - _builder.append(_name_3); - { - DataClass _base_1 = dc.getBase(); - boolean _notEquals_1 = (!Objects.equal(_base_1, null)); - if (_notEquals_1) { - _builder.append(" : public "); - String _name_4 = dc.getBase().getName(); - _builder.append(_name_4); - } - } - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this.helpers.userCode(dc.getUserCode2()); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _attributes = this.helpers.attributes(dc.getAttributes()); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(dc.getAttributes(), dc.getName()); - _builder.append(_attributeSettersGettersImplementation, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(dc.getOperations(), dc.getName()); - _builder.append(_operationsDeclaration, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// default constructor, copy constructor and assignment operator"); - _builder.newLine(); - _builder.append("\t"); - String _name_5 = dc.getName(); - _builder.append(_name_5, "\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _name_6 = dc.getName(); - _builder.append(_name_6, "\t"); - _builder.append("(const "); - String _name_7 = dc.getName(); - _builder.append(_name_7, "\t"); - _builder.append("& rhs);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("// constructor using fields"); - _builder.newLine(); - _builder.append("\t"); - { - boolean _isEmpty = this._roomHelpers.getAllAttributes(dc).isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - String _name_8 = dc.getName(); - _builder.append(_name_8, "\t"); - _builder.append("("); - String _constArgList = this.helpers.constArgList(this._roomHelpers.getAllAttributes(dc)); - _builder.append(_constArgList, "\t"); - _builder.append(");"); - } - } - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - String _name_9 = dc.getName(); - _builder.append(_name_9, "\t"); - _builder.append("& operator=(const "); - String _name_10 = dc.getName(); - _builder.append(_name_10, "\t"); - _builder.append("& rhs);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceEnd = this.stdExt.generateNamespaceEnd(dc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(dc, ""); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - return _builder; - } - - public CharSequence generateSourceFile(final Root root, final DataClass dc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of DataClass "); - String _name = dc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc); - _builder.append(_cppHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"etUnit/etUnit.h\""); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this.stdExt.generateNamespaceBegin(dc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(dc.getUserCode3()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("// default constructor"); - _builder.newLine(); - String _name_1 = dc.getName(); - _builder.append(_name_1); - _builder.append("::"); - String _name_2 = dc.getName(); - _builder.append(_name_2); - _builder.append("()"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _generateDefaultInitalizerList = this.generateDefaultInitalizerList(dc); - _builder.append(_generateDefaultInitalizerList, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - CharSequence _genExtraInitializers = this.initHelper.genExtraInitializers(dc.getAttributes()); - _builder.append(_genExtraInitializers, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _userStructorBody = this.helpers.userStructorBody(dc, true); - _builder.append(_userStructorBody, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// copy constructor"); - _builder.newLine(); - String _name_3 = dc.getName(); - _builder.append(_name_3); - _builder.append("::"); - String _name_4 = dc.getName(); - _builder.append(_name_4); - _builder.append("(const "); - String _name_5 = dc.getName(); - _builder.append(_name_5); - _builder.append("& rhs)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _generateCopyInitalizerList = this.generateCopyInitalizerList(dc); - _builder.append(_generateCopyInitalizerList, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// constructor using fields"); - _builder.newLine(); - _builder.append("// TODO"); - _builder.newLine(); - { - boolean _isEmpty = this._roomHelpers.getAllAttributes(dc).isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - String _name_6 = dc.getName(); - _builder.append(_name_6); - _builder.append("::"); - String _name_7 = dc.getName(); - _builder.append(_name_7); - _builder.append("("); - String _constArgList = this.helpers.constArgList(this._roomHelpers.getAllAttributes(dc)); - _builder.append(_constArgList); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _generateFieldInitializerList = this.generateFieldInitializerList(dc); - _builder.append(_generateFieldInitializerList, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("// assignment operator"); - _builder.newLine(); - String _name_8 = dc.getName(); - _builder.append(_name_8); - _builder.append("& "); - String _name_9 = dc.getName(); - _builder.append(_name_9); - _builder.append("::operator=(const "); - String _name_10 = dc.getName(); - _builder.append(_name_10); - _builder.append("& rhs)"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("if (this == &rhs) { return *this; };"); - _builder.newLine(); - _builder.append("\t"); - { - DataClass _base = dc.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - String _name_11 = dc.getBase().getName(); - _builder.append(_name_11, "\t"); - _builder.append("::operator=(rhs);"); - } - } - _builder.newLineIfNotEmpty(); - { - EList<Attribute> _attributes = dc.getAttributes(); - for(final Attribute attr : _attributes) { - _builder.append("\t"); - _builder.append("this->"); - String _name_12 = attr.getName(); - _builder.append(_name_12, "\t"); - _builder.append(" = rhs."); - String _name_13 = attr.getName(); - _builder.append(_name_13, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("return *this;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - CharSequence _operationsImplementation = this.helpers.operationsImplementation(dc.getOperations(), dc.getName()); - _builder.append(_operationsImplementation); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _generateNamespaceEnd = this.stdExt.generateNamespaceEnd(dc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - return _builder; - } - - private CharSequence generateDefaultInitalizerList(final DataClass dataClass) { - CharSequence _xblockexpression = null; - { - @Extension - final Initialization initHelper = this.initHelper; - ArrayList<CharSequence> initList = CollectionLiterals.<CharSequence>newArrayList(); - DataClass _base = dataClass.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - String _name = dataClass.getBase().getName(); - String _plus = (_name + "()"); - initList.add(_plus); - } - final Function1<Attribute, String> _function = (Attribute it) -> { - StringConcatenation _builder = new StringConcatenation(); - String _name_1 = it.getName(); - _builder.append(_name_1); - _builder.append("("); - String _initializerListValue = initHelper.getInitializerListValue(it); - _builder.append(_initializerListValue); - _builder.append(")"); - return _builder.toString(); - }; - List<String> _map = ListExtensions.<Attribute, String>map(dataClass.getAttributes(), _function); - Iterables.<CharSequence>addAll(initList, _map); - _xblockexpression = initHelper.generateCtorInitializerList(initList); - } - return _xblockexpression; - } - - private CharSequence generateCopyInitalizerList(final DataClass dataClass) { - CharSequence _xblockexpression = null; - { - @Extension - final Initialization initHelper = this.initHelper; - ArrayList<CharSequence> initList = CollectionLiterals.<CharSequence>newArrayList(); - DataClass _base = dataClass.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - String _name = dataClass.getBase().getName(); - String _plus = (_name + "(rhs)"); - initList.add(_plus); - } - final Function1<Attribute, String> _function = (Attribute it) -> { - StringConcatenation _builder = new StringConcatenation(); - String _name_1 = it.getName(); - _builder.append(_name_1); - _builder.append("(rhs."); - String _name_2 = it.getName(); - _builder.append(_name_2); - _builder.append(")"); - return _builder.toString(); - }; - List<String> _map = ListExtensions.<Attribute, String>map(dataClass.getAttributes(), _function); - Iterables.<CharSequence>addAll(initList, _map); - _xblockexpression = initHelper.generateCtorInitializerList(initList); - } - return _xblockexpression; - } - - private CharSequence generateFieldInitializerList(final DataClass dataClass) { - CharSequence _xblockexpression = null; - { - @Extension - final Initialization initHelper = this.initHelper; - ArrayList<CharSequence> initList = CollectionLiterals.<CharSequence>newArrayList(); - DataClass _base = dataClass.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - StringConcatenation _builder = new StringConcatenation(); - String _name = dataClass.getBase().getName(); - _builder.append(_name); - _builder.append("("); - final Function1<Attribute, String> _function = (Attribute it) -> { - return it.getName(); - }; - String _join = IterableExtensions.join(ListExtensions.<Attribute, String>map(this._roomHelpers.getAllAttributes(dataClass.getBase()), _function), ", "); - _builder.append(_join); - _builder.append(")"); - initList.add(_builder.toString()); - } - final Function1<Attribute, String> _function_1 = (Attribute it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name_1 = it.getName(); - _builder_1.append(_name_1); - _builder_1.append("("); - String _name_2 = it.getName(); - _builder_1.append(_name_2); - _builder_1.append(")"); - return _builder_1.toString(); - }; - List<String> _map = ListExtensions.<Attribute, String>map(dataClass.getAttributes(), _function_1); - Iterables.<CharSequence>addAll(initList, _map); - _xblockexpression = initHelper.generateCtorInitializerList(initList); - } - return _xblockexpression; - } - - public String deepCopy(final DataClass _dc) { - String result = ""; - DataClass dc = _dc; - while ((!Objects.equal(dc, null))) { - { - String _string = this.deepCopy(dc.getAttributes()).toString(); - String _plus = (_string + result); - result = _plus; - dc = dc.getBase(); - } - } - return result; - } - - public CharSequence deepCopy(final List<Attribute> attributes) { - StringConcatenation _builder = new StringConcatenation(); - { - for(final Attribute a : attributes) { - { - DataType _type = a.getType().getType(); - if ((_type instanceof ComplexType)) { - _builder.append("if ("); - String _name = a.getName(); - _builder.append(_name); - _builder.append("!=null) {"); - _builder.newLineIfNotEmpty(); - { - int _size = a.getSize(); - boolean _equals = (_size == 0); - if (_equals) { - _builder.append("\t"); - _builder.append("copy."); - String _name_1 = a.getName(); - _builder.append(_name_1, "\t"); - _builder.append(" = "); - String _name_2 = a.getName(); - _builder.append(_name_2, "\t"); - _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, "\t"); - _builder.append(".length;i++){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("copy."); - String _name_4 = a.getName(); - _builder.append(_name_4, "\t\t"); - _builder.append("[i] = "); - String _name_5 = a.getName(); - _builder.append(_name_5, "\t\t"); - _builder.append("[i].deepCopy();"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - } else { - { - int _size_1 = a.getSize(); - boolean _equals_1 = (_size_1 == 0); - if (_equals_1) { - _builder.append("copy."); - String _name_6 = a.getName(); - _builder.append(_name_6); - _builder.append(" = "); - String _name_7 = a.getName(); - _builder.append(_name_7); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("for (int i=0;i<"); - String _name_8 = a.getName(); - _builder.append(_name_8); - _builder.append(".length;i++){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("copy."); - String _name_9 = a.getName(); - _builder.append(_name_9, "\t"); - _builder.append("[i] = "); - String _name_10 = a.getName(); - _builder.append(_name_10, "\t"); - _builder.append("[i];"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - } - } - } - } - return _builder; - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java deleted file mode 100644 index 8f75401a9..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java +++ /dev/null @@ -1,854 +0,0 @@ -/** - * Copyright (c) 2011 Draeger Medical GmbH (http://www.draeger.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Peter Karlitschek (initial contribution) - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.common.converter.TimeConverter; -import org.eclipse.etrice.core.etmap.util.ETMapUtil; -import org.eclipse.etrice.core.etphys.eTPhys.ExecMode; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.etphys.eTPhys.PhysicalThread; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Wire; -import org.eclipse.etrice.core.genmodel.etricegen.WiredSubSystemClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.generator.cpp.Main; -import org.eclipse.etrice.generator.cpp.gen.CppExtensions; -import org.eclipse.etrice.generator.cpp.gen.Initialization; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.fsm.base.Indexed; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class NodeGen { - @Inject - @Extension - private CppExtensions _cppExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private ProcedureHelpers _procedureHelpers; - - @Inject - @Extension - private FileSystemHelpers _fileSystemHelpers; - - @Inject - private IGeneratorFileIo fileIO; - - @Inject - private Initialization initHelper; - - public void doGenerate(final Root root) { - final Map<SubSystemClass, WiredSubSystemClass> sscc2wired = CollectionLiterals.<SubSystemClass, WiredSubSystemClass>newHashMap(); - final Consumer<WiredSubSystemClass> _function = (WiredSubSystemClass it) -> { - sscc2wired.put(it.getSubSystemClass(), it); - }; - Iterables.<WiredSubSystemClass>filter(root.getWiredInstances(), WiredSubSystemClass.class).forEach(_function); - Collection<NodeRef> _nodeRefs = ETMapUtil.getNodeRefs(); - for (final NodeRef nr : _nodeRefs) { - List<String> _subSystemInstancePaths = ETMapUtil.getSubSystemInstancePaths(nr); - for (final String instpath : _subSystemInstancePaths) { - { - StructureInstance _instance = root.getInstance(instpath); - final SubSystemInstance ssi = ((SubSystemInstance) _instance); - if (((!Objects.equal(ssi, null)) && this._fileSystemHelpers.isValidGenerationLocation(ssi.getSubSystemClass()))) { - final WiredSubSystemClass wired = sscc2wired.get(ssi.getSubSystemClass()); - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(ssi.getSubSystemClass()); - String _path = this._roomExtensions.getPath(ssi.getSubSystemClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(ssi.getSubSystemClass()); - String _path_1 = this._roomExtensions.getPath(ssi.getSubSystemClass()); - final String infopath = (_generationInfoPath + _path_1); - final Set<PhysicalThread> usedThreads = ETMapUtil.getUsedThreads(nr, ssi); - this.fileIO.generateFile("generating Node declaration", path, infopath, this._cppExtensions.getCppHeaderFileName(nr, ssi), this.generateHeaderFile(root, ssi, wired, usedThreads)); - this.fileIO.generateFile("generating Node implementation", path, infopath, this._cppExtensions.getCppSourceFileName(nr, ssi), this.generateSourceFile(root, ssi, wired, usedThreads)); - } - } - } - } - } - - public CharSequence generateHeaderFile(final Root root, final SubSystemInstance comp, final WiredSubSystemClass wired, final Collection<PhysicalThread> usedThreads) { - CharSequence _xblockexpression = null; - { - final SubSystemClass cc = comp.getSubSystemClass(); - final EList<RoomModel> models = root.getReferencedModels(cc); - final NodeRef nr = ETMapUtil.getNodeRef(comp); - final String clsname = this._cppExtensions.getCppClassName(nr, comp); - final Function1<PhysicalThread, Boolean> _function = (PhysicalThread t) -> { - return Boolean.valueOf(usedThreads.contains(t)); - }; - final Iterable<PhysicalThread> threads = IterableExtensions.<PhysicalThread>filter(nr.getType().getThreads(), _function); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of SubSystemClass "); - _builder.append(clsname, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(cc, ""); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/messaging/IMessageService.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/SubSystemClassBase.h\""); - _builder.newLine(); - { - EList<ActorInstance> _actorInstances = comp.getActorInstances(); - for(final ActorInstance ai : _actorInstances) { - _builder.append("#include \""); - String _actorIncludePath = this._cppExtensions.getActorIncludePath(ai.getActorClass()); - _builder.append(_actorIncludePath); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(cc.getUserCode1()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _generateNamespaceBegin = this._cppExtensions.generateNamespaceBegin(cc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("class "); - _builder.append(clsname); - _builder.append(" : public etRuntime::SubSystemClassBase{"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this._procedureHelpers.userCode(cc.getUserCode2()); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public:"); - _builder.newLine(); - { - Iterable<Indexed<PhysicalThread>> _indexed = Indexed.<PhysicalThread>indexed(threads); - for(final Indexed<PhysicalThread> thread : _indexed) { - _builder.append("\t\t"); - _builder.append("static const int "); - String _threadId = this.getThreadId(thread.getValue()); - _builder.append(_threadId, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// sub actors"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs = cc.getActorRefs(); - for(final ActorRef sub : _actorRefs) { - { - int _multiplicity = sub.getMultiplicity(); - boolean _greaterThan = (_multiplicity > 1); - if (_greaterThan) { - _builder.append("\t\t"); - _builder.append("Replicated"); - String _implementationClassName = this._cppExtensions.getImplementationClassName(sub.getType()); - _builder.append(_implementationClassName, "\t\t"); - _builder.append(" "); - String _name = sub.getName(); - _builder.append(_name, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t\t"); - String _implementationClassName_1 = this._cppExtensions.getImplementationClassName(sub.getType()); - _builder.append(_implementationClassName_1, "\t\t"); - _builder.append(" "); - String _name_1 = sub.getName(); - _builder.append(_name_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(clsname, "\t\t"); - _builder.append("(IRTObject* parent, const String& name);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("~"); - _builder.append(clsname, "\t\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void instantiateMessageServices();"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void mapThreads(void);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void initialize(void);"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t\t"); - _builder.append("virtual void setProbesActive(bool recursive, bool active);"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void init();"); - _builder.newLine(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t\t"); - _builder.append("etBool hasGeneratedMSCInstrumentation() const { return true; }"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual void destroy();"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("private:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// MessageServices"); - _builder.newLine(); - { - for(final PhysicalThread thread_1 : threads) { - _builder.append("\t\t"); - _builder.append("IMessageService* msgSvc_"); - String _name_2 = thread_1.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(clsname, "\t\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append(clsname, "\t\t"); - _builder.append("("); - _builder.append(clsname, "\t\t"); - _builder.append(" const&);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append(clsname, "\t\t"); - _builder.append("& operator=("); - _builder.append(clsname, "\t\t"); - _builder.append(" const&);"); - _builder.newLineIfNotEmpty(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceEnd = this._cppExtensions.generateNamespaceEnd(cc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(cc, ""); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String getThreadId(final PhysicalThread thread) { - String _upperCase = thread.getName().toUpperCase(); - return ("THREAD_" + _upperCase); - } - - private CharSequence generateConstructorInitalizerList(final SubSystemClass cc) { - CharSequence _xblockexpression = null; - { - @Extension - final Initialization initHelper = this.initHelper; - ArrayList<CharSequence> initList = CollectionLiterals.<CharSequence>newArrayList(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("SubSystemClassBase(parent, name)"); - initList.add(_builder.toString()); - final Function1<ActorRef, String> _function = (ActorRef it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name = it.getName(); - _builder_1.append(_name); - _builder_1.append("(this, \""); - String _name_1 = it.getName(); - _builder_1.append(_name_1); - _builder_1.append("\")"); - return _builder_1.toString(); - }; - List<String> _map = ListExtensions.<ActorRef, String>map(cc.getActorRefs(), _function); - Iterables.<CharSequence>addAll(initList, _map); - _xblockexpression = initHelper.generateCtorInitializerList(initList); - } - return _xblockexpression; - } - - public CharSequence generateSourceFile(final Root root, final SubSystemInstance comp, final WiredSubSystemClass wired, final Collection<PhysicalThread> usedThreads) { - CharSequence _xblockexpression = null; - { - final SubSystemClass cc = comp.getSubSystemClass(); - final EList<RoomModel> models = root.getReferencedModels(cc); - final NodeRef nr = ETMapUtil.getNodeRef(comp); - final String clsname = this._cppExtensions.getCppClassName(nr, comp); - final Function1<PhysicalThread, Boolean> _function = (PhysicalThread t) -> { - return Boolean.valueOf(usedThreads.contains(t)); - }; - final Iterable<PhysicalThread> threads = IterableExtensions.<PhysicalThread>filter(nr.getType().getThreads(), _function); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of SubsystemClass "); - _builder.append(clsname, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(nr, comp); - _builder.append(_cppHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/debugging/DebuggingService.h\""); - _builder.newLine(); - _builder.append("#include \"common/debugging/MSCFunctionObject.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/IMessageService.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/MessageService.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/MessageServiceController.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/RTServices.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/StaticMessageMemory.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/InterfaceItemBase.h\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("using namespace etRuntime;"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this._cppExtensions.generateNamespaceBegin(cc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - Iterable<Indexed<PhysicalThread>> _indexed = Indexed.<PhysicalThread>indexed(threads); - for(final Indexed<PhysicalThread> thread : _indexed) { - _builder.append("const int "); - _builder.append(clsname); - _builder.append("::"); - String _threadId = this.getThreadId(thread.getValue()); - _builder.append(_threadId); - _builder.append(" = "); - int _index0 = thread.getIndex0(); - _builder.append(_index0); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append(clsname); - _builder.append("::"); - _builder.append(clsname); - _builder.append("(IRTObject* parent, const String& name)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(cc); - _builder.append(_generateConstructorInitalizerList, "\t\t"); - _builder.newLineIfNotEmpty(); - { - for(final PhysicalThread thread_1 : threads) { - _builder.append("\t\t"); - _builder.append(", msgSvc_"); - String _name = thread_1.getName(); - _builder.append(_name, "\t\t"); - _builder.append("(NULL)"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("{"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"Constructor\");"); - _builder.newLine(); - } - } - { - EList<ActorRef> _actorRefs = cc.getActorRefs(); - for(final ActorRef sub : _actorRefs) { - { - int _multiplicity = sub.getMultiplicity(); - boolean _greaterThan = (_multiplicity > 1); - if (_greaterThan) { - _builder.append("\t"); - String _name_1 = sub.getName(); - _builder.append(_name_1, "\t"); - _builder.append(".createSubActors("); - int _multiplicity_1 = sub.getMultiplicity(); - _builder.append(_multiplicity_1, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append(clsname); - _builder.append("::~"); - _builder.append(clsname); - _builder.append("() {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"Destructor\");"); - _builder.newLine(); - } - } - { - for(final PhysicalThread thread_2 : threads) { - _builder.append("\t"); - _builder.append("delete msgSvc_"); - String _name_2 = thread_2.getName(); - _builder.append(_name_2, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data){"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("::instantiateMessageServices(){"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"instantiateMessageServices()\");"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("IMessageMemory* msgMemory;"); - _builder.newLine(); - { - final Function1<PhysicalThread, Long> _function_1 = (PhysicalThread it) -> { - long _prio = it.getPrio(); - return Long.valueOf((-_prio)); - }; - List<PhysicalThread> _sortBy = IterableExtensions.<PhysicalThread, Long>sortBy(threads, _function_1); - for(final PhysicalThread thread_3 : _sortBy) { - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("msgMemory = new StaticMessageMemory(this, \"MessageMemory_"); - String _name_3 = thread_3.getName(); - _builder.append(_name_3, "\t\t"); - _builder.append("\", "); - int _msgblocksize = thread_3.getMsgblocksize(); - _builder.append(_msgblocksize, "\t\t"); - _builder.append(", "); - int _msgpoolsize = thread_3.getMsgpoolsize(); - _builder.append(_msgpoolsize, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - { - if ((Objects.equal(thread_3.getExecmode(), ExecMode.POLLED) || Objects.equal(thread_3.getExecmode(), ExecMode.MIXED))) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("etTime interval;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("interval.sec = "); - long _split = TimeConverter.split(thread_3.getTime(), TimeConverter.SEC, true); - _builder.append(_split, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("interval.nSec = "); - long _split_1 = TimeConverter.split(thread_3.getTime(), TimeConverter.MILLI_SEC, false); - _builder.append(_split_1, "\t\t"); - _builder.append("L;"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("msgSvc_"); - String _name_4 = thread_3.getName(); - _builder.append(_name_4, "\t\t"); - _builder.append(" = new MessageService(this, IMessageService::"); - String _name_5 = thread_3.getExecmode().getName(); - _builder.append(_name_5, "\t\t"); - _builder.append(", interval, 0, "); - String _threadId_1 = this.getThreadId(thread_3); - _builder.append(_threadId_1, "\t\t"); - _builder.append(", \"MessageService_"); - String _name_6 = thread_3.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append("\", msgMemory, "); - long _prio = thread_3.getPrio(); - _builder.append(_prio, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("msgSvc_"); - String _name_7 = thread_3.getName(); - _builder.append(_name_7, "\t\t"); - _builder.append(" = new MessageService(this, IMessageService::"); - String _name_8 = thread_3.getExecmode().getName(); - _builder.append(_name_8, "\t\t"); - _builder.append(", 0, "); - String _threadId_2 = this.getThreadId(thread_3); - _builder.append(_threadId_2, "\t\t"); - _builder.append(", \"MessageService_"); - String _name_9 = thread_3.getName(); - _builder.append(_name_9, "\t\t"); - _builder.append("\", msgMemory, "); - long _prio_1 = thread_3.getPrio(); - _builder.append(_prio_1, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(*msgSvc_"); - String _name_10 = thread_3.getName(); - _builder.append(_name_10, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("::mapThreads() {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("// thread mappings"); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances(); - for(final ActorInstance ai : _allContainedInstances) { - _builder.append("\t"); - final ETMapUtil.MappedThread mapped = ETMapUtil.getMappedThread(ai); - _builder.newLineIfNotEmpty(); - { - boolean _not = (!(mapped.isImplicit() || mapped.isAsParent())); - if (_not) { - _builder.append("\t"); - _builder.append("addPathToThread(\""); - String _path = ai.getPath(); - _builder.append(_path, "\t"); - _builder.append("\", "); - String _threadId_3 = this.getThreadId(mapped.getThread()); - _builder.append(_threadId_3, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("::initialize() {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_3 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_3) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().getSyncLogger().addVisibleComment(\"starting initialization\");"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"initialize()\");"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_1 = cc.getActorRefs(); - for(final ActorRef sub_1 : _actorRefs_1) { - { - int _multiplicity_2 = sub_1.getMultiplicity(); - boolean _greaterThan_1 = (_multiplicity_2 > 1); - if (_greaterThan_1) { - _builder.append("\t"); - _builder.append("for (int i=0; i<"); - int _multiplicity_3 = sub_1.getMultiplicity(); - _builder.append(_multiplicity_3, "\t"); - _builder.append("; ++i) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addMessageActorCreate(*this, "); - String _name_11 = sub_1.getName(); - _builder.append(_name_11, "\t\t"); - _builder.append(".getSubActor(i)->getName());"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addMessageActorCreate(*this, \""); - String _name_12 = sub_1.getName(); - _builder.append(_name_12, "\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// wiring"); - _builder.newLine(); - { - EList<Wire> _wires = wired.getWires(); - for(final Wire wire : _wires) { - _builder.append("\t"); - String _xifexpression = null; - boolean _isDataDriven = wire.isDataDriven(); - if (_isDataDriven) { - _xifexpression = "DataPortBase"; - } else { - _xifexpression = "InterfaceItemBase"; - } - _builder.append(_xifexpression, "\t"); - _builder.append("::connect(this, \""); - String _join = IterableExtensions.join(wire.getPath1(), "/"); - _builder.append(_join, "\t"); - _builder.append("\", \""); - String _join_1 = IterableExtensions.join(wire.getPath2(), "/"); - _builder.append(_join_1, "\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// call initialize of sub actors"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_2 = cc.getActorRefs(); - for(final ActorRef sub_2 : _actorRefs_2) { - _builder.append("\t"); - String _name_13 = sub_2.getName(); - _builder.append(_name_13, "\t"); - _builder.append(".initialize();"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_4 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_4) { - _builder.append("void "); - _builder.append(clsname); - _builder.append("::setProbesActive(bool recursive, bool active) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("for(int i = 0; i < m_RTSystemPort.getNInterfaceItems(); i++)"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("DebuggingService::getInstance().addPortInstance(*(m_RTSystemPort.getInterfaceItem(i)));"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("if(recursive) {"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs_3 = cc.getActorRefs(); - for(final ActorRef sub_3 : _actorRefs_3) { - _builder.append("\t\t"); - String _name_14 = sub_3.getName(); - _builder.append(_name_14, "\t\t"); - _builder.append(".setProbesActive(recursive, active);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("::init(){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("SubSystemClassBase::init();"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_5 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_5) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addVisibleComment(\"done sub system initialization\");"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_6 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_6) { - _builder.newLine(); - _builder.append("void "); - _builder.append(clsname); - _builder.append("::destroy() {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_7 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_7) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().getSyncLogger().addVisibleComment(\"starting destruction\");"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("MSCFunctionObject mscFunctionObject(getInstancePathName(), \"destroy()\");"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addVisibleComment(\"begin sub system destruction\");"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("SubSystemClassBase::destroy();"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_8 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_8) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addVisibleComment(\"done sub system destruction\");"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - String _generateNamespaceEnd = this._cppExtensions.generateNamespaceEnd(cc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java deleted file mode 100644 index 6fef1fe28..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java +++ /dev/null @@ -1,1543 +0,0 @@ -/** - * Copyright (c) 2011 Draeger Medical GmbH (http://www.draeger.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Peter Karlitschek (initial contribution) - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.InterfaceItem; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.MessageHandler; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.SAP; -import org.eclipse.etrice.core.room.SPP; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.generator.cpp.Main; -import org.eclipse.etrice.generator.cpp.gen.CppExtensions; -import org.eclipse.etrice.generator.cpp.gen.Initialization; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class ProtocolClassGen extends GenericProtocolClassGenerator { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private CppExtensions stdExt; - - @Inject - @Extension - private RoomExtensions roomExt; - - @Inject - @Extension - private ProcedureHelpers helpers; - - @Inject - @Extension - private TypeHelpers _typeHelpers; - - @Inject - @Extension - private FileSystemHelpers _fileSystemHelpers; - - @Inject - private Initialization initHelper; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - final Function1<ProtocolClass, Boolean> _function = (ProtocolClass cl) -> { - return Boolean.valueOf(this._fileSystemHelpers.isValidGenerationLocation(cl)); - }; - Iterable<ProtocolClass> _filter = IterableExtensions.<ProtocolClass>filter(root.getProtocolClasses(), _function); - for (final ProtocolClass pc : _filter) { - { - String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc); - String _path = this.roomExt.getPath(pc); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this.roomExt.getGenerationInfoPath(pc); - String _path_1 = this.roomExt.getPath(pc); - final String infopath = (_generationInfoPath + _path_1); - CommunicationType _commType = pc.getCommType(); - if (_commType != null) { - switch (_commType) { - case EVENT_DRIVEN: - this.fileIO.generateFile("generating ProtocolClass declaration", path, infopath, this.stdExt.getCppHeaderFileName(pc), this.generateHeaderFile(root, pc)); - this.fileIO.generateFile("generating ProtocolClass implementation", path, infopath, this.stdExt.getCppSourceFileName(pc), this.generateSourceFile(root, pc)); - break; - case DATA_DRIVEN: - this.fileIO.generateFile("generating ProtocolClass declaration", path, infopath, this.stdExt.getCppHeaderFileName(pc), this.generateDataDrivenHeaderFile(root, pc)); - this.fileIO.generateFile("generating ProtocolClass implementation", path, infopath, this.stdExt.getCppSourceFileName(pc), this.generateDataDrivenSourceFile(root, pc)); - break; - case SYNCHRONOUS: - this.logger.logError("synchronous protocols not supported yet", pc); - break; - default: - break; - } - } - } - } - } - - protected CharSequence generateHeaderFile(final Root root, final ProtocolClass pc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of ProtocolClass "); - String _name = pc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(pc, ""); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/modelbase/InterfaceItemBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/PortBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/ReplicatedInterfaceItemBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/ReplicatedPortBase.h\""); - _builder.newLine(); - _builder.append("#include \"common/etDatatypesCpp.hpp\""); - _builder.newLine(); - _builder.newLine(); - { - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc); - for(final DataClass dataClass : _referencedDataClasses) { - _builder.append("#include \""); - String _path = this.roomExt.getPath(dataClass); - _builder.append(_path); - String _name_1 = dataClass.getName(); - _builder.append(_name_1); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(pc.getUserCode1()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _generateNamespaceBegin = this.stdExt.generateNamespaceBegin(pc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("class "); - String _name_2 = pc.getName(); - _builder.append(_name_2); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("/* message IDs */"); - _builder.newLine(); - _builder.append("\t\t"); - String _genMessageIDs = this.genMessageIDs(pc); - _builder.append(_genMessageIDs, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - CharSequence _userCode_1 = this.helpers.userCode(pc, 2); - _builder.append(_userCode_1, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("static bool isValidEvtID(int evtId) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return ((MSG_MIN < evtId) && (evtId < MSG_MAX));"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("static bool isValidOutgoingEvtID(int evtId) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return ((MSG_MIN < evtId) && (evtId < "); - { - int _size = pc.getIncomingMessages().size(); - boolean _equals = (_size == 0); - if (_equals) { - _builder.append("MSG_MAX"); - } else { - _builder.append("IN_"); - String _name_3 = pc.getIncomingMessages().get(0).getName(); - _builder.append(_name_3, "\t\t\t"); - } - } - _builder.append("));"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("static bool isValidIncomingEvtID(int evtId) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return (("); - { - int _size_1 = pc.getIncomingMessages().size(); - boolean _equals_1 = (_size_1 == 0); - if (_equals_1) { - _builder.append("MSG_MAX"); - } else { - _builder.append("IN_"); - String _name_4 = pc.getIncomingMessages().get(0).getName(); - _builder.append(_name_4, "\t\t\t"); - } - } - _builder.append(" <= evtId) && (evtId < MSG_MAX));"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("static const etRuntime::String& getMessageString(int msg_id);"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("private:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("static const etRuntime::String s_messageStrings[];"); - _builder.newLine(); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - CharSequence _portClassDeclaration = this.portClassDeclaration(pc, false); - _builder.append(_portClassDeclaration); - _builder.newLineIfNotEmpty(); - CharSequence _portClassDeclaration_1 = this.portClassDeclaration(pc, true); - _builder.append(_portClassDeclaration_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _generateNamespaceEnd = this.stdExt.generateNamespaceEnd(pc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(pc, ""); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - return _builder; - } - - protected CharSequence portClassDeclaration(final ProtocolClass pc, final boolean conj) { - CharSequence _xblockexpression = null; - { - PortClass pclass = this.roomExt.getPortClass(pc, conj); - String portClassName = this.roomExt.getPortClassName(pc, conj); - String replPortClassName = this.roomExt.getPortClassName(pc, conj, true); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append("// "); - { - if (conj) { - _builder.append("conjugated "); - } - } - _builder.append("port class"); - _builder.newLineIfNotEmpty(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append("class "); - _builder.append(portClassName); - _builder.append(" : public etRuntime::PortBase {"); - _builder.newLineIfNotEmpty(); - { - boolean _notEquals = (!Objects.equal(pclass, null)); - if (_notEquals) { - _builder.append("\t"); - CharSequence _userCode = this.helpers.userCode(pclass.getUserCode()); - _builder.append(_userCode, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append(" "); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t "); - _builder.append(portClassName, "\t "); - _builder.append("(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t "); - _builder.append(portClassName, "\t "); - _builder.append("(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("virtual void destroy();"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t "); - _builder.append("virtual void receive(const etRuntime::Message* m);"); - _builder.newLine(); - _builder.newLine(); - { - boolean _notEquals_1 = (!Objects.equal(pclass, null)); - if (_notEquals_1) { - _builder.append("\t"); - CharSequence _attributes = this.helpers.attributes(pclass.getAttributes()); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(pclass.getOperations(), portClassName); - _builder.append(_operationsDeclaration, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t "); - _builder.append("// sent messages"); - _builder.newLine(); - { - List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, conj); - for(final Message m : _allMessages) { - _builder.append("\t"); - CharSequence _messageSignature = this.messageSignature(m, false); - _builder.append(_messageSignature, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _messageSignature_1 = this.messageSignature(m, true); - _builder.append(_messageSignature_1, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append("// "); - { - if (conj) { - _builder.append("conjugated "); - } - } - _builder.append("replicated port class"); - _builder.newLineIfNotEmpty(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append("class "); - _builder.append(replPortClassName); - _builder.append(" : public etRuntime::ReplicatedPortBase {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(replPortClassName, "\t\t"); - _builder.append("(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("int getReplication() const { return getNInterfaceItems(); }"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("int getIndexOf(const etRuntime::InterfaceItemBase& ifitem) const { return ifitem.getIdx(); }"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(portClassName, "\t\t"); - _builder.append("& get(int idx) const { return *dynamic_cast<"); - _builder.append(portClassName, "\t\t"); - _builder.append("*>(getInterfaceItem(idx)); }"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if (conj) { - _builder.append("\t\t"); - _builder.append("// incoming messages"); - _builder.newLine(); - { - List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc); - for(final Message m_1 : _allIncomingMessages) { - _builder.append("\t\t"); - CharSequence _messageSignature_2 = this.messageSignature(m_1, false); - _builder.append(_messageSignature_2, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } else { - _builder.append("\t\t"); - _builder.append("// outgoing messages"); - _builder.newLine(); - { - List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc); - for(final Message m_2 : _allOutgoingMessages) { - _builder.append("\t\t"); - CharSequence _messageSignature_3 = this.messageSignature(m_2, false); - _builder.append(_messageSignature_3, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const etRuntime::String& name, int lid, int idx) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return new "); - _builder.append(portClassName, "\t\t\t"); - _builder.append("(rcv, name, lid, idx);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - protected CharSequence generateSourceFile(final Root root, final ProtocolClass pc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of ProtocolClass "); - String _name = pc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc); - _builder.append(_cppHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/debugging/DebuggingService.h\""); - _builder.newLine(); - _builder.append("#include \"common/debugging/MSCFunctionObject.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/AbstractMessageReceiver.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/Address.h\""); - _builder.newLine(); - _builder.append("#include \"common/messaging/Message.h\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/IEventReceiver.h\""); - _builder.newLine(); - _builder.newLine(); - _builder.append("using namespace etRuntime;"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this.stdExt.generateNamespaceBegin(pc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(pc, 3); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* message names as strings for debugging (generate MSC) */"); - _builder.newLine(); - _builder.append("const String "); - String _name_1 = pc.getName(); - _builder.append(_name_1); - _builder.append("::s_messageStrings[] = {\"MIN\", "); - { - List<Message> _allOutgoingMessages = this._roomHelpers.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._roomHelpers.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("const String& "); - String _name_4 = pc.getName(); - _builder.append(_name_4); - _builder.append("::getMessageString(int msg_id) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return s_messageStrings[msg_id];"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("} else {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// id out of range"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("static const String errorMsg = \"Message ID out of range\";"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return errorMsg;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - CharSequence _portClassImplementation = this.portClassImplementation(pc, false); - _builder.append(_portClassImplementation); - _builder.newLineIfNotEmpty(); - CharSequence _portClassImplementation_1 = this.portClassImplementation(pc, true); - _builder.append(_portClassImplementation_1); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _generateNamespaceEnd = this.stdExt.generateNamespaceEnd(pc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - return _builder; - } - - protected CharSequence portClassImplementation(final ProtocolClass pc, final boolean conj) { - CharSequence _xblockexpression = null; - { - PortClass pclass = this.roomExt.getPortClass(pc, conj); - String portClassName = this.roomExt.getPortClassName(pc, conj); - String replPortClassName = this.roomExt.getPortClassName(pc, conj, true); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append("// "); - { - if (conj) { - _builder.append("conjugated "); - } - } - _builder.append("port class"); - _builder.newLineIfNotEmpty(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.newLine(); - _builder.append(portClassName); - _builder.append("::"); - _builder.append(portClassName); - _builder.append("(IInterfaceItemOwner* actor, const String& name, int localId)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(pclass, "0"); - _builder.append(_generateConstructorInitalizerList, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append(portClassName); - _builder.append("::"); - _builder.append(portClassName); - _builder.append("(IInterfaceItemOwner* actor, const String& name, int localId, int idx)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _generateConstructorInitalizerList_1 = this.generateConstructorInitalizerList(pclass, "idx"); - _builder.append(_generateConstructorInitalizerList_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - { - boolean _notEquals = (!Objects.equal(pclass, null)); - if (_notEquals) { - CharSequence _genExtraInitializers = this.initHelper.genExtraInitializers(pclass.getAttributes()); - _builder.append(_genExtraInitializers, "\t"); - } - } - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.newLine(); - _builder.append("void "); - _builder.append(portClassName); - _builder.append("::destroy() {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().removePortInstance(*this);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("PortBase::destroy();"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("void "); - _builder.append(portClassName); - _builder.append("::receive(const Message* msg) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("// TODO JH further"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("if (! "); - String _name = pc.getName(); - _builder.append(_name, "\t"); - _builder.append("::"); - { - if (conj) { - _builder.append("isValidOutgoingEvtID"); - } else { - _builder.append("isValidIncomingEvtID"); - } - } - _builder.append("(msg->getEvtId())) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("//std::cout << \"unknown\" << std::endl;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), "); - String _name_1 = pc.getName(); - _builder.append(_name_1, "\t"); - _builder.append("::getMessageString(msg->getEvtId()).c_str());"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj); - if (_handlesReceive) { - _builder.append("\t"); - _builder.append("switch (msg->getEvtId()) {"); - _builder.newLine(); - { - List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj); - for(final MessageHandler hdlr : _receiveHandlers) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("case "); - String _name_2 = pc.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append("::"); - String _codeName = this.roomExt.getCodeName(hdlr.getMsg()); - _builder.append(_codeName, "\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - { - EList<String> _lines = hdlr.getDetailCode().getLines(); - for(final String command : _lines) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append(command, "\t\t\t\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("default:"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("getActor()->receiveEvent(this, msg->getEvtId(),\tmsg->getData());"); - _builder.newLine(); - { - boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, conj); - if (_handlesReceive_1) { - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _notEquals_1 = (!Objects.equal(pclass, null)); - if (_notEquals_1) { - CharSequence _operationsImplementation = this.helpers.operationsImplementation(pclass.getOperations(), portClassName); - _builder.append(_operationsImplementation); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("// sent messages"); - _builder.newLine(); - { - List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, conj); - for(final Message m : _allMessages) { - CharSequence _sendMessage = this.sendMessage(m, pc.getName(), portClassName, conj); - _builder.append(_sendMessage); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append("// "); - { - if (conj) { - _builder.append("conjugated "); - } - } - _builder.append("replicated port class"); - _builder.newLineIfNotEmpty(); - _builder.append("//------------------------------------------------------------------------------------------------------------"); - _builder.newLine(); - _builder.append(replPortClassName); - _builder.append("::"); - _builder.append(replPortClassName); - _builder.append("(IInterfaceItemOwner* actor, const String& name, int localId) :"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("ReplicatedPortBase(actor, name, localId)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - if (conj) { - _builder.append("// incoming messages"); - _builder.newLine(); - { - List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc); - for(final Message m_1 : _allIncomingMessages) { - CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName, false); - _builder.append(_messageSignatureDefinition); - _builder.append("{"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("(dynamic_cast<"); - _builder.append(portClassName, "\t\t"); - _builder.append("*>(*it))->"); - CharSequence _messageCall = this.messageCall(m_1, false); - _builder.append(_messageCall, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - } else { - _builder.append("// outgoing messages"); - _builder.newLine(); - { - List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc); - for(final Message m_2 : _allOutgoingMessages) { - CharSequence _messageSignatureDefinition_1 = this.messageSignatureDefinition(m_2, replPortClassName, false); - _builder.append(_messageSignatureDefinition_1); - _builder.append("{"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("(dynamic_cast<"); - _builder.append(portClassName, "\t\t"); - _builder.append("*>(*it))->"); - CharSequence _messageCall_1 = this.messageCall(m_2, false); - _builder.append(_messageCall_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } - } - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateConstructorInitalizerList(final PortClass pc, final String index) { - CharSequence _xblockexpression = null; - { - @Extension - final Initialization initHelper = this.initHelper; - final List<CharSequence> initList = CollectionLiterals.<CharSequence>newArrayList(); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("PortBase(actor, name, localId, "); - _builder.append(index); - _builder.append(")"); - initList.add(_builder.toString()); - boolean _notEquals = (!Objects.equal(pc, null)); - if (_notEquals) { - final Function1<Attribute, String> _function = (Attribute it) -> { - StringConcatenation _builder_1 = new StringConcatenation(); - String _name = it.getName(); - _builder_1.append(_name); - _builder_1.append("("); - String _initializerListValue = initHelper.getInitializerListValue(it); - _builder_1.append(_initializerListValue); - _builder_1.append(")"); - return _builder_1.toString(); - }; - List<String> _map = ListExtensions.<Attribute, String>map(pc.getAttributes(), _function); - Iterables.<CharSequence>addAll(initList, _map); - } - _xblockexpression = initHelper.generateCtorInitializerList(initList); - } - return _xblockexpression; - } - - protected CharSequence messageCall(final Message m, final boolean impl) { - StringConcatenation _builder = new StringConcatenation(); - String _name = m.getName(); - _builder.append(_name); - { - if (impl) { - _builder.append("_impl"); - } - } - _builder.append("("); - { - VarDecl _data = m.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - _builder.append(" "); - String _name_1 = m.getData().getName(); - _builder.append(_name_1); - } - } - _builder.append(")"); - return _builder; - } - - protected CharSequence messageSignature(final Message m, final boolean impl) { - StringConcatenation _builder = new StringConcatenation(); - { - if ((m.isPriv() || impl)) { - _builder.append("private:"); - } else { - _builder.append("public:"); - } - } - _builder.append(" void "); - String _name = m.getName(); - _builder.append(_name); - { - if (impl) { - _builder.append("_impl"); - } - } - _builder.append("("); - { - VarDecl _data = m.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - String _signatureString = this.helpers.signatureString(m.getData().getRefType()); - _builder.append(_signatureString); - _builder.append(" "); - String _name_1 = m.getData().getName(); - _builder.append(_name_1); - } - } - _builder.append(")"); - return _builder; - } - - protected CharSequence messageSignatureDefinition(final Message m, final String classPrefix, final boolean impl) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("void "); - _builder.append(classPrefix); - _builder.append("::"); - String _name = m.getName(); - _builder.append(_name); - { - if (impl) { - _builder.append("_impl"); - } - } - _builder.append("("); - { - VarDecl _data = m.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - String _signatureString = this.helpers.signatureString(m.getData().getRefType()); - _builder.append(_signatureString); - _builder.append(" "); - String _name_1 = m.getData().getName(); - _builder.append(_name_1); - } - } - _builder.append(")"); - return _builder; - } - - protected CharSequence sendMessage(final Message m, final String portClassName, final String classPrefix, final boolean conj) { - CharSequence _xblockexpression = null; - { - String _xifexpression = null; - if (conj) { - _xifexpression = "IN"; - } else { - _xifexpression = "OUT"; - } - String dir = _xifexpression; - MessageHandler hdlr = this.roomExt.getSendHandler(m, conj); - String _xifexpression_1 = null; - VarDecl _data = m.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append(", "); - String _name = m.getData().getName(); - _builder.append(_name); - _xifexpression_1 = _builder.toString(); - } - final String dataArg = _xifexpression_1; - String _xifexpression_2 = null; - if (((!Objects.equal(m.getData(), null)) && (!m.getData().getRefType().isRef()))) { - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("DataMessage<"); - String _typeName = this._typeHelpers.typeName(m.getData().getRefType().getType()); - _builder_1.append(_typeName); - _builder_1.append(">"); - _xifexpression_2 = _builder_1.toString(); - } else { - StringConcatenation _builder_2 = new StringConcatenation(); - _builder_2.append("Message"); - _xifexpression_2 = _builder_2.toString(); - } - final String messageType = _xifexpression_2; - StringConcatenation _builder_3 = new StringConcatenation(); - _builder_3.append("new (buffer) "); - _builder_3.append(messageType); - _builder_3.append("(getPeerAddress(), "); - _builder_3.append(portClassName); - _builder_3.append("::"); - _builder_3.append(dir); - _builder_3.append("_"); - String _name_1 = m.getName(); - _builder_3.append(_name_1); - String _elvis = null; - if (dataArg != null) { - _elvis = dataArg; - } else { - _elvis = ""; - } - _builder_3.append(_elvis); - _builder_3.append(")"); - final String message = _builder_3.toString(); - StringConcatenation _builder_4 = new StringConcatenation(); - CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix, false); - _builder_4.append(_messageSignatureDefinition); - _builder_4.append(" {"); - _builder_4.newLineIfNotEmpty(); - { - boolean _notEquals_1 = (!Objects.equal(hdlr, null)); - if (_notEquals_1) { - _builder_4.append("\t"); - { - EList<String> _lines = hdlr.getDetailCode().getLines(); - for(final String command : _lines) { - _builder_4.append("\t"); - _builder_4.append(command, "\t"); - _builder_4.newLineIfNotEmpty(); - } - } - } else { - _builder_4.append("\t"); - CharSequence _messageCall = this.messageCall(m, true); - _builder_4.append(_messageCall, "\t"); - _builder_4.append(";"); - _builder_4.newLineIfNotEmpty(); - } - } - _builder_4.append("}"); - _builder_4.newLine(); - _builder_4.newLine(); - CharSequence _messageSignatureDefinition_1 = this.messageSignatureDefinition(m, classPrefix, true); - _builder_4.append(_messageSignatureDefinition_1); - _builder_4.append(" {"); - _builder_4.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder_4.append("\t"); - _builder_4.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),"); - _builder_4.newLine(); - _builder_4.append("\t"); - _builder_4.append("\t"); - _builder_4.append(portClassName, "\t\t"); - _builder_4.append("::getMessageString("); - _builder_4.append(portClassName, "\t\t"); - _builder_4.append("::"); - _builder_4.append(dir, "\t\t"); - _builder_4.append("_"); - String _name_2 = m.getName(); - _builder_4.append(_name_2, "\t\t"); - _builder_4.append(").c_str());"); - _builder_4.newLineIfNotEmpty(); - } - } - _builder_4.append("\t"); - _builder_4.append("if (getPeerAddress().isValid()) {"); - _builder_4.newLine(); - _builder_4.append("\t\t"); - _builder_4.append("Message* buffer = dynamic_cast<IMessageService*>(getPeerMsgReceiver())->getMessageBuffer(sizeof("); - _builder_4.append(messageType, "\t\t"); - _builder_4.append("));"); - _builder_4.newLineIfNotEmpty(); - _builder_4.append("\t\t"); - _builder_4.append("if (buffer) {"); - _builder_4.newLine(); - _builder_4.append("\t\t\t"); - _builder_4.append("getPeerMsgReceiver()->receive("); - _builder_4.append(message, "\t\t\t"); - _builder_4.append(");"); - _builder_4.newLineIfNotEmpty(); - _builder_4.append("\t\t"); - _builder_4.append("}"); - _builder_4.newLine(); - _builder_4.append("\t"); - _builder_4.append("}"); - _builder_4.newLine(); - _builder_4.append("}"); - _builder_4.newLine(); - _xblockexpression = _builder_4; - } - return _xblockexpression; - } - - protected CharSequence generateDataDrivenHeaderFile(final Root root, final ProtocolClass pc) { - CharSequence _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - final Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(this._roomHelpers.getAllIncomingMessages(pc), _function); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Header File of ProtocolClass "); - String _name = pc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(pc, ""); - _builder.append(_generateIncludeGuardBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("#include \"common/etDatatypesCpp.hpp\""); - _builder.newLine(); - _builder.append("#include \"common/modelbase/DataPort.h\""); - _builder.newLine(); - { - EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc); - for(final DataClass dataClass : _referencedDataClasses) { - _builder.append("#include \""); - String _path = this.roomExt.getPath(dataClass); - _builder.append(_path); - String _name_1 = dataClass.getName(); - _builder.append(_name_1); - _builder.append(".h\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(pc.getUserCode1()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - String _generateNamespaceBegin = this.stdExt.generateNamespaceBegin(pc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("class "); - String _name_2 = pc.getName(); - _builder.append(_name_2); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this.helpers.userCode(pc.getUserCode2()); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// send port holds data"); - _builder.newLine(); - _builder.append("class "); - String _portClassName = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName); - _builder.append(" : public etRuntime::DataSendPort {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t"); - String _portClassName_1 = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName_1, "\t"); - _builder.append("(etRuntime::IRTObject* parent, const etRuntime::String& name, int localId);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// getters and setters"); - _builder.newLine(); - { - for(final Message msg : sentMsgs) { - _builder.append("\t"); - _builder.append("void "); - String _name_3 = msg.getName(); - _builder.append(_name_3, "\t"); - _builder.append("("); - String _typeName = this._typeHelpers.typeName(msg.getData().getRefType().getType()); - _builder.append(_typeName, "\t"); - _builder.append(" "); - String _name_4 = msg.getName(); - _builder.append(_name_4, "\t"); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("m_"); - String _name_5 = msg.getName(); - _builder.append(_name_5, "\t\t"); - _builder.append(" = "); - String _name_6 = msg.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - String _typeName_1 = this._typeHelpers.typeName(msg.getData().getRefType().getType()); - _builder.append(_typeName_1, "\t"); - _builder.append(" "); - String _name_7 = msg.getName(); - _builder.append(_name_7, "\t"); - _builder.append("() const {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("return m_"); - String _name_8 = msg.getName(); - _builder.append(_name_8, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("private:"); - _builder.newLine(); - { - for(final Message msg_1 : sentMsgs) { - _builder.append("\t"); - String _typeName_2 = this._typeHelpers.typeName(msg_1.getData().getRefType().getType()); - _builder.append(_typeName_2, "\t"); - _builder.append(" m_"); - String _name_9 = msg_1.getName(); - _builder.append(_name_9, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// receive port accesses send port"); - _builder.newLine(); - _builder.append("class "); - String _portClassName_2 = this.roomExt.getPortClassName(pc, false); - _builder.append(_portClassName_2); - _builder.append(" : public etRuntime::DataReceivePort {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("public:"); - _builder.newLine(); - _builder.append("\t"); - String _portClassName_3 = this.roomExt.getPortClassName(pc, false); - _builder.append(_portClassName_3, "\t"); - _builder.append("(etRuntime::IRTObject* parent, const etRuntime::String& name, int localId);"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// getters"); - _builder.newLine(); - { - for(final Message msg_2 : sentMsgs) { - _builder.append("\t"); - String _typeName_3 = this._typeHelpers.typeName(msg_2.getData().getRefType().getType()); - _builder.append(_typeName_3, "\t"); - _builder.append(" "); - String _name_10 = msg_2.getName(); - _builder.append(_name_10, "\t"); - _builder.append("() const;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("protected:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("virtual void connect(etRuntime::DataSendPort* dataSendPort);"); - _builder.newLine(); - _builder.newLine(); - _builder.append("private:"); - _builder.newLine(); - _builder.append("\t"); - String _portClassName_4 = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName_4, "\t"); - _builder.append("* m_peer;"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceEnd = this.stdExt.generateNamespaceEnd(pc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(pc, ""); - _builder.append(_generateIncludeGuardEnd); - _builder.newLineIfNotEmpty(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - protected CharSequence generateDataDrivenSourceFile(final Root root, final ProtocolClass pc) { - CharSequence _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - final Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(this._roomHelpers.getAllIncomingMessages(pc), _function); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @author generated by eTrice"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* Source File of ProtocolClass "); - String _name = pc.getName(); - _builder.append(_name, " "); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - _builder.append("*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.newLine(); - _builder.append("#include \""); - String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc); - _builder.append(_cppHeaderFileName); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("using namespace etRuntime;"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceBegin = this.stdExt.generateNamespaceBegin(pc); - _builder.append(_generateNamespaceBegin); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _userCode = this.helpers.userCode(pc.getUserCode3()); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("// send port holds data"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// constructor"); - _builder.newLine(); - String _portClassName = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName); - _builder.append("::"); - String _portClassName_1 = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName_1); - _builder.append("(IRTObject* parent, const String& name, int localId) :"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("DataSendPort(parent, name, localId)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// receive port accesses send port"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// constructor"); - _builder.newLine(); - String _portClassName_2 = this.roomExt.getPortClassName(pc, false); - _builder.append(_portClassName_2); - _builder.append("::"); - String _portClassName_3 = this.roomExt.getPortClassName(pc, false); - _builder.append(_portClassName_3); - _builder.append("(IRTObject* parent, const String& name, int localId) :"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("DataReceivePort(parent, name, localId),"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("m_peer(0)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// getters"); - _builder.newLine(); - { - for(final Message msg : sentMsgs) { - String _typeName = this._typeHelpers.typeName(msg.getData().getRefType().getType()); - _builder.append(_typeName); - _builder.append(" "); - String _portClassName_4 = this.roomExt.getPortClassName(pc, false); - _builder.append(_portClassName_4); - _builder.append("::"); - String _name_1 = msg.getName(); - _builder.append(_name_1); - _builder.append("() const {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("// TODO needs default value"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("//if (m_peer == 0)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/*\treturn "); - String _defaultValue = this.stdExt.defaultValue(msg.getData().getRefType().getType()); - _builder.append(_defaultValue, "\t"); - _builder.append("; */"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return m_peer->"); - String _name_2 = msg.getName(); - _builder.append(_name_2, "\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("void "); - String _portClassName_5 = this.roomExt.getPortClassName(pc, false); - _builder.append(_portClassName_5); - _builder.append("::connect(DataSendPort* dataSendPort) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _portClassName_6 = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName_6, "\t"); - _builder.append("* peer = dynamic_cast<"); - String _portClassName_7 = this.roomExt.getPortClassName(pc, true); - _builder.append(_portClassName_7, "\t"); - _builder.append("*>(dataSendPort);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if (peer != 0)"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("m_peer = peer;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - String _generateNamespaceEnd = this.stdExt.generateNamespaceEnd(pc); - _builder.append(_generateNamespaceEnd); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - @Override - public String getMessageID(final Message msg, final InterfaceItem item) { - if ((item instanceof Port)) { - Port p = ((Port) item); - String _xifexpression = null; - boolean _isConjugated = p.isConjugated(); - if (_isConjugated) { - _xifexpression = "OUT_"; - } else { - _xifexpression = "IN_"; - } - String direction = _xifexpression; - String _name = p.getProtocol().getName(); - String _name_1 = msg.getName(); - String _plus = (direction + _name_1); - return this.enumInUse(_name, _plus); - } else { - if ((item instanceof SAP)) { - SAP sap = ((SAP) item); - String _name_2 = sap.getProtocol().getName(); - String _name_3 = msg.getName(); - String _plus_1 = ("OUT_" + _name_3); - return this.enumInUse(_name_2, _plus_1); - } else { - if ((item instanceof SPP)) { - SPP spp = ((SPP) item); - String _name_4 = spp.getProtocol().getName(); - String _name_5 = msg.getName(); - String _plus_2 = ("IN_" + _name_5); - return this.enumInUse(_name_4, _plus_2); - } - } - } - return "unknown interface item"; - } - - protected String enumInUse(final String namespace, final String member) { - return ((namespace + "::") + member); - } -} diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java deleted file mode 100644 index c751e2cb7..000000000 --- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - * Peter Karlitschek - */ -package org.eclipse.etrice.generator.cpp.gen; - -import com.google.inject.Singleton; -import java.util.Comparator; -import java.util.List; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.generator.cpp.Main; -import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; - -@Singleton -@SuppressWarnings("all") -public class StateMachineGen extends GenericStateMachineGenerator { - private static class NodeComparator implements Comparator<Node> { - @Override - public int compare(final Node o1, final Node o2) { - int _inheritanceLevel = o1.getInheritanceLevel(); - int _inheritanceLevel_1 = o2.getInheritanceLevel(); - boolean _equals = (_inheritanceLevel == _inheritanceLevel_1); - if (_equals) { - if ((FsmGenExtensions.isLeaf(o1) && FsmGenExtensions.isLeaf(o2))) { - return 0; - } - boolean _isLeaf = FsmGenExtensions.isLeaf(o1); - if (_isLeaf) { - return 1; - } - boolean _isLeaf_1 = FsmGenExtensions.isLeaf(o2); - if (_isLeaf_1) { - return (-1); - } - return 0; - } else { - return Integer.compare(o1.getInheritanceLevel(), o1.getInheritanceLevel()); - } - } - } - - private final StateMachineGen.NodeComparator nodeComparator = new StateMachineGen.NodeComparator(); - - @Override - public CharSequence genExtra(final GraphContainer gc, final boolean generateImplementation) { - CharSequence _xblockexpression = null; - { - ModelComponent ac = gc.getComponent(); - final String clsName = ac.getComponentName(); - final List<Node> orderedStateNodes = IterableExtensions.<Node>sortWith(IteratorExtensions.<Node>toList(FsmGenExtensions.getAllStateNodes(gc.getGraph())), this.nodeComparator); - CharSequence _xifexpression = null; - if (generateImplementation) { - StringConcatenation _builder = new StringConcatenation(); - { - if ((Main.getSettings().isGenerateMSCInstrumentation() || Main.getSettings().isGenerateWithVerboseOutput())) { - _builder.append("// state names"); - _builder.newLine(); - _builder.append("const String "); - _builder.append(clsName); - _builder.append("::s_stateStrings[] = {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\"<no state>\","); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\"<top>\","); - _builder.newLine(); - { - boolean _hasElements = false; - for(final Node state : orderedStateNodes) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - _builder.append("\""); - StateGraphNode _stateGraphNode = state.getStateGraphNode(); - String _genStatePathName = this._codegenHelpers.getGenStatePathName(((State) _stateGraphNode)); - _builder.append(_genStatePathName, "\t"); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - } - } - _builder.append("const int "); - _builder.append(clsName); - _builder.append("::s_numberOfStates = "); - int _size = orderedStateNodes.size(); - int _plus = (2 + _size); - _builder.append(_plus); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("void "); - _builder.append(clsName); - _builder.append("::setState(int new_state) {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state].c_str());"); - _builder.newLine(); - } - } - { - boolean _isGenerateWithVerboseOutput = Main.getSettings().isGenerateWithVerboseOutput(); - if (_isGenerateWithVerboseOutput) { - _builder.append("\t"); - _builder.append("if (s_stateStrings[new_state] != \"Idle\") {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("std::cout << getInstancePath().c_str() << \" -> \" << s_stateStrings[new_state].c_str() << std::endl;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("m_state = new_state;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _xifexpression = _builder; - } else { - StringConcatenation _builder_1 = new StringConcatenation(); - { - if ((Main.getSettings().isGenerateMSCInstrumentation() || Main.getSettings().isGenerateWithVerboseOutput())) { - _builder_1.append("static const String s_stateStrings[];"); - _builder_1.newLine(); - } - } - _builder_1.append("static const int s_numberOfStates;"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("int history["); - int _size_1 = orderedStateNodes.size(); - int _plus_1 = (2 + _size_1); - _builder_1.append(_plus_1); - _builder_1.append("];"); - _builder_1.newLineIfNotEmpty(); - _builder_1.newLine(); - _builder_1.append("void setState(int new_state);"); - _builder_1.newLine(); - _xifexpression = _builder_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String stateType() { - return "etInt16"; - } - - @Override - public String boolType() { - return "etBool"; - } -} diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java deleted file mode 100644 index 4ca0a71ca..000000000 --- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java +++ /dev/null @@ -1,1473 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Jung, Thomas Schuetz (initial contribution) - */ -package org.eclipse.etrice.generator.doc.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.io.File; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.common.base.Documentation; -import org.eclipse.etrice.core.common.base.util.RelativePathHelpers; -import org.eclipse.etrice.core.fsm.fSM.ChoicePoint; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.CompoundProtocolClass; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.EnumLiteral; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.GeneralProtocolClass; -import org.eclipse.etrice.core.room.LogicalSystem; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.Port; -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.RoomClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.StandardOperation; -import org.eclipse.etrice.core.room.SubProtocol; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.fsm.base.CodegenHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.generator.JavaIoFileSystemAccess; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@Singleton -@SuppressWarnings("all") -public class DocGen { - public static class DocGenContext { - private final Root root; - - private final RoomModel model; - - public DocGenContext(final Root r, final RoomModel m) { - this.root = r; - this.model = m; - } - } - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private CodegenHelpers _codegenHelpers; - - @Inject - @Extension - private JavaIoFileSystemAccess fileAccess; - - @Inject - @Extension - private RoomExtensions roomExt; - - @Inject - private ILogger logger; - - private final String IMGDIR_DEFAULT = "./images"; - - private final String IMGWIDTH_DEFAULT = "1.0\\textwidth"; - - public void doGenerate(final Root root) { - EList<RoomModel> _models = root.getModels(); - for (final RoomModel model : _models) { - { - final DocGen.DocGenContext ctx = new DocGen.DocGenContext(root, model); - String path = this.roomExt.getDocGenerationTargetPath(model); - String _name = model.getName(); - String file = (_name + ".tex"); - final Set<RoomModel> referencedModels = CollectionLiterals.<RoomModel>newHashSet(); - this.logger.logInfo((((("generating LaTeX documentation: \'" + file) + "\' in \'") + path) + "\'")); - String _name_1 = model.getName(); - String _plus = (path + _name_1); - this.fileAccess.setOutputPath(_plus); - final Consumer<LogicalSystem> _function = (LogicalSystem it) -> { - this.saveAs(this.generateDoc(it, ctx), this.docFragmentName(it)); - }; - model.getSystems().forEach(_function); - final Consumer<LogicalSystem> _function_1 = (LogicalSystem it) -> { - referencedModels.addAll(root.getReferencedModels(it)); - }; - model.getSystems().forEach(_function_1); - final Consumer<SubSystemClass> _function_2 = (SubSystemClass it) -> { - this.saveAs(this.generateDoc(it, ctx), this.docFragmentName(it)); - }; - model.getSubSystemClasses().forEach(_function_2); - final Consumer<SubSystemClass> _function_3 = (SubSystemClass it) -> { - referencedModels.addAll(root.getReferencedModels(it)); - }; - model.getSubSystemClasses().forEach(_function_3); - final Consumer<GeneralProtocolClass> _function_4 = (GeneralProtocolClass it) -> { - this.saveAs(this.generateDoc(it, ctx), this.docFragmentName(it)); - }; - model.getProtocolClasses().forEach(_function_4); - final Consumer<GeneralProtocolClass> _function_5 = (GeneralProtocolClass it) -> { - referencedModels.addAll(root.getReferencedModels(it)); - }; - model.getProtocolClasses().forEach(_function_5); - final Consumer<EnumerationType> _function_6 = (EnumerationType it) -> { - this.saveAs(this.generateDoc(it, ctx), this.docFragmentName(it)); - }; - model.getEnumerationTypes().forEach(_function_6); - final Consumer<EnumerationType> _function_7 = (EnumerationType it) -> { - referencedModels.addAll(root.getReferencedModels(it)); - }; - model.getEnumerationTypes().forEach(_function_7); - final Consumer<DataClass> _function_8 = (DataClass it) -> { - this.saveAs(this.generateDoc(it, ctx), this.docFragmentName(it)); - }; - model.getDataClasses().forEach(_function_8); - final Consumer<DataClass> _function_9 = (DataClass it) -> { - referencedModels.addAll(root.getReferencedModels(it)); - }; - model.getDataClasses().forEach(_function_9); - final Consumer<ActorClass> _function_10 = (ActorClass it) -> { - this.saveAs(this.generateDoc(it, ctx), this.docFragmentName(it)); - }; - model.getActorClasses().forEach(_function_10); - final Consumer<ActorClass> _function_11 = (ActorClass it) -> { - referencedModels.addAll(root.getReferencedModels(it)); - }; - model.getActorClasses().forEach(_function_11); - this.fileAccess.setOutputPath(path); - this.saveAs(this.generateModelDoc(ctx, referencedModels), file); - } - } - } - - private String removeLast(final String str) { - int _length = str.length(); - int _minus = (_length - 1); - return str.substring(0, _minus); - } - - private String appendIfNotEmpty(final String txt, final String suffix) { - String _xifexpression = null; - boolean _isEmpty = txt.isEmpty(); - if (_isEmpty) { - _xifexpression = txt; - } else { - _xifexpression = (txt + suffix); - } - return _xifexpression; - } - - private CharSequence generateModelDoc(final DocGen.DocGenContext ctx, final Set<RoomModel> referencedModels) { - CharSequence _xblockexpression = null; - { - RoomModel model = ctx.model; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\documentclass[titlepage]{article}"); - _builder.newLine(); - _builder.append("\\usepackage{import}"); - _builder.newLine(); - _builder.append("\\usepackage{graphicx}"); - _builder.newLine(); - _builder.append("\\usepackage{xr}"); - _builder.newLine(); - _builder.append("\\usepackage{hyperref}"); - _builder.newLine(); - _builder.append("\\IfFileExists{../doc/userinputs.tex}{\\subimport{../doc/}{userinputs.tex}}{} %hook for conditional user-specific inputs, includes, macros, ... "); - _builder.newLine(); - _builder.append("\\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry}"); - _builder.newLine(); - _builder.append("\\usepackage{nonfloat}"); - _builder.newLine(); - _builder.append("\\parindent 0pt"); - _builder.newLine(); - _builder.append("\\makeatletter"); - _builder.newLine(); - _builder.append("\\newcommand\\level[1]{%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\ifcase#1\\relax\\expandafter\\chapter\\or"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\expandafter\\section\\or"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\expandafter\\subsection\\or"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\expandafter\\subsubsection\\else"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\def\\next{\\@level{#1}}\\expandafter\\next"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\fi}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\newcommand{\\@level}[1]{%"); - _builder.newLine(); - _builder.append("\\@startsection{level#1}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{#1}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{\\z@}%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{-3.25ex\\@plus -1ex \\@minus -.2ex}%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{1.5ex \\@plus .2ex}%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{\\normalfont\\normalsize\\bfseries}}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\newdimen\\@leveldim"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\newdimen\\@dotsdim"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{\\normalfont\\normalsize"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\sbox\\z@{0}\\global\\@leveldim=\\wd\\z@"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\sbox\\z@{.}\\global\\@dotsdim=\\wd\\z@"); - _builder.newLine(); - _builder.append(" "); - _builder.append("} "); - _builder.newLine(); - _builder.append("\\newcounter{level4}[subsubsection]"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\@namedef{thelevel4}{\\thesubsubsection.\\arabic{level4}}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\@namedef{level4mark}#1{}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\def\\l@section{\\@dottedtocline{1}{0pt}{\\dimexpr\\@leveldim*4+\\@dotsdim*1+6pt\\relax}}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\def\\l@subsection{\\@dottedtocline{2}{0pt}{\\dimexpr\\@leveldim*5+\\@dotsdim*2+6pt\\relax}}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\def\\l@subsubsection{\\@dottedtocline{3}{0pt}{\\dimexpr\\@leveldim*6+\\@dotsdim*3+6pt\\relax}}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\@namedef{l@level4}{\\@dottedtocline{4}{0pt}{\\dimexpr\\@leveldim*7+\\@dotsdim*4+6pt\\relax}}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\count@=4"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\def\\@ncp#1{\\number\\numexpr\\count@+#1\\relax}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\loop\\ifnum\\count@<100"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\begingroup\\edef\\x{\\endgroup"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\noexpand\\newcounter{level\\@ncp{1}}[level\\number\\count@]"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\noexpand\\@namedef{thelevel\\@ncp{1}}{%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\noexpand\\@nameuse{thelevel\\@ncp{0}}.\\noexpand\\arabic{level\\@ncp{0}}}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\noexpand\\@namedef{level\\@ncp{1}mark}####1{}%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\noexpand\\@namedef{l@level\\@ncp{1}}%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("{\\noexpand\\@dottedtocline{\\@ncp{1}}{0pt}{\\the\\dimexpr\\@leveldim*\\@ncp{5}+\\@dotsdim*\\@ncp{0}\\relax}}}%"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\x"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\advance\\count@\\@ne"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\repeat"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\makeatother"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\setcounter{secnumdepth}{100}"); - _builder.newLine(); - _builder.append(" "); - _builder.append("\\setcounter{tocdepth}{100}"); - _builder.newLine(); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\title{"); - String _escapedString = this.escapedString(model.getName()); - _builder.append(_escapedString); - _builder.append(" Model Documentation}"); - _builder.newLineIfNotEmpty(); - _builder.append("\\date{\\today}"); - _builder.newLine(); - _builder.append("\\author{generated by eTrice}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\begin{document}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\pagestyle{plain}"); - _builder.newLine(); - _builder.append("\\maketitle"); - _builder.newLine(); - _builder.append("\\tableofcontents"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\newpage"); - _builder.newLine(); - _builder.append("\\listoffigures"); - _builder.newLine(); - _builder.append("\\newpage"); - _builder.newLine(); - _builder.append("\\section{Model Description}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _isEmpty = referencedModels.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("\\section{Referenced Models}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\begin{itemize}"); - _builder.newLine(); - { - final Function1<RoomModel, String> _function = (RoomModel it) -> { - return it.getName(); - }; - List<RoomModel> _sortBy = IterableExtensions.<RoomModel, String>sortBy(referencedModels, _function); - for(final RoomModel refModel : _sortBy) { - final String relPath = this.appendIfNotEmpty(RelativePathHelpers.getRelativePath( - this.removeLast(this.roomExt.getDocGenerationTargetPath(model)), this.removeLast(this.roomExt.getDocGenerationTargetPath(refModel)), true), "/"); - _builder.newLineIfNotEmpty(); - _builder.append("\\item \\href{"); - String _replace = relPath.replace("\\", "/"); - String _name = refModel.getName(); - String _escapedString_1 = this.escapedString((_replace + _name)); - _builder.append(_escapedString_1); - _builder.append(".pdf}{"); - String _escapedString_2 = this.escapedString(refModel.getName()); - _builder.append(_escapedString_2); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\end{itemize}"); - _builder.newLine(); - _builder.append("\\newpage"); - _builder.newLine(); - } - } - _builder.newLine(); - { - boolean _isEmpty_1 = model.getSystems().isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - _builder.append("\\section{Logical System Classes}"); - _builder.newLine(); - { - EList<LogicalSystem> _systems = model.getSystems(); - for(final LogicalSystem s : _systems) { - CharSequence _generateImport = this.generateImport(s, model.getName()); - _builder.append(_generateImport); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\newpage"); - _builder.newLine(); - } - } - _builder.newLine(); - { - boolean _isEmpty_2 = model.getSubSystemClasses().isEmpty(); - boolean _not_2 = (!_isEmpty_2); - if (_not_2) { - _builder.append("\\section{Subsystem Classes}"); - _builder.newLine(); - { - EList<SubSystemClass> _subSystemClasses = model.getSubSystemClasses(); - for(final SubSystemClass s_1 : _subSystemClasses) { - CharSequence _generateImport_1 = this.generateImport(s_1, model.getName()); - _builder.append(_generateImport_1); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\newpage"); - _builder.newLine(); - } - } - _builder.newLine(); - { - boolean _isEmpty_3 = model.getProtocolClasses().isEmpty(); - boolean _not_3 = (!_isEmpty_3); - if (_not_3) { - _builder.append("\\section{Protocol Classes}"); - _builder.newLine(); - { - EList<GeneralProtocolClass> _protocolClasses = model.getProtocolClasses(); - for(final GeneralProtocolClass c : _protocolClasses) { - CharSequence _generateImport_2 = this.generateImport(c, model.getName()); - _builder.append(_generateImport_2); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\newpage"); - _builder.newLine(); - } - } - _builder.newLine(); - { - boolean _isEmpty_4 = model.getEnumerationTypes().isEmpty(); - boolean _not_4 = (!_isEmpty_4); - if (_not_4) { - _builder.append("\\section{Enumeration Types}"); - _builder.newLine(); - { - EList<EnumerationType> _enumerationTypes = model.getEnumerationTypes(); - for(final EnumerationType e : _enumerationTypes) { - CharSequence _generateImport_3 = this.generateImport(e, model.getName()); - _builder.append(_generateImport_3); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\newpage"); - _builder.newLine(); - } - } - _builder.newLine(); - { - boolean _isEmpty_5 = model.getDataClasses().isEmpty(); - boolean _not_5 = (!_isEmpty_5); - if (_not_5) { - _builder.append("\\section{Data Classes}"); - _builder.newLine(); - { - EList<DataClass> _dataClasses = model.getDataClasses(); - for(final DataClass c_1 : _dataClasses) { - CharSequence _generateImport_4 = this.generateImport(c_1, model.getName()); - _builder.append(_generateImport_4); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\newpage"); - _builder.newLine(); - } - } - _builder.newLine(); - { - boolean _isEmpty_6 = model.getActorClasses().isEmpty(); - boolean _not_6 = (!_isEmpty_6); - if (_not_6) { - _builder.append("\\section{Actor Classes}"); - _builder.newLine(); - { - EList<ActorClass> _actorClasses = model.getActorClasses(); - for(final ActorClass c_2 : _actorClasses) { - CharSequence _generateImport_5 = this.generateImport(c_2, model.getName()); - _builder.append(_generateImport_5); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("\\end{document}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence _generateDoc(final LogicalSystem system, final DocGen.DocGenContext ctx) { - CharSequence _xblockexpression = null; - { - String _name = system.getName(); - final String filename = (_name + "_instanceTree.jpg"); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2}{"); - String _escapedString = this.escapedString(system.getName()); - _builder.append(_escapedString); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(system.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.append("\\level{3}{Instance Tree}"); - _builder.newLine(); - { - boolean _equals = this.fileExists(ctx.model, this.getImagePath(filename)).equals("true"); - if (_equals) { - String _imagePath = this.getImagePath(filename); - String _name_1 = system.getName(); - String _plus = (_name_1 + " Instance Tree"); - CharSequence _includeGraphics = this.includeGraphics(_imagePath, this.IMGWIDTH_DEFAULT, _plus); - _builder.append(_includeGraphics); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence _generateDoc(final SubSystemClass ssc, final DocGen.DocGenContext ctx) { - CharSequence _xblockexpression = null; - { - String _escapedString = this.escapedString(ssc.getName()); - final String filename = (_escapedString + "_structure.jpg"); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2}{"); - String _escapedString_1 = this.escapedString(ssc.getName()); - _builder.append(_escapedString_1); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(ssc.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.append("\\level{3}{Structure}"); - _builder.newLine(); - { - boolean _equals = this.fileExists(ctx.model, this.getImagePath(filename)).equals("true"); - if (_equals) { - String _imagePath = this.getImagePath(filename); - String _name = ssc.getName(); - String _plus = (_name + " Structure"); - CharSequence _includeGraphics = this.includeGraphics(_imagePath, this.IMGWIDTH_DEFAULT, _plus); - _builder.append(_includeGraphics); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence _generateDoc(final EnumerationType dc, final DocGen.DocGenContext ctx) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2} {"); - String _escapedString = this.escapedString(dc.getName()); - _builder.append(_escapedString); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(dc.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - { - PrimitiveType _primitiveType = dc.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _builder.append("The literals of this enumeration are based on PrimitiveType "); - String _escapedString_1 = this.escapedString(dc.getPrimitiveType().getName()); - _builder.append(_escapedString_1); - _builder.append("."); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("The literals of this enumeration are of type \\texttt{int}."); - _builder.newLine(); - } - } - _builder.append("\\level{3}{Literals}"); - _builder.newLine(); - _builder.append("\\begin{tabular}[ht]{|l|r|r|r|}"); - _builder.newLine(); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\textbf{Name} & \\textbf{Value} & \\textbf{Hex Value} & \\textbf{Binary Value}\\\\"); - _builder.newLine(); - { - EList<EnumLiteral> _literals = dc.getLiterals(); - for(final EnumLiteral lit : _literals) { - _builder.append("\\hline"); - _builder.newLine(); - String _escapedString_2 = this.escapedString(lit.getName()); - _builder.append(_escapedString_2); - _builder.append(" & "); - long _literalValue = lit.getLiteralValue(); - _builder.append(_literalValue); - _builder.append(" & 0x"); - String _hexString = Long.toHexString(lit.getLiteralValue()); - _builder.append(_hexString); - _builder.append(" & "); - String _binaryString = Long.toBinaryString(lit.getLiteralValue()); - _builder.append(_binaryString); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - return _builder; - } - - private CharSequence _generateDoc(final DataClass dc, final DocGen.DocGenContext ctx) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2} {"); - String _escapedString = this.escapedString(dc.getName()); - _builder.append(_escapedString); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(dc.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.append("\\level{3}{Attributes}"); - _builder.newLine(); - CharSequence _generateAttributesDoc = this.generateAttributesDoc(dc.getAttributes()); - _builder.append(_generateAttributesDoc); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\\level{3}{Operations}"); - _builder.newLine(); - CharSequence _generateOperationsDoc = this.generateOperationsDoc(dc.getOperations()); - _builder.append(_generateOperationsDoc); - _builder.newLineIfNotEmpty(); - return _builder; - } - - private CharSequence _generateDoc(final ProtocolClass pc, final DocGen.DocGenContext ctx) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2} {"); - String _escapedString = this.escapedString(pc.getName()); - _builder.append(_escapedString); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(pc.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - { - boolean _isEmpty = this._roomHelpers.getAllIncomingMessages(pc).isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("\\level{3}{Incoming Messages}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\begin{tabular}[ht]{|l|l|l|p{8cm}|}"); - _builder.newLine(); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("Message & Data & Type & Description\\\\"); - _builder.newLine(); - { - List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc); - for(final Message ims : _allIncomingMessages) { - _builder.append("\\hline"); - _builder.newLine(); - String _escapedString_1 = this.escapedString(ims.getName()); - _builder.append(_escapedString_1); - _builder.append(" & "); - { - VarDecl _data = ims.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - _builder.append(" "); - String _escapedString_2 = this.escapedString(ims.getData().getName()); - _builder.append(_escapedString_2); - _builder.append(" "); - } - } - _builder.append(" & "); - { - VarDecl _data_1 = ims.getData(); - boolean _notEquals_1 = (!Objects.equal(_data_1, null)); - if (_notEquals_1) { - _builder.append(" "); - String _escapedString_3 = this.escapedString(ims.getData().getRefType().getType().getName()); - _builder.append(_escapedString_3); - _builder.append(" "); - } - } - _builder.append(" & "); - CharSequence _generateDocText_1 = this.generateDocText(ims.getDocu()); - _builder.append(_generateDocText_1); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - } - } - { - boolean _isEmpty_1 = this._roomHelpers.getAllOutgoingMessages(pc).isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - _builder.append("\\level{3}{Outgoing Messages}"); - _builder.newLine(); - _builder.append("\\begin{tabular}[ht]{|l|l|l|p{8cm}|}"); - _builder.newLine(); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("Message & Data & Type & Description\\\\"); - _builder.newLine(); - { - List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc); - for(final Message oms : _allOutgoingMessages) { - _builder.append("\\hline"); - _builder.newLine(); - String _escapedString_4 = this.escapedString(oms.getName()); - _builder.append(_escapedString_4); - _builder.append(" & "); - { - VarDecl _data_2 = oms.getData(); - boolean _notEquals_2 = (!Objects.equal(_data_2, null)); - if (_notEquals_2) { - _builder.append(" "); - String _escapedString_5 = this.escapedString(oms.getData().getName()); - _builder.append(_escapedString_5); - _builder.append(" "); - } - } - _builder.append(" & "); - { - VarDecl _data_3 = oms.getData(); - boolean _notEquals_3 = (!Objects.equal(_data_3, null)); - if (_notEquals_3) { - _builder.append(" "); - String _escapedString_6 = this.escapedString(oms.getData().getRefType().getType().getName()); - _builder.append(_escapedString_6); - _builder.append(" "); - } - } - _builder.append(" & "); - CharSequence _generateDocText_2 = this.generateDocText(oms.getDocu()); - _builder.append(_generateDocText_2); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - } - } - return _builder; - } - - private CharSequence _generateDoc(final CompoundProtocolClass pc, final DocGen.DocGenContext ctx) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2} {"); - String _escapedString = this.escapedString(pc.getName()); - _builder.append(_escapedString); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(pc.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.append("\\level{3}{Sub Protocols}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\\begin{tabular}[ht]{|l|l|}"); - _builder.newLine(); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\textbf{Name} & \\textbf{Protocol}\\\\"); - _builder.newLine(); - { - EList<SubProtocol> _subProtocols = pc.getSubProtocols(); - for(final SubProtocol sub : _subProtocols) { - _builder.append("\\hline"); - _builder.newLine(); - String _escapedString_1 = this.escapedString(sub.getName()); - _builder.append(_escapedString_1); - _builder.append(" & "); - String _escapedString_2 = this.escapedString(sub.getProtocol().getName()); - _builder.append(_escapedString_2); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - return _builder; - } - - private CharSequence _generateDoc(final ActorClass ac, final DocGen.DocGenContext ctx) { - CharSequence _xblockexpression = null; - { - String _name = ac.getName(); - final String filename = (_name + "_structure.jpg"); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{2}{"); - String _escapedString = this.escapedString(ac.getName()); - _builder.append(_escapedString); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - CharSequence _generateDocText = this.generateDocText(ac.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if ((this.fileExists(ctx.model, this.getImagePath(filename)).equals("true") && ((!this._roomHelpers.getAllInterfaceItems(ac).isEmpty()) || (!ac.getActorRefs().isEmpty())))) { - _builder.append("\\level{3}{Structure}"); - _builder.newLine(); - CharSequence _generateDocText_1 = this.generateDocText(ac.getStructureDocu()); - _builder.append(_generateDocText_1); - _builder.newLineIfNotEmpty(); - String _imagePath = this.getImagePath(filename); - String _name_1 = ac.getName(); - String _plus = (_name_1 + " Structure"); - CharSequence _includeGraphics = this.includeGraphics(_imagePath, this.IMGWIDTH_DEFAULT, _plus); - _builder.append(_includeGraphics); - _builder.newLineIfNotEmpty(); - } else { - Documentation _structureDocu = ac.getStructureDocu(); - boolean _notEquals = (!Objects.equal(_structureDocu, null)); - if (_notEquals) { - _builder.append("\\level{3}{Structure}"); - _builder.newLine(); - CharSequence _generateDocText_2 = this.generateDocText(ac.getStructureDocu()); - _builder.append(_generateDocText_2); - _builder.newLineIfNotEmpty(); - } - } - } - _builder.newLine(); - { - boolean _isEmpty = this._roomHelpers.getAllPorts(ac).isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("\\level{3}{Ports}"); - _builder.newLine(); - String _generatePortDoc = this.generatePortDoc(ac); - _builder.append(_generatePortDoc); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - boolean _isBehaviorAnnotationPresent = this._roomHelpers.isBehaviorAnnotationPresent(ac, "BehaviorManual"); - if (_isBehaviorAnnotationPresent) { - _builder.append("\\level{3}{Behavior}"); - _builder.newLine(); - CharSequence _generateDocText_3 = this.generateDocText(ac.getBehaviorDocu()); - _builder.append(_generateDocText_3); - _builder.newLineIfNotEmpty(); - _builder.append("The behavior for ActorClass "); - String _name_2 = ac.getName(); - _builder.append(_name_2); - _builder.append(" is implemented manually."); - _builder.newLineIfNotEmpty(); - } else { - boolean _hasNonEmptyStateMachine = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine) { - _builder.append("\\level{3}{Behavior}"); - _builder.newLine(); - CharSequence _generateDocText_4 = this.generateDocText(ac.getBehaviorDocu()); - _builder.append(_generateDocText_4); - _builder.newLineIfNotEmpty(); - CharSequence _generateFsmDoc = this.generateFsmDoc(ctx.model, ac); - _builder.append(_generateFsmDoc); - _builder.newLineIfNotEmpty(); - } else { - Documentation _behaviorDocu = ac.getBehaviorDocu(); - boolean _notEquals_1 = (!Objects.equal(_behaviorDocu, null)); - if (_notEquals_1) { - _builder.append("\\level{3}{Behavior}"); - _builder.newLine(); - CharSequence _generateDocText_5 = this.generateDocText(ac.getBehaviorDocu()); - _builder.append(_generateDocText_5); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - { - boolean _isEmpty_1 = ac.getAttributes().isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - _builder.append("\\level{3}{Attributes}"); - _builder.newLine(); - CharSequence _generateAttributesDoc = this.generateAttributesDoc(ac.getAttributes()); - _builder.append(_generateAttributesDoc); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - boolean _isEmpty_2 = ac.getOperations().isEmpty(); - boolean _not_2 = (!_isEmpty_2); - if (_not_2) { - _builder.append("\\level{3}{Operations}"); - _builder.newLine(); - CharSequence _generateOperationsDoc = this.generateOperationsDoc(ac.getOperations()); - _builder.append(_generateOperationsDoc); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence generateFsmDoc(final RoomModel model, final ActorClass ac) { - CharSequence _xblockexpression = null; - { - String _name = ac.getName(); - final String filename = (_name + "_behavior.jpg"); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{4}{Top Level}"); - _builder.newLine(); - { - boolean _equals = this.fileExists(model, this.getImagePath(filename)).equals("true"); - if (_equals) { - String _imagePath = this.getImagePath(filename); - String _name_1 = ac.getName(); - String _plus = (_name_1 + " Top State"); - CharSequence _includeGraphics = this.includeGraphics(_imagePath, this.IMGWIDTH_DEFAULT, _plus); - _builder.append(_includeGraphics); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\\begin{par}"); - _builder.newLine(); - { - EList<State> _states = ac.getStateMachine().getStates(); - for(final State s : _states) { - { - Documentation _docu = s.getDocu(); - boolean _notEquals = (!Objects.equal(_docu, null)); - if (_notEquals) { - _builder.append("\\textbf{State description} \\textit{"); - String _replaceAll = this._codegenHelpers.getGenStatePathName(s).replaceAll("_", "\\\\_"); - _builder.append(_replaceAll); - _builder.append("}:"); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline"); - _builder.newLine(); - CharSequence _generateDocText = this.generateDocText(s.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline\\newline"); - _builder.newLine(); - } - } - } - } - _builder.newLine(); - { - EList<ChoicePoint> _chPoints = ac.getStateMachine().getChPoints(); - for(final ChoicePoint c : _chPoints) { - { - Documentation _docu_1 = c.getDocu(); - boolean _notEquals_1 = (!Objects.equal(_docu_1, null)); - if (_notEquals_1) { - _builder.append("\\textbf{Choicepoint description} \\textit{"); - String _escapedString = this.escapedString(c.getName()); - _builder.append(_escapedString); - _builder.append("}:"); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline"); - _builder.newLine(); - CharSequence _generateDocText_1 = this.generateDocText(c.getDocu()); - _builder.append(_generateDocText_1); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline\\newline"); - _builder.newLine(); - } - } - } - } - _builder.append("\\end{par}"); - _builder.newLine(); - _builder.newLine(); - { - EList<State> _states_1 = ac.getStateMachine().getStates(); - for(final State s_1 : _states_1) { - { - boolean _isLeaf = this._roomHelpers.isLeaf(s_1); - boolean _not = (!_isLeaf); - if (_not) { - String _generateStateDoc = this.generateStateDoc(model, ac, s_1); - _builder.append(_generateStateDoc); - _builder.newLineIfNotEmpty(); - } - } - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String getType(final Port p) { - String _xifexpression = null; - boolean _isConjugated = p.isConjugated(); - if (_isConjugated) { - _xifexpression = "conj."; - } else { - _xifexpression = "reg."; - } - return _xifexpression; - } - - private String getKind(final Port p) { - String _xifexpression = null; - boolean _isInternal = this._roomHelpers.isInternal(p); - if (_isInternal) { - _xifexpression = "internal"; - } else { - String _xifexpression_1 = null; - boolean _isExternal = this._roomHelpers.isExternal(p); - if (_isExternal) { - _xifexpression_1 = "external"; - } else { - String _xifexpression_2 = null; - boolean _isRelay = this._roomHelpers.isRelay(p); - if (_isRelay) { - _xifexpression_2 = "relay"; - } else { - _xifexpression_2 = "?"; - } - _xifexpression_1 = _xifexpression_2; - } - _xifexpression = _xifexpression_1; - } - return _xifexpression; - } - - private String getMultAsText(final Port p) { - String _xifexpression = null; - int _multiplicity = p.getMultiplicity(); - boolean _equals = (_multiplicity == (-1)); - if (_equals) { - _xifexpression = "*"; - } else { - _xifexpression = Integer.valueOf(p.getMultiplicity()).toString(); - } - return _xifexpression; - } - - private String generatePortDoc(final ActorClass ac) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\begin{tabular}[ht]{|l|l|l|l|l|p{5cm}|}"); - _builder.newLine(); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\textbf{Name} & \\textbf{Protocol} & \\textbf{Type} & \\textbf{Kind} & \\textbf{Multiplicity} & \\textbf{Description}\\\\"); - _builder.newLine(); - { - List<Port> _allPorts = this._roomHelpers.getAllPorts(ac); - for(final Port at : _allPorts) { - _builder.append("\\hline"); - _builder.newLine(); - String _escapedString = this.escapedString(at.getName()); - _builder.append(_escapedString); - _builder.append(" & "); - String _escapedString_1 = this.escapedString(at.getProtocol().getName()); - _builder.append(_escapedString_1); - _builder.append(" & "); - String _type = this.getType(at); - _builder.append(_type); - _builder.append(" & "); - String _kind = this.getKind(at); - _builder.append(_kind); - _builder.append(" & "); - String _multAsText = this.getMultAsText(at); - _builder.append(_multAsText); - _builder.append(" & "); - CharSequence _generateDocText = this.generateDocText(at.getDocu()); - _builder.append(_generateDocText); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - return _builder.toString(); - } - - private String generateStateDoc(final RoomModel model, final ActorClass ac, final State state) { - String _xblockexpression = null; - { - String _name = ac.getName(); - String _plus = (_name + "_"); - String _genStatePathName = this._codegenHelpers.getGenStatePathName(state); - String _plus_1 = (_plus + _genStatePathName); - final String filename = (_plus_1 + "_behavior.jpg"); - this.logger.logInfo(("Gen Filename: " + filename)); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\level{4}{Subgraph "); - String _replaceAll = this._codegenHelpers.getGenStatePathName(state).replaceAll("_", "\\\\_"); - _builder.append(_replaceAll); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - { - boolean _equals = this.fileExists(model, this.getImagePath(filename)).equals("true"); - if (_equals) { - String _imagePath = this.getImagePath(filename); - String _name_1 = ac.getName(); - String _plus_2 = (_name_1 + "_"); - String _genStatePathName_1 = this._codegenHelpers.getGenStatePathName(state); - String _plus_3 = (_plus_2 + _genStatePathName_1); - CharSequence _includeGraphics = this.includeGraphics(_imagePath, this.IMGWIDTH_DEFAULT, _plus_3); - _builder.append(_includeGraphics); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\\begin{par}"); - _builder.newLine(); - { - EList<State> _states = state.getSubgraph().getStates(); - for(final State s : _states) { - { - Documentation _docu = s.getDocu(); - boolean _notEquals = (!Objects.equal(_docu, null)); - if (_notEquals) { - _builder.append("\\textbf{State description} \\textit{"); - String _replaceAll_1 = this._codegenHelpers.getGenStatePathName(s).replaceAll("_", "\\\\_"); - _builder.append(_replaceAll_1); - _builder.append("}:"); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline"); - _builder.newLine(); - CharSequence _generateDocText = this.generateDocText(s.getDocu()); - _builder.append(_generateDocText); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline\\newline"); - _builder.newLine(); - } - } - } - } - _builder.newLine(); - { - EList<ChoicePoint> _chPoints = state.getSubgraph().getChPoints(); - for(final ChoicePoint c : _chPoints) { - { - Documentation _docu_1 = c.getDocu(); - boolean _notEquals_1 = (!Objects.equal(_docu_1, null)); - if (_notEquals_1) { - _builder.append("\\textbf{Choicepoint description} \\textit{"); - String _escapedString = this.escapedString(c.getName()); - _builder.append(_escapedString); - _builder.append("}:"); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline"); - _builder.newLine(); - CharSequence _generateDocText_1 = this.generateDocText(c.getDocu()); - _builder.append(_generateDocText_1); - _builder.newLineIfNotEmpty(); - _builder.append("\\newline\\newline"); - _builder.newLine(); - } - } - } - } - _builder.append("\\end{par}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - { - EList<State> _states_1 = state.getSubgraph().getStates(); - for(final State s_1 : _states_1) { - { - boolean _isLeaf = this._roomHelpers.isLeaf(s_1); - boolean _not = (!_isLeaf); - if (_not) { - String _generateStateDoc = this.generateStateDoc(model, ac, s_1); - _builder.append(_generateStateDoc); - _builder.newLineIfNotEmpty(); - } - } - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - private CharSequence generateAttributesDoc(final List<Attribute> attributes) { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isEmpty = attributes.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("\\begin{tabular}[ht]{|l|l|p{8cm}|}"); - _builder.newLine(); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\textbf{Name} & \\textbf{Type} & \\textbf{Description}\\\\"); - _builder.newLine(); - { - for(final Attribute at : attributes) { - _builder.append("\\hline"); - _builder.newLine(); - String _escapedString = this.escapedString(at.getName()); - _builder.append(_escapedString); - _builder.append(" & "); - String _escapedString_1 = this.escapedString(at.getType().getType().getName()); - _builder.append(_escapedString_1); - _builder.append(" & "); - CharSequence _generateDocText = this.generateDocText(at.getDocu()); - _builder.append(_generateDocText); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - } - } - return _builder; - } - - private CharSequence generateOperationsDoc(final List<StandardOperation> operations) { - StringConcatenation _builder = new StringConcatenation(); - { - for(final StandardOperation op : operations) { - _builder.append("\\begin{tabular}[ht]{|l|l|}"); - _builder.newLine(); - _builder.append("\\hline\t\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("Name: & "); - String _escapedString = this.escapedString(op.getName()); - _builder.append(_escapedString, "\t"); - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("ReturnType: & "); - { - RefableType _returnType = op.getReturnType(); - boolean _notEquals = (!Objects.equal(_returnType, null)); - if (_notEquals) { - String _escapedString_1 = this.escapedString(op.getReturnType().getType().getName()); - _builder.append(_escapedString_1, "\t"); - } else { - _builder.append("void"); - } - } - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("Arguments: & "); - { - EList<VarDecl> _arguments = op.getArguments(); - boolean _hasElements = false; - for(final VarDecl pa : _arguments) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", "\t"); - } - String _escapedString_2 = this.escapedString(pa.getName()); - _builder.append(_escapedString_2, "\t"); - _builder.append(":"); - String _escapedString_3 = this.escapedString(pa.getRefType().getType().getName()); - _builder.append(_escapedString_3, "\t"); - } - } - _builder.append("\\\\"); - _builder.newLineIfNotEmpty(); - { - Documentation _docu = op.getDocu(); - boolean _notEquals_1 = (!Objects.equal(_docu, null)); - if (_notEquals_1) { - _builder.append("\t"); - _builder.append("\\hline"); - _builder.newLine(); - { - int _length = op.getDocu().toString().length(); - boolean _greaterThan = (_length > 85); - if (_greaterThan) { - _builder.append("\t"); - _builder.append("\\multicolumn{2} {|p{13cm}|} {"); - CharSequence _generateDocText = this.generateDocText(op.getDocu()); - _builder.append(_generateDocText, "\t"); - _builder.append("}\\\\"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("\\multicolumn{2} {|l|} {"); - CharSequence _generateDocText_1 = this.generateDocText(op.getDocu()); - _builder.append(_generateDocText_1, "\t"); - _builder.append("}\\\\"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("\t"); - _builder.append("\\hline"); - _builder.newLine(); - _builder.append("\\end{tabular}"); - _builder.newLine(); - _builder.append("\\newline\\newline\\newline"); - _builder.newLine(); - } - } - return _builder; - } - - private CharSequence generateDocText(final Documentation doc) { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _notEquals = (!Objects.equal(doc, null)); - if (_notEquals) { - _builder.append("% begin text from user Documentation"); - _builder.newLine(); - { - EList<String> _lines = doc.getLines(); - for(final String line : _lines) { - String _escapedString = this.escapedString(line); - _builder.append(_escapedString); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("% end text from user Documentation"); - _builder.newLine(); - } - } - return _builder; - } - - private String fileExists(final RoomModel model, final String f) { - String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model); - final String absPath = (_docGenerationTargetPath + f); - final File file = new File(absPath); - final boolean exist = file.exists(); - if ((exist == true)) { - this.logger.logInfo(("File found ! " + f)); - return "true"; - } else { - this.logger.logInfo(("File not found ! " + f)); - return "false"; - } - } - - private CharSequence includeGraphics(final String filename, final String width, final String caption) { - CharSequence _xblockexpression = null; - { - String latexCaption = caption.replaceAll("_", "\\\\_"); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\\centering{}"); - _builder.newLine(); - _builder.append("\\includegraphics[width="); - _builder.append(width); - _builder.append("]{"); - _builder.append(filename); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - _builder.append("\\figcaption{"); - _builder.append(latexCaption); - _builder.append("}"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String escapedString(final String text) { - return text.replace("_", "\\_"); - } - - private String getImagePath(final String filename) { - String filenamei = ((this.IMGDIR_DEFAULT + "/") + filename); - filenamei = filenamei.replaceAll("\\\\", "/"); - return filenamei; - } - - private void saveAs(final CharSequence content, final String filename) { - this.fileAccess.generateFile(filename, content); - } - - private String docFragmentName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + ".tex"); - } - - private CharSequence generateImport(final RoomClass rc, final String dir) { - StringConcatenation _builder = new StringConcatenation(); - CharSequence _generateImport = this.generateImport(this.docFragmentName(rc), dir); - _builder.append(_generateImport); - return _builder; - } - - private CharSequence generateImport(final String name, final String dir) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\\subimport*{"); - _builder.append(dir); - _builder.append("/}{"); - _builder.append(name); - _builder.append("}"); - return _builder; - } - - private CharSequence generateDoc(final RoomClass ac, final DocGen.DocGenContext ctx) { - if (ac instanceof ActorClass) { - return _generateDoc((ActorClass)ac, ctx); - } else if (ac instanceof DataClass) { - return _generateDoc((DataClass)ac, ctx); - } else if (ac instanceof SubSystemClass) { - return _generateDoc((SubSystemClass)ac, ctx); - } else if (ac instanceof CompoundProtocolClass) { - return _generateDoc((CompoundProtocolClass)ac, ctx); - } else if (ac instanceof EnumerationType) { - return _generateDoc((EnumerationType)ac, ctx); - } else if (ac instanceof LogicalSystem) { - return _generateDoc((LogicalSystem)ac, ctx); - } else if (ac instanceof ProtocolClass) { - return _generateDoc((ProtocolClass)ac, ctx); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " + - Arrays.<Object>asList(ac, ctx).toString()); - } - } -} diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java deleted file mode 100644 index 3e3c6592b..000000000 --- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.doc.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.io.File; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.etmap.util.ETMapUtil; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInterfaceInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.generator.JavaIoFileSystemAccess; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.Extension; - -@Singleton -@SuppressWarnings("all") -public class InstanceDiagramGen { - @Inject - @Extension - private JavaIoFileSystemAccess fileAccess; - - @Inject - @Extension - private RoomExtensions roomExt; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - EList<RoomModel> _models = root.getModels(); - for (final RoomModel model : _models) { - { - String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model); - String path = (_docGenerationTargetPath + "/images"); - this.fileAccess.setOutputPath(path); - String batchFile = "dot2jpg.bat"; - EList<SystemInstance> _systemInstances = root.getSystemInstances(); - for (final SystemInstance sys : _systemInstances) { - { - String _name = sys.getName(); - String file = (_name + "_instanceTree.dot"); - this.logger.logInfo((((("generating instance tree diagram: \'" + file) + "\' in \'") + path) + "\'")); - this.fileAccess.generateFile(file, this.generate(root, sys)); - } - } - this.fileAccess.generateFile(batchFile, this.generate2jpg(root)); - this.runDot2Jpg(path, batchFile); - } - } - } - - private CharSequence generate2jpg(final Root root) { - StringConcatenation _builder = new StringConcatenation(); - { - EList<SystemInstance> _systemInstances = root.getSystemInstances(); - for(final SystemInstance sys : _systemInstances) { - _builder.append("dot -Tjpg -o "); - String _name = sys.getName(); - _builder.append(_name); - _builder.append("_instanceTree.jpg "); - String _name_1 = sys.getName(); - _builder.append(_name_1); - _builder.append("_instanceTree.dot"); - _builder.newLineIfNotEmpty(); - } - } - return _builder; - } - - private CharSequence generate(final Root root, final SystemInstance sys) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("digraph "); - String _name = sys.getName(); - _builder.append(_name); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("rankdir=LR;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("node [shape=box];"); - _builder.newLine(); - _builder.append("\t"); - String _pathName = this.roomExt.getPathName(sys.getPath()); - _builder.append(_pathName, "\t"); - _builder.append(" [label=\""); - String _name_1 = sys.getName(); - _builder.append(_name_1, "\t"); - _builder.append("\\n("); - String _name_2 = sys.getName(); - _builder.append(_name_2, "\t"); - _builder.append(")\" style=filled color=red];"); - _builder.newLineIfNotEmpty(); - { - EList<SubSystemInstance> _instances = sys.getInstances(); - for(final SubSystemInstance ssi : _instances) { - _builder.append("\t"); - String _pathName_1 = this.roomExt.getPathName(ssi.getPath()); - _builder.append(_pathName_1, "\t"); - _builder.append(" [label=\""); - String _name_3 = ssi.getName(); - _builder.append(_name_3, "\t"); - _builder.append("\\n("); - String _name_4 = ssi.getSubSystemClass().getName(); - _builder.append(_name_4, "\t"); - _builder.append(")\" style=filled color=yellow];"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _pathName_2 = this.roomExt.getPathName(sys.getPath()); - _builder.append(_pathName_2, "\t"); - _builder.append(" -> "); - String _pathName_3 = this.roomExt.getPathName(ssi.getPath()); - _builder.append(_pathName_3, "\t"); - _builder.append("; "); - _builder.newLineIfNotEmpty(); - { - EList<AbstractInstance> _instances_1 = ssi.getInstances(); - for(final AbstractInstance ai : _instances_1) { - _builder.append("\t"); - String _instance = this.instance(ai); - _builder.append(_instance, "\t"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("}"); - _builder.newLine(); - return _builder; - } - - private String instance(final AbstractInstance ai) { - String _xblockexpression = null; - { - EObject _eContainer = ai.eContainer(); - final StructureInstance parent = ((StructureInstance) _eContainer); - final ETMapUtil.MappedThread pthread = ETMapUtil.getMappedThread(ai); - String _xifexpression = null; - boolean _equals = Objects.equal(pthread, null); - if (_equals) { - _xifexpression = "?"; - } else { - _xifexpression = pthread.getThread().getName(); - } - final String tname = _xifexpression; - final NodeRef node = ETMapUtil.getNodeRef(ai); - String _xifexpression_1 = null; - boolean _equals_1 = Objects.equal(node, null); - if (_equals_1) { - _xifexpression_1 = "?"; - } else { - _xifexpression_1 = node.getName(); - } - final String nname = _xifexpression_1; - String _xifexpression_2 = null; - if ((ai instanceof ActorInterfaceInstance)) { - _xifexpression_2 = "optional "; - } else { - _xifexpression_2 = ""; - } - final String optional = _xifexpression_2; - String _xifexpression_3 = null; - if ((ai instanceof ActorInstance)) { - _xifexpression_3 = ((ActorInstance) ai).getActorClass().getName(); - } else { - String _xifexpression_4 = null; - if ((ai instanceof ActorInterfaceInstance)) { - _xifexpression_4 = ((ActorInterfaceInstance) ai).getActorClass().getName(); - } else { - _xifexpression_4 = "?"; - } - _xifexpression_3 = _xifexpression_4; - } - final String clsname = _xifexpression_3; - StringConcatenation _builder = new StringConcatenation(); - String _pathName = this.roomExt.getPathName(ai.getPath()); - _builder.append(_pathName); - _builder.append(" [label=\""); - _builder.append(optional); - String _name = ai.getName(); - _builder.append(_name); - _builder.append("\\n("); - _builder.append(clsname); - _builder.append(")\\n@"); - _builder.append(nname); - _builder.append(":"); - _builder.append(tname); - _builder.append("\""); - { - boolean _isEmpty = optional.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append(" color=blue style=dashed"); - } - } - _builder.append("];"); - _builder.newLineIfNotEmpty(); - String _pathName_1 = this.roomExt.getPathName(parent.getPath()); - _builder.append(_pathName_1); - _builder.append(" -> "); - String _pathName_2 = this.roomExt.getPathName(ai.getPath()); - _builder.append(_pathName_2); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - { - if ((ai instanceof StructureInstance)) { - { - EList<AbstractInstance> _instances = ((StructureInstance) ai).getInstances(); - for(final AbstractInstance sub_ai : _instances) { - String _instance = this.instance(sub_ai); - _builder.append(_instance); - _builder.newLineIfNotEmpty(); - } - } - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - private void runDot2Jpg(final String path, final String bat) { - File wdir = new File(path); - try { - final Process p = Runtime.getRuntime().exec(("cmd /C " + bat), null, wdir); - int _waitFor = p.waitFor(); - String _plus = ((bat + " finished with ") + Integer.valueOf(_waitFor)); - this.logger.logInfo(_plus); - } catch (final Throwable _t) { - if (_t instanceof Exception) { - final Exception e = (Exception)_t; - e.printStackTrace(); - } else { - throw Exceptions.sneakyThrow(_t); - } - } - } -} diff --git a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java deleted file mode 100644 index 8bcdcfc2b..000000000 --- a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java +++ /dev/null @@ -1,1774 +0,0 @@ -/** - * Copyright (c) 2014 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.fsm.generic; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.common.collect.Iterators; -import com.google.inject.Inject; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType; -import org.eclipse.etrice.core.fsm.fSM.GuardedTransition; -import org.eclipse.etrice.core.fsm.fSM.InitialTransition; -import org.eclipse.etrice.core.fsm.fSM.MessageFromIf; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.Transition; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.fsm.fSM.TransitionPoint; -import org.eclipse.etrice.core.fsm.naming.FSMNameProvider; -import org.eclipse.etrice.core.fsm.util.FSMHelpers; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.TriggerExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.CommonTrigger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.generator.fsm.base.CodegenHelpers; -import org.eclipse.etrice.generator.fsm.generic.FSMExtensions; -import org.eclipse.etrice.generator.fsm.generic.IDetailCodeTranslator; -import org.eclipse.etrice.generator.fsm.generic.IIfItemIdGenerator; -import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase; -import org.eclipse.etrice.generator.fsm.generic.IMessageIdGenerator; -import org.eclipse.etrice.generator.fsm.generic.TransitionChainGenerator; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.util.Pair; -import org.eclipse.xtext.util.Tuples; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -/** - * @author Henrik Rentz-Reichert - */ -@SuppressWarnings("all") -public abstract class AbstractStateMachineGenerator { - @Inject - @Extension - public FSMHelpers _fSMHelpers; - - @Inject - @Extension - public CodegenHelpers _codegenHelpers; - - @Inject - @Extension - public FSMExtensions _fSMExtensions; - - @Inject - public ILanguageExtensionBase langExt; - - @Inject - public IMessageIdGenerator msgIdGen; - - @Inject - public IIfItemIdGenerator itemIdGen; - - @Inject - public TransitionChainGenerator transitionChainGenerator; - - @Inject - public IDetailCodeTranslator translator; - - @Inject - public FSMNameProvider fsmNameProvider; - - /** - * generates trigger IDs. - * Inheritance (if available) is used for base class IDs. - * - * @param gc the {@link GraphContainer} - * @return the generated code - */ - public String genTriggerConstants(final GraphContainer gc) { - return this.genTriggerConstants(gc, this.langExt.usesInheritance()); - } - - /** - * generates trigger IDs. - * Inheritance (if available) is used for base class IDs. - * - * @param gc the {@link GraphContainer} - * @param omitBase use <code>true</code> if no base class trigger constants are needed - * - * @return the generated code - */ - public String genTriggerConstants(final GraphContainer gc, final boolean omitBase) { - List<MessageFromIf> _xifexpression = null; - if (omitBase) { - _xifexpression = this._fSMHelpers.getOwnMessagesFromInterfaces(gc.getComponent()); - } else { - _xifexpression = this._fSMHelpers.getAllMessagesFromInterfaces(gc.getComponent()); - } - final List<MessageFromIf> triggers = _xifexpression; - final ArrayList<Pair<String, String>> list = CollectionLiterals.<Pair<String, String>>newArrayList(); - list.add(Tuples.<String, String>pair("POLLING", "0")); - for (final MessageFromIf mif : triggers) { - boolean _isEventDriven = mif.getFrom().isEventDriven(); - if (_isEventDriven) { - String _triggerCodeName = this.getTriggerCodeName(mif); - String _ifItemId = this.itemIdGen.getIfItemId(mif.getFrom()); - String _plus = (_ifItemId + " + EVT_SHIFT*"); - String _messageID = this.msgIdGen.getMessageID(mif); - String _plus_1 = (_plus + _messageID); - list.add(Tuples.<String, String>pair(_triggerCodeName, _plus_1)); - } - } - return this.langExt.genEnumeration("triggers", list); - } - - public String getTriggerCodeName(final MessageFromIf mif) { - String _name = mif.getFrom().getName(); - String _plus = ("TRIG_" + _name); - String _plus_1 = (_plus + "__"); - String _messageName = this.fsmNameProvider.getMessageName(mif.getMessage()); - return (_plus_1 + _messageName); - } - - /** - * generates state ID constants. - * Inheritance (if available) is used for base class IDs. - * - * @param gc the {@link GraphContainer} - * @return the generated code - */ - public String genStateIdConstants(final GraphContainer gc) { - return this.genStateIdConstants(gc, this.langExt.usesInheritance()); - } - - /** - * generates state ID constants. - * Inheritance (if available) is used for base class IDs. - * - * @param gc the {@link GraphContainer} - * @param omitBase use <code>true</code> if no base class state constants are needed - * - * @return the generated code - */ - public String genStateIdConstants(final GraphContainer gc, final boolean omitBase) { - final List<Node> allStateNodes = IteratorExtensions.<Node>toList(FsmGenExtensions.getAllStateNodes(gc.getGraph())); - int _xifexpression = (int) 0; - if (omitBase) { - final Function1<Node, Boolean> _function = (Node it) -> { - return Boolean.valueOf(it.isInherited()); - }; - _xifexpression = IterableExtensions.size(IterableExtensions.<Node>filter(allStateNodes, _function)); - } else { - _xifexpression = 0; - } - int offset = (2 + _xifexpression); - Iterable<Node> _xifexpression_1 = null; - if (omitBase) { - final Function1<Node, Boolean> _function_1 = (Node it) -> { - boolean _isInherited = it.isInherited(); - return Boolean.valueOf((!_isInherited)); - }; - _xifexpression_1 = IterableExtensions.<Node>filter(allStateNodes, _function_1); - } else { - _xifexpression_1 = allStateNodes; - } - final Function1<Node, StateGraphNode> _function_2 = (Node it) -> { - return it.getStateGraphNode(); - }; - List<State> baseStates = IterableExtensions.<State>toList(Iterables.<State>filter(IterableExtensions.<Node, StateGraphNode>map(_xifexpression_1, _function_2), State.class)); - baseStates = IterableExtensions.<State>toList(this._fSMExtensions.getLeafStatesLast(baseStates)); - ArrayList<Pair<String, String>> list = CollectionLiterals.<Pair<String, String>>newArrayList(); - if ((!omitBase)) { - list.add(Tuples.<String, String>pair("NO_STATE", "0")); - list.add(Tuples.<String, String>pair("STATE_TOP", "1")); - } - for (final State state : baseStates) { - { - list.add(Tuples.<String, String>pair(this._codegenHelpers.getGenStateId(state), Integer.valueOf(offset).toString())); - offset = (offset + 1); - } - } - list.add(Tuples.<String, String>pair("STATE_MAX", Integer.valueOf(offset).toString())); - return this.langExt.genEnumeration("state_ids", list); - } - - /** - * generates transition chain ID constants. - * Inheritance can't be used used for base class IDs because of corner cases - * where base class and derived class chain IDs deviate (see bug 501354). - * - * @param gc the {@link GraphContainer} - * - * @return the generated code - */ - public String genTransitionChainConstants(final GraphContainer gc) { - return this.genTransitionChainConstants(gc, false); - } - - /** - * generates transition chain ID constants.<br/><br/> - * - * <b>Note:</b> Inheritance can't be used used for base class IDs because of corner cases - * where base class and derived class chain IDs deviate. - * - * @param gc the {@link GraphContainer} - * @param omitBase use <code>true</code> if no base class transition chain constants are needed - * - * @return the generated code - */ - public String genTransitionChainConstants(final GraphContainer gc, final boolean omitBase) { - Iterator<Link> _xifexpression = null; - if (omitBase) { - final Function1<Link, Boolean> _function = (Link it) -> { - boolean _isInherited = it.isInherited(); - return Boolean.valueOf((!_isInherited)); - }; - _xifexpression = IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(gc.getGraph()), _function); - } else { - _xifexpression = FsmGenExtensions.getAllLinks(gc.getGraph()); - } - final Function1<Link, TransitionBase> _function_1 = (Link it) -> { - return it.getTransition(); - }; - final Function1<TransitionBase, Boolean> _function_2 = (TransitionBase it) -> { - return Boolean.valueOf(FsmGenExtensions.isChainHead(it)); - }; - final List<Transition> chains = IteratorExtensions.<Transition>toList(Iterators.<Transition>filter(IteratorExtensions.<TransitionBase>filter(IteratorExtensions.<Link, TransitionBase>map(_xifexpression, _function_1), _function_2), Transition.class)); - int _xifexpression_1 = (int) 0; - if (omitBase) { - final Function1<Link, Boolean> _function_3 = (Link it) -> { - return Boolean.valueOf(it.isInherited()); - }; - _xifexpression_1 = IteratorExtensions.size(IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(gc.getGraph()), _function_3)); - } else { - _xifexpression_1 = 0; - } - int offset = _xifexpression_1; - ArrayList<Pair<String, String>> list = CollectionLiterals.<Pair<String, String>>newArrayList(); - for (final Transition chain : chains) { - { - offset = (offset + 1); - list.add(Tuples.<String, String>pair(this._codegenHelpers.getGenChainId(chain), Integer.valueOf(offset).toString())); - } - } - return this.langExt.genEnumeration("ChainIDs", list); - } - - /** - * generates entry and exit code for states - * - * @param gc the {@link GraphContainer} - * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration - * - * @return the generated code - */ - public String genEntryAndExitCodes(final GraphContainer gc, final boolean generateImplementation) { - return this.genEntryAndExitCodes(gc, generateImplementation, this.langExt.usesInheritance()); - } - - /** - * generates entry and exit code for states - * - * @param gc the {@link GraphContainer} - * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration - * @param omitBase use <code>true</code> if no base class entry and exit codes are needed - * - * @return the generated code - */ - public String genEntryAndExitCodes(final GraphContainer gc, final boolean generateImplementation, final boolean omitBase) { - String _xblockexpression = null; - { - final Function1<Node, Boolean> _function = (Node it) -> { - return Boolean.valueOf(((!omitBase) || (!it.isInherited()))); - }; - final List<Node> states = IteratorExtensions.<Node>toList(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(gc.getGraph()), _function)); - StringConcatenation _builder = new StringConcatenation(); - { - for(final Node state : states) { - String _genActionCodeMethods = this.genActionCodeMethods(gc, state, generateImplementation); - _builder.append(_genActionCodeMethods); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - /** - * generates transition action codes - * - * @param gc the {@link GraphContainer} - * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration - * - * @return the generated code - */ - public String genActionCodes(final GraphContainer gc, final boolean generateImplementation) { - return this.genActionCodes(gc, generateImplementation, this.langExt.usesInheritance()); - } - - /** - * generates transition action codes - * - * @param gc the {@link GraphContainer} - * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration - * @param omitBase use <code>true</code> if no base class action codes are needed - * - * @return the generated code - */ - public String genActionCodes(final GraphContainer gc, final boolean generateImplementation, final boolean omitBase) { - String _xblockexpression = null; - { - final Function1<Link, Boolean> _function = (Link it) -> { - return Boolean.valueOf(((!omitBase) || (!it.isInherited()))); - }; - final Function1<Link, Boolean> _function_1 = (Link it) -> { - return Boolean.valueOf(this._fSMHelpers.hasDetailCode(it.getTransition().getAction())); - }; - final List<Link> transitions = IteratorExtensions.<Link>toList(IteratorExtensions.<Link>filter(IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(gc.getGraph()), _function), _function_1)); - StringConcatenation _builder = new StringConcatenation(); - { - for(final Link tr : transitions) { - String _genActionCodeMethod = this.genActionCodeMethod(gc, tr, generateImplementation); - _builder.append(_genActionCodeMethod); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - public String genStateSwitchMethods(final GraphContainer gc, final boolean generateImplementation) { - String _xblockexpression = null; - { - final ModelComponent mc = gc.getComponent(); - ComponentCommunicationType _commType = mc.getCommType(); - final boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS); - ComponentCommunicationType _commType_1 = mc.getCommType(); - final boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN); - String _interfaceItemType = this.interfaceItemType(); - String _pointerLiteral = this.langExt.pointerLiteral(); - final String ifItemPtr = (_interfaceItemType + _pointerLiteral); - final boolean handleEvents = (async || eventDriven); - String _xifexpression = null; - boolean _usesInheritance = this.langExt.usesInheritance(); - if (_usesInheritance) { - String _className = this.getClassName(mc); - String _scopeSeparator = this.langExt.scopeSeparator(); - _xifexpression = (_className + _scopeSeparator); - } else { - _xifexpression = ""; - } - final String chainIDScope = _xifexpression; - final String opScope = this.langExt.operationScope(this.getClassName(mc), (!generateImplementation)); - String _xifexpression_1 = null; - boolean _usesInheritance_1 = this.langExt.usesInheritance(); - if (_usesInheritance_1) { - _xifexpression_1 = opScope; - } else { - _xifexpression_1 = ""; - } - final String opScopePriv = _xifexpression_1; - String _xifexpression_2 = null; - boolean _usesInheritance_2 = this.langExt.usesInheritance(); - if (_usesInheritance_2) { - _xifexpression_2 = this.langExt.accessLevelPublic(); - } else { - _xifexpression_2 = this.langExt.accessLevelPrivate(); - } - final String publicIf = _xifexpression_2; - final String privAccess = this.langExt.accessLevelPrivate(); - final String selfPtr = this.langExt.selfPointer(this.getClassName(mc), true); - final String selfOnly = this.langExt.selfPointer(this.getClassName(mc), false); - String _xifexpression_3 = null; - boolean _usesInheritance_3 = this.langExt.usesInheritance(); - if (_usesInheritance_3) { - String _xifexpression_4 = null; - boolean _usesPointers = this.langExt.usesPointers(); - if (_usesPointers) { - _xifexpression_4 = "->getLocalId()"; - } else { - _xifexpression_4 = ".getLocalId()"; - } - _xifexpression_3 = _xifexpression_4; - } else { - _xifexpression_3 = "->localId"; - } - final String getLocalId = _xifexpression_3; - String _xifexpression_5 = null; - boolean _usesPointers_1 = this.langExt.usesPointers(); - if (_usesPointers_1) { - _xifexpression_5 = ("const " + ifItemPtr); - } else { - _xifexpression_5 = ifItemPtr; - } - final String constIfItemPtr = _xifexpression_5; - final boolean usesHdlr = this.usesHandlerTrPoints(gc); - final Function1<Node, String> _function = (Node it) -> { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return this._codegenHelpers.getGenStateId(((State) _stateGraphNode)); - }; - final List<Node> nodes = IterableExtensions.<Node, String>sortBy(IteratorExtensions.<Node>toList(FsmGenExtensions.getAllStateNodes(gc.getGraph())), _function); - final HashMap<State, Node> state2node = CollectionLiterals.<State, Node>newHashMap(); - final Consumer<Node> _function_1 = (Node it) -> { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - state2node.put(((State) _stateGraphNode), it); - }; - nodes.forEach(_function_1); - final Function1<Node, StateGraphNode> _function_2 = (Node it) -> { - return it.getStateGraphNode(); - }; - final List<State> states = IterableExtensions.<State>toList(Iterables.<State>filter(ListExtensions.<Node, StateGraphNode>map(nodes, _function_2), State.class)); - final Function1<Link, Boolean> _function_3 = (Link it) -> { - return Boolean.valueOf(FsmGenExtensions.isChainHead(it)); - }; - final Function1<Link, String> _function_4 = (Link it) -> { - return this._codegenHelpers.getGenChainId(it.getTransition()); - }; - final List<Link> transitionChains = IterableExtensions.<Link, String>sortBy(IteratorExtensions.<Link>toList(IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(gc.getGraph()), _function_3)), _function_4); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* calls exit codes while exiting from the current state to one of its"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* parent states while remembering the history"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @param current__et - the current state"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @param to - the final parent state"); - _builder.newLine(); - { - if (usesHdlr) { - _builder.append("* @param handler__et - entry and exit codes are called only if not handler (for handler TransitionPoints)"); - _builder.newLine(); - } - } - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - { - if (generateImplementation) { - _builder.append(privAccess); - _builder.append("void "); - _builder.append(opScopePriv); - _builder.append("exitTo("); - _builder.append(selfPtr); - String _stateType = this.stateType(); - _builder.append(_stateType); - _builder.append(" current__et, "); - String _stateType_1 = this.stateType(); - _builder.append(_stateType_1); - _builder.append(" to"); - { - if (usesHdlr) { - _builder.append(", "); - String _boolType = this.boolType(); - _builder.append(_boolType); - _builder.append(" handler__et"); - } - } - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("while (current__et!=to) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("switch (current__et) {"); - _builder.newLine(); - { - for(final State state : states) { - _builder.append("\t\t\t"); - _builder.append("case "); - String _genStateId = this._codegenHelpers.getGenStateId(state); - _builder.append(_genStateId, "\t\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - { - boolean _hasExitCode = this._fSMHelpers.hasExitCode(state, true); - if (_hasExitCode) { - { - if (usesHdlr) { - _builder.append("if (!handler__et) "); - } - } - String _exitCodeOperationName = this._codegenHelpers.getExitCodeOperationName(state); - _builder.append(_exitCodeOperationName, "\t\t\t\t"); - _builder.append("("); - String _selfPointer = this.langExt.selfPointer(false); - _builder.append(_selfPointer, "\t\t\t\t"); - _builder.append(");"); - } - } - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - String _setHistory = this.setHistory(this._codegenHelpers.getParentStateId(state), this._codegenHelpers.getGenStateId(state)); - _builder.append(_setHistory, "\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("current__et = "); - String _parentStateId = this._codegenHelpers.getParentStateId(state); - _builder.append(_parentStateId, "\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("\t\t\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("/* should not occur */"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("void exitTo("); - _builder.append(selfPtr); - String _stateType_2 = this.stateType(); - _builder.append(_stateType_2); - _builder.append(" current__et, "); - String _stateType_3 = this.stateType(); - _builder.append(_stateType_3); - _builder.append(" to"); - { - if (usesHdlr) { - _builder.append(", "); - String _boolType_1 = this.boolType(); - _builder.append(_boolType_1); - _builder.append(" handler__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* matching the trigger of this chain. The ID of the final state is returned"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @param chain__et - the chain ID"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @param generic_data__et - the generic data pointer"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @return the +/- ID of the final state either with a positive sign, that indicates to execute the state\'s entry code, or a negative sign vice versa"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - { - if (generateImplementation) { - _builder.append(privAccess); - String _stateType_4 = this.stateType(); - _builder.append(_stateType_4); - _builder.append(" "); - _builder.append(opScopePriv); - _builder.append("executeTransitionChain("); - _builder.append(selfPtr); - _builder.append("int chain__et"); - { - if (handleEvents) { - _builder.append(", "); - _builder.append(constIfItemPtr); - _builder.append(" ifitem, "); - String _voidPointer = this.langExt.voidPointer(); - _builder.append(_voidPointer); - _builder.append(" generic_data__et"); - } - } - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("switch (chain__et) {"); - _builder.newLine(); - { - for(final Link tc : transitionChains) { - _builder.append("\t\t"); - _builder.append("case "); - _builder.append(chainIDScope, "\t\t"); - String _genChainId = this._codegenHelpers.getGenChainId(tc.getTransition()); - _builder.append(_genChainId, "\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - String _generateExecuteChain = this.transitionChainGenerator.generateExecuteChain(gc, tc); - _builder.append(_generateExecuteChain, "\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t\t\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("/* should not occur */"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("return NO_STATE;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } else { - String _stateType_5 = this.stateType(); - _builder.append(_stateType_5); - _builder.append(" executeTransitionChain("); - _builder.append(selfPtr); - _builder.append("int chain__et"); - { - if (handleEvents) { - _builder.append(", "); - _builder.append(constIfItemPtr); - _builder.append(" ifitem, "); - String _voidPointer_1 = this.langExt.voidPointer(); - _builder.append(_voidPointer_1); - _builder.append(" generic_data__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/**"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* @param state__et - the state which is entered"); - _builder.newLine(); - { - if (usesHdlr) { - _builder.append("* @param handler__et - entry code is executed if not handler"); - _builder.newLine(); - } - } - _builder.append(" "); - _builder.append("* @return - the ID of the final leaf state"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - { - if (generateImplementation) { - _builder.append(privAccess); - String _stateType_6 = this.stateType(); - _builder.append(_stateType_6); - _builder.append(" "); - _builder.append(opScopePriv); - _builder.append("enterHistory("); - _builder.append(selfPtr); - String _stateType_7 = this.stateType(); - _builder.append(_stateType_7); - _builder.append(" state__et"); - { - if (usesHdlr) { - _builder.append(", "); - String _boolType_2 = this.boolType(); - _builder.append(_boolType_2); - _builder.append(" handler__et"); - } - } - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - final Function1<State, Boolean> _function_5 = (State s) -> { - return Boolean.valueOf(this._fSMHelpers.hasEntryCode(s, true)); - }; - boolean _isEmpty = IterableExtensions.isEmpty(IterableExtensions.<State>filter(states, _function_5)); - final boolean needsSkipVar = (!_isEmpty); - _builder.newLineIfNotEmpty(); - { - if (needsSkipVar) { - _builder.append("\t"); - String _boolType_3 = this.boolType(); - _builder.append(_boolType_3, "\t"); - _builder.append(" skip_entry__et = "); - String _booleanConstant = this.langExt.booleanConstant(false); - _builder.append(_booleanConstant, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("if (state__et >= STATE_MAX) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("state__et = "); - { - boolean _usesInheritance_4 = this.langExt.usesInheritance(); - boolean _not = (!_usesInheritance_4); - if (_not) { - _builder.append("("); - String _stateType_8 = this.stateType(); - _builder.append(_stateType_8, "\t\t"); - _builder.append(")"); - } - } - _builder.append(" (state__et - STATE_MAX);"); - _builder.newLineIfNotEmpty(); - { - if (needsSkipVar) { - _builder.append("\t\t"); - _builder.append("skip_entry__et = "); - String _booleanConstant_1 = this.langExt.booleanConstant(true); - _builder.append(_booleanConstant_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("while ("); - String _booleanConstant_2 = this.langExt.booleanConstant(true); - _builder.append(_booleanConstant_2, "\t"); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("switch (state__et) {"); - _builder.newLine(); - { - for(final State state_1 : states) { - _builder.append("\t\t\t"); - _builder.append("case "); - String _genStateId_1 = this._codegenHelpers.getGenStateId(state_1); - _builder.append(_genStateId_1, "\t\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - { - boolean _hasEntryCode = this._fSMHelpers.hasEntryCode(state_1, true); - if (_hasEntryCode) { - _builder.append("if (!(skip_entry__et"); - { - if (usesHdlr) { - _builder.append(" || handler__et"); - } - } - _builder.append(")) "); - String _entryCodeOperationName = this._codegenHelpers.getEntryCodeOperationName(state_1); - _builder.append(_entryCodeOperationName, "\t\t\t\t"); - _builder.append("("); - String _selfPointer_1 = this.langExt.selfPointer(false); - _builder.append(_selfPointer_1, "\t\t\t\t"); - _builder.append(");"); - } - } - _builder.newLineIfNotEmpty(); - { - boolean _isLeaf = this._fSMHelpers.isLeaf(state_1); - if (_isLeaf) { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("/* in leaf state: return state id */"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("return "); - String _genStateId_2 = this._codegenHelpers.getGenStateId(state_1); - _builder.append(_genStateId_2, "\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("/* state has a sub graph */"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - InitialTransition sub_initt = FsmGenExtensions.getInitialTransition(state2node.get(state_1).getSubgraph()); - _builder.newLineIfNotEmpty(); - { - if ((sub_initt != null)) { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("/* with init transition */"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("if ("); - String _history = this.getHistory(this._codegenHelpers.getGenStateId(state_1)); - _builder.append(_history, "\t\t\t\t"); - _builder.append("==NO_STATE) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("state__et = executeTransitionChain("); - String _selfPointer_2 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_2, "\t\t\t\t\t"); - _builder.append(chainIDScope, "\t\t\t\t\t"); - String _genChainId_1 = this._codegenHelpers.getGenChainId(sub_initt); - _builder.append(_genChainId_1, "\t\t\t\t\t"); - { - if (handleEvents) { - _builder.append(", "); - String _nullPointer = this.langExt.nullPointer(); - _builder.append(_nullPointer, "\t\t\t\t\t"); - _builder.append(", "); - String _nullPointer_1 = this.langExt.nullPointer(); - _builder.append(_nullPointer_1, "\t\t\t\t\t"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("else {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("state__et = "); - String _history_1 = this.getHistory(this._codegenHelpers.getGenStateId(state_1)); - _builder.append(_history_1, "\t\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("/* without init transition */"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("state__et = "); - String _history_2 = this.getHistory(this._codegenHelpers.getGenStateId(state_1)); - _builder.append(_history_2, "\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - } - } - _builder.append("\t\t\t"); - _builder.append("case STATE_TOP:"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("state__et = "); - String _history_3 = this.getHistory("STATE_TOP"); - _builder.append(_history_3, "\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("/* should not occur */"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - { - if (needsSkipVar) { - _builder.append("\t\t"); - _builder.append("skip_entry__et = "); - String _booleanConstant_3 = this.langExt.booleanConstant(false); - _builder.append(_booleanConstant_3, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - String _unreachableReturn = this.unreachableReturn(); - _builder.append(_unreachableReturn, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } else { - String _stateType_9 = this.stateType(); - _builder.append(_stateType_9); - _builder.append(" enterHistory("); - _builder.append(selfPtr); - String _stateType_10 = this.stateType(); - _builder.append(_stateType_10); - _builder.append(" state__et"); - { - if (usesHdlr) { - _builder.append(", "); - String _boolType_4 = this.boolType(); - _builder.append(_boolType_4); - _builder.append(" handler__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - if (generateImplementation) { - _builder.append(publicIf); - _builder.append("void "); - _builder.append(opScope); - _builder.append("executeInitTransition("); - _builder.append(selfOnly); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - InitialTransition initt = FsmGenExtensions.getInitialTransition(gc.getGraph()); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("int chain__et = "); - _builder.append(chainIDScope, "\t"); - String _genChainId_2 = this._codegenHelpers.getGenChainId(initt); - _builder.append(_genChainId_2, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _stateType_11 = this.stateType(); - _builder.append(_stateType_11, "\t"); - _builder.append(" next__et = "); - _builder.append(opScopePriv, "\t"); - _builder.append("executeTransitionChain("); - String _selfPointer_3 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_3, "\t"); - _builder.append("chain__et"); - { - if (handleEvents) { - _builder.append(", "); - String _nullPointer_2 = this.langExt.nullPointer(); - _builder.append(_nullPointer_2, "\t"); - _builder.append(", "); - String _nullPointer_3 = this.langExt.nullPointer(); - _builder.append(_nullPointer_3, "\t"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("next__et = "); - _builder.append(opScopePriv, "\t"); - _builder.append("enterHistory("); - String _selfPointer_4 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_4, "\t"); - _builder.append("next__et"); - { - if (usesHdlr) { - _builder.append(", "); - String _booleanConstant_4 = this.langExt.booleanConstant(false); - _builder.append(_booleanConstant_4, "\t"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("setState("); - String _selfPointer_5 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_5, "\t"); - _builder.append("next__et);"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("void "); - _builder.append(opScope); - _builder.append("executeInitTransition("); - _builder.append(selfOnly); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("/* receiveEvent contains the main implementation of the FSM */"); - _builder.newLine(); - { - if (generateImplementation) { - _builder.append(publicIf); - _builder.append("void "); - _builder.append(opScope); - _builder.append("receiveEventInternal("); - String _selfPointer_6 = this.langExt.selfPointer(this.getClassName(mc), handleEvents); - _builder.append(_selfPointer_6); - { - if (handleEvents) { - _builder.append(ifItemPtr); - _builder.append(" ifitem, int localId, int evt, "); - String _voidPointer_2 = this.langExt.voidPointer(); - _builder.append(_voidPointer_2); - _builder.append(" generic_data__et"); - } - } - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - { - if (async) { - _builder.append("\t"); - _builder.append("int trigger__et = (ifitem=="); - String _nullPointer_4 = this.langExt.nullPointer(); - _builder.append(_nullPointer_4, "\t"); - _builder.append(")? POLLING : localId + EVT_SHIFT*evt;"); - _builder.newLineIfNotEmpty(); - } else { - if (eventDriven) { - _builder.append("\t"); - _builder.append("int trigger__et = localId + EVT_SHIFT*evt;"); - _builder.newLine(); - } - } - } - _builder.append("\t"); - _builder.append("int chain__et = NOT_CAUGHT;"); - _builder.newLine(); - _builder.append("\t"); - String _stateType_12 = this.stateType(); - _builder.append(_stateType_12, "\t"); - _builder.append(" catching_state__et = NO_STATE;"); - _builder.newLineIfNotEmpty(); - { - if (usesHdlr) { - _builder.append("\t"); - String _boolType_5 = this.boolType(); - _builder.append(_boolType_5, "\t"); - _builder.append(" is_handler__et = "); - String _booleanConstant_5 = this.langExt.booleanConstant(false); - _builder.append(_booleanConstant_5, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - { - if ((async || eventDriven)) { - _builder.append("\t"); - CharSequence _markVariableUsed = this.markVariableUsed("trigger__et"); - _builder.append(_markVariableUsed, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - if (handleEvents) { - _builder.append("\t"); - _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data__et)) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genStateSwitch = this.genStateSwitch(gc, usesHdlr); - _builder.append(_genStateSwitch, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t"); - CharSequence _genStateSwitch_1 = this.genStateSwitch(gc, usesHdlr); - _builder.append(_genStateSwitch_1, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("if (chain__et != NOT_CAUGHT) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append(opScopePriv, "\t\t"); - _builder.append("exitTo("); - String _selfPointer_7 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_7, "\t\t"); - _builder.append("getState("); - String _selfPointer_8 = this.langExt.selfPointer(false); - _builder.append(_selfPointer_8, "\t\t"); - _builder.append("), catching_state__et"); - { - if (usesHdlr) { - _builder.append(", is_handler__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t\t"); - String _stateType_13 = this.stateType(); - _builder.append(_stateType_13, "\t\t\t"); - _builder.append(" next__et = "); - _builder.append(opScopePriv, "\t\t\t"); - _builder.append("executeTransitionChain("); - String _selfPointer_9 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_9, "\t\t\t"); - _builder.append("chain__et"); - { - if (handleEvents) { - _builder.append(", ifitem, generic_data__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("next__et = "); - _builder.append(opScopePriv, "\t\t\t"); - _builder.append("enterHistory("); - String _selfPointer_10 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_10, "\t\t\t"); - _builder.append("next__et"); - { - if (usesHdlr) { - _builder.append(", is_handler__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("setState("); - String _selfPointer_11 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_11, "\t\t\t"); - _builder.append("next__et);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - CharSequence _finalAction = this.finalAction(); - _builder.append(_finalAction, "\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("void "); - _builder.append(opScope); - _builder.append("receiveEventInternal("); - String _selfPointer_12 = this.langExt.selfPointer(this.getClassName(mc), handleEvents); - _builder.append(_selfPointer_12); - { - if (handleEvents) { - _builder.append(ifItemPtr); - _builder.append(" ifitem, int localId, int evt, "); - String _voidPointer_3 = this.langExt.voidPointer(); - _builder.append(_voidPointer_3); - _builder.append(" generic_data__et"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - { - if (handleEvents) { - { - if (generateImplementation) { - _builder.append(publicIf); - _builder.append("void "); - _builder.append(opScope); - _builder.append("receiveEvent("); - String _selfPointer_13 = this.langExt.selfPointer(this.getClassName(mc), true); - _builder.append(_selfPointer_13); - _builder.append(ifItemPtr); - _builder.append(" ifitem, int evt, "); - String _voidPointer_4 = this.langExt.voidPointer(); - _builder.append(_voidPointer_4); - _builder.append(" generic_data__et) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("int localId = (ifitem=="); - String _nullPointer_5 = this.langExt.nullPointer(); - _builder.append(_nullPointer_5, "\t"); - _builder.append(")? 0 : ifitem"); - _builder.append(getLocalId, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append(opScope, "\t"); - _builder.append("receiveEventInternal("); - String _selfPointer_14 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_14, "\t"); - _builder.append("ifitem, localId, evt, generic_data__et);"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("void "); - _builder.append(opScope); - _builder.append("receiveEvent("); - String _selfPointer_15 = this.langExt.selfPointer(true); - _builder.append(_selfPointer_15); - _builder.append(ifItemPtr); - _builder.append(" ifitem, int evt, "); - String _voidPointer_5 = this.langExt.voidPointer(); - _builder.append(_voidPointer_5); - _builder.append(" generic_data__et);"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - /** - * generate the do code calls for a given state - * - * @param state the {@link State} - * @return the generated code - */ - public String genDoCodes(final State state) { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _hasDoCode = this._fSMHelpers.hasDoCode(state, true); - if (_hasDoCode) { - String _doCodeOperationName = this._codegenHelpers.getDoCodeOperationName(state); - _builder.append(_doCodeOperationName); - _builder.append("("); - String _selfPointer = this.langExt.selfPointer(false); - _builder.append(_selfPointer); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - { - EObject _eContainer = state.eContainer().eContainer(); - if ((_eContainer instanceof State)) { - EObject _eContainer_1 = state.eContainer().eContainer(); - String _genDoCodes = this.genDoCodes(((State) _eContainer_1)); - _builder.append(_genDoCodes); - _builder.newLineIfNotEmpty(); - } - } - return _builder.toString(); - } - - /** - * helper method which generates the state switch. - * Asynchronous, data driven and event driven state machines are distinguished - * - * @param gc the {@link GraphContainer} - * @param usesHdlr if the state machine uses no handler {@link TransitionPoint}s - * at all then unused variables can be avoided by passing <code>true</code> - * @return the generated code - */ - public CharSequence genStateSwitch(final GraphContainer gc, final boolean usesHdlr) { - CharSequence _xblockexpression = null; - { - ComponentCommunicationType _commType = gc.getComponent().getCommType(); - boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS); - ComponentCommunicationType _commType_1 = gc.getComponent().getCommType(); - boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN); - ComponentCommunicationType _commType_2 = gc.getComponent().getCommType(); - boolean dataDriven = Objects.equal(_commType_2, ComponentCommunicationType.DATA_DRIVEN); - final Function1<Node, Boolean> _function = (Node it) -> { - return Boolean.valueOf(FsmGenExtensions.isLeaf(it)); - }; - final Function1<Node, String> _function_1 = (Node it) -> { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return this._codegenHelpers.getGenStateId(((State) _stateGraphNode)); - }; - final List<Node> allLeafStateNodes = IterableExtensions.<Node, String>sortBy(IteratorExtensions.<Node>toList(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(gc.getGraph()), _function)), _function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch (getState("); - String _selfPointer = this.langExt.selfPointer(false); - _builder.append(_selfPointer); - _builder.append(")) {"); - _builder.newLineIfNotEmpty(); - { - for(final Node stateNode : allLeafStateNodes) { - _builder.append("\t"); - StateGraphNode _stateGraphNode = stateNode.getStateGraphNode(); - final State state = ((State) _stateGraphNode); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("case "); - String _genStateId = this._codegenHelpers.getGenStateId(state); - _builder.append(_genStateId, "\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - final EList<CommonTrigger> caughtTriggers = stateNode.getCaughtTriggers(); - _builder.newLineIfNotEmpty(); - { - if (async) { - { - boolean _isEmpty = caughtTriggers.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("switch(trigger__et) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("case POLLING:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - CharSequence _genDataDrivenTriggers = this.genDataDrivenTriggers(gc, stateNode, usesHdlr); - _builder.append(_genDataDrivenTriggers, "\t\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genEventDrivenTriggers = this.genEventDrivenTriggers(gc, stateNode, usesHdlr); - _builder.append(_genEventDrivenTriggers, "\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genDataDrivenTriggers_1 = this.genDataDrivenTriggers(gc, stateNode, usesHdlr); - _builder.append(_genDataDrivenTriggers_1, "\t\t"); - _builder.newLineIfNotEmpty(); - } - } - } else { - if (dataDriven) { - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genDataDrivenTriggers_2 = this.genDataDrivenTriggers(gc, stateNode, usesHdlr); - _builder.append(_genDataDrivenTriggers_2, "\t\t"); - _builder.newLineIfNotEmpty(); - } else { - if (eventDriven) { - { - boolean _isEmpty_1 = caughtTriggers.isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("switch(trigger__et) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genEventDrivenTriggers_1 = this.genEventDrivenTriggers(gc, stateNode, usesHdlr); - _builder.append(_genEventDrivenTriggers_1, "\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - } - } - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("/* should not occur */"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("break;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - /** - * helper method which generates the data driven triggers - * - * @param gc the {@link GraphContainer} - * @param state the {@link State} for which the trigger if-else switch should be generated - * @param usesHdlr if the state machine uses no handler {@link TransitionPoints} - * at all then unused variables can be avoided by passing <code>true</code> - * @return the generated code - */ - public CharSequence genDataDrivenTriggers(final GraphContainer gc, final Node stateNode, final boolean usesHdlr) { - CharSequence _xblockexpression = null; - { - String _xifexpression = null; - boolean _usesInheritance = this.langExt.usesInheritance(); - if (_usesInheritance) { - String _className = this.getClassName(gc); - String _scopeSeparator = this.langExt.scopeSeparator(); - _xifexpression = (_className + _scopeSeparator); - } else { - _xifexpression = ""; - } - final String chainIDScope = _xifexpression; - StateGraphNode _stateGraphNode = stateNode.getStateGraphNode(); - final State state = ((State) _stateGraphNode); - StringConcatenation _builder = new StringConcatenation(); - String _genDoCodes = this.genDoCodes(state); - _builder.append(_genDoCodes); - _builder.newLineIfNotEmpty(); - final Function1<Link, Boolean> _function = (Link it) -> { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof GuardedTransition)); - }; - Iterable<Link> links = IterableExtensions.<Link>filter(FsmGenExtensions.getOutgoingLinksHierarchically(stateNode), _function); - _builder.newLineIfNotEmpty(); - { - for(final Link l : links) { - _builder.append("if ("); - String _genGuardedTransitionGuard = this.genGuardedTransitionGuard(l, "", gc); - _builder.append(_genGuardedTransitionGuard); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("chain__et = "); - _builder.append(chainIDScope, "\t"); - String _genChainId = this._codegenHelpers.getGenChainId(l.getTransition()); - _builder.append(_genChainId, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("catching_state__et = "); - String _genStateId = this._codegenHelpers.getGenStateId(this._fSMHelpers.getSuperState(l.getTransition())); - _builder.append(_genStateId, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - { - if ((FsmGenExtensions.isHandler(l) && usesHdlr)) { - _builder.append("\t"); - _builder.append("is_handler__et = TRUE;"); - _builder.newLine(); - } - } - _builder.append("}"); - _builder.newLine(); - { - Link _last = IterableExtensions.<Link>last(links); - boolean _notEquals = (!Objects.equal(l, _last)); - if (_notEquals) { - _builder.append("else"); - _builder.newLine(); - } - } - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - /** - * helper method which generates the event driven triggers - * - * @param gc the {@link GraphContainer} - * @param state the {@link State} for which the trigger switch should be generated - * @param usesHdlr if the state machine uses no handler {@link TransitionPoints} - * at all then unused variables can be avoided by passing <code>true</code> - * @return the generated code - */ - public CharSequence genEventDrivenTriggers(final GraphContainer gc, final Node stateNode, final boolean usesHdlr) { - CharSequence _xblockexpression = null; - { - EList<CommonTrigger> _caughtTriggers = stateNode.getCaughtTriggers(); - final Function1<CommonTrigger, String> _function = (CommonTrigger it) -> { - return this.getTriggerCodeName(it); - }; - final List<CommonTrigger> caughtTriggers = IterableExtensions.<CommonTrigger, String>sortBy(new ArrayList<CommonTrigger>(_caughtTriggers), _function); - String _xifexpression = null; - boolean _usesInheritance = this.langExt.usesInheritance(); - if (_usesInheritance) { - String _className = this.getClassName(gc); - String _scopeSeparator = this.langExt.scopeSeparator(); - _xifexpression = (_className + _scopeSeparator); - } else { - _xifexpression = ""; - } - final String chainIDScope = _xifexpression; - StringConcatenation _builder = new StringConcatenation(); - { - for(final CommonTrigger ct : caughtTriggers) { - _builder.append("case "); - String _triggerCodeName = this.getTriggerCodeName(ct); - _builder.append(_triggerCodeName); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - boolean needData = ct.isHasGuard(); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - { - if (needData) { - _builder.append("{ "); - String _typedDataDefinition = this.langExt.getTypedDataDefinition(ct.getMsg()); - _builder.append(_typedDataDefinition, "\t"); - } - } - _builder.newLineIfNotEmpty(); - { - EList<Link> _links = ct.getLinks(); - boolean _hasElements = false; - for(final Link link : _links) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(" else ", "\t"); - } - _builder.append("\t"); - String _genTriggeredTransitionGuard = this.genTriggeredTransitionGuard(link, ct.getTrigger(), gc); - _builder.append(_genTriggeredTransitionGuard, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("chain__et = "); - _builder.append(chainIDScope, "\t\t"); - String _genChainId = this._codegenHelpers.getGenChainId(link.getTransition()); - _builder.append(_genChainId, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("catching_state__et = "); - String _genStateId = this._codegenHelpers.getGenStateId(this._fSMHelpers.getSuperState(link.getTransition())); - _builder.append(_genStateId, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - { - if ((FsmGenExtensions.isHandler(link) && usesHdlr)) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("is_handler__et = "); - String _booleanConstant = this.langExt.booleanConstant(true); - _builder.append(_booleanConstant, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t"); - { - if (needData) { - _builder.append("}"); - } - } - _builder.newLineIfNotEmpty(); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("/* should not occur */"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - public String getClassName(final GraphContainer gc) { - return this.getClassName(gc.getComponent()); - } - - public String getClassName(final ModelComponent mc) { - return mc.getComponentName(); - } - - public String getTriggerCodeName(final CommonTrigger tr) { - final String[] parts = tr.getTrigger().split(TriggerExtensions.TRIGGER_SEP); - String _get = parts[0]; - String _plus = ("TRIG_" + _get); - String _plus_1 = (_plus + "__"); - String _get_1 = parts[1]; - return (_plus_1 + _get_1); - } - - /** - * getter for history array - * - * @param state the ID of the history state - * @return the generated code - */ - public String getHistory(final String state) { - String _memberAccess = this.langExt.memberAccess(); - String _plus = (_memberAccess + "history["); - String _plus_1 = (_plus + state); - return (_plus_1 + "]"); - } - - /** - * setter for history array - * - * @param state the ID of the state whose history should be set - * @param historyState the ID of the state that should be assigned - * @return the generated code - */ - public String setHistory(final String state, final String historyState) { - String _memberAccess = this.langExt.memberAccess(); - String _plus = (_memberAccess + "history["); - String _plus_1 = (_plus + state); - String _plus_2 = (_plus_1 + "] = "); - return (_plus_2 + historyState); - } - - /** - * @return the type of (temporary) state variables (defaults to "int") - * and has to be signed - */ - public String stateType() { - return "int"; - } - - /** - * allow target language dependent generation of unreachable return in generated enterHistory method. - * The default is just a comment. - * @return the generated code - */ - public String unreachableReturn() { - return "/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"; - } - - /** - * type of (temporary) boolean variables (defaults to "boolean") - * @return the generated code - */ - public String boolType() { - return "boolean"; - } - - /** - * empty, but may be overridden - */ - public CharSequence finalAction() { - StringConcatenation _builder = new StringConcatenation(); - return _builder; - } - - /** - * the type of the interface item passed into the receiveEvent() method - */ - public String interfaceItemType() { - return "InterfaceItemBase"; - } - - /** - * empty, but may be overridden - */ - public CharSequence markVariableUsed(final String varname) { - StringConcatenation _builder = new StringConcatenation(); - return _builder; - } - - /** - * helper method to determine whether this state machine uses handler transitions - * points at all - * - * @param xpax the {@link GraphContainer} - * @return <code>true</code> if the state machine uses handler transition points - */ - public boolean usesHandlerTrPoints(final GraphContainer gc) { - final Function1<Node, Boolean> _function = (Node t) -> { - StateGraphNode _stateGraphNode = t.getStateGraphNode(); - return Boolean.valueOf(((TransitionPoint) _stateGraphNode).isHandler()); - }; - boolean _isEmpty = IteratorExtensions.isEmpty(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllTransitionPointNodes(gc.getGraph()), _function)); - return (!_isEmpty); - } - - public abstract String genTriggeredTransitionGuard(final Link link, final String trigger, final GraphContainer mc); - - public abstract String genGuardedTransitionGuard(final Link link, final String trigger, final GraphContainer mc); - - public abstract String genActionCodeMethod(final GraphContainer gc, final Link link, final boolean generateImplementation); - - public abstract String genActionCodeMethods(final GraphContainer gc, final Node node, final boolean generateImplementation); -} diff --git a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java deleted file mode 100644 index c4befecfc..000000000 --- a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) 2014 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.fsm.generic; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.CPBranchTransition; -import org.eclipse.etrice.core.fsm.fSM.DetailCode; -import org.eclipse.etrice.core.fsm.fSM.Guard; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.util.FSMHelpers; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -/** - * @author Henrik Rentz-Reichert - */ -@SuppressWarnings("all") -public class FSMExtensions { - @Inject - @Extension - protected FSMHelpers _fSMHelpers; - - /** - * the template type is T - * @param l an iterable of type T - * @param e a single element of type T - * @return the union of the iterable and the element as new list - */ - public <T extends Object> List<T> union(final Iterable<T> l, final T e) { - ArrayList<T> ret = new ArrayList<T>(); - Iterables.<T>addAll(ret, l); - ret.add(e); - return ret; - } - - /** - * the template type is T - * @param l1 an iterable of type T - * @param l2 a second iterable of type T - * @return the union of the two iterables as new list - */ - public <T extends Object> List<T> union(final Iterable<T> l1, final Iterable<T> l2) { - ArrayList<T> ret = new ArrayList<T>(); - Iterables.<T>addAll(ret, l1); - Iterables.<T>addAll(ret, l2); - return ret; - } - - /** - * the template type is T - * @param l1 a list of elements of type T - * @param l2 a second list of elements of type T - * @return a new list with the contents of l1 - */ - public <T extends Object> List<T> minus(final List<T> l1, final List<T> l2) { - ArrayList<T> ret = new ArrayList<T>(l1); - ret.removeAll(l2); - return ret; - } - - /** - * @param states a list of {@link State}s - * @return a list ordered such that leaf states are last - */ - public Iterable<State> getLeafStatesLast(final List<State> states) { - Iterable<State> _xblockexpression = null; - { - final Function1<State, Boolean> _function = (State s) -> { - return Boolean.valueOf(this._fSMHelpers.isLeaf(s)); - }; - final Iterable<State> leaf = IterableExtensions.<State>filter(states, _function); - final Function1<State, Boolean> _function_1 = (State s) -> { - boolean _isLeaf = this._fSMHelpers.isLeaf(s); - return Boolean.valueOf((!_isLeaf)); - }; - final Iterable<State> nonLeaf = IterableExtensions.<State>filter(states, _function_1); - _xblockexpression = Iterables.<State>concat(nonLeaf, leaf); - } - return _xblockexpression; - } - - /** - * @param ac an {@link ActorClass} - * @return a list of all leaf states - */ - public List<State> getAllLeafStates(final ModelComponent mc) { - return this._fSMHelpers.getLeafStateList(mc.getStateMachine()); - } - - /** - * @param ac an {@link ActorClass} - * @return a list of simple states with leaf states last - */ - public List<State> getAllBaseStatesLeavesLast(final ModelComponent mc) { - return IterableExtensions.<State>toList(this.getLeafStatesLast(this._fSMHelpers.getAllBaseStates(mc))); - } - - /** - * @param ac an {@link ModelComponent} - * @return the number of all inherited states - */ - public int getNumberOfInheritedStates(final ModelComponent mc) { - ModelComponent _base = mc.getBase(); - boolean _equals = Objects.equal(_base, null); - if (_equals) { - return 0; - } else { - int _size = this._fSMHelpers.getStateList(mc.getBase().getStateMachine()).size(); - int _numberOfInheritedStates = this.getNumberOfInheritedStates(mc.getBase()); - return (_size + _numberOfInheritedStates); - } - } - - /** - * @param ac an {@link ModelComponent} - * @return the number of all inherited base (or simple) states - */ - public int getNumberOfInheritedBaseStates(final ModelComponent ac) { - ModelComponent _base = ac.getBase(); - boolean _equals = Objects.equal(_base, null); - if (_equals) { - return 0; - } else { - int _size = this._fSMHelpers.getBaseStateList(ac.getBase().getStateMachine()).size(); - int _numberOfInheritedBaseStates = this.getNumberOfInheritedBaseStates(ac.getBase()); - return (_size + _numberOfInheritedBaseStates); - } - } - - public boolean isConditionOrGuard(final DetailCode dc) { - boolean _xblockexpression = false; - { - final EObject parent = dc.eContainer(); - boolean _switchResult = false; - boolean _matched = false; - if (parent instanceof Guard) { - _matched=true; - _switchResult = true; - } - if (!_matched) { - if (parent instanceof CPBranchTransition) { - _matched=true; - DetailCode _condition = ((CPBranchTransition)parent).getCondition(); - _switchResult = Objects.equal(_condition, dc); - } - } - if (!_matched) { - _switchResult = false; - } - _xblockexpression = _switchResult; - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java deleted file mode 100644 index d7db6a750..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java +++ /dev/null @@ -1,222 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.HashMap; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.WiredStructureClass; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@Singleton -@SuppressWarnings("all") -public class ActorClassDataGen { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private FileSystemHelpers _fileSystemHelpers; - - @Inject - @Extension - private ProcedureHelpers _procedureHelpers; - - public void doGenerate(final Root root) { - final HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>(); - final Function1<WiredStructureClass, Boolean> _function = (WiredStructureClass w) -> { - return Boolean.valueOf((w instanceof WiredActorClass)); - }; - final Consumer<WiredStructureClass> _function_1 = (WiredStructureClass w) -> { - ac2wired.put(((WiredActorClass) w).getActorClass(), ((WiredActorClass) w)); - }; - IterableExtensions.<WiredStructureClass>filter(root.getWiredInstances(), _function).forEach(_function_1); - final Function1<ActorClass, Boolean> _function_2 = (ActorClass it) -> { - return Boolean.valueOf(this._fileSystemHelpers.isValidGenerationLocation(it)); - }; - final Function1<ActorClass, ExpandedActorClass> _function_3 = (ActorClass it) -> { - return root.getExpandedActorClass(it); - }; - Iterable<ExpandedActorClass> _map = IterableExtensions.<ActorClass, ExpandedActorClass>map(IterableExtensions.<ActorClass>filter(root.getActorClasses(), _function_2), _function_3); - for (final ExpandedActorClass xpac : _map) { - { - final WiredActorClass wired = ac2wired.get(xpac.getActorClass()); - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(xpac.getActorClass()); - String _path = this._roomExtensions.getPath(xpac.getActorClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(xpac.getActorClass()); - String _path_1 = this._roomExtensions.getPath(xpac.getActorClass()); - final String infopath = (_generationInfoPath + _path_1); - String _name = xpac.getActorClass().getName(); - String file = (_name + "_DataObject.java"); - this.fileIO.generateFile("generating ActorClass implementation", path, infopath, file, this.generate(root, xpac, wired)); - } - } - } - - public CharSequence generate(final Root root, final ExpandedActorClass xpac, final WiredActorClass wired) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - String _name = ac.getName(); - final String clsname = (_name + "_DataObject"); - final EList<RoomModel> models = root.getReferencedModels(ac); - String _xifexpression = null; - ModelComponent _base = ac.getBase(); - boolean _notEquals = (!Objects.equal(_base, null)); - if (_notEquals) { - String _name_1 = ac.getActorBase().getName(); - String _plus = ("extends " + _name_1); - _xifexpression = (_plus + "_DataObject "); - } else { - _xifexpression = ""; - } - final String baseClass = _xifexpression; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("package "); - String _package = this._roomExtensions.getPackage(ac); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IActorClassDataObject;"); - _builder.newLine(); - { - for(final RoomModel model : models) { - _builder.append("import "); - String _name_2 = model.getName(); - _builder.append(_name_2); - _builder.append(".*;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("public class "); - _builder.append(clsname); - _builder.append(" "); - _builder.append(baseClass); - _builder.append("implements IActorClassDataObject {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.newLine(); - { - boolean _hasNonEmptyStateMachine = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine) { - _builder.append("\t"); - _builder.append("// state and history"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("private int state;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("private int[] history;"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - } - } - _builder.append("\t"); - CharSequence _attributes = this._procedureHelpers.attributes(ac.getAttributes()); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.newLine(); - { - boolean _hasNonEmptyStateMachine_1 = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine_1) { - _builder.append("\t"); - _builder.append("public int getState() {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("return state;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void setState(int state) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("this.state = state;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public int[] getHistory() {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("return history;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void setHistory(int[] history) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("this.history = history;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - } - } - _builder.append("\t"); - CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(ac.getAttributes(), ac.getName()); - _builder.append(_attributeSettersGettersImplementation, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _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/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java deleted file mode 100644 index 257123985..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java +++ /dev/null @@ -1,1673 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.HashMap; -import java.util.List; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType; -import org.eclipse.etrice.core.genmodel.builder.GenmodelConstants; -import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.Wire; -import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.WiredStructureClass; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.InterfaceItem; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.ReferenceType; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.SAP; -import org.eclipse.etrice.core.room.ServiceImplementation; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.generator.base.IDataConfiguration; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.GenericActorClassGenerator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.etrice.generator.java.Main; -import org.eclipse.etrice.generator.java.gen.ConfigGenAddon; -import org.eclipse.etrice.generator.java.gen.Initialization; -import org.eclipse.etrice.generator.java.gen.JavaExtensions; -import org.eclipse.etrice.generator.java.gen.StateMachineGen; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.StringExtensions; - -@Singleton -@SuppressWarnings("all") -public class ActorClassGen extends GenericActorClassGenerator { - @Inject - protected IGeneratorFileIo fileIO; - - @Inject - @Extension - protected JavaExtensions _javaExtensions; - - @Inject - @Extension - protected RoomExtensions _roomExtensions; - - @Inject - protected IDataConfiguration dataConfigExt; - - protected final ConfigGenAddon configGenAddon; - - @Inject - @Extension - protected ProcedureHelpers _procedureHelpers; - - @Inject - @Extension - protected Initialization _initialization; - - @Inject - @Extension - protected StateMachineGen _stateMachineGen; - - @Inject - @Extension - protected TypeHelpers _typeHelpers; - - @Inject - @Extension - protected FileSystemHelpers _fileSystemHelpers; - - @Inject - public ActorClassGen(final ConfigGenAddon configGenAddon) { - this.configGenAddon = configGenAddon; - } - - public void doGenerate(final Root root) { - final HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>(); - final Function1<WiredStructureClass, Boolean> _function = (WiredStructureClass w) -> { - return Boolean.valueOf((w instanceof WiredActorClass)); - }; - final Consumer<WiredStructureClass> _function_1 = (WiredStructureClass w) -> { - ac2wired.put(((WiredActorClass) w).getActorClass(), ((WiredActorClass) w)); - }; - IterableExtensions.<WiredStructureClass>filter(root.getWiredInstances(), _function).forEach(_function_1); - final Function1<ActorClass, Boolean> _function_2 = (ActorClass it) -> { - return Boolean.valueOf(this._fileSystemHelpers.isValidGenerationLocation(it)); - }; - final Function1<ActorClass, ExpandedActorClass> _function_3 = (ActorClass it) -> { - return root.getExpandedActorClass(it); - }; - Iterable<ExpandedActorClass> _map = IterableExtensions.<ActorClass, ExpandedActorClass>map(IterableExtensions.<ActorClass>filter(root.getActorClasses(), _function_2), _function_3); - for (final ExpandedActorClass xpac : _map) { - { - final WiredActorClass wired = ac2wired.get(xpac.getActorClass()); - final boolean manualBehavior = this._roomHelpers.isBehaviorAnnotationPresent(xpac.getActorClass(), "BehaviorManual"); - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(xpac.getActorClass()); - String _path = this._roomExtensions.getPath(xpac.getActorClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(xpac.getActorClass()); - String _path_1 = this._roomExtensions.getPath(xpac.getActorClass()); - final String infopath = (_generationInfoPath + _path_1); - String file = this._javaExtensions.getJavaFileName(xpac.getActorClass()); - if (manualBehavior) { - file = ("Abstract" + file); - } - this.fileIO.generateFile("generating ActorClass implementation", path, infopath, file, this.generate(root, xpac, wired, manualBehavior)); - } - } - } - - public CharSequence generate(final Root root, final ExpandedActorClass xpac, final WiredActorClass wired, final boolean manualBehavior) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - String _xifexpression = null; - if (manualBehavior) { - String _name = ac.getName(); - _xifexpression = ("Abstract" + _name); - } else { - _xifexpression = ac.getName(); - } - final String clsname = _xifexpression; - final EList<RoomModel> models = root.getReferencedModels(ac); - String _xifexpression_1 = null; - boolean _isGeneratePersistenceInterface = Main.getSettings().isGeneratePersistenceInterface(); - if (_isGeneratePersistenceInterface) { - _xifexpression_1 = "implements IPersistable "; - } else { - _xifexpression_1 = ""; - } - final String impPersist = _xifexpression_1; - String _name_1 = ac.getName(); - final String dataObjClass = (_name_1 + "_DataObject"); - String _xifexpression_2 = null; - ActorClass _actorBase = ac.getActorBase(); - boolean _notEquals = (!Objects.equal(_actorBase, null)); - if (_notEquals) { - _xifexpression_2 = ac.getActorBase().getName(); - } else { - String _xifexpression_3 = null; - boolean _isEmpty = this._roomHelpers.getAttribute(ac, "ActorBaseClass", "class").isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - _xifexpression_3 = this._roomHelpers.getAttribute(ac, "ActorBaseClass", "class"); - } else { - String _xifexpression_4 = null; - boolean _isGenerateStoreDataObj = Main.getSettings().isGenerateStoreDataObj(); - if (_isGenerateStoreDataObj) { - _xifexpression_4 = "ActorClassFinalActionBase"; - } else { - _xifexpression_4 = "ActorClassBase"; - } - _xifexpression_3 = _xifexpression_4; - } - _xifexpression_2 = _xifexpression_3; - } - final String baseClass = _xifexpression_2; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("package "); - String _package = this._roomExtensions.getPackage(ac); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - boolean _isEmpty_1 = this.dataConfigExt.getDynConfigReadAttributes(ac).isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - _builder.append("import org.eclipse.etrice.runtime.java.config.DynConfigLock;"); - _builder.newLine(); - } - } - { - boolean _isGeneratePersistenceInterface_1 = Main.getSettings().isGeneratePersistenceInterface(); - if (_isGeneratePersistenceInterface_1) { - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IPersistable;"); - _builder.newLine(); - _builder.append("import java.io.IOException;"); - _builder.newLine(); - _builder.append("import java.io.ObjectInput;"); - _builder.newLine(); - _builder.append("import java.io.ObjectOutput;"); - _builder.newLine(); - } - } - { - boolean _isGenerateStoreDataObj_1 = Main.getSettings().isGenerateStoreDataObj(); - if (_isGenerateStoreDataObj_1) { - _builder.append("import java.util.Arrays;"); - _builder.newLine(); - } - } - _builder.append("import org.eclipse.etrice.runtime.java.messaging.*;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.debugging.*;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;"); - _builder.newLine(); - _builder.newLine(); - { - for(final RoomModel model : models) { - _builder.append("import "); - String _name_2 = model.getName(); - _builder.append(_name_2); - _builder.append(".*;"); - _builder.newLineIfNotEmpty(); - } - } - { - EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac); - for(final ProtocolClass pc : _referencedProtocolClasses) { - _builder.append("import "); - String _package_1 = this._roomExtensions.getPackage(pc); - _builder.append(_package_1); - _builder.append("."); - String _name_3 = pc.getName(); - _builder.append(_name_3); - _builder.append(".*;"); - _builder.newLineIfNotEmpty(); - } - } - { - final Function1<ActorRef, Boolean> _function = (ActorRef r) -> { - ReferenceType _refType = r.getRefType(); - return Boolean.valueOf(Objects.equal(_refType, ReferenceType.OPTIONAL)); - }; - Iterable<ActorRef> _filter = IterableExtensions.<ActorRef>filter(ac.getActorRefs(), _function); - for(final ActorRef sub : _filter) { - _builder.append("import "); - String _package_2 = this._roomExtensions.getPackage(sub.getType()); - _builder.append(_package_2); - _builder.append("."); - String _name_4 = sub.getType().getName(); - _builder.append(_name_4); - _builder.append("Interface;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(ac, 1, true); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.newLine(); - _builder.append("public "); - { - if ((manualBehavior || ac.isAbstract())) { - _builder.append("abstract "); - } - } - _builder.append("class "); - _builder.append(clsname); - _builder.append(" extends "); - _builder.append(baseClass); - _builder.append(" "); - _builder.append(impPersist); - _builder.append("{"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2, false); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- ports"); - _builder.newLine(); - { - List<Port> _endPorts = this._roomHelpers.getEndPorts(ac); - for(final Port ep : _endPorts) { - _builder.append("\t"); - _builder.append("protected "); - String _portClassName = this._roomExtensions.getPortClassName(ep); - _builder.append(_portClassName, "\t"); - _builder.append(" "); - String _name_5 = ep.getName(); - _builder.append(_name_5, "\t"); - _builder.append(" = null;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- saps"); - _builder.newLine(); - { - EList<SAP> _serviceAccessPoints = ac.getServiceAccessPoints(); - for(final SAP sap : _serviceAccessPoints) { - _builder.append("\t"); - _builder.append("protected "); - String _portClassName_1 = this._roomExtensions.getPortClassName(sap); - _builder.append(_portClassName_1, "\t"); - _builder.append(" "); - String _name_6 = sap.getName(); - _builder.append(_name_6, "\t"); - _builder.append(" = null;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- services"); - _builder.newLine(); - { - EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations(); - for(final ServiceImplementation svc : _serviceImplementations) { - _builder.append("\t"); - _builder.append("protected "); - String _portClassName_2 = this._roomExtensions.getPortClassName(svc); - _builder.append(_portClassName_2, "\t"); - _builder.append(" "); - String _name_7 = svc.getSpp().getName(); - _builder.append(_name_7, "\t"); - _builder.append(" = null;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- optional actors"); - _builder.newLine(); - { - final Function1<ActorRef, Boolean> _function_1 = (ActorRef r) -> { - ReferenceType _refType = r.getRefType(); - return Boolean.valueOf(Objects.equal(_refType, ReferenceType.OPTIONAL)); - }; - Iterable<ActorRef> _filter_1 = IterableExtensions.<ActorRef>filter(ac.getActorRefs(), _function_1); - for(final ActorRef sub_1 : _filter_1) { - _builder.append("\t"); - _builder.append("protected "); - String _name_8 = sub_1.getType().getName(); - _builder.append(_name_8, "\t"); - { - int _multiplicity = sub_1.getMultiplicity(); - boolean _notEquals_1 = (_multiplicity != 1); - if (_notEquals_1) { - _builder.append("Replicated"); - } - } - _builder.append("Interface "); - String _name_9 = sub_1.getName(); - _builder.append(_name_9, "\t"); - _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); - _builder.append(_genInterfaceItemConstants, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - String _genMinMaxConstants = this.configGenAddon.genMinMaxConstants(ac); - _builder.append(_genMinMaxConstants, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _attributes = this._procedureHelpers.attributes(ac.getAttributes()); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - { - List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac); - for(final Attribute a : _dynConfigReadAttributes) { - _builder.append("\t"); - _builder.append("private DynConfigLock lock_"); - String _name_10 = a.getName(); - _builder.append(_name_10, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac.getOperations(), ac.getName()); - _builder.append(_operationsImplementation, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- construction"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(clsname, "\t"); - _builder.append("(IRTObject parent, String name) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("super(parent, name);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("setClassName(\""); - String _name_11 = ac.getName(); - _builder.append(_name_11, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - CharSequence _attributeInitialization = this._initialization.attributeInitialization(ac.getAttributes(), ac, false); - _builder.append(_attributeInitialization, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// own ports"); - _builder.newLine(); - { - List<Port> _endPorts_1 = this._roomHelpers.getEndPorts(ac); - for(final Port ep_1 : _endPorts_1) { - _builder.append("\t\t"); - String _name_12 = ep_1.getName(); - _builder.append(_name_12, "\t\t"); - _builder.append(" = new "); - String _portClassName_3 = this._roomExtensions.getPortClassName(ep_1); - _builder.append(_portClassName_3, "\t\t"); - _builder.append("(this, \""); - String _name_13 = ep_1.getName(); - _builder.append(_name_13, "\t\t"); - _builder.append("\", "); - String _ifItemId = this.getIfItemId(ep_1); - _builder.append(_ifItemId, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// own saps"); - _builder.newLine(); - { - EList<SAP> _serviceAccessPoints_1 = ac.getServiceAccessPoints(); - for(final SAP sap_1 : _serviceAccessPoints_1) { - _builder.append("\t\t"); - String _name_14 = sap_1.getName(); - _builder.append(_name_14, "\t\t"); - _builder.append(" = new "); - String _portClassName_4 = this._roomExtensions.getPortClassName(sap_1); - _builder.append(_portClassName_4, "\t\t"); - _builder.append("(this, \""); - String _name_15 = sap_1.getName(); - _builder.append(_name_15, "\t\t"); - _builder.append("\", "); - String _ifItemId_1 = this.getIfItemId(sap_1); - _builder.append(_ifItemId_1, "\t\t"); - _builder.append(", 0);"); - _builder.newLineIfNotEmpty(); - } - } - _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"); - String _name_16 = svc_1.getSpp().getName(); - _builder.append(_name_16, "\t\t"); - _builder.append(" = new "); - String _portClassName_5 = this._roomExtensions.getPortClassName(svc_1); - _builder.append(_portClassName_5, "\t\t"); - _builder.append("(this, \""); - String _name_17 = svc_1.getSpp().getName(); - _builder.append(_name_17, "\t\t"); - _builder.append("\", "); - String _ifItemId_2 = this.getIfItemId(svc_1.getSpp()); - _builder.append(_ifItemId_2, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// sub actors"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs = ac.getActorRefs(); - for(final ActorRef sub_2 : _actorRefs) { - { - ReferenceType _refType = sub_2.getRefType(); - boolean _equals = Objects.equal(_refType, ReferenceType.OPTIONAL); - if (_equals) { - _builder.append("\t\t"); - String _name_18 = sub_2.getName(); - _builder.append(_name_18, "\t\t"); - _builder.append(" = new "); - String _name_19 = sub_2.getType().getName(); - _builder.append(_name_19, "\t\t"); - { - int _multiplicity_1 = sub_2.getMultiplicity(); - boolean _notEquals_2 = (_multiplicity_1 != 1); - if (_notEquals_2) { - _builder.append("Replicated"); - } - } - _builder.append("Interface(this, \""); - String _name_20 = sub_2.getName(); - _builder.append(_name_20, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } else { - int _multiplicity_2 = sub_2.getMultiplicity(); - boolean _greaterThan = (_multiplicity_2 > 1); - if (_greaterThan) { - _builder.append("\t\t"); - _builder.append("for (int i=0; i<"); - int _multiplicity_3 = sub_2.getMultiplicity(); - _builder.append(_multiplicity_3, "\t\t"); - _builder.append("; ++i) {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \""); - String _name_21 = sub_2.getName(); - _builder.append(_name_21, "\t\t\t"); - _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t"); - _builder.append("\"+i);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("new "); - String _name_22 = sub_2.getType().getName(); - _builder.append(_name_22, "\t\t\t"); - _builder.append("(this, \""); - String _name_23 = sub_2.getName(); - _builder.append(_name_23, "\t\t\t"); - _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t"); - _builder.append("\"+i);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - } else { - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t\t"); - _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \""); - String _name_24 = sub_2.getName(); - _builder.append(_name_24, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("new "); - String _name_25 = sub_2.getType().getName(); - _builder.append(_name_25, "\t\t"); - _builder.append("(this, \""); - String _name_26 = sub_2.getName(); - _builder.append(_name_26, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// wiring"); - _builder.newLine(); - { - EList<Wire> _wires = wired.getWires(); - for(final Wire wire : _wires) { - _builder.append("\t\t"); - String _xifexpression_5 = null; - boolean _isDataDriven = wire.isDataDriven(); - if (_isDataDriven) { - _xifexpression_5 = "DataPortBase"; - } else { - _xifexpression_5 = "InterfaceItemBase"; - } - _builder.append(_xifexpression_5, "\t\t"); - _builder.append(".connect(this, \""); - String _join = IterableExtensions.join(wire.getPath1(), "/"); - _builder.append(_join, "\t\t"); - _builder.append("\", \""); - String _join_1 = IterableExtensions.join(wire.getPath2(), "/"); - _builder.append(_join_1, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("\t\t"); - _builder.append("// activate polling for data-driven communication"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(getThread()).addPollingMessageReceiver(this);"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - String _userStructorBody = this._procedureHelpers.userStructorBody(ac, true); - _builder.append(_userStructorBody, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - if (((!this.dataConfigExt.getDynConfigReadAttributes(ac).isEmpty()) || (!this.dataConfigExt.getDynConfigWriteAttributes(ac).isEmpty()))) { - { - List<Attribute> _dynConfigReadAttributes_1 = this.dataConfigExt.getDynConfigReadAttributes(ac); - for(final Attribute a_1 : _dynConfigReadAttributes_1) { - _builder.append("\t\t"); - _builder.append("lock_"); - String _name_27 = a_1.getName(); - _builder.append(_name_27, "\t\t"); - _builder.append(" = new DynConfigLock();"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(this._roomExtensions.<Attribute>minus(ac.getAttributes(), this.dataConfigExt.getDynConfigReadAttributes(ac)), ac.getName()); - _builder.append(_attributeSettersGettersImplementation, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _genDynConfigGetterSetter = this.configGenAddon.genDynConfigGetterSetter(ac); - _builder.append(_genDynConfigGetterSetter, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- port getters"); - _builder.newLine(); - { - List<Port> _endPorts_2 = this._roomHelpers.getEndPorts(ac); - for(final Port ep_2 : _endPorts_2) { - _builder.append("\t"); - CharSequence _terImplementation = this._procedureHelpers.getterImplementation(this._roomExtensions.getPortClassName(ep_2), ep_2.getName(), ac.getName()); - _builder.append(_terImplementation, "\t"); - _builder.newLineIfNotEmpty(); - } - } - { - EList<SAP> _serviceAccessPoints_2 = ac.getServiceAccessPoints(); - for(final SAP sap_2 : _serviceAccessPoints_2) { - _builder.append("\t"); - CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(this._roomExtensions.getPortClassName(sap_2), sap_2.getName(), ac.getName()); - _builder.append(_terImplementation_1, "\t"); - _builder.newLineIfNotEmpty(); - } - } - { - EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations(); - for(final ServiceImplementation svc_2 : _serviceImplementations_2) { - _builder.append("\t"); - CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(this._roomExtensions.getPortClassName(svc_2), svc_2.getSpp().getName(), ac.getName()); - _builder.append(_terImplementation_2, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("//--------------------- lifecycle functions"); - _builder.newLine(); - { - boolean _overridesStop = this._roomExtensions.overridesStop(ac); - boolean _not_2 = (!_overridesStop); - if (_not_2) { - { - if (manualBehavior) { - _builder.append("\t"); - _builder.append("public abstract void stop();"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("public void stop(){"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("super.stop();"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - } - } - _builder.newLine(); - { - if (manualBehavior) { - _builder.append("\t"); - _builder.append("public abstract void destroy();"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("public void destroy(){"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - String _userStructorBody_1 = this._procedureHelpers.userStructorBody(ac, false); - _builder.append(_userStructorBody_1, "\t\t"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addMessageActorDestroy(this);"); - _builder.newLine(); - } - } - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(getThread()).removePollingMessageReceiver(this);"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("super.destroy();"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - { - if (manualBehavior) { - _builder.append("\t"); - _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {"); - _builder.newLine(); - { - List<InterfaceItem> _allInterfaceItems = this._roomHelpers.getAllInterfaceItems(ac); - boolean _hasElements = false; - for(final InterfaceItem ifitem : _allInterfaceItems) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate("else ", "\t\t"); - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("if (ifitem=="); - String _name_28 = ifitem.getName(); - _builder.append(_name_28, "\t\t"); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("switch (evt) {"); - _builder.newLine(); - { - List<Message> _incoming = this._roomHelpers.getIncoming(ifitem); - for(final Message msg : _incoming) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("case "); - String _name_29 = this._roomHelpers.getProtocolClass(msg).getName(); - _builder.append(_name_29, "\t\t\t\t"); - _builder.append("."); - String _xifexpression_6 = null; - boolean _isIncoming = this._roomExtensions.isIncoming(msg); - if (_isIncoming) { - _xifexpression_6 = "IN_"; - } else { - _xifexpression_6 = "OUT_"; - } - _builder.append(_xifexpression_6, "\t\t\t\t"); - String _name_30 = msg.getName(); - _builder.append(_name_30, "\t\t\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - { - VarDecl _data = msg.getData(); - boolean _notEquals_3 = (!Objects.equal(_data, null)); - if (_notEquals_3) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("{"); - String _typedDataDefinition = this._javaExtensions.getTypedDataDefinition(msg); - _builder.append(_typedDataDefinition, "\t\t\t\t\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("on_"); - String _name_31 = ifitem.getName(); - _builder.append(_name_31, "\t\t\t\t\t"); - _builder.append("_"); - String _name_32 = msg.getName(); - _builder.append(_name_32, "\t\t\t\t\t"); - _builder.append("(ifitem"); - { - VarDecl _data_1 = msg.getData(); - boolean _notEquals_4 = (!Objects.equal(_data_1, null)); - if (_notEquals_4) { - _builder.append(", "); - String _name_33 = msg.getData().getName(); - _builder.append(_name_33, "\t\t\t\t\t"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - { - VarDecl _data_2 = msg.getData(); - boolean _notEquals_5 = (!Objects.equal(_data_2, null)); - if (_notEquals_5) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - { - List<InterfaceItem> _allInterfaceItems_1 = this._roomHelpers.getAllInterfaceItems(ac); - for(final InterfaceItem ifitem_1 : _allInterfaceItems_1) { - { - List<Message> _incoming_1 = this._roomHelpers.getIncoming(ifitem_1); - for(final Message msg_1 : _incoming_1) { - _builder.append("\t"); - _builder.append("protected void on_"); - String _name_34 = ifitem_1.getName(); - _builder.append(_name_34, "\t"); - _builder.append("_"); - String _name_35 = msg_1.getName(); - _builder.append(_name_35, "\t"); - _builder.append("(InterfaceItemBase ifitem"); - { - VarDecl _data_3 = msg_1.getData(); - boolean _notEquals_6 = (!Objects.equal(_data_3, null)); - if (_notEquals_6) { - String _get = this._javaExtensions.generateArglistAndTypedData(msg_1.getData())[2]; - _builder.append(_get, "\t"); - } - } - _builder.append(") {}"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("public abstract void executeInitTransition();"); - _builder.newLine(); - } else { - { - boolean _hasNonEmptyStateMachine = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine) { - _builder.append("\t"); - CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac.getGraphContainer()); - _builder.append(_genStateMachine, "\t"); - _builder.newLineIfNotEmpty(); - { - ComponentCommunicationType _commType = ac.getCommType(); - boolean _equals_1 = Objects.equal(_commType, ComponentCommunicationType.DATA_DRIVEN); - if (_equals_1) { - _builder.append("\t"); - _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("handleSystemEvent(ifitem, evt, generic_data);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - { - if ((Objects.equal(ac.getCommType(), ComponentCommunicationType.ASYNCHRONOUS) || Objects.equal(ac.getCommType(), ComponentCommunicationType.DATA_DRIVEN))) { - _builder.append("\t"); - _builder.append("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void receive(Message msg) {"); - _builder.newLine(); - { - ComponentCommunicationType _commType_1 = ac.getCommType(); - boolean _equals_2 = Objects.equal(_commType_1, ComponentCommunicationType.ASYNCHRONOUS); - if (_equals_2) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("receiveEvent(null, -1, null);"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("receiveEventInternal();"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - } else { - boolean _isEmpty_2 = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - if (_isEmpty_2) { - _builder.append("\t"); - _builder.append("//--------------------- no state machine"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("handleSystemEvent(ifitem, evt, data);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void executeInitTransition() {}"); - _builder.newLine(); - } - } - } - } - } - _builder.newLine(); - { - boolean _isGeneratePersistenceInterface_2 = Main.getSettings().isGeneratePersistenceInterface(); - if (_isGeneratePersistenceInterface_2) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void saveObject(ObjectOutput output) throws IOException {"); - _builder.newLine(); - { - boolean _isEmpty_3 = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - boolean _not_3 = (!_isEmpty_3); - if (_not_3) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("// state and history"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("output.writeInt(getState());"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("for (int h: history) output.writeInt(h);"); - _builder.newLine(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("saveAttributes(output);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected void saveAttributes(ObjectOutput output) throws IOException {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genSaveImpl = this.genSaveImpl(xpac); - _builder.append(_genSaveImpl, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void loadObject(ObjectInput input) throws IOException, ClassNotFoundException {"); - _builder.newLine(); - { - boolean _isEmpty_4 = FsmGenExtensions.isEmpty(xpac.getGraphContainer().getGraph()); - boolean _not_4 = (!_isEmpty_4); - if (_not_4) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("// state and history"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("setState(input.readInt());"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("for (int i=0; i<history.length; ++i) history[i] = input.readInt();"); - _builder.newLine(); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("\t"); - _builder.append("loadAttributes(input);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected void loadAttributes(ObjectInput input) throws IOException, ClassNotFoundException {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - CharSequence _genLoadImpl = this.genLoadImpl(xpac); - _builder.append(_genLoadImpl, "\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - { - boolean _isGenerateStoreDataObj_2 = Main.getSettings().isGenerateStoreDataObj(); - if (_isGenerateStoreDataObj_2) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected void store(IActorClassDataObject obj) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("if (!(obj instanceof "); - _builder.append(dataObjClass, "\t\t"); - _builder.append("))"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("return;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(dataObjClass, "\t\t"); - _builder.append(" dataObject = ("); - _builder.append(dataObjClass, "\t\t"); - _builder.append(") obj;"); - _builder.newLineIfNotEmpty(); - { - ActorClass _actorBase_1 = ac.getActorBase(); - boolean _notEquals_7 = (!Objects.equal(_actorBase_1, null)); - if (_notEquals_7) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("super.store(dataObject);"); - _builder.newLine(); - } - } - { - boolean _hasNonEmptyStateMachine_1 = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine_1) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("dataObject.setState(getState());"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("dataObject.setHistory(Arrays.copyOf(history, history.length));"); - _builder.newLine(); - } - } - { - boolean _isEmpty_5 = ac.getAttributes().isEmpty(); - boolean _not_5 = (!_isEmpty_5); - if (_not_5) { - _builder.newLine(); - { - EList<Attribute> _attributes_1 = ac.getAttributes(); - for(final Attribute att : _attributes_1) { - { - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(att.getType().getType()); - if (_isEnumerationOrPrimitive) { - { - int _size = att.getSize(); - boolean _greaterThan_1 = (_size > 1); - if (_greaterThan_1) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("dataObject.set"); - String _firstUpper = StringExtensions.toFirstUpper(att.getName()); - _builder.append(_firstUpper, "\t\t"); - _builder.append("(Arrays.copyOf("); - String _name_36 = att.getName(); - _builder.append(_name_36, "\t\t"); - _builder.append(", "); - String _name_37 = att.getName(); - _builder.append(_name_37, "\t\t"); - _builder.append(".length));"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("dataObject.set"); - String _firstUpper_1 = StringExtensions.toFirstUpper(att.getName()); - _builder.append(_firstUpper_1, "\t\t"); - _builder.append("("); - String _name_38 = att.getName(); - _builder.append(_name_38, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } else { - { - int _size_1 = att.getSize(); - boolean _greaterThan_2 = (_size_1 > 1); - if (_greaterThan_2) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - String _name_39 = att.getType().getType().getName(); - _builder.append(_name_39, "\t\t\t"); - _builder.append("[] arr = Arrays.copyOf("); - String _name_40 = att.getName(); - _builder.append(_name_40, "\t\t\t"); - _builder.append(", "); - String _name_41 = att.getName(); - _builder.append(_name_41, "\t\t\t"); - _builder.append(".length);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("dataObject.set"); - String _firstUpper_2 = StringExtensions.toFirstUpper(att.getName()); - _builder.append(_firstUpper_2, "\t\t\t"); - _builder.append("(arr);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("dataObject.set"); - String _firstUpper_3 = StringExtensions.toFirstUpper(att.getName()); - _builder.append(_firstUpper_3, "\t\t"); - _builder.append("("); - String _name_42 = att.getName(); - _builder.append(_name_42, "\t\t"); - _builder.append(".deepCopy());"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected void restore(IActorClassDataObject obj) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("if (!(obj instanceof "); - _builder.append(dataObjClass, "\t\t"); - _builder.append("))"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("return;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(dataObjClass, "\t\t"); - _builder.append(" dataObject = ("); - _builder.append(dataObjClass, "\t\t"); - _builder.append(") obj;"); - _builder.newLineIfNotEmpty(); - { - ActorClass _actorBase_2 = ac.getActorBase(); - boolean _notEquals_8 = (!Objects.equal(_actorBase_2, null)); - if (_notEquals_8) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("super.restore(dataObject);"); - _builder.newLine(); - } - } - { - boolean _hasNonEmptyStateMachine_2 = this._roomHelpers.hasNonEmptyStateMachine(ac); - if (_hasNonEmptyStateMachine_2) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("setState(dataObject.getState());"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("history = Arrays.copyOf(dataObject.getHistory(), dataObject.getHistory().length);"); - _builder.newLine(); - } - } - { - boolean _isEmpty_6 = ac.getAttributes().isEmpty(); - boolean _not_6 = (!_isEmpty_6); - if (_not_6) { - _builder.newLine(); - { - EList<Attribute> _attributes_2 = ac.getAttributes(); - for(final Attribute att_1 : _attributes_2) { - { - boolean _isEnumerationOrPrimitive_1 = this._typeHelpers.isEnumerationOrPrimitive(att_1.getType().getType()); - if (_isEnumerationOrPrimitive_1) { - { - int _size_2 = att_1.getSize(); - boolean _greaterThan_3 = (_size_2 > 1); - if (_greaterThan_3) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("set"); - String _firstUpper_4 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_4, "\t\t"); - _builder.append("(Arrays.copyOf(dataObject.get"); - String _firstUpper_5 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_5, "\t\t"); - _builder.append("(), "); - String _name_43 = att_1.getName(); - _builder.append(_name_43, "\t\t"); - _builder.append(".length));"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("set"); - String _firstUpper_6 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_6, "\t\t"); - _builder.append("(dataObject.get"); - String _firstUpper_7 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_7, "\t\t"); - _builder.append("());"); - _builder.newLineIfNotEmpty(); - } - } - } else { - { - int _size_3 = att_1.getSize(); - boolean _greaterThan_4 = (_size_3 > 1); - if (_greaterThan_4) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - String _name_44 = att_1.getType().getType().getName(); - _builder.append(_name_44, "\t\t\t"); - _builder.append("[] arr = Arrays.copyOf(dataObject.get"); - String _firstUpper_8 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_8, "\t\t\t"); - _builder.append("(), "); - String _name_45 = att_1.getName(); - _builder.append(_name_45, "\t\t\t"); - _builder.append(".length);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("set"); - String _firstUpper_9 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_9, "\t\t\t"); - _builder.append("(arr);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("set"); - String _firstUpper_10 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_10, "\t\t"); - _builder.append("(dataObject.get"); - String _firstUpper_11 = StringExtensions.toFirstUpper(att_1.getName()); - _builder.append(_firstUpper_11, "\t\t"); - _builder.append("().deepCopy());"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected "); - _builder.append(dataObjClass, "\t"); - _builder.append(" newDataObject() {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("return new "); - _builder.append(dataObjClass, "\t\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("};"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genSaveImpl(final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - StringConcatenation _builder = new StringConcatenation(); - { - ActorClass _actorBase = ac.getActorBase(); - boolean _notEquals = (!Objects.equal(_actorBase, null)); - if (_notEquals) { - _builder.append("super.saveAttributes(output);"); - _builder.newLine(); - _builder.newLine(); - } - } - { - boolean _isEmpty = ac.getAttributes().isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - { - EList<Attribute> _attributes = ac.getAttributes(); - for(final Attribute att : _attributes) { - { - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(att.getType().getType()); - if (_isEnumerationOrPrimitive) { - String _genSavePrimitive = this.genSavePrimitive(att); - _builder.append(_genSavePrimitive); - _builder.newLineIfNotEmpty(); - } else { - { - int _size = att.getSize(); - boolean _greaterThan = (_size > 1); - if (_greaterThan) { - _builder.append("for ("); - String _name = att.getType().getType().getName(); - _builder.append(_name); - _builder.append(" v: "); - String _name_1 = att.getName(); - _builder.append(_name_1); - _builder.append(") output.writeObject(v);"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("output.writeObject("); - String _name_2 = att.getName(); - _builder.append(_name_2); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genLoadImpl(final ExpandedActorClass xpac) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = xpac.getActorClass(); - StringConcatenation _builder = new StringConcatenation(); - { - ActorClass _actorBase = ac.getActorBase(); - boolean _notEquals = (!Objects.equal(_actorBase, null)); - if (_notEquals) { - _builder.append("super.loadAttributes(input);"); - _builder.newLine(); - _builder.newLine(); - } - } - { - boolean _isEmpty = ac.getAttributes().isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - { - EList<Attribute> _attributes = ac.getAttributes(); - for(final Attribute att : _attributes) { - { - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(att.getType().getType()); - if (_isEnumerationOrPrimitive) { - String _genLoadPrimitive = this.genLoadPrimitive(att); - _builder.append(_genLoadPrimitive); - _builder.newLineIfNotEmpty(); - } else { - { - int _size = att.getSize(); - boolean _greaterThan = (_size > 1); - if (_greaterThan) { - _builder.append("for (int i=0; i< "); - String _name = att.getName(); - _builder.append(_name); - _builder.append(".length; ++i) "); - String _name_1 = att.getName(); - _builder.append(_name_1); - _builder.append("[i] = ("); - String _name_2 = att.getType().getType().getName(); - _builder.append(_name_2); - _builder.append(") input.readObject();"); - _builder.newLineIfNotEmpty(); - } else { - String _name_3 = att.getName(); - _builder.append(_name_3); - _builder.append(" = ("); - String _name_4 = att.getType().getType().getName(); - _builder.append(_name_4); - _builder.append(") input.readObject();"); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String genSavePrimitive(final Attribute att) { - String _xblockexpression = null; - { - String _xifexpression = null; - if (((att.getType().getType() instanceof EnumerationType) && Objects.equal(((EnumerationType) att.getType().getType()).getPrimitiveType(), null))) { - _xifexpression = "int"; - } else { - _xifexpression = this._typeHelpers.typeName(att.getType().getType()); - } - final String type = _xifexpression; - final String method = this.getSaveMethod(type); - String _xifexpression_1 = null; - int _size = att.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - String _name = att.getName(); - String _plus = ((("for (" + type) + " v: ") + _name); - String _plus_1 = (_plus + ") output."); - String _plus_2 = (_plus_1 + method); - _xifexpression_1 = (_plus_2 + "(v);"); - } else { - String _name_1 = att.getName(); - String _plus_3 = ((("output." + method) + "(") + _name_1); - _xifexpression_1 = (_plus_3 + ");"); - } - _xblockexpression = _xifexpression_1; - } - return _xblockexpression; - } - - private String getSaveMethod(final String type) { - String _switchResult = null; - if (type != null) { - switch (type) { - case "boolean": - _switchResult = "writeBoolean"; - break; - case "char": - _switchResult = "writeChar"; - break; - case "byte": - _switchResult = "writeByte"; - break; - case "short": - _switchResult = "writeShort"; - break; - case "int": - _switchResult = "write"; - break; - case "long": - _switchResult = "writeLong"; - break; - case "float": - _switchResult = "writeFloat"; - break; - case "double": - _switchResult = "writeDouble"; - break; - case "String": - _switchResult = "writeUTF"; - break; - } - } - return _switchResult; - } - - private String genLoadPrimitive(final Attribute att) { - String _xblockexpression = null; - { - String _xifexpression = null; - if (((att.getType().getType() instanceof EnumerationType) && Objects.equal(((EnumerationType) att.getType().getType()).getPrimitiveType(), null))) { - _xifexpression = "int"; - } else { - _xifexpression = this._typeHelpers.typeName(att.getType().getType()); - } - final String type = _xifexpression; - final String method = this.getLoadMethod(type); - String _xifexpression_1 = null; - int _size = att.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - String _name = att.getName(); - String _plus = ("for (int i=0; i<" + _name); - String _plus_1 = (_plus + ".length; ++i) "); - String _name_1 = att.getName(); - String _plus_2 = (_plus_1 + _name_1); - String _plus_3 = (_plus_2 + "[i] = input."); - String _plus_4 = (_plus_3 + method); - _xifexpression_1 = (_plus_4 + "();"); - } else { - String _name_2 = att.getName(); - String _plus_5 = (_name_2 + " = input."); - String _plus_6 = (_plus_5 + method); - _xifexpression_1 = (_plus_6 + "();"); - } - _xblockexpression = _xifexpression_1; - } - return _xblockexpression; - } - - private String getLoadMethod(final String type) { - String _switchResult = null; - if (type != null) { - switch (type) { - case "boolean": - _switchResult = "readBoolean"; - break; - case "char": - _switchResult = "readChar"; - break; - case "byte": - _switchResult = "readByte"; - break; - case "short": - _switchResult = "readShort"; - break; - case "int": - _switchResult = "read"; - break; - case "long": - _switchResult = "readLong"; - break; - case "float": - _switchResult = "readFloat"; - break; - case "double": - _switchResult = "readDouble"; - break; - case "String": - _switchResult = "readUTF"; - break; - } - } - return _switchResult; - } -} diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java deleted file mode 100644 index d9546d831..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java +++ /dev/null @@ -1,448 +0,0 @@ -/** - * Copyright (c) 2012 Juergen Haug - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Juergen Haug - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase; -import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.PrimitiveType; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.base.IDataConfiguration; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.etrice.generator.java.gen.Initialization; -import org.eclipse.etrice.generator.java.gen.JavaExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.StringExtensions; - -@SuppressWarnings("all") -public class ConfigGenAddon { - @Inject - @Extension - private JavaExtensions stdExt; - - @Inject - @Extension - private TypeHelpers typeHelpers; - - @Inject - @Extension - private ProcedureHelpers helpers; - - @Inject - private IDataConfiguration dataConfigExt; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - private Initialization initGen; - - public CharSequence genActorInstanceConfig(final ActorInstance ai, final String aiVariableName) { - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(ai.getActorClass()); - for(final Attribute a : _allAttributes) { - CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, aiVariableName, this._roomExtensions.<Attribute>union(new ArrayList<Attribute>(), a)); - _builder.append(_applyInstanceConfig); - _builder.newLineIfNotEmpty(); - } - } - { - EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances(); - for(final InterfaceItemInstance pi : _orderedIfItemInstances) { - PortClass _portClass = this._roomHelpers.getPortClass(pi.getInterfaceItem()); - EList<Attribute> _attributes = null; - if (_portClass!=null) { - _attributes=_portClass.getAttributes(); - } - EList<Attribute> attribs = _attributes; - _builder.newLineIfNotEmpty(); - { - boolean _notEquals = (!Objects.equal(attribs, null)); - if (_notEquals) { - { - for(final Attribute a_1 : attribs) { - CharSequence _invokeGetter = this.helpers.invokeGetter(pi.getName(), null); - String _plus = ((aiVariableName + ".") + _invokeGetter); - CharSequence _applyInstanceConfig_1 = this.applyInstanceConfig(pi, _plus, this._roomExtensions.<Attribute>union(new ArrayList<Attribute>(), a_1)); - _builder.append(_applyInstanceConfig_1); - _builder.newLineIfNotEmpty(); - } - } - } - } - } - } - return _builder; - } - - private CharSequence applyInstanceConfig(final InstanceBase instance, final String invokes, final List<Attribute> path) { - CharSequence _xblockexpression = null; - { - Attribute a = IterableExtensions.<Attribute>last(path); - DataType aType = a.getType().getType(); - CharSequence _switchResult = null; - boolean _matched = false; - if (aType instanceof PrimitiveType) { - _matched=true; - CharSequence _xblockexpression_1 = null; - { - String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance); - CharSequence _xifexpression = null; - boolean _notEquals = (!Objects.equal(value, null)); - if (_notEquals) { - _xifexpression = this.initGen.genAttributeInitializer(a, this.stdExt.toValueLiteral(((PrimitiveType)aType), value), invokes); - } - _xblockexpression_1 = _xifexpression; - } - _switchResult = _xblockexpression_1; - } - if (!_matched) { - if (aType instanceof EnumerationType) { - _matched=true; - CharSequence _xblockexpression_1 = null; - { - String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance); - CharSequence _xifexpression = null; - boolean _notEquals = (!Objects.equal(value, null)); - if (_notEquals) { - _xifexpression = this.initGen.genAttributeInitializer(a, value, invokes); - } - _xblockexpression_1 = _xifexpression; - } - _switchResult = _xblockexpression_1; - } - } - if (!_matched) { - if (aType instanceof DataClass) { - _matched=true; - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(((DataClass) aType)); - for(final Attribute e : _allAttributes) { - CharSequence _invokeGetter = this.helpers.invokeGetter(a.getName(), null); - String _plus = ((invokes + ".") + _invokeGetter); - CharSequence _applyInstanceConfig = this.applyInstanceConfig(instance, _plus, this._roomExtensions.<Attribute>union(path, e)); - _builder.append(_applyInstanceConfig); - _builder.newLineIfNotEmpty(); - } - } - _switchResult = _builder; - } - } - _xblockexpression = _switchResult; - } - return _xblockexpression; - } - - public CharSequence genDynConfigGetterSetter(final ActorClass ac) { - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac); - for(final Attribute a : _dynConfigReadAttributes) { - _builder.append("public "); - String _typeName = this.typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName); - { - int _size = a.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("[]"); - } - } - _builder.append(" get"); - String _firstUpper = StringExtensions.toFirstUpper(a.getName()); - _builder.append(_firstUpper); - _builder.append("(){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if(lock_"); - String _name = a.getName(); - _builder.append(_name, "\t"); - _builder.append(" == null)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("return "); - String _name_1 = a.getName(); - _builder.append(_name_1, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("synchronized(lock_"); - String _name_2 = a.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("return "); - String _name_3 = a.getName(); - _builder.append(_name_3, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("public void set"); - String _firstUpper_1 = StringExtensions.toFirstUpper(a.getName()); - _builder.append(_firstUpper_1); - _builder.append("("); - String _typeName_1 = this.typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName_1); - { - int _size_1 = a.getSize(); - boolean _greaterThan_1 = (_size_1 > 0); - if (_greaterThan_1) { - _builder.append("[]"); - } - } - _builder.append(" "); - String _name_4 = a.getName(); - _builder.append(_name_4); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if(lock_"); - String _name_5 = a.getName(); - _builder.append(_name_5, "\t"); - _builder.append(" == null)"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("this."); - String _name_6 = a.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append(" = "); - String _name_7 = a.getName(); - _builder.append(_name_7, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("synchronized(lock_"); - String _name_8 = a.getName(); - _builder.append(_name_8, "\t\t"); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("this."); - String _name_9 = a.getName(); - _builder.append(_name_9, "\t\t\t"); - _builder.append(" = "); - String _name_10 = a.getName(); - _builder.append(_name_10, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("public DynConfigLock get"); - String _firstUpper_2 = StringExtensions.toFirstUpper(a.getName()); - _builder.append(_firstUpper_2); - _builder.append("Lock(){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return lock_"); - String _name_11 = a.getName(); - _builder.append(_name_11, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("}\t"); - _builder.newLine(); - } - } - { - List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac); - for(final Attribute a_1 : _dynConfigWriteAttributes) { - _builder.append("public void setAndWrite"); - String _firstUpper_3 = StringExtensions.toFirstUpper(a_1.getName()); - _builder.append(_firstUpper_3); - _builder.append("("); - String _typeName_2 = this.typeHelpers.typeName(a_1.getType().getType()); - _builder.append(_typeName_2); - { - int _size_2 = a_1.getSize(); - boolean _greaterThan_2 = (_size_2 > 0); - if (_greaterThan_2) { - _builder.append("[]"); - } - } - _builder.append(" "); - String _name_12 = a_1.getName(); - _builder.append(_name_12); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("set"); - String _firstUpper_4 = StringExtensions.toFirstUpper(a_1.getName()); - _builder.append(_firstUpper_4, "\t\t"); - _builder.append("("); - String _name_13 = a_1.getName(); - _builder.append(_name_13, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("getVariableService().write(this.getInstancePath()+\"/"); - String _name_14 = a_1.getName(); - _builder.append(_name_14, "\t\t"); - _builder.append("\", "); - String _name_15 = a_1.getName(); - _builder.append(_name_15, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - return _builder; - } - - public String genMinMaxConstants(final ActorClass ac) { - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(ac); - for(final Attribute a : _allAttributes) { - CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, a.getName(), this._roomExtensions.<Attribute>union(new ArrayList<Attribute>(), a)); - _builder.append(_genMinMaxConstantsRec); - _builder.newLineIfNotEmpty(); - } - } - String result = _builder.toString(); - int _length = result.length(); - boolean _notEquals = (_length != 0); - if (_notEquals) { - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("//--------------------- Attribute Specifications"); - String _plus = (result + _builder_1); - result = _plus; - } - return result; - } - - private CharSequence genMinMaxConstantsRec(final ActorClass ac, final String varNamePath, final List<Attribute> path) { - CharSequence _xblockexpression = null; - { - DataType aType = IterableExtensions.<Attribute>last(path).getType().getType(); - CharSequence _switchResult = null; - boolean _matched = false; - if (aType instanceof DataClass) { - _matched=true; - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(((DataClass) aType)); - for(final Attribute e : _allAttributes) { - String _name = e.getName(); - String _plus = ((varNamePath + "_") + _name); - CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus, this._roomExtensions.<Attribute>union(path, e)); - _builder.append(_genMinMaxConstantsRec); - _builder.newLineIfNotEmpty(); - } - } - _switchResult = _builder; - } - if (!_matched) { - if (aType instanceof PrimitiveType) { - _matched=true; - CharSequence _xblockexpression_1 = null; - { - String temp = ((String) null); - StringConcatenation _builder = new StringConcatenation(); - { - boolean _notEquals = (!Objects.equal((temp = this.dataConfigExt.getAttrClassConfigMinValue(ac, path)), null)); - if (_notEquals) { - _builder.append("public static "); - String _minMaxType = this.getMinMaxType(((PrimitiveType)aType)); - _builder.append(_minMaxType); - _builder.append(" MIN_"); - _builder.append(varNamePath); - _builder.append(" = "); - String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType)aType), temp); - _builder.append(_valueLiteral); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - { - boolean _notEquals_1 = (!Objects.equal((temp = this.dataConfigExt.getAttrClassConfigMaxValue(ac, path)), null)); - if (_notEquals_1) { - _builder.append("public static "); - String _minMaxType_1 = this.getMinMaxType(((PrimitiveType)aType)); - _builder.append(_minMaxType_1); - _builder.append(" MAX_"); - _builder.append(varNamePath); - _builder.append(" = "); - String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType)aType), temp); - _builder.append(_valueLiteral_1); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression_1 = _builder; - } - _switchResult = _xblockexpression_1; - } - } - _xblockexpression = _switchResult; - } - return _xblockexpression; - } - - private String getMinMaxType(final PrimitiveType type) { - String _switchResult = null; - String _typeName = this.typeHelpers.typeName(type); - if (_typeName != null) { - switch (_typeName) { - case "byte": - _switchResult = "int"; - break; - case "short": - _switchResult = "int"; - break; - case "float": - _switchResult = "double"; - break; - default: - _switchResult = this.typeHelpers.typeName(type); - break; - } - } else { - _switchResult = this.typeHelpers.typeName(type); - } - return _switchResult; - } -} 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 658dea044..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java +++ /dev/null @@ -1,565 +0,0 @@ -/** - * Copyright (c) 2010 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.EnumLiteral; -import org.eclipse.etrice.core.room.EnumerationType; -import org.eclipse.etrice.core.room.ExternalType; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.PrimitiveType; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase; -import org.eclipse.etrice.generator.generic.ILanguageExtension; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.util.Pair; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.StringExtensions; - -@Singleton -@SuppressWarnings("all") -public class JavaExtensions implements ILanguageExtension { - @Inject - private TypeHelpers typeHelpers; - - @Override - public String getTypedDataDefinition(final EObject msg) { - String _xifexpression = null; - if ((msg instanceof Message)) { - _xifexpression = this.generateArglistAndTypedData(((Message) msg).getData())[ILanguageExtensionBase.TypedDataKind.DECLARATION_AND_INITIALIZATION.ordinal()]; - } else { - _xifexpression = ""; - } - return _xifexpression; - } - - public String getJavaFileName(final RoomClass rc) { - String _name = rc.getName(); - return (_name + ".java"); - } - - public String getJavaFactoryName(final ActorClass rc) { - String _name = rc.getName(); - return (_name + "Factory"); - } - - public String getJavaFactoryFileName(final ActorClass rc) { - String _javaFactoryName = this.getJavaFactoryName(rc); - return (_javaFactoryName + ".java"); - } - - public String getJavaScalarInterfaceName(final ActorClass rc) { - String _name = rc.getName(); - return (_name + "Interface"); - } - - public String getJavaScalarInterfaceFileName(final ActorClass rc) { - String _javaScalarInterfaceName = this.getJavaScalarInterfaceName(rc); - return (_javaScalarInterfaceName + ".java"); - } - - public String getJavaReplicatedInterfaceName(final ActorClass rc) { - String _name = rc.getName(); - return (_name + "ReplicatedInterface"); - } - - public String getJavaReplicatedInterfaceFileName(final ActorClass rc) { - String _javaReplicatedInterfaceName = this.getJavaReplicatedInterfaceName(rc); - return (_javaReplicatedInterfaceName + ".java"); - } - - public String getJavaInterfaceName(final ActorClass ac, final boolean replicated) { - String _xifexpression = null; - if (replicated) { - _xifexpression = this.getJavaReplicatedInterfaceName(ac); - } else { - _xifexpression = this.getJavaScalarInterfaceName(ac); - } - return _xifexpression; - } - - public String getJavaInterfaceFileName(final ActorClass ac, final boolean replicated) { - String _xifexpression = null; - if (replicated) { - _xifexpression = this.getJavaReplicatedInterfaceFileName(ac); - } else { - _xifexpression = this.getJavaScalarInterfaceFileName(ac); - } - return _xifexpression; - } - - public String getJavaClassName(final NodeRef nr, final SubSystemInstance ssi) { - String _name = nr.getName(); - String _plus = ("Node_" + _name); - String _plus_1 = (_plus + "_"); - String _name_1 = ssi.getName(); - return (_plus_1 + _name_1); - } - - public String getJavaFileName(final NodeRef nr, final SubSystemInstance ssi) { - String _javaClassName = this.getJavaClassName(nr, ssi); - return (_javaClassName + ".java"); - } - - public String toWrapper(final String type) { - String _switchResult = null; - if (type != null) { - switch (type) { - case "int": - _switchResult = "Integer"; - break; - case "char": - _switchResult = "Character"; - break; - default: - _switchResult = StringExtensions.toFirstUpper(type); - break; - } - } else { - _switchResult = StringExtensions.toFirstUpper(type); - } - return _switchResult; - } - - public boolean needsInitialization(final Attribute a) { - return (((a.getSize() > 0) || (!this.typeHelpers.isEnumerationOrPrimitive(a.getType().getType()))) || this.typeHelpers.typeName(a.getType().getType()).equals("String")); - } - - @Override - public String accessLevelPrivate() { - return "private "; - } - - @Override - public String accessLevelProtected() { - return "protected "; - } - - @Override - public String accessLevelPublic() { - return "public "; - } - - @Override - public String memberAccess() { - return "this."; - } - - @Override - public String selfPointer(final String classname, final boolean hasArgs) { - return ""; - } - - @Override - public String selfPointer(final boolean hasArgs) { - return ""; - } - - @Override - public String operationScope(final String classname, final boolean isDeclaration) { - return ""; - } - - @Override - public String scopeSeparator() { - return "."; - } - - @Override - public String memberInDeclaration(final String namespace, final String member) { - return member; - } - - @Override - public String memberInUse(final String namespace, final String member) { - return ((namespace + ".") + member); - } - - @Override - public boolean usesInheritance() { - return true; - } - - @Override - public boolean usesPointers() { - return false; - } - - @Override - 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(); - } - } - return _builder.toString(); - } - - @Override - public String booleanConstant(final boolean b) { - return Boolean.valueOf(b).toString(); - } - - @Override - public String pointerLiteral() { - return ""; - } - - @Override - public String nullPointer() { - return "null"; - } - - @Override - public String voidPointer() { - return "Object"; - } - - @Override - public String arrayType(final String type, final int size, final boolean isRef) { - return (type + "[]"); - } - - @Override - public String arrayDeclaration(final String type, final int size, final boolean isRef, final String name) { - return (((type + " ") + name) + "[]"); - } - - @Override - public String superCall(final String baseClassName, final String method, final String args) { - return (((("super." + method) + "(") + args) + ");"); - } - - @Override - public String toValueLiteral(final PrimitiveType type, final String value) { - String _xifexpression = null; - if (((!this.typeHelpers.isCharacterType(type)) && (value.contains(",") || value.contains("{")))) { - String _xblockexpression = null; - { - String[] singleValues = value.replace("{", "").replace("}", "").trim().split(","); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{ "); - { - boolean _hasElements = false; - for(final String v : singleValues) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _castValue = this.castValue(type, v.trim()); - _builder.append(_castValue); - } - } - _builder.append(" }"); - _xblockexpression = _builder.toString(); - } - _xifexpression = _xblockexpression; - } else { - _xifexpression = this.castValue(type, value); - } - return _xifexpression; - } - - @Override - public String toEnumLiteral(final EnumerationType type, final String value) { - String _xifexpression = null; - if ((value.contains(",") || value.contains("{"))) { - String _xblockexpression = null; - { - String[] singleValues = value.replace("{", "").replace("}", "").trim().split(","); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{ "); - { - boolean _hasElements = false; - for(final String v : singleValues) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _convertStringEnumLiteral = this.convertStringEnumLiteral(type, v.trim()); - _builder.append(_convertStringEnumLiteral); - } - } - _builder.append(" }"); - _xblockexpression = _builder.toString(); - } - _xifexpression = _xblockexpression; - } else { - _xifexpression = this.convertStringEnumLiteral(type, value); - } - return _xifexpression; - } - - private String convertStringEnumLiteral(final EnumerationType type, final String value) { - String v = value; - boolean _startsWith = v.startsWith(type.getName()); - if (_startsWith) { - int _length = type.getName().length(); - int _plus = (_length + 1); - v = v.substring(_plus); - } - EList<EnumLiteral> _literals = type.getLiterals(); - for (final EnumLiteral l : _literals) { - boolean _equals = l.getName().equals(v); - if (_equals) { - String _name = type.getName(); - String _plus_1 = (_name + "."); - String _name_1 = l.getName(); - return (_plus_1 + _name_1); - } - } - return null; - } - - private String castValue(final PrimitiveType type, final String value) { - String _switchResult = null; - String _targetName = type.getTargetName(); - if (_targetName != null) { - switch (_targetName) { - case "boolean": - _switchResult = value.toLowerCase(); - break; - case "byte": - _switchResult = ("(byte)" + value); - break; - case "short": - _switchResult = ("(short)" + value); - break; - case "int": - _switchResult = value; - break; - case "long": - _switchResult = (value + "L"); - break; - case "float": - _switchResult = (value + "f"); - break; - case "double": - _switchResult = (value + "d"); - break; - case "char": - String _xifexpression = null; - boolean _isEmpty = value.isEmpty(); - if (_isEmpty) { - _xifexpression = "(char) 0"; - } else { - String _xifexpression_1 = null; - int _length = value.length(); - boolean _equals = (_length == 1); - if (_equals) { - char _charAt = value.charAt(0); - String _plus = ("\'" + Character.valueOf(_charAt)); - _xifexpression_1 = (_plus + "\'"); - } else { - String _replace = value.replace("\\", "\\\\").replace("\"", "\\\""); - String _plus_1 = ("\"" + _replace); - _xifexpression_1 = (_plus_1 + "\".toCharArray()"); - } - _xifexpression = _xifexpression_1; - } - _switchResult = _xifexpression; - break; - case "String": - String _replace_1 = value.replace("\\", "\\\\").replace("\"", "\\\""); - String _plus_2 = ("\"" + _replace_1); - _switchResult = (_plus_2 + "\""); - break; - default: - String _targetName_1 = type.getTargetName(); - throw new UnsupportedOperationException(_targetName_1); - } - } else { - String _targetName_1 = type.getTargetName(); - throw new UnsupportedOperationException(_targetName_1); - } - return _switchResult; - } - - @Override - public String defaultValue(final DataType dt) { - String _switchResult = null; - boolean _matched = false; - if (dt instanceof PrimitiveType) { - _matched=true; - _switchResult = this.toValueLiteral(((PrimitiveType)dt), ((PrimitiveType)dt).getDefaultValueLiteral()); - } - if (!_matched) { - if (dt instanceof EnumerationType) { - _matched=true; - _switchResult = this.getDefaultValue(((EnumerationType)dt)); - } - } - if (!_matched) { - if (dt instanceof ExternalType) { - _matched=true; - String _targetName = ((ExternalType) dt).getTargetName(); - String _plus = ("new " + _targetName); - _switchResult = (_plus + "()"); - } - } - if (!_matched) { - String _name = dt.getName(); - String _plus = ("new " + _name); - _switchResult = (_plus + "()"); - } - return _switchResult; - } - - public String getDefaultValue(final EnumerationType type) { - String _xifexpression = null; - boolean _isEmpty = type.getLiterals().isEmpty(); - if (_isEmpty) { - _xifexpression = ""; - } else { - _xifexpression = this.getCastedValue(type.getLiterals().get(0)); - } - return _xifexpression; - } - - @Override - public String initializationWithDefaultValues(final DataType dt, final int size) { - String _xblockexpression = null; - { - final String dv = this.defaultValue(dt); - String _xifexpression = null; - if ((size > 1)) { - String _xblockexpression_1 = null; - { - String res = "{"; - int i = 0; - while ((i < size)) { - { - res = (res + dv); - i = (i + 1); - if ((i < size)) { - res = (res + ","); - } - } - } - _xblockexpression_1 = (res + "}"); - } - _xifexpression = _xblockexpression_1; - } else { - _xifexpression = dv; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String[] generateArglistAndTypedData(final EObject d) { - if ((Objects.equal(d, null) || (!(d instanceof VarDecl)))) { - return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class)); - } - final VarDecl data = ((VarDecl) d); - String typeName = data.getRefType().getType().getName(); - String castTypeName = typeName; - DataType _type = data.getRefType().getType(); - if ((_type instanceof PrimitiveType)) { - DataType _type_1 = data.getRefType().getType(); - typeName = ((PrimitiveType) _type_1).getTargetName(); - DataType _type_2 = data.getRefType().getType(); - final String ct = ((PrimitiveType) _type_2).getCastName(); - if (((!Objects.equal(ct, null)) && (!ct.isEmpty()))) { - castTypeName = ct; - } - } else { - DataType _type_3 = data.getRefType().getType(); - if ((_type_3 instanceof EnumerationType)) { - DataType _type_4 = data.getRefType().getType(); - typeName = this.getTargetType(((EnumerationType) _type_4)); - DataType _type_5 = data.getRefType().getType(); - castTypeName = this.getCastType(((EnumerationType) _type_5)); - } - } - final String dataArg = (", " + ILanguageExtension.GENERIC_DATA_NAME); - final String typedData = (((((typeName + " ") + ILanguageExtension.GENERIC_DATA_NAME) + " = (") + castTypeName) + ") generic_data__et;\n"); - final String typedArgList = (((", " + typeName) + " ") + ILanguageExtension.GENERIC_DATA_NAME); - return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(dataArg, typedData, typedArgList), String.class)); - } - - @Override - public String getTargetType(final EnumerationType type) { - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = type.getPrimitiveType().getTargetName(); - } else { - _xifexpression = "int"; - } - return _xifexpression; - } - - @Override - public String getCastedValue(final EnumLiteral literal) { - String _xblockexpression = null; - { - EObject _eContainer = literal.eContainer(); - final EnumerationType type = ((EnumerationType) _eContainer); - final String cast = this.getTargetType(type); - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _equals = Objects.equal(_primitiveType, null); - if (_equals) { - _xifexpression = Long.toString(literal.getLiteralValue()); - } else { - String _string = Long.toString(literal.getLiteralValue()); - String _plus = ((("((" + cast) + ")") + _string); - _xifexpression = (_plus + ")"); - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - @Override - public String getCastType(final EnumerationType type) { - String _xifexpression = null; - PrimitiveType _primitiveType = type.getPrimitiveType(); - boolean _notEquals = (!Objects.equal(_primitiveType, null)); - if (_notEquals) { - _xifexpression = type.getPrimitiveType().getCastName(); - } else { - _xifexpression = "int"; - } - return _xifexpression; - } - - @Override - public String makeOverridable() { - return ""; - } -} diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/NodeGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/NodeGen.java deleted file mode 100644 index ee57b0bd3..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/NodeGen.java +++ /dev/null @@ -1,794 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.etmap.util.ETMapUtil; -import org.eclipse.etrice.core.etphys.eTPhys.ExecMode; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.etphys.eTPhys.PhysicalThread; -import org.eclipse.etrice.core.genmodel.builder.GenmodelConstants; -import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInterfaceInstance; -import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase; -import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.OptionalActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.ServiceImplInstance; -import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Wire; -import org.eclipse.etrice.core.genmodel.etricegen.WiredStructureClass; -import org.eclipse.etrice.core.genmodel.etricegen.WiredSubSystemClass; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.generator.base.IDataConfiguration; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.fsm.base.Indexed; -import org.eclipse.etrice.generator.fsm.base.IntelligentSeparator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.java.Main; -import org.eclipse.etrice.generator.java.gen.ConfigGenAddon; -import org.eclipse.etrice.generator.java.gen.JavaExtensions; -import org.eclipse.etrice.generator.java.gen.VariableServiceGen; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -@Singleton -@SuppressWarnings("all") -public class NodeGen { - @Inject - @Extension - private JavaExtensions _javaExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - private IDataConfiguration dataConfigExt; - - @Inject - private ConfigGenAddon configGenAddon; - - @Inject - @Extension - private ProcedureHelpers _procedureHelpers; - - @Inject - @Extension - private FileSystemHelpers _fileSystemHelpers; - - @Inject - private IGeneratorFileIo fileIO; - - @Inject - private VariableServiceGen varService; - - @Inject - private IDiagnostician diagnostician; - - public void doGenerate(final Root root) { - final HashMap<SubSystemClass, WiredSubSystemClass> sscc2wired = new HashMap<SubSystemClass, WiredSubSystemClass>(); - final Function1<WiredStructureClass, Boolean> _function = (WiredStructureClass w) -> { - return Boolean.valueOf((w instanceof WiredSubSystemClass)); - }; - final Consumer<WiredStructureClass> _function_1 = (WiredStructureClass w) -> { - sscc2wired.put(((WiredSubSystemClass) w).getSubSystemClass(), ((WiredSubSystemClass) w)); - }; - IterableExtensions.<WiredStructureClass>filter(root.getWiredInstances(), _function).forEach(_function_1); - Collection<NodeRef> _nodeRefs = ETMapUtil.getNodeRefs(); - for (final NodeRef nr : _nodeRefs) { - List<String> _subSystemInstancePaths = ETMapUtil.getSubSystemInstancePaths(nr); - for (final String instpath : _subSystemInstancePaths) { - { - StructureInstance _instance = root.getInstance(instpath); - final SubSystemInstance ssi = ((SubSystemInstance) _instance); - if (((!Objects.equal(ssi, null)) && this._fileSystemHelpers.isValidGenerationLocation(ssi.getSubSystemClass()))) { - final WiredSubSystemClass wired = sscc2wired.get(ssi.getSubSystemClass()); - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(ssi.getSubSystemClass()); - String _path = this._roomExtensions.getPath(ssi.getSubSystemClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(ssi.getSubSystemClass()); - String _path_1 = this._roomExtensions.getPath(ssi.getSubSystemClass()); - final String infopath = (_generationInfoPath + _path_1); - final String file = this._javaExtensions.getJavaFileName(nr, ssi); - this.checkDataPorts(ssi); - final Set<PhysicalThread> usedThreads = ETMapUtil.getUsedThreads(nr, ssi); - this.fileIO.generateFile("generating Node implementation", path, infopath, file, this.generate(root, ssi, wired, usedThreads)); - boolean _hasVariableService = this.dataConfigExt.hasVariableService(ssi); - if (_hasVariableService) { - this.varService.doGenerate(root, ssi); - } - } - } - } - } - } - - /** - * Recursively collect all possible interface instances below a given structure instance. - */ - private HashSet<ActorClass> getOptionalActorClasses(final Root root, final StructureInstance si) { - final Function1<EObject, Boolean> _function = (EObject i) -> { - return Boolean.valueOf((i instanceof ActorInterfaceInstance)); - }; - final Function1<EObject, ActorInterfaceInstance> _function_1 = (EObject aii) -> { - return ((ActorInterfaceInstance) aii); - }; - final ArrayList<ActorInterfaceInstance> aifs = Lists.<ActorInterfaceInstance>newArrayList(IteratorExtensions.<EObject, ActorInterfaceInstance>map(IteratorExtensions.<EObject>filter(si.eAllContents(), _function), _function_1)); - final Function1<ActorInterfaceInstance, ActorClass> _function_2 = (ActorInterfaceInstance aii) -> { - return ((ActorInterfaceInstance) aii).getActorClass(); - }; - final HashSet<ActorClass> result = Sets.<ActorClass>newHashSet(ListExtensions.<ActorInterfaceInstance, ActorClass>map(aifs, _function_2)); - for (final ActorInterfaceInstance ai : aifs) { - EList<OptionalActorInstance> _optionalInstances = ai.getOptionalInstances(); - for (final OptionalActorInstance oi : _optionalInstances) { - result.addAll(this.getOptionalActorClasses(root, oi)); - } - } - return result; - } - - public CharSequence generate(final Root root, final SubSystemInstance comp, final WiredSubSystemClass wired, final Collection<PhysicalThread> usedThreads) { - CharSequence _xblockexpression = null; - { - final SubSystemClass cc = comp.getSubSystemClass(); - final EList<RoomModel> models = root.getReferencedModels(cc); - final NodeRef nr = ETMapUtil.getNodeRef(comp); - final String clsname = this._javaExtensions.getJavaClassName(nr, comp); - final Function1<PhysicalThread, Boolean> _function = (PhysicalThread t) -> { - return Boolean.valueOf(usedThreads.contains(t)); - }; - final Iterable<PhysicalThread> threads = IterableExtensions.<PhysicalThread>filter(nr.getType().getThreads(), _function); - final HashSet<ActorClass> opt = this.getOptionalActorClasses(root, comp); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("package "); - String _package = this._roomExtensions.getPackage(cc); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.config.IVariableService;"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;"); - _builder.newLine(); - } - } - _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageService;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageServiceController;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.DataPortBase;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.OptionalActorInterfaceBase;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IOptionalActorFactory;"); - _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.modelbase.InterfaceItemBroker;"); - _builder.newLine(); - _builder.newLine(); - { - for(final RoomModel model : models) { - _builder.append("import "); - String _name = model.getName(); - _builder.append(_name); - _builder.append(".*;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(cc, 1, false); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("public class "); - _builder.append(clsname); - _builder.append(" extends SubSystemClassBase {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - Iterable<Indexed<PhysicalThread>> _indexed = Indexed.<PhysicalThread>indexed(threads); - for(final Indexed<PhysicalThread> thread : _indexed) { - _builder.append("\t"); - _builder.append("public static final int "); - String _threadId = this.getThreadId(thread.getValue()); - _builder.append(_threadId, "\t"); - _builder.append(" = "); - int _index0 = thread.getIndex0(); - _builder.append(_index0, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2, false); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(clsname, "\t"); - _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.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.newLine(); - _builder.append("\t"); - _builder.append("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void instantiateMessageServices() {"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("IMessageService msgService;"); - _builder.newLine(); - { - final Function1<PhysicalThread, Long> _function_1 = (PhysicalThread it) -> { - long _prio = it.getPrio(); - return Long.valueOf((-_prio)); - }; - List<PhysicalThread> _sortBy = IterableExtensions.<PhysicalThread, Long>sortBy(threads, _function_1); - for(final PhysicalThread thread_1 : _sortBy) { - { - if ((Objects.equal(thread_1.getExecmode(), ExecMode.POLLED) || Objects.equal(thread_1.getExecmode(), ExecMode.MIXED))) { - _builder.append("\t\t"); - _builder.append("msgService = new MessageService(this, MessageService.ExecMode."); - String _name_1 = thread_1.getExecmode().getName(); - _builder.append(_name_1, "\t\t"); - _builder.append(", "); - long _time = thread_1.getTime(); - _builder.append(_time, "\t\t"); - _builder.append("L, 0, "); - String _threadId_1 = this.getThreadId(thread_1); - _builder.append(_threadId_1, "\t\t"); - _builder.append(", \"MessageService_"); - String _name_2 = thread_1.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append("\" /*, thread_prio */);"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t\t"); - _builder.append("msgService = new MessageService(this, MessageService.ExecMode."); - String _name_3 = thread_1.getExecmode().getName(); - _builder.append(_name_3, "\t\t"); - _builder.append(", 0, "); - String _threadId_2 = this.getThreadId(thread_1); - _builder.append(_threadId_2, "\t\t"); - _builder.append(", \"MessageService_"); - String _name_4 = thread_1.getName(); - _builder.append(_name_4, "\t\t"); - _builder.append("\" /*, thread_prio */);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(msgService);"); - _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 instantiateActors() {"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// thread mappings"); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances(); - for(final ActorInstance ai : _allContainedInstances) { - _builder.append("\t\t"); - final ETMapUtil.MappedThread mapped = ETMapUtil.getMappedThread(ai); - _builder.newLineIfNotEmpty(); - { - boolean _not = (!(mapped.isImplicit() || mapped.isAsParent())); - if (_not) { - _builder.append("\t\t"); - _builder.append("addPathToThread(\""); - String _path = ai.getPath(); - _builder.append(_path, "\t\t"); - _builder.append("\", "); - String _threadId_3 = this.getThreadId(mapped.getThread()); - _builder.append(_threadId_3, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// sub actors"); - _builder.newLine(); - { - EList<ActorRef> _actorRefs = cc.getActorRefs(); - for(final ActorRef sub : _actorRefs) { - { - int _multiplicity = sub.getMultiplicity(); - boolean _greaterThan = (_multiplicity > 1); - if (_greaterThan) { - _builder.append("\t\t"); - _builder.append("for (int i=0; i<"); - int _multiplicity_1 = sub.getMultiplicity(); - _builder.append(_multiplicity_1, "\t\t"); - _builder.append("; ++i) {"); - _builder.newLineIfNotEmpty(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \""); - String _name_5 = sub.getName(); - _builder.append(_name_5, "\t\t\t"); - _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t"); - _builder.append("\"+i);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("new "); - String _name_6 = sub.getType().getName(); - _builder.append(_name_6, "\t\t\t"); - _builder.append("(this, \""); - String _name_7 = sub.getName(); - _builder.append(_name_7, "\t\t\t"); - _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t"); - _builder.append("\"+i);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - } else { - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("\t\t"); - _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \""); - String _name_8 = sub.getName(); - _builder.append(_name_8, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("new "); - String _name_9 = sub.getType().getName(); - _builder.append(_name_9, "\t\t"); - _builder.append("(this, \""); - String _name_10 = sub.getName(); - _builder.append(_name_10, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// create service brokers in optional actor interfaces"); - _builder.newLine(); - { - final Function1<AbstractInstance, Boolean> _function_2 = (AbstractInstance inst) -> { - return Boolean.valueOf((inst instanceof ActorInterfaceInstance)); - }; - final Function1<AbstractInstance, ActorInterfaceInstance> _function_3 = (AbstractInstance inst) -> { - return ((ActorInterfaceInstance) inst); - }; - Iterable<ActorInterfaceInstance> _map = IterableExtensions.<AbstractInstance, ActorInterfaceInstance>map(IterableExtensions.<AbstractInstance>filter(this._roomExtensions.getAllSubInstances(comp), _function_2), _function_3); - for(final ActorInterfaceInstance aii : _map) { - _builder.append("\t\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("OptionalActorInterfaceBase oai = (OptionalActorInterfaceBase) getObject(\""); - String _path_1 = aii.getPath(); - _builder.append(_path_1, "\t\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - { - EList<ServiceImplInstance> _providedServices = aii.getProvidedServices(); - for(final ServiceImplInstance svc : _providedServices) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("new InterfaceItemBroker(oai, \""); - String _fullyQualifiedName = this._roomExtensions.getFullyQualifiedName(svc.getProtocol()); - _builder.append(_fullyQualifiedName, "\t\t\t"); - _builder.append("\", 0);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("InterfaceItemBase.connect(this, \""); - String _path_2 = svc.getPath(); - _builder.append(_path_2, "\t\t\t"); - _builder.append("\", \""); - String _path_3 = aii.getPath(); - String _plus = (_path_3 + Character.valueOf(InstanceBase.pathDelim)); - String _fullyQualifiedName_1 = this._roomExtensions.getFullyQualifiedName(svc.getProtocol()); - String _plus_1 = (_plus + _fullyQualifiedName_1); - _builder.append(_plus_1, "\t\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// wiring"); - _builder.newLine(); - { - EList<Wire> _wires = wired.getWires(); - for(final Wire wire : _wires) { - _builder.append("\t\t"); - String _xifexpression = null; - boolean _isDataDriven = wire.isDataDriven(); - if (_isDataDriven) { - _xifexpression = "DataPortBase"; - } else { - _xifexpression = "InterfaceItemBase"; - } - _builder.append(_xifexpression, "\t\t"); - _builder.append(".connect(this, \""); - String _join = IterableExtensions.join(wire.getPath1(), "/"); - _builder.append(_join, "\t\t"); - _builder.append("\", \""); - String _join_1 = IterableExtensions.join(wire.getPath2(), "/"); - _builder.append(_join_1, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// apply instance attribute configurations"); - _builder.newLine(); - { - EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances(); - for(final ActorInstance ai_1 : _allContainedInstances_1) { - _builder.append("\t\t"); - final CharSequence cfg = this.configGenAddon.genActorInstanceConfig(ai_1, "inst"); - _builder.newLineIfNotEmpty(); - { - int _length = cfg.length(); - boolean _greaterThan_1 = (_length > 0); - if (_greaterThan_1) { - _builder.append("\t\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - String _name_11 = ai_1.getActorClass().getName(); - _builder.append(_name_11, "\t\t\t"); - _builder.append(" inst = ("); - String _name_12 = ai_1.getActorClass().getName(); - _builder.append(_name_12, "\t\t\t"); - _builder.append(") getObject(\""); - String _path_4 = ai_1.getPath(); - _builder.append(_path_4, "\t\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("if (inst!=null) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t\t"); - _builder.append(cfg, "\t\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _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 init(){"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_3 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_3) { - _builder.append("\t\t"); - _builder.append("DebuggingService.getInstance().addVisibleComment(\"begin sub system initialization\");"); - _builder.newLine(); - } - } - { - boolean _hasVariableService = this.dataConfigExt.hasVariableService(comp); - if (_hasVariableService) { - _builder.append("\t\t"); - _builder.append("variableService = new "); - _builder.append(clsname, "\t\t"); - _builder.append("VariableService(this);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.append("super.init();"); - _builder.newLine(); - { - boolean _hasVariableService_1 = this.dataConfigExt.hasVariableService(comp); - if (_hasVariableService_1) { - _builder.append("\t\t"); - _builder.append("variableService.init();"); - _builder.newLine(); - } - } - { - boolean _isGenerateMSCInstrumentation_4 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_4) { - _builder.append("\t\t"); - _builder.append("DebuggingService.getInstance().addVisibleComment(\"done sub system initialization\");"); - _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 stop(){"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("super.stop();"); - _builder.newLine(); - { - boolean _hasVariableService_2 = this.dataConfigExt.hasVariableService(comp); - if (_hasVariableService_2) { - _builder.append("\t\t"); - _builder.append("variableService.stop();"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_5 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_5) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public boolean hasGeneratedMSCInstrumentation() {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("return true;"); - _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 destroy() {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addVisibleComment(\"begin sub system destruction\");"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("super.destroy();"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addVisibleComment(\"done sub system destruction\");"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("public IOptionalActorFactory getFactory(String optionalActorClass, String actorClass) {"); - _builder.newLine(); - _builder.append("\t\t"); - final IntelligentSeparator else1 = new IntelligentSeparator("else "); - _builder.newLineIfNotEmpty(); - { - for(final ActorClass oa : opt) { - _builder.append("\t\t"); - _builder.append(else1, "\t\t"); - _builder.append("if (optionalActorClass.equals(\""); - String _name_13 = oa.getName(); - _builder.append(_name_13, "\t\t"); - _builder.append("\")) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - final IntelligentSeparator else2 = new IntelligentSeparator("else "); - _builder.newLineIfNotEmpty(); - { - final Function1<ActorClass, Boolean> _function_4 = (ActorClass s) -> { - boolean _isAbstract = s.isAbstract(); - return Boolean.valueOf((!_isAbstract)); - }; - Iterable<ActorClass> _filter = IterableExtensions.<ActorClass>filter(this._roomExtensions.<ActorClass>union(root.getSubClasses(oa), oa), _function_4); - for(final ActorClass subcls : _filter) { - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append(else2, "\t\t\t"); - _builder.append("if (\""); - String _name_14 = subcls.getName(); - _builder.append(_name_14, "\t\t\t"); - _builder.append("\".equals(actorClass)) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("return new "); - String _javaFactoryName = this._javaExtensions.getJavaFactoryName(subcls); - _builder.append(_javaFactoryName, "\t\t\t\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _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("return null;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("};"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private String getThreadId(final PhysicalThread thread) { - String _upperCase = thread.getName().toUpperCase(); - return ("THREAD_" + _upperCase); - } - - private void checkDataPorts(final SubSystemInstance comp) { - final HashSet<String> found = new HashSet<String>(); - EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances(); - for (final ActorInstance ai : _allContainedInstances) { - { - final int thread = ai.getThreadId(); - EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances(); - for (final InterfaceItemInstance pi : _orderedIfItemInstances) { - CommunicationType _commType = pi.getProtocol().getCommType(); - boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN); - if (_equals) { - EList<InterfaceItemInstance> _peers = pi.getPeers(); - for (final InterfaceItemInstance peer : _peers) { - { - EObject _eContainer = peer.eContainer(); - final ActorInstance peer_ai = ((ActorInstance) _eContainer); - final int peer_thread = peer_ai.getThreadId(); - if ((thread != peer_thread)) { - final String path = pi.getPath(); - final String ppath = peer.getPath(); - String _xifexpression = null; - int _compareTo = path.compareTo(ppath); - boolean _lessThan = (_compareTo < 0); - if (_lessThan) { - _xifexpression = ((path + " and ") + ppath); - } else { - _xifexpression = ((ppath + " and ") + path); - } - final String pair = _xifexpression; - boolean _contains = found.contains(pair); - boolean _not = (!_contains); - if (_not) { - found.add(pair); - this.diagnostician.error((pair + ": data ports placed on different threads (not supported yet)"), - pi.getInterfaceItem(), pi.getInterfaceItem().eContainingFeature()); - } - } - } - } - } - } - } - } - } -} diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorFactoryGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorFactoryGen.java deleted file mode 100644 index 0616e4b64..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorFactoryGen.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import java.util.HashMap; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.genmodel.etricegen.OpenBinding; -import org.eclipse.etrice.core.genmodel.etricegen.OpenServiceConnection; -import org.eclipse.etrice.core.genmodel.etricegen.OptionalActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass; -import org.eclipse.etrice.core.genmodel.etricegen.WiredStructureClass; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.java.gen.JavaExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@SuppressWarnings("all") -public class OptionalActorFactoryGen { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - @Inject - @Extension - private JavaExtensions _javaExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private FileSystemHelpers _fileSystemHelpers; - - public void doGenerate(final Root root) { - final HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>(); - final Function1<WiredStructureClass, Boolean> _function = (WiredStructureClass w) -> { - return Boolean.valueOf((w instanceof WiredActorClass)); - }; - final Consumer<WiredStructureClass> _function_1 = (WiredStructureClass w) -> { - ac2wired.put(((WiredActorClass) w).getActorClass(), ((WiredActorClass) w)); - }; - IterableExtensions.<WiredStructureClass>filter(root.getWiredInstances(), _function).forEach(_function_1); - final Function1<OptionalActorInstance, Boolean> _function_2 = (OptionalActorInstance cl) -> { - return Boolean.valueOf(this._fileSystemHelpers.isValidGenerationLocation(cl.getActorClass())); - }; - Iterable<OptionalActorInstance> _filter = IterableExtensions.<OptionalActorInstance>filter(root.getOptionalInstances(), _function_2); - for (final OptionalActorInstance oi : _filter) { - { - final ActorClass ac = oi.getActorClass(); - final WiredActorClass wired = ac2wired.get(ac); - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(ac); - String _path = this._roomExtensions.getPath(ac); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(ac); - String _path_1 = this._roomExtensions.getPath(ac); - final String infopath = (_generationInfoPath + _path_1); - final String file = this._javaExtensions.getJavaFactoryFileName(ac); - this.fileIO.generateFile("generating ActorClass Interface implementation", path, infopath, file, this.generate(root, oi, wired)); - } - } - } - - public CharSequence generate(final Root root, final OptionalActorInstance oi, final WiredActorClass wired) { - CharSequence _xblockexpression = null; - { - final ActorClass ac = oi.getActorClass(); - final String clsname = this._javaExtensions.getJavaFactoryName(ac); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("package "); - String _package = this._roomExtensions.getPackage(ac); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("import "); - String _package_1 = this._roomExtensions.getPackage(ac); - _builder.append(_package_1); - _builder.append("."); - String _name = ac.getName(); - _builder.append(_name); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.OptionalActorInterfaceBase;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IOptionalActorFactory;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;"); - _builder.newLine(); - _builder.newLine(); - _builder.append("public class "); - _builder.append(clsname); - _builder.append(" implements IOptionalActorFactory {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - String _name_1 = ac.getName(); - _builder.append(_name_1, "\t"); - _builder.append(" create(OptionalActorInterfaceBase ai, String name) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("// instantiate sub tree"); - _builder.newLine(); - _builder.append("\t\t"); - String _name_2 = ac.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append(" actor = new "); - String _name_3 = ac.getName(); - _builder.append(_name_3, "\t\t"); - _builder.append("(ai, name);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// wiring"); - _builder.newLine(); - { - final Function1<Port, Boolean> _function = (Port p) -> { - return Boolean.valueOf(this._roomHelpers.isExternal(p)); - }; - Iterable<Port> _filter = IterableExtensions.<Port>filter(this._roomHelpers.getAllEndPorts(ac), _function); - for(final Port port : _filter) { - _builder.append("\t\t"); - String _xifexpression = null; - boolean _isDataDriven = this._roomHelpers.isDataDriven(port); - if (_isDataDriven) { - _xifexpression = "DataPortBase"; - } else { - _xifexpression = "InterfaceItemBase"; - } - _builder.append(_xifexpression, "\t\t"); - _builder.append(".connect(ai, \""); - String _name_4 = port.getName(); - _builder.append(_name_4, "\t\t"); - _builder.append("\", name+\"/"); - String _name_5 = port.getName(); - _builder.append(_name_5, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - { - EList<OpenBinding> _openBindings = wired.getOpenBindings(); - for(final OpenBinding open : _openBindings) { - _builder.append("\t\t"); - String _xifexpression_1 = null; - boolean _isDataDriven_1 = this._roomHelpers.isDataDriven(open.getPort()); - if (_isDataDriven_1) { - _xifexpression_1 = "DataPortBase"; - } else { - _xifexpression_1 = "InterfaceItemBase"; - } - _builder.append(_xifexpression_1, "\t\t"); - _builder.append(".connect(ai, \""); - String _name_6 = open.getPort().getName(); - _builder.append(_name_6, "\t\t"); - _builder.append("\", name+\"/"); - String _join = IterableExtensions.join(open.getPath(), "/"); - _builder.append(_join, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - { - EList<OpenServiceConnection> _requiredServices = wired.getRequiredServices(); - for(final OpenServiceConnection req : _requiredServices) { - _builder.append("\t\t"); - String _xifexpression_2 = null; - CommunicationType _commType = req.getProtocol().getCommType(); - boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN); - if (_equals) { - _xifexpression_2 = "DataPortBase"; - } else { - _xifexpression_2 = "InterfaceItemBase"; - } - _builder.append(_xifexpression_2, "\t\t"); - _builder.append(".connect(ai, \""); - String _fullyQualifiedName = this._roomExtensions.getFullyQualifiedName(req.getProtocol()); - _builder.append(_fullyQualifiedName, "\t\t"); - _builder.append("\", name+\"/"); - String _join_1 = IterableExtensions.join(req.getPath(), "/"); - _builder.append(_join_1, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return actor;"); - _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/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java deleted file mode 100644 index 9dd91217b..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java +++ /dev/null @@ -1,1030 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.CommunicationType; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.MessageHandler; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.etrice.generator.java.Main; -import org.eclipse.etrice.generator.java.gen.DataClassGen; -import org.eclipse.etrice.generator.java.gen.Initialization; -import org.eclipse.etrice.generator.java.gen.JavaExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@Singleton -@SuppressWarnings("all") -public class ProtocolClassGen extends GenericProtocolClassGenerator { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private JavaExtensions _javaExtensions; - - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - @Extension - private ProcedureHelpers _procedureHelpers; - - @Inject - @Extension - private Initialization _initialization; - - @Inject - @Extension - private TypeHelpers _typeHelpers; - - @Inject - @Extension - private DataClassGen _dataClassGen; - - @Inject - @Extension - private FileSystemHelpers _fileSystemHelpers; - - @Inject - private ILogger logger; - - public void doGenerate(final Root root) { - final Function1<ProtocolClass, Boolean> _function = (ProtocolClass cl) -> { - return Boolean.valueOf(this._fileSystemHelpers.isValidGenerationLocation(cl)); - }; - Iterable<ProtocolClass> _filter = IterableExtensions.<ProtocolClass>filter(root.getProtocolClasses(), _function); - for (final ProtocolClass pc : _filter) { - { - String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc); - String _path = this._roomExtensions.getPath(pc); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(pc); - String _path_1 = this._roomExtensions.getPath(pc); - final String infopath = (_generationInfoPath + _path_1); - final String file = this._javaExtensions.getJavaFileName(pc); - CharSequence _switchResult = null; - CommunicationType _commType = pc.getCommType(); - if (_commType != null) { - switch (_commType) { - case EVENT_DRIVEN: - _switchResult = this.generate(root, pc); - break; - case DATA_DRIVEN: - _switchResult = this.generateDataDriven(root, pc); - break; - case SYNCHRONOUS: - _switchResult = ""; - break; - default: - break; - } - } - final CharSequence contents = _switchResult; - boolean _isEmpty = contents.toString().isEmpty(); - if (_isEmpty) { - this.logger.logError("synchronous protocols not supported yet", pc); - } else { - this.fileIO.generateFile("generating ProtocolClass implementation", path, infopath, file, contents); - } - } - } - } - - public CharSequence generate(final Root root, final ProtocolClass pc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("package "); - String _package = this._roomExtensions.getPackage(pc); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.messaging.Message;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.EventMessage;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.EventWithDataMessage;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IInterfaceItemOwner;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.PortBase;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ReplicatedPortBase;"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;"); - _builder.newLine(); - } - } - _builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;"); - _builder.newLine(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(pc, 1); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - EList<RoomModel> models = root.getReferencedModels(pc); - _builder.newLineIfNotEmpty(); - { - for(final RoomModel model : models) { - _builder.append("import "); - String _name = model.getName(); - _builder.append(_name); - _builder.append(".*;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("public class "); - String _name_1 = pc.getName(); - _builder.append(_name_1); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("// message IDs"); - _builder.newLine(); - _builder.append("\t"); - String _genMessageIDs = this.genMessageIDs(pc); - _builder.append(_genMessageIDs, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("private static String messageStrings[] = {\"MIN\", "); - { - List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc); - for(final Message m : _allOutgoingMessages) { - _builder.append("\""); - String _name_2 = m.getName(); - _builder.append(_name_2, "\t"); - _builder.append("\","); - } - } - _builder.append(" "); - { - List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc); - for(final Message m_1 : _allIncomingMessages) { - _builder.append("\""); - String _name_3 = m_1.getName(); - _builder.append(_name_3, "\t"); - _builder.append("\","); - } - } - _builder.append("\"MAX\"};"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public String getMessageString(int msg_id) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("// id out of range"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return \"Message ID out of range\";"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("else{"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return messageStrings[msg_id];"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - CharSequence _portClass = this.portClass(pc, false); - _builder.append(_portClass, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _portClass_1 = this.portClass(pc, true); - _builder.append(_portClass_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - return _builder; - } - - public CharSequence portClass(final ProtocolClass pc, final boolean conj) { - CharSequence _xblockexpression = null; - { - PortClass pclass = this._roomExtensions.getPortClass(pc, conj); - String portClassName = this._roomExtensions.getPortClassName(pc, conj); - String replPortClassName = this._roomExtensions.getPortClassName(pc, conj, true); - StringConcatenation _builder = new StringConcatenation(); - _builder.newLine(); - _builder.append("// port class"); - _builder.newLine(); - _builder.append("static public class "); - _builder.append(portClassName); - _builder.append(" extends PortBase {"); - _builder.newLineIfNotEmpty(); - { - boolean _notEquals = (!Objects.equal(pclass, null)); - if (_notEquals) { - _builder.append("\t"); - CharSequence _userCode = this._procedureHelpers.userCode(pclass.getUserCode()); - _builder.append(_userCode, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("// constructors"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(portClassName, "\t"); - _builder.append("(IInterfaceItemOwner actor, String name, int localId) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("this(actor, name, localId, 0);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(portClassName, "\t"); - _builder.append("(IInterfaceItemOwner actor, String name, int localId, int idx) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("super(actor, name, localId, idx);"); - _builder.newLine(); - { - boolean _notEquals_1 = (!Objects.equal(pclass, null)); - if (_notEquals_1) { - _builder.append("\t\t"); - CharSequence _attributeInitialization = this._initialization.attributeInitialization(pclass.getAttributes(), pclass, true); - _builder.append(_attributeInitialization, "\t\t"); - _builder.newLineIfNotEmpty(); - } - } - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t\t"); - _builder.append("DebuggingService.getInstance().addPortInstance(this);"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_1 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_1) { - _builder.newLine(); - _builder.append("\t"); - _builder.append("public void destroy() {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().removePortInstance(this);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("super.destroy();"); - _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"); - _builder.append("if (!(m instanceof EventMessage))"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("return;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("EventMessage msg = (EventMessage) m;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) {"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation_2 = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation_2) { - _builder.append("\t\t\t"); - _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);"); - _builder.newLine(); - } - } - { - boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, conj); - if (_handlesReceive) { - _builder.append("\t\t\t"); - _builder.append("switch (msg.getEvtId()) {"); - _builder.newLine(); - { - List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, conj); - for(final MessageHandler hdlr : _receiveHandlers) { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("case "); - String _codeName = this._roomExtensions.getCodeName(hdlr.getMsg()); - _builder.append(_codeName, "\t\t\t\t"); - _builder.append(":"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - { - EList<String> _lines = hdlr.getDetailCode().getLines(); - for(final String command : _lines) { - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("\t"); - _builder.append(command, "\t\t\t\t\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("break;"); - _builder.newLine(); - } - } - _builder.append("\t\t\t"); - _builder.append("\t"); - _builder.append("default:"); - _builder.newLine(); - } - } - _builder.append("\t\t\t"); - _builder.append("if (msg instanceof EventWithDataMessage)"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t\t\t\t"); - _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);"); - _builder.newLine(); - { - boolean _handlesReceive_1 = this._roomExtensions.handlesReceive(pc, conj); - if (_handlesReceive_1) { - _builder.append("\t\t\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - boolean _notEquals_2 = (!Objects.equal(pclass, null)); - if (_notEquals_2) { - _builder.append("\t"); - CharSequence _attributes = this._procedureHelpers.attributes(pclass.getAttributes()); - _builder.append(_attributes, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(pclass.getAttributes(), null); - _builder.append(_attributeSettersGettersImplementation, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(pclass.getOperations(), portClassName); - _builder.append(_operationsImplementation, "\t"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t"); - _builder.append("// sent messages"); - _builder.newLine(); - { - List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, conj); - for(final Message m : _allMessages) { - _builder.append("\t"); - CharSequence _sendMessage = this.sendMessage(m, conj); - _builder.append(_sendMessage, "\t"); - _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(" extends ReplicatedPortBase {"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(replPortClassName, "\t"); - _builder.append("(IInterfaceItemOwner actor, String name, int localId) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("super(actor, name, localId);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public int getReplication() {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return getNInterfaceItems();"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _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"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(portClassName, "\t"); - _builder.append(" get(int idx) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("return ("); - _builder.append(portClassName, "\t\t"); - _builder.append(") getInterfaceItem(idx);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return new "); - _builder.append(portClassName, "\t\t"); - _builder.append("(rcv, name, lid, idx);"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - { - if (conj) { - _builder.append("\t"); - _builder.append("// incoming messages"); - _builder.newLine(); - { - List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc); - for(final Message m_1 : _allIncomingMessages) { - _builder.append("\t"); - CharSequence _messageSignature = this.messageSignature(m_1); - _builder.append(_messageSignature, "\t"); - _builder.append("{"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("for (InterfaceItemBase item : getItems()) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("(("); - _builder.append(portClassName, "\t\t\t"); - _builder.append(")item)."); - CharSequence _messageCall = this.messageCall(m_1); - _builder.append(_messageCall, "\t\t\t"); - _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._roomHelpers.getAllOutgoingMessages(pc); - for(final Message m_2 : _allOutgoingMessages) { - _builder.append("\t"); - CharSequence _messageSignature_1 = this.messageSignature(m_2); - _builder.append(_messageSignature_1, "\t"); - _builder.append("{"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("for (InterfaceItemBase item : getItems()) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t"); - _builder.append("(("); - _builder.append(portClassName, "\t\t\t"); - _builder.append(")item)."); - CharSequence _messageCall_1 = this.messageCall(m_2); - _builder.append(_messageCall_1, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - } - } - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - public CharSequence messageSignature(final Message m) { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isPriv = m.isPriv(); - if (_isPriv) { - _builder.append("private"); - } else { - _builder.append("public"); - } - } - _builder.append(" void "); - String _name = m.getName(); - _builder.append(_name); - _builder.append("("); - { - VarDecl _data = m.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - String _typeName = this._typeHelpers.typeName(m.getData().getRefType().getType()); - _builder.append(_typeName); - _builder.append(" "); - String _name_1 = m.getData().getName(); - _builder.append(_name_1); - } - } - _builder.append(")"); - return _builder; - } - - public CharSequence messageSignatureExplicit(final Message m) { - CharSequence _xblockexpression = null; - { - DataType _type = m.getData().getRefType().getType(); - DataClass dc = ((DataClass) _type); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("public void "); - String _name = m.getName(); - _builder.append(_name); - _builder.append("("); - String _argList = this._dataClassGen.argList(dc); - _builder.append(_argList); - _builder.append(")"); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - public CharSequence messageCall(final Message m) { - StringConcatenation _builder = new StringConcatenation(); - String _name = m.getName(); - _builder.append(_name); - _builder.append("("); - { - VarDecl _data = m.getData(); - boolean _notEquals = (!Objects.equal(_data, null)); - if (_notEquals) { - _builder.append(" "); - String _name_1 = m.getData().getName(); - _builder.append(_name_1); - } - } - _builder.append(")"); - return _builder; - } - - public CharSequence sendMessage(final Message m, final boolean conj) { - CharSequence _xblockexpression = null; - { - String _xifexpression = null; - if (conj) { - _xifexpression = "IN"; - } else { - _xifexpression = "OUT"; - } - String dir = _xifexpression; - MessageHandler hdlr = this._roomExtensions.getSendHandler(m, conj); - StringConcatenation _builder = new StringConcatenation(); - CharSequence _messageSignature = this.messageSignature(m); - _builder.append(_messageSignature); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - { - boolean _notEquals = (!Objects.equal(hdlr, null)); - if (_notEquals) { - _builder.append("\t"); - { - EList<String> _lines = hdlr.getDetailCode().getLines(); - for(final String command : _lines) { - _builder.append("\t"); - _builder.append(command, "\t"); - _builder.newLineIfNotEmpty(); - } - } - } else { - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings["); - _builder.append(dir, "\t"); - _builder.append("_"); - String _name = m.getName(); - _builder.append(_name, "\t"); - _builder.append("]);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("if (getPeerAddress()!=null)"); - _builder.newLine(); - { - VarDecl _data = m.getData(); - boolean _equals = Objects.equal(_data, null); - if (_equals) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), "); - _builder.append(dir, "\t\t"); - _builder.append("_"); - String _name_1 = m.getName(); - _builder.append(_name_1, "\t\t"); - _builder.append("));"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), "); - _builder.append(dir, "\t\t"); - _builder.append("_"); - String _name_2 = m.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append(", "); - String _name_3 = m.getData().getName(); - _builder.append(_name_3, "\t\t"); - { - if (((!m.getData().getRefType().isRef()) && (!this._typeHelpers.isEnumerationOrPrimitive(m.getData().getRefType().getType())))) { - _builder.append(".deepCopy()"); - } - } - _builder.append("));"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("}"); - _builder.newLine(); - { - if (((!Objects.equal(m.getData(), null)) && (m.getData().getRefType().getType() instanceof DataClass))) { - CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m); - _builder.append(_messageSignatureExplicit); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _name_4 = m.getName(); - _builder.append(_name_4, "\t"); - _builder.append("(new "); - String _name_5 = m.getData().getRefType().getType().getName(); - _builder.append(_name_5, "\t"); - _builder.append("("); - DataType _type = m.getData().getRefType().getType(); - String _paramList = this._dataClassGen.paramList(((DataClass) _type)); - _builder.append(_paramList, "\t"); - _builder.append("));"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - _xblockexpression = _builder; - } - return _xblockexpression; - } - - public CharSequence generateDataDriven(final Root root, final ProtocolClass pc) { - CharSequence _xblockexpression = null; - { - final Function1<Message, Boolean> _function = (Message m) -> { - VarDecl _data = m.getData(); - return Boolean.valueOf((!Objects.equal(_data, null))); - }; - final Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(this._roomHelpers.getAllIncomingMessages(pc), _function); - final EList<RoomModel> models = root.getReferencedModels(pc); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("package "); - String _package = this._roomExtensions.getPackage(pc); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.DataReceivePort;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.modelbase.DataSendPort;"); - _builder.newLine(); - _builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;"); - _builder.newLine(); - _builder.newLine(); - CharSequence _userCode = this._procedureHelpers.userCode(pc, 1); - _builder.append(_userCode); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - { - 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.newLine(); - _builder.append("\t"); - CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2); - _builder.append(_userCode_1, "\t"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// send port holds data"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("static public class "); - String _portClassName = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName, "\t"); - _builder.append(" extends DataSendPort {"); - _builder.newLineIfNotEmpty(); - { - for(final Message msg : sentMsgs) { - _builder.append("\t\t"); - _builder.append("private "); - String _typeName = this._typeHelpers.typeName(msg.getData().getRefType().getType()); - _builder.append(_typeName, "\t\t"); - _builder.append(" "); - String _name_2 = msg.getName(); - _builder.append(_name_2, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// constructor"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("public "); - String _portClassName_1 = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName_1, "\t\t"); - _builder.append("(IRTObject parent, String name, int localId) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("super(parent, name, localId);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// getters and setters"); - _builder.newLine(); - { - for(final Message msg_1 : sentMsgs) { - _builder.append("\t\t"); - _builder.append("public void "); - String _name_3 = msg_1.getName(); - _builder.append(_name_3, "\t\t"); - _builder.append("("); - String _typeName_1 = this._typeHelpers.typeName(msg_1.getData().getRefType().getType()); - _builder.append(_typeName_1, "\t\t"); - _builder.append(" "); - String _name_4 = msg_1.getName(); - _builder.append(_name_4, "\t\t"); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("this."); - String _name_5 = msg_1.getName(); - _builder.append(_name_5, "\t\t\t"); - _builder.append(" = "); - String _name_6 = msg_1.getName(); - _builder.append(_name_6, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("public "); - String _typeName_2 = this._typeHelpers.typeName(msg_1.getData().getRefType().getType()); - _builder.append(_typeName_2, "\t\t"); - _builder.append(" "); - String _name_7 = msg_1.getName(); - _builder.append(_name_7, "\t\t"); - _builder.append("() {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("return "); - String _name_8 = msg_1.getName(); - _builder.append(_name_8, "\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// receive port accesses send port"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("static public class "); - String _portClassName_2 = this._roomExtensions.getPortClassName(pc, false); - _builder.append(_portClassName_2, "\t"); - _builder.append(" extends DataReceivePort {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("private "); - String _portClassName_3 = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName_3, "\t\t"); - _builder.append(" peer;"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// constructor"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("public "); - String _portClassName_4 = this._roomExtensions.getPortClassName(pc, false); - _builder.append(_portClassName_4, "\t\t"); - _builder.append("(IRTObject parent, String name, int localId) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t"); - _builder.append("super(parent, name, localId);"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("// getters"); - _builder.newLine(); - { - for(final Message msg_2 : sentMsgs) { - _builder.append("\t\t"); - _builder.append("public "); - String _typeName_3 = this._typeHelpers.typeName(msg_2.getData().getRefType().getType()); - _builder.append(_typeName_3, "\t\t"); - _builder.append(" "); - String _name_9 = msg_2.getName(); - _builder.append(_name_9, "\t\t"); - _builder.append("() {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("if (peer==null)"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t\t"); - _builder.append("return "); - String _defaultValue = this._javaExtensions.defaultValue(msg_2.getData().getRefType().getType()); - _builder.append(_defaultValue, "\t\t\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("return peer."); - String _name_10 = msg_2.getName(); - _builder.append(_name_10, "\t\t\t"); - _builder.append("();"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("protected void connect(DataSendPort dataSendPort) {"); - _builder.newLine(); - _builder.append("\t\t\t"); - _builder.append("if (dataSendPort instanceof "); - String _portClassName_5 = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName_5, "\t\t\t"); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t\t\t"); - _builder.append("peer = ("); - String _portClassName_6 = this._roomExtensions.getPortClassName(pc, true); - _builder.append(_portClassName_6, "\t\t\t\t"); - _builder.append(")dataSendPort;"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("}"); - _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/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java deleted file mode 100644 index dd1bd481d..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.inject.Singleton; -import java.util.Comparator; -import java.util.List; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator; -import org.eclipse.etrice.generator.java.Main; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; - -@Singleton -@SuppressWarnings("all") -public class StateMachineGen extends GenericStateMachineGenerator { - private static class NodeComparator implements Comparator<Node> { - @Override - public int compare(final Node o1, final Node o2) { - int _inheritanceLevel = o1.getInheritanceLevel(); - int _inheritanceLevel_1 = o2.getInheritanceLevel(); - boolean _equals = (_inheritanceLevel == _inheritanceLevel_1); - if (_equals) { - if ((FsmGenExtensions.isLeaf(o1) && FsmGenExtensions.isLeaf(o2))) { - return 0; - } - boolean _isLeaf = FsmGenExtensions.isLeaf(o1); - if (_isLeaf) { - return 1; - } - boolean _isLeaf_1 = FsmGenExtensions.isLeaf(o2); - if (_isLeaf_1) { - return (-1); - } - return 0; - } else { - return Integer.compare(o1.getInheritanceLevel(), o1.getInheritanceLevel()); - } - } - } - - private final StateMachineGen.NodeComparator nodeComparator = new StateMachineGen.NodeComparator(); - - /** - * @param generateImplementation NOT used - */ - @Override - public CharSequence genExtra(final GraphContainer gc, final boolean generateImplementation) { - CharSequence _xblockexpression = null; - { - final List<Node> orderedStateNodes = IterableExtensions.<Node>sortWith(IteratorExtensions.<Node>toList(FsmGenExtensions.getAllStateNodes(gc.getGraph())), this.nodeComparator); - StringConcatenation _builder = new StringConcatenation(); - { - if ((Main.getSettings().isGenerateMSCInstrumentation() || Main.getSettings().isGenerateWithVerboseOutput())) { - _builder.append("// state names"); - _builder.newLine(); - _builder.append("protected static final String stateStrings[] = {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\"<no state>\","); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\"<top>\","); - _builder.newLine(); - { - boolean _hasElements = false; - for(final Node node : orderedStateNodes) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(",", "\t"); - } - _builder.append("\t"); - _builder.append("\""); - StateGraphNode _stateGraphNode = node.getStateGraphNode(); - String _genStatePathName = this._codegenHelpers.getGenStatePathName(((State) _stateGraphNode)); - _builder.append(_genStatePathName, "\t"); - _builder.append("\""); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("};"); - _builder.newLine(); - _builder.newLine(); - } - } - _builder.append("// history"); - _builder.newLine(); - _builder.append("protected int history[] = {NO_STATE, NO_STATE"); - { - for(final Node state : orderedStateNodes) { - _builder.append(", NO_STATE"); - } - } - _builder.append("};"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("private void setState(int new_state) {"); - _builder.newLine(); - { - boolean _isGenerateMSCInstrumentation = Main.getSettings().isGenerateMSCInstrumentation(); - if (_isGenerateMSCInstrumentation) { - _builder.append("\t"); - _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);"); - _builder.newLine(); - } - } - { - boolean _isGenerateWithVerboseOutput = Main.getSettings().isGenerateWithVerboseOutput(); - if (_isGenerateWithVerboseOutput) { - _builder.append("\t"); - _builder.append("if (stateStrings[new_state]!=\"Idle\") {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t"); - _builder.append("System.out.println(\"state switch of \"+getInstancePath() + \": \""); - _builder.newLine(); - _builder.append("\t"); - _builder.append("\t\t\t"); - _builder.append("+ stateStrings[this.state] + \" -> \" + stateStrings[new_state]);"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - } - } - _builder.append("\t"); - _builder.append("this.state = new_state;"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - /** - * if {@code -storeDataObj} is set then a call to {@code finalAction()} is generated - */ - @Override - public CharSequence finalAction() { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isGenerateStoreDataObj = Main.getSettings().isGenerateStoreDataObj(); - if (_isGenerateStoreDataObj) { - _builder.append("finalAction();"); - _builder.newLine(); - } - } - return _builder; - } - - public int getHistorySize(final ExpandedActorClass xpac) { - int _size = this._fSMHelpers.getAllBaseStates(xpac.getActorClass()).size(); - return (_size + 2); - } -} diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java deleted file mode 100644 index 776b89346..000000000 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java +++ /dev/null @@ -1,880 +0,0 @@ -/** - * Copyright (c) 2012 Juergen Haug - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Juergen Haug - */ -package org.eclipse.etrice.generator.java.gen; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.common.converter.TimeConverter; -import org.eclipse.etrice.core.etmap.util.ETMapUtil; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.base.IDataConfiguration; -import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo; -import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.etrice.generator.java.gen.JavaExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.StringExtensions; - -@Singleton -@SuppressWarnings("all") -public class VariableServiceGen { - @Inject - private IGeneratorFileIo fileIO; - - @Inject - @Extension - private JavaExtensions stdExt; - - @Inject - @Extension - private RoomExtensions roomExt; - - @Inject - private IDataConfiguration configExt; - - @Inject - @Extension - private ProcedureHelpers helpers; - - @Inject - @Extension - private TypeHelpers _typeHelpers; - - @Inject - @Extension - private RoomHelpers _roomHelpers; - - public void doGenerate(final Root root, final SubSystemInstance ssi) { - final NodeRef nr = ETMapUtil.getNodeRef(ssi); - final String clsname = this.stdExt.getJavaClassName(nr, ssi); - String _generationTargetPath = this.roomExt.getGenerationTargetPath(ssi.getSubSystemClass()); - String _path = this.roomExt.getPath(ssi.getSubSystemClass()); - final String path = (_generationTargetPath + _path); - String _generationInfoPath = this.roomExt.getGenerationInfoPath(ssi.getSubSystemClass()); - String _path_1 = this.roomExt.getPath(ssi.getSubSystemClass()); - final String infopath = (_generationInfoPath + _path_1); - final String file = (clsname + "VariableService.java"); - this.fileIO.generateFile("generating VariableService implementation", path, infopath, file, this.generate(root, ssi)); - } - - private CharSequence generate(final Root root, final SubSystemInstance comp) { - CharSequence _xblockexpression = null; - { - final NodeRef nr = ETMapUtil.getNodeRef(comp); - final String clsname = this.stdExt.getJavaClassName(nr, comp); - final HashMap<ActorInstance, List<Attribute>> aisAttrMap = new HashMap<ActorInstance, List<Attribute>>(); - final Consumer<ActorInstance> _function = (ActorInstance ai) -> { - boolean _isEmpty = this.configExt.getDynConfigReadAttributes(ai).isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - aisAttrMap.put(ai, this.configExt.getDynConfigReadAttributes(ai)); - } - }; - comp.getAllContainedInstances().forEach(_function); - StringConcatenation _builder = new StringConcatenation(); - _builder.newLine(); - _builder.append("package "); - String _package = this.roomExt.getPackage(comp.getSubSystemClass()); - _builder.append(_package); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("import java.util.Arrays;"); - _builder.newLine(); - _builder.append("import java.util.HashMap;"); - _builder.newLine(); - _builder.append("import java.util.Map;"); - _builder.newLine(); - _builder.append("import org.eclipse.etrice.runtime.java.config.AbstractVariableService;"); - _builder.newLine(); - String _userCode1 = this.configExt.getUserCode1(comp); - _builder.append(_userCode1); - _builder.newLineIfNotEmpty(); - { - HashSet<RoomModel> _roomModels = this.getRoomModels(aisAttrMap.keySet()); - for(final RoomModel model : _roomModels) { - _builder.append("import "); - String _name = model.getName(); - _builder.append(_name); - _builder.append(".*;"); - _builder.newLineIfNotEmpty(); - } - } - _builder.newLine(); - _builder.newLine(); - _builder.append("public class "); - _builder.append(clsname); - _builder.append("VariableService extends AbstractVariableService{"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("private "); - _builder.append(clsname, "\t"); - _builder.append(" subSystem;"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// Actor instances"); - _builder.newLine(); - { - Set<ActorInstance> _keySet = aisAttrMap.keySet(); - for(final ActorInstance ai : _keySet) { - _builder.append("\t"); - _builder.append("private "); - String _name_1 = ai.getActorClass().getName(); - _builder.append(_name_1, "\t"); - _builder.append(" "); - CharSequence _varName = this.getVarName(ai); - _builder.append(_varName, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("public "); - _builder.append(clsname, "\t"); - _builder.append("VariableService("); - _builder.append(clsname, "\t"); - _builder.append(" subSystem) {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("super("); - String _userCode2 = this.configExt.getUserCode2(comp); - _builder.append(_userCode2, "\t\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("this.subSystem = subSystem;"); - _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("protected void initInstances(){"); - _builder.newLine(); - { - Set<ActorInstance> _keySet_1 = aisAttrMap.keySet(); - for(final ActorInstance ai_1 : _keySet_1) { - _builder.append("\t\t"); - CharSequence _varName_1 = this.getVarName(ai_1); - _builder.append(_varName_1, "\t\t"); - _builder.append(" = ("); - String _name_2 = ai_1.getActorClass().getName(); - _builder.append(_name_2, "\t\t"); - _builder.append(")subSystem.getInstance(\""); - String _path = ai_1.getPath(); - _builder.append(_path, "\t\t"); - _builder.append("\");"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected void setAttributeValues(Map<String, Object> values) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("Object object;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("String id = null;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.newLine(); - { - Set<ActorInstance> _keySet_2 = aisAttrMap.keySet(); - for(final ActorInstance ai_2 : _keySet_2) { - { - List<Attribute> _get = aisAttrMap.get(ai_2); - for(final Attribute a : _get) { - _builder.append("\t\t"); - _builder.append("try{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("boolean changed = false;"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - CharSequence _genSetAttributeValues1 = this.genSetAttributeValues1(this.roomExt.<Attribute>union(new ArrayList<Attribute>(), a), ai_2); - _builder.append(_genSetAttributeValues1, "\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("if(changed)"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t\t"); - _builder.append("synchronized("); - CharSequence _varName_2 = this.getVarName(ai_2); - _builder.append(_varName_2, "\t\t\t\t"); - _builder.append("."); - String _name_3 = a.getName(); - String _plus = (_name_3 + "Lock"); - CharSequence _invokeGetter = this.helpers.invokeGetter(_plus, null); - _builder.append(_invokeGetter, "\t\t\t\t"); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t\t\t"); - _builder.append("if("); - CharSequence _varName_3 = this.getVarName(ai_2); - _builder.append(_varName_3, "\t\t\t\t\t"); - _builder.append("."); - String _name_4 = a.getName(); - String _plus_1 = (_name_4 + "Lock"); - CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_plus_1, null); - _builder.append(_invokeGetter_1, "\t\t\t\t\t"); - _builder.append(".isUpdate()){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t\t\t\t"); - CharSequence _genSetAttributeValues2 = this.genSetAttributeValues2(this.roomExt.<Attribute>union(new ArrayList<Attribute>(), a), ai_2); - _builder.append(_genSetAttributeValues2, "\t\t\t\t\t\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("}catch(IllegalArgumentException e){"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("error(id, e);"); - _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("@Override"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("protected Map<String, Object> getAttributeValues(){"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("Map<String, Object> values = new HashMap<String, Object>();"); - _builder.newLine(); - { - Set<ActorInstance> _keySet_3 = aisAttrMap.keySet(); - for(final ActorInstance ai_3 : _keySet_3) { - { - List<Attribute> _get_1 = aisAttrMap.get(ai_3); - for(final Attribute a_1 : _get_1) { - _builder.append("\t\t"); - CharSequence _genGetAttributeValues = this.genGetAttributeValues(this.roomExt.<Attribute>union(new ArrayList<Attribute>(), a_1), ai_3); - _builder.append(_genGetAttributeValues, "\t\t"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _builder.append("\t\t"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return values;"); - _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 writeDataClass(String id, Object dcObject, Map<String, Object> writeMap) {"); - _builder.newLine(); - _builder.append("\t\t"); - HashSet<DataClass> dataClasses = this.getDynConfigDataClasses(aisAttrMap.keySet()); - _builder.newLineIfNotEmpty(); - { - for(final DataClass dc : dataClasses) { - _builder.append("\t\t"); - _builder.append("if(dcObject.getClass().equals("); - String _typeName = this._typeHelpers.typeName(dc); - _builder.append(_typeName, "\t\t"); - _builder.append(".class))"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("\t"); - _builder.append("writeDataClass(id, ("); - String _typeName_1 = this._typeHelpers.typeName(dc); - _builder.append(_typeName_1, "\t\t\t"); - _builder.append(") dcObject, writeTasks);"); - _builder.newLineIfNotEmpty(); - } - } - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("// DataClasses write operations"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - { - HashSet<DataClass> _allDataClasses = this.getAllDataClasses(dataClasses); - for(final DataClass dc_1 : _allDataClasses) { - _builder.append("\t"); - _builder.append("private void writeDataClass(String id, "); - String _typeName_2 = this._typeHelpers.typeName(dc_1); - _builder.append(_typeName_2, "\t"); - _builder.append(" object, Map<String, Object> map){"); - _builder.newLineIfNotEmpty(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(dc_1); - for(final Attribute a_2 : _allAttributes) { - { - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(a_2.getType().getType()); - if (_isEnumerationOrPrimitive) { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("map.put(id+\"/"); - String _name_5 = a_2.getName(); - _builder.append(_name_5, "\t\t"); - _builder.append("\", "); - { - int _size = a_2.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("toObjectArray("); - } - } - _builder.append("object."); - CharSequence _invokeGetter_2 = this.helpers.invokeGetter(a_2.getName(), null); - _builder.append(_invokeGetter_2, "\t\t"); - { - int _size_1 = a_2.getSize(); - boolean _greaterThan_1 = (_size_1 > 0); - if (_greaterThan_1) { - _builder.append(")"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } else { - _builder.append("\t"); - _builder.append("\t"); - _builder.append("writeDataClass(id+\"/"); - String _name_6 = a_2.getName(); - _builder.append(_name_6, "\t\t"); - _builder.append("\", object."); - CharSequence _invokeGetter_3 = this.helpers.invokeGetter(a_2.getName(), null); - _builder.append(_invokeGetter_3, "\t\t"); - _builder.append(", map);"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _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("protected int getPollingTimerUser(){"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("return "); - long _split = TimeConverter.split(this.configExt.getPollingTimerUser(comp), TimeConverter.MILLI_SEC, true); - _builder.append(_split, "\t\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder; - } - return _xblockexpression; - } - - private CharSequence genMinMaxCheck(final List<Attribute> path, final ActorClass ac) { - CharSequence _xblockexpression = null; - { - Attribute a = IterableExtensions.<Attribute>last(path); - String aVarName = this.toAbsolutePath(path, "_"); - String _attrClassConfigMinValue = this.configExt.getAttrClassConfigMinValue(ac, path); - boolean min = (!Objects.equal(_attrClassConfigMinValue, null)); - String _attrClassConfigMaxValue = this.configExt.getAttrClassConfigMaxValue(ac, path); - boolean max = (!Objects.equal(_attrClassConfigMaxValue, null)); - CharSequence _xifexpression = null; - if ((min || max)) { - StringConcatenation _builder = new StringConcatenation(); - { - int _size = a.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("for("); - String _typeName = this._typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName); - _builder.append(" e : "); - _builder.append(aVarName); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - } - } - _builder.append("checkMinMax("); - { - int _size_1 = a.getSize(); - boolean _greaterThan_1 = (_size_1 > 0); - if (_greaterThan_1) { - _builder.append("e"); - } else { - _builder.append(aVarName); - } - } - _builder.append(", "); - { - if (min) { - String _name = ac.getName(); - _builder.append(_name); - _builder.append(".MIN"); - _builder.append(aVarName); - } else { - _builder.append("null"); - } - } - _builder.append(", "); - { - if (max) { - String _name_1 = ac.getName(); - _builder.append(_name_1); - _builder.append(".MAX"); - _builder.append(aVarName); - } else { - _builder.append("null"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _xifexpression = _builder; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - private HashSet<DataClass> getDynConfigDataClasses(final Iterable<ActorInstance> ais) { - final HashSet<DataClass> result = new HashSet<DataClass>(); - final Consumer<ActorInstance> _function = (ActorInstance ai) -> { - final Consumer<Attribute> _function_1 = (Attribute a) -> { - boolean _isDataClass = this._typeHelpers.isDataClass(a.getType().getType()); - if (_isDataClass) { - DataType _type = a.getType().getType(); - result.add(((DataClass) _type)); - } - }; - this.configExt.getDynConfigReadAttributes(ai).forEach(_function_1); - }; - ais.forEach(_function); - return result; - } - - private HashSet<DataClass> getAllDataClasses(final Iterable<DataClass> dcs) { - final HashSet<DataClass> result = new HashSet<DataClass>(); - Iterables.<DataClass>addAll(result, dcs); - final LinkedList<DataClass> visit = new LinkedList<DataClass>(); - Iterables.<DataClass>addAll(visit, dcs); - while ((!visit.isEmpty())) { - { - DataClass dc = visit.pop(); - final Consumer<Attribute> _function = (Attribute a) -> { - boolean _isDataClass = this._typeHelpers.isDataClass(a.getType().getType()); - if (_isDataClass) { - DataType _type = a.getType().getType(); - visit.add(((DataClass) _type)); - } - }; - this._roomHelpers.getAllAttributes(dc).forEach(_function); - } - } - return result; - } - - private HashSet<RoomModel> getRoomModels(final Collection<ActorInstance> ais) { - final HashSet<RoomModel> models = new HashSet<RoomModel>(); - final Consumer<ActorInstance> _function = (ActorInstance ai) -> { - EObject _eContainer = ai.getActorClass().eContainer(); - models.add(((RoomModel) _eContainer)); - }; - ais.forEach(_function); - return models; - } - - private String toAbsolutePath(final List<Attribute> path, final String pathDelim) { - StringConcatenation _builder = new StringConcatenation(); - { - for(final Attribute p : path) { - _builder.append(pathDelim); - String _name = p.getName(); - _builder.append(_name); - } - } - return _builder.toString(); - } - - private CharSequence getVarName(final ActorInstance ai) { - StringConcatenation _builder = new StringConcatenation(); - { - Iterable<String> _drop = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(ai.getPath().split("/"))), 2); - boolean _hasElements = false; - for(final String p : _drop) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate("_", ""); - } - _builder.append(p); - } - } - return _builder; - } - - private CharSequence genGetAttributeValues(final List<Attribute> path, final ActorInstance ai) { - CharSequence _xblockexpression = null; - { - final Attribute a = IterableExtensions.<Attribute>last(path); - CharSequence _xifexpression = null; - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(a.getType().getType()); - if (_isEnumerationOrPrimitive) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("values.put(\""); - String _path = ai.getPath(); - _builder.append(_path); - String _absolutePath = this.toAbsolutePath(path, "/"); - _builder.append(_absolutePath); - _builder.append("\", "); - { - int _size = a.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _builder.append("toObjectArray("); - } - } - CharSequence _varName = this.getVarName(ai); - _builder.append(_varName); - _builder.append("."); - CharSequence _invokeGetters = this.helpers.invokeGetters(path, null); - _builder.append(_invokeGetters); - { - int _size_1 = a.getSize(); - boolean _greaterThan_1 = (_size_1 > 0); - if (_greaterThan_1) { - _builder.append(")"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _xifexpression = _builder; - } else { - CharSequence _xifexpression_1 = null; - boolean _isDataClass = this._typeHelpers.isDataClass(a.getType().getType()); - if (_isDataClass) { - CharSequence _xblockexpression_1 = null; - { - DataType _type = a.getType().getType(); - DataClass dataClass = ((DataClass) _type); - StringConcatenation _builder_1 = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(dataClass); - for(final Attribute at : _allAttributes) { - CharSequence _genGetAttributeValues = this.genGetAttributeValues(this.roomExt.<Attribute>union(path, at), ai); - _builder_1.append(_genGetAttributeValues); - _builder_1.newLineIfNotEmpty(); - } - } - _xblockexpression_1 = _builder_1; - } - _xifexpression_1 = _xblockexpression_1; - } - _xifexpression = _xifexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - private CharSequence genSetAttributeValues1(final List<Attribute> path, final ActorInstance ai) { - CharSequence _xblockexpression = null; - { - Attribute a = IterableExtensions.<Attribute>last(path); - String aVarName = this.toAbsolutePath(path, "_"); - CharSequence _xifexpression = null; - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(a.getType().getType()); - if (_isEnumerationOrPrimitive) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("id = \""); - String _path = ai.getPath(); - _builder.append(_path); - String _absolutePath = this.toAbsolutePath(path, "/"); - _builder.append(_absolutePath); - _builder.append("\";"); - _builder.newLineIfNotEmpty(); - { - int _size = a.getSize(); - boolean _equals = (_size == 0); - if (_equals) { - String _wrapper = this.stdExt.toWrapper(this._typeHelpers.typeName(a.getType().getType())); - _builder.append(_wrapper); - } else { - String _typeName = this._typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName); - _builder.append("[]"); - } - } - _builder.append(" "); - _builder.append(aVarName); - _builder.append(" = null;"); - _builder.newLineIfNotEmpty(); - _builder.append("object = values.get(id);"); - _builder.newLine(); - _builder.append("if(object != null){"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(aVarName, "\t"); - _builder.append(" = ensure"); - String _firstUpper = StringExtensions.toFirstUpper(this._typeHelpers.typeName(a.getType().getType())); - _builder.append(_firstUpper, "\t"); - { - int _size_1 = a.getSize(); - boolean _greaterThan = (_size_1 > 0); - if (_greaterThan) { - _builder.append("Array"); - } - } - _builder.append("(object"); - { - int _size_2 = a.getSize(); - boolean _greaterThan_1 = (_size_2 > 0); - if (_greaterThan_1) { - _builder.append(", "); - int _size_3 = a.getSize(); - _builder.append(_size_3, "\t"); - } - } - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _genMinMaxCheck = this.genMinMaxCheck(path, ai.getActorClass()); - _builder.append(_genMinMaxCheck, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("if(!"); - { - int _size_4 = a.getSize(); - boolean _equals_1 = (_size_4 == 0); - if (_equals_1) { - _builder.append(aVarName, "\t"); - _builder.append(".equals("); - } else { - _builder.append("Arrays.equals("); - _builder.append(aVarName, "\t"); - _builder.append(", "); - } - } - _builder.append("("); - { - int _size_5 = a.getSize(); - boolean _equals_2 = (_size_5 == 0); - if (_equals_2) { - String _wrapper_1 = this.stdExt.toWrapper(this._typeHelpers.typeName(a.getType().getType())); - _builder.append(_wrapper_1, "\t"); - } else { - String _typeName_1 = this._typeHelpers.typeName(a.getType().getType()); - _builder.append(_typeName_1, "\t"); - _builder.append("[]"); - } - } - _builder.append(")getDiffMap().get(id)))"); - _builder.newLineIfNotEmpty(); - _builder.append("\t\t"); - _builder.append("changed = true;"); - _builder.newLine(); - _builder.append("} else"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("warning(id, \"is missing\");"); - _builder.newLine(); - _xifexpression = _builder; - } else { - CharSequence _xifexpression_1 = null; - boolean _isDataClass = this._typeHelpers.isDataClass(a.getType().getType()); - if (_isDataClass) { - CharSequence _xblockexpression_1 = null; - { - DataType _type = a.getType().getType(); - DataClass dataClass = ((DataClass) _type); - StringConcatenation _builder_1 = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(dataClass); - for(final Attribute at : _allAttributes) { - CharSequence _genSetAttributeValues1 = this.genSetAttributeValues1(this.roomExt.<Attribute>union(path, at), ai); - _builder_1.append(_genSetAttributeValues1); - _builder_1.newLineIfNotEmpty(); - } - } - _xblockexpression_1 = _builder_1; - } - _xifexpression_1 = _xblockexpression_1; - } - _xifexpression = _xifexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } - - private CharSequence genSetAttributeValues2(final List<Attribute> path, final ActorInstance ai) { - CharSequence _xblockexpression = null; - { - Attribute a = IterableExtensions.<Attribute>last(path); - String aVarName = this.toAbsolutePath(path, "_"); - CharSequence _xifexpression = null; - boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(a.getType().getType()); - if (_isEnumerationOrPrimitive) { - CharSequence _xblockexpression_1 = null; - { - String _xifexpression_1 = null; - int _size = path.size(); - boolean _greaterThan = (_size > 1); - if (_greaterThan) { - int _size_1 = path.size(); - int _minus = (_size_1 - 1); - CharSequence _invokeGetters = this.helpers.invokeGetters(IterableExtensions.<Attribute>take(path, _minus), null); - _xifexpression_1 = (_invokeGetters + "."); - } else { - _xifexpression_1 = ""; - } - final String getters = _xifexpression_1; - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if("); - _builder.append(aVarName); - _builder.append(" != null){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - CharSequence _varName = this.getVarName(ai); - _builder.append(_varName, "\t"); - _builder.append("."); - _builder.append(getters, "\t"); - CharSequence _invokeSetter = this.helpers.invokeSetter(a.getName(), null, aVarName); - _builder.append(_invokeSetter, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("getDiffMap().put(\""); - String _path = ai.getPath(); - _builder.append(_path, "\t"); - String _absolutePath = this.toAbsolutePath(path, "/"); - _builder.append(_absolutePath, "\t"); - _builder.append("\", "); - _builder.append(aVarName, "\t"); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression_1 = _builder; - } - _xifexpression = _xblockexpression_1; - } else { - CharSequence _xifexpression_1 = null; - boolean _isDataClass = this._typeHelpers.isDataClass(a.getType().getType()); - if (_isDataClass) { - CharSequence _xblockexpression_2 = null; - { - DataType _type = a.getType().getType(); - final DataClass dataClass = ((DataClass) _type); - StringConcatenation _builder = new StringConcatenation(); - { - List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(dataClass); - for(final Attribute at : _allAttributes) { - CharSequence _genSetAttributeValues2 = this.genSetAttributeValues2(this.roomExt.<Attribute>union(path, at), ai); - _builder.append(_genSetAttributeValues2); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression_2 = _builder; - } - _xifexpression_1 = _xblockexpression_2; - } - _xifexpression = _xifexpression_1; - } - _xblockexpression = _xifexpression; - } - return _xblockexpression; - } -} diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java deleted file mode 100644 index 0d170c02c..000000000 --- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java +++ /dev/null @@ -1,434 +0,0 @@ -/** - * Copyright (c) 2012 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.generic; - -import com.google.inject.Inject; -import org.eclipse.etrice.core.fsm.fSM.GuardedTransition; -import org.eclipse.etrice.core.fsm.fSM.ModelComponent; -import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition; -import org.eclipse.etrice.core.fsm.fSM.RefinedState; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.fsm.fSM.Trigger; -import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition; -import org.eclipse.etrice.core.fsm.util.FSMHelpers; -import org.eclipse.etrice.core.genmodel.fsm.TriggerExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.generator.fsm.generic.AbstractStateMachineGenerator; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -/** - * A target language independent generator of the state machine implementation - */ -@SuppressWarnings("all") -public class GenericStateMachineGenerator extends AbstractStateMachineGenerator { - @Inject - @Extension - protected TriggerExtensions _triggerExtensions; - - @Inject - @Extension - protected FSMHelpers _fSMHelpers; - - /** - * generates the code of the whole state machine, consisting of constants + methods - * - * @param xpmc the {@link ExpandedModelComponent} - * @return the generated code - */ - public CharSequence genStateMachine(final GraphContainer gc) { - StringConcatenation _builder = new StringConcatenation(); - CharSequence _genStateMachineConstants = this.genStateMachineConstants(gc); - _builder.append(_genStateMachineConstants); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - CharSequence _genStateMachineMethods = this.genStateMachineMethods(gc, true); - _builder.append(_genStateMachineMethods); - _builder.newLineIfNotEmpty(); - return _builder; - } - - /** - * generates the constants for the state machine - */ - public CharSequence genStateMachineConstants(final GraphContainer gc) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* state IDs */"); - _builder.newLine(); - String _genStateIdConstants = this.genStateIdConstants(gc); - _builder.append(_genStateIdConstants); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* transition chains */"); - _builder.newLine(); - String _genTransitionChainConstants = this.genTransitionChainConstants(gc); - _builder.append(_genTransitionChainConstants); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* triggers */"); - _builder.newLine(); - String _genTriggerConstants = this.genTriggerConstants(gc); - _builder.append(_genTriggerConstants); - _builder.newLineIfNotEmpty(); - return _builder; - } - - /** - * generates the methods for the state machine codes and state switching - * - * @param xpmc the {@link ExpandedModelComponent} - * @param generateImplemenation or declaration only - * @return the generated code - */ - public CharSequence genStateMachineMethods(final GraphContainer gc, final boolean generateImplementation) { - StringConcatenation _builder = new StringConcatenation(); - CharSequence _genExtra = this.genExtra(gc, generateImplementation); - _builder.append(_genExtra); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* Entry and Exit Codes */"); - _builder.newLine(); - String _genEntryAndExitCodes = this.genEntryAndExitCodes(gc, generateImplementation); - _builder.append(_genEntryAndExitCodes); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* Action Codes */"); - _builder.newLine(); - String _genActionCodes = this.genActionCodes(gc, generateImplementation); - _builder.append(_genActionCodes); - _builder.newLineIfNotEmpty(); - _builder.newLine(); - _builder.append("/* State Switch Methods */"); - _builder.newLine(); - String _genStateSwitchMethods = this.genStateSwitchMethods(gc, generateImplementation); - _builder.append(_genStateSwitchMethods); - _builder.newLineIfNotEmpty(); - return _builder; - } - - /** - * generate a transition guard if applicable - * - * @param tt a {@link TriggeredTransition} - * @param trigger a trigger string - * @param xpmc an expanded actor class - * @return the generated code - */ - @Override - public String genTriggeredTransitionGuard(final Link tt, final String trigger, final GraphContainer gc) { - String _xblockexpression = null; - { - TransitionBase _transition = tt.getTransition(); - final Function1<Trigger, Boolean> _function = (Trigger trig) -> { - return Boolean.valueOf(this._triggerExtensions.isMatching(trig, trigger)); - }; - final Trigger tr = IterableExtensions.<Trigger>findFirst(((TriggeredTransition) _transition).getTriggers(), _function); - StringConcatenation _builder = new StringConcatenation(); - { - boolean _hasGuard = this._fSMHelpers.hasGuard(tr); - if (_hasGuard) { - _builder.append("if ("); - String _translatedCode = this.translator.getTranslatedCode(tr.getGuard().getGuard()); - _builder.append(_translatedCode); - _builder.append(")"); - _builder.newLineIfNotEmpty(); - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - @Override - public String genGuardedTransitionGuard(final Link link, final String trigger, final GraphContainer gc) { - StringConcatenation _builder = new StringConcatenation(); - TransitionBase _transition = link.getTransition(); - String _translatedCode = this.translator.getTranslatedCode(((GuardedTransition) _transition).getGuard()); - _builder.append(_translatedCode); - _builder.newLineIfNotEmpty(); - return _builder.toString(); - } - - @Override - public String genActionCodeMethod(final GraphContainer gc, final Link link, final boolean generateImplementation) { - String _xblockexpression = null; - { - boolean hasArgs = ((!link.getChainHeads().isEmpty()) && IterableExtensions.<Link>forall(link.getChainHeads(), ((Function1<Link, Boolean>) (Link it) -> { - return Boolean.valueOf(((it.getTransition() instanceof NonInitialTransition) && (!(it.getTransition() instanceof GuardedTransition)))); - }))); - final String opScope = this.langExt.operationScope(this.getClassName(gc), false); - String _xifexpression = null; - boolean _usesInheritance = this.langExt.usesInheritance(); - if (_usesInheritance) { - _xifexpression = opScope; - } else { - _xifexpression = ""; - } - final String opScopePriv = _xifexpression; - String _pointerLiteral = this.langExt.pointerLiteral(); - final String ifItemPtr = ("InterfaceItemBase" + _pointerLiteral); - String _xifexpression_1 = null; - boolean _usesPointers = this.langExt.usesPointers(); - if (_usesPointers) { - _xifexpression_1 = ("const " + ifItemPtr); - } else { - _xifexpression_1 = ifItemPtr; - } - final String constIfItemPtr = _xifexpression_1; - String _xifexpression_2 = null; - if (generateImplementation) { - StringConcatenation _builder = new StringConcatenation(); - String _accessLevelProtected = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected); - _builder.append("void "); - _builder.append(opScopePriv); - String _actionCodeOperationName = this._codegenHelpers.getActionCodeOperationName(link.getTransition()); - _builder.append(_actionCodeOperationName); - _builder.append("("); - String _selfPointer = this.langExt.selfPointer(this.getClassName(gc), hasArgs); - _builder.append(_selfPointer); - { - if (hasArgs) { - _builder.append(constIfItemPtr); - _builder.append(" ifitem"); - String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(gc, link); - _builder.append(_generateArgumentList); - } - } - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append(" "); - String _translatedCode = this.translator.getTranslatedCode(link.getTransition().getAction()); - _builder.append(_translatedCode, " "); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _xifexpression_2 = _builder.toString(); - } else { - StringConcatenation _builder_1 = new StringConcatenation(); - String _accessLevelProtected_1 = this.langExt.accessLevelProtected(); - _builder_1.append(_accessLevelProtected_1); - String _makeOverridable = this.langExt.makeOverridable(); - _builder_1.append(_makeOverridable); - _builder_1.append("void "); - String _actionCodeOperationName_1 = this._codegenHelpers.getActionCodeOperationName(link.getTransition()); - _builder_1.append(_actionCodeOperationName_1); - _builder_1.append("("); - String _selfPointer_1 = this.langExt.selfPointer(this.getClassName(gc), hasArgs); - _builder_1.append(_selfPointer_1); - { - if (hasArgs) { - _builder_1.append(constIfItemPtr); - _builder_1.append(" ifitem"); - String _generateArgumentList_1 = this.transitionChainGenerator.generateArgumentList(gc, link); - _builder_1.append(_generateArgumentList_1); - } - } - _builder_1.append(");"); - _builder_1.newLineIfNotEmpty(); - _xifexpression_2 = _builder_1.toString(); - } - _xblockexpression = _xifexpression_2; - } - return _xblockexpression; - } - - /** - * generate action code method implementations or declarations - * - * @param xpax the {@link ExpandedModelComponent} - * @param state the {@link State} - * @param generateImplementation if only declarations should be generated then <code>false</code> has to be passed - * @return the generated code - */ - @Override - public String genActionCodeMethods(final GraphContainer gc, final Node node, final boolean generateImplementation) { - String _xblockexpression = null; - { - final ModelComponent mc = this._fSMHelpers.getModelComponent(gc); - final String selfPtr = this.langExt.selfPointer(this.getClassName(gc), false); - final String opScope = this.langExt.operationScope(this.getClassName(gc), false); - String _xifexpression = null; - boolean _usesInheritance = this.langExt.usesInheritance(); - if (_usesInheritance) { - _xifexpression = opScope; - } else { - _xifexpression = ""; - } - final String opScopePriv = _xifexpression; - StateGraphNode _stateGraphNode = node.getStateGraphNode(); - final State state = ((State) _stateGraphNode); - final String entryOp = this._codegenHelpers.getEntryCodeOperationName(state); - final String exitOp = this._codegenHelpers.getExitCodeOperationName(state); - final String doOp = this._codegenHelpers.getDoCodeOperationName(state); - String entry = this.translator.getTranslatedCode(state.getEntryCode()); - String exit = this.translator.getTranslatedCode(state.getExitCode()); - String docode = this.translator.getTranslatedCode(state.getDoCode()); - if ((state instanceof RefinedState)) { - final String inhEntry = this.translator.getTranslatedCode(this._fSMHelpers.getInheritedEntryCode(((RefinedState)state))); - final String inhExit = this.translator.getTranslatedCode(this._fSMHelpers.getInheritedExitCode(((RefinedState)state))); - final String inhDo = this.translator.getTranslatedCode(this._fSMHelpers.getInheritedDoCode(((RefinedState)state))); - boolean _usesInheritance_1 = this.langExt.usesInheritance(); - if (_usesInheritance_1) { - final String baseName = this.getClassName(mc.getBase()); - boolean _hasDetailCode = this._fSMHelpers.hasDetailCode(this._fSMHelpers.getInheritedEntryCode(((RefinedState)state))); - if (_hasDetailCode) { - String _superCall = this.langExt.superCall(baseName, entryOp, ""); - String _plus = (_superCall + entry); - entry = _plus; - } - boolean _hasDetailCode_1 = this._fSMHelpers.hasDetailCode(this._fSMHelpers.getInheritedExitCode(((RefinedState)state))); - if (_hasDetailCode_1) { - String _superCall_1 = this.langExt.superCall(baseName, exitOp, ""); - String _plus_1 = (exit + _superCall_1); - exit = _plus_1; - } - boolean _hasDetailCode_2 = this._fSMHelpers.hasDetailCode(this._fSMHelpers.getInheritedDoCode(((RefinedState)state))); - if (_hasDetailCode_2) { - String _superCall_2 = this.langExt.superCall(baseName, doOp, ""); - String _plus_2 = (_superCall_2 + docode); - docode = _plus_2; - } - } else { - entry = (inhEntry + entry); - exit = (exit + inhExit); - docode = (inhDo + docode); - } - } - StringConcatenation _builder = new StringConcatenation(); - { - boolean _isEmpty = entry.isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - { - if (generateImplementation) { - String _accessLevelProtected = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected); - _builder.append("void "); - _builder.append(opScopePriv); - _builder.append(entryOp); - _builder.append("("); - _builder.append(selfPtr); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append(entry, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } else { - String _accessLevelProtected_1 = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected_1); - String _makeOverridable = this.langExt.makeOverridable(); - _builder.append(_makeOverridable); - _builder.append("void "); - _builder.append(entryOp); - _builder.append("("); - _builder.append(selfPtr); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - { - boolean _isEmpty_1 = exit.isEmpty(); - boolean _not_1 = (!_isEmpty_1); - if (_not_1) { - { - if (generateImplementation) { - String _accessLevelProtected_2 = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected_2); - _builder.append("void "); - _builder.append(opScopePriv); - _builder.append(exitOp); - _builder.append("("); - _builder.append(selfPtr); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append(exit, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } else { - String _accessLevelProtected_3 = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected_3); - String _makeOverridable_1 = this.langExt.makeOverridable(); - _builder.append(_makeOverridable_1); - _builder.append("void "); - _builder.append(exitOp); - _builder.append("("); - _builder.append(selfPtr); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - { - boolean _isEmpty_2 = docode.isEmpty(); - boolean _not_2 = (!_isEmpty_2); - if (_not_2) { - { - if (generateImplementation) { - String _accessLevelProtected_4 = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected_4); - _builder.append(" void "); - _builder.append(opScopePriv); - _builder.append(doOp); - _builder.append("("); - _builder.append(selfPtr); - _builder.append(") {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append(docode, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } else { - String _accessLevelProtected_5 = this.langExt.accessLevelProtected(); - _builder.append(_accessLevelProtected_5); - String _makeOverridable_2 = this.langExt.makeOverridable(); - _builder.append(_makeOverridable_2); - _builder.append("void "); - _builder.append(doOp); - _builder.append("("); - _builder.append(selfPtr); - _builder.append(");"); - _builder.newLineIfNotEmpty(); - } - } - } - } - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - /** - * let derived class add extra code after definition of constants - * - * @param xpmc an expanded actor class - * @param generateImplementation or declaration only - * @return the generated code - */ - public CharSequence genExtra(final GraphContainer gc, final boolean generateImplementation) { - StringConcatenation _builder = new StringConcatenation(); - return _builder; - } -} diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java deleted file mode 100644 index 8d986e4ab..000000000 --- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.generic; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.io.File; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.etrice.core.genmodel.etricegen.Root; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.generator.generic.RoomExtensions; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.generator.JavaIoFileSystemAccess; -import org.eclipse.xtext.xbase.lib.Extension; - -/** - * A class that is used to recursively erase all folders receiving generated code - * an to place a readme file into those folders. - */ -@Singleton -@SuppressWarnings("all") -public class PrepareFileSystem { - @Inject - @Extension - private RoomExtensions _roomExtensions; - - @Inject - private JavaIoFileSystemAccess fileAccess; - - @Inject - private ILogger logger; - - public void prepareCodeTargetPaths(final Resource resource) { - Set<String> pathes = new HashSet<String>(); - EList<EObject> _contents = resource.getContents(); - for (final EObject e : _contents) { - if ((e instanceof Root)) { - EList<RoomModel> _models = ((Root) e).getModels(); - for (final RoomModel mdl : _models) { - { - final String tgtpath = this._roomExtensions.getGenerationTargetPath(mdl); - if (((!Objects.equal(tgtpath, null)) && (!tgtpath.isEmpty()))) { - pathes.add(tgtpath); - } - } - } - } - } - this.prepare(pathes); - } - - public void prepareDocTargetPaths(final Resource resource) { - Set<String> pathes = new HashSet<String>(); - EList<EObject> _contents = resource.getContents(); - for (final EObject e : _contents) { - if ((e instanceof Root)) { - EList<RoomModel> _models = ((Root) e).getModels(); - for (final RoomModel mdl : _models) { - { - final String tgtpath = this._roomExtensions.getDocGenerationTargetPath(mdl); - if (((!Objects.equal(tgtpath, null)) && (!tgtpath.isEmpty()))) { - pathes.add(tgtpath); - } - } - } - } - } - this.prepare(pathes); - } - - /** - * Recursively erase all folders receiving generated code - * and place a readme file in those folders. - * The folders are determined from the used models of every generator - * model found in the resource. - * - * @param resource a {@link Resource} - */ - public void prepare(final Collection<String> pathes) { - for (final String path : pathes) { - { - this.logger.logInfo(("clearing " + path)); - File f = new File(path); - this.eraseContents(f); - this.fileAccess.setOutputPath(path); - this.fileAccess.generateFile("readme.txt", this.readmeText()); - } - } - } - - private void eraseContents(final File f) { - boolean _isDirectory = f.isDirectory(); - if (_isDirectory) { - File[] children = f.listFiles(); - for (final File child : children) { - boolean _not = (!(child.isDirectory() && child.getName().equals("images"))); - if (_not) { - this.eraseContents(child); - child.delete(); - } - } - } - } - - private CharSequence readmeText() { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("This directory is an eTrice code generation target."); - _builder.newLine(); - _builder.append("It will be erased every time the generator is executed."); - _builder.newLine(); - _builder.newLine(); - _builder.append("DO NOT PLACE OTHER FILES HERE!"); - _builder.newLine(); - return _builder; - } -} diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java deleted file mode 100644 index e26eb6101..000000000 --- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java +++ /dev/null @@ -1,857 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - * Thomas Schuetz (refactoring, adapted for other target languages) - */ -package org.eclipse.etrice.generator.generic; - -import com.google.common.base.Objects; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.etrice.core.fsm.fSM.DetailCode; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorContainerClass; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.ClassStructor; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.Operation; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RefableType; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.etrice.core.room.util.RoomHelpers; -import org.eclipse.etrice.generator.base.AbstractGenerator; -import org.eclipse.etrice.generator.generic.ILanguageExtension; -import org.eclipse.etrice.generator.generic.TypeHelpers; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.StringExtensions; - -/** - * A collection of methods for generation of user code, attributes with getters and setters - * and operations. - */ -@Singleton -@SuppressWarnings("all") -public class ProcedureHelpers { - protected final String NEWLINE = System.getProperty("line.separator"); - - @Inject - @Extension - protected RoomHelpers _roomHelpers; - - @Inject - @Extension - protected TypeHelpers _typeHelpers; - - @Inject - protected ILanguageExtension languageExt; - - @Inject - protected ILogger logger; - - /** - * @param dc a {@link DataClass} - * @param id 0, 1 or 2 for the corresponding user codes - * @return the generated code - */ - public CharSequence userCode(final DataClass dc, final int id) { - CharSequence _switchResult = null; - switch (id) { - case 1: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode1(dc)); - break; - case 2: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode2(dc)); - break; - case 3: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode3(dc)); - break; - } - return _switchResult; - } - - /** - * @param pc a {@link ProtocolClass} - * @param id 0, 1 or 2 for the corresponding user codes - * @return the generated code - */ - public CharSequence userCode(final ProtocolClass pc, final int id) { - CharSequence _switchResult = null; - switch (id) { - case 1: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode1(pc)); - break; - case 2: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode2(pc)); - break; - case 3: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode3(pc)); - break; - } - return _switchResult; - } - - /** - * @param ac an {@link ActorContainerClass} - * @param id 0, 1 or 2 for the corresponding user codes - * @return the generated code - */ - public CharSequence userCode(final ActorContainerClass ac, final int id, final boolean includeInherited) { - CharSequence _xifexpression = null; - if (includeInherited) { - CharSequence _switchResult = null; - switch (id) { - case 1: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode1(ac)); - break; - case 2: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode2(ac)); - break; - case 3: - _switchResult = this.userCode(this._roomHelpers.getDeepUserCode3(ac)); - break; - } - _xifexpression = _switchResult; - } else { - CharSequence _switchResult_1 = null; - switch (id) { - case 1: - _switchResult_1 = this.userCode(ac.getUserCode1()); - break; - case 2: - _switchResult_1 = this.userCode(ac.getUserCode2()); - break; - case 3: - _switchResult_1 = this.userCode(ac.getUserCode3()); - break; - } - _xifexpression = _switchResult_1; - } - return _xifexpression; - } - - /** - * @param dc some {@link DetailCode} - * @return a string containing the expanded code surrounded by - * comments (no tag replacement will happen) - */ - public CharSequence userCode(final DetailCode dc) { - return this.userCode(this._roomHelpers.getDetailCode(dc)); - } - - private CharSequence userCode(final String code) { - StringConcatenation _builder = new StringConcatenation(); - { - if (((!Objects.equal(code, null)) && (!code.isEmpty()))) { - _builder.append("/*--------------------- begin user code ---------------------*/"); - _builder.newLine(); - _builder.append(code); - _builder.newLineIfNotEmpty(); - _builder.append("/*--------------------- end user code ---------------------*/"); - _builder.newLine(); - } - } - return _builder; - } - - /** - * @param attributes a list of {@link Attribute}s - * @return code declaring the attributes - */ - public CharSequence attributes(final List<Attribute> attributes) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/*--------------------- attributes ---------------------*/"); - _builder.newLine(); - { - for(final Attribute it : attributes) { - CharSequence _attributeDeclaration = this.attributeDeclaration(it); - _builder.append(_attributeDeclaration); - _builder.newLineIfNotEmpty(); - } - } - return _builder; - } - - /** - * @param attribute an {@link Attribute} - * @return the code declaring the attribute - */ - public CharSequence attributeDeclaration(final Attribute attribute) { - StringConcatenation _builder = new StringConcatenation(); - String _accessLevelPublic = this.languageExt.accessLevelPublic(); - _builder.append(_accessLevelPublic); - _builder.append(" "); - String _declarationString = this.declarationString(attribute); - _builder.append(_declarationString); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - return _builder; - } - - /** - * @param attribute an {@link Attribute} - * @return the code for an array initializer - */ - public String arrayInitializer(final Attribute att) { - String _xifexpression = null; - String _defaultValueLiteral = att.getDefaultValueLiteral(); - boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null)); - if (_notEquals) { - _xifexpression = att.getDefaultValueLiteral(); - } else { - _xifexpression = this.languageExt.defaultValue(att.getType().getType()); - } - final String dflt = _xifexpression; - boolean _startsWith = dflt.startsWith("{"); - if (_startsWith) { - int _size = ((List<String>)Conversions.doWrapArray(dflt.split(","))).size(); - int _size_1 = att.getSize(); - boolean _notEquals_1 = (_size != _size_1); - if (_notEquals_1) { - String _name = att.getName(); - String _plus = ("WARNING: array size determined by initializer differs from attribute size (" + _name); - String _plus_1 = (_plus + "["); - int _size_2 = att.getSize(); - String _plus_2 = (_plus_1 + Integer.valueOf(_size_2)); - String _plus_3 = (_plus_2 + "] <-> "); - String _plus_4 = (_plus_3 + dflt); - String _plus_5 = (_plus_4 + ")"); - this.logger.logInfo(_plus_5); - } - return dflt; - } - String result = "{"; - int i = 0; - while ((i < att.getSize())) { - { - result = (result + dflt); - i = (i + 1); - int _size_3 = att.getSize(); - boolean _lessThan = (i < _size_3); - if (_lessThan) { - result = (result + ", "); - } - } - } - return (result + "}"); - } - - /** - * @param EnumTest a list of {@link Attribute}s - * @param classname the name of the defining class - * @return code declaring setters and getters for the attributes - */ - public CharSequence attributeSettersGettersDeclaration(final List<Attribute> attributes, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* --------------------- attribute setters and getters */"); - _builder.newLine(); - { - for(final Attribute attribute : attributes) { - CharSequence _setterHeader = this.setterHeader(attribute, classname); - _builder.append(_setterHeader); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - CharSequence _terHeader = this.getterHeader(attribute, classname); - _builder.append(_terHeader); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - return _builder; - } - - /** - * @param EnumTest a list of {@link Attribute}s - * @param classname the name of the defining class - * @return code defining setters and getters for the attributes - */ - public CharSequence attributeSettersGettersImplementation(final List<Attribute> attributes, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* --------------------- attribute setters and getters */"); - _builder.newLine(); - { - for(final Attribute attribute : attributes) { - CharSequence _setterHeader = this.setterHeader(attribute, classname); - _builder.append(_setterHeader); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t "); - String _memberAccess = this.languageExt.memberAccess(); - _builder.append(_memberAccess, "\t "); - String _name = attribute.getName(); - _builder.append(_name, "\t "); - _builder.append(" = "); - String _name_1 = attribute.getName(); - _builder.append(_name_1, "\t "); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - CharSequence _terHeader = this.getterHeader(attribute, classname); - _builder.append(_terHeader); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return "); - String _memberAccess_1 = this.languageExt.memberAccess(); - _builder.append(_memberAccess_1, "\t"); - String _name_2 = attribute.getName(); - _builder.append(_name_2, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - return _builder; - } - - /** - * @param attribute an {@link Attribute} - * @param classname the name of the defining class - * @return code for the attribute setter declaration - */ - protected CharSequence setterHeader(final Attribute attribute, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - String _accessLevelPublic = this.languageExt.accessLevelPublic(); - _builder.append(_accessLevelPublic); - _builder.append("void set"); - String _firstUpper = StringExtensions.toFirstUpper(attribute.getName()); - _builder.append(_firstUpper); - _builder.append("("); - String _selfPointer = this.languageExt.selfPointer(classname, true); - _builder.append(_selfPointer); - String _argList = this.argList(Collections.<Attribute>unmodifiableList(CollectionLiterals.<Attribute>newArrayList(attribute))); - _builder.append(_argList); - _builder.append(")"); - return _builder; - } - - /** - * @param attribute an {@link Attribute} - * @param classname the name of the defining class - * @return code for the attribute getter declaration - */ - protected CharSequence getterHeader(final Attribute attribute, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - String _accessLevelPublic = this.languageExt.accessLevelPublic(); - _builder.append(_accessLevelPublic); - String _signatureString = this.signatureString(attribute); - _builder.append(_signatureString); - _builder.append(" get"); - String _firstUpper = StringExtensions.toFirstUpper(attribute.getName()); - _builder.append(_firstUpper); - _builder.append("("); - String _selfPointer = this.languageExt.selfPointer(classname, false); - _builder.append(_selfPointer); - _builder.append(")"); - return _builder; - } - - /** - * @param attributes a list of {@link Attribute}s - * @return an argument list for the attributes - */ - public String argList(final Iterable<Attribute> attributes) { - final Function1<Attribute, String> _function = (Attribute it) -> { - String _signatureString = this.signatureString(it); - String _plus = (_signatureString + " "); - String _name = it.getName(); - return (_plus + _name); - }; - return IterableExtensions.join(IterableExtensions.<Attribute, String>map(attributes, _function), ", "); - } - - /** - * @param EnumTest an iterable of {@link Attribute}s representing a path - * @param classname the name of the defining class - * @return the invocation code for the call of a setter - */ - public CharSequence invokeGetters(final Iterable<Attribute> path, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - { - boolean _hasElements = false; - for(final Attribute a : path) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(".", ""); - } - CharSequence _invokeGetter = this.invokeGetter(a.getName(), classname); - _builder.append(_invokeGetter); - } - } - return _builder; - } - - /** - * @param typeName the type name of the attribute - * @param name the name of the attribute - * @param classname the name of the type defining the getter - * @return code defining the attribute getter - */ - public CharSequence getterImplementation(final String typeName, final String name, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - String _accessLevelPublic = this.languageExt.accessLevelPublic(); - _builder.append(_accessLevelPublic); - _builder.append(typeName); - _builder.append(" get"); - String _firstUpper = StringExtensions.toFirstUpper(name); - _builder.append(_firstUpper); - _builder.append(" ("); - String _selfPointer = this.languageExt.selfPointer(classname, false); - _builder.append(_selfPointer); - _builder.append("){"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.append("return "); - String _memberAccess = this.languageExt.memberAccess(); - _builder.append(_memberAccess, "\t"); - _builder.append(name, "\t"); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - return _builder; - } - - /** - * @param name the name of the attribute - * @param classname the name of the type defining the getter - * @return code defining the getter call - */ - public CharSequence invokeGetter(final String name, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("get"); - String _firstUpper = StringExtensions.toFirstUpper(name); - _builder.append(_firstUpper); - _builder.append("("); - String _selfPointer = this.languageExt.selfPointer(classname, true); - _builder.append(_selfPointer); - _builder.append(")"); - return _builder; - } - - /** - * @param name the name of the attribute - * @param classname the name of the type defining the getter - * @param value the value to be assigned - * @return code defining the setter call - */ - public CharSequence invokeSetter(final String name, final String classname, final String value) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("set"); - String _firstUpper = StringExtensions.toFirstUpper(name); - _builder.append(_firstUpper); - _builder.append("("); - String _selfPointer = this.languageExt.selfPointer(classname, true); - _builder.append(_selfPointer); - _builder.append(value); - _builder.append(")"); - return _builder; - } - - /** - * @param operations a list of {@link Operation}s - * @param classname the name of the type defining the getter - * @return code declaring the operations - */ - public CharSequence operationsDeclaration(final List<? extends Operation> operations, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/*--------------------- operations ---------------------*/"); - _builder.newLine(); - { - for(final Operation operation : operations) { - CharSequence _operationSignature = this.operationSignature(operation, classname, true); - _builder.append(_operationSignature); - _builder.append(";"); - _builder.newLineIfNotEmpty(); - } - } - return _builder; - } - - /** - * @param operations a list of {@link Operation}s - * @param classname the name of the type defining the getter - * @return code defining the operations - */ - public CharSequence operationsImplementation(final List<? extends Operation> operations, final String classname) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/*--------------------- operations ---------------------*/"); - _builder.newLine(); - { - for(final Operation operation : operations) { - CharSequence _operationSignature = this.operationSignature(operation, classname, false); - _builder.append(_operationSignature); - _builder.append(" {"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _translatedCode = AbstractGenerator.getInstance().getTranslatedCode(operation.getDetailCode()); - _builder.append(_translatedCode, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - } - } - return _builder; - } - - public CharSequence asBlock(final CharSequence str) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append(str, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - return _builder; - } - - /** - * invoke user structor, if (inherited) present - <b>C only</b> - * - * @param cls {@link ActorClass} or {@link DataClass} - * @param args self pointer to instance - */ - public String invokeUserStructor(final RoomClass cls, final String args, final boolean ctor) { - boolean _usesInheritance = this.languageExt.usesInheritance(); - boolean _not = (!_usesInheritance); - final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> { - boolean _isConstructor = it.isConstructor(); - return Boolean.valueOf((_isConstructor == ctor)); - }; - boolean _exists = IterableExtensions.<ClassStructor>exists(this.getStructors(cls, _not), _function); - if (_exists) { - StringConcatenation _builder = new StringConcatenation(); - String _name = cls.getName(); - String _xifexpression = null; - if (ctor) { - _xifexpression = "ctor"; - } else { - _xifexpression = "dtor"; - } - String _memberInDeclaration = this.languageExt.memberInDeclaration(_name, _xifexpression); - _builder.append(_memberInDeclaration); - _builder.append("("); - _builder.append(args); - _builder.append(");"); - return _builder.toString(); - } - return ""; - } - - /** - * declaration of user constructor + destructor, if (inherited) present - <b>C only</b> - * - * @param cls {@link ActorClass} or {@link DataClass} - */ - public String userStructorsDeclaration(final RoomClass cls) { - String _xblockexpression = null; - { - final String namePrefix = this.languageExt.operationScope(cls.getName(), true); - final ArrayList<String> declBlock = CollectionLiterals.<String>newArrayList(); - declBlock.add("/*--------------------- user constructor/destructor ---------------------*/"); - boolean _usesInheritance = this.languageExt.usesInheritance(); - boolean _not = (!_usesInheritance); - final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> { - return Boolean.valueOf(it.isConstructor()); - }; - boolean _exists = IterableExtensions.<ClassStructor>exists(this.getStructors(cls, _not), _function); - if (_exists) { - CharSequence _functionSignature = this.functionSignature(cls.getName(), (namePrefix + "ctor"), "void", ""); - String _plus = (_functionSignature + ";"); - declBlock.add(_plus); - } - boolean _usesInheritance_1 = this.languageExt.usesInheritance(); - boolean _not_1 = (!_usesInheritance_1); - final Function1<ClassStructor, Boolean> _function_1 = (ClassStructor it) -> { - boolean _isConstructor = it.isConstructor(); - return Boolean.valueOf((!_isConstructor)); - }; - boolean _exists_1 = IterableExtensions.<ClassStructor>exists(this.getStructors(cls, _not_1), _function_1); - if (_exists_1) { - CharSequence _functionSignature_1 = this.functionSignature(cls.getName(), (namePrefix + "dtor"), "void", ""); - String _plus_1 = (_functionSignature_1 + ";"); - declBlock.add(_plus_1); - } - _xblockexpression = IterableExtensions.join(declBlock, this.NEWLINE); - } - return _xblockexpression; - } - - /** - * implementation of user constructor + destructor, if (inherited) present - <b>C only</b> - * - * @param cls {@link ActorClass} or {@link DataClass} - */ - public String userStructorsImplementation(final RoomClass cls) { - String _xblockexpression = null; - { - final ArrayList<String> declBlock = CollectionLiterals.<String>newArrayList(); - declBlock.add("/*--------------------- user constructor/destructor ---------------------*/"); - String _userStuctorImplementation = this.userStuctorImplementation(cls, true); - declBlock.add(_userStuctorImplementation); - String _userStuctorImplementation_1 = this.userStuctorImplementation(cls, false); - declBlock.add(_userStuctorImplementation_1); - _xblockexpression = IterableExtensions.join(IterableExtensions.<String>filterNull(declBlock), this.NEWLINE); - } - return _xblockexpression; - } - - protected String userStuctorImplementation(final RoomClass cls, final boolean ctor) { - String _xblockexpression = null; - { - final String namePrefix = this.languageExt.operationScope(cls.getName(), false); - boolean _usesInheritance = this.languageExt.usesInheritance(); - boolean _not = (!_usesInheritance); - final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> { - boolean _isConstructor = it.isConstructor(); - return Boolean.valueOf((_isConstructor == ctor)); - }; - boolean _exists = IterableExtensions.<ClassStructor>exists(this.getStructors(cls, _not), _function); - boolean _not_1 = (!_exists); - if (_not_1) { - return null; - } - StringConcatenation _builder = new StringConcatenation(); - String _name = cls.getName(); - String _xifexpression = null; - if (ctor) { - _xifexpression = "ctor"; - } else { - _xifexpression = "dtor"; - } - String _plus = (namePrefix + _xifexpression); - CharSequence _functionSignature = this.functionSignature(_name, _plus, "void", ""); - _builder.append(_functionSignature); - _builder.append("{"); - _builder.newLineIfNotEmpty(); - _builder.append("\t"); - String _userStructorBody = this.userStructorBody(cls, ctor); - _builder.append(_userStructorBody, "\t"); - _builder.newLineIfNotEmpty(); - _builder.append("}"); - _builder.newLine(); - _xblockexpression = _builder.toString(); - } - return _xblockexpression; - } - - /** - * implementation of user structor, if (inherited) present - */ - public String userStructorBody(final RoomClass cls, final boolean ctor) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/* user defined "); - { - if (ctor) { - _builder.append("con"); - } else { - _builder.append("de"); - } - } - _builder.append("structor body */"); - final String comment = _builder.toString(); - boolean _usesInheritance = this.languageExt.usesInheritance(); - boolean _not = (!_usesInheritance); - final Function1<ClassStructor, Boolean> _function = (ClassStructor it) -> { - boolean _isConstructor = it.isConstructor(); - return Boolean.valueOf((_isConstructor == ctor)); - }; - final Iterable<ClassStructor> implementedStructors = IterableExtensions.<ClassStructor>filter(this.getStructors(cls, _not), _function); - final Function1<ClassStructor, DetailCode> _function_1 = (ClassStructor it) -> { - return it.getDetailCode(); - }; - final Function1<DetailCode, String> _function_2 = (DetailCode it) -> { - return AbstractGenerator.getInstance().getTranslatedCode(it); - }; - final Iterable<String> translatedCodes = IterableExtensions.<DetailCode, String>map(IterableExtensions.<ClassStructor, DetailCode>map(implementedStructors, _function_1), _function_2); - final Function1<String, CharSequence> _function_3 = (String it) -> { - CharSequence _xifexpression = null; - int _size = IterableExtensions.size(translatedCodes); - boolean _greaterThan = (_size > 1); - if (_greaterThan) { - _xifexpression = this.asBlock(it); - } else { - _xifexpression = it; - } - return _xifexpression; - }; - String _join = IterableExtensions.join(IterableExtensions.<String, CharSequence>map(translatedCodes, _function_3)); - return ((comment + this.NEWLINE) + _join); - } - - protected List<ClassStructor> getStructors(final RoomClass cls, final boolean inherited) { - List<ClassStructor> _switchResult = null; - final RoomClass it = cls; - boolean _matched = false; - if (it instanceof ActorClass) { - if ((!inherited)) { - _matched=true; - _switchResult = ((ActorClass)it).getStructors(); - } - } - if (!_matched) { - if (it instanceof DataClass) { - if ((!inherited)) { - _matched=true; - _switchResult = ((DataClass)it).getStructors(); - } - } - } - if (!_matched) { - if (it instanceof ActorClass) { - if (inherited) { - _matched=true; - _switchResult = this._roomHelpers.getAllStructors(((ActorClass)it)); - } - } - } - if (!_matched) { - if (it instanceof DataClass) { - if (inherited) { - _matched=true; - _switchResult = this._roomHelpers.getAllStructors(((DataClass)it)); - } - } - } - return _switchResult; - } - - /** - * @param operation an {@link Operation} - * @return the operation signature (with special care for - * constructor and destructor - */ - protected CharSequence operationSignature(final Operation operation, final String classname, final boolean isDeclaration) { - CharSequence _xblockexpression = null; - { - StringConcatenation _builder = new StringConcatenation(); - { - EList<VarDecl> _arguments = operation.getArguments(); - boolean _hasElements = false; - for(final VarDecl argument : _arguments) { - if (!_hasElements) { - _hasElements = true; - } else { - _builder.appendImmediate(", ", ""); - } - String _signatureString = this.signatureString(argument.getRefType()); - _builder.append(_signatureString); - _builder.append(" "); - String _name = argument.getName(); - _builder.append(_name); - } - } - final String arguments = _builder.toString(); - final String returnType = this.signatureString(operation.getReturnType()); - String _operationScope = this.languageExt.operationScope(classname, isDeclaration); - String _name_1 = operation.getName(); - String _plus = (_operationScope + _name_1); - _xblockexpression = this.functionSignature(classname, _plus, returnType, arguments); - } - return _xblockexpression; - } - - /** - * @param type a {@link RefableType} - * @return a string for the type (also for pointers) - */ - public String signatureString(final RefableType type) { - String _switchResult = null; - final RefableType it = type; - boolean _matched = false; - if (Objects.equal(it, null)) { - _matched=true; - _switchResult = "void"; - } - if (!_matched) { - boolean _isRef = it.isRef(); - if (_isRef) { - _matched=true; - String _typeName = this._typeHelpers.typeName(type.getType()); - String _pointerLiteral = this.languageExt.pointerLiteral(); - _switchResult = (_typeName + _pointerLiteral); - } - } - if (!_matched) { - _switchResult = this._typeHelpers.typeName(type.getType()); - } - return _switchResult; - } - - public String signatureString(final Attribute attribute) { - String _switchResult = null; - final Attribute it = attribute; - boolean _matched = false; - int _size = it.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _matched=true; - _switchResult = this.languageExt.arrayType(this._typeHelpers.typeName(it.getType().getType()), it.getSize(), it.getType().isRef()); - } - if (!_matched) { - _switchResult = this.signatureString(it.getType()); - } - return _switchResult; - } - - /** - * @param attribute a {@link Attribute} - * @return a string for <code>type name</code> - */ - public String declarationString(final Attribute attribute) { - String _switchResult = null; - final Attribute it = attribute; - boolean _matched = false; - int _size = it.getSize(); - boolean _greaterThan = (_size > 0); - if (_greaterThan) { - _matched=true; - _switchResult = this.languageExt.arrayDeclaration(this._typeHelpers.typeName(it.getType().getType()), it.getSize(), it.getType().isRef(), it.getName()); - } - if (!_matched) { - String _signatureString = this.signatureString(it.getType()); - String _plus = (_signatureString + " "); - String _name = it.getName(); - _switchResult = (_plus + _name); - } - return _switchResult; - } - - protected CharSequence functionSignature(final String className, final String fullFctName, final String returnType, final String arguments) { - StringConcatenation _builder = new StringConcatenation(); - String _accessLevelPublic = this.languageExt.accessLevelPublic(); - _builder.append(_accessLevelPublic); - _builder.append(" "); - _builder.append(returnType); - _builder.append(" "); - _builder.append(fullFctName); - _builder.append("("); - boolean _isEmpty = arguments.isEmpty(); - boolean _not = (!_isEmpty); - String _selfPointer = this.languageExt.selfPointer(className, _not); - _builder.append(_selfPointer); - _builder.append(arguments); - _builder.append(")"); - return _builder; - } -} diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java deleted file mode 100644 index d60d88a50..000000000 --- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java +++ /dev/null @@ -1,611 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.generator.generic; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.inject.Singleton; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; -import javax.inject.Inject; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance; -import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance; -import org.eclipse.etrice.core.genmodel.etricegen.PortInstance; -import org.eclipse.etrice.core.genmodel.etricegen.SAPInstance; -import org.eclipse.etrice.core.genmodel.etricegen.ServiceImplInstance; -import org.eclipse.etrice.core.genmodel.etricegen.StructureInstance; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ExternalPort; -import org.eclipse.etrice.core.room.GeneralProtocolClass; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.MessageHandler; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.PortClass; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RoomClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.SAP; -import org.eclipse.etrice.core.room.SPP; -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.fsm.base.FileSystemHelpers; -import org.eclipse.etrice.generator.fsm.generic.FSMExtensions; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -/** - * collection of convenience functions for code generation - */ -@Singleton -@SuppressWarnings("all") -public class RoomExtensions extends FSMExtensions { - public final String NEWLINE = System.getProperty("line.separator"); - - private static String genDir = "/src-gen/"; - - private static String genInfoDir = "/src-gen-info/"; - - private static String genDocDir = "/doc-gen/"; - - @Inject - @Extension - protected RoomHelpers _roomHelpers; - - public static String setDefaultGenDir() { - return RoomExtensions.genDir = "/src-gen/"; - } - - public static String setDefaultGenInfoDir() { - return RoomExtensions.genInfoDir = "/src-gen-info/"; - } - - public static String setDefaultGenDocDir() { - return RoomExtensions.genDocDir = "/doc-gen/"; - } - - public static String setGenDir(final String dir) { - return RoomExtensions.genDir = (("/" + dir) + "/"); - } - - public static String setGenInfoDir(final String dir) { - return RoomExtensions.genInfoDir = (("/" + dir) + "/"); - } - - public static String setGenDocDir(final String dir) { - return RoomExtensions.genDocDir = (("/" + dir) + "/"); - } - - /** - * a specialized version of {@link #union(Iterable, Iterable)} - * @param in1 an iterable of type T - * @param in2 a second iterable of type T - * @return the union of the two iterables as new list - */ - public List<Port> punion(final Iterable<Port> in1, final Iterable<ExternalPort> in2) { - final ArrayList<Port> ret = new ArrayList<Port>(); - final Consumer<ExternalPort> _function = (ExternalPort e) -> { - ret.add(e.getInterfacePort()); - }; - in2.forEach(_function); - Iterables.<Port>addAll(ret, in1); - return ret; - } - - /** - * @return the relative path to the destination folder for the generated code - */ - public String getGenerationPathSegment() { - return RoomExtensions.genDir; - } - - /** - * @return the relative path to the destination folder for the generated code - */ - public String getGenerationInfoSegment() { - return RoomExtensions.genInfoDir; - } - - /** - * @return the relative path to the destination folder for the generated documentation - */ - public String getDocGenerationPathSegment() { - return RoomExtensions.genDocDir; - } - - /** - * @param e an {@link EObject} - * @return the URI of the EObject's resource as file string - * (or an empty string if no such resource exists) - */ - public String getModelPath(final EObject e) { - Resource res = e.eResource(); - boolean _equals = Objects.equal(res, null); - if (_equals) { - return ""; - } else { - return res.getURI().toFileString(); - } - } - - /** - * @param rc a {@link RoomClass} - * @return the name of the room model which also serves as a package name - */ - public String getPackage(final RoomClass rc) { - EObject _eContainer = rc.eContainer(); - return ((RoomModel) _eContainer).getName(); - } - - /** - * @param rc a {@link RoomClass} - * @return the name of the room model followed by the class name and all . replaced with _ - */ - public String getFullyQualifiedName(final RoomClass rc) { - String _replace = this.getPackage(rc).replace(".", "_"); - String _plus = (_replace + "_"); - String _name = rc.getName(); - return (_plus + _name); - } - - /** - * @param packageName a dot (.) separated package anem - * @return the input with dots replaced with slashes (/) - */ - public String getPathFromPackage(final String packageName) { - String _replaceAll = packageName.replaceAll("\\.", "/"); - return (_replaceAll + "/"); - } - - /** - * @param rc a {@link RoomClass} - * @return the relative folder path of the package - * (as defined by the Java convention) - */ - public String getPath(final RoomClass rc) { - return this.getPathFromPackage(this.getPackage(rc)); - } - - /** - * @param e an {@link EObject} - * @return the path of the Eclipse project containing the EObject's resource - */ - public String getProjectPath(final EObject e) { - final URI res = FileSystemHelpers.getProjectURI(e); - boolean _equals = Objects.equal(res, null); - if (_equals) { - return ""; - } - return res.toFileString(); - } - - /** - * @param e an {@link EObject} - * @return the concatenation of the object's project path - * with the {@link #getGenerationPathSegment()} - */ - public String getGenerationTargetPath(final EObject e) { - String _projectPath = this.getProjectPath(e); - String _generationPathSegment = this.getGenerationPathSegment(); - return (_projectPath + _generationPathSegment); - } - - /** - * @param e an {@link EObject} - * @return the concatenation of the object's project path - * with the {@link #getGenerationInfoSegment()} - */ - public String getGenerationInfoPath(final EObject e) { - String _projectPath = this.getProjectPath(e); - String _generationInfoSegment = this.getGenerationInfoSegment(); - return (_projectPath + _generationInfoSegment); - } - - /** - * @param e an {@link EObject} - * @return the concatenation of the objects project path - * with the {@link #getDocGenerationPathSegment()} - */ - public String getDocGenerationTargetPath(final EObject e) { - String _projectPath = this.getProjectPath(e); - String _docGenerationPathSegment = this.getDocGenerationPathSegment(); - return (_projectPath + _docGenerationPathSegment); - } - - /** - * makes a valid identifier from a path string - * @param path a slash (/) separated path - * @return the path with slashes (and colons as in replicated actors) replaced by underscores (_) - */ - public String getPathName(final String path) { - return path.replaceAll("/", "_").replaceAll(":", "_"); - } - - /** - * @param p a {@link Port} - * @return a name for the associated port class - */ - protected String _getPortClassName(final Port p) { - String _xifexpression = null; - GeneralProtocolClass _protocol = p.getProtocol(); - if ((_protocol instanceof ProtocolClass)) { - GeneralProtocolClass _protocol_1 = p.getProtocol(); - _xifexpression = this.getPortClassName(((ProtocolClass) _protocol_1), p.isConjugated(), p.isReplicated()); - } else { - _xifexpression = ""; - } - return _xifexpression; - } - - /** - * @param p a {@link ExternalPort} - * @return a name for the associated port class - */ - protected String _getPortClassName(final ExternalPort p) { - return this.getPortClassName(p.getInterfacePort()); - } - - /** - * @param sap a {@link SAP} - * @return a name for the associated port class - */ - protected String _getPortClassName(final SAP sap) { - return this.getPortClassName(sap.getProtocol(), true); - } - - /** - * @param spp a {@link SPP} - * @return a name for the associated port class - */ - protected String _getPortClassName(final SPP spp) { - return this.getPortClassName(spp.getProtocol(), false, true); - } - - /** - * @param svc a {@link ServiceImplementation} - * @return a name for the associated port class - */ - protected String _getPortClassName(final ServiceImplementation svc) { - return this.getPortClassName(svc.getSpp().getProtocol(), false, true); - } - - /** - * @param p a {@link ProtocolClass} - * @param conj if <code>true</code> consider conjugate port, else regular - * @return a name for the associated port class - */ - public String getPortClassName(final ProtocolClass p, final boolean conj) { - return this.getPortClassName(p, conj, false); - } - - /** - * @param p a {@link ProtocolClass} - * @param conj if <code>true</code> consider conjugate port, else regular - * @param repl if <code>true</code> class name for replicated port - * else for plain port - * @return a name for the associated port class - */ - public String getPortClassName(final ProtocolClass p, final boolean conj, final boolean repl) { - String _name = p.getName(); - String _xifexpression = null; - if (conj) { - _xifexpression = "Conj"; - } else { - _xifexpression = ""; - } - String _plus = (_name + _xifexpression); - String _xifexpression_1 = null; - if (repl) { - _xifexpression_1 = "Repl"; - } else { - _xifexpression_1 = ""; - } - String _plus_1 = (_plus + _xifexpression_1); - return (_plus_1 + "Port"); - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired {@link PortClass} - * @return the port class - */ - public PortClass getPortClass(final ProtocolClass pc, final boolean conj) { - if (conj) { - return pc.getConjugated(); - } else { - return pc.getRegular(); - } - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired {@link PortClass} - * @return the port class - */ - public List<PortClass> getAllPortClasses(final ProtocolClass pc, final boolean conj) { - final ArrayList<PortClass> result = CollectionLiterals.<PortClass>newArrayList(); - ProtocolClass protocol = pc; - while ((!Objects.equal(protocol, null))) { - { - if (conj) { - PortClass _conjugated = protocol.getConjugated(); - boolean _notEquals = (!Objects.equal(_conjugated, null)); - if (_notEquals) { - result.add(protocol.getConjugated()); - } - } else { - PortClass _regular = protocol.getRegular(); - boolean _notEquals_1 = (!Objects.equal(_regular, null)); - if (_notEquals_1) { - result.add(protocol.getRegular()); - } - } - protocol = protocol.getBase(); - } - } - return result; - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired communication direction - * @return <code>true</code> if a send handler is specified for this direction - */ - public boolean handlesSend(final ProtocolClass pc, final boolean conj) { - PortClass _portClass = this.getPortClass(pc, conj); - boolean _equals = Objects.equal(_portClass, null); - if (_equals) { - return false; - } else { - final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, conj); - List<MessageHandler> _safeList = RoomExtensions.getSafeList(this.getPortClass(pc, conj).getMsgHandlers()); - for (final MessageHandler hdlr : _safeList) { - boolean _contains = allMessages.contains(hdlr.getMsg()); - if (_contains) { - return true; - } - } - } - return false; - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired communication direction - * @return <code>true</code> if a receive handler is specified for this direction - */ - public boolean handlesReceive(final ProtocolClass pc, final boolean conj) { - PortClass _portClass = this.getPortClass(pc, conj); - boolean _equals = Objects.equal(_portClass, null); - if (_equals) { - return false; - } else { - final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj)); - List<MessageHandler> _safeList = RoomExtensions.getSafeList(this.getPortClass(pc, conj).getMsgHandlers()); - for (final MessageHandler hdlr : _safeList) { - boolean _contains = allMessages.contains(hdlr.getMsg()); - if (_contains) { - return true; - } - } - } - return false; - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired communication direction - * @return <code>true</code> if a receive handler is specified for this direction including base classes - */ - public boolean handlesReceiveIncludingSuper(final ProtocolClass pc, final boolean conj) { - final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj); - final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj)); - for (final PortClass p : allPortClasses) { - List<MessageHandler> _safeList = RoomExtensions.getSafeList(p.getMsgHandlers()); - for (final MessageHandler hdlr : _safeList) { - boolean _contains = allMessages.contains(hdlr.getMsg()); - if (_contains) { - return true; - } - } - } - return false; - } - - /** - * @param iii an {@link InterfaceItemInstance} - * @return <code>true</code> if the interface item instance is logically conjugate - */ - public boolean isConjugated(final InterfaceItemInstance iii) { - if ((iii instanceof PortInstance)) { - return ((PortInstance) iii).getPort().isConjugated(); - } else { - if ((iii instanceof SAPInstance)) { - return true; - } else { - if ((iii instanceof ServiceImplInstance)) { - return false; - } else { - return false; - } - } - } - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired communication direction - * @return a list of defined receive {@link MessageHandler} for this direction - */ - public List<MessageHandler> getReceiveHandlers(final ProtocolClass pc, final boolean conj) { - final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>(); - PortClass _portClass = this.getPortClass(pc, conj); - boolean _notEquals = (!Objects.equal(_portClass, null)); - if (_notEquals) { - final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj)); - List<MessageHandler> _safeList = RoomExtensions.getSafeList(this.getPortClass(pc, conj).getMsgHandlers()); - for (final MessageHandler hdlr : _safeList) { - boolean _contains = allMessages.contains(hdlr.getMsg()); - if (_contains) { - res.add(hdlr); - } - } - } - return res; - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired communication direction - * @return a list of defined receive {@link MessageHandler} for this direction including base classes - */ - public List<MessageHandler> getReceiveHandlersIncludingSuper(final ProtocolClass pc, final boolean conj) { - final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>(); - final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj); - final List<Message> allMsgs = this._roomHelpers.getAllMessages(pc, (!conj)); - for (final PortClass p : allPortClasses) { - List<MessageHandler> _safeList = RoomExtensions.getSafeList(p.getMsgHandlers()); - for (final MessageHandler hdlr : _safeList) { - boolean _contains = allMsgs.contains(hdlr.getMsg()); - if (_contains) { - res.add(hdlr); - } - } - } - return res; - } - - /** - * @param pc a {@link ProtocolClass} - * @param conj flag indicating the desired communication direction - * @return a list of defined send {@link MessageHandler} for this direction - */ - public List<MessageHandler> getSendHandlers(final ProtocolClass pc, final boolean conj) { - PortClass _portClass = this.getPortClass(pc, conj); - boolean _equals = Objects.equal(_portClass, null); - if (_equals) { - return Collections.<MessageHandler>emptyList(); - } else { - final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>(); - final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, conj); - List<MessageHandler> _safeList = RoomExtensions.getSafeList(this.getPortClass(pc, conj).getMsgHandlers()); - for (final MessageHandler hdlr : _safeList) { - boolean _contains = allMessages.contains(hdlr.getMsg()); - if (_contains) { - res.add(hdlr); - } - } - return res; - } - } - - /** - * @param m a {@link Message} - * @param conj flag indicating the desired communication direction - * @return a send {@link MessageHandler} for this direction if it is defined, <code>null</code> else - */ - public MessageHandler getSendHandler(final Message m, final boolean conj) { - EObject _eContainer = m.eContainer(); - final Function1<MessageHandler, Boolean> _function = (MessageHandler e) -> { - Message _msg = e.getMsg(); - return Boolean.valueOf(Objects.equal(_msg, m)); - }; - return IterableExtensions.<MessageHandler>findFirst(this.getSendHandlers(((ProtocolClass) _eContainer), conj), _function); - } - - /** - * @param m a {@link Message} - * @return <code>true</code> if this message is an incoming message - */ - public boolean isIncoming(final Message m) { - EObject _eContainer = m.eContainer(); - return this._roomHelpers.getAllIncomingMessages(((ProtocolClass) _eContainer)).contains(m); - } - - /** - * @param m a {@link Message} - * @return a string that can be used as identifier for the message. It is prefixed with IN_ or OUT_ - * to avoid ambiguities - */ - public String getCodeName(final Message m) { - boolean _isIncoming = this.isIncoming(m); - if (_isIncoming) { - String _name = m.getName(); - return ("IN_" + _name); - } else { - String _name_1 = m.getName(); - return ("OUT_" + _name_1); - } - } - - /** - * @param ac an {@link ActorClass} - * @return <code>true</code> if an operation named 'stop' is defined with a void argument list and - * void return type - */ - public boolean overridesStop(final ActorClass ac) { - return (IterableExtensions.<StandardOperation>exists(ac.getOperations(), ((Function1<StandardOperation, Boolean>) (StandardOperation e) -> { - return Boolean.valueOf(((Objects.equal(e.getName(), "stop") && e.getArguments().isEmpty()) && Objects.equal(e.getReturnType(), null))); - })) || ((!Objects.equal(ac.getActorBase(), null)) && this.overridesStop(ac.getActorBase()))); - } - - public BasicEList<AbstractInstance> getAllSubInstances(final StructureInstance ssi) { - final BasicEList<AbstractInstance> result = new BasicEList<AbstractInstance>(); - final TreeIterator<EObject> it = ssi.eAllContents(); - while (it.hasNext()) { - { - final EObject obj = it.next(); - if ((obj instanceof AbstractInstance)) { - result.add(((AbstractInstance) obj)); - } - } - } - return result; - } - - public static List<MessageHandler> getSafeList(final List<MessageHandler> msgHandlers) { - List<MessageHandler> _xifexpression = null; - boolean _equals = Objects.equal(msgHandlers, null); - if (_equals) { - _xifexpression = Collections.<MessageHandler>emptyList(); - } else { - _xifexpression = msgHandlers; - } - return _xifexpression; - } - - public String getPortClassName(final EObject p) { - if (p instanceof Port) { - return _getPortClassName((Port)p); - } else if (p instanceof SAP) { - return _getPortClassName((SAP)p); - } else if (p instanceof SPP) { - return _getPortClassName((SPP)p); - } else if (p instanceof ExternalPort) { - return _getPortClassName((ExternalPort)p); - } else if (p instanceof ServiceImplementation) { - return _getPortClassName((ServiceImplementation)p); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " + - Arrays.<Object>asList(p).toString()); - } - } -} diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java deleted file mode 100644 index 49cf2b2d2..000000000 --- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TestInstanceCreator.java +++ /dev/null @@ -1,265 +0,0 @@ -package org.eclipse.etrice.generator.generic; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.etrice.core.common.base.Annotation; -import org.eclipse.etrice.core.etmap.eTMap.ETMapFactory; -import org.eclipse.etrice.core.etmap.eTMap.Mapping; -import org.eclipse.etrice.core.etmap.eTMap.MappingModel; -import org.eclipse.etrice.core.etmap.eTMap.SubSystemMapping; -import org.eclipse.etrice.core.etphys.eTPhys.NodeRef; -import org.eclipse.etrice.core.etphys.eTPhys.PhysicalModel; -import org.eclipse.etrice.core.etphys.eTPhys.PhysicalSystem; -import org.eclipse.etrice.core.genmodel.fsm.ILogger; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.LogicalSystem; -import org.eclipse.etrice.core.room.RoomFactory; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.StructureClass; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.core.room.SubSystemRef; -import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Conversions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.Functions.Function2; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; -import org.eclipse.xtext.xbase.lib.ObjectExtensions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; - -@FinalFieldsConstructor -@SuppressWarnings("all") -public class TestInstanceCreator { - private final static String ANNOTATION_TYPE_NAME = "TestInstance"; - - @Extension - private final RoomFactory _roomFactory = RoomFactory.eINSTANCE; - - @Extension - private final ETMapFactory _eTMapFactory = ETMapFactory.eINSTANCE; - - private final ILogger logger; - - /** - * Creates instance and mapping for classes having <code>@TestInstance</code> annotation: - * <p> - * a) In case of a single SubSystemClass, a new LogicalSystem with a SubSystemRef will be created<br> - * b) For ActorClasses, one new SubSystem- and LogicalSystem with necessary refs will be created</br> - * Resulting ROOM classes are stored in new RoomModel within a new memory-only resource.</br> - * Resulting mapping is stored in a new MappingModel within a new memory-only resource.</br> - * </p> - * - * Note: currently only one class having <code>@TestInstance</code> annotation is supported - * - * @param rs ResourceSet for new resources - * @return false, if creation failed and generation should stop - */ - public List<Resource> createInstancesAndMapping(final ResourceSet rs) { - final ArrayList<RoomModel> roomModels = CollectionLiterals.<RoomModel>newArrayList(); - final ArrayList<PhysicalModel> physModels = CollectionLiterals.<PhysicalModel>newArrayList(); - final Consumer<Resource> _function = (Resource it) -> { - final Function1<EObject, Boolean> _function_1 = (EObject it_1) -> { - boolean _switchResult = false; - boolean _matched = false; - if (it_1 instanceof RoomModel) { - _matched=true; - _switchResult = roomModels.add(((RoomModel)it_1)); - } - if (!_matched) { - if (it_1 instanceof PhysicalModel) { - _matched=true; - _switchResult = physModels.add(((PhysicalModel)it_1)); - } - } - return Boolean.valueOf(_switchResult); - }; - IterableExtensions.<EObject>forall(it.getContents(), _function_1); - }; - rs.getResources().forEach(_function); - final Function2<ArrayList<SubSystemClass>, RoomModel, ArrayList<SubSystemClass>> _function_1 = (ArrayList<SubSystemClass> list, RoomModel model) -> { - final Function1<SubSystemClass, Boolean> _function_2 = (SubSystemClass it) -> { - return Boolean.valueOf(this.hasTestAnnotation(it)); - }; - Iterable<SubSystemClass> _filter = IterableExtensions.<SubSystemClass>filter(model.getSubSystemClasses(), _function_2); - Iterables.<SubSystemClass>addAll(list, _filter); - return list; - }; - final ArrayList<SubSystemClass> allTestSubSystems = IterableExtensions.<RoomModel, ArrayList<SubSystemClass>>fold(roomModels, CollectionLiterals.<SubSystemClass>newArrayList(), _function_1); - final List<StructureClass> allAnnotatedClasses = CollectionLiterals.<StructureClass>newArrayList(((StructureClass[])Conversions.unwrapArray(allTestSubSystems, StructureClass.class))); - final ArrayList<Resource> result = CollectionLiterals.<Resource>newArrayList(); - { - SubSystemClass _createSubSystemClass = this._roomFactory.createSubSystemClass(); - final Procedure1<SubSystemClass> _function_2 = (SubSystemClass it) -> { - it.setName("DerivedTestSubSystem"); - }; - final SubSystemClass derivedSubSystem = ObjectExtensions.<SubSystemClass>operator_doubleArrow(_createSubSystemClass, _function_2); - final Consumer<RoomModel> _function_3 = (RoomModel model) -> { - EList<ActorRef> _actorRefs = derivedSubSystem.getActorRefs(); - final Function1<ActorClass, Boolean> _function_4 = (ActorClass it) -> { - return Boolean.valueOf(this.hasTestAnnotation(it)); - }; - final Function1<ActorClass, ActorRef> _function_5 = (ActorClass ac) -> { - ActorRef _xblockexpression = null; - { - allAnnotatedClasses.add(ac); - ActorRef _createActorRef = this._roomFactory.createActorRef(); - final Procedure1<ActorRef> _function_6 = (ActorRef it) -> { - String _name = ac.getName(); - String _plus = ("ref_" + _name); - it.setName(_plus); - it.setType(ac); - }; - _xblockexpression = ObjectExtensions.<ActorRef>operator_doubleArrow(_createActorRef, _function_6); - } - return _xblockexpression; - }; - Iterable<ActorRef> _map = IterableExtensions.<ActorClass, ActorRef>map(IterableExtensions.<ActorClass>filter(model.getActorClasses(), _function_4), _function_5); - Iterables.<ActorRef>addAll(_actorRefs, _map); - }; - roomModels.forEach(_function_3); - boolean _isEmpty = derivedSubSystem.getActorRefs().isEmpty(); - boolean _not = (!_isEmpty); - if (_not) { - allTestSubSystems.add(derivedSubSystem); - } - } - boolean _isEmpty = allTestSubSystems.isEmpty(); - if (_isEmpty) { - return result; - } - int _size = allAnnotatedClasses.size(); - boolean _greaterThan = (_size > 1); - if (_greaterThan) { - final Consumer<StructureClass> _function_2 = (StructureClass roomCls) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("TestInstanceCreator: mapping failed, multiple test instances present"); - this.logger.logError(_builder.toString(), roomCls); - }; - allAnnotatedClasses.forEach(_function_2); - return null; - } - final Function2<ArrayList<PhysicalSystem>, PhysicalModel, ArrayList<PhysicalSystem>> _function_3 = (ArrayList<PhysicalSystem> list, PhysicalModel model) -> { - EList<PhysicalSystem> _systems = model.getSystems(); - Iterables.<PhysicalSystem>addAll(list, _systems); - return list; - }; - final List<PhysicalSystem> allPhysSystems = IterableExtensions.<PhysicalModel, ArrayList<PhysicalSystem>>fold(physModels, CollectionLiterals.<PhysicalSystem>newArrayList(), _function_3); - int _size_1 = allPhysSystems.size(); - boolean _notEquals = (_size_1 != 1); - if (_notEquals) { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("TestInstanceCreator: mapping failed, found "); - int _size_2 = allPhysSystems.size(); - _builder.append(_size_2); - _builder.append(" physical systems"); - this.logger.logError(_builder.toString(), null); - return null; - } - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("TestInstanceCreator: creating instance and mapping for "); - String _name = IterableExtensions.<StructureClass>head(allAnnotatedClasses).getName(); - _builder_1.append(_name); - _builder_1.append(":"); - String _name_1 = IterableExtensions.<StructureClass>head(allAnnotatedClasses).eClass().getName(); - _builder_1.append(_name_1); - this.logger.logInfo(_builder_1.toString()); - final PhysicalSystem physSystem = IterableExtensions.<PhysicalSystem>head(allPhysSystems); - final SubSystemClass testSubSystem = IterableExtensions.<SubSystemClass>head(allTestSubSystems); - LogicalSystem _createLogicalSystem = this._roomFactory.createLogicalSystem(); - final Procedure1<LogicalSystem> _function_4 = (LogicalSystem it) -> { - it.setName("DerivedTestSystem"); - }; - final LogicalSystem testSystem = ObjectExtensions.<LogicalSystem>operator_doubleArrow(_createLogicalSystem, _function_4); - EList<SubSystemRef> _subSystems = testSystem.getSubSystems(); - SubSystemRef _createSubSystemRef = this._roomFactory.createSubSystemRef(); - final Procedure1<SubSystemRef> _function_5 = (SubSystemRef it) -> { - String _name_2 = testSubSystem.getName(); - String _plus = ("ref_" + _name_2); - it.setName(_plus); - it.setType(testSubSystem); - }; - SubSystemRef _doubleArrow = ObjectExtensions.<SubSystemRef>operator_doubleArrow(_createSubSystemRef, _function_5); - _subSystems.add(_doubleArrow); - RoomModel _createRoomModel = this._roomFactory.createRoomModel(); - final Procedure1<RoomModel> _function_6 = (RoomModel it) -> { - it.setName("DerivedTestRoomModel"); - EList<LogicalSystem> _systems = it.getSystems(); - _systems.add(testSystem); - Resource _eResource = testSubSystem.eResource(); - boolean _tripleEquals = (_eResource == null); - if (_tripleEquals) { - EList<SubSystemClass> _subSystemClasses = it.getSubSystemClasses(); - _subSystemClasses.add(testSubSystem); - } - }; - final RoomModel testRoomModel = ObjectExtensions.<RoomModel>operator_doubleArrow(_createRoomModel, _function_6); - MappingModel _createMappingModel = this._eTMapFactory.createMappingModel(); - final Procedure1<MappingModel> _function_7 = (MappingModel it) -> { - it.setName("DerivedTestMappingModel"); - EList<Mapping> _mappings = it.getMappings(); - Mapping _createMapping = this._eTMapFactory.createMapping(); - final Procedure1<Mapping> _function_8 = (Mapping it_1) -> { - it_1.setLogicalSys(testSystem); - it_1.setPhysicalSys(physSystem); - EList<SubSystemMapping> _subsysMappings = it_1.getSubsysMappings(); - final Function1<SubSystemRef, SubSystemMapping> _function_9 = (SubSystemRef subSysRef) -> { - SubSystemMapping _createSubSystemMapping = this._eTMapFactory.createSubSystemMapping(); - final Procedure1<SubSystemMapping> _function_10 = (SubSystemMapping it_2) -> { - it_2.setLogicalSubSys(subSysRef); - it_2.setNode(IterableExtensions.<NodeRef>head(physSystem.getNodeRefs())); - }; - return ObjectExtensions.<SubSystemMapping>operator_doubleArrow(_createSubSystemMapping, _function_10); - }; - List<SubSystemMapping> _map = ListExtensions.<SubSystemRef, SubSystemMapping>map(testSystem.getSubSystems(), _function_9); - Iterables.<SubSystemMapping>addAll(_subsysMappings, _map); - }; - Mapping _doubleArrow_1 = ObjectExtensions.<Mapping>operator_doubleArrow(_createMapping, _function_8); - _mappings.add(_doubleArrow_1); - }; - final MappingModel testMappingModel = ObjectExtensions.<MappingModel>operator_doubleArrow(_createMappingModel, _function_7); - Resource _xifexpression = null; - Resource _eResource = testSubSystem.eResource(); - boolean _tripleNotEquals = (_eResource != null); - if (_tripleNotEquals) { - _xifexpression = testSubSystem.eResource(); - } else { - _xifexpression = IterableExtensions.<StructureClass>head(allAnnotatedClasses).eResource(); - } - final Resource existingResource = _xifexpression; - final URI uriPath = existingResource.getURI().trimFileExtension().trimSegments(1); - Resource res = rs.createResource(uriPath.appendSegment("DerivedTestMappingModel").appendFileExtension("etmap")); - EList<EObject> _contents = res.getContents(); - _contents.add(testMappingModel); - result.add(res); - res = rs.createResource(uriPath.appendSegment("DerivedTestRoomModel").appendFileExtension("room")); - EList<EObject> _contents_1 = res.getContents(); - _contents_1.add(testRoomModel); - result.add(res); - return result; - } - - protected boolean hasTestAnnotation(final StructureClass cls) { - final Function1<Annotation, Boolean> _function = (Annotation it) -> { - String _name = it.getType().getName(); - return Boolean.valueOf(Objects.equal(_name, TestInstanceCreator.ANNOTATION_TYPE_NAME)); - }; - return IterableExtensions.<Annotation>exists(cls.getAnnotations(), _function); - } - - public TestInstanceCreator(final ILogger logger) { - super(); - this.logger = logger; - } -} diff --git a/runtime/org.eclipse.etrice.modellib.c/model/TcpService.room b/runtime/org.eclipse.etrice.modellib.c/model/TcpService.room index 4a828dc3b..945725c5e 100644 --- a/runtime/org.eclipse.etrice.modellib.c/model/TcpService.room +++ b/runtime/org.eclipse.etrice.modellib.c/model/TcpService.room @@ -61,7 +61,7 @@ RoomModel room.basic.service.tcp { } action { "/* send payload to connection */" - "setErrorCode(etWriteServerSocket(server, data->connectionId, data->length, data->data));" + "setErrorCode(etWriteServerSocket(server, transitionData->connectionId, transitionData->length, transitionData->data));" "if(hasError())" "\tcontrolPort.error();" } @@ -84,7 +84,7 @@ RoomModel room.basic.service.tcp { } action { "/* start accept thread */" - "setErrorCode(etStartListening(server, data->TcpPort));" + "setErrorCode(etStartListening(server, transitionData->TcpPort));" } } Transition tr4: cp cp1 -> connected { @@ -187,7 +187,7 @@ RoomModel room.basic.service.tcp { } action { "/* connect to server */" - "setErrorCode(etConnectServer(client, data->IPAddr, data->TcpPort));" + "setErrorCode(etConnectServer(client, transitionData->IPAddr, transitionData->TcpPort));" } } Transition tr1: connected -> unconnected { @@ -219,7 +219,7 @@ RoomModel room.basic.service.tcp { <dataPackage: payloadPort> } action { - "setErrorCode(etWriteSocket(client, data->length, data->data));" + "setErrorCode(etWriteSocket(client, transitionData->length, transitionData->data));" "if(hasError())" "\tcontrolPort.error();" } diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/readme.txt b/runtime/org.eclipse.etrice.modellib.c/src-gen/readme.txt new file mode 100644 index 000000000..1dc2b35ab --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/readme.txt @@ -0,0 +1,4 @@ +This directory is an eTrice code generation target. +It will be erased every time the generator is executed. + +DO NOT PLACE OTHER FILES HERE! diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h index 602d5601a..340b8068e 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h @@ -12,6 +12,7 @@ #include "modelbase/etPort.h" +/* include all referenced room classes */ /* message IDs */ diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c index b72cf1235..09613fadf 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c @@ -90,9 +90,9 @@ static void entry_initError(ATcpClient* self) { static void action_TRANS_INITIAL_TO__cp1(ATcpClient* self) { printf("Client Init!\n"); } -static void action_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* data) { +static void action_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* transitionData) { /* connect to server */ - setErrorCode(etConnectServer(client, data->IPAddr, data->TcpPort)); + setErrorCode(etConnectServer(client, transitionData->IPAddr, transitionData->TcpPort)); } static void action_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort(ATcpClient* self, const InterfaceItemBase* ifitem) { /* close read thread */ @@ -100,14 +100,14 @@ static void action_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolP controlPort_disconnected(); } -static void action_TRANS_tr2_FROM_cp0_TO_connected(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* data) { +static void action_TRANS_tr2_FROM_cp0_TO_connected(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* transitionData) { controlPort_connected(); } -static void action_TRANS_tr7_FROM_cp0_TO_unconnected_COND_tr7(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* data) { +static void action_TRANS_tr7_FROM_cp0_TO_unconnected_COND_tr7(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* transitionData) { controlPort_error(); } -static void action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpPayload* data) { - setErrorCode(etWriteSocket(client, data->length, data->data)); +static void action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpPayload* transitionData) { + setErrorCode(etWriteSocket(client, transitionData->length, transitionData->data)); if(hasError()) controlPort_error(); } @@ -122,10 +122,6 @@ static void action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPo static void exitTo(ATcpClient* self, etInt16 current__et, etInt16 to) { while (current__et!=to) { switch (current__et) { - case STATE_unconnected: - self->history[STATE_TOP] = STATE_unconnected; - current__et = STATE_TOP; - break; case STATE_connected: self->history[STATE_TOP] = STATE_connected; current__et = STATE_TOP; @@ -134,6 +130,10 @@ static void exitTo(ATcpClient* self, etInt16 current__et, etInt16 to) { self->history[STATE_TOP] = STATE_initError; current__et = STATE_TOP; break; + case STATE_unconnected: + self->history[STATE_TOP] = STATE_unconnected; + current__et = STATE_TOP; + break; default: /* should not occur */ break; @@ -160,13 +160,13 @@ static etInt16 executeTransitionChain(ATcpClient* self, int chain__et, const Int } case CHAIN_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort: { - DTcpControl* data = ((DTcpControl*) generic_data__et); - action_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort(self, ifitem, data); + DTcpControl* transitionData = ((DTcpControl*) generic_data__et); + action_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort(self, ifitem, transitionData); if (hasError()) { - action_TRANS_tr7_FROM_cp0_TO_unconnected_COND_tr7(self, ifitem, data); + action_TRANS_tr7_FROM_cp0_TO_unconnected_COND_tr7(self, ifitem, transitionData); return STATE_unconnected;} else { - action_TRANS_tr2_FROM_cp0_TO_connected(self, ifitem, data); + action_TRANS_tr2_FROM_cp0_TO_connected(self, ifitem, transitionData); return STATE_connected;} } case CHAIN_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort: @@ -176,13 +176,13 @@ static etInt16 executeTransitionChain(ATcpClient* self, int chain__et, const Int } case CHAIN_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3: { - DTcpPayload* data = ((DTcpPayload*) generic_data__et); - action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3(self, ifitem, data); + DTcpPayload* transitionData = ((DTcpPayload*) generic_data__et); + action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3(self, ifitem, transitionData); return STATE_connected; } case CHAIN_TRANS_tr6_FROM_initError_TO_initError_BY_connectcontrolPort_tr6: { - DTcpControl* data = ((DTcpControl*) generic_data__et); + DTcpControl* transitionData = ((DTcpControl*) generic_data__et); return STATE_initError; } default: @@ -205,9 +205,6 @@ static etInt16 enterHistory(ATcpClient* self, etInt16 state__et) { } while (ET_TRUE) { switch (state__et) { - case STATE_unconnected: - /* in leaf state: return state id */ - return STATE_unconnected; case STATE_connected: /* in leaf state: return state id */ return STATE_connected; @@ -215,6 +212,9 @@ static etInt16 enterHistory(ATcpClient* self, etInt16 state__et) { if (!(skip_entry__et)) entry_initError(self); /* in leaf state: return state id */ return STATE_initError; + case STATE_unconnected: + /* in leaf state: return state id */ + return STATE_unconnected; case STATE_TOP: state__et = self->history[STATE_TOP]; break; @@ -243,54 +243,54 @@ static void ATcpClient_receiveEventInternal(ATcpClient* self, InterfaceItemBase* if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState(self)) { - case STATE_unconnected: - switch(trigger__et) { - case TRIG_controlPort__connect: - { - chain__et = CHAIN_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_connected: - switch(trigger__et) { - case TRIG_controlPort__disconnect: - { - chain__et = CHAIN_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort; - catching_state__et = STATE_TOP; - } - break; - case TRIG_payloadPort__dataPackage: - { - chain__et = CHAIN_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_initError: - switch(trigger__et) { - case TRIG_controlPort__connect: - { - chain__et = CHAIN_TRANS_tr6_FROM_initError_TO_initError_BY_connectcontrolPort_tr6; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - default: - /* should not occur */ - break; + case STATE_connected: + switch(trigger__et) { + case TRIG_controlPort__disconnect: + { + chain__et = CHAIN_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_payloadPort__dataPackage: + { + chain__et = CHAIN_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_initError: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr6_FROM_initError_TO_initError_BY_connectcontrolPort_tr6; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_unconnected: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h index 3f6962c52..366a447b0 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h @@ -11,6 +11,7 @@ #include "etDatatypes.h" #include "messaging/etMessage.h" +/* include all referenced room classes */ #include "room/basic/service/tcp/DTcpPayload.h" #include "room/basic/service/tcp/PTcpControl.h" #include "room/basic/service/tcp/PTcpPayload.h" diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c index 17d9dc398..3fdc8eda4 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c @@ -87,9 +87,9 @@ static void entry_initError(ATcpServer* self) { } /* Action Codes */ -static void action_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpPayload* data) { +static void action_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpPayload* transitionData) { /* send payload to connection */ - setErrorCode(etWriteServerSocket(server, data->connectionId, data->length, data->data)); + setErrorCode(etWriteServerSocket(server, transitionData->connectionId, transitionData->length, transitionData->data)); if(hasError()) controlPort_error(); } @@ -100,14 +100,14 @@ static void action_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolP controlPort_disconnected(); } -static void action_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* data) { +static void action_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* transitionData) { /* start accept thread */ - setErrorCode(etStartListening(server, data->TcpPort)); + setErrorCode(etStartListening(server, transitionData->TcpPort)); } -static void action_TRANS_tr4_FROM_cp1_TO_connected(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* data) { +static void action_TRANS_tr4_FROM_cp1_TO_connected(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* transitionData) { controlPort_connected(); } -static void action_TRANS_tr8_FROM_cp1_TO_unconnected_COND_tr8(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* data) { +static void action_TRANS_tr8_FROM_cp1_TO_unconnected_COND_tr8(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* transitionData) { controlPort_error(); } @@ -125,14 +125,14 @@ static void exitTo(ATcpServer* self, etInt16 current__et, etInt16 to) { self->history[STATE_TOP] = STATE_connected; current__et = STATE_TOP; break; - case STATE_unconnected: - self->history[STATE_TOP] = STATE_unconnected; - current__et = STATE_TOP; - break; case STATE_initError: self->history[STATE_TOP] = STATE_initError; current__et = STATE_TOP; break; + case STATE_unconnected: + self->history[STATE_TOP] = STATE_unconnected; + current__et = STATE_TOP; + break; default: /* should not occur */ break; @@ -156,10 +156,15 @@ static etInt16 executeTransitionChain(ATcpServer* self, int chain__et, const Int else { return STATE_unconnected;} } + case CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2: + { + DTcpControl* transitionData = ((DTcpControl*) generic_data__et); + return STATE_initError; + } case CHAIN_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5: { - DTcpPayload* data = ((DTcpPayload*) generic_data__et); - action_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5(self, ifitem, data); + DTcpPayload* transitionData = ((DTcpPayload*) generic_data__et); + action_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5(self, ifitem, transitionData); return STATE_connected; } case CHAIN_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort: @@ -169,20 +174,15 @@ static etInt16 executeTransitionChain(ATcpServer* self, int chain__et, const Int } case CHAIN_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort: { - DTcpControl* data = ((DTcpControl*) generic_data__et); - action_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort(self, ifitem, data); + DTcpControl* transitionData = ((DTcpControl*) generic_data__et); + action_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort(self, ifitem, transitionData); if (hasError()) { - action_TRANS_tr8_FROM_cp1_TO_unconnected_COND_tr8(self, ifitem, data); + action_TRANS_tr8_FROM_cp1_TO_unconnected_COND_tr8(self, ifitem, transitionData); return STATE_unconnected;} else { - action_TRANS_tr4_FROM_cp1_TO_connected(self, ifitem, data); + action_TRANS_tr4_FROM_cp1_TO_connected(self, ifitem, transitionData); return STATE_connected;} } - case CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2: - { - DTcpControl* data = ((DTcpControl*) generic_data__et); - return STATE_initError; - } default: /* should not occur */ break; @@ -206,13 +206,13 @@ static etInt16 enterHistory(ATcpServer* self, etInt16 state__et) { case STATE_connected: /* in leaf state: return state id */ return STATE_connected; - case STATE_unconnected: - /* in leaf state: return state id */ - return STATE_unconnected; case STATE_initError: if (!(skip_entry__et)) entry_initError(self); /* in leaf state: return state id */ return STATE_initError; + case STATE_unconnected: + /* in leaf state: return state id */ + return STATE_unconnected; case STATE_TOP: state__et = self->history[STATE_TOP]; break; @@ -241,54 +241,54 @@ static void ATcpServer_receiveEventInternal(ATcpServer* self, InterfaceItemBase* if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState(self)) { - case STATE_connected: - switch(trigger__et) { - case TRIG_payloadPort__dataPackage: - { - chain__et = CHAIN_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5; - catching_state__et = STATE_TOP; - } - break; - case TRIG_controlPort__disconnect: - { - chain__et = CHAIN_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_unconnected: - switch(trigger__et) { - case TRIG_controlPort__connect: - { - chain__et = CHAIN_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_initError: - switch(trigger__et) { - case TRIG_controlPort__connect: - { - chain__et = CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - default: - /* should not occur */ - break; + case STATE_connected: + switch(trigger__et) { + case TRIG_controlPort__disconnect: + { + chain__et = CHAIN_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_payloadPort__dataPackage: + { + chain__et = CHAIN_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_initError: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_unconnected: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h index 2bff8d75e..a83b955a0 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h @@ -11,6 +11,7 @@ #include "etDatatypes.h" #include "messaging/etMessage.h" +/* include all referenced room classes */ #include "room/basic/service/tcp/DTcpPayload.h" #include "room/basic/service/tcp/PTcpControl.h" #include "room/basic/service/tcp/PTcpPayload.h" diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h index 0d1c71664..ed7edcdd0 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h @@ -10,6 +10,7 @@ #include "etDatatypes.h" +/* include all referenced room classes */ typedef struct { diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h index 23aa03dd3..99fc0cf07 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h @@ -10,6 +10,7 @@ #include "etDatatypes.h" +/* include all referenced room classes */ typedef struct { diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h index 2809a5f03..d0e781960 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h @@ -12,6 +12,7 @@ #include "modelbase/etPort.h" +/* include all referenced room classes */ #include "room/basic/service/tcp/DTcpControl.h" diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h index b27deac85..9a30653ab 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h @@ -12,6 +12,7 @@ #include "modelbase/etPort.h" +/* include all referenced room classes */ #include "room/basic/service/tcp/DTcpPayload.h" diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c index c2f7f4acd..0a7cc630c 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c @@ -102,12 +102,12 @@ static void action_TRANS_INITIAL_TO__Operational(ATimingService* self) { tcbs[i].next=&tcbs[i+1]; } } -static void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(ATimingService* self, const InterfaceItemBase* ifitem, uint32 time) { +static void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(ATimingService* self, const InterfaceItemBase* ifitem, uint32 transitionData) { etTimerControlBlock* timer = getTcb(); etTime t; if (timer!= 0){ - t.sec=time/1000; - t.nSec=(time%1000)*1000000L; + t.sec=transitionData/1000; + t.nSec=(transitionData%1000)*1000000L; timer->pTime.sec = 0; timer->pTime.nSec = 0; timer->portIdx=((etReplSubPort*)ifitem)->index; @@ -116,12 +116,12 @@ static void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttime putTcbToUsedList(timer); } } -static void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ATimingService* self, const InterfaceItemBase* ifitem, uint32 time) { +static void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ATimingService* self, const InterfaceItemBase* ifitem, uint32 transitionData) { etTimerControlBlock* timer = getTcb(); etTime t; if (timer!= 0){ - t.sec=time/1000; - t.nSec=(time%1000)*1000000L; + t.sec=transitionData/1000; + t.nSec=(transitionData%1000)*1000000L; timer->pTime = t; timer->portIdx=((etReplSubPort*)ifitem)->index; getTimeFromTarget(&(timer->expTime)); @@ -170,14 +170,14 @@ static etInt16 executeTransitionChain(ATimingService* self, int chain__et, const } case CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1: { - uint32 time = *((uint32*) generic_data__et); - action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(self, ifitem, time); + uint32 transitionData = *((uint32*) generic_data__et); + action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(self, ifitem, transitionData); return STATE_Operational; } case CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3: { - uint32 time = *((uint32*) generic_data__et); - action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(self, ifitem, time); + uint32 transitionData = *((uint32*) generic_data__et); + action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(self, ifitem, transitionData); return STATE_Operational; } case CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4: @@ -237,37 +237,37 @@ static void ATimingService_receiveEventInternal(ATimingService* self, InterfaceI if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState(self)) { - case STATE_Operational: - switch(trigger__et) { - case POLLING: - do_Operational(self); - break; - case TRIG_timer__startTimeout: - { - chain__et = CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1; - catching_state__et = STATE_TOP; - } - break; - case TRIG_timer__startTimer: - { - chain__et = CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3; - catching_state__et = STATE_TOP; - } - break; - case TRIG_timer__kill: - { - chain__et = CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - default: - /* should not occur */ - break; + case STATE_Operational: + switch(trigger__et) { + case POLLING: + do_Operational(self); + break; + case TRIG_timer__kill: + { + chain__et = CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__startTimeout: + { + chain__et = CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__startTimer: + { + chain__et = CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h index 36e86ddc9..6a4b62231 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h @@ -11,6 +11,7 @@ #include "etDatatypes.h" #include "messaging/etMessage.h" +/* include all referenced room classes */ #include "room/basic/service/timing/PTimer.h" /*--------------------- begin user code ---------------------*/ diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h index 585239128..faeea093e 100644 --- a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h @@ -16,6 +16,7 @@ #define ET_TIMER_PERIODIC 0x02 /*--------------------- end user code ---------------------*/ +/* include all referenced room classes */ /* message IDs */ diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt new file mode 100644 index 000000000..1dc2b35ab --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/readme.txt @@ -0,0 +1,4 @@ +This directory is an eTrice code generation target. +It will be erased every time the generator is executed. + +DO NOT PLACE OTHER FILES HERE! diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp index 8639764df..db590f23b 100644 --- a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp @@ -212,12 +212,12 @@ void ATimingService::action_TRANS_INITIAL_TO__Operational() { tcbs[i].next = &tcbs[i + 1]; } } -void ATimingService::action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 time) { +void ATimingService::action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 transitionData) { etTimerControlBlock* timer = getTcb(); etTime t; if (timer != 0) { - t.sec = time / 1000; - t.nSec = (time % 1000) * 1000000L; + t.sec = transitionData / 1000; + t.nSec = (transitionData % 1000) * 1000000L; timer->pTime.sec = 0; timer->pTime.nSec = 0; timer->portIdx = ifitem->getIdx(); @@ -226,12 +226,12 @@ void ATimingService::action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTi putTcbToUsedList(timer); } } -void ATimingService::action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 time) { +void ATimingService::action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 transitionData) { etTimerControlBlock* timer = getTcb(); etTime t; if (timer != 0) { - t.sec = time / 1000; - t.nSec = (time % 1000) * 1000000L; + t.sec = transitionData / 1000; + t.nSec = (transitionData % 1000) * 1000000L; timer->pTime = t; timer->portIdx = ifitem->getIdx(); getTimeFromTarget(&(timer->expTime)); @@ -280,14 +280,14 @@ etInt16 ATimingService::executeTransitionChain(int chain__et, const InterfaceIte } case ATimingService::CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1: { - uint32 time = *(static_cast<uint32*>(generic_data__et)); - action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(ifitem, time); + uint32 transitionData = *(static_cast<uint32*>(generic_data__et)); + action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(ifitem, transitionData); return STATE_Operational; } case ATimingService::CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3: { - uint32 time = *(static_cast<uint32*>(generic_data__et)); - action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ifitem, time); + uint32 transitionData = *(static_cast<uint32*>(generic_data__et)); + action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ifitem, transitionData); return STATE_Operational; } case ATimingService::CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4: @@ -346,37 +346,37 @@ void ATimingService::receiveEventInternal(InterfaceItemBase* ifitem, int localId if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState()) { - case STATE_Operational: - switch(trigger__et) { - case POLLING: - do_Operational(); - break; - case TRIG_timer__startTimeout: - { - chain__et = ATimingService::CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1; - catching_state__et = STATE_TOP; - } - break; - case TRIG_timer__startTimer: - { - chain__et = ATimingService::CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3; - catching_state__et = STATE_TOP; - } - break; - case TRIG_timer__kill: - { - chain__et = ATimingService::CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - default: - /* should not occur */ - break; + case STATE_Operational: + switch(trigger__et) { + case POLLING: + do_Operational(); + break; + case TRIG_timer__kill: + { + chain__et = ATimingService::CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__startTimeout: + { + chain__et = ATimingService::CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__startTimer: + { + chain__et = ATimingService::CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h index d351dd0aa..8b75c3ea4 100644 --- a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h @@ -119,8 +119,8 @@ class ATimingService : public etRuntime::ActorClassBase { /* Action Codes */ virtual void action_TRANS_INITIAL_TO__Operational(); - virtual void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 time); - virtual void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 time); + virtual void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 transitionData); + virtual void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 transitionData); virtual void action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(const InterfaceItemBase* ifitem); /* State Switch Methods */ diff --git a/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room b/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room index 51a868f60..ec36490f3 100644 --- a/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room +++ b/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room @@ -35,7 +35,7 @@ RoomModel room.basic.service.logging { action { "Date d=new Date(tStart);" "try{" - "file=new FileOutputStream(fileName);" + "file=new FileOutputStream(transitionData);" "p=new PrintStream(file);" "p.println(\"Log opened at \"+ d.toString());" "p.println(\"--------------------------------------------------\");" @@ -59,11 +59,11 @@ RoomModel room.basic.service.logging { <internalLog: log> } action { - "p.println(\"Timestamp: \" + Long.toString(data.timeStamp-tStart) + \"ms\");" - "p.println(\"SenderInstance: \"+ data.sender);" - "p.println(\"UserString: \" + data.userString);" + "p.println(\"Timestamp: \" + Long.toString(transitionData.timeStamp-tStart) + \"ms\");" + "p.println(\"SenderInstance: \"+ transitionData.sender);" + "p.println(\"UserString: \" + transitionData.userString);" "p.println(\"--------------------------------------------------\");" - "System.out.printf(data.userString);" + "System.out.printf(transitionData.userString);" } } State closed diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/readme.txt b/runtime/org.eclipse.etrice.modellib.java/src-gen/readme.txt new file mode 100644 index 000000000..1dc2b35ab --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/readme.txt @@ -0,0 +1,4 @@ +This directory is an eTrice code generation target. +It will be erased every time the generator is executed. + +DO NOT PLACE OTHER FILES HERE! diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java index 427ed97bb..0690a7f6e 100644 --- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java @@ -124,10 +124,10 @@ public class ALogService extends ActorClassBase { /* Entry and Exit Codes */ /* Action Codes */ - protected void action_TRANS_open_FROM_closed_TO_opened_BY_openlog(InterfaceItemBase ifitem, String fileName) { + protected void action_TRANS_open_FROM_closed_TO_opened_BY_openlog(InterfaceItemBase ifitem, String transitionData) { Date d=new Date(tStart); try{ - file=new FileOutputStream(fileName); + file=new FileOutputStream(transitionData); p=new PrintStream(file); p.println("Log opened at "+ d.toString()); p.println("--------------------------------------------------"); @@ -140,12 +140,12 @@ public class ALogService extends ActorClassBase { p.close(); p=null; } - protected void action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(InterfaceItemBase ifitem, InternalLogData data) { - p.println("Timestamp: " + Long.toString(data.timeStamp-tStart) + "ms"); - p.println("SenderInstance: "+ data.sender); - p.println("UserString: " + data.userString); + protected void action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(InterfaceItemBase ifitem, InternalLogData transitionData) { + p.println("Timestamp: " + Long.toString(transitionData.timeStamp-tStart) + "ms"); + p.println("SenderInstance: "+ transitionData.sender); + p.println("UserString: " + transitionData.userString); p.println("--------------------------------------------------"); - System.out.printf(data.userString); + System.out.printf(transitionData.userString); } /* State Switch Methods */ @@ -188,8 +188,8 @@ public class ALogService extends ActorClassBase { } case ALogService.CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog: { - String fileName = (String) generic_data__et; - action_TRANS_open_FROM_closed_TO_opened_BY_openlog(ifitem, fileName); + String transitionData = (String) generic_data__et; + action_TRANS_open_FROM_closed_TO_opened_BY_openlog(ifitem, transitionData); return STATE_opened; } case ALogService.CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog: @@ -199,8 +199,8 @@ public class ALogService extends ActorClassBase { } case ALogService.CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1: { - InternalLogData data = (InternalLogData) generic_data__et; - action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(ifitem, data); + InternalLogData transitionData = (InternalLogData) generic_data__et; + action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(ifitem, transitionData); return STATE_opened; } default: @@ -253,41 +253,41 @@ public class ALogService extends ActorClassBase { if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState()) { - case STATE_closed: - switch(trigger__et) { - case TRIG_log__open: - { - chain__et = ALogService.CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_opened: - switch(trigger__et) { - case TRIG_log__close: - { - chain__et = ALogService.CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog; - catching_state__et = STATE_TOP; - } - break; - case TRIG_log__internalLog: - { - chain__et = ALogService.CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - default: - /* should not occur */ - break; + case STATE_closed: + switch(trigger__et) { + case TRIG_log__open: + { + chain__et = ALogService.CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_opened: + switch(trigger__et) { + case TRIG_log__close: + { + chain__et = ALogService.CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog; + catching_state__et = STATE_TOP; + } + break; + case TRIG_log__internalLog: + { + chain__et = ALogService.CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java index 212e2e702..554c8eabf 100644 --- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java @@ -170,10 +170,10 @@ public class ATcpClient extends ActorClassBase { protected void action_TRANS_INITIAL_TO__closed() { System.out.println("Client Init !"); } - protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) { + protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl transitionData) { lastError=0; try{ - socket = new Socket(data.IPAddr,data.TcpPort); + socket = new Socket(transitionData.IPAddr,transitionData.TcpPort); (new ClientRxThread(PayloadPort, socket)).start(); out = socket.getOutputStream(); }catch(IOException e){ @@ -190,10 +190,10 @@ public class ATcpClient extends ActorClassBase { System.err.println(e.toString()); } } - protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) { + protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl transitionData) { ControlPort.established(); } - protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) { + protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl transitionData) { ControlPort.error(); try{ socket.close(); @@ -201,9 +201,9 @@ public class ATcpClient extends ActorClassBase { System.err.println(e.toString()); } } - protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) { + protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload transitionData) { try{ - out.write(data.getData(),0,data.length); + out.write(transitionData.getData(),0,transitionData.length); }catch(IOException e){ System.err.println(e.toString()); } @@ -223,14 +223,14 @@ public class ATcpClient extends ActorClassBase { this.history[STATE_TOP] = STATE_closed; current__et = STATE_TOP; break; - case STATE_opened: - this.history[STATE_TOP] = STATE_opened; - current__et = STATE_TOP; - break; case STATE_error: this.history[STATE_TOP] = STATE_error; current__et = STATE_TOP; break; + case STATE_opened: + this.history[STATE_TOP] = STATE_opened; + current__et = STATE_TOP; + break; default: /* should not occur */ break; @@ -254,13 +254,13 @@ public class ATcpClient extends ActorClassBase { } case ATcpClient.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort: { - DTcpControl data = (DTcpControl) generic_data__et; - action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data); + DTcpControl transitionData = (DTcpControl) generic_data__et; + action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, transitionData); if (lastError!=0) { - action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data); + action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, transitionData); return STATE_error;} else { - action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data); + action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, transitionData); return STATE_opened;} } case ATcpClient.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort: @@ -270,8 +270,8 @@ public class ATcpClient extends ActorClassBase { } case ATcpClient.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3: { - DTcpPayload data = (DTcpPayload) generic_data__et; - action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data); + DTcpPayload transitionData = (DTcpPayload) generic_data__et; + action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, transitionData); return STATE_opened; } default: @@ -295,12 +295,12 @@ public class ATcpClient extends ActorClassBase { case STATE_closed: /* in leaf state: return state id */ return STATE_closed; - case STATE_opened: - /* in leaf state: return state id */ - return STATE_opened; case STATE_error: /* in leaf state: return state id */ return STATE_error; + case STATE_opened: + /* in leaf state: return state id */ + return STATE_opened; case STATE_TOP: state__et = this.history[STATE_TOP]; break; @@ -327,43 +327,43 @@ public class ATcpClient extends ActorClassBase { if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState()) { - case STATE_closed: - switch(trigger__et) { - case TRIG_ControlPort__open: - { - chain__et = ATcpClient.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_opened: - switch(trigger__et) { - case TRIG_ControlPort__close: - { - chain__et = ATcpClient.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort; - catching_state__et = STATE_TOP; - } - break; - case TRIG_PayloadPort__send: - { - chain__et = ATcpClient.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_error: - break; - default: - /* should not occur */ - break; + case STATE_closed: + switch(trigger__et) { + case TRIG_ControlPort__open: + { + chain__et = ATcpClient.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_error: + break; + case STATE_opened: + switch(trigger__et) { + case TRIG_ControlPort__close: + { + chain__et = ATcpClient.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_PayloadPort__send: + { + chain__et = ATcpClient.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java index a5f807a7b..abaae95bb 100644 --- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java @@ -210,10 +210,10 @@ public class ATcpServer extends ActorClassBase { /* Entry and Exit Codes */ /* Action Codes */ - protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) { + protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl transitionData) { lastError=0; try{ - socket = new ServerSocket(data.TcpPort); + socket = new ServerSocket(transitionData.TcpPort); (new ServerAcceptThread(PayloadPort, socket, this)).start(); }catch(IOException e){ System.err.println(e.toString()); @@ -229,10 +229,10 @@ public class ATcpServer extends ActorClassBase { System.err.println(e.toString()); } } - protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) { + protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl transitionData) { ControlPort.established(); } - protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) { + protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl transitionData) { ControlPort.error(); try{ socket.close(); @@ -240,9 +240,9 @@ public class ATcpServer extends ActorClassBase { System.err.println(e.toString()); } } - protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) { + protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload transitionData) { try{ - outStreams.get(data.getConnectionId()).write(data.getData(),0,data.length); + outStreams.get(transitionData.getConnectionId()).write(transitionData.getData(),0,transitionData.length); }catch(IOException e){ System.err.println(e.toString()); } @@ -262,14 +262,14 @@ public class ATcpServer extends ActorClassBase { this.history[STATE_TOP] = STATE_closed; current__et = STATE_TOP; break; - case STATE_opened: - this.history[STATE_TOP] = STATE_opened; - current__et = STATE_TOP; - break; case STATE_error: this.history[STATE_TOP] = STATE_error; current__et = STATE_TOP; break; + case STATE_opened: + this.history[STATE_TOP] = STATE_opened; + current__et = STATE_TOP; + break; default: /* should not occur */ break; @@ -292,13 +292,13 @@ public class ATcpServer extends ActorClassBase { } case ATcpServer.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort: { - DTcpControl data = (DTcpControl) generic_data__et; - action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data); + DTcpControl transitionData = (DTcpControl) generic_data__et; + action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, transitionData); if (lastError!=0) { - action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data); + action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, transitionData); return STATE_error;} else { - action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data); + action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, transitionData); return STATE_opened;} } case ATcpServer.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort: @@ -308,8 +308,8 @@ public class ATcpServer extends ActorClassBase { } case ATcpServer.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3: { - DTcpPayload data = (DTcpPayload) generic_data__et; - action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data); + DTcpPayload transitionData = (DTcpPayload) generic_data__et; + action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, transitionData); return STATE_opened; } default: @@ -333,12 +333,12 @@ public class ATcpServer extends ActorClassBase { case STATE_closed: /* in leaf state: return state id */ return STATE_closed; - case STATE_opened: - /* in leaf state: return state id */ - return STATE_opened; case STATE_error: /* in leaf state: return state id */ return STATE_error; + case STATE_opened: + /* in leaf state: return state id */ + return STATE_opened; case STATE_TOP: state__et = this.history[STATE_TOP]; break; @@ -365,43 +365,43 @@ public class ATcpServer extends ActorClassBase { if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState()) { - case STATE_closed: - switch(trigger__et) { - case TRIG_ControlPort__open: - { - chain__et = ATcpServer.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_opened: - switch(trigger__et) { - case TRIG_ControlPort__close: - { - chain__et = ATcpServer.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort; - catching_state__et = STATE_TOP; - } - break; - case TRIG_PayloadPort__send: - { - chain__et = ATcpServer.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - case STATE_error: - break; - default: - /* should not occur */ - break; + case STATE_closed: + switch(trigger__et) { + case TRIG_ControlPort__open: + { + chain__et = ATcpServer.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_error: + break; + case STATE_opened: + switch(trigger__et) { + case TRIG_ControlPort__close: + { + chain__et = ATcpServer.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_PayloadPort__send: + { + chain__et = ATcpServer.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java index 89ca94411..879caea9c 100644 --- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java @@ -122,18 +122,18 @@ public class ATimingService extends ActorClassBase { protected void action_TRANS_INITIAL_TO__Operational() { timerService = new Timer(); } - protected void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1(InterfaceItemBase ifitem, TimerData td) { + protected void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1(InterfaceItemBase ifitem, TimerData transitionData) { // start timer taskCount++; if (taskCount>PURGE_LIMIT) timerService.purge(); - int t = td.getTime(); + int t = transitionData.getTime(); timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(),t,t); } - protected void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3(InterfaceItemBase ifitem, TimerData td) { + protected void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3(InterfaceItemBase ifitem, TimerData transitionData) { // start timeout taskCount++; if (taskCount>PURGE_LIMIT) timerService.purge(); - timerService.schedule(((PTimerPort)ifitem).getTask(), ((TimerData)td).getTime()); + timerService.schedule(((PTimerPort)ifitem).getTask(), transitionData.getTime()); } protected void action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(InterfaceItemBase ifitem) { // nothing to do to kill timer (handled by timer) @@ -176,14 +176,14 @@ public class ATimingService extends ActorClassBase { } case ATimingService.CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1: { - TimerData td = (TimerData) generic_data__et; - action_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1(ifitem, td); + TimerData transitionData = (TimerData) generic_data__et; + action_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1(ifitem, transitionData); return STATE_Operational; } case ATimingService.CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3: { - TimerData td = (TimerData) generic_data__et; - action_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3(ifitem, td); + TimerData transitionData = (TimerData) generic_data__et; + action_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3(ifitem, transitionData); return STATE_Operational; } case ATimingService.CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4: @@ -242,34 +242,34 @@ public class ATimingService extends ActorClassBase { if (!handleSystemEvent(ifitem, evt, generic_data__et)) { switch (getState()) { - case STATE_Operational: - switch(trigger__et) { - case TRIG_timer__internalStartTimer: - { - chain__et = ATimingService.CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1; - catching_state__et = STATE_TOP; - } - break; - case TRIG_timer__internalStartTimeout: - { - chain__et = ATimingService.CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3; - catching_state__et = STATE_TOP; - } - break; - case TRIG_timer__kill: - { - chain__et = ATimingService.CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; - catching_state__et = STATE_TOP; - } - break; - default: - /* should not occur */ - break; - } - break; - default: - /* should not occur */ - break; + case STATE_Operational: + switch(trigger__et) { + case TRIG_timer__internalStartTimeout: + { + chain__et = ATimingService.CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__internalStartTimer: + { + chain__et = ATimingService.CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__kill: + { + chain__et = ATimingService.CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; } } if (chain__et != NOT_CAUGHT) { diff --git a/tests/org.eclipse.etrice.core.common.tests/build.properties b/tests/org.eclipse.etrice.core.common.tests/build.properties index d0cce7a46..5df6a2f43 100644 --- a/tests/org.eclipse.etrice.core.common.tests/build.properties +++ b/tests/org.eclipse.etrice.core.common.tests/build.properties @@ -1,5 +1,6 @@ source.. = src/,\ src-gen/,\ - models/ + models/,\ + xtend-gen/ bin.includes = META-INF/,\ . diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.java deleted file mode 100644 index 0198fb95c..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * hrr@protos.de (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import com.google.inject.Injector; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.etrice.core.RoomStandaloneSetup; -import org.eclipse.etrice.core.TestBase; -import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.tests.FSMGenModelTestsActivator; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; - -@SuppressWarnings("all") -public class FsmGenTestBase extends TestBase { - protected Resource res = null; - - protected ActorClass actor; - - protected IDiagnostician diagnostician = new NullDiagnostician(); - - @Extension - protected ExtendedFsmGenBuilder builder; - - protected GraphContainer getGraphContainer(final String roomFile, final String actorName) { - GraphContainer _xblockexpression = null; - { - this.prepare(FSMGenModelTestsActivator.getInstance().getBundle()); - this.res = this.getResource(roomFile); - EObject _get = this.res.getContents().get(0); - final Function1<ActorClass, Boolean> _function = new Function1<ActorClass, Boolean>() { - @Override - public Boolean apply(final ActorClass it) { - return Boolean.valueOf(it.getName().equals(actorName)); - } - }; - this.actor = IterableExtensions.<ActorClass>findFirst(((RoomModel) _get).getActorClasses(), _function); - final Injector injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration(); - ExtendedFsmGenBuilder _extendedFsmGenBuilder = new ExtendedFsmGenBuilder(injector, this.diagnostician); - this.builder = _extendedFsmGenBuilder; - _xblockexpression = this.builder.createTransformedModel(this.actor); - } - return _xblockexpression; - } - - protected void save(final GraphContainer gc, final String fileName) { - try { - final ResourceSetImpl rs = new ResourceSetImpl(); - final URI uri = URI.createFileURI((("./output/" + fileName) + ".fsmgen")); - final Resource res = rs.createResource(uri); - res.getContents().add(gc); - res.save(CollectionLiterals.<Object, Object>newHashMap()); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestCodeInheritance.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestCodeInheritance.java deleted file mode 100644 index c1ffb81b2..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestCodeInheritance.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.fsm.fSM.RefinedState; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.util.FSMHelpers; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestCodeInheritance extends FsmGenTestBase { - private GraphContainer gc; - - @Extension - private FSMHelpers fsmHelpers = new FSMHelpers(); - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("CodeInheritanceExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - Assert.assertFalse("diagnostician has no errors", this.diagnostician.isFailed()); - } - - @Test - public void testActionCodes_BaseEntryExit() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("BaseEntryExit")); - } - }; - final Node s = IteratorExtensions.<Node>findFirst(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function); - Assert.assertNotNull("state found", s); - StateGraphNode _stateGraphNode = s.getStateGraphNode(); - Assert.assertTrue("refined state", (_stateGraphNode instanceof RefinedState)); - StateGraphNode _stateGraphNode_1 = s.getStateGraphNode(); - final RefinedState rs = ((RefinedState) _stateGraphNode_1); - Assert.assertEquals("entry code", "// derived entry\n", this.fsmHelpers.getDetailCode(rs.getEntryCode())); - Assert.assertNull("exit code", rs.getExitCode()); - Assert.assertEquals("inherited entry", "// base entry\n", this.fsmHelpers.getDetailCode(this.fsmHelpers.getInheritedEntryCode(rs))); - Assert.assertEquals("inherited exit", "// base exit\n", this.fsmHelpers.getDetailCode(this.fsmHelpers.getInheritedExitCode(rs))); - } - - @Test - public void testActionCodes_Base() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("Base")); - } - }; - final Node s = IteratorExtensions.<Node>findFirst(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function); - Assert.assertNotNull("state found", s); - StateGraphNode _stateGraphNode = s.getStateGraphNode(); - Assert.assertTrue("refined state", (_stateGraphNode instanceof RefinedState)); - StateGraphNode _stateGraphNode_1 = s.getStateGraphNode(); - final RefinedState rs = ((RefinedState) _stateGraphNode_1); - Assert.assertNull("entry code", rs.getEntryCode()); - Assert.assertEquals("exit code", "// derived exit\n", this.fsmHelpers.getDetailCode(rs.getExitCode())); - Assert.assertEquals("inherited entry", "", this.fsmHelpers.getDetailCode(this.fsmHelpers.getInheritedEntryCode(rs))); - Assert.assertEquals("inherited exit", "", this.fsmHelpers.getDetailCode(this.fsmHelpers.getInheritedExitCode(rs))); - } - - @Test - public void testActionCodes_BaseSub() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("BaseSub")); - } - }; - final Node s = IteratorExtensions.<Node>findFirst(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function); - Assert.assertNotNull("state found", s); - StateGraphNode _stateGraphNode = s.getStateGraphNode(); - Assert.assertTrue("refined state", (_stateGraphNode instanceof RefinedState)); - StateGraphNode _stateGraphNode_1 = s.getStateGraphNode(); - final RefinedState rs = ((RefinedState) _stateGraphNode_1); - Assert.assertEquals("entry code", "// derived entry\n", this.fsmHelpers.getDetailCode(rs.getEntryCode())); - Assert.assertNull("exit code", rs.getExitCode()); - Assert.assertEquals("inherited entry", "", this.fsmHelpers.getDetailCode(this.fsmHelpers.getInheritedEntryCode(rs))); - Assert.assertEquals("inherited exit", "", this.fsmHelpers.getDetailCode(this.fsmHelpers.getInheritedExitCode(rs))); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestFlatFSM.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestFlatFSM.java deleted file mode 100644 index fc6734787..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestFlatFSM.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.fsm.fSM.ChoicePoint; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.TrPoint; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestFlatFSM extends FsmGenTestBase { - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("FlatFSMExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - } - - @Test - public void testFlatFSMItemCounts() { - Assert.assertEquals("number of nodes", 6, this.gc.getGraph().getNodes().size()); - Assert.assertEquals("number of links", 6, this.gc.getGraph().getLinks().size()); - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof State)); - } - }; - Assert.assertEquals("number of states", 4, IterableExtensions.size(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function))); - final Function1<Node, Boolean> _function_1 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof TrPoint)); - } - }; - Assert.assertEquals("number of tr points", 1, IterableExtensions.size(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function_1))); - final Function1<Node, Boolean> _function_2 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof ChoicePoint)); - } - }; - Assert.assertEquals("number of choice points", 1, IterableExtensions.size(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function_2))); - } - - @Test - public void testFlatFSMState1Connections() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1")); - } - }; - final Node s1 = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s1); - Assert.assertEquals("incoming links", 1, s1.getIncoming().size()); - Assert.assertEquals("outgoing links", 1, s1.getOutgoing().size()); - } - - @Test - public void testFlatFSMState3Connections() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state3")); - } - }; - final Node s3 = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s3); - Assert.assertEquals("incoming links", 1, s3.getIncoming().size()); - Assert.assertEquals("outgoing links", 0, s3.getOutgoing().size()); - } - - @Test - public void testFlatFSMCPConnections() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("cp0")); - } - }; - final Node cp = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getChoicePointNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("choice point found", cp); - Assert.assertEquals("incoming links", 1, cp.getIncoming().size()); - Assert.assertEquals("outgoing links", 2, cp.getOutgoing().size()); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestFlatInheritedFSM.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestFlatInheritedFSM.java deleted file mode 100644 index 8fbd53473..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestFlatInheritedFSM.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.fsm.fSM.RefinedState; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestFlatInheritedFSM extends FsmGenTestBase { - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("FlatInheritedFSMExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - } - - @Test - public void testFlatInheritedFSMItemCounts() { - Assert.assertEquals("number of nodes", 6, this.gc.getGraph().getNodes().size()); - Assert.assertEquals("number of links", 6, this.gc.getGraph().getLinks().size()); - Assert.assertEquals("number of states", 6, IterableExtensions.size(FsmGenExtensions.getStateNodes(this.gc.getGraph()))); - Assert.assertEquals("number of tr points", 0, IterableExtensions.size(FsmGenExtensions.getTrPointNodes(this.gc.getGraph()))); - Assert.assertEquals("number of choice points", 0, IterableExtensions.size(FsmGenExtensions.getChoicePointNodes(this.gc.getGraph()))); - } - - @Test - public void testFlatInheritedFSMState0Connections() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state0")); - } - }; - final Node s = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("incoming links", 1, s.getIncoming().size()); - Assert.assertEquals("outgoing links", 1, s.getOutgoing().size()); - } - - @Test - public void testHierFSMPointersIntoOriginalFSM() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1")); - } - }; - final Node n = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)); - final Function1<State, Boolean> _function_1 = new Function1<State, Boolean>() { - @Override - public Boolean apply(final State it) { - return Boolean.valueOf(it.getName().equals("state1")); - } - }; - final State s = IterableExtensions.<State>head(IterableExtensions.<State>filter(this.actor.getStateMachine().getStates(), _function_1)); - Assert.assertNotNull("node found", n); - Assert.assertNotNull("state found", s); - StateGraphNode _stateGraphNode = n.getStateGraphNode(); - Assert.assertTrue("RefinedState expected", (_stateGraphNode instanceof RefinedState)); - Assert.assertEquals("correct target", s, n.getStateGraphNode()); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestHierFSM.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestHierFSM.java deleted file mode 100644 index 64b14a66c..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestHierFSM.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.fsm.fSM.SimpleState; -import org.eclipse.etrice.core.fsm.fSM.State; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestHierFSM extends FsmGenTestBase { - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("HierFSMExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - } - - @Test - public void testHierFSMItemCounts() { - Assert.assertEquals("number of nodes", 3, this.gc.getGraph().getNodes().size()); - Assert.assertEquals("number of links", 4, this.gc.getGraph().getLinks().size()); - Assert.assertEquals("number of states", 3, IterableExtensions.size(FsmGenExtensions.getStateNodes(this.gc.getGraph()))); - Assert.assertEquals("number of tr points", 0, IterableExtensions.size(FsmGenExtensions.getTrPointNodes(this.gc.getGraph()))); - Assert.assertEquals("number of choice points", 0, IterableExtensions.size(FsmGenExtensions.getChoicePointNodes(this.gc.getGraph()))); - } - - @Test - public void testHierFSMSubGraphItemCounts() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1")); - } - }; - final Graph subGraph = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)).getSubgraph(); - Assert.assertEquals("number of nodes", 4, subGraph.getNodes().size()); - Assert.assertEquals("number of links", 4, subGraph.getLinks().size()); - Assert.assertEquals("number of states", 2, IterableExtensions.size(FsmGenExtensions.getStateNodes(subGraph))); - Assert.assertEquals("number of tr points", 2, IterableExtensions.size(FsmGenExtensions.getTrPointNodes(subGraph))); - Assert.assertEquals("number of choice points", 0, IterableExtensions.size(FsmGenExtensions.getChoicePointNodes(subGraph))); - } - - @Test - public void testHierFSMState1_1Connections() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1")); - } - }; - final Graph subGraph = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)).getSubgraph(); - final Function1<Node, Boolean> _function_1 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1_1")); - } - }; - final Node s1_1 = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(subGraph), _function_1)); - Assert.assertNotNull("state found", s1_1); - Assert.assertEquals("incoming links", 2, s1_1.getIncoming().size()); - Assert.assertEquals("outgoing links", 1, s1_1.getOutgoing().size()); - } - - @Test - public void testHierFSMPointersIntoOriginalFSM() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1")); - } - }; - final Node n = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(FsmGenExtensions.getStateNodes(this.gc.getGraph()), _function)); - final Function1<State, Boolean> _function_1 = new Function1<State, Boolean>() { - @Override - public Boolean apply(final State it) { - return Boolean.valueOf(it.getName().equals("state1")); - } - }; - final State s = IterableExtensions.<State>head(IterableExtensions.<State>filter(this.actor.getStateMachine().getStates(), _function_1)); - Assert.assertNotNull("node found", n); - Assert.assertNotNull("state found", s); - StateGraphNode _stateGraphNode = n.getStateGraphNode(); - Assert.assertTrue("State expected", (_stateGraphNode instanceof SimpleState)); - Assert.assertEquals("correct target", s, n.getStateGraphNode()); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestHierInheritedFSM.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestHierInheritedFSM.java deleted file mode 100644 index 466923419..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestHierInheritedFSM.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import com.google.common.base.Objects; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.ObjectExtensions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestHierInheritedFSM extends FsmGenTestBase { - private GraphContainer gc; - - private GraphContainer gc2; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("HierInheritedFSMExample.room", "TestActor"); - this.gc2 = this.getGraphContainer("HierInheritedFSMExample.room", "TestActor2"); - Assert.assertNotNull("graph context was created", this.gc); - Assert.assertNotNull("graph context was created", this.gc2); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - this.save(this.gc, "HierInheritedFSMExample"); - this.save(this.gc2, "HierInheritedFSMExample2"); - } - - @Test - public void testHierInheritedFSMItemCounts() { - Assert.assertEquals("number of nodes", 4, this.gc.getGraph().getNodes().size()); - Assert.assertEquals("number of links", 6, this.gc.getGraph().getLinks().size()); - Assert.assertEquals("number of states", 4, IterableExtensions.size(FsmGenExtensions.getStateNodes(this.gc.getGraph()))); - Assert.assertEquals("number of tr points", 0, IterableExtensions.size(FsmGenExtensions.getTrPointNodes(this.gc.getGraph()))); - Assert.assertEquals("number of choice points", 0, IterableExtensions.size(FsmGenExtensions.getChoicePointNodes(this.gc.getGraph()))); - } - - @Test - public void testHierInheritedFSMDeepItemCounts() { - Assert.assertEquals("number of nodes", 12, IteratorExtensions.size(FsmGenExtensions.getAllNodes(this.gc.getGraph()))); - Assert.assertEquals("number of links", 14, IteratorExtensions.size(FsmGenExtensions.getAllLinks(this.gc.getGraph()))); - Assert.assertEquals("number of states", 10, IteratorExtensions.size(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()))); - Assert.assertEquals("number of tr points", 2, IteratorExtensions.size(FsmGenExtensions.getAllTrPointNodes(this.gc.getGraph()))); - Assert.assertEquals("number of choice points", 0, IteratorExtensions.size(FsmGenExtensions.getAllChoicePointNodes(this.gc.getGraph()))); - } - - @Test - public void testHierInheritedFSMLinks() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1_0")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("incoming links", 2, s.getIncoming().size()); - Assert.assertEquals("outgoing links", 1, s.getOutgoing().size()); - } - - @Test - public void testOriginRefs() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - String _name = it.getStateGraphNode().getName(); - return Boolean.valueOf(Objects.equal(_name, "state0")); - } - }; - Iterable<Node> _filter = IterableExtensions.<Node>filter(this.gc2.getGraph().getNodes(), _function); - final Procedure1<Iterable<Node>> _function_1 = new Procedure1<Iterable<Node>>() { - @Override - public void apply(final Iterable<Node> it) { - Assert.assertEquals(1, IterableExtensions.size(it)); - Assert.assertEquals("RefinedState:TestActor2$state0", EcoreUtil.getURI(IterableExtensions.<Node>head(it).getStateGraphNode()).fragment()); - } - }; - ObjectExtensions.<Iterable<Node>>operator_doubleArrow(_filter, _function_1); - final Function1<Link, Boolean> _function_2 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - String _name = it.getTransition().getName(); - return Boolean.valueOf(Objects.equal(_name, "tr3")); - } - }; - Iterable<Link> _filter_1 = IterableExtensions.<Link>filter(this.gc2.getGraph().getLinks(), _function_2); - final Procedure1<Iterable<Link>> _function_3 = new Procedure1<Iterable<Link>>() { - @Override - public void apply(final Iterable<Link> it) { - Assert.assertEquals(1, IterableExtensions.size(it)); - Assert.assertEquals("RefinedTransition:TestActor2$tr3", EcoreUtil.getURI(IterableExtensions.<Link>head(it).getTransition()).fragment()); - } - }; - ObjectExtensions.<Iterable<Link>>operator_doubleArrow(_filter_1, _function_3); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestMultipleConnectedChoicepoint.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestMultipleConnectedChoicepoint.java deleted file mode 100644 index 27cf9e006..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestMultipleConnectedChoicepoint.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.fsm.fSM.CPBranchTransition; -import org.eclipse.etrice.core.fsm.fSM.ContinuationTransition; -import org.eclipse.etrice.core.fsm.fSM.Transition; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.DataType; -import org.eclipse.etrice.core.room.VarDecl; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestMultipleConnectedChoicepoint extends FsmGenTestBase { - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("MultipleConnectedChoicepointExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - this.builder.withCommonData(this.builder.withChainHeads(this.builder.withTriggersInStates(this.gc))); - Assert.assertFalse("diagnostician has no errors", this.diagnostician.isFailed()); - } - - @Test - public void testObjectNumbers() { - Assert.assertEquals("Number of states", 6, IteratorExtensions.size(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of choice points", 1, IteratorExtensions.size(FsmGenExtensions.getAllChoicePointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of transition points", 0, IteratorExtensions.size(FsmGenExtensions.getAllTransitionPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of entry points", 1, IteratorExtensions.size(FsmGenExtensions.getAllEntryPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of exit points", 1, IteratorExtensions.size(FsmGenExtensions.getAllExitPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of initial transitions", 1, IteratorExtensions.size(FsmGenExtensions.getAllInitialTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of triggered transitions", 5, IteratorExtensions.size(FsmGenExtensions.getAllTriggeredTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of continuation transitions", 3, IteratorExtensions.size(FsmGenExtensions.getAllContinuationTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of cpbranch transitions", 1, IteratorExtensions.size(FsmGenExtensions.getAllCPBranchTranisitionLinks(this.gc.getGraph()))); - } - - @Test - public void testChainsAndTriggers() { - Assert.assertEquals("transition chains", 6, IteratorExtensions.size(FsmGenExtensions.getAllChainHeads(this.gc.getGraph()))); - } - - @Test - public void testData() { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(((Transition) _transition).getName().equals("tr0")); - } - }; - Link tr = IterableExtensions.<Link>head(IterableExtensions.<Link>filter(this.gc.getGraph().getLinks(), _function)); - Assert.assertNotNull("transition found", tr); - TransitionBase _transition = tr.getTransition(); - Assert.assertTrue("transition is TriggeredTransition", (_transition instanceof TriggeredTransition)); - EObject _commonData = tr.getCommonData(); - VarDecl data = ((VarDecl) _commonData); - DataType _type = data.getRefType().getType(); - Assert.assertTrue("data is DataClass", (_type instanceof DataClass)); - Assert.assertEquals("data is of type", "DC2", data.getRefType().getType().getName()); - final Function1<Node, Boolean> _function_1 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(it.getStateGraphNode().getName().equals("state1")); - } - }; - final Node s = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function_1)); - Assert.assertNotNull("state found", s); - final Function1<Link, Boolean> _function_2 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(((Transition) _transition).getName().equals("tr2")); - } - }; - tr = IterableExtensions.<Link>head(IterableExtensions.<Link>filter(s.getSubgraph().getLinks(), _function_2)); - TransitionBase _transition_1 = tr.getTransition(); - Assert.assertTrue("transition is TriggeredTransition", (_transition_1 instanceof TriggeredTransition)); - EObject _commonData_1 = tr.getCommonData(); - data = ((VarDecl) _commonData_1); - DataType _type_1 = data.getRefType().getType(); - Assert.assertTrue("data is DataClass", (_type_1 instanceof DataClass)); - Assert.assertEquals("data is of type", "DC2", data.getRefType().getType().getName()); - final Function1<Link, Boolean> _function_3 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(((Transition) _transition).getName().equals("tr3")); - } - }; - tr = IterableExtensions.<Link>head(IterableExtensions.<Link>filter(s.getSubgraph().getLinks(), _function_3)); - TransitionBase _transition_2 = tr.getTransition(); - Assert.assertTrue("transition is TriggeredTransition", (_transition_2 instanceof TriggeredTransition)); - EObject _commonData_2 = tr.getCommonData(); - data = ((VarDecl) _commonData_2); - DataType _type_2 = data.getRefType().getType(); - Assert.assertTrue("data is DataClass", (_type_2 instanceof DataClass)); - Assert.assertEquals("data is of type", "DC4", data.getRefType().getType().getName()); - final Function1<Link, Boolean> _function_4 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(((Transition) _transition).getName().equals("tr1")); - } - }; - tr = IterableExtensions.<Link>head(IterableExtensions.<Link>filter(this.gc.getGraph().getLinks(), _function_4)); - Assert.assertNotNull("transition found", tr); - TransitionBase _transition_3 = tr.getTransition(); - Assert.assertTrue("transition is TriggeredTransition", (_transition_3 instanceof TriggeredTransition)); - EObject _commonData_3 = tr.getCommonData(); - data = ((VarDecl) _commonData_3); - DataType _type_3 = data.getRefType().getType(); - Assert.assertTrue("data is DataClass", (_type_3 instanceof DataClass)); - Assert.assertEquals("data is of type", "DC3", data.getRefType().getType().getName()); - final Function1<Link, Boolean> _function_5 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(((Transition) _transition).getName().equals("tr3")); - } - }; - tr = IterableExtensions.<Link>head(IterableExtensions.<Link>filter(this.gc.getGraph().getLinks(), _function_5)); - Assert.assertNotNull("transition found", tr); - TransitionBase _transition_4 = tr.getTransition(); - Assert.assertTrue("transition is ContinuationTransition", (_transition_4 instanceof ContinuationTransition)); - EObject _commonData_4 = tr.getCommonData(); - data = ((VarDecl) _commonData_4); - DataType _type_4 = data.getRefType().getType(); - Assert.assertTrue("data is DataClass", (_type_4 instanceof DataClass)); - Assert.assertEquals("data is of type", "DC", data.getRefType().getType().getName()); - final Function1<Link, Boolean> _function_6 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(((Transition) _transition).getName().equals("tr4")); - } - }; - tr = IterableExtensions.<Link>head(IterableExtensions.<Link>filter(this.gc.getGraph().getLinks(), _function_6)); - Assert.assertNotNull("transition found", tr); - TransitionBase _transition_5 = tr.getTransition(); - Assert.assertTrue("transition is CPBranchTransition", (_transition_5 instanceof CPBranchTransition)); - EObject _commonData_5 = tr.getCommonData(); - data = ((VarDecl) _commonData_5); - DataType _type_5 = data.getRefType().getType(); - Assert.assertTrue("data is DataClass", (_type_5 instanceof DataClass)); - Assert.assertEquals("data is of type", "DC", data.getRefType().getType().getName()); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestStatesInheritance.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestStatesInheritance.java deleted file mode 100644 index 099db3f80..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestStatesInheritance.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.fsm.fSM.ContinuationTransition; -import org.eclipse.etrice.core.fsm.fSM.SimpleState; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.Transition; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.etrice.core.naming.RoomNameProvider; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestStatesInheritance extends FsmGenTestBase { - private RoomNameProvider roomNameProvider = new RoomNameProvider(); - - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("StatesInheritanceExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - this.builder.withCommonData(this.builder.withChainHeads(this.builder.withTriggersInStates(this.gc))); - Assert.assertFalse("diagnostician has no errors", this.diagnostician.isFailed()); - } - - @Test - public void testNoTrigger() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("State3")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("non-leave state has no caught triggers", 0, s.getCaughtTriggers().size()); - } - - @Test - public void testObjectNumbers() { - Assert.assertEquals("Number of states", 11, IteratorExtensions.size(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()))); - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - StateGraphNode _stateGraphNode = it.getStateGraphNode(); - return Boolean.valueOf((_stateGraphNode instanceof SimpleState)); - } - }; - Assert.assertEquals("Number of states", 9, IteratorExtensions.size(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function))); - Assert.assertEquals("Number of choice points", 1, IteratorExtensions.size(FsmGenExtensions.getAllChoicePointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of transition points", 5, IteratorExtensions.size(FsmGenExtensions.getAllTransitionPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of entry points", 2, IteratorExtensions.size(FsmGenExtensions.getAllEntryPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of exit points", 1, IteratorExtensions.size(FsmGenExtensions.getAllExitPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of initial transitions", 3, IteratorExtensions.size(FsmGenExtensions.getAllInitialTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of triggered transitions", 17, IteratorExtensions.size(FsmGenExtensions.getAllTriggeredTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of continuation transitions", 4, IteratorExtensions.size(FsmGenExtensions.getAllContinuationTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of cpbranch transitions", 3, IteratorExtensions.size(FsmGenExtensions.getAllCPBranchTranisitionLinks(this.gc.getGraph()))); - } - - @Test - public void testChainsAndTriggers() { - Assert.assertEquals("transition chains", 20, IteratorExtensions.size(FsmGenExtensions.getAllChainHeads(this.gc.getGraph()))); - } - - @Test - public void testGraph() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(TestStatesInheritance.this.roomNameProvider.getFullPath(it.getStateGraphNode()).equals("State3_State3")); - } - }; - Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state exists", s); - Assert.assertEquals("number of incoming transitions", 3, s.getIncoming().size()); - Assert.assertEquals("number of outgoing transitions", 2, s.getOutgoing().size()); - Assert.assertEquals("active triggers", 6, s.getCaughtTriggers().size()); - final Function1<Node, Boolean> _function_1 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(TestStatesInheritance.this.roomNameProvider.getFullPath(it.getStateGraphNode()).equals("State2")); - } - }; - s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function_1)); - Assert.assertNotNull("state exists", s); - Assert.assertEquals("number of incoming transitions", 4, s.getIncoming().size()); - Assert.assertEquals("number of outgoing transitions", 1, s.getOutgoing().size()); - Assert.assertEquals("active triggers", 3, s.getCaughtTriggers().size()); - final Function1<Node, Boolean> _function_2 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(it.getStateGraphNode().getName().equals("CP1")); - } - }; - final Node cp = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllChoicePointNodes(this.gc.getGraph()), _function_2)); - Assert.assertNotNull("cp exists", cp); - Assert.assertEquals("number of incoming transitions", 1, cp.getIncoming().size()); - Assert.assertEquals("number of outgoing transitions", 4, cp.getOutgoing().size()); - final Function1<Link, Boolean> _function_3 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof ContinuationTransition)); - } - }; - final Iterable<Link> cts = IterableExtensions.<Link>filter(cp.getOutgoing(), _function_3); - Assert.assertEquals("Exactly one continuation (=default) transition", 1, IterableExtensions.size(cts)); - } - - @Test - public void testChains() { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(TestStatesInheritance.this.roomNameProvider.getFullPath(((Transition) _transition)).equals("State3_TRANS_tr1_FROM_tp1_TO_State3")); - } - }; - Link tr = IteratorExtensions.<Link>head(IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(this.gc.getGraph()), _function)); - Assert.assertNotNull("transition", tr); - Assert.assertEquals("one chain head", 1, tr.getChainHeads().size()); - TransitionBase _transition = IterableExtensions.<Link>head(tr.getChainHeads()).getTransition(); - Assert.assertEquals("chain name", "TRANS_tr5_FROM_tp0_TO_State3_tp1_BY_afct", this.roomNameProvider.getFullPath(((Transition) _transition))); - final Function1<Link, Boolean> _function_1 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(TestStatesInheritance.this.roomNameProvider.getFullPath(((Transition) _transition)).equals("State3_TRANS_tr8_FROM_tp6_TO_State2")); - } - }; - tr = IteratorExtensions.<Link>head(IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(this.gc.getGraph()), _function_1)); - Assert.assertNotNull("transition", tr); - Assert.assertEquals("one chain head", 1, tr.getChainHeads().size()); - TransitionBase _transition_1 = IterableExtensions.<Link>head(tr.getChainHeads()).getTransition(); - Assert.assertEquals("chain name", "TRANS_tr12_FROM_State5_TO_State3_tp6_BY_aport", this.roomNameProvider.getFullPath(((Transition) _transition_1))); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestStatesTriggers.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestStatesTriggers.java deleted file mode 100644 index ee2c0d9f7..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestStatesTriggers.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.fsm.fSM.ContinuationTransition; -import org.eclipse.etrice.core.fsm.fSM.Transition; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.etrice.core.naming.RoomNameProvider; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestStatesTriggers extends FsmGenTestBase { - private RoomNameProvider roomNameProvider = new RoomNameProvider(); - - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("StatesTriggersExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - this.builder.withCommonData(this.builder.withChainHeads(this.builder.withTriggersInStates(this.gc))); - Assert.assertFalse("diagnostician has no errors", this.diagnostician.isFailed()); - } - - @Test - public void testNoTrigger() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("State3")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("non-leave state has no caught triggers", 0, s.getCaughtTriggers().size()); - } - - @Test - public void testObjectNumbers() { - Assert.assertEquals("Number of states", 7, IteratorExtensions.size(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of choice points", 1, IteratorExtensions.size(FsmGenExtensions.getAllChoicePointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of transition points", 4, IteratorExtensions.size(FsmGenExtensions.getAllTransitionPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of entry points", 1, IteratorExtensions.size(FsmGenExtensions.getAllEntryPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of exit points", 1, IteratorExtensions.size(FsmGenExtensions.getAllExitPointNodes(this.gc.getGraph()))); - Assert.assertEquals("Number of initial transitions", 2, IteratorExtensions.size(FsmGenExtensions.getAllInitialTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of triggered transitions", 11, IteratorExtensions.size(FsmGenExtensions.getAllTriggeredTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of continuation transitions", 3, IteratorExtensions.size(FsmGenExtensions.getAllContinuationTranisitionLinks(this.gc.getGraph()))); - Assert.assertEquals("Number of cpbranch transitions", 2, IteratorExtensions.size(FsmGenExtensions.getAllCPBranchTranisitionLinks(this.gc.getGraph()))); - } - - @Test - public void testChainsAndTriggers() { - Assert.assertEquals("transition chains", 13, IteratorExtensions.size(FsmGenExtensions.getAllChainHeads(this.gc.getGraph()))); - } - - @Test - public void testGraph() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("State3")); - } - }; - Node s = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function)); - final Function1<Node, Boolean> _function_1 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("State3")); - } - }; - s = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(s.getSubgraph().getNodes(), _function_1)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("number of incoming transitions", 3, s.getIncoming().size()); - Assert.assertEquals("number of outgoing transitions", 2, s.getOutgoing().size()); - Assert.assertEquals("active triggers", 6, s.getCaughtTriggers().size()); - final Function1<Node, Boolean> _function_2 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("State2")); - } - }; - s = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function_2)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("number of incoming transitions", 4, s.getIncoming().size()); - Assert.assertEquals("number of outgoing transitions", 1, s.getOutgoing().size()); - Assert.assertEquals("active triggers", 3, s.getCaughtTriggers().size()); - final Function1<Node, Boolean> _function_3 = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("CP1")); - } - }; - final Node cp = IterableExtensions.<Node>head(IterableExtensions.<Node>filter(this.gc.getGraph().getNodes(), _function_3)); - Assert.assertNotNull("cp found", cp); - Assert.assertEquals("number of incoming transitions", 1, cp.getIncoming().size()); - Assert.assertEquals("number of outgoing transitions", 3, cp.getOutgoing().size()); - final Function1<Link, Boolean> _function_4 = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf((_transition instanceof ContinuationTransition)); - } - }; - final Iterable<Link> cts = IterableExtensions.<Link>filter(cp.getOutgoing(), _function_4); - Assert.assertEquals("Exactly one continuation (=default) transition", 1, IterableExtensions.size(cts)); - } - - @Test - public void testChains() { - final Function1<Link, Boolean> _function = new Function1<Link, Boolean>() { - @Override - public Boolean apply(final Link it) { - TransitionBase _transition = it.getTransition(); - return Boolean.valueOf(TestStatesTriggers.this.roomNameProvider.getFullPath(((Transition) _transition)).equals("State3_TRANS_tr1_FROM_tp1_TO_State3")); - } - }; - final Link tr = IteratorExtensions.<Link>head(IteratorExtensions.<Link>filter(FsmGenExtensions.getAllLinks(this.gc.getGraph()), _function)); - Assert.assertNotNull("transition found", tr); - Assert.assertEquals("one chain head", 1, tr.getChainHeads().size()); - TransitionBase _transition = IterableExtensions.<Link>head(tr.getChainHeads()).getTransition(); - Assert.assertEquals("correct chain head", "TRANS_tr5_FROM_tp0_TO_State3_tp1_BY_afct", this.roomNameProvider.getFullPath(((Transition) _transition))); - } -} diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestTrigger.java b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestTrigger.java deleted file mode 100644 index 222a967be..000000000 --- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/xtend-gen/org/eclipse/etrice/core/genmodel/fsm/tests/TestTrigger.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright (c) 2017 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Henrik Rentz-Reichert (initial contribution) - */ -package org.eclipse.etrice.core.genmodel.fsm.tests; - -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.TriggerExtensions; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.genmodel.fsm.tests.FsmGenTestBase; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestTrigger extends FsmGenTestBase { - private GraphContainer gc; - - @Before - public void SetUp() { - this.gc = this.getGraphContainer("TriggerExample.room", "TestActor"); - Assert.assertNotNull("graph context was created", this.gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(this.gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - this.builder.withTriggersInStates(this.gc); - Assert.assertFalse("diagnostician has no errors", this.diagnostician.isFailed()); - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state0_0")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertEquals("leave state triggers", 3, s.getCaughtTriggers().size()); - } - - @Test - public void testNoTrigger() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state0")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("non-leave state has no caught triggers", 0, s.getCaughtTriggers().size()); - } - - @Test - public void testTrigger_state0_0() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state0_0")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("leave state triggers", 3, s.getCaughtTriggers().size()); - Assert.assertEquals("1st trigger", this.trigger("in3"), s.getCaughtTriggers().get(0).getTrigger()); - Assert.assertEquals("1st trigger, transitions", 1, s.getCaughtTriggers().get(0).getLinks().size()); - Assert.assertEquals("2nd trigger", this.trigger("in1"), s.getCaughtTriggers().get(1).getTrigger()); - Assert.assertEquals("2nd trigger, transitions", 1, s.getCaughtTriggers().get(1).getLinks().size()); - Assert.assertEquals("3rd trigger", this.trigger("in2"), s.getCaughtTriggers().get(2).getTrigger()); - Assert.assertEquals("3rd trigger, transitions", 1, s.getCaughtTriggers().get(2).getLinks().size()); - } - - @Test - public void testTrigger_state0_1() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state0_1")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("leave state triggers", 2, s.getCaughtTriggers().size()); - Assert.assertEquals("1st trigger", this.trigger("in2"), s.getCaughtTriggers().get(0).getTrigger()); - Assert.assertEquals("1st trigger, transitions", 1, s.getCaughtTriggers().get(0).getLinks().size()); - Assert.assertEquals("2nd trigger", this.trigger("in1"), s.getCaughtTriggers().get(1).getTrigger()); - Assert.assertEquals("2nd trigger, transitions", 1, s.getCaughtTriggers().get(1).getLinks().size()); - } - - @Test - public void testTrigger_state1_0() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1_0")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("leave state triggers", 2, s.getCaughtTriggers().size()); - Assert.assertEquals("1st trigger", this.trigger("in1"), s.getCaughtTriggers().get(0).getTrigger()); - Assert.assertEquals("1st trigger, transitions", 1, s.getCaughtTriggers().get(0).getLinks().size()); - Assert.assertEquals("2nd trigger", this.trigger("in2"), s.getCaughtTriggers().get(1).getTrigger()); - Assert.assertEquals("2nd trigger, transitions", 1, s.getCaughtTriggers().get(1).getLinks().size()); - } - - @Test - public void testTrigger_state1_1() { - final Function1<Node, Boolean> _function = new Function1<Node, Boolean>() { - @Override - public Boolean apply(final Node it) { - return Boolean.valueOf(FsmGenExtensions.getName(it).equals("state1_1")); - } - }; - final Node s = IteratorExtensions.<Node>head(IteratorExtensions.<Node>filter(FsmGenExtensions.getAllStateNodes(this.gc.getGraph()), _function)); - Assert.assertNotNull("state found", s); - Assert.assertEquals("leave state triggers", 2, s.getCaughtTriggers().size()); - Assert.assertEquals("1st trigger", this.trigger("in1"), s.getCaughtTriggers().get(0).getTrigger()); - Assert.assertEquals("1st trigger, transitions", 3, s.getCaughtTriggers().get(0).getLinks().size()); - Assert.assertEquals("2nd trigger", this.trigger("in2"), s.getCaughtTriggers().get(1).getTrigger()); - Assert.assertEquals("2nd trigger, transitions", 1, s.getCaughtTriggers().get(1).getLinks().size()); - } - - public String trigger(final String msg) { - return (("p0" + TriggerExtensions.TRIGGER_SEP) + msg); - } -} diff --git a/tests/org.eclipse.etrice.core.room.tests/org.eclipse.etrice.core.room.tests.launch b/tests/org.eclipse.etrice.core.room.tests/org.eclipse.etrice.core.room.tests.launch index e7e2c69f0..6cb9c65b8 100644 --- a/tests/org.eclipse.etrice.core.room.tests/org.eclipse.etrice.core.room.tests.launch +++ b/tests/org.eclipse.etrice.core.room.tests/org.eclipse.etrice.core.room.tests.launch @@ -36,15 +36,9 @@ <stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="product" value="org.eclipse.platform.ide"/> <booleanAttribute key="run_in_ui_thread" value="false"/> -<<<<<<< Upstream, based on origin/master <stringAttribute key="selected_target_plugins" value="com.google.guava*15.0.0.v201403281430@default:default,com.google.guava*21.0.0.v20170206-1425@default:default,com.google.inject@default:default,javax.inject@default:default,javax.xml@default:default,org.antlr.runtime*3.2.0.v201101311130@default:default,org.antlr.runtime*4.3.0.v201502022030@default:default,org.apache.log4j@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources.win32.x86_64@default:false,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi@-1:true,org.eclipse.xtend.core@default:default,org.eclipse.xtend.lib.macro@default:default,org.eclipse.xtend.lib@default:default,org.eclipse.xtext.common.types@default:default,org.eclipse.xtext.logging@default:false,org.eclipse.xtext.smap@default:default,org.eclipse.xtext.util@default:default,org.eclipse.xtext.xbase.lib@default:default,org.eclipse.xtext.xbase@default:default,org.eclipse.xtext@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.objectweb.asm@default:default"/> <stringAttribute key="selected_workspace_plugins" value="org.eclipse.etrice.core.common@default:default,org.eclipse.etrice.core.fsm@default:default,org.eclipse.etrice.core.room.tests@default:default,org.eclipse.etrice.core.room@default:default,org.eclipse.etrice.logging@default:false"/> <booleanAttribute key="show_selected_only" value="true"/> -======= -<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.google.inject@default:default,com.ibm.icu@default:default,javax.inject@default:default,javax.xml@default:default,org.antlr.runtime@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.log4j@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources.win32.x86_64@default:false,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.win32.win32.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.ui.trace@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.eclipse.xtend.core@default:default,org.eclipse.xtend.lib.macro@default:default,org.eclipse.xtend.lib@default:default,org.eclipse.xtext.common.types@default:default,org.eclipse.xtext.logging@default:false,org.eclipse.xtext.smap@default:default,org.eclipse.xtext.util@default:default,org.eclipse.xtext.xbase.lib@default:default,org.eclipse.xtext.xbase@default:default,org.eclipse.xtext@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.objectweb.asm@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/> -<stringAttribute key="selected_workspace_plugins" value="org.eclipse.etrice.core.common@default:default,org.eclipse.etrice.core.fsm@default:default,org.eclipse.etrice.core.genmodel.fsm@default:default,org.eclipse.etrice.core.room.tests@default:default,org.eclipse.etrice.core.room@default:default,org.eclipse.etrice.logging@default:false"/> -<booleanAttribute key="show_selected_only" value="false"/> ->>>>>>> ff1be2e Bug 511330 - [core.genmodel.fsm] introduce simplified generator model for state machines <stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> <booleanAttribute key="tracing" value="false"/> <booleanAttribute key="useCustomFeatures" value="false"/> diff --git a/tests/org.eclipse.etrice.core.room.tests/xtend-gen/org/eclipse/etrice/core/TestNames.java b/tests/org.eclipse.etrice.core.room.tests/xtend-gen/org/eclipse/etrice/core/TestNames.java deleted file mode 100644 index 37641c0ed..000000000 --- a/tests/org.eclipse.etrice.core.room.tests/xtend-gen/org/eclipse/etrice/core/TestNames.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Copyright (c) 2015 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Juergen Haug (initial contribution) - */ -package org.eclipse.etrice.core; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; -import java.util.ArrayList; -import java.util.Map; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.etrice.core.CoreTestsActivator; -import org.eclipse.etrice.core.TestBase; -import org.eclipse.etrice.core.room.ExternalPort; -import org.eclipse.xtext.validation.AbstractValidationDiagnostic; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestNames extends TestBase { - private final Map<EObject, Boolean> nameErrorMap = Maps.<EObject, Boolean>newHashMap(); - - private Resource res; - - @Before - public void SetUp() { - this.prepare(CoreTestsActivator.getInstance().getBundle()); - this.res = this.getResource("NamesAreUnique.room"); - final EObject model = IterableExtensions.<EObject>head(this.res.getContents()); - final Diagnostic diag = this.getDiag(model); - final Consumer<Diagnostic> _function = (Diagnostic it) -> { - if ((it instanceof AbstractValidationDiagnostic)) { - final EObject obj = ((AbstractValidationDiagnostic)it).getSourceEObject(); - Boolean nameError = this.nameErrorMap.get(obj); - boolean _equals = Objects.equal(nameError, null); - if (_equals) { - nameError = Boolean.valueOf(false); - } - this.nameErrorMap.put(obj, Boolean.valueOf(((nameError).booleanValue() || this.isNameErrorMessage(it)))); - } - }; - diag.getChildren().forEach(_function); - } - - @Test - public void RoomClassNames() { - Assert.assertTrue(this.hasNameErrorMessage(this.res.getEObject("ActorClass:ClassDuplicate1"))); - Assert.assertTrue(this.hasNameErrorMessage(this.res.getEObject("LogicalSystem:ClassDuplicate1"))); - Assert.assertTrue(this.hasNameErrorMessage(this.res.getEObject("AnnotationType:ClassDuplicate1"))); - Assert.assertTrue(this.hasNameErrorMessage(this.res.getEObject("EnumerationType:ClassDuplicate1"))); - Assert.assertTrue(this.hasNameErrorMessage(this.res.getEObject("PrimitiveType:ClassDuplicate1"))); - } - - @Test - public void BaseClassNames() { - final EObject ac = this.res.getEObject("ActorClass:Base"); - final EObject dc = this.res.getEObject("DataClass:DBase"); - final ArrayList<EObject> items = CollectionLiterals.<EObject>newArrayList(ac, dc); - EList<EObject> _eContents = ac.eContents(); - Iterables.<EObject>addAll(items, _eContents); - EList<EObject> _eContents_1 = dc.eContents(); - Iterables.<EObject>addAll(items, _eContents_1); - Assert.assertEquals("Unexpected item count", 15, items.size()); - final Consumer<EObject> _function = (EObject it) -> { - Assert.assertFalse(("expected no name error: " + it), this.hasNameErrorMessage(it)); - }; - items.forEach(_function); - } - - @Test - public void OverrideNames() { - final EObject ac = this.res.getEObject("ActorClass:Override"); - final EObject dc = this.res.getEObject("DataClass:DOverride"); - final ArrayList<EObject> items = CollectionLiterals.<EObject>newArrayList(ac, dc); - EList<EObject> _eContents = ac.eContents(); - Iterables.<EObject>addAll(items, _eContents); - EList<EObject> _eContents_1 = dc.eContents(); - Iterables.<EObject>addAll(items, _eContents_1); - Assert.assertEquals("Unexpected item count", 9, items.size()); - final Consumer<EObject> _function = (EObject it) -> { - Assert.assertFalse(("expected no name error: " + it), this.hasNameErrorMessage(it)); - }; - items.forEach(_function); - } - - @Test - public void InheritedNames() { - final EObject ac = this.res.getEObject("ActorClass:Sub"); - final EObject dc = this.res.getEObject("DataClass:DSub"); - final ArrayList<EObject> items = CollectionLiterals.<EObject>newArrayList(); - final Function1<EObject, Boolean> _function = (EObject it) -> { - return Boolean.valueOf((!(it instanceof ExternalPort))); - }; - Iterable<EObject> _filter = IterableExtensions.<EObject>filter(ac.eContents(), _function); - Iterables.<EObject>addAll(items, _filter); - EList<EObject> _eContents = dc.eContents(); - Iterables.<EObject>addAll(items, _eContents); - Assert.assertEquals("Unexpected item count", 13, items.size()); - final Consumer<EObject> _function_1 = (EObject it) -> { - Assert.assertTrue(("expected name error: " + it), this.hasNameErrorMessage(it)); - }; - items.forEach(_function_1); - } - - @Test - public void FlatNames() { - final EObject ac = this.res.getEObject("ActorClass:Flat"); - final EObject dc = this.res.getEObject("DataClass:DFlat"); - final EObject lc = this.res.getEObject("DataClass:LFlat"); - final EObject sc = this.res.getEObject("DataClass:SFlat"); - final EObject enum_ = this.res.getEObject("DataClass:EnumFlat"); - final ArrayList<EObject> items = CollectionLiterals.<EObject>newArrayList(); - final Function1<EObject, Boolean> _function = (EObject it) -> { - return Boolean.valueOf((!(it instanceof ExternalPort))); - }; - Iterable<EObject> _filter = IterableExtensions.<EObject>filter(ac.eContents(), _function); - Iterables.<EObject>addAll(items, _filter); - EList<EObject> _eContents = dc.eContents(); - Iterables.<EObject>addAll(items, _eContents); - EList<EObject> _eContents_1 = lc.eContents(); - Iterables.<EObject>addAll(items, _eContents_1); - EList<EObject> _eContents_2 = sc.eContents(); - Iterables.<EObject>addAll(items, _eContents_2); - EList<EObject> _eContents_3 = enum_.eContents(); - Iterables.<EObject>addAll(items, _eContents_3); - Assert.assertEquals("Unexpected item count", 16, items.size()); - final Consumer<EObject> _function_1 = (EObject it) -> { - Assert.assertTrue(("expected name error: " + it), this.hasNameErrorMessage(it)); - }; - items.forEach(_function_1); - } - - private boolean hasNameErrorMessage(final EObject obj) { - return (this.nameErrorMap.containsKey(obj) && (this.nameErrorMap.get(obj)).booleanValue()); - } - - protected boolean isNameErrorMessage(final Diagnostic diag) { - final String message = diag.getMessage(); - return ((diag.getSeverity() >= Diagnostic.ERROR) && (message.contains("Duplicate name") || (message.contains("Name") && message.contains("is already assigned to")))); - } -} diff --git a/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room b/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room index 8091671e9..d8d7fdd82 100644 --- a/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room +++ b/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room @@ -30,7 +30,7 @@ RoomModel SendingDataTest { <pingInt16: PingPongPort> } action { - "PingPongPort.pongInt16(d);" + "PingPongPort.pongInt16(transitionData);" } } Transition tr1: reply -> reply { @@ -38,7 +38,7 @@ RoomModel SendingDataTest { <pingInt8: PingPongPort> } action { - "PingPongPort.pongInt8(d);" + "PingPongPort.pongInt8(transitionData);" } } Transition init: initial -> reply { } @@ -47,7 +47,7 @@ RoomModel SendingDataTest { <pingInt32: PingPongPort> } action { - "PingPongPort.pongInt32(d);" + "PingPongPort.pongInt32(transitionData);" } } Transition tr3: reply -> reply { @@ -55,7 +55,7 @@ RoomModel SendingDataTest { <pingFloat32: PingPongPort> } action { - "PingPongPort.pongFloat32(d);" + "PingPongPort.pongFloat32(transitionData);" } } Transition tr4: reply -> reply { @@ -63,27 +63,27 @@ RoomModel SendingDataTest { <pingFloat64: PingPongPort> } action { - "PingPongPort.pongFloat64(d);" + "PingPongPort.pongFloat64(transitionData);" } } Transition tr7: reply -> cp cp0 { triggers { <pingInt32Ref: PingPongPort guard { - "(*d)!=0" + "(*transitionData)!=0" }> } } Transition tr8: cp cp0 -> reply { action { - "PingPongPort.pongInt32((*d)+10);" + "PingPongPort.pongInt32((*transitionData)+10);" } } Transition tr6: cp cp0 -> reply { cond { - "(*d)!=5" + "(*transitionData)!=5" } action { - "PingPongPort.pongInt32(*d);" + "PingPongPort.pongInt32(*transitionData);" } } Transition tr9: reply -> reply { @@ -91,7 +91,7 @@ RoomModel SendingDataTest { <pingComplex: PingPongPort> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr11: reply -> reply { @@ -99,7 +99,7 @@ RoomModel SendingDataTest { <pingComplexRef: PingPongPort> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr5: reply -> reply { @@ -107,7 +107,7 @@ RoomModel SendingDataTest { <pingInt64: PingPongPort> } action { - "PingPongPort.pongInt64(d);" + "PingPongPort.pongInt64(transitionData);" } } Transition tr10: reply -> reply { @@ -115,30 +115,30 @@ RoomModel SendingDataTest { <pingInt16Ref: PingPongPort> } action { - "PingPongPort.pongInt16(*d);" + "PingPongPort.pongInt16(*transitionData);" } } Transition tr12: reply -> cp cp1 { triggers { <pingComplexRef: PingPongPort guard { - "d->i8ValPPD == 5" + "transitionData->i8ValPPD == 5" }> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr13: cp cp1 -> reply { action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr14: cp cp1 -> reply { cond { - "d->i8ValPPD==7" + "transitionData->i8ValPPD==7" } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr15: reply -> reply { @@ -146,7 +146,7 @@ RoomModel SendingDataTest { <pingComplexDerived: PingPongPort> } action { - "PingPongPort.pongComplexDerived(d);" + "PingPongPort.pongComplexDerived(transitionData);" } } Transition tr16: my tp0 -> my tp0 { @@ -230,7 +230,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==5){" + "if (transitionData==5){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -243,7 +243,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==19){" + "if (transitionData==19){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 3);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -256,7 +256,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==4711){" + "if (transitionData==4711){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 4);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -273,7 +273,7 @@ RoomModel SendingDataTest { "counter=0;" "if (lang == 1){" "/* Java cannot send references of primitive types */" - "\tif (d==4711){\t" + "\tif (transitionData==4711){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -281,7 +281,7 @@ RoomModel SendingDataTest { "} " "if (lang == 2){" "/* C */" - "\tif (d==4712){\t" + "\tif (transitionData==4712){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -295,7 +295,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==11470815){" + "if (transitionData==11470815){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 5);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -308,7 +308,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>3)&&(d<4)){" + "if ((transitionData>3)&&(transitionData<4)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 6);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -321,7 +321,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>7)&&(d<8)){" + "if ((transitionData>7)&&(transitionData<8)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 7);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -334,7 +334,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==6){" + "if (transitionData==6){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 10);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -347,7 +347,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==20){" + "if (transitionData==20){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 11);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -360,7 +360,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==4712){" + "if (transitionData==4712){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 12);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -373,7 +373,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==11470816){" + "if (transitionData==11470816){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 13);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -386,7 +386,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>13)&&(d<14)){" + "if ((transitionData>13)&&(transitionData<14)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 14);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -399,7 +399,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>28)&&(d<29)){" + "if ((transitionData>28)&&(transitionData<29)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 15);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -413,7 +413,7 @@ RoomModel SendingDataTest { }> } action { - "if (d==4712){\t" + "if (transitionData==4712){\t" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 17);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -430,7 +430,7 @@ RoomModel SendingDataTest { "counter++;" "if (lang == 1){" "/* Java cannot send references of primitive types */" - "\tif (d==19){\t" + "\tif (transitionData==19){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -438,7 +438,7 @@ RoomModel SendingDataTest { "} " "if (lang == 2){" "/* C */" - "\tif (d==20){\t" + "\tif (transitionData==20){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -454,7 +454,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==20){\t" + "if (transitionData==20){\t" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 16);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -492,13 +492,13 @@ RoomModel SendingDataTest { } action { "counter=0;" - "if (d->i8ValPPD==10){" + "if (transitionData->i8ValPPD==10){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 19);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" "}" "" - "if (d->complexVal.i32Val2PPDD==80){" + "if (transitionData->complexVal.i32Val2PPDD==80){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 20);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -514,7 +514,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d->i8ValPPD==10){" + "if (transitionData->i8ValPPD==10){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 18);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -526,13 +526,13 @@ RoomModel SendingDataTest { <pongComplexDerived: PingPongPort> } action { - "if (d->i8ValPPD==11){" + "if (transitionData->i8ValPPD==11){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 21);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" "}" "" - "if (d->i32Val3PPDe==150){" + "if (transitionData->i32Val3PPDe==150){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 22);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room index 2ff8d6533..12fc5f20b 100644 --- a/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room +++ b/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room @@ -29,12 +29,8 @@ RoomModel DetailExpressionTestModel { triggers { <out1: cPortEvent guard { "/* TODO activate action code editor */" -<<<<<<< Upstream, based on origin/master - "rPortData.in1 == numberArray[3] && accessibleMessageData && infoData.flag && actorOp(32) && rPortEvent.regularOp(32) && cPortEvent.conjugatedOp(32)" -======= "rPortData.in1 == numberArray[3] &&" "transitionData && infoData.flag" ->>>>>>> ff1be2e Bug 511330 - [core.genmodel.fsm] introduce simplified generator model for state machines }> } action diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room b/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room index b38d93c30..9f6d42b55 100644 --- a/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room +++ b/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room @@ -30,7 +30,7 @@ RoomModel SendingDataTest { <pingInt16: PingPongPort> } action { - "PingPongPort.pongInt16(d);" + "PingPongPort.pongInt16(transitionData);" } } Transition tr1: reply -> reply { @@ -38,7 +38,7 @@ RoomModel SendingDataTest { <pingInt8: PingPongPort> } action { - "PingPongPort.pongInt8(d);" + "PingPongPort.pongInt8(transitionData);" } } Transition init: initial -> reply { } @@ -47,7 +47,7 @@ RoomModel SendingDataTest { <pingInt32: PingPongPort> } action { - "PingPongPort.pongInt32(d);" + "PingPongPort.pongInt32(transitionData);" } } Transition tr3: reply -> reply { @@ -55,7 +55,7 @@ RoomModel SendingDataTest { <pingFloat32: PingPongPort> } action { - "PingPongPort.pongFloat32(d);" + "PingPongPort.pongFloat32(transitionData);" } } Transition tr4: reply -> reply { @@ -63,27 +63,27 @@ RoomModel SendingDataTest { <pingFloat64: PingPongPort> } action { - "PingPongPort.pongFloat64(d);" + "PingPongPort.pongFloat64(transitionData);" } } Transition tr7: reply -> cp cp0 { triggers { <pingInt32Ref: PingPongPort guard { - "(*d)!=0" + "(*transitionData)!=0" }> } } Transition tr8: cp cp0 -> reply { action { - "PingPongPort.pongInt32((*d)+10);" + "PingPongPort.pongInt32((*transitionData)+10);" } } Transition tr6: cp cp0 -> reply { cond { - "(*d)!=5" + "(*transitionData)!=5" } action { - "PingPongPort.pongInt32(*d);" + "PingPongPort.pongInt32(*transitionData);" } } Transition tr9: reply -> reply { @@ -91,7 +91,7 @@ RoomModel SendingDataTest { <pingComplex: PingPongPort> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr11: reply -> reply { @@ -99,7 +99,7 @@ RoomModel SendingDataTest { <pingComplexRef: PingPongPort> } action { - "PingPongPort.pongComplex(*d);" + "PingPongPort.pongComplex(*transitionData);" } } Transition tr5: reply -> reply { @@ -107,7 +107,7 @@ RoomModel SendingDataTest { <pingInt64: PingPongPort> } action { - "PingPongPort.pongInt64(d);" + "PingPongPort.pongInt64(transitionData);" } } Transition tr10: reply -> reply { @@ -115,30 +115,30 @@ RoomModel SendingDataTest { <pingInt16Ref: PingPongPort> } action { - "PingPongPort.pongInt16(*d);" + "PingPongPort.pongInt16(*transitionData);" } } Transition tr12: reply -> cp cp1 { triggers { <pingComplexRef: PingPongPort guard { - "d->i8ValPPD == 5" + "transitionData->i8ValPPD == 5" }> } action { - "PingPongPort.pongComplex(*d);" + "PingPongPort.pongComplex(*transitionData);" } } Transition tr13: cp cp1 -> reply { action { - "PingPongPort.pongComplex(*d);" + "PingPongPort.pongComplex(*transitionData);" } } Transition tr14: cp cp1 -> reply { cond { - "d->i8ValPPD==7" + "transitionData->i8ValPPD==7" } action { - "PingPongPort.pongComplex(*d);" + "PingPongPort.pongComplex(*transitionData);" } } Transition tr15: reply -> reply { @@ -146,7 +146,7 @@ RoomModel SendingDataTest { <pingComplexDerived: PingPongPort> } action { - "PingPongPort.pongComplexDerived(d);" + "PingPongPort.pongComplexDerived(transitionData);" } } Transition tr16: my tp0 -> my tp0 { @@ -230,7 +230,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==5){" + "if (transitionData==5){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -243,7 +243,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==19){" + "if (transitionData==19){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 3);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -256,7 +256,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==4711){" + "if (transitionData==4711){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 4);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -273,7 +273,7 @@ RoomModel SendingDataTest { "counter=0;" "if (lang == 1){" "/* Java cannot send references of primitive types */" - "\tif (d==4711){\t" + "\tif (transitionData==4711){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -281,7 +281,7 @@ RoomModel SendingDataTest { "} " "if (lang == 2){" "/* C */" - "\tif (d==4712){\t" + "\tif (transitionData==4712){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -295,7 +295,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==11470815){" + "if (transitionData==11470815){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 5);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -308,7 +308,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>3)&&(d<4)){" + "if ((transitionData>3)&&(transitionData<4)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 6);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -321,7 +321,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>7)&&(d<8)){" + "if ((transitionData>7)&&(transitionData<8)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 7);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -334,7 +334,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==6){" + "if (transitionData==6){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 10);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -347,7 +347,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==20){" + "if (transitionData==20){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 11);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -360,7 +360,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==4712){" + "if (transitionData==4712){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 12);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -373,7 +373,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==11470816){" + "if (transitionData==11470816){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 13);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -386,7 +386,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>13)&&(d<14)){" + "if ((transitionData>13)&&(transitionData<14)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 14);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -399,7 +399,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>28)&&(d<29)){" + "if ((transitionData>28)&&(transitionData<29)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 15);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -413,7 +413,7 @@ RoomModel SendingDataTest { }> } action { - "if (d==4712){\t" + "if (transitionData==4712){\t" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 17);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -430,7 +430,7 @@ RoomModel SendingDataTest { "counter++;" "if (lang == 1){" "/* Java cannot send references of primitive types */" - "\tif (d==19){\t" + "\tif (transitionData==19){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -438,7 +438,7 @@ RoomModel SendingDataTest { "} " "if (lang == 2){" "/* C */" - "\tif (d==20){\t" + "\tif (transitionData==20){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -454,7 +454,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==20){\t" + "if (transitionData==20){\t" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 16);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -492,13 +492,13 @@ RoomModel SendingDataTest { } action { "counter=0;" - "if (d.i8ValPPD==10){" + "if (transitionData.i8ValPPD==10){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 19);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" "}" "" - "if (d.complexVal.i32Val2PPDD==80){" + "if (transitionData.complexVal.i32Val2PPDD==80){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 20);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -514,7 +514,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d.i8ValPPD==10){" + "if (transitionData.i8ValPPD==10){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 18);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -526,13 +526,13 @@ RoomModel SendingDataTest { <pongComplexDerived: PingPongPort> } action { - "if (d.i8ValPPD==11){" + "if (transitionData.i8ValPPD==11){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 21);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" "}" "" - "if (d.i32Val3PPDe==150){" + "if (transitionData.i32Val3PPDe==150){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 22);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room index 9f393fd1a..331261002 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room @@ -43,7 +43,7 @@ RoomModel DynamicActorTest1 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da1Test/appl/cont/opt/sub2/deep_sub\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC3:/JavaGenTests/da1Test/appl/cont/opt/sub2/deep_sub\"));" "opt.destroyOptionalActor();" } } @@ -52,7 +52,7 @@ RoomModel DynamicActorTest1 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC1:/JavaGenTests/da1Test/appl/cont/opt/sub1\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC1:/JavaGenTests/da1Test/appl/cont/opt/sub1\"));" "opt.destroyOptionalActor();" } } diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room index 9893c7dbf..ed4439255 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room @@ -43,7 +43,7 @@ RoomModel DynamicActorTest2 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:0/sub2/deep_sub\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:0/sub2/deep_sub\"));" } } Transition tr2: CreateOptional1 -> ReceivedHelloAgain { @@ -51,7 +51,7 @@ RoomModel DynamicActorTest2 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:0/sub2/deep_sub\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:0/sub2/deep_sub\"));" } } Transition tr1: ReceivedHelloAgain -> Destroy0 { @@ -59,7 +59,7 @@ RoomModel DynamicActorTest2 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC1:/JavaGenTests/da2Test/appl/cont/optarray:1/sub1\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC1:/JavaGenTests/da2Test/appl/cont/optarray:1/sub1\"));" } } Transition tr3: Destroy0 -> Destroy1Create2 { @@ -67,7 +67,7 @@ RoomModel DynamicActorTest2 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC1:/JavaGenTests/da2Test/appl/cont/optarray:1/sub1\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC1:/JavaGenTests/da2Test/appl/cont/optarray:1/sub1\"));" } } Transition tr4: Destroy1Create2 -> Done { @@ -75,7 +75,7 @@ RoomModel DynamicActorTest2 { <hello: p0> } action { - "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:1/sub2/deep_sub\"));" + "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", transitionData.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:1/sub2/deep_sub\"));" } } State CreateOptional2 { diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room index 152b36811..892a80686 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room @@ -39,7 +39,7 @@ RoomModel DynamicActorTest3 { <hello: opt> } action { - "System.out.println(\"controller received \"+txt);" + "System.out.println(\"controller received \"+transitionData);" } } Transition tr2: createOpt1 -> UnexpectedError { @@ -101,7 +101,7 @@ RoomModel DynamicActorTest3 { <create: fct> } action { - "if (optRef.createOptionalActor(ac, getThread()))" + "if (optRef.createOptionalActor(transitionData, getThread()))" "\tfct.ok();" "else" "\tfct.error();" @@ -165,7 +165,7 @@ RoomModel DynamicActorTest3 { <hello: hlp> } action { - "System.out.println(\"helper said \"+txt);" + "System.out.println(\"helper said \"+transitionData);" "p0.hello(\"this is AC1, instance \"+getInstancePath());" } } diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room index 3deb03ddd..14de05c25 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room @@ -40,7 +40,7 @@ RoomModel DynamicActorTest4 { <hello: p0> } action { - "System.out.println(txt+\"\\n\");" + "System.out.println(transitionData+\"\\n\");" "opt.destroyOptionalActor();" "dumpTree(\"after deletion of Optional2\");" } diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room index 0a4d3d8c0..c2680d7d0 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room @@ -42,7 +42,7 @@ RoomModel DynamicActorTest5 { action { "dumpTree(\"after received hello\");" "" - "System.out.println(\"received \"+txt);" + "System.out.println(\"received \"+transitionData);" "" "etUnit_testFinished(caseId);" } diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room index 174b03d01..d1b69ba3a 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room @@ -41,7 +41,7 @@ RoomModel DynamicActorTest6 { <hello: pin> } action { - "System.out.println(\"Controller received: \"+txt);" + "System.out.println(\"Controller received: \"+transitionData);" } } Transition tr2: Destroy -> CreateAgain { @@ -59,7 +59,7 @@ RoomModel DynamicActorTest6 { <hello: pin> } action { - "System.out.println(\"Controller received: \"+txt);" + "System.out.println(\"Controller received: \"+transitionData);" } } State CreateOptionals { @@ -212,9 +212,9 @@ RoomModel DynamicActorTest6 { <hello: pin> } action { - "System.out.println(\"AC2 received \"+txt);" + "System.out.println(\"AC2 received \"+transitionData);" "" - "pout.hello(\"AC2: forwarding \"+txt);" + "pout.hello(\"AC2: forwarding \"+transitionData);" } } State Ready diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room index ec9aff939..99755e2cf 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room @@ -59,7 +59,7 @@ RoomModel DynamicActorTest7 { <hello: op> } action { - "System.out.println(\"received \"+txt);" + "System.out.println(\"received \"+transitionData);" } } Transition tr1: DestroyAndCreate -> DestroyAndRestore { @@ -67,7 +67,7 @@ RoomModel DynamicActorTest7 { <hello: op> } action { - "System.out.println(\"received \"+txt);" + "System.out.println(\"received \"+transitionData);" } } Transition tr2: DestroyAndRestore -> LoadInArray { @@ -75,7 +75,7 @@ RoomModel DynamicActorTest7 { <hello: op> } action { - "System.out.println(\"received \"+txt);" + "System.out.println(\"received \"+transitionData);" } } Transition tr3: LoadInArray -> ReceivedHello { @@ -83,7 +83,7 @@ RoomModel DynamicActorTest7 { <hello: opa> } action { - "System.out.println(\"received \"+txt);" + "System.out.println(\"received \"+transitionData);" } } Transition tr4: ReceivedHello -> Done { @@ -91,7 +91,7 @@ RoomModel DynamicActorTest7 { <hello: opa> } action { - "System.out.println(\"received \"+txt);" + "System.out.println(\"received \"+transitionData);" } } State Init { diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room index 39a66aeee..42f0554ac 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room @@ -28,7 +28,7 @@ RoomModel SendingDataTest { <pingInt16: PingPongPort> } action { - "PingPongPort.pongInt16(d);" + "PingPongPort.pongInt16(transitionData);" } } Transition tr1: reply -> reply { @@ -36,7 +36,7 @@ RoomModel SendingDataTest { <pingInt8: PingPongPort> } action { - "PingPongPort.pongInt8(d);" + "PingPongPort.pongInt8(transitionData);" } } Transition init: initial -> reply { } @@ -45,7 +45,7 @@ RoomModel SendingDataTest { <pingInt32: PingPongPort> } action { - "PingPongPort.pongInt32(d);" + "PingPongPort.pongInt32(transitionData);" } } Transition tr3: reply -> reply { @@ -53,7 +53,7 @@ RoomModel SendingDataTest { <pingFloat32: PingPongPort> } action { - "PingPongPort.pongFloat32(d);" + "PingPongPort.pongFloat32(transitionData);" } } Transition tr4: reply -> reply { @@ -61,27 +61,27 @@ RoomModel SendingDataTest { <pingFloat64: PingPongPort> } action { - "PingPongPort.pongFloat64(d);" + "PingPongPort.pongFloat64(transitionData);" } } Transition tr7: reply -> cp cp0 { triggers { <pingInt32Ref: PingPongPort guard { - "d!=0" + "transitionData!=0" }> } } Transition tr8: cp cp0 -> reply { action { - "PingPongPort.pongInt32(d+10);" + "PingPongPort.pongInt32(transitionData+10);" } } Transition tr6: cp cp0 -> reply { cond { - "d!=5" + "transitionData!=5" } action { - "PingPongPort.pongInt32(d);" + "PingPongPort.pongInt32(transitionData);" } } Transition tr9: reply -> reply { @@ -89,7 +89,7 @@ RoomModel SendingDataTest { <pingComplex: PingPongPort> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr11: reply -> reply { @@ -97,7 +97,7 @@ RoomModel SendingDataTest { <pingComplexRef: PingPongPort> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr5: reply -> reply { @@ -105,7 +105,7 @@ RoomModel SendingDataTest { <pingInt64: PingPongPort> } action { - "PingPongPort.pongInt64(d);" + "PingPongPort.pongInt64(transitionData);" } } Transition tr10: reply -> reply { @@ -113,30 +113,30 @@ RoomModel SendingDataTest { <pingInt16Ref: PingPongPort> } action { - "PingPongPort.pongInt16(d);" + "PingPongPort.pongInt16(transitionData);" } } Transition tr12: reply -> cp cp1 { triggers { <pingComplexRef: PingPongPort guard { - "d.i8Val == 5" + "transitionData.i8Val == 5" }> } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr13: cp cp1 -> reply { action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr14: cp cp1 -> reply { cond { - "d.i8Val==7" + "transitionData.i8Val==7" } action { - "PingPongPort.pongComplex(d);" + "PingPongPort.pongComplex(transitionData);" } } Transition tr15: reply -> reply { @@ -144,7 +144,7 @@ RoomModel SendingDataTest { <pingComplexDerived: PingPongPort> } action { - "PingPongPort.pongComplexDerived(d);" + "PingPongPort.pongComplexDerived(transitionData);" } } ChoicePoint cp0 @@ -222,7 +222,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==5){" + "if (transitionData==5){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -235,7 +235,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==19){" + "if (transitionData==19){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 3);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -248,7 +248,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==4711){" + "if (transitionData==4711){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 4);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -265,7 +265,7 @@ RoomModel SendingDataTest { "counter=0;" "if (lang == 1){" "// Java cannot send references of primitive types" - "\tif (d==4711){\t" + "\tif (transitionData==4711){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -273,7 +273,7 @@ RoomModel SendingDataTest { "} " "if (lang == 2){" "// C" - "\tif (d==4712){\t" + "\tif (transitionData==4712){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -287,7 +287,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==11470815){" + "if (transitionData==11470815){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 5);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -300,7 +300,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>3)&&(d<4)){" + "if ((transitionData>3)&&(transitionData<4)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 6);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -313,7 +313,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>7)&&(d<8)){" + "if ((transitionData>7)&&(transitionData<8)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 7);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -326,7 +326,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==6){" + "if (transitionData==6){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 10);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -339,7 +339,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==20){" + "if (transitionData==20){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 11);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -352,7 +352,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==4712){" + "if (transitionData==4712){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 12);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -365,7 +365,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==11470816){" + "if (transitionData==11470816){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 13);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -378,7 +378,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>13)&&(d<14)){" + "if ((transitionData>13)&&(transitionData<14)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 14);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -391,7 +391,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if ((d>28)&&(d<29)){" + "if ((transitionData>28)&&(transitionData<29)){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 15);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -405,7 +405,7 @@ RoomModel SendingDataTest { }> } action { - "if (d==4712){\t" + "if (transitionData==4712){\t" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 17);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -422,7 +422,7 @@ RoomModel SendingDataTest { "counter++;" "if (lang == 1){" "// Java cannot send references of primitive types" - "\tif (d==19){\t" + "\tif (transitionData==19){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -430,7 +430,7 @@ RoomModel SendingDataTest { "} " "if (lang == 2){" "// C" - "\tif (d==20){\t" + "\tif (transitionData==20){\t" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" "\t}else{" "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -446,7 +446,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d==20){\t" + "if (transitionData==20){\t" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 16);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -484,13 +484,13 @@ RoomModel SendingDataTest { } action { "counter=0;" - "if (d.i8Val==10){" + "if (transitionData.i8Val==10){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 19);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" "}" "" - "if (d.complexVal.i32Val2==80){" + "if (transitionData.complexVal.i32Val2==80){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 20);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -506,7 +506,7 @@ RoomModel SendingDataTest { } action { "counter++;" - "if (d.i8Val==10){" + "if (transitionData.i8Val==10){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 18);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" @@ -518,13 +518,13 @@ RoomModel SendingDataTest { <pongComplexDerived: PingPongPort> } action { - "if (d.i8Val==11){" + "if (transitionData.i8Val==11){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 21);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" "}" "" - "if (d.i32Val3==150){" + "if (transitionData.i32Val3==150){" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 22);" "}else{" "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room index 939f5c211..300e23378 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room @@ -141,7 +141,7 @@ RoomModel StoreRestoreTest { <valueIs: prt> } action { - "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, val);" + "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, transitionData);" } } Transition tr4: Prepare2 -> Loop { @@ -154,7 +154,7 @@ RoomModel StoreRestoreTest { <valueIs: prt> } action { - "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, val);" + "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, transitionData);" } } ChoicePoint cp0 diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room index 5e2b2c4f3..456827558 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room +++ b/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room @@ -1,160 +1,160 @@ -RoomModel TCPTest {
-
- import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
- import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
- import room.basic.service.tcp.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/TcpService.room"
-
- ActorClass TCPTestTop {
- @TestInstance
- Structure {
- ActorRef ref0: ATcpServer
- ActorRef ref1 [ 5 ]: ATcpClient
- ActorRef ref2: Tester
- Binding ref2.p1 and ref0.PayloadPort
- Binding ref2.p0 and ref0.ControlPort
- Binding ref2.p2 and ref1.ControlPort
- Binding ref2.p3 and ref1.PayloadPort
- }
- Behavior { }
- }
-
- ActorClass Tester {
- Interface {
- conjugated Port p0: PTcpControl
- conjugated Port p1: PTcpPayload
- conjugated Port p2 [*]: PTcpControl
- conjugated Port p3 [5]: PTcpPayload
- }
- Structure {
- external Port p0
- external Port p1
- external Port p2
- external Port p3
- Attribute controlData:DTcpControl
- Attribute testData:DTcpPayload
- Attribute counter:int32
- Attribute resultPattern:int32
- Attribute pattern:int32
- Attribute caseId: int32
- Attribute resultlist[3]: int16 = "{1,2,3}"
-
- }
- Behavior {
- ctor {
- "caseId = etUnit_openAll(\"log\", \"TCPTest\", \"org.eclipse.etrice.generator.java.tests.TCPTest\", \"TCPTest_case\");"
- }
- dtor {
- "etUnit_closeAll(caseId);"
- }
- StateMachine {
- Transition init: initial -> state0 {
- action {
- "EXPECT_ORDER_START(caseId,resultlist,3);"
- "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);"
- "// open Server"
- "controlData.setIPAddr(\"127.0.0.1\");"
- "controlData.setTcpPort(4711);"
- "p0.open(controlData);"
- }
- }
- Transition tr0: state0 -> state1 {
- triggers {
- <established: p0>
- }
- action {
- "// open 5 clients"
- "for (int i=0;i<p2.getReplication();i++){"
- "p2[i].open(controlData);"
- "}"
- "counter=0;"
- }
- }
- Transition tr1: state1 -> cp cp0 {
- triggers {
- <established: p2>
- }
- action {
- "counter++;"
- }
- }
- Transition tr4: cp cp0 -> state1
- Transition tr5: cp cp0 -> state2 {
- cond {
- "counter>=p2.getReplication()"
- }
- action {
- "String s=new String (\"Test!\");"
- "testData.setData(s.getBytes());"
- "testData.setLength(s.length());"
- "testData.setConnectionId(0);"
- "for (int i=0; i<p3.getReplication();i++){"
- "\tp3[i].send(testData);"
- "}"
- "counter=0;"
- "resultPattern=0;"
- }
- }
- Transition tr8: state2 -> cp cp2 {
- triggers {
- <receive: p3>
- }
- action {
- "resultPattern+=p3.getIndexOf(ifitem);"
- "//System.out.printf(\"c:%d, Idx:%d!\\n\", counter,p3.getIndexOf(ifitem));"
- "counter++;"
- }
- }
- Transition tr9: cp cp2 -> state2
- Transition tr10: cp cp2 -> cp cp1 {
- cond {
- "counter>=p2.getReplication()"
- }
- action {
- "int i;"
- "p0.close();"
- "// close all clients"
- "p2.close();"
- "pattern=0;"
- "for (i=0;i<p2.getReplication();i++){"
- "\tpattern+=i;"
- "}"
- }
- }
- Transition tr3: state2 -> state2 {
- triggers {
- <receive: p1>
- }
- action {
- "p1.send(data);"
- }
- }
- Transition tr2: cp cp1 -> test_failed
- Transition tr6: cp cp1 -> test_ok {
- cond {
- "pattern==resultPattern"
- }
- }
- ChoicePoint cp0
- ChoicePoint cp2
- ChoicePoint cp1
- State state0
- State state1
- State state2
- State test_ok {
- entry {
- "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);"
- "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);"
- "etUnit_testFinished(caseId);"
- }
- }
- State test_failed {
- entry {
- "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);"
- "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);"
- "etUnit_testFinished(caseId);"
- }
- }
- }
- }
- }
+RoomModel TCPTest { + + import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room" + import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room" + import room.basic.service.tcp.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/TcpService.room" + + ActorClass TCPTestTop { + @TestInstance + Structure { + ActorRef ref0: ATcpServer + ActorRef ref1 [ 5 ]: ATcpClient + ActorRef ref2: Tester + Binding ref2.p1 and ref0.PayloadPort + Binding ref2.p0 and ref0.ControlPort + Binding ref2.p2 and ref1.ControlPort + Binding ref2.p3 and ref1.PayloadPort + } + Behavior { } + } + + ActorClass Tester { + Interface { + conjugated Port p0: PTcpControl + conjugated Port p1: PTcpPayload + conjugated Port p2 [*]: PTcpControl + conjugated Port p3 [5]: PTcpPayload + } + Structure { + external Port p0 + external Port p1 + external Port p2 + external Port p3 + Attribute controlData:DTcpControl + Attribute testData:DTcpPayload + Attribute counter:int32 + Attribute resultPattern:int32 + Attribute pattern:int32 + Attribute caseId: int32 + Attribute resultlist[3]: int16 = "{1,2,3}" + + } + Behavior { + ctor { + "caseId = etUnit_openAll(\"log\", \"TCPTest\", \"org.eclipse.etrice.generator.java.tests.TCPTest\", \"TCPTest_case\");" + } + dtor { + "etUnit_closeAll(caseId);" + } + StateMachine { + Transition init: initial -> state0 { + action { + "EXPECT_ORDER_START(caseId,resultlist,3);" + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);" + "// open Server" + "controlData.setIPAddr(\"127.0.0.1\");" + "controlData.setTcpPort(4711);" + "p0.open(controlData);" + } + } + Transition tr0: state0 -> state1 { + triggers { + <established: p0> + } + action { + "// open 5 clients" + "for (int i=0;i<p2.getReplication();i++){" + "p2[i].open(controlData);" + "}" + "counter=0;" + } + } + Transition tr1: state1 -> cp cp0 { + triggers { + <established: p2> + } + action { + "counter++;" + } + } + Transition tr4: cp cp0 -> state1 + Transition tr5: cp cp0 -> state2 { + cond { + "counter>=p2.getReplication()" + } + action { + "String s=new String (\"Test!\");" + "testData.setData(s.getBytes());" + "testData.setLength(s.length());" + "testData.setConnectionId(0);" + "for (int i=0; i<p3.getReplication();i++){" + "\tp3[i].send(testData);" + "}" + "counter=0;" + "resultPattern=0;" + } + } + Transition tr8: state2 -> cp cp2 { + triggers { + <receive: p3> + } + action { + "resultPattern+=p3.getIndexOf(ifitem);" + "//System.out.printf(\"c:%d, Idx:%d!\\n\", counter,p3.getIndexOf(ifitem));" + "counter++;" + } + } + Transition tr9: cp cp2 -> state2 + Transition tr10: cp cp2 -> cp cp1 { + cond { + "counter>=p2.getReplication()" + } + action { + "int i;" + "p0.close();" + "// close all clients" + "p2.close();" + "pattern=0;" + "for (i=0;i<p2.getReplication();i++){" + "\tpattern+=i;" + "}" + } + } + Transition tr3: state2 -> state2 { + triggers { + <receive: p1> + } + action { + "p1.send(transitionData);" + } + } + Transition tr2: cp cp1 -> test_failed + Transition tr6: cp cp1 -> test_ok { + cond { + "pattern==resultPattern" + } + } + ChoicePoint cp0 + ChoicePoint cp2 + ChoicePoint cp1 + State state0 + State state1 + State state2 + State test_ok { + entry { + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);" + "etUnit_testFinished(caseId);" + } + } + State test_failed { + entry { + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);" + "etUnit_testFinished(caseId);" + } + } + } + } + }
}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.java.tests/targetModels/TCPTest.room b/tests/org.eclipse.etrice.generator.java.tests/targetModels/TCPTest.room index 7508f94f1..b337eb919 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/targetModels/TCPTest.room +++ b/tests/org.eclipse.etrice.generator.java.tests/targetModels/TCPTest.room @@ -1,160 +1,160 @@ -RoomModel TCPTest { - - import room.basic.etunit.* from "Tests.room" - import room.basic.types.* from "Types.room" - import room.basic.service.tcp.* from "TcpService.room" - - ActorClass TCPTestTop { - @TestInstance - Structure { - ActorRef ref0: ATcpServer - ActorRef ref1 [ 5 ]: ATcpClient - ActorRef ref2: Tester - Binding ref2.p1 and ref0.PayloadPort - Binding ref2.p0 and ref0.ControlPort - Binding ref2.p2 and ref1.ControlPort - Binding ref2.p3 and ref1.PayloadPort - } - Behavior { } - } - - ActorClass Tester { - Interface { - conjugated Port p0: PTcpControl - conjugated Port p1: PTcpPayload - conjugated Port p2 [*]: PTcpControl - conjugated Port p3 [5]: PTcpPayload - } - Structure { - external Port p0 - external Port p1 - external Port p2 - external Port p3 - Attribute controlData:DTcpControl - Attribute testData:DTcpPayload - Attribute counter:int32 - Attribute resultPattern:int32 - Attribute pattern:int32 - Attribute caseId: int32 - Attribute resultlist[3]: int16 = "{1,2,3}" - - } - Behavior { - ctor { - "caseId = etUnit_openAll(\"log/testlog\", \"TCPTest\", \"org.eclipse.etrice.generator.common.tests.TCPTest\", \"TCPTest_case\");" - } - dtor { - "etUnit_closeAll(caseId);" - } - StateMachine { - Transition init: initial -> state0 { - action { - "EXPECT_ORDER_START(caseId,resultlist,3);" - "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);" - "// open Server" - "controlData.setIPAddr(\"127.0.0.1\");" - "controlData.setTcpPort(4711);" - "p0.open(controlData);" - } - } - Transition tr0: state0 -> state1 { - triggers { - <established: p0> - } - action { - "// open 5 clients" - "for (int i=0;i<p2.getReplication();i++){" - "p2[i].open(controlData);" - "}" - "counter=0;" - } - } - Transition tr1: state1 -> cp cp0 { - triggers { - <established: p2> - } - action { - "counter++;" - } - } - Transition tr4: cp cp0 -> state1 - Transition tr5: cp cp0 -> state2 { - cond { - "counter>=p2.getReplication()" - } - action { - "String s=new String (\"Test!\");" - "testData.setData(s.getBytes());" - "testData.setLength(s.length());" - "testData.setConnectionId(0);" - "for (int i=0; i<p3.getReplication();i++){" - "\tp3[i].send(testData);" - "}" - "counter=0;" - "resultPattern=0;" - } - } - Transition tr8: state2 -> cp cp2 { - triggers { - <receive: p3> - } - action { - "resultPattern+=p3.getIndexOf(ifitem);" - "//System.out.printf(\"c:%d, Idx:%d!\\n\", counter,p3.getIndexOf(ifitem));" - "counter++;" - } - } - Transition tr9: cp cp2 -> state2 - Transition tr10: cp cp2 -> cp cp1 { - cond { - "counter>=p2.getReplication()" - } - action { - "int i;" - "p0.close();" - "// close all clients" - "p2.close();" - "pattern=0;" - "for (i=0;i<p2.getReplication();i++){" - "\tpattern+=i;" - "}" - } - } - Transition tr3: state2 -> state2 { - triggers { - <receive: p1> - } - action { - "p1.send(transitionData);" - } - } - Transition tr2: cp cp1 -> test_failed - Transition tr6: cp cp1 -> test_ok { - cond { - "pattern==resultPattern" - } - } - ChoicePoint cp0 - ChoicePoint cp2 - ChoicePoint cp1 - State state0 - State state1 - State state2 - State test_ok { - entry { - "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" - "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);" - "etUnit_testFinished(caseId);" - } - } - State test_failed { - entry { - "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" - "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);" - "etUnit_testFinished(caseId);" - } - } - } - } - }
+RoomModel TCPTest {
+
+ import room.basic.etunit.* from "Tests.room"
+ import room.basic.types.* from "Types.room"
+ import room.basic.service.tcp.* from "TcpService.room"
+
+ ActorClass TCPTestTop {
+ @TestInstance
+ Structure {
+ ActorRef ref0: ATcpServer
+ ActorRef ref1 [ 5 ]: ATcpClient
+ ActorRef ref2: Tester
+ Binding ref2.p1 and ref0.PayloadPort
+ Binding ref2.p0 and ref0.ControlPort
+ Binding ref2.p2 and ref1.ControlPort
+ Binding ref2.p3 and ref1.PayloadPort
+ }
+ Behavior { }
+ }
+
+ ActorClass Tester {
+ Interface {
+ conjugated Port p0: PTcpControl
+ conjugated Port p1: PTcpPayload
+ conjugated Port p2 [*]: PTcpControl
+ conjugated Port p3 [5]: PTcpPayload
+ }
+ Structure {
+ external Port p0
+ external Port p1
+ external Port p2
+ external Port p3
+ Attribute controlData:DTcpControl
+ Attribute testData:DTcpPayload
+ Attribute counter:int32
+ Attribute resultPattern:int32
+ Attribute pattern:int32
+ Attribute caseId: int32
+ Attribute resultlist[3]: int16 = "{1,2,3}"
+
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\"log/testlog\", \"TCPTest\", \"org.eclipse.etrice.generator.common.tests.TCPTest\", \"TCPTest_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+ StateMachine {
+ Transition init: initial -> state0 {
+ action {
+ "EXPECT_ORDER_START(caseId,resultlist,3);"
+ "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);"
+ "// open Server"
+ "controlData.setIPAddr(\"127.0.0.1\");"
+ "controlData.setTcpPort(4711);"
+ "p0.open(controlData);"
+ }
+ }
+ Transition tr0: state0 -> state1 {
+ triggers {
+ <established: p0>
+ }
+ action {
+ "// open 5 clients"
+ "for (int i=0;i<p2.getReplication();i++){"
+ "p2[i].open(controlData);"
+ "}"
+ "counter=0;"
+ }
+ }
+ Transition tr1: state1 -> cp cp0 {
+ triggers {
+ <established: p2>
+ }
+ action {
+ "counter++;"
+ }
+ }
+ Transition tr4: cp cp0 -> state1
+ Transition tr5: cp cp0 -> state2 {
+ cond {
+ "counter>=p2.getReplication()"
+ }
+ action {
+ "String s=new String (\"Test!\");"
+ "testData.setData(s.getBytes());"
+ "testData.setLength(s.length());"
+ "testData.setConnectionId(0);"
+ "for (int i=0; i<p3.getReplication();i++){"
+ "\tp3[i].send(testData);"
+ "}"
+ "counter=0;"
+ "resultPattern=0;"
+ }
+ }
+ Transition tr8: state2 -> cp cp2 {
+ triggers {
+ <receive: p3>
+ }
+ action {
+ "resultPattern+=p3.getIndexOf(ifitem);"
+ "//System.out.printf(\"c:%d, Idx:%d!\\n\", counter,p3.getIndexOf(ifitem));"
+ "counter++;"
+ }
+ }
+ Transition tr9: cp cp2 -> state2
+ Transition tr10: cp cp2 -> cp cp1 {
+ cond {
+ "counter>=p2.getReplication()"
+ }
+ action {
+ "int i;"
+ "p0.close();"
+ "// close all clients"
+ "p2.close();"
+ "pattern=0;"
+ "for (i=0;i<p2.getReplication();i++){"
+ "\tpattern+=i;"
+ "}"
+ }
+ }
+ Transition tr3: state2 -> state2 {
+ triggers {
+ <receive: p1>
+ }
+ action {
+ "p1.send(transitionData);"
+ }
+ }
+ Transition tr2: cp cp1 -> test_failed
+ Transition tr6: cp cp1 -> test_ok {
+ cond {
+ "pattern==resultPattern"
+ }
+ }
+ ChoicePoint cp0
+ ChoicePoint cp2
+ ChoicePoint cp1
+ State state0
+ State state1
+ State state2
+ State test_ok {
+ entry {
+ "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);"
+ "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);"
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ State test_failed {
+ entry {
+ "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);"
+ "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);"
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Base.behavior b/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Base.behavior index 510dfad28..fbcd4d516 100644 --- a/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Base.behavior +++ b/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Base.behavior @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ASCII"?> -<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.behavior" name="Behavior of Base" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@children.0/@children.3/@link //@children.0/@children.4/@link //@children.0/@children.5/@link //@children.0/@children.6/@link //@children.1/@link //@children.1/@children.1/@link //@children.0/@children.4/@children.1/@link //@children.1/@children.2/@link //@children.0/@children.4/@children.2/@link //@connections.0/@link //@connections.1/@link //@connections.2/@link //@connections.3/@link //@connections.4/@link" verticalGridUnit="10" version="0.13.0"> +<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.behavior" name="Behavior of Base" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@children.0/@children.3/@link //@children.0/@children.4/@link //@children.0/@children.5/@link //@children.0/@children.6/@link //@children.1/@link //@children.1/@children.1/@link //@children.0/@children.4/@children.1/@link //@children.1/@children.2/@link //@children.0/@children.4/@children.2/@link //@connections.0/@link //@connections.1/@link //@connections.2/@link //@connections.3/@link //@connections.4/@link" verticalGridUnit="10" version="0.14.0"> <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/> <link> <businessObjects href="../InheritedStateMachine.room#ActorClass:Base"/> @@ -17,7 +17,7 @@ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="800" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/"/> </children> <children xsi:type="pi:ContainerShape" visible="true" active="true"> - <properties key="obj-type" value="trp"/> + <properties key="obj-type" value="ini"/> <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="40" height="40" x="100" y="100"> <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="10" y="10"/> </graphicsAlgorithm> @@ -179,7 +179,7 @@ </children> </children> <children xsi:type="pi:ContainerShape" visible="true" active="true"> - <properties key="obj-type" value="trp"/> + <properties key="obj-type" value="cp"/> <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="50" height="50" x="55" y="265"> <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="25" height="25" x="12" y="12"/> </graphicsAlgorithm> diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Derived.behavior b/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Derived.behavior index 50f9fda19..b6b9291d0 100644 --- a/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Derived.behavior +++ b/tests/org.eclipse.etrice.ui.behavior.tests/models/diagrams/InheritedStateMachine.Derived.behavior @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ASCII"?> -<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.behavior" name="Behavior of Derived" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@children.0/@children.3/@link //@children.0/@children.4/@link //@children.0/@children.5/@link //@children.0/@children.6/@link //@children.1/@link //@children.1/@children.1/@link //@children.0/@children.4/@children.1/@link //@children.1/@children.2/@link //@children.0/@children.4/@children.2/@link //@children.1/@children.3/@link //@connections.0/@link //@connections.1/@link //@children.2/@link //@children.2/@children.1/@link //@connections.2/@link //@connections.3/@link //@connections.4/@link //@connections.5/@link //@connections.6/@link" verticalGridUnit="10" version="0.13.0"> +<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.behavior" name="Behavior of Derived" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@children.0/@children.3/@link //@children.0/@children.4/@link //@children.0/@children.5/@link //@children.0/@children.6/@link //@children.1/@link //@children.1/@children.1/@link //@children.0/@children.4/@children.1/@link //@children.1/@children.2/@link //@children.0/@children.4/@children.2/@link //@children.1/@children.3/@link //@connections.0/@link //@connections.1/@link //@children.2/@link //@children.2/@children.1/@link //@connections.2/@link //@connections.3/@link //@connections.4/@link //@connections.5/@link //@connections.6/@link" verticalGridUnit="10" version="0.14.0"> <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/> <link> <businessObjects href="../InheritedStateMachine.room#ActorClass:Derived"/> @@ -17,16 +17,16 @@ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="800" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/"/> </children> <children xsi:type="pi:ContainerShape" visible="true" active="true"> - <properties key="obj-type" value="trp"/> + <properties key="obj-type" value="ini"/> <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="40" height="40" x="100" y="100"> - <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="10" y="10"/> + <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.3" lineWidth="2" transparency="0.0" width="20" height="20" x="10" y="10"/> </graphicsAlgorithm> <link> <businessObjects href="../InheritedStateMachine.room#StateGraph:Derived$sg"/> </link> - <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.2" referencedGraphicsAlgorithm="//@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/> + <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.2"/> <children visible="true"> - <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="40" height="20" y="10" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="I"/> + <graphicsAlgorithm xsi:type="al:Text" background="//@colors.3" foreground="//@colors.3" lineWidth="1" filled="false" transparency="0.0" width="40" height="20" y="10" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="I"/> </children> </children> <children xsi:type="pi:ContainerShape" visible="true" active="true"> @@ -38,7 +38,7 @@ <link> <businessObjects href="../InheritedStateMachine.room#TransitionPoint:Base$tp0"/> </link> - <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.2/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/> + <anchors xsi:type="pi:ChopboxAnchor"/> <children visible="true"> <graphicsAlgorithm xsi:type="al:Text" background="//@colors.3" foreground="//@colors.3" lineWidth="1" filled="false" transparency="0.0" width="80" height="30" font="//@fonts.0" verticalAlignment="ALIGNMENT_BOTTOM" value="tp0"/> </children> @@ -179,14 +179,14 @@ </children> </children> <children xsi:type="pi:ContainerShape" visible="true" active="true"> - <properties key="obj-type" value="trp"/> + <properties key="obj-type" value="cp"/> <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="50" height="50" x="55" y="265"> <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.3" lineWidth="2" transparency="0.0" width="25" height="25" x="12" y="12"/> </graphicsAlgorithm> <link> <businessObjects href="../InheritedStateMachine.room#ChoicePoint:Base$cp0"/> </link> - <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.4 //@connections.5" incomingConnections="//@connections.3" referencedGraphicsAlgorithm="//@children.0/@children.6/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/> + <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.4 //@connections.5" incomingConnections="//@connections.3"/> <children visible="true"> <graphicsAlgorithm xsi:type="al:Text" background="//@colors.3" foreground="//@colors.3" lineWidth="1" filled="false" transparency="0.0" width="50" height="25" y="12" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="C"/> </children> diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/output/Base.fsmgen b/tests/org.eclipse.etrice.ui.behavior.tests/output/Base.fsmgen deleted file mode 100644 index 8e4ad56d6..000000000 --- a/tests/org.eclipse.etrice.ui.behavior.tests/output/Base.fsmgen +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<fsmgen:GraphContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fsmgen="http://www.eclipse.org/etrice/generator/fsm"> - <graph> - <nodes outgoing="//@graph/@links.2 //@graph/@links.3" incoming="//@graph/@links.1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ChoicePoint:Base$cp0"/> - </nodes> - <nodes> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TransitionPoint:Base$tp0"/> - </nodes> - <nodes outgoing="//@graph/@links.1" incoming="//@graph/@links.0"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Base$b0"/> - </nodes> - <nodes> - <subgraph> - <nodes incoming="//@graph/@links.3"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#EntryPoint:Base$b1$tp0"/> - </nodes> - <nodes outgoing="//@graph/@links.4"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ExitPoint:Base$b1$tp1"/> - </nodes> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:Base$b1$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Base$b1"/> - </nodes> - <nodes incoming="//@graph/@links.2 //@graph/@links.4"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Base$b2"/> - </nodes> - <links target="//@graph/@nodes.2"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#InitialTransition:Base$initial"/> - </links> - <links source="//@graph/@nodes.2" target="//@graph/@nodes.0"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TriggeredTransition:Base$tr0"/> - </links> - <links source="//@graph/@nodes.0" target="//@graph/@nodes.4"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Base$tr1"/> - </links> - <links source="//@graph/@nodes.0" target="//@graph/@nodes.3/@subgraph/@nodes.0"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#CPBranchTransition:Base$tr2"/> - </links> - <links source="//@graph/@nodes.3/@subgraph/@nodes.1" target="//@graph/@nodes.4"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Base$tr3"/> - </links> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:Base$sg"/> - </graph> - <component href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ActorClass:Base"/> -</fsmgen:GraphContainer> diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/output/Derived.fsmgen b/tests/org.eclipse.etrice.ui.behavior.tests/output/Derived.fsmgen deleted file mode 100644 index a2a66226f..000000000 --- a/tests/org.eclipse.etrice.ui.behavior.tests/output/Derived.fsmgen +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<fsmgen:GraphContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fsmgen="http://www.eclipse.org/etrice/generator/fsm"> - <graph> - <nodes inherited="true" outgoing="//@graph/@links.2 //@graph/@links.3" incoming="//@graph/@links.1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ChoicePoint:Base$cp0"/> - </nodes> - <nodes inherited="true"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TransitionPoint:Base$tp0"/> - </nodes> - <nodes inherited="true" outgoing="//@graph/@links.1" incoming="//@graph/@links.0"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Base$b0"/> - </nodes> - <nodes inherited="true"> - <subgraph> - <nodes inherited="true" outgoing="//@graph/@nodes.3/@subgraph/@links.0" incoming="//@graph/@links.3"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#EntryPoint:Base$b1$tp0"/> - </nodes> - <nodes inherited="true" outgoing="//@graph/@links.4" incoming="//@graph/@nodes.3/@subgraph/@links.1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ExitPoint:Base$b1$tp1"/> - </nodes> - <nodes outgoing="//@graph/@nodes.3/@subgraph/@links.1" incoming="//@graph/@nodes.3/@subgraph/@links.0" inheritanceLevel="1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Derived$b1$d11"/> - </nodes> - <links source="//@graph/@nodes.3/@subgraph/@nodes.0" target="//@graph/@nodes.3/@subgraph/@nodes.2"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Derived$b1$tr0"/> - </links> - <links source="//@graph/@nodes.3/@subgraph/@nodes.2" target="//@graph/@nodes.3/@subgraph/@nodes.1"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TriggeredTransition:Derived$b1$tr1"/> - </links> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:Derived$b1$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#RefinedState:Derived$b1"/> - </nodes> - <nodes inherited="true" incoming="//@graph/@links.2 //@graph/@links.4"> - <subgraph> - <nodes inheritanceLevel="1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Derived$b2$d21"/> - </nodes> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:Derived$b2$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#RefinedState:Derived$b2"/> - </nodes> - <links inherited="true" target="//@graph/@nodes.2"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#InitialTransition:Base$initial"/> - </links> - <links inherited="true" source="//@graph/@nodes.2" target="//@graph/@nodes.0"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TriggeredTransition:Base$tr0"/> - </links> - <links inherited="true" source="//@graph/@nodes.0" target="//@graph/@nodes.4"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Base$tr1"/> - </links> - <links inherited="true" source="//@graph/@nodes.0" target="//@graph/@nodes.3/@subgraph/@nodes.0"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#CPBranchTransition:Base$tr2"/> - </links> - <links inherited="true" source="//@graph/@nodes.3/@subgraph/@nodes.1" target="//@graph/@nodes.4"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Base$tr3"/> - </links> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:Derived$sg"/> - </graph> - <component href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ActorClass:Derived"/> -</fsmgen:GraphContainer> diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/output/DoubleDerived.fsmgen b/tests/org.eclipse.etrice.ui.behavior.tests/output/DoubleDerived.fsmgen deleted file mode 100644 index 57c3ec88f..000000000 --- a/tests/org.eclipse.etrice.ui.behavior.tests/output/DoubleDerived.fsmgen +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<fsmgen:GraphContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fsmgen="http://www.eclipse.org/etrice/generator/fsm"> - <graph> - <nodes inherited="true" outgoing="//@graph/@links.2 //@graph/@links.3" incoming="//@graph/@links.1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ChoicePoint:Base$cp0"/> - </nodes> - <nodes inherited="true"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TransitionPoint:Base$tp0"/> - </nodes> - <nodes inherited="true" outgoing="//@graph/@links.1" incoming="//@graph/@links.0"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:Base$b0"/> - </nodes> - <nodes inherited="true"> - <subgraph> - <nodes inherited="true" outgoing="//@graph/@nodes.3/@subgraph/@links.0" incoming="//@graph/@links.3"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#EntryPoint:Base$b1$tp0"/> - </nodes> - <nodes inherited="true" outgoing="//@graph/@links.4" incoming="//@graph/@nodes.3/@subgraph/@links.1"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ExitPoint:Base$b1$tp1"/> - </nodes> - <nodes inherited="true" outgoing="//@graph/@nodes.3/@subgraph/@links.1" incoming="//@graph/@nodes.3/@subgraph/@links.0" inheritanceLevel="1"> - <subgraph> - <nodes inheritanceLevel="2"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:DoubleDerived$b1$d11$dd111"/> - </nodes> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:DoubleDerived$b1$d11$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#RefinedState:DoubleDerived$b1$d11"/> - </nodes> - <nodes inheritanceLevel="2"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:DoubleDerived$b1$dd12"/> - </nodes> - <nodes inheritanceLevel="2"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:DoubleDerived$b1$dd13"/> - </nodes> - <links inherited="true" source="//@graph/@nodes.3/@subgraph/@nodes.0" target="//@graph/@nodes.3/@subgraph/@nodes.2"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Derived$b1$tr0"/> - </links> - <links inherited="true" source="//@graph/@nodes.3/@subgraph/@nodes.2" target="//@graph/@nodes.3/@subgraph/@nodes.1"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TriggeredTransition:Derived$b1$tr1"/> - </links> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:DoubleDerived$b1$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#RefinedState:DoubleDerived$b1"/> - </nodes> - <nodes inherited="true" incoming="//@graph/@links.2 //@graph/@links.4"> - <subgraph> - <nodes inherited="true" inheritanceLevel="1"> - <subgraph> - <nodes inheritanceLevel="2"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:DoubleDerived$b2$d21$dd211"/> - </nodes> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:DoubleDerived$b2$d21$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#RefinedState:DoubleDerived$b2$d21"/> - </nodes> - <nodes inheritanceLevel="2"> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#SimpleState:DoubleDerived$b2$xt2"/> - </nodes> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:DoubleDerived$b2$sg"/> - </subgraph> - <stateGraphNode href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#RefinedState:DoubleDerived$b2"/> - </nodes> - <links inherited="true" target="//@graph/@nodes.2"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#InitialTransition:Base$initial"/> - </links> - <links inherited="true" source="//@graph/@nodes.2" target="//@graph/@nodes.0"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#TriggeredTransition:Base$tr0"/> - </links> - <links inherited="true" source="//@graph/@nodes.0" target="//@graph/@nodes.4"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Base$tr1"/> - </links> - <links inherited="true" source="//@graph/@nodes.0" target="//@graph/@nodes.3/@subgraph/@nodes.0"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#CPBranchTransition:Base$tr2"/> - </links> - <links inherited="true" source="//@graph/@nodes.3/@subgraph/@nodes.1" target="//@graph/@nodes.4"> - <transition href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ContinuationTransition:Base$tr3"/> - </links> - <stateGraph href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#StateGraph:DoubleDerived$sg"/> - </graph> - <component href="file:/C:/Users/hrentz.PROTOS/git/newfsmgen/org.eclipse.etrice/tests/org.eclipse.etrice.ui.behavior.tests/models/InheritedStateMachine.room#ActorClass:DoubleDerived"/> -</fsmgen:GraphContainer> diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/AbstractStateMachineTest.java b/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/AbstractStateMachineTest.java index e75e9521c..04f836404 100644 --- a/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/AbstractStateMachineTest.java +++ b/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/AbstractStateMachineTest.java @@ -17,11 +17,9 @@ import java.net.URL; import java.util.List; import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.room.ActorClass; import org.eclipse.etrice.core.fsm.fSM.ChoicePoint; import org.eclipse.etrice.core.fsm.fSM.EntryPoint; import org.eclipse.etrice.core.fsm.fSM.ExitPoint; -import org.eclipse.etrice.core.fsm.fSM.InitialTransition; import org.eclipse.etrice.core.fsm.fSM.RefinedState; import org.eclipse.etrice.core.fsm.fSM.State; import org.eclipse.etrice.core.fsm.fSM.StateGraph; @@ -29,6 +27,8 @@ import org.eclipse.etrice.core.fsm.fSM.StateGraphItem; import org.eclipse.etrice.core.fsm.fSM.TrPoint; import org.eclipse.etrice.core.fsm.fSM.Transition; import org.eclipse.etrice.core.fsm.fSM.TransitionPoint; +import org.eclipse.etrice.core.fsm.util.FSMHelpers; +import org.eclipse.etrice.core.room.ActorClass; import org.eclipse.etrice.tests.base.TestBase; import org.eclipse.etrice.ui.behavior.BehaviorTestActivator; import org.eclipse.etrice.ui.behavior.fsm.support.StateSupport; @@ -49,6 +49,8 @@ import org.eclipse.graphiti.services.Graphiti; */ public abstract class AbstractStateMachineTest extends TestBase { + private FSMHelpers fsmHelpers = new FSMHelpers(); + /** * test general conditions for state graphs * @param diagram the diagram @@ -60,15 +62,24 @@ public abstract class AbstractStateMachineTest extends TestBase { ActorClass ac = (ActorClass) bo; - boolean hasInitialTransition = false; - for (Transition trans : sg.getTransitions()) { - if (trans instanceof InitialTransition) { - hasInitialTransition = true; - break; + List<PictogramElement> elements; + + // check initial transition + { + boolean hasInitialTransition = fsmHelpers.hasInitTransition(sg); + + // if this is the top level and we have an inherited initial transition we count that + // too since its pe is also linked to the current state graph + if (sg==ac.getStateMachine()) { + ActorClass theAC = ac.getActorBase(); + while (theAC!=null) { + hasInitialTransition |= fsmHelpers.hasInitTransition(theAC.getStateMachine()); + theAC = theAC.getActorBase(); + } } + elements = Graphiti.getLinkService().getPictogramElements(diagram, sg); + assertEquals("PEs for our state graph: sg and initial point", hasInitialTransition? 2:1, elements.size()); } - List<PictogramElement> elements = Graphiti.getLinkService().getPictogramElements(diagram, sg); - assertEquals("PEs for our state graph: sg and initial point", hasInitialTransition? 2:1, elements.size()); for (State s : sg.getStates()) { elements = Graphiti.getLinkService().getPictogramElements(diagram, s); diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/xtend-gen/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.java b/tests/org.eclipse.etrice.ui.behavior.tests/xtend-gen/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.java deleted file mode 100644 index 7535dfc38..000000000 --- a/tests/org.eclipse.etrice.ui.behavior.tests/xtend-gen/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Juergen Haug (initial contribution) - */ -package org.eclipse.etrice.ui.behavior.commands; - -import com.google.common.base.Objects; -import com.google.common.collect.Iterables; -import com.google.common.collect.Iterators; -import com.google.common.collect.Sets; -import com.google.inject.Injector; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.etrice.core.RoomStandaloneSetup; -import org.eclipse.etrice.core.TestBase; -import org.eclipse.etrice.core.fsm.fSM.StateGraphItem; -import org.eclipse.etrice.core.fsm.fSM.StateGraphNode; -import org.eclipse.etrice.core.fsm.fSM.TransitionBase; -import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder; -import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker; -import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician; -import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician; -import org.eclipse.etrice.core.genmodel.fsm.NullLogger; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link; -import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.ui.behavior.BehaviorTestActivator; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.IteratorExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; -import org.eclipse.xtext.xbase.lib.ObjectExtensions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.junit.Assert; -import org.junit.Test; - -@SuppressWarnings("all") -public class TestFSMGenModel extends TestBase { - private final Injector injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration(); - - protected IDiagnostician diagnostician = new NullDiagnostician(); - - @Extension - protected ExtendedFsmGenBuilder builder = new ExtendedFsmGenBuilder(this.injector, this.diagnostician); - - protected ResourceSet createResourceSetWithGc(final String roomFile, final String actorName) { - this.prepare(BehaviorTestActivator.getDefault().getBundle()); - final Resource res = this.getResource(roomFile); - EObject _get = res.getContents().get(0); - final Function1<ActorClass, Boolean> _function = (ActorClass it) -> { - return Boolean.valueOf(it.getName().equals(actorName)); - }; - final ActorClass actor = IterableExtensions.<ActorClass>findFirst(((RoomModel) _get).getActorClasses(), _function); - GraphContainer _createTransformedModel = this.builder.createTransformedModel(actor); - final Procedure1<GraphContainer> _function_1 = (GraphContainer gc) -> { - Assert.assertNotNull("graph context was created", gc); - final NullLogger logger = new NullLogger(); - FsmGenChecker.check(gc, logger); - Assert.assertFalse("logger has no errors", logger.hasErrors()); - this.save(gc, actor.getName()); - }; - final GraphContainer gc = ObjectExtensions.<GraphContainer>operator_doubleArrow(_createTransformedModel, _function_1); - Resource _createResource = res.getResourceSet().createResource(URI.createURI((("dummy://" + actorName) + ".fsmgen"))); - final Procedure1<Resource> _function_2 = (Resource it) -> { - EList<EObject> _contents = it.getContents(); - _contents.add(gc); - }; - ObjectExtensions.<Resource>operator_doubleArrow(_createResource, _function_2); - return res.getResourceSet(); - } - - protected void save(final GraphContainer gc, final String fileName) { - try { - final ResourceSetImpl rs = new ResourceSetImpl(); - final URI uri = URI.createFileURI((("./output/" + fileName) + ".fsmgen")); - final Resource res = rs.createResource(uri); - res.getContents().add(gc); - res.save(CollectionLiterals.<Object, Object>newHashMap()); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } - - @Test - public void testBaseClass() { - final ResourceSet rs = this.createResourceSetWithGc("InheritedStateMachine.room", "Base"); - final Function1<ActorClass, Boolean> _function = (ActorClass it) -> { - String _name = it.getName(); - return Boolean.valueOf(Objects.equal(_name, "Base")); - }; - final List<ActorClass> actorClasses = IteratorExtensions.<ActorClass>toList(IteratorExtensions.<ActorClass>filter(Iterators.<ActorClass>filter(EcoreUtil.<Object>getAllContents(rs, true), ActorClass.class), _function)); - final Function1<Resource, EList<EObject>> _function_1 = (Resource it) -> { - return it.getContents(); - }; - final GraphContainer gc = IterableExtensions.<GraphContainer>head(Iterables.<GraphContainer>filter(Iterables.<EObject>concat(ListExtensions.<Resource, EList<EObject>>map(rs.getResources(), _function_1)), GraphContainer.class)); - this.checkAgainstRoom(gc, actorClasses); - } - - @Test - public void testDerivedClass() { - final ResourceSet rs = this.createResourceSetWithGc("InheritedStateMachine.room", "Derived"); - final Function1<ActorClass, Boolean> _function = (ActorClass it) -> { - return Boolean.valueOf((Objects.equal(it.getName(), "Base") || Objects.equal(it.getName(), "Derived"))); - }; - final List<ActorClass> actorClasses = IteratorExtensions.<ActorClass>toList(IteratorExtensions.<ActorClass>filter(Iterators.<ActorClass>filter(EcoreUtil.<Object>getAllContents(rs, true), ActorClass.class), _function)); - final Function1<Resource, EList<EObject>> _function_1 = (Resource it) -> { - return it.getContents(); - }; - final GraphContainer gc = IterableExtensions.<GraphContainer>head(Iterables.<GraphContainer>filter(Iterables.<EObject>concat(ListExtensions.<Resource, EList<EObject>>map(rs.getResources(), _function_1)), GraphContainer.class)); - this.checkAgainstRoom(gc, actorClasses); - } - - @Test - public void testDoubleDerivedClass() { - final ResourceSet rs = this.createResourceSetWithGc("InheritedStateMachine.room", "DoubleDerived"); - final Function1<ActorClass, Boolean> _function = (ActorClass it) -> { - return Boolean.valueOf(((Objects.equal(it.getName(), "Base") || Objects.equal(it.getName(), "Derived")) || Objects.equal(it.getName(), "DoubleDerived"))); - }; - final List<ActorClass> actorClasses = IteratorExtensions.<ActorClass>toList(IteratorExtensions.<ActorClass>filter(Iterators.<ActorClass>filter(EcoreUtil.<Object>getAllContents(rs, true), ActorClass.class), _function)); - final Function1<Resource, EList<EObject>> _function_1 = (Resource it) -> { - return it.getContents(); - }; - final GraphContainer gc = IterableExtensions.<GraphContainer>head(Iterables.<GraphContainer>filter(Iterables.<EObject>concat(ListExtensions.<Resource, EList<EObject>>map(rs.getResources(), _function_1)), GraphContainer.class)); - this.checkAgainstRoom(gc, actorClasses); - } - - public void checkAgainstRoom(final GraphContainer gc, final List<ActorClass> actorClasses) { - final Function1<Node, StateGraphNode> _function = (Node it) -> { - return it.getStateGraphNode(); - }; - Iterator<StateGraphNode> _map = IteratorExtensions.<Node, StateGraphNode>map(Iterators.<Node>filter(EcoreUtil.<Object>getAllContents(gc, true), Node.class), _function); - final Function1<Link, TransitionBase> _function_1 = (Link it) -> { - return it.getTransition(); - }; - Iterator<TransitionBase> _map_1 = IteratorExtensions.<Link, TransitionBase>map(Iterators.<Link>filter(EcoreUtil.<Object>getAllContents(gc, true), Link.class), _function_1); - final Set<StateGraphItem> genModelRefs = IteratorExtensions.<StateGraphItem>toSet(Iterators.<StateGraphItem>concat(_map, _map_1)); - final Procedure1<StateGraphItem> _function_2 = (StateGraphItem it) -> { - URI _uRI = EcoreUtil.getURI(it); - String _plus = ("missing " + _uRI); - Assert.assertTrue(_plus, genModelRefs.contains(it)); - }; - IteratorExtensions.<StateGraphItem>forEach(Iterators.<StateGraphItem>filter(EcoreUtil.<Object>getAllContents(IterableExtensions.<ActorClass>last(actorClasses), false), StateGraphItem.class), _function_2); - final Function1<StateGraphItem, String> _function_3 = (StateGraphItem it) -> { - return it.getName(); - }; - final TreeSet<String> stateGraphItemsNames = this.<String>toSortedSet(IteratorExtensions.<String>toIterable(IteratorExtensions.<StateGraphItem, String>map(Iterators.<StateGraphItem>filter(EcoreUtil.<Object>getAllContents(actorClasses, true), StateGraphItem.class), _function_3))); - final Function1<StateGraphItem, String> _function_4 = (StateGraphItem it) -> { - return it.getName(); - }; - final TreeSet<String> namesFromGenModel = this.<String>toSortedSet(IterableExtensions.<StateGraphItem, String>map(genModelRefs, _function_4)); - Assert.assertEquals(stateGraphItemsNames, namesFromGenModel); - } - - private <T extends Comparable> TreeSet<T> toSortedSet(final Iterable<T> iterable) { - return Sets.<T>newTreeSet(iterable); - } -} |