summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-09-04 06:43:32 (EDT)
committerJuergen Haug2012-09-04 07:44:32 (EDT)
commit6fe05eb4d4a8dc783b7d260156d8f0e9fb16f609 (patch)
tree4e0c5b4ca52f6014cde1423d86b9fa85a8666279
parent927c25922c80dc2cca4156194c4da89920fa6f0d (diff)
downloadorg.eclipse.etrice-6fe05eb4d4a8dc783b7d260156d8f0e9fb16f609.zip
org.eclipse.etrice-6fe05eb4d4a8dc783b7d260156d8f0e9fb16f609.tar.gz
org.eclipse.etrice-6fe05eb4d4a8dc783b7d260156d8f0e9fb16f609.tar.bz2
[CQ 6485][config, runtime] .gitignore for config.tests,refs/changes/98/7398/6
ActorInstanceConfig hyperlinking added, runtime.ui rebuild Change-Id: Ia4ddd0651b9dd7f81207fef7bbcac14b8090a840
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/ConfigUiModule.java4
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java7
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/linking/ConfigHyperlinkHelper.java60
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java25
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java82
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/linking/ImportAwareHyperlinkHelper.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java779
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java246
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java247
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java60
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java1185
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java117
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java1679
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java171
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend5
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend3
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend71
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java720
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java444
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java460
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java60
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java790
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java81
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java151
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java972
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend396
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java287
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java90
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java119
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java1392
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java81
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zipbin15511 -> 15511 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin41189 -> 21628 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin27611 -> 27611 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin27511 -> 34290 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.zipbin99797 -> 99797 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/ConfigSourceFile.java2
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/IConfigSource.java2
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/VariableService.java126
-rw-r--r--tests/org.eclipse.etrice.core.config.tests/.classpath1
-rw-r--r--tests/org.eclipse.etrice.core.config.tests/.gitignore2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.config12
-rw-r--r--tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.room10
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/AC1_ac.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/ConfigText_Top_ac.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/DynTestee_ac.java96
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTest.java5
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTestVariableService.java133
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/Testee_ac.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java1
-rw-r--r--tests/org.eclipse.etrice.integration.tests/tmp/subSystemConfigTest7
73 files changed, 10638 insertions, 580 deletions
diff --git a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/ConfigUiModule.java b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/ConfigUiModule.java
index 8e8c33a..c175b43 100644
--- a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/ConfigUiModule.java
+++ b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/ConfigUiModule.java
@@ -11,8 +11,8 @@
*******************************************************************************/
package org.eclipse.etrice.core.ui;
+import org.eclipse.etrice.core.ui.linking.ConfigHyperlinkHelper;
import org.eclipse.etrice.core.ui.linking.GlobalNonPlatformURIEditorOpener;
-import org.eclipse.etrice.core.ui.linking.ImportAwareHyperlinkHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper;
@@ -33,6 +33,6 @@ public class ConfigUiModule extends
// HOWTO: use URI imports - need special class for creating hyper links for
// imports
public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() {
- return ImportAwareHyperlinkHelper.class;
+ return ConfigHyperlinkHelper.class;
}
}
diff --git a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java
index 7e49269..d2183be 100644
--- a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java
+++ b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java
@@ -136,8 +136,11 @@ public class ConfigProposalProvider extends AbstractConfigProposalProvider {
root = ConfigUtil.resolve(root, path);
if (root != null) {
for (ActorContainerRef ref : RoomHelpers.getRefs(root, true)) {
- if (ref instanceof ActorRef)
- refs.add((ActorRef) ref);
+ if (ref instanceof ActorRef) {
+ ActorRef aRef = (ActorRef) ref;
+ if (aRef.getSize() == 1)
+ refs.add((ActorRef) ref);
+ }
}
}
}
diff --git a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/linking/ConfigHyperlinkHelper.java b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/linking/ConfigHyperlinkHelper.java
new file mode 100644
index 0000000..f8ac2b2
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/linking/ConfigHyperlinkHelper.java
@@ -0,0 +1,60 @@
+package org.eclipse.etrice.core.ui.linking;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.config.ActorInstanceConfig;
+import org.eclipse.etrice.core.room.ActorContainerClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.xtext.AbstractRule;
+import org.eclipse.xtext.RuleCall;
+import org.eclipse.xtext.nodemodel.ILeafNode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.parser.IParseResult;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
+
+public class ConfigHyperlinkHelper extends ImportAwareHyperlinkHelper {
+
+ @Override
+ public void createHyperlinksByOffset(XtextResource resource, int offset,
+ IHyperlinkAcceptor acceptor) {
+ IParseResult parseResult = resource.getParseResult();
+ if (parseResult != null && parseResult.getRootNode() != null) {
+ ILeafNode leaf = NodeModelUtils.findLeafNodeAtOffset(
+ parseResult.getRootNode(), offset);
+ EObject grammarElement = leaf.getParent().getGrammarElement();
+ if (grammarElement instanceof RuleCall) {
+ RuleCall rc = (RuleCall) grammarElement;
+ AbstractRule rule = rc.getRule();
+
+ EObject crossLinkedEObject = null;
+ if (rule.getName().equals("RefPath")) {
+ EObject parent = leaf.getSemanticElement().eContainer();
+ if (parent instanceof ActorInstanceConfig) {
+ crossLinkedEObject = getCrossLinkedEObject((ActorInstanceConfig) parent);
+ }
+ }
+ if (crossLinkedEObject != null)
+ createHyperlinksTo(resource, null, crossLinkedEObject,
+ acceptor);
+ }
+ }
+
+ super.createHyperlinksByOffset(resource, offset, acceptor);
+ }
+
+ private EObject getCrossLinkedEObject(ActorInstanceConfig config) {
+ ActorContainerClass lastAcContainer = config.getRoot();
+ ActorRef lastRef = null;
+ for (String ref : config.getPath().getRefs()) {
+ for (ActorRef r : lastAcContainer.getActorRefs())
+ if (r.getName().equals(ref)) {
+ lastRef = r;
+ lastAcContainer = lastRef.getType();
+ break;
+ }
+ }
+
+ return lastRef;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java
index 1806e6a..4eb4762 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java
@@ -73,6 +73,31 @@ public class ConfigUtil {
return (ActorClass) result;
}
+
+ public static ActorRef getLastActorRef(ActorContainerClass root,
+ RefPath path) {
+ if(path.getRefs().isEmpty())
+ return null;
+
+ ActorRef lastMatch = null;
+ ActorContainerClass result = root;
+ for (String ref : path.getRefs()) {
+ ActorRef match = null;
+ for (ActorContainerRef actor : RoomHelpers.getRefs(result, true)) {
+ if (actor instanceof ActorRef && actor.getName().equals(ref)) {
+ match = (ActorRef) actor;
+ break;
+ }
+ }
+
+ if (match == null)
+ return null;
+ result = match.getType();
+ lastMatch = match;
+ }
+
+ return lastMatch;
+ }
/**
* returns first invalid path segment else null
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
index 40c2f93..87d9aa4 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
@@ -41,6 +41,7 @@ import org.eclipse.etrice.core.config.util.ConfigUtil;
import org.eclipse.etrice.core.converter.ConfigValueConverterService;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerClass;
+import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.InterfaceItem;
@@ -95,6 +96,9 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
@Check
public void checkActorClassConfig(ActorClassConfig config) {
+ if (config.getActor().isAbstract())
+ error("abstract actor classes not supported",
+ ConfigPackage.Literals.ACTOR_CLASS_CONFIG__ACTOR);
checkDuplicateAttributes(config.getAttributes(),
ConfigPackage.Literals.ACTOR_CLASS_CONFIG__ATTRIBUTES);
@@ -109,8 +113,17 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
String invalidSegment = ConfigUtil.checkPath(root, path);
if (invalidSegment != null)
error("no match for segment '" + invalidSegment + "'",
- ConfigPackage.eINSTANCE
- .getActorInstanceConfig_Path());
+ ConfigPackage.Literals.ACTOR_INSTANCE_CONFIG__PATH);
+ else {
+ ActorRef aRef = ConfigUtil.getLastActorRef(root, path);
+ if (aRef != null) {
+ if (aRef.getSize() > 1)
+ error("no arrays of actor references supported",
+ ConfigPackage.Literals.ACTOR_INSTANCE_CONFIG__PATH);
+ } else
+ error("invalid actor reference",
+ ConfigPackage.Literals.ACTOR_INSTANCE_CONFIG__PATH);
+ }
}
}
// duplicate port instance config check
@@ -155,18 +168,21 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
@Check
public void checkAttrConfig(AttrConfig config) {
- Attribute attr = config.getAttribute();
- if (attr == null)
+ Attribute a = config.getAttribute();
+ if (a == null)
return;
- DataType type = attr.getRefType().getType();
+ DataType type = a.getRefType().getType();
if (type instanceof PrimitiveType) {
PrimitiveType primitive = (PrimitiveType) type;
checkAttrConfigValue(primitive, config);
} else if (type instanceof DataType) {
if (config.getValue() != null)
- error("not allowed",
- ConfigPackage.eINSTANCE.getAttrConfig_Value());
+ error("not available",
+ ConfigPackage.Literals.ATTR_CONFIG__VALUE);
+ if (a.getSize() > 0)
+ error("DataClass arrays not supported",
+ ConfigPackage.Literals.ATTR_CLASS_CONFIG__ATTRIBUTES);
}
}
@@ -196,19 +212,21 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
if (config.isDynConfig()) {
if (!(config.eContainer() instanceof ActorInstanceConfig))
error("dynamic configuration only at root attributes", feature);
- if(config.eContainer() instanceof ActorInstanceConfig){
- SubSystemClass ssc = ((ActorInstanceConfig)config.eContainer()).getRoot();
+ if (config.eContainer() instanceof ActorInstanceConfig) {
+ SubSystemClass ssc = ((ActorInstanceConfig) config.eContainer())
+ .getRoot();
ConfigModel model = getConfigModel(config);
boolean found = false;
- for(SubSystemConfig c : model.getSubSystemConfigs())
- if(c.getSubSystem().equals(ssc)){
- if(c.getDynConfig() == null)
- error("no source for dynamic config in SubSystemConfig", feature);
- found = true;
+ for (SubSystemConfig c : model.getSubSystemConfigs())
+ if (c.getSubSystem().equals(ssc)) {
+ if (c.getDynConfig() == null)
+ error("no source for dynamic config in SubSystemConfig",
+ feature);
+ found = true;
}
- if(!found)
+ if (!found)
error("no SubSystemConfig found", feature);
-
+
}
}
@@ -346,16 +364,12 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
LiteralType type = primitive.getType();
if (type == LiteralType.INT || type == LiteralType.REAL) {
- if (config.getValue() != null) {
- if (config.getValue().getLiterals().get(0) instanceof IntLiteral) {
- if (!(min instanceof IntLiteral))
- error("incompatible datatype: maximum is not int",
- minRef);
- } else if (config.getValue().getLiterals().get(0) instanceof RealLiteral) {
- if (!(min instanceof RealLiteral))
- error("incompatible datatype: maximum is not real",
- minRef);
- }
+ if (primitive.getType() == LiteralType.INT) {
+ if (!(min instanceof IntLiteral))
+ error("incompatible datatype: maximum is not int", minRef);
+ } else if (primitive.getType() == LiteralType.REAL) {
+ if (!(min instanceof RealLiteral))
+ error("incompatible datatype: maximum is not real", minRef);
}
// check room default if config default is not set
String defaultValue = config.getAttribute()
@@ -411,16 +425,12 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
LiteralType type = primitive.getType();
if (type == LiteralType.INT || type == LiteralType.REAL) {
- if (config.getValue() != null) {
- if (config.getValue().getLiterals().get(0) instanceof IntLiteral) {
- if (!(max instanceof IntLiteral))
- error("incompatible datatype: maximum is not int",
- maxRef);
- } else if (config.getValue().getLiterals().get(0) instanceof RealLiteral) {
- if (!(max instanceof RealLiteral))
- error("incompatible datatype: maximum is not real",
- maxRef);
- }
+ if (primitive.getType() == LiteralType.INT) {
+ if (!(max instanceof IntLiteral))
+ error("incompatible datatype: maximum is not int", maxRef);
+ } else if (primitive.getType() == LiteralType.REAL) {
+ if (!(max instanceof RealLiteral))
+ error("incompatible datatype: maximum is not real", maxRef);
}
// check room default if config default is not set
String defaultValue = config.getAttribute()
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/linking/ImportAwareHyperlinkHelper.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/linking/ImportAwareHyperlinkHelper.java
index 956c275..a06afed 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/linking/ImportAwareHyperlinkHelper.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/linking/ImportAwareHyperlinkHelper.java
@@ -36,10 +36,10 @@ import com.google.inject.Provider;
public class ImportAwareHyperlinkHelper extends HyperlinkHelper {
@Inject
- private Provider<XtextHyperlink> hyperlinkProvider;
+ protected Provider<XtextHyperlink> hyperlinkProvider;
@Inject
- private PlatformRelativeUriResolver uriResolver;
+ protected PlatformRelativeUriResolver uriResolver;
public ImportAwareHyperlinkHelper() {
super();
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
new file mode 100644
index 0000000..5e1afee
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -0,0 +1,779 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.Annotation;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.c.gen.StateMachineGen;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions _cExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private StateMachineGen _stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this._roomExtensions.getPath(_actorClass_1);
+ String path = (_generationTargetPath + _path);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(_actorClass_2);
+ String _plus = ("generating ActorClass header \'" + _cHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ boolean _hasBehaviorAnnotation = this.hasBehaviorAnnotation(xpac, "BehaviorManual");
+ if (_hasBehaviorAnnotation) {
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _name = _actorClass_5.getName();
+ String _plus_4 = ("omitting ActorClass source for \'" + _name);
+ String _plus_5 = (_plus_4 + "\' since @BehaviorManual is specified");
+ this.logger.logInfo(_plus_5);
+ } else {
+ ActorClass _actorClass_6 = xpac.getActorClass();
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(_actorClass_6);
+ String _plus_6 = ("generating ActorClass source \'" + _cSourceFileName);
+ String _plus_7 = (_plus_6 + "\' in \'");
+ String _plus_8 = (_plus_7 + path);
+ String _plus_9 = (_plus_8 + "\'");
+ this.logger.logInfo(_plus_9);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_7 = xpac.getActorClass();
+ String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(_actorClass_7);
+ ActorClass _actorClass_8 = xpac.getActorClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+ }
+
+ private boolean hasBehaviorAnnotation(final ExpandedActorClass xpac, final String annotation) {
+ ActorClass _actorClass = xpac.getActorClass();
+ EList<Annotation> _behaviorAnnotations = _actorClass.getBehaviorAnnotations();
+ boolean _notEquals = (!Objects.equal(_behaviorAnnotations, null));
+ if (_notEquals) {
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ EList<Annotation> _behaviorAnnotations_1 = _actorClass_1.getBehaviorAnnotations();
+ final Function1<Annotation,Boolean> _function = new Function1<Annotation,Boolean>() {
+ public Boolean apply(final Annotation e) {
+ String _name = e.getName();
+ boolean _equals = Objects.equal(_name, annotation);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Annotation _findFirst = IterableExtensions.<Annotation>findFirst(_behaviorAnnotations_1, _function);
+ boolean _notEquals_1 = (!Objects.equal(_findFirst, null));
+ if (_notEquals_1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Port> _allEndPorts = this._roomExtensions.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ GeneralProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Iterable<Port> eventPorts = IterableExtensions.<Port>filter(_allEndPorts, _function);
+ List<Port> _allEndPorts_1 = this._roomExtensions.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function_1 = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ boolean _and = false;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
+ if (!_equals) {
+ _and = false;
+ } else {
+ boolean _isConjugated = p.isConjugated();
+ _and = (_equals && _isConjugated);
+ }
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<Port> sendPorts = IterableExtensions.<Port>filter(_allEndPorts_1, _function_1);
+ List<Port> _allEndPorts_2 = this._roomExtensions.getAllEndPorts(ac);
+ final Function1<Port,Boolean> _function_2 = new Function1<Port,Boolean>() {
+ public Boolean apply(final Port p) {
+ boolean _and = false;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
+ if (!_equals) {
+ _and = false;
+ } else {
+ boolean _isConjugated = p.isConjugated();
+ boolean _not = (!_isConjugated);
+ _and = (_equals && _not);
+ }
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<Port> recvPorts = IterableExtensions.<Port>filter(_allEndPorts_2, _function_2);
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean dataDriven = Objects.equal(_commType, ActorCommunicationType.DATA_DRIVEN);
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean async = Objects.equal(_commType_1, ActorCommunicationType.ASYNCHRONOUS);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ActorClass ");
+ String _name = ac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = ac.getName();
+ CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessage.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ String _name_4 = ac.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = ac.getName();
+ _builder.append(_name_5, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* const part of ActorClass (ROM) */");
+ _builder.newLine();
+ {
+ boolean _and = false;
+ boolean _and_1 = false;
+ boolean _and_2 = false;
+ boolean _isEmpty = IterableExtensions.isEmpty(eventPorts);
+ if (!_isEmpty) {
+ _and_2 = false;
+ } else {
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
+ _and_2 = (_isEmpty && _isEmpty_1);
+ }
+ if (!_and_2) {
+ _and_1 = false;
+ } else {
+ List<SAPRef> _allSAPs = this._roomExtensions.getAllSAPs(ac);
+ boolean _isEmpty_2 = _allSAPs.isEmpty();
+ _and_1 = (_and_2 && _isEmpty_2);
+ }
+ if (!_and_1) {
+ _and = false;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations = this._roomExtensions.getAllServiceImplementations(ac);
+ boolean _isEmpty_3 = _allServiceImplementations.isEmpty();
+ _and = (_and_1 && _isEmpty_3);
+ }
+ if (_and) {
+ _builder.append("/* this actor class has no ports and thus no constant data */");
+ _builder.newLine();
+ } else {
+ _builder.append("typedef struct ");
+ String _name_6 = ac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_const {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* simple ports */");
+ _builder.newLine();
+ {
+ for(final Port ep : eventPorts) {
+ {
+ int _multiplicity = ep.getMultiplicity();
+ boolean _equals = (_multiplicity == 1);
+ if (_equals) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName = this._roomExtensions.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_7 = ep.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* data receive ports */");
+ _builder.newLine();
+ {
+ for(final Port ep_1 : recvPorts) {
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _equals_1 = (_multiplicity_1 == 1);
+ if (_equals_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1);
+ _builder.append(_portClassName_1, " ");
+ _builder.append(" ");
+ String _name_8 = ep_1.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* saps */");
+ _builder.newLine();
+ {
+ List<SAPRef> _allSAPs_1 = this._roomExtensions.getAllSAPs(ac);
+ for(final SAPRef sap : _allSAPs_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_2 = this._roomExtensions.getPortClassName(sap);
+ _builder.append(_portClassName_2, " ");
+ _builder.append(" ");
+ String _name_9 = sap.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* replicated ports */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts_3 = this._roomExtensions.getAllEndPorts(ac);
+ for(final Port ep_2 : _allEndPorts_3) {
+ {
+ int _multiplicity_2 = ep_2.getMultiplicity();
+ boolean _notEquals = (_multiplicity_2 != 1);
+ if (_notEquals) {
+ _builder.append("\t");
+ _builder.append("const etReplPort ");
+ String _name_10 = ep_2.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* services */");
+ _builder.newLine();
+ {
+ List<ServiceImplementation> _allServiceImplementations_1 = this._roomExtensions.getAllServiceImplementations(ac);
+ for(final ServiceImplementation svc : _allServiceImplementations_1) {
+ _builder.append("\t");
+ _builder.append("const etReplPort ");
+ SPPRef _spp = svc.getSpp();
+ String _name_11 = _spp.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("} ");
+ String _name_12 = ac.getName();
+ _builder.append(_name_12, "");
+ _builder.append("_const;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ boolean _isEmpty_4 = RoomHelpers.isEmpty(_stateMachine);
+ boolean _not = (!_isEmpty_4);
+ if (_not) {
+ _builder.newLine();
+ CharSequence _genHeaderConstants = this._stateMachineGen.genHeaderConstants(xpac);
+ _builder.append(_genHeaderConstants, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* variable part of ActorClass (RAM) */");
+ _builder.newLine();
+ _builder.append("struct ");
+ String _name_13 = ac.getName();
+ _builder.append(_name_13, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _and_3 = false;
+ boolean _and_4 = false;
+ boolean _and_5 = false;
+ boolean _isEmpty_5 = IterableExtensions.isEmpty(eventPorts);
+ if (!_isEmpty_5) {
+ _and_5 = false;
+ } else {
+ boolean _isEmpty_6 = IterableExtensions.isEmpty(recvPorts);
+ _and_5 = (_isEmpty_5 && _isEmpty_6);
+ }
+ if (!_and_5) {
+ _and_4 = false;
+ } else {
+ List<SAPRef> _allSAPs_2 = this._roomExtensions.getAllSAPs(ac);
+ boolean _isEmpty_7 = _allSAPs_2.isEmpty();
+ _and_4 = (_and_5 && _isEmpty_7);
+ }
+ if (!_and_4) {
+ _and_3 = false;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations_2 = this._roomExtensions.getAllServiceImplementations(ac);
+ boolean _isEmpty_8 = _allServiceImplementations_2.isEmpty();
+ _and_3 = (_and_4 && _isEmpty_8);
+ }
+ boolean _not_1 = (!_and_3);
+ if (_not_1) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_14 = ac.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("_const* const constData;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("/* data send ports */");
+ _builder.newLine();
+ {
+ for(final Port ep_3 : sendPorts) {
+ {
+ int _multiplicity_3 = ep_3.getMultiplicity();
+ boolean _equals_2 = (_multiplicity_3 == 1);
+ if (_equals_2) {
+ _builder.append("\t");
+ String _portClassName_3 = this._roomExtensions.getPortClassName(ep_3);
+ _builder.append(_portClassName_3, " ");
+ _builder.append(" ");
+ String _name_15 = ep_3.getName();
+ _builder.append(_name_15, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(ac);
+ CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ List<Attribute> _allAttributes_1 = this._roomExtensions.getAllAttributes(ac);
+ for(final Attribute a : _allAttributes_1) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals_1) {
+ String _name_16 = ac.getName();
+ String _plus = (_name_16 + " ");
+ String _name_17 = a.getName();
+ String _plus_1 = (_plus + _name_17);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ boolean _isEmpty_9 = RoomHelpers.isEmpty(_stateMachine_1);
+ boolean _not_2 = (!_isEmpty_9);
+ if (_not_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genDataMembers = this._stateMachineGen.genDataMembers(xpac);
+ _builder.append(_genDataMembers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_18 = ac.getName();
+ _builder.append(_name_18, "");
+ _builder.append("_init(");
+ String _name_19 = ac.getName();
+ _builder.append(_name_19, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_20 = ac.getName();
+ _builder.append(_name_20, "");
+ _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _or = false;
+ if (dataDriven) {
+ _or = true;
+ } else {
+ _or = (dataDriven || async);
+ }
+ if (_or) {
+ _builder.append("void ");
+ String _name_21 = ac.getName();
+ _builder.append(_name_21, "");
+ _builder.append("_execute(");
+ String _name_22 = ac.getName();
+ _builder.append(_name_22, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ EList<StandardOperation> _operations = ac.getOperations();
+ String _name_23 = ac.getName();
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, _name_23);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_24 = ac.getName();
+ CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_24);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ ActorCommunicationType _commType = ac.getCommType();
+ boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ boolean eventDriven = Objects.equal(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ ActorCommunicationType _commType_2 = ac.getCommType();
+ boolean dataDriven = Objects.equal(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ boolean _or = false;
+ if (async) {
+ _or = true;
+ } else {
+ _or = (async || eventDriven);
+ }
+ boolean handleEvents = _or;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ActorClass ");
+ String _name = ac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(ac);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etActor.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etMemory.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName_1, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* interface item IDs */");
+ _builder.newLine();
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ boolean _isEmpty = RoomHelpers.isEmpty(_stateMachine);
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
+ _builder.append(_genStateMachine, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_init(");
+ String _name_2 = ac.getName();
+ _builder.append(_name_2, "");
+ _builder.append("* self){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_3 = ac.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", \"init\")");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ boolean _isEmpty_1 = RoomHelpers.isEmpty(_stateMachine_1);
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ _builder.append("\t");
+ CharSequence _genInitialization = this._stateMachineGen.genInitialization(xpac);
+ _builder.append(_genInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = ac.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveMessage(void* self, void* ifitem, const etMessage* msg){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_5 = ac.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\", \"_receiveMessage\")");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ boolean _isEmpty_2 = RoomHelpers.isEmpty(_stateMachine_2);
+ boolean _not_2 = (!_isEmpty_2);
+ if (_not_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self");
+ {
+ if (handleEvents) {
+ _builder.append(", (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _or_1 = false;
+ if (dataDriven) {
+ _or_1 = true;
+ } else {
+ _or_1 = (dataDriven || async);
+ }
+ if (_or_1) {
+ _builder.append("void ");
+ String _name_6 = ac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_execute(");
+ String _name_7 = ac.getName();
+ _builder.append(_name_7, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("\", \"_execute\")");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_3 = xpac.getStateMachine();
+ boolean _isEmpty_3 = RoomHelpers.isEmpty(_stateMachine_3);
+ boolean _not_3 = (!_isEmpty_3);
+ if (_not_3) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self");
+ {
+ if (handleEvents) {
+ _builder.append(", NULL, 0, NULL");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
new file mode 100644
index 0000000..628d1c1
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -0,0 +1,246 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+
+@Singleton
+@SuppressWarnings("all")
+public class CExtensions implements ILanguageExtension {
+ @Inject
+ private AbstractTransitionChainGenerator chainGenerator;
+
+ public String getTypedDataDefinition(final Message m) {
+ VarDecl _data = m.getData();
+ return this.chainGenerator.generateTypedData(_data);
+ }
+
+ public String accessLevelPrivate() {
+ return "static ";
+ }
+
+ public String accessLevelProtected() {
+ return "static ";
+ }
+
+ public String accessLevelPublic() {
+ return "";
+ }
+
+ public String memberAccess() {
+ return "self->";
+ }
+
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "* self, ";
+ } else {
+ _xifexpression = "* self";
+ }
+ String _plus = (classname + _xifexpression);
+ return _plus;
+ }
+
+ public String selfPointer(final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "self, ";
+ } else {
+ _xifexpression = "self";
+ }
+ return _xifexpression;
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ String _plus = (classname + "_");
+ return _plus;
+ }
+
+ public String memberInDeclaration(final String namespace, final String member) {
+ String _plus = (namespace + "_");
+ return (_plus + member);
+ }
+
+ public String memberInUse(final String namespace, final String member) {
+ String _plus = (namespace + "_");
+ return (_plus + member);
+ }
+
+ /**
+ * TODO: move specific code elsewhere
+ */
+ public String getCHeaderFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + ".h");
+ }
+
+ public String getCSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + ".c");
+ }
+
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + "_Inst.h");
+ }
+
+ public String getDispSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ return (_name + "_Disp.h");
+ }
+
+ public CharSequence getIncludeGuardString(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("_");
+ String _upperCase = filename.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_H_");
+ return _builder;
+ }
+
+ public CharSequence generateIncludeGuardBegin(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#ifndef ");
+ CharSequence _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#define ");
+ CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString_1, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence generateIncludeGuardEnd(final String filename) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#endif /* ");
+ CharSequence _includeGuardString = this.getIncludeGuardString(filename);
+ _builder.append(_includeGuardString, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public boolean usesInheritance() {
+ return false;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ String _xblockexpression = null;
+ {
+ boolean _isEmpty = entries.isEmpty();
+ if (_isEmpty) {
+ return "/* empty enum not generated */";
+ }
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("enum ");
+ _builder.append(name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasElements = false;
+ for(final Pair<String,String> entry : entries) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _first = entry.getFirst();
+ _builder.append(_first, " ");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ String _string = _builder.toString();
+ _xblockexpression = (_string);
+ }
+ return _xblockexpression;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _xifexpression = null;
+ if (b) {
+ _xifexpression = "TRUE";
+ } else {
+ _xifexpression = "FALSE";
+ }
+ return _xifexpression;
+ }
+
+ public String pointerLiteral() {
+ return "*";
+ }
+
+ public String nullPointer() {
+ return "NULL";
+ }
+
+ public String voidPointer() {
+ return "void*";
+ }
+
+ public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
+ String _xifexpression = null;
+ if (isRef) {
+ String _plus = (type + "* ");
+ String _plus_1 = (_plus + name);
+ String _plus_2 = (_plus_1 + "[");
+ String _plus_3 = (_plus_2 + Integer.valueOf(size));
+ String _plus_4 = (_plus_3 + "]");
+ _xifexpression = _plus_4;
+ } else {
+ String _plus_5 = (type + " ");
+ String _plus_6 = (_plus_5 + name);
+ String _plus_7 = (_plus_6 + "[");
+ String _plus_8 = (_plus_7 + Integer.valueOf(size));
+ String _plus_9 = (_plus_8 + "]");
+ _xifexpression = _plus_9;
+ }
+ return _xifexpression;
+ }
+
+ public String constructorName(final String cls) {
+ return "ctor";
+ }
+
+ public String destructorName(final String cls) {
+ return "dtor";
+ }
+
+ public String constructorReturnType() {
+ return "void";
+ }
+
+ public String destructorReturnType() {
+ return "void";
+ }
+
+ public String toCharArrayExpr(final String s) {
+ String _plus = ("\"" + s);
+ String _plus_1 = (_plus + "\"");
+ return _plus_1;
+ }
+
+ public String superCall(final String baseClassName, final String method, final String args) {
+ return "";
+ }
+
+ public String toValueLiteral(final PrimitiveType type, final String value) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("TODO Config for C");
+ throw _unsupportedOperationException;
+ }
+}
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
new file mode 100644
index 0000000..61236fc
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -0,0 +1,247 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions _cExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
+ String _path = this._roomExtensions.getPath(dc);
+ String path = (_generationTargetPath + _path);
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(dc);
+ String _plus = ("generating DataClass header \'" + _cHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(dc);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(dc);
+ String _plus_4 = ("generating DataClass source \'" + _cSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(dc);
+ CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence generateHeaderFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = dc.getName();
+ CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(dc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(dc);
+ CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes);
+ _builder.append(_attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("} ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ List<Attribute> _allAttributes_1 = this._roomExtensions.getAllAttributes(dc);
+ for(final Attribute a : _allAttributes_1) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals) {
+ String _name_4 = dc.getName();
+ String _plus = (_name_4 + " ");
+ String _name_5 = a.getName();
+ String _plus_1 = (_plus + _name_5);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_6 = dc.getName();
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, _name_6);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* deep copy */");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = dc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_deepCopy(");
+ String _name_8 = dc.getName();
+ _builder.append(_name_8, "");
+ _builder.append("* source, ");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, "");
+ _builder.append("* target);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_10 = dc.getName();
+ CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_10);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence generateSourceFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(dc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <string.h>");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(dc, 3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_1 = dc.getName();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, _name_1);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = dc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_deepCopy(");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("* source, ");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("* target) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("memcpy(target, source, sizeof(");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
new file mode 100644
index 0000000..26daa4b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
@@ -0,0 +1,60 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.c.gen.ActorClassGen;
+import org.eclipse.etrice.generator.c.gen.DataClassGen;
+import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@Singleton
+@SuppressWarnings("all")
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _not = (!_isLibrary);
+ if (_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
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
new file mode 100644
index 0000000..91dcd5e
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -0,0 +1,1185 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions _cExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
+ String _path = this._roomExtensions.getPath(pc);
+ String path = (_generationTargetPath + _path);
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(pc);
+ String _plus = ("generating ProtocolClass header \'" + _cHeaderFileName);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(pc);
+ String _plus_4 = ("generating ProtocolClass source \'" + _cSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(pc);
+ CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private CharSequence generateHeaderFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"modelbase/etPort.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(pc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ _builder.newLine();
+ _builder.append("/* message IDs */");
+ _builder.newLine();
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ CharSequence _portClassHeader = this.portClassHeader(pc, Boolean.valueOf(false));
+ _builder.append(_portClassHeader, "");
+ _builder.newLineIfNotEmpty();
+ CharSequence _portClassHeader_1 = this.portClassHeader(pc, Boolean.valueOf(true));
+ _builder.append(_portClassHeader_1, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ CharSequence _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
+ _builder.append(_genDataDrivenPortHeaders, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* get message string for message id */");
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(_name_4);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this._cExtensions.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(pc, 3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- port methods */");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ CharSequence _portClassSource = this.portClassSource(pc, Boolean.valueOf(false));
+ _builder.append(_portClassSource, "");
+ _builder.newLineIfNotEmpty();
+ CharSequence _portClassSource_1 = this.portClassSource(pc, Boolean.valueOf(true));
+ _builder.append(_portClassSource_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ CharSequence _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
+ _builder.append(_genDataDrivenPortSources, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronous protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
+ List<Message> _xifexpression = null;
+ if ((conj).booleanValue()) {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals = (!Objects.equal(_portClass, null));
+ if (_notEquals) {
+ {
+ PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("/* variable part of PortClass (RAM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var ");
+ _builder.append(portClassName, "");
+ _builder.append("_var; ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
+ CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ {
+ PortClass _portClass_3 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
+ for(final Attribute a : _attributes_3) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals_1) {
+ String _plus = (portClassName + " ");
+ String _name = a.getName();
+ String _plus_1 = (_plus + _name);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean hasData = (!Objects.equal(_data, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ boolean _or = false;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _not_1 = (!(_type_1 instanceof PrimitiveType));
+ if (_not_1) {
+ _or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _or = (_not_1 || _isRef);
+ }
+ _and = (hasData && _or);
+ }
+ if (_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _plus_3 = (", " + typeName);
+ String _plus_4 = (_plus_3 + refp);
+ String _plus_5 = (_plus_4 + " data");
+ _xifexpression_3 = _plus_5;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _name_1 = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_3 = message.getName();
+ String _plus_6 = (", int idx" + data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _plus_6);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ PortClass _portClass_4 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals_2 = (!Objects.equal(_portClass_4, null));
+ if (_notEquals_2) {
+ PortClass _portClass_5 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations = _portClass_5.getOperations();
+ CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_6 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations_1 = _portClass_6.getOperations();
+ CharSequence _operationsDeclaration_1 = this._procedureHelpers.operationsDeclaration(_operations_1, replPortClassName);
+ _builder.append(_operationsDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ {
+ List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name_4 = _msg.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenPortHeaders(final ProtocolClass pc) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ return Boolean.valueOf(_notEquals);
+ }
+ };
+ Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* data driven send port (conjugated) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ {
+ for(final Message msg : sentMsgs) {
+ _builder.append("\t");
+ VarDecl _data = msg.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String typeName = this._typeHelpers.typeName(_type);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _xifexpression = null;
+ VarDecl _data_1 = msg.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(typeName, " ");
+ _builder.append(refp, " ");
+ _builder.append(" ");
+ String _name = msg.getName();
+ _builder.append(_name, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName = this._roomExtensions.getPortClassName(pc, true);
+ _builder.append(_portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data driven receive port (regular) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this._roomExtensions.getPortClassName(pc, true);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("* peer;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_2 = this._roomExtensions.getPortClassName(pc, false);
+ _builder.append(_portClassName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ for(final Message message : sentMsgs) {
+ VarDecl _data_2 = message.getData();
+ boolean hasData = (!Objects.equal(_data_2, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName = this._typeHelpers.typeName(_type_1);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName_1 = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ boolean _not = (!(_type_2 instanceof PrimitiveType));
+ _and = (hasData && _not);
+ }
+ if (_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp_1 = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _plus = (", " + typeName_1);
+ String _plus_1 = (_plus + refp_1);
+ String _plus_2 = (_plus_1 + " data");
+ _xifexpression_3 = _plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _portClassName_3 = this._roomExtensions.getPortClassName(pc, true);
+ String _name_1 = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _portClassName_4 = this._roomExtensions.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenPortSources(final ProtocolClass pc) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ return Boolean.valueOf(_notEquals);
+ }
+ };
+ Iterable<Message> messages = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String typeName = this._typeHelpers.typeName(_type);
+ _builder.newLineIfNotEmpty();
+ String _xifexpression = null;
+ VarDecl _data_1 = message.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _not = (!(_type_1 instanceof PrimitiveType));
+ if (_not) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ String _plus = (", " + typeName);
+ String _plus_1 = (_plus + refp);
+ String data = (_plus_1 + " data");
+ _builder.newLineIfNotEmpty();
+ String _portClassName = this._roomExtensions.getPortClassName(pc, true);
+ String _name = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = data;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_1 = this._roomExtensions.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return self->peer->");
+ String _name_3 = message.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence portClassSource(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
+ List<Message> _xifexpression = null;
+ if ((conj).booleanValue()) {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if ((conj).booleanValue()) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean hasData = (!Objects.equal(_data, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_2 = _typeName;
+ } else {
+ _xifexpression_2 = "";
+ }
+ String typeName = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ _and = (hasData && _isRef);
+ }
+ if (_and) {
+ _xifexpression_3 = "*";
+ } else {
+ _xifexpression_3 = "";
+ }
+ String refp = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_4 = null;
+ boolean _and_1 = false;
+ if (!hasData) {
+ _and_1 = false;
+ } else {
+ boolean _or = false;
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ boolean _not = (!(_type_1 instanceof PrimitiveType));
+ if (_not) {
+ _or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _or = (_not || _isRef_1);
+ }
+ _and_1 = (hasData && _or);
+ }
+ if (_and_1) {
+ _xifexpression_4 = "*";
+ } else {
+ _xifexpression_4 = "";
+ }
+ String refpd = _xifexpression_4;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_5 = null;
+ boolean _and_2 = false;
+ boolean _and_3 = false;
+ if (!hasData) {
+ _and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _not_1 = (!(_type_2 instanceof PrimitiveType));
+ _and_3 = (hasData && _not_1);
+ }
+ if (!_and_3) {
+ _and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _not_2 = (!_isRef_2);
+ _and_2 = (_and_3 && _not_2);
+ }
+ if (_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
+ if (hasData) {
+ String _plus = (", " + typeName);
+ String _plus_1 = (_plus + refpd);
+ String _plus_2 = (_plus_1 + " data");
+ _xifexpression_6 = _plus_2;
+ } else {
+ _xifexpression_6 = "";
+ }
+ String data = _xifexpression_6;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_7 = null;
+ if (hasData) {
+ _xifexpression_7 = ", data";
+ } else {
+ _xifexpression_7 = "";
+ }
+ String dataCall = _xifexpression_7;
+ _builder.newLineIfNotEmpty();
+ MessageHandler hdlr = this._roomExtensions.getSendHandler(message, (conj).booleanValue());
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(hdlr, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(portClassName, " ");
+ _builder.append("\", \"");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _plus_3 = (dir + _name_3);
+ String _memberInUse = this._cExtensions.memberInUse(_name_2, _plus_3);
+ String _plus_4 = (typeName + refp);
+ String _plus_5 = (refa + "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _plus_4, _plus_5);
+ _builder.append(_sendMessageCall, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_4 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(hdlr, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_6 = message.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_7 = pc.getName();
+ String _name_8 = message.getName();
+ String _plus_6 = (dir + _name_8);
+ String _memberInUse_1 = this._cExtensions.memberInUse(_name_7, _plus_6);
+ String _plus_7 = (typeName + refp);
+ String _plus_8 = (refa + "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _plus_7, _plus_8);
+ _builder.append(_sendMessageCall_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_9 = message.getName();
+ String _plus_9 = (", int idx" + data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _plus_9);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_2 = (!Objects.equal(hdlr, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_10 = message.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_11 = message.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_12 = pc.getName();
+ String _name_13 = message.getName();
+ String _plus_10 = (dir + _name_13);
+ String _memberInUse_2 = this._cExtensions.memberInUse(_name_12, _plus_10);
+ String _plus_11 = (typeName + refp);
+ String _plus_12 = (refa + "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _plus_11, _plus_12);
+ _builder.append(_sendMessageCall_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ {
+ PortClass _portClass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals_3 = (!Objects.equal(_portClass, null));
+ if (_notEquals_3) {
+ PortClass _portClass_1 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ CharSequence _operationsImplementation_1 = this._procedureHelpers.operationsImplementation(_operations_1, replPortClassName);
+ _builder.append(_operationsImplementation_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// getReplication");
+ _builder.newLine();
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return ((etReplPort*)self)->size;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ CharSequence _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
+ _builder.append(_genReceiveHandlers, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
+ String _xifexpression = null;
+ if (hasData) {
+ String _plus = ("etPort_sendMessage(" + self);
+ String _plus_1 = (_plus + ", ");
+ String _plus_2 = (_plus_1 + msg);
+ String _plus_3 = (_plus_2 + ", sizeof(");
+ String _plus_4 = (_plus_3 + typeName);
+ String _plus_5 = (_plus_4 + "), ");
+ String _plus_6 = (_plus_5 + data);
+ String _plus_7 = (_plus_6 + ");");
+ _xifexpression = _plus_7;
+ } else {
+ String _plus_8 = ("etPort_sendMessage(" + self);
+ String _plus_9 = (_plus_8 + ", ");
+ String _plus_10 = (_plus_9 + msg);
+ String _plus_11 = (_plus_10 + ", 0, NULL);");
+ _xifexpression = _plus_11;
+ }
+ return _xifexpression;
+ }
+
+ private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
+ String _plus = ("void " + className);
+ String _plus_1 = (_plus + "_");
+ String _plus_2 = (_plus_1 + messageName);
+ String _plus_3 = (_plus_2 + methodSuffix);
+ String _plus_4 = (_plus_3 + "(const ");
+ String _plus_5 = (_plus_4 + className);
+ String _plus_6 = (_plus_5 + "* self");
+ String _plus_7 = (_plus_6 + data);
+ String _plus_8 = (_plus_7 + ")");
+ return _plus_8;
+ }
+
+ private String messageSetterSignature(final String className, final String messageName, final String data) {
+ String _plus = ("void " + className);
+ String _plus_1 = (_plus + "_");
+ String _plus_2 = (_plus_1 + messageName);
+ String _plus_3 = (_plus_2 + "_set(");
+ String _plus_4 = (_plus_3 + className);
+ String _plus_5 = (_plus_4 + "* self");
+ String _plus_6 = (_plus_5 + data);
+ String _plus_7 = (_plus_6 + ")");
+ return _plus_7;
+ }
+
+ private String messageGetterSignature(final String className, final String messageName, final String type) {
+ String _plus = (type + " ");
+ String _plus_1 = (_plus + className);
+ String _plus_2 = (_plus_1 + "_");
+ String _plus_3 = (_plus_2 + messageName);
+ String _plus_4 = (_plus_3 + "_get(const ");
+ String _plus_5 = (_plus_4 + className);
+ String _plus_6 = (_plus_5 + "* const self)");
+ return _plus_6;
+ }
+
+ private CharSequence genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* receiver handlers */");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name = _msg.getName();
+ _builder.append(_name, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ DetailCode _detailCode = h.getDetailCode();
+ CharSequence _userCode = this._procedureHelpers.userCode(_detailCode);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* hand over the message to the actor: */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("static const char* const ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\", ");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (msg_id<");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_MSG_MIN || msg_id>");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_MSG_MAX+1){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("/* id out of range */");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_messageStrings[msg_id];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}
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
new file mode 100644
index 0000000..de6d18f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
@@ -0,0 +1,117 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+
+@Singleton
+@SuppressWarnings("all")
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public CharSequence genHeaderConstants(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
+ int _size = _allBaseStates.size();
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(ac);
+ int _size_1 = _allLeafStates.size();
+ int _minus = (_size - _size_1);
+ final int historySize = (_minus + 2);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* constant for state machine data */");
+ _builder.newLine();
+ _builder.append("#define ");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_HISTORY_SIZE ");
+ _builder.append(historySize, "");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genDataMembers(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* state machine variables */");
+ _builder.newLine();
+ _builder.append("etInt16 state;");
+ _builder.newLine();
+ _builder.append("etInt16 history[");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, "");
+ _builder.append("_HISTORY_SIZE];");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genInitialization(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("self->state = STATE_TOP;");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<");
+ String _name = ac.getName();
+ String _upperCase = _name.toUpperCase();
+ _builder.append(_upperCase, " ");
+ _builder.append("_HISTORY_SIZE; ++i)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("self->history[i] = NO_STATE;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("executeInitTransition(self);");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genExtra(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void setState(");
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append("* self, int new_state) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
new file mode 100644
index 0000000..ddf22e2
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -0,0 +1,1679 @@
+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.HashMap;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+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.SubSystemInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+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.DetailCode;
+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.RefableType;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILanguageExtension languageExt;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance ssi : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String path = (_generationTargetPath + _path);
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String file = this.stdExt.getCHeaderFileName(_subSystemClass_2);
+ String _plus = ("generating SubSystemClass declaration: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generateHeaderFile);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_4);
+ file = _cSourceFileName;
+ String _plus_4 = ("generating SubSystemClass implementation: \'" + file);
+ 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);
+ SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
+ this.fileAccess.generateFile(file, _generateSourceFile);
+ SubSystemClass _subSystemClass_6 = ssi.getSubSystemClass();
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_6);
+ file = _instSourceFileName;
+ String _plus_8 = ("generating SubSystemClass instance file: \'" + file);
+ String _plus_9 = (_plus_8 + "\' in \'");
+ String _plus_10 = (_plus_9 + path);
+ String _plus_11 = (_plus_10 + "\'");
+ this.logger.logInfo(_plus_11);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_7 = ssi.getSubSystemClass();
+ CharSequence _generateInstanceFile = this.generateInstanceFile(root, ssi, _subSystemClass_7);
+ this.fileAccess.generateFile(file, _generateInstanceFile);
+ SubSystemClass _subSystemClass_8 = ssi.getSubSystemClass();
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_8);
+ file = _dispSourceFileName;
+ String _plus_12 = ("generating SubSystemClass dispatcher file: \'" + file);
+ String _plus_13 = (_plus_12 + "\' in \'");
+ String _plus_14 = (_plus_13 + path);
+ String _plus_15 = (_plus_14 + "\'");
+ this.logger.logInfo(_plus_15);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_9 = ssi.getSubSystemClass();
+ CharSequence _generateDispatcherFile = this.generateDispatcherFile(root, ssi, _subSystemClass_9);
+ this.fileAccess.generateFile(file, _generateDispatcherFile);
+ }
+ }
+ }
+
+ private CharSequence generateHeaderFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = ssc.getName();
+ CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode1 = ssc.getUserCode1();
+ CharSequence _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* lifecycle functions");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* init -> start -> run (loop) -> stop -> destroy");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_init(void);\t\t/* lifecycle init \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_start(void);\t/* lifecycle start \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_run(void);\t\t/* lifecycle run \t */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("_stop(void); \t/* lifecycle stop\t */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_destroy(void); \t/* lifecycle destroy */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = ssc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_shutdown(void); /* shutdown the dispatcher loop */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode2 = ssc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_8 = ssc.getName();
+ CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_8);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(ssc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* include instances for all classes */");
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(ssc);
+ _builder.append(_instSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"");
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(ssc);
+ _builder.append(_dispSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"platform/etTimer.h\"");
+ _builder.newLine();
+ _builder.append("#include \"etGlobalFlags.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = ssc.getUserCode3();
+ CharSequence _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data for SubSysten ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef struct ");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("char *name;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("volatile int shutdownRequest;");
+ _builder.newLine();
+ _builder.append("} ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("static ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("Inst = {\"");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("\",0};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = ssc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_initActorInstances(void);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("void ");
+ String _name_8 = ssc.getName();
+ _builder.append(_name_8, "");
+ _builder.append("_constructActorInstances(void);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_9 = ssc.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_init(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"init\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_init\", ");
+ String _name_10 = ssc.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* construct all actors */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_11 = ssc.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("_constructActorInstances();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* initialization of all message services */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_Thread1_receiveMessage);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* init all actors */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_12 = ssc.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("_initActorInstances();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_13 = ssc.getName();
+ _builder.append(_name_13, "");
+ _builder.append("_start(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"start\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_start\", ");
+ String _name_14 = ssc.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_15 = ssc.getName();
+ _builder.append(_name_15, "");
+ _builder.append("_run(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"run\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#ifdef ET_RUNTIME_ENDLESS");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("while(!(");
+ String _name_16 = ssc.getName();
+ _builder.append(_name_16, " ");
+ _builder.append("Inst.shutdownRequest)){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("if (etTimer_executeNeeded()){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("etMessageService_execute(&msgService_Thread1);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ CharSequence _generateDatadrivenExecutes = this.generateDatadrivenExecutes(root, ssi);
+ _builder.append(_generateDatadrivenExecutes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("uint32 loopCounter = 0;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("while(!(");
+ String _name_17 = ssc.getName();
+ _builder.append(_name_17, " ");
+ _builder.append("Inst.shutdownRequest)){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("if (etTimer_executeNeeded()){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("etMessageService_execute(&msgService_Thread1);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ CharSequence _generateDatadrivenExecutes_1 = this.generateDatadrivenExecutes(root, ssi);
+ _builder.append(_generateDatadrivenExecutes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("etLogger_logInfo(\"Execute\");");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("if (loopCounter++ > ET_RUNTIME_MAXLOOP){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#endif");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_18 = ssc.getName();
+ _builder.append(_name_18, "");
+ _builder.append("_stop(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"stop\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_stop\", ");
+ String _name_19 = ssc.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_20 = ssc.getName();
+ _builder.append(_name_20, "");
+ _builder.append("_destroy(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"destroy\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_destroy\", ");
+ String _name_21 = ssc.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ List<ActorInstance> _reverseView = ListExtensions.<ActorInstance>reverseView(_allContainedInstances);
+ for(final ActorInstance ai : _reverseView) {
+ {
+ ActorClass _actorClass = ai.getActorClass();
+ EList<StandardOperation> _operations = _actorClass.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ boolean _isEmpty = IterableExtensions.isEmpty(_filter);
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("\t");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_22 = _actorClass_1.getName();
+ String _destructorName = this.languageExt.destructorName(_name_22);
+ _builder.append(_destructorName, " ");
+ _builder.append("(&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_23 = ssc.getName();
+ _builder.append(_name_23, "");
+ _builder.append("_shutdown(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"shutdown\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"%s_shutdown\", ");
+ String _name_24 = ssc.getName();
+ _builder.append(_name_24, " ");
+ _builder.append("Inst.name);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_25 = ssc.getName();
+ _builder.append(_name_25, " ");
+ _builder.append("Inst.shutdownRequest = 1;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_26 = ssc.getName();
+ _builder.append(_name_26, "");
+ _builder.append("_constructActorInstances(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_27 = ssc.getName();
+ _builder.append(_name_27, " ");
+ _builder.append("\", \"constructActorInstances\")");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ {
+ ActorClass _actorClass_2 = ai_1.getActorClass();
+ EList<StandardOperation> _operations_1 = _actorClass_2.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(_filter_1);
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ _builder.append("\t");
+ ActorClass _actorClass_3 = ai_1.getActorClass();
+ String _name_28 = _actorClass_3.getName();
+ String _constructorName = this.languageExt.constructorName(_name_28);
+ _builder.append(_constructorName, " ");
+ _builder.append("(&");
+ String _path_1 = ai_1.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_29 = ssc.getName();
+ _builder.append(_name_29, "");
+ _builder.append("_initActorInstances(void){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ String _name_30 = ssc.getName();
+ _builder.append(_name_30, " ");
+ _builder.append("\", \"initActorInstances\")");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_2) {
+ _builder.append("\t");
+ ActorClass _actorClass_4 = ai_2.getActorClass();
+ String _name_31 = _actorClass_4.getName();
+ _builder.append(_name_31, " ");
+ _builder.append("_init(&");
+ String _path_2 = ai_2.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence generateInstanceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Instance File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - instantiation of all actor instances and port instances");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* - configuration of data and connection of ports");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessageService.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etMemory.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* instantiation of message services */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* MessageService for Thread1 */");
+ _builder.newLine();
+ _builder.append("static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];");
+ _builder.newLine();
+ _builder.append("static etMessageService msgService_Thread1;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* include all used ActorClasses */");
+ _builder.newLine();
+ {
+ EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
+ for(final ActorClass actorClass : _usedActorClasses) {
+ _builder.append("#include \"");
+ String _name_1 = actorClass.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* include all used ProtcolClasses */");
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for(final ProtocolClass protocolClass : _usedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_2 = protocolClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* declarations of all ActorClass instances (const and variable structs) */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* forward declaration of variable actor structs */");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("static ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" ");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* forward declaration of variable port structs */\t\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/*nothing to do */");
+ _builder.newLine();
+ } else {
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_1.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances_1) {
+ {
+ ProtocolClass _protocol = pi.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
+ boolean _notEquals = (!Objects.equal(_portClass, null));
+ if (_notEquals) {
+ {
+ ProtocolClass _protocol_1 = pi.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1);
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty_1 = _attributes.isEmpty();
+ boolean _not = (!_isEmpty_1);
+ if (_not) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ _builder.append("static ");
+ ProtocolClass _protocol_2 = pi.getProtocol();
+ boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
+ String _portClassName = this.roomExt.getPortClassName(_protocol_2, _isConjugated_2);
+ _builder.append(_portClassName, "");
+ _builder.append("_var ");
+ String _path_1 = pi.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append("_var[");
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ int _size = _peers.size();
+ _builder.append(_size, "");
+ _builder.append("]={");
+ String _genReplPortAttributeInitializer = this.genReplPortAttributeInitializer(pi);
+ _builder.append(_genReplPortAttributeInitializer, "");
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("static ");
+ ProtocolClass _protocol_3 = pi.getProtocol();
+ boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
+ String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3);
+ _builder.append(_portClassName_1, "");
+ _builder.append("_var ");
+ String _path_2 = pi.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append("_var={");
+ CharSequence _genPortAttributeInitializer = this.genPortAttributeInitializer(pi);
+ _builder.append(_genPortAttributeInitializer, "");
+ _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 _path_3 = ai_2.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_3, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty_2 = _orderedIfItemInstances_2.isEmpty();
+ if (_isEmpty_2) {
+ _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();
+ return _builder;
+ }
+
+ private String genReplPortAttributeInitializer(final InterfaceItemInstance pi) {
+ int i = 0;
+ String retval = "";
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ int _size = _peers.size();
+ i = _size;
+ boolean _greaterThan = (i > 0);
+ boolean _while = _greaterThan;
+ while (_while) {
+ {
+ String _plus = (retval + "\r\n\t\t\t{");
+ CharSequence _genPortAttributeInitializer = this.genPortAttributeInitializer(pi);
+ String _plus_1 = (_plus + _genPortAttributeInitializer);
+ String _plus_2 = (_plus_1 + "}");
+ retval = _plus_2;
+ int _minus = (i - 1);
+ i = _minus;
+ boolean _greaterThan_1 = (i > 0);
+ if (_greaterThan_1) {
+ String _plus_3 = (retval + ",");
+ retval = _plus_3;
+ }
+ }
+ boolean _greaterThan_1 = (i > 0);
+ _while = _greaterThan_1;
+ }
+ return retval;
+ }
+
+ private CharSequence genPortAttributeInitializer(final InterfaceItemInstance pi) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ ProtocolClass _protocol = pi.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
+ EList<Attribute> _attributes = _portClass.getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute attr : _attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", "");
+ }
+ {
+ String _defaultValueLiteral = attr.getDefaultValueLiteral();
+ boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals) {
+ String _defaultValueLiteral_1 = attr.getDefaultValueLiteral();
+ _builder.append(_defaultValueLiteral_1, "");
+ } else {
+ RefableType _refType = attr.getRefType();
+ DataType _type = _refType.getType();
+ String _defaultValue = this._typeHelpers.defaultValue(_type);
+ _builder.append(_defaultValue, "");
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence genActorInstanceInitializer(final Root root, final ActorInstance ai) {
+ CharSequence _xblockexpression = null;
+ {
+ String _path = ai.getPath();
+ String instName = this.roomExt.getPathName(_path);
+ ArrayList<InterfaceItemInstance> _arrayList = new ArrayList<InterfaceItemInstance>();
+ ArrayList<InterfaceItemInstance> replPorts = _arrayList;
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ final Function1<InterfaceItemInstance,Boolean> _function = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ boolean _isReplicated = e.isReplicated();
+ return Boolean.valueOf(_isReplicated);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances, _function);
+ Iterables.<InterfaceItemInstance>addAll(replPorts, _filter);
+ final Function1<InterfaceItemInstance,Boolean> _function_1 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ EList<InterfaceItemInstance> _peers = e.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ boolean _not = (!_isEmpty);
+ return Boolean.valueOf(_not);
+ }
+ };
+ InterfaceItemInstance _findFirst = IterableExtensions.<InterfaceItemInstance>findFirst(replPorts, _function_1);
+ boolean haveReplSubPorts = (!Objects.equal(_findFirst, null));
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai.getOrderedIfItemInstances();
+ final Function1<InterfaceItemInstance,Boolean> _function_2 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ boolean _isSimple = e.isSimple();
+ return Boolean.valueOf(_isSimple);
+ }
+ };
+ Iterable<InterfaceItemInstance> simplePorts = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances_1, _function_2);
+ ArrayList<InterfaceItemInstance> _arrayList_1 = new ArrayList<InterfaceItemInstance>();
+ ArrayList<InterfaceItemInstance> eventPorts = _arrayList_1;
+ final Function1<InterfaceItemInstance,Boolean> _function_3 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ ProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_1 = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_3);
+ Iterable<InterfaceItemInstance> _union = this.roomExt.<InterfaceItemInstance>union(_filter_1, replPorts);
+ Iterables.<InterfaceItemInstance>addAll(eventPorts, _union);
+ final Function1<InterfaceItemInstance,Boolean> _function_4 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ ProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Iterable<InterfaceItemInstance> dataPorts = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_4);
+ final Function1<InterfaceItemInstance,Boolean> _function_5 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ boolean _and = false;
+ if (!(p instanceof PortInstance)) {
+ _and = false;
+ } else {
+ Port _port = ((PortInstance) p).getPort();
+ boolean _isConjugated = _port.isConjugated();
+ boolean _not = (!_isConjugated);
+ _and = ((p instanceof PortInstance) && _not);
+ }
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<InterfaceItemInstance> recvPorts = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_5);
+ HashMap<InterfaceItemInstance,Integer> _hashMap = new HashMap<InterfaceItemInstance,Integer>();
+ HashMap<InterfaceItemInstance,Integer> offsets = _hashMap;
+ int offset = 0;
+ for (final InterfaceItemInstance p : replPorts) {
+ {
+ offsets.put(p, Integer.valueOf(offset));
+ EList<InterfaceItemInstance> _peers = p.getPeers();
+ int _size = _peers.size();
+ int _plus = (offset + _size);
+ offset = _plus;
+ }
+ }
+ String _xifexpression = null;
+ if (haveReplSubPorts) {
+ String _plus = (instName + "_repl_sub_ports");
+ _xifexpression = _plus;
+ } else {
+ _xifexpression = "NULL";
+ }
+ String replSubPortsArray = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ if (haveReplSubPorts) {
+ _builder.append("static const etReplSubPort ");
+ _builder.append(replSubPortsArray, "");
+ _builder.append("[");
+ _builder.append(offset, "");
+ _builder.append("] = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */");
+ _builder.newLine();
+ {
+ final Function1<InterfaceItemInstance,Boolean> _function_6 = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance e) {
+ EList<InterfaceItemInstance> _peers = e.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ boolean _not = (!_isEmpty);
+ return Boolean.valueOf(_not);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter_2 = IterableExtensions.<InterfaceItemInstance>filter(replPorts, _function_6);
+ boolean _hasElements = false;
+ for(final InterfaceItemInstance pi : _filter_2) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi);
+ _builder.append(_genReplSubPortInitializers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _and = false;
+ boolean _isEmpty = eventPorts.isEmpty();
+ if (!_isEmpty) {
+ _and = false;
+ } else {
+ boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
+ _and = (_isEmpty && _isEmpty_1);
+ }
+ boolean _not = (!_and);
+ if (_not) {
+ _builder.append("static const ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ _builder.append(_name, "");
+ _builder.append("_const ");
+ _builder.append(instName, "");
+ _builder.append("_const = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Ports: {varData, msgService, peerAddress, localId} */");
+ _builder.newLine();
+ {
+ boolean _hasElements_1 = false;
+ for(final InterfaceItemInstance pi_1 : eventPorts) {
+ if (!_hasElements_1) {
+ _hasElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _isSimple = pi_1.isSimple();
+ if (_isSimple) {
+ _builder.append("\t");
+ String _genPortInitializer = this.genPortInitializer(root, ai, pi_1);
+ _builder.append(_genPortInitializer, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("{");
+ EList<InterfaceItemInstance> _peers = pi_1.getPeers();
+ int _size = _peers.size();
+ _builder.append(_size, " ");
+ _builder.append(", ");
+ _builder.append(replSubPortsArray, " ");
+ _builder.append("+");
+ Integer _get = offsets.get(pi_1);
+ _builder.append(_get, " ");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ {
+ boolean _and_1 = false;
+ boolean _isEmpty_2 = eventPorts.isEmpty();
+ boolean _not_1 = (!_isEmpty_2);
+ if (!_not_1) {
+ _and_1 = false;
+ } else {
+ boolean _isEmpty_3 = IterableExtensions.isEmpty(recvPorts);
+ boolean _not_2 = (!_isEmpty_3);
+ _and_1 = (_not_1 && _not_2);
+ }
+ if (_and_1) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* data receive ports */");
+ _builder.newLine();
+ {
+ boolean _hasElements_2 = false;
+ for(final InterfaceItemInstance pi_2 : recvPorts) {
+ if (!_hasElements_2) {
+ _hasElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _genRecvPortInitializer = this.genRecvPortInitializer(root, ai, pi_2);
+ _builder.append(_genRecvPortInitializer, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("static ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_1 = _actorClass_1.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" ");
+ _builder.append(instName, "");
+ _builder.append(" = {&");
+ _builder.append(instName, "");
+ _builder.append("_const};");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String genPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
+ String _xblockexpression = null;
+ {
+ int _xifexpression = (int) 0;
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ if (_isEmpty) {
+ _xifexpression = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ InterfaceItemInstance _get = _peers_1.get(0);
+ int _objId = _get.getObjId();
+ _xifexpression = _objId;
+ }
+ int objId = _xifexpression;
+ int _xifexpression_1 = (int) 0;
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ boolean _isEmpty_1 = _peers_2.isEmpty();
+ if (_isEmpty_1) {
+ _xifexpression_1 = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ InterfaceItemInstance _get_1 = _peers_3.get(0);
+ EList<InterfaceItemInstance> _peers_4 = _get_1.getPeers();
+ int _indexOf = _peers_4.indexOf(pi);
+ _xifexpression_1 = _indexOf;
+ }
+ int idx = _xifexpression_1;
+ String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi);
+ String _plus = ("{" + _interfaceItemInstanceData);
+ String _plus_1 = (_plus + ",");
+ String _plus_2 = (_plus_1 + "&msgService_Thread1, ");
+ int _plus_3 = (objId + idx);
+ String _plus_4 = (_plus_2 + Integer.valueOf(_plus_3));
+ String _plus_5 = (_plus_4 + ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
+ int _plus_6 = (_interfaceItemLocalId + 1);
+ String _plus_7 = (_plus_5 + Integer.valueOf(_plus_6));
+ String _plus_8 = (_plus_7 + "} /* Port ");
+ String _name = pi.getName();
+ String _plus_9 = (_plus_8 + _name);
+ String _plus_10 = (_plus_9 + " */");
+ _xblockexpression = (_plus_10);
+ }
+ return _xblockexpression;
+ }
+
+ private String getInterfaceItemInstanceData(final InterfaceItemInstance pi) {
+ ProtocolClass _protocol = pi.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
+ boolean _equals = Objects.equal(_portClass, null);
+ if (_equals) {
+ return "0";
+ }
+ ProtocolClass _protocol_1 = pi.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1);
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ if (_isEmpty) {
+ return "0";
+ } else {
+ String _path = pi.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _plus = ("&" + _pathName);
+ return (_plus + "_var");
+ }
+ }
+
+ private String genRecvPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
+ String _xblockexpression = null;
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ if (_isEmpty) {
+ return "{NULL}";
+ }
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ InterfaceItemInstance peer = _peers_1.get(0);
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ InterfaceItemInstance _get = _peers_2.get(0);
+ EObject _eContainer = _get.eContainer();
+ ActorInstance peerInst = ((ActorInstance) _eContainer);
+ String _path = peerInst.getPath();
+ String instName = this.roomExt.getPathName(_path);
+ String _plus = ("{&" + instName);
+ String _plus_1 = (_plus + ".");
+ String _name = peer.getName();
+ String _plus_2 = (_plus_1 + _name);
+ String _plus_3 = (_plus_2 + "}");
+ _xblockexpression = (_plus_3);
+ }
+ return _xblockexpression;
+ }
+
+ private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
+ String result = "";
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for (final InterfaceItemInstance p : _peers) {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int idx = _peers_1.indexOf(p);
+ String _xifexpression = null;
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _size = _peers_2.size();
+ int _minus = (_size - 1);
+ boolean _lessThan = (idx < _minus);
+ if (_lessThan) {
+ _xifexpression = ",";
+ } else {
+ _xifexpression = "";
+ }
+ String comma = _xifexpression;
+ String iiiD = this.getInterfaceItemInstanceData(pi);
+ String _xifexpression_1 = null;
+ boolean _equals = iiiD.equals("0");
+ if (_equals) {
+ String _plus = (iiiD + ",");
+ _xifexpression_1 = _plus;
+ } else {
+ String _plus_1 = (iiiD + "[");
+ String _plus_2 = (_plus_1 + Integer.valueOf(idx));
+ String _plus_3 = (_plus_2 + "],");
+ _xifexpression_1 = _plus_3;
+ }
+ iiiD = _xifexpression_1;
+ String _plus_4 = (result +
+ "{");
+ String _plus_5 = (_plus_4 + iiiD);
+ String _plus_6 = (_plus_5 + "&msgService_Thread1, ");
+ int _objId = p.getObjId();
+ String _plus_7 = (_plus_6 + Integer.valueOf(_objId));
+ String _plus_8 = (_plus_7 + ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
+ int _plus_9 = (_interfaceItemLocalId + 1);
+ String _plus_10 = (_plus_8 + Integer.valueOf(_plus_9));
+ String _plus_11 = (_plus_10 + ", ");
+ String _plus_12 = (_plus_11 + Integer.valueOf(idx));
+ String _plus_13 = (_plus_12 + "}");
+ String _plus_14 = (_plus_13 + comma);
+ String _plus_15 = (_plus_14 + " /* Repl Sub Port ");
+ String _name = pi.getName();
+ String _plus_16 = (_plus_15 + _name);
+ String _plus_17 = (_plus_16 + " idx +");
+ String _plus_18 = (_plus_17 + Integer.valueOf(idx));
+ String _plus_19 = (_plus_18 + "*/\n");
+ result = _plus_19;
+ }
+ }
+ return result;
+ }
+
+ private CharSequence generateDispatcherFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Dispatcher File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - one generated dispatcher for each MessageService (Thread)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"messaging/etMessageReceiver.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_Thread1\", \"receiveMessage\")");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("switch(msg->address){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("\t\t");
+ _builder.append("/* interface items of ");
+ String _path = ai.getPath();
+ _builder.append(_path, " ");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ final Function1<InterfaceItemInstance,Boolean> _function = new Function1<InterfaceItemInstance,Boolean>() {
+ public Boolean apply(final InterfaceItemInstance p) {
+ ProtocolClass _protocol = p.getProtocol();
+ CommunicationType _commType = _protocol.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances, _function);
+ for(final InterfaceItemInstance pi : _filter) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId = pi.getObjId();
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(peer);
+ int _plus = (_objId + _indexOf);
+ _builder.append(_plus, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ {
+ ProtocolClass _protocol = pi.getProtocol();
+ boolean _isConjugated = this.roomExt.isConjugated(pi);
+ boolean _handlesReceive = this.roomExt.handlesReceive(_protocol, _isConjugated);
+ if (_handlesReceive) {
+ _builder.append("\t\t");
+ _builder.append("switch (msg->evtID){");
+ _builder.newLine();
+ {
+ ProtocolClass _protocol_1 = pi.getProtocol();
+ boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(_protocol_1, _isConjugated_1);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ ProtocolClass _protocol_2 = pi.getProtocol();
+ String _name_1 = _protocol_2.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _codeName = this.roomExt.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ ProtocolClass _protocol_3 = pi.getProtocol();
+ boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
+ String _portClassName = this.roomExt.getPortClassName(_protocol_3, _isConjugated_2);
+ _builder.append(_portClassName, " ");
+ _builder.append("_");
+ Message _msg_1 = h.getMsg();
+ String _name_2 = _msg_1.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("_receiveHandler((etPort *)&");
+ String _path_1 = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append("_const.");
+ String _name_3 = pi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_1 = _peers_2.indexOf(peer);
+ _builder.append(_indexOf_1, " ");
+ _builder.append("],msg,(void*)&");
+ String _path_2 = ai.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_1, " ");
+ _builder.append(",");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_4 = _actorClass.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_receiveMessage);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("default: ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_5 = _actorClass_1.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_3 = ai.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_2, " ");
+ _builder.append(",(etPort*)&");
+ String _path_4 = ai.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_4);
+ _builder.append(_pathName_3, " ");
+ _builder.append("_const.");
+ String _name_6 = pi.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ int _indexOf_2 = _peers_3.indexOf(peer);
+ _builder.append(_indexOf_2, " ");
+ _builder.append("], msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ ActorClass _actorClass_2 = ai.getActorClass();
+ String _name_7 = _actorClass_2.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_5 = ai.getPath();
+ String _pathName_4 = this.roomExt.getPathName(_path_5);
+ _builder.append(_pathName_4, " ");
+ _builder.append(",(etPort*)&");
+ String _path_6 = ai.getPath();
+ String _pathName_5 = this.roomExt.getPathName(_path_6);
+ _builder.append(_pathName_5, " ");
+ _builder.append("_const.");
+ String _name_8 = pi.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ int _indexOf_3 = _peers_4.indexOf(peer);
+ _builder.append(_indexOf_3, " ");
+ _builder.append("], msg);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId_1 = pi.getObjId();
+ _builder.append(_objId_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ {
+ ProtocolClass _protocol_4 = pi.getProtocol();
+ boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
+ boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_4, _isConjugated_3);
+ if (_handlesReceive_1) {
+ _builder.append("\t\t");
+ _builder.append("switch (msg->evtID){");
+ _builder.newLine();
+ {
+ ProtocolClass _protocol_5 = pi.getProtocol();
+ boolean _isConjugated_4 = this.roomExt.isConjugated(pi);
+ List<MessageHandler> _receiveHandlers_1 = this.roomExt.getReceiveHandlers(_protocol_5, _isConjugated_4);
+ for(final MessageHandler h_1 : _receiveHandlers_1) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ ProtocolClass _protocol_6 = pi.getProtocol();
+ String _name_9 = _protocol_6.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("_");
+ Message _msg_2 = h_1.getMsg();
+ String _codeName_1 = this.roomExt.getCodeName(_msg_2);
+ _builder.append(_codeName_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ ProtocolClass _protocol_7 = pi.getProtocol();
+ boolean _isConjugated_5 = this.roomExt.isConjugated(pi);
+ String _portClassName_1 = this.roomExt.getPortClassName(_protocol_7, _isConjugated_5);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("_");
+ Message _msg_3 = h_1.getMsg();
+ String _name_10 = _msg_3.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("_receiveHandler((etPort *)&");
+ String _path_7 = ai.getPath();
+ String _pathName_6 = this.roomExt.getPathName(_path_7);
+ _builder.append(_pathName_6, " ");
+ _builder.append("_const.");
+ String _name_11 = pi.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(",msg,(void*)&");
+ String _path_8 = ai.getPath();
+ String _pathName_7 = this.roomExt.getPathName(_path_8);
+ _builder.append(_pathName_7, " ");
+ _builder.append(",");
+ ActorClass _actorClass_3 = ai.getActorClass();
+ String _name_12 = _actorClass_3.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("_receiveMessage);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("default: ");
+ ActorClass _actorClass_4 = ai.getActorClass();
+ String _name_13 = _actorClass_4.getName();
+ _builder.append(_name_13, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_9 = ai.getPath();
+ String _pathName_8 = this.roomExt.getPathName(_path_9);
+ _builder.append(_pathName_8, " ");
+ _builder.append(",(etPort*)&");
+ String _path_10 = ai.getPath();
+ String _pathName_9 = this.roomExt.getPathName(_path_10);
+ _builder.append(_pathName_9, " ");
+ _builder.append("_const.");
+ String _name_14 = pi.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ ActorClass _actorClass_5 = ai.getActorClass();
+ String _name_15 = _actorClass_5.getName();
+ _builder.append(_name_15, " ");
+ _builder.append("_receiveMessage((void*)&");
+ String _path_11 = ai.getPath();
+ String _pathName_10 = this.roomExt.getPathName(_path_11);
+ _builder.append(_pathName_10, " ");
+ _builder.append(",(etPort*)&");
+ String _path_12 = ai.getPath();
+ String _pathName_11 = this.roomExt.getPathName(_path_12);
+ _builder.append(_pathName_11, " ");
+ _builder.append("_const.");
+ String _name_16 = pi.getName();
+ _builder.append(_name_16, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("default:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("etLogger_logErrorF(\"MessageService_Thread1_receiveMessage: address %d does not exist \", msg->address);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence generateDatadrivenExecutes(final Root root, final SubSystemInstance ssi) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ {
+ boolean _or = false;
+ ActorClass _actorClass = ai.getActorClass();
+ ActorCommunicationType _commType = _actorClass.getCommType();
+ boolean _equals = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ if (_equals) {
+ _or = true;
+ } else {
+ ActorClass _actorClass_1 = ai.getActorClass();
+ ActorCommunicationType _commType_1 = _actorClass_1.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, ActorCommunicationType.DATA_DRIVEN);
+ _or = (_equals || _equals_1);
+ }
+ if (_or) {
+ ActorClass _actorClass_2 = ai.getActorClass();
+ String _name = _actorClass_2.getName();
+ _builder.append(_name, "");
+ _builder.append("_execute(&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
new file mode 100644
index 0000000..a1a5d02
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
@@ -0,0 +1,171 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _plus = (_generationTargetPath + _path);
+ this.fileAccess.setOutputPath(_plus);
+ String _name = sc.getName();
+ String _plus_1 = (_name + "_Runner.c");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_plus_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssi.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _name_2 = ssi.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"debugging/etLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etPlatform.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("int main(void) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etUserEntry(); /* platform specific */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_OPEN(\"main\");");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* startup sequence of lifecycle */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_3 = ssi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("_init(); \t\t/* lifecycle init */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_4 = ssi.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_start(); \t/* lifecycle start */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etUserPreRun(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* run Scheduler */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_5 = ssi.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_run();");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etUserPostRun(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* shutdown sequence of lifecycle */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_6 = ssi.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_stop(); \t\t/* lifecycle stop */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_7 = ssi.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("_destroy(); \t/* lifecycle destroy */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_CLOSE");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfo(\"*** T H E E N D ***\");");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etUserExit(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return 0;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
index bb5676e..43f8c7b 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
@@ -146,7 +146,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«ENDIF»
}
- «IF !dynConfigReadAttributes.empty»
+ «IF !dynConfigReadAttributes.empty || !dynConfigWriteAttributes.empty»
public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr, VariableService variableService){
this(parent, name, port_addr, peer_addr);
@@ -159,8 +159,7 @@ class ActorClassGen extends GenericActorClassGenerator {
}
«ENDIF»
- //--------------------- attributes getter and setter
- «attributeSettersGettersImplementation(ac.attributes.minus(dynConfigReadAttributes), ac.name)»
+ «attributeSettersGettersImplementation(ac.attributes.minus(dynConfigReadAttributes.toList), ac.name)»
«configAddon.genDynConfigGetterSetter(ac)»
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
index 7405de7..1788da5 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
@@ -60,7 +60,7 @@ class ConfigGenAddon {
def public genDynConfigGetterSetter(ActorClass ac){'''
«FOR a : ac.getDynConfigAttributes(true, false)»
- public «a.refType.type.typeName» get«a.name.toFirstUpper»(){
+ public «a.refType.type.typeName»«IF a.size>0»[]«ENDIF» get«a.name.toFirstUpper»(){
if(lock_«a.name» == null)
return «a.name»;
else
@@ -68,7 +68,7 @@ class ConfigGenAddon {
return «a.name»;
}
}
- public void set«a.name.toFirstUpper»(«a.refType.type.typeName» «a.name»){
+ public void set«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
if(lock_«a.name» == null)
this.«a.name» = «a.name»;
else
@@ -81,7 +81,7 @@ class ConfigGenAddon {
}
«ENDFOR»
«FOR a : ac.getDynConfigAttributes(false, true)»
- public void setAndWrite«a.name.toFirstUpper»(«a.refType.type.typeName» «a.name»){
+ public void setAndWrite«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
set«a.name.toFirstUpper»(«a.name»);
variableService.write(this.getInstancePath()+"/«a.name»", «a.name»);
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index e803c12..9832ea0 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -127,8 +127,7 @@ class JavaExtensions implements ILanguageExtension {
case "double":
return value+"d"
case "char":{
- var string = String::valueOf(value)
- if(string.length == 1)
+ if(value.length == 1)
return "'"+value+"'"
else
return value.toCharArrayExpr
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
index d5a283f..0334901 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
@@ -29,6 +29,7 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.RoomModel
import org.eclipse.etrice.core.room.SubSystemClass
import org.eclipse.etrice.generator.generic.ConfigExtension
import org.eclipse.etrice.generator.generic.ProcedureHelpers
@@ -65,36 +66,34 @@ class VariableServiceGen {
import java.util.Map;
import org.eclipse.etrice.runtime.java.config.VariableService;
«IF dynConfig.userCode1 != null»
- «dynConfig.userCode1»
+ «dynConfig.userCode1»;
«ELSE»
- import org.eclipse.etrice.runtime.java.config.ConfigSourceFile
- «ENDIF»;
+ import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;
+ «ENDIF»
+ «var ais = dynConfigsAIs(comp)»
+ «FOR model : ais.roomModels»
+ import «model.name».*;
+ «ENDFOR»
+
public class «comp.name+"VariableService"» extends VariableService{
private «cc.name» subSystem;
- private Map<String, Object> diffMap;
- // Actor instances
- «var ais = dynConfigsAIs(comp)»
+ // Actor instances
«FOR ai : ais»
- private «ai.actorClass.name» «ai.name»;
+ private «ai.actorClass.name» «ai.path.split("/").drop(2).toPath("_")»;
«ENDFOR»
public «comp.name+"VariableService"»(«cc.name» subSystem) {
+ super(«IF dynConfig.filePath != null»new ConfigSourceFile("«dynConfig.filePath»")«ELSE»«dynConfig.userCode2»«ENDIF»);
this.subSystem = subSystem;
- «IF dynConfig.filePath != null»
- source = new ConfigSourceFile("«dynConfig.filePath»");
- «ELSE»
- source = «dynConfig.userCode2»;
- «ENDIF»
- diffMap = new HashMap<String, Object>();
}
@Override
- protected void getInstances(){
+ protected void initInstances(){
«FOR ai : ais»
- «ai.name» = («ai.actorClass.name»)subSystem.getInstance("«ai.path»");
+ «ai.path.split("/").drop(2).toPath("_")» = («ai.actorClass.name»)subSystem.getInstance("«ai.path»");
«ENDFOR»
}
@@ -104,7 +103,7 @@ class VariableServiceGen {
Object object;
String id = null;
«FOR attrConfig : cc.getAttrDynConfigs(true, false)»
- «var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.last»
+ «var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.toPath("_")»
try{
boolean changed = false;
«FOR entry : attrConfig.allAttributes.entrySet»
@@ -116,7 +115,7 @@ class VariableServiceGen {
if(object != null){
_«a.name» = ensure«a.refType.type.typeName.toFirstUpper»«IF a.size>0»Array«ENDIF»(object«IF a.size>0», «a.size»«ENDIF»);
«genMinMaxCheck(attrConfig, (attrConfig.eContainer as ActorInstanceConfig).actorClassConfig)»
- if(!«IF a.size==0»_«a.name».equals(«ELSE»Arrays.equals(_«a.name», «ENDIF»(«IF a.size==0»«a.refType.type.typeName.toWrapper»«ELSE»«a.refType.type.typeName»[]«ENDIF»)diffMap.get(id)))
+ if(!«IF a.size==0»_«a.name».equals(«ELSE»Arrays.equals(_«a.name», «ENDIF»(«IF a.size==0»«a.refType.type.typeName.toWrapper»«ELSE»«a.refType.type.typeName»[]«ENDIF»)getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
@@ -127,7 +126,7 @@ class VariableServiceGen {
«FOR entry : attrConfig.allAttributes.entrySet»
if(_«entry.key.name» != null){
«aiName»«entry.value.toInvoke».«invokeSetter(entry.key.name, null, "_"+entry.key.name)»;
- diffMap.put("«comp.path»«entry.value.toPath("/")»/«entry.key.name»", _«entry.key.name»);
+ getDiffMap().put("«attrConfig.getPath(true, true, true, false).toPath("/")+entry.value.toPath("/")+"/"+entry.key.name»", _«entry.key.name»);
}
«ENDFOR»
}
@@ -142,7 +141,7 @@ class VariableServiceGen {
protected Map<String, Object> getAttributeValues(){
Map<String, Object> values = new HashMap<String, Object>();
«FOR attrConfig : cc.getAttrDynConfigs(true, false)»
- «var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.last»
+ «var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.toPath("_")»
«FOR entry : attrConfig.allAttributes.entrySet»
«var array = entry.key.size>0»
«var aPath = attrConfig.getPath(true, true, true, false).toPath("/")+entry.value.toPath("/")+"/"+entry.key.name»
@@ -154,33 +153,32 @@ class VariableServiceGen {
}
@Override
- public void write(String id, Object object){
- if(object.getClass().isPrimitive() || object.getClass().isArray())
- writeTasks.put(id, object);
- else {
- synchronized(writeTasks){
- «FOR dc : comp.dynDataClasses»
- if(object.getClass().equals(«dc.typeName».class))
- write(id, («dc.typeName») object);
- «ENDFOR»
- }
- }
+ public void writeDataClass(String id, Object dcObject, Map<String, Object> writeMap) {
+ «FOR dc : comp.dynDataClasses»
+ if(dcObject.getClass().equals(«dc.typeName».class))
+ writeDataClass(id, («dc.typeName») dcObject, writeTasks);
+ «ENDFOR»
}
// DataClasses write operations
«FOR dc : comp.allDynDataClasses»
- private void write(String id, «dc.typeName» object){
+ private void writeDataClass(String id, «dc.typeName» object, Map<String, Object> map){
«FOR a : dc.attributes»
«IF a.refType.type.primitive»
- writeTasks.put("id/«a.name»", object.«invokeGetter(a.name, null)»);
+ map.put(id+"/«a.name»", «IF a.size>0»toObjectArray(«ENDIF»object.«invokeGetter(a.name, null)»«IF a.size>0»)«ENDIF»);
«ELSE»
- write("id/«a.name»", object.«invokeGetter(a.name, null)»);
+ writeDataClass(id+"/«a.name»", object.«invokeGetter(a.name, null)», map);
«ENDIF»
«ENDFOR»
}
«ENDFOR»
+ @Override
+ protected int getPollingTimerUser(){
+ return «dynConfig.polling»;
+ }
+
}
'''}
@@ -265,7 +263,6 @@ class VariableServiceGen {
}
def private resolve(ActorClassConfig config, String[] path){
-
var result = config.attributes.findFirst(c | c.attribute.name.equals(path.head))
for (String ref : path.tail) {
result = result?.attributes.findFirst(c | c.attribute.name.equals(ref))
@@ -276,5 +273,11 @@ class VariableServiceGen {
return result
}
+ def private getRoomModels(List<ActorInstance> ais){
+ val models = new HashSet<RoomModel>
+ ais.forEach(ai | models.add(ai.actorClass.eContainer as RoomModel))
+ return models
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
new file mode 100644
index 0000000..79bc67a
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -0,0 +1,720 @@
+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.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.java.gen.ConfigGenAddon;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.etrice.generator.java.gen.StateMachineGen;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ConfigExtension configExt;
+
+ @Inject
+ private ConfigGenAddon configAddon;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private StateMachineGen _stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this.roomExt.getPath(_actorClass_1);
+ String path = (_generationTargetPath + _path);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String file = this.stdExt.getJavaFileName(_actorClass_2);
+ String _plus = ("generating ActorClass implementation \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ CharSequence _generate = this.generate(root, xpac, _actorClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ EList<StandardOperation> _operations_1 = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
+ final HashSet<Attribute> dynConfigReadAttributes = this.configExt.getDynConfigAttributes(ac, true, false);
+ final HashSet<Attribute> dynConfigWriteAttributes = this.configExt.getDynConfigAttributes(ac, false, true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(ac);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _isEmpty = dynConfigReadAttributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("import org.eclipse.etrice.runtime.java.config.DynConfigLock;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _or = false;
+ boolean _isEmpty_1 = dynConfigReadAttributes.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ _or = true;
+ } else {
+ boolean _isEmpty_2 = dynConfigWriteAttributes.isEmpty();
+ boolean _not_2 = (!_isEmpty_2);
+ _or = (_not_1 || _not_2);
+ }
+ if (_or) {
+ _builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
+ for(final RoomModel model : _referencedModels) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("import ");
+ String _package_1 = this.roomExt.getPackage(pc);
+ _builder.append(_package_1, "");
+ _builder.append(".");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public ");
+ {
+ boolean _isAbstract = ac.isAbstract();
+ if (_isAbstract) {
+ _builder.append("abstract ");
+ }
+ }
+ _builder.append("class ");
+ String _name_2 = ac.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" extends ");
+ {
+ ActorClass _base = ac.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ ActorClass _base_1 = ac.getBase();
+ String _name_3 = _base_1.getName();
+ _builder.append(_name_3, "");
+ } else {
+ _builder.append("ActorClassBase");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _isEmpty_3 = dynConfigWriteAttributes.isEmpty();
+ boolean _not_3 = (!_isEmpty_3);
+ if (_not_3) {
+ _builder.append("\t");
+ _builder.append("private VariableService variableService;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts = this.roomExt.getEndPorts(ac);
+ for(final Port ep : _endPorts) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName = this.roomExt.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_4 = ep.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ for(final SAPRef sap : _strSAPs) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName_1 = this.roomExt.getPortClassName(sap);
+ _builder.append(_portClassName_1, " ");
+ _builder.append(" ");
+ String _name_5 = sap.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- services");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ for(final ServiceImplementation svc : _serviceImplementations) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName_2 = this.roomExt.getPortClassName(svc);
+ _builder.append(_portClassName_2, " ");
+ _builder.append(" ");
+ SPPRef _spp = svc.getSpp();
+ String _name_6 = _spp.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- interface item IDs");
+ _builder.newLine();
+ _builder.append("\t");
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _genMinMaxConstants = this.configAddon.genMinMaxConstants(ac);
+ _builder.append(_genMinMaxConstants, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ for(final Attribute a : dynConfigReadAttributes) {
+ _builder.append("\t");
+ _builder.append("private DynConfigLock lock_");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- construction");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
+ _builder.newLineIfNotEmpty();
+ {
+ ActorClass _base_2 = ac.getBase();
+ boolean _equals = Objects.equal(_base_2, null);
+ if (_equals) {
+ _builder.append("\t\t");
+ _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("super(parent, name, port_addr, peer_addr);");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("setClassName(\"");
+ String _name_9 = ac.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<Attribute> _attributes_2 = ac.getAttributes();
+ CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes_2, false);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_1 : _endPorts_1) {
+ _builder.append("\t\t");
+ String _name_10 = ep_1.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(" = new ");
+ String _portClassName_3 = this.roomExt.getPortClassName(ep_1);
+ _builder.append(_portClassName_3, " ");
+ _builder.append("(this, \"");
+ String _name_11 = ep_1.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\", IFITEM_");
+ String _name_12 = ep_1.getName();
+ _builder.append(_name_12, " ");
+ _builder.append(", ");
+ {
+ int _multiplicity = ep_1.getMultiplicity();
+ boolean _equals_1 = (_multiplicity == 1);
+ if (_equals_1) {
+ _builder.append("0, ");
+ }
+ }
+ _builder.append("port_addr[IFITEM_");
+ String _name_13 = ep_1.getName();
+ _builder.append(_name_13, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _equals_2 = (_multiplicity_1 == 1);
+ if (_equals_2) {
+ _builder.append("[0]");
+ }
+ }
+ _builder.append(", peer_addr[IFITEM_");
+ String _name_14 = ep_1.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_2 = ep_1.getMultiplicity();
+ boolean _equals_3 = (_multiplicity_2 == 1);
+ if (_equals_3) {
+ _builder.append("[0]");
+ }
+ }
+ _builder.append("); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
+ for(final SAPRef sap_1 : _strSAPs_1) {
+ _builder.append("\t\t");
+ String _name_15 = sap_1.getName();
+ _builder.append(_name_15, " ");
+ _builder.append(" = new ");
+ String _portClassName_4 = this.roomExt.getPortClassName(sap_1);
+ _builder.append(_portClassName_4, " ");
+ _builder.append("(this, \"");
+ String _name_16 = sap_1.getName();
+ _builder.append(_name_16, " ");
+ _builder.append("\", IFITEM_");
+ String _name_17 = sap_1.getName();
+ _builder.append(_name_17, " ");
+ _builder.append(", 0, port_addr[IFITEM_");
+ String _name_18 = sap_1.getName();
+ _builder.append(_name_18, " ");
+ _builder.append("][0], peer_addr[IFITEM_");
+ String _name_19 = sap_1.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("][0]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own service implementations");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
+ _builder.append("\t\t");
+ SPPRef _spp_1 = svc_1.getSpp();
+ String _name_20 = _spp_1.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(" = new ");
+ String _portClassName_5 = this.roomExt.getPortClassName(svc_1);
+ _builder.append(_portClassName_5, " ");
+ _builder.append("(this, \"");
+ SPPRef _spp_2 = svc_1.getSpp();
+ String _name_21 = _spp_2.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("\", IFITEM_");
+ SPPRef _spp_3 = svc_1.getSpp();
+ String _name_22 = _spp_3.getName();
+ _builder.append(_name_22, " ");
+ _builder.append(", port_addr[IFITEM_");
+ SPPRef _spp_4 = svc_1.getSpp();
+ String _name_23 = _spp_4.getName();
+ _builder.append(_name_23, " ");
+ _builder.append("], peer_addr[IFITEM_");
+ SPPRef _spp_5 = svc_1.getSpp();
+ String _name_24 = _spp_5.getName();
+ _builder.append(_name_24, " ");
+ _builder.append("]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ boolean _notEquals_1 = (!Objects.equal(ctor, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// user defined constructor body");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ DetailCode _detailCode = ctor.getDetailCode();
+ String _translatedCode = _instance.getTranslatedCode(_detailCode);
+ _builder.append(_translatedCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _or_1 = false;
+ boolean _isEmpty_4 = dynConfigReadAttributes.isEmpty();
+ boolean _not_4 = (!_isEmpty_4);
+ if (_not_4) {
+ _or_1 = true;
+ } else {
+ boolean _isEmpty_5 = dynConfigWriteAttributes.isEmpty();
+ boolean _not_5 = (!_isEmpty_5);
+ _or_1 = (_not_4 || _not_5);
+ }
+ if (_or_1) {
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_25 = ac.getName();
+ _builder.append(_name_25, " ");
+ _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr, VariableService variableService){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("this(parent, name, port_addr, peer_addr);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _isEmpty_6 = dynConfigWriteAttributes.isEmpty();
+ boolean _not_6 = (!_isEmpty_6);
+ if (_not_6) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("this.variableService = variableService;");
+ _builder.newLine();
+ }
+ }
+ {
+ for(final Attribute a_1 : dynConfigReadAttributes) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("lock_");
+ String _name_26 = a_1.getName();
+ _builder.append(_name_26, " ");
+ _builder.append(" = new DynConfigLock();");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_3 = ac.getAttributes();
+ List<Attribute> _list = IterableExtensions.<Attribute>toList(dynConfigReadAttributes);
+ List<Attribute> _minus = this.roomExt.<Attribute>minus(_attributes_3, _list);
+ String _name_27 = ac.getName();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_27);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _genDynConfigGetterSetter = this.configAddon.genDynConfigGetterSetter(ac);
+ _builder.append(_genDynConfigGetterSetter, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- port getters");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_2 : _endPorts_2) {
+ _builder.append("\t");
+ String _portClassName_6 = this.roomExt.getPortClassName(ep_2);
+ String _name_28 = ep_2.getName();
+ String _name_29 = ac.getName();
+ CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_28, _name_29);
+ _builder.append(_terImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
+ for(final SAPRef sap_2 : _strSAPs_2) {
+ _builder.append("\t");
+ String _portClassName_7 = this.roomExt.getPortClassName(sap_2);
+ String _name_30 = sap_2.getName();
+ String _name_31 = ac.getName();
+ CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_30, _name_31);
+ _builder.append(_terImplementation_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
+ _builder.append("\t");
+ String _portClassName_8 = this.roomExt.getPortClassName(svc_2);
+ SPPRef _spp_6 = svc_2.getSpp();
+ String _name_32 = _spp_6.getName();
+ String _name_33 = ac.getName();
+ CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_32, _name_33);
+ _builder.append(_terImplementation_2, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- lifecycle functions");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void init(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("initUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void start(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("startUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _overridesStop = this.roomExt.overridesStop(ac);
+ boolean _not_7 = (!_overridesStop);
+ if (_not_7) {
+ _builder.append("\t");
+ _builder.append("public void stop(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("stopUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void destroy(){");
+ _builder.newLine();
+ {
+ boolean _notEquals_2 = (!Objects.equal(dtor, null));
+ if (_notEquals_2) {
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// user defined destructor body");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ AbstractGenerator _instance_1 = AbstractGenerator.getInstance();
+ DetailCode _detailCode_1 = dtor.getDetailCode();
+ String _translatedCode_1 = _instance_1.getTranslatedCode(_detailCode_1);
+ _builder.append(_translatedCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\t");
+ CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
+ _builder.append(_genStateMachine, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _hasStateMachine = xpac.hasStateMachine();
+ boolean _not_8 = (!_hasStateMachine);
+ if (_not_8) {
+ _builder.append("\t");
+ _builder.append("//--------------------- no state machine");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("handleSystemEvent(ifitem, evt, data);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void executeInitTransition(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
new file mode 100644
index 0000000..238102d
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
@@ -0,0 +1,444 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.config.AttrClassConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.LiteralArray;
+import org.eclipse.etrice.core.config.NumberLiteral;
+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.PrimitiveType;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@SuppressWarnings("all")
+public class ConfigGenAddon {
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private TypeHelpers typeHelpers;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ConfigExtension configExt;
+
+ public CharSequence applyInstanceConfig(final String instance, final String className, final List<AttrInstanceConfig> attrConfigs) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final AttrInstanceConfig attrConfig : attrConfigs) {
+ Attribute a = attrConfig.getAttribute();
+ _builder.newLineIfNotEmpty();
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
+ if (_isPrimitive) {
+ LiteralArray _value = attrConfig.getValue();
+ String[] values = _value==null?(String[])null:this.configExt.getValues(_value);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _equals = Objects.equal(values, null);
+ if (_equals) {
+ } else {
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals_1 = (_size == 0);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
+ _or = (_equals_1 || _isCharacterType);
+ }
+ if (_or) {
+ _builder.append(instance, "");
+ _builder.append(".");
+ String _name = a.getName();
+ final String[] _converted_values = (String[])values;
+ String _get = ((List<String>)Conversions.doWrapArray(_converted_values)).get(0);
+ String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), _get);
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name, className, _valueLiteral);
+ _builder.append(_invokeSetter, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ int _size_1 = a.getSize();
+ final String[] _converted_values_1 = (String[])values;
+ int _size_2 = ((List<String>)Conversions.doWrapArray(_converted_values_1)).size();
+ boolean _equals_2 = (_size_1 == _size_2);
+ if (_equals_2) {
+ _builder.append(instance, "");
+ _builder.append(".");
+ String _name_1 = a.getName();
+ String _typeName = this.typeHelpers.typeName(aType);
+ String _plus = ("new " + _typeName);
+ String _plus_1 = (_plus + "[]");
+ String _arrayValueLiteral = this.configExt.toArrayValueLiteral(((PrimitiveType) aType), values);
+ String _plus_2 = (_plus_1 + _arrayValueLiteral);
+ CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, className, _plus_2);
+ _builder.append(_invokeSetter_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ String _typeName_1 = this.typeHelpers.typeName(aType);
+ _builder.append(_typeName_1, " ");
+ _builder.append("[] array = ");
+ _builder.append(instance, " ");
+ _builder.append(".");
+ String _name_2 = a.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name_2, className);
+ _builder.append(_invokeGetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, " ");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("array[i] = ");
+ final String[] _converted_values_2 = (String[])values;
+ String _get_1 = ((List<String>)Conversions.doWrapArray(_converted_values_2)).get(0);
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _get_1);
+ _builder.append(_valueLiteral_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ } else {
+ boolean _isDataClass = this.typeHelpers.isDataClass(aType);
+ if (_isDataClass) {
+ String _plus_3 = (instance + ".");
+ String _name_3 = a.getName();
+ CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_name_3, className);
+ String _plus_4 = (_plus_3 + _invokeGetter_1);
+ String _typeName_2 = this.typeHelpers.typeName(aType);
+ EList<AttrInstanceConfig> _attributes = attrConfig.getAttributes();
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(_plus_4, _typeName_2, _attributes);
+ _builder.append(_applyInstanceConfig, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence genDynConfigGetterSetter(final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ HashSet<Attribute> _dynConfigAttributes = this.configExt.getDynConfigAttributes(ac, true, false);
+ for(final Attribute a : _dynConfigAttributes) {
+ _builder.append("public ");
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this.typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" get");
+ String _name = a.getName();
+ String _firstUpper = StringExtensions.toFirstUpper(_name);
+ _builder.append(_firstUpper, "");
+ _builder.append("(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if(lock_");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" == null)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("synchronized(lock_");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("return ");
+ String _name_4 = a.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("public void set");
+ String _name_5 = a.getName();
+ String _firstUpper_1 = StringExtensions.toFirstUpper(_name_5);
+ _builder.append(_firstUpper_1, "");
+ _builder.append("(");
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this.typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size_1 = a.getSize();
+ boolean _greaterThan_1 = (_size_1 > 0);
+ if (_greaterThan_1) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, "");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if(lock_");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(" == null)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("this.");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(" = ");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("synchronized(lock_");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("this.");
+ String _name_11 = a.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(" = ");
+ String _name_12 = a.getName();
+ _builder.append(_name_12, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("public DynConfigLock get");
+ String _name_13 = a.getName();
+ String _firstUpper_2 = StringExtensions.toFirstUpper(_name_13);
+ _builder.append(_firstUpper_2, "");
+ _builder.append("Lock(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return lock_");
+ String _name_14 = a.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}\t");
+ _builder.newLine();
+ }
+ }
+ {
+ HashSet<Attribute> _dynConfigAttributes_1 = this.configExt.getDynConfigAttributes(ac, false, true);
+ for(final Attribute a_1 : _dynConfigAttributes_1) {
+ _builder.append("public void setAndWrite");
+ String _name_15 = a_1.getName();
+ String _firstUpper_3 = StringExtensions.toFirstUpper(_name_15);
+ _builder.append(_firstUpper_3, "");
+ _builder.append("(");
+ RefableType _refType_2 = a_1.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_2 = this.typeHelpers.typeName(_type_2);
+ _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_16 = a_1.getName();
+ _builder.append(_name_16, "");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("set");
+ String _name_17 = a_1.getName();
+ String _firstUpper_4 = StringExtensions.toFirstUpper(_name_17);
+ _builder.append(_firstUpper_4, " ");
+ _builder.append("(");
+ String _name_18 = a_1.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("variableService.write(this.getInstancePath()+\"/");
+ String _name_19 = a_1.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("\", ");
+ String _name_20 = a_1.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence genMinMaxConstants(final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ List<AttrClassConfig> _allAttrConfigFlat = this.configExt.getAllAttrConfigFlat(ac);
+ final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig c) {
+ boolean _or = false;
+ NumberLiteral _min = c.getMin();
+ boolean _notEquals = (!Objects.equal(_min, null));
+ if (_notEquals) {
+ _or = true;
+ } else {
+ NumberLiteral _max = c.getMax();
+ boolean _notEquals_1 = (!Objects.equal(_max, null));
+ _or = (_notEquals || _notEquals_1);
+ }
+ return Boolean.valueOf(_or);
+ }
+ };
+ Iterable<AttrClassConfig> attrConfigs = IterableExtensions.<AttrClassConfig>filter(_allAttrConfigFlat, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = IterableExtensions.isEmpty(attrConfigs);
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("//--------------------- attribute specifications");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final AttrClassConfig c : attrConfigs) {
+ Attribute _attribute = c.getAttribute();
+ RefableType _refType = _attribute.getRefType();
+ DataType _type = _refType.getType();
+ PrimitiveType aType = ((PrimitiveType) _type);
+ _builder.newLineIfNotEmpty();
+ {
+ NumberLiteral _min = c.getMin();
+ boolean _notEquals = (!Objects.equal(_min, null));
+ if (_notEquals) {
+ _builder.append("public static ");
+ String _minMaxType = this.getMinMaxType(aType);
+ _builder.append(_minMaxType, "");
+ _builder.append(" MIN");
+ List<String> _path = this.configExt.getPath(c, false, false, true, true);
+ String _path_1 = this.configExt.toPath(_path, "_");
+ _builder.append(_path_1, "");
+ _builder.append(" = ");
+ NumberLiteral _min_1 = c.getMin();
+ String _value = this.configExt.getValue(_min_1);
+ String _valueLiteral = this.stdExt.toValueLiteral(aType, _value);
+ _builder.append(_valueLiteral, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ NumberLiteral _max = c.getMax();
+ boolean _notEquals_1 = (!Objects.equal(_max, null));
+ if (_notEquals_1) {
+ _builder.append("public static ");
+ String _minMaxType_1 = this.getMinMaxType(aType);
+ _builder.append(_minMaxType_1, "");
+ _builder.append(" MAX");
+ List<String> _path_2 = this.configExt.getPath(c, false, false, true, true);
+ String _path_3 = this.configExt.toPath(_path_2, "_");
+ _builder.append(_path_3, "");
+ _builder.append(" = ");
+ NumberLiteral _max_1 = c.getMax();
+ String _value_1 = this.configExt.getValue(_max_1);
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, _value_1);
+ _builder.append(_valueLiteral_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String getMinMaxType(final PrimitiveType type) {
+ String _typeName = this.typeHelpers.typeName(type);
+ final String _switchValue = _typeName;
+ boolean _matched = false;
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"byte")) {
+ _matched=true;
+ return "int";
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"short")) {
+ _matched=true;
+ return "int";
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"float")) {
+ _matched=true;
+ return "double";
+ }
+ }
+ return this.typeHelpers.typeName(type);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
new file mode 100644
index 0000000..a187baa
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -0,0 +1,460 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ComplexType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
+ String _path = this._roomExtensions.getPath(dc);
+ String path = (_generationTargetPath + _path);
+ String file = this._javaExtensions.getJavaFileName(dc);
+ String _plus = ("generating DataClass implementation \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ CharSequence _generate = this.generate(root, dc);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final DataClass dc) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = dc.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(dc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<RoomModel> models = root.getReferencedModels(dc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(dc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = dc.getName();
+ _builder.append(_name_1, "");
+ {
+ DataClass _base = dc.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ _builder.append(" extends ");
+ DataClass _base_1 = dc.getBase();
+ String _name_2 = _base_1.getName();
+ _builder.append(_name_2, "");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(dc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_2 = dc.getAttributes();
+ String _name_3 = dc.getName();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<StandardOperation> _operations_1 = dc.getOperations();
+ String _name_4 = dc.getName();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations_1, _name_4);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// default constructor");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes_3, true);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(ctor, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// user defined constructor body");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = ctor.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String l : _commands) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(l, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructor using fields");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_6 = dc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(");
+ String _argList = this.argList(dc);
+ _builder.append(_argList, " ");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ {
+ DataClass _base_2 = dc.getBase();
+ boolean _notEquals_2 = (!Objects.equal(_base_2, null));
+ if (_notEquals_2) {
+ _builder.append("\t\t");
+ _builder.append("super(");
+ DataClass _base_3 = dc.getBase();
+ String _paramList = this.paramList(_base_3);
+ _builder.append(_paramList, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("super();");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ EList<Attribute> _attributes_4 = dc.getAttributes();
+ for(final Attribute a : _attributes_4) {
+ _builder.append("\t\t");
+ _builder.append("this.");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(" = ");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" deepCopy() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(" copy = new ");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ String _deepCopy = this.deepCopy(dc);
+ _builder.append(_deepCopy, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return copy;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public String paramList(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _paramList = this.paramList(_attributes);
+ String _string = _paramList.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ if (_notEquals_1) {
+ String _plus_1 = (", " + result);
+ result = _plus_1;
+ }
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence paramList(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasElements = false;
+ for(final Attribute a : attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ String _name = a.getName();
+ _builder.append(_name, "");
+ }
+ }
+ return _builder;
+ }
+
+ public String argList(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _argList = this._procedureHelpers.argList(_attributes);
+ String _string = _argList.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ if (_notEquals_1) {
+ String _plus_1 = (", " + result);
+ result = _plus_1;
+ }
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public String deepCopy(final DataClass _dc) {
+ String result = "";
+ DataClass dc = _dc;
+ boolean _notEquals = (!Objects.equal(dc, null));
+ boolean _while = _notEquals;
+ while (_while) {
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ CharSequence _deepCopy = this.deepCopy(_attributes);
+ String _string = _deepCopy.toString();
+ String _plus = (_string + result);
+ result = _plus;
+ DataClass _base = dc.getBase();
+ dc = _base;
+ }
+ boolean _notEquals_1 = (!Objects.equal(dc, null));
+ _while = _notEquals_1;
+ }
+ return result;
+ }
+
+ public CharSequence deepCopy(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Attribute a : attributes) {
+ {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof ComplexType)) {
+ _builder.append("if (");
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("!=null) {");
+ _builder.newLineIfNotEmpty();
+ {
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = ");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(".deepCopy();");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".length;i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_4 = a.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("[i] = ");
+ String _name_5 = a.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("[i].deepCopy();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ {
+ int _size_1 = a.getSize();
+ boolean _equals_1 = (_size_1 == 0);
+ if (_equals_1) {
+ _builder.append("copy.");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, "");
+ _builder.append(" = ");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("for (int i=0;i<");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, "");
+ _builder.append(".length;i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("copy.");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("[i] = ");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("[i];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 630e6b2..395be27 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -216,8 +216,7 @@ public class JavaExtensions implements ILanguageExtension {
if (!_matched) {
if (Objects.equal(_switchValue,"char")) {
_matched=true;
- String string = String.valueOf(value);
- int _length = string.length();
+ int _length = value.length();
boolean _equals = (_length == 1);
if (_equals) {
String _plus = ("\'" + value);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
new file mode 100644
index 0000000..fba8b06
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
@@ -0,0 +1,60 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.generator.generic.PrepareFileSystem;
+import org.eclipse.etrice.generator.java.gen.ActorClassGen;
+import org.eclipse.etrice.generator.java.gen.DataClassGen;
+import org.eclipse.etrice.generator.java.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.java.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.java.gen.SubSystemRunnerGen;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@Singleton
+@SuppressWarnings("all")
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _not = (!_isLibrary);
+ if (_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
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
new file mode 100644
index 0000000..7b20909
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -0,0 +1,790 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.DataClassGen;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private DataClassGen _dataClassGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
+ String _path = this._roomExtensions.getPath(pc);
+ String path = (_generationTargetPath + _path);
+ String file = this._javaExtensions.getJavaFileName(pc);
+ String _plus = ("generating ProtocolClass implementation \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ CharSequence _generate = this.generate(root, pc);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(pc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import java.util.ArrayList;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Message;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(pc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<RoomModel> models = root.getReferencedModels(pc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// message IDs");
+ _builder.newLine();
+ _builder.append("\t");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(pc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private static String messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append(" ");
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_3 = m_1.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public String getMessageString(int msg_id) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("// id out of range");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return messageStrings[msg_id];");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _portClass = this.portClass(pc, Boolean.valueOf(false));
+ _builder.append(_portClass, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _portClass_1 = this.portClass(pc, Boolean.valueOf(true));
+ _builder.append(_portClass_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence portClass(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ PortClass pclass = this._roomExtensions.getPortClass(pc, (conj).booleanValue());
+ String portClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this._roomExtensions.getPortClassName(pc, (conj).booleanValue(), true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("// port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(portClassName, "");
+ _builder.append(" extends PortBase {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(pclass, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ DetailCode _userCode = pclass.getUserCode();
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(_userCode);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("// constructors");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("this(actor, name, localId, 0, addr, peerAddress);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("DebuggingService.getInstance().addPortInstance(this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(actor, name, localId, idx, addr, peerAddress);");
+ _builder.newLine();
+ {
+ boolean _notEquals_1 = (!Objects.equal(pclass, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t");
+ EList<Attribute> _attributes = pclass.getAttributes();
+ CharSequence _attributeInitialization = this._procedureHelpers.attributeInitialization(_attributes, true);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("DebuggingService.getInstance().addPortInstance(this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receive(Message m) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("if (!(m instanceof EventMessage))");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("return;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("EventMessage msg = (EventMessage) m;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("System.out.println(\"unknown\");");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ _builder.append("\t\t\t\t");
+ _builder.append("switch (msg.getEvtId()) {");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this._roomExtensions.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler hdlr : _receiveHandlers) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ Message _msg = hdlr.getMsg();
+ String _codeName = this._roomExtensions.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("default:");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("if (msg instanceof EventWithDataMessage)");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);");
+ _builder.newLine();
+ {
+ boolean _handlesReceive_1 = this._roomExtensions.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive_1) {
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _notEquals_2 = (!Objects.equal(pclass, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ EList<Attribute> _attributes_1 = pclass.getAttributes();
+ CharSequence _attributes_2 = this._procedureHelpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// TODO JH: Avoid collision attr getters/setter <-> user operations");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes_3 = pclass.getAttributes();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_3, null);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<PortOperation> _operations = pclass.getOperations();
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// sent messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing = this._roomExtensions.getOutgoing(pc, (conj).booleanValue());
+ for(final Message m : _outgoing) {
+ _builder.append("\t");
+ CharSequence _sendMessage = this.sendMessage(m, (conj).booleanValue());
+ _builder.append(_sendMessage, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// replicated port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(replPortClassName, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private ArrayList<");
+ _builder.append(portClassName, " ");
+ _builder.append("> ports;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private int replication;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, Address[] addr,");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("Address[] peerAddress) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("replication = addr==null? 0:addr.length;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports = new ArrayList<");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append(".");
+ _builder.append(portClassName, " ");
+ _builder.append(">(replication);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("ports.add(new ");
+ _builder.append(portClassName, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int getReplication() {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return replication;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int getIndexOf(InterfaceItemBase ifitem){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return ifitem.getIdx();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append(" get(int i) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return ports.get(i);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("\t");
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this._roomExtensions.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\t");
+ CharSequence _messageSignature = this.messageSignature(m_1);
+ _builder.append(_messageSignature, " ");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("ports.get(i).");
+ CharSequence _messageCall = this.messageCall(m_1);
+ _builder.append(_messageCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this._roomExtensions.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ _builder.append("\t");
+ CharSequence _messageSignature_1 = this.messageSignature(m_2);
+ _builder.append(_messageSignature_1, " ");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("ports.get(i).");
+ CharSequence _messageCall_1 = this.messageCall(m_2);
+ _builder.append(_messageCall_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence messageSignature(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isPriv = m.isPriv();
+ if (_isPriv) {
+ _builder.append("private");
+ } else {
+ _builder.append("public");
+ }
+ }
+ _builder.append(" void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_1 = _data_2.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public CharSequence messageSignatureExplicit(final Message m) {
+ CharSequence _xblockexpression = null;
+ {
+ VarDecl _data = m.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ DataClass dc = ((DataClass) _type);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("public void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ String _argList = this._dataClassGen.argList(dc);
+ _builder.append(_argList, "");
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ if (_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public CharSequence sendMessage(final Message m, final boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ if (conj) {
+ _xifexpression = "IN";
+ } else {
+ _xifexpression = "OUT";
+ }
+ String dir = _xifexpression;
+ MessageHandler hdlr = this._roomExtensions.getSendHandler(m, conj);
+ StringConcatenation _builder = new StringConcatenation();
+ CharSequence _messageSignature = this.messageSignature(m);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(hdlr, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("if (messageStrings[ ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name = m.getName();
+ _builder.append(_name, " ");
+ _builder.append("] != \"timerTick\"){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (getPeerAddress()!=null)");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ VarDecl _data = m.getData();
+ boolean _equals = Objects.equal(_data, null);
+ if (_equals) {
+ _builder.append("getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ } else {
+ _builder.append("getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_3 = m.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(", ");
+ VarDecl _data_1 = m.getData();
+ String _name_4 = _data_1.getName();
+ _builder.append(_name_4, " ");
+ {
+ boolean _and = false;
+ VarDecl _data_2 = m.getData();
+ RefableType _refType = _data_2.getRefType();
+ boolean _isRef = _refType.isRef();
+ boolean _not = (!_isRef);
+ if (!_not) {
+ _and = false;
+ } else {
+ VarDecl _data_3 = m.getData();
+ RefableType _refType_1 = _data_3.getRefType();
+ DataType _type = _refType_1.getType();
+ boolean _not_1 = (!(_type instanceof PrimitiveType));
+ _and = (_not && _not_1);
+ }
+ if (_and) {
+ _builder.append(".deepCopy()");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _and_1 = false;
+ VarDecl _data_4 = m.getData();
+ boolean _notEquals_1 = (!Objects.equal(_data_4, null));
+ if (!_notEquals_1) {
+ _and_1 = false;
+ } else {
+ VarDecl _data_5 = m.getData();
+ RefableType _refType_2 = _data_5.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ _and_1 = (_notEquals_1 && (_type_1 instanceof DataClass));
+ }
+ if (_and_1) {
+ CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m);
+ _builder.append(_messageSignatureExplicit, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_5 = m.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("(new ");
+ VarDecl _data_6 = m.getData();
+ RefableType _refType_3 = _data_6.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ String _name_6 = _type_2.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(");
+ VarDecl _data_7 = m.getData();
+ RefableType _refType_4 = _data_7.getRefType();
+ DataType _type_3 = _refType_4.getType();
+ String _paramList = this._dataClassGen.paramList(((DataClass) _type_3));
+ _builder.append(_paramList, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
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
new file mode 100644
index 0000000..bb397d6
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
@@ -0,0 +1,81 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+
+@Singleton
+@SuppressWarnings("all")
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public CharSequence genExtra(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("// state names");
+ _builder.newLine();
+ _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
+ {
+ List<State> _allBaseStatesLeavesLast = this._roomExtensions.getAllBaseStatesLeavesLast(ac);
+ boolean _hasElements = false;
+ for(final State state : _allBaseStatesLeavesLast) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", "");
+ }
+ _builder.append("\"");
+ String _statePathName = this._roomExtensions.getStatePathName(state);
+ _builder.append(_statePathName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// history");
+ _builder.newLine();
+ _builder.append("protected int history[] = {NO_STATE,NO_STATE");
+ {
+ List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
+ for(final State state_1 : _allBaseStates) {
+ _builder.append(",NO_STATE");
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("private void setState(int new_state) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("this.state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
new file mode 100644
index 0000000..99ffe08
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
@@ -0,0 +1,151 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _plus = (_generationTargetPath + _path);
+ this.fileAccess.setOutputPath(_plus);
+ String _name = sc.getName();
+ String _plus_1 = (_name + "Runner.java");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ CharSequence _generate = this.generate(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_plus_1, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_2 = ssc.getName();
+ String _plus = (_name_2 + "Runner");
+ _builder.append(_plus, "");
+ _builder.append(" extends SubSystemRunnerBase {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("static ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" main_component = new ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(null, \"");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public static void main(String[] args) {");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"*** T H E B E G I N ***\");");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.init(); // lifecycle init");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.start(); // lifecycle start");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// application runs until quit ");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("waitForQuit();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// end the lifecycle");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.stop(); // lifecycle stop");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.destroy(); // lifecycle destroy");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"*** T H E E N D ***\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+}
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
new file mode 100644
index 0000000..bee7d72
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
@@ -0,0 +1,972 @@
+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.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.config.ActorClassConfig;
+import org.eclipse.etrice.core.config.ActorInstanceConfig;
+import org.eclipse.etrice.core.config.AttrClassConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.DynamicConfig;
+import org.eclipse.etrice.core.config.NumberLiteral;
+import org.eclipse.etrice.core.config.RefPath;
+import org.eclipse.etrice.core.config.SubSystemConfig;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.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.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class VariableServiceGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ConfigExtension configExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root, final SubSystemInstance ssi) {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String path = (_generationTargetPath + _path);
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _name = _subSystemClass_2.getName();
+ String file = (_name + "VariableService.java");
+ String _plus = ("generating VariableService implementation: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ CharSequence _generate = this.generate(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+
+ private CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ SubSystemConfig _subSystemConfig = this.configExt.getSubSystemConfig(cc);
+ final DynamicConfig dynConfig = _subSystemConfig.getDynConfig();
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(cc);
+ _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.VariableService;");
+ _builder.newLine();
+ {
+ String _userCode1 = dynConfig.getUserCode1();
+ boolean _notEquals = (!Objects.equal(_userCode1, null));
+ if (_notEquals) {
+ String _userCode1_1 = dynConfig.getUserCode1();
+ _builder.append(_userCode1_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;");
+ _builder.newLine();
+ }
+ }
+ List<ActorInstance> ais = this.dynConfigsAIs(comp);
+ _builder.newLineIfNotEmpty();
+ {
+ HashSet<RoomModel> _roomModels = this.getRoomModels(ais);
+ 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 ");
+ String _name_1 = comp.getName();
+ String _plus = (_name_1 + "VariableService");
+ _builder.append(_plus, "");
+ _builder.append(" extends VariableService{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private ");
+ String _name_2 = cc.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(" subSystem;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// Actor instances");
+ _builder.newLine();
+ {
+ for(final ActorInstance ai : ais) {
+ _builder.append("\t");
+ _builder.append("private ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" ");
+ String _path = ai.getPath();
+ String[] _split = _path.split("/");
+ Iterable<String> _drop = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split)), 2);
+ String _path_1 = this.configExt.toPath(_drop, "_");
+ _builder.append(_path_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_4 = comp.getName();
+ String _plus_1 = (_name_4 + "VariableService");
+ _builder.append(_plus_1, " ");
+ _builder.append("(");
+ String _name_5 = cc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(" subSystem) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(");
+ {
+ String _filePath = dynConfig.getFilePath();
+ boolean _notEquals_1 = (!Objects.equal(_filePath, null));
+ if (_notEquals_1) {
+ _builder.append("new ConfigSourceFile(\"");
+ String _filePath_1 = dynConfig.getFilePath();
+ _builder.append(_filePath_1, " ");
+ _builder.append("\")");
+ } else {
+ String _userCode2 = dynConfig.getUserCode2();
+ _builder.append(_userCode2, " ");
+ }
+ }
+ _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();
+ {
+ for(final ActorInstance ai_1 : ais) {
+ _builder.append("\t\t");
+ String _path_2 = ai_1.getPath();
+ String[] _split_1 = _path_2.split("/");
+ Iterable<String> _drop_1 = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split_1)), 2);
+ String _path_3 = this.configExt.toPath(_drop_1, "_");
+ _builder.append(_path_3, " ");
+ _builder.append(" = (");
+ ActorClass _actorClass_1 = ai_1.getActorClass();
+ String _name_6 = _actorClass_1.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(")subSystem.getInstance(\"");
+ String _path_4 = ai_1.getPath();
+ _builder.append(_path_4, " ");
+ _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();
+ {
+ Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(cc, true, false);
+ for(final AttrInstanceConfig attrConfig : _attrDynConfigs) {
+ _builder.append("\t\t");
+ EObject _eContainer = attrConfig.eContainer();
+ RefPath _path_5 = ((ActorInstanceConfig) _eContainer).getPath();
+ EList<String> _refs = _path_5.getRefs();
+ String aiName = this.configExt.toPath(_refs, "_");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("try{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("boolean changed = false;");
+ _builder.newLine();
+ {
+ Map<Attribute,List<String>> _allAttributes = this.getAllAttributes(attrConfig);
+ Set<Entry<Attribute,List<String>>> _entrySet = _allAttributes.entrySet();
+ for(final Entry<Attribute,List<String>> entry : _entrySet) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ Attribute a = entry.getKey();
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ List<String> _path_6 = this.configExt.getPath(attrConfig, true, true, true, false);
+ String _path_7 = this.configExt.toPath(_path_6, "/");
+ List<String> _value = entry.getValue();
+ String _path_8 = this.configExt.toPath(_value, "/");
+ String _plus_2 = (_path_7 + _path_8);
+ String _plus_3 = (_plus_2 + "/");
+ String _name_7 = a.getName();
+ String aPath = (_plus_3 + _name_7);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("id = \"");
+ _builder.append(aPath, " ");
+ _builder.append("\";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ {
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String _wrapper = this.stdExt.toWrapper(_typeName);
+ _builder.append(_wrapper, " ");
+ } else {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, " ");
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" _");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("object = values.get(id);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("if(object != null){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("_");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" = ensure");
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_2 = this._typeHelpers.typeName(_type_2);
+ String _firstUpper = StringExtensions.toFirstUpper(_typeName_2);
+ _builder.append(_firstUpper, " ");
+ {
+ 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, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ EObject _eContainer_1 = attrConfig.eContainer();
+ ActorClassConfig _actorClassConfig = this.configExt.getActorClassConfig(((ActorInstanceConfig) _eContainer_1));
+ CharSequence _genMinMaxCheck = this.genMinMaxCheck(attrConfig, _actorClassConfig);
+ _builder.append(_genMinMaxCheck, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("if(!");
+ {
+ int _size_4 = a.getSize();
+ boolean _equals_1 = (_size_4 == 0);
+ if (_equals_1) {
+ _builder.append("_");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(".equals(");
+ } else {
+ _builder.append("Arrays.equals(_");
+ String _name_11 = a.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(", ");
+ }
+ }
+ _builder.append("(");
+ {
+ int _size_5 = a.getSize();
+ boolean _equals_2 = (_size_5 == 0);
+ if (_equals_2) {
+ RefableType _refType_3 = a.getRefType();
+ DataType _type_3 = _refType_3.getType();
+ String _typeName_3 = this._typeHelpers.typeName(_type_3);
+ String _wrapper_1 = this.stdExt.toWrapper(_typeName_3);
+ _builder.append(_wrapper_1, " ");
+ } else {
+ RefableType _refType_4 = a.getRefType();
+ DataType _type_4 = _refType_4.getType();
+ String _typeName_4 = this._typeHelpers.typeName(_type_4);
+ _builder.append(_typeName_4, " ");
+ _builder.append("[]");
+ }
+ }
+ _builder.append(")getDiffMap().get(id)))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("changed = true;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("} else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("warning(id, \"is missing\");");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("if(changed)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("synchronized(");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ Attribute _attribute = attrConfig.getAttribute();
+ String _name_12 = _attribute.getName();
+ String _plus_4 = (_name_12 + "Lock");
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_plus_4, null);
+ _builder.append(_invokeGetter, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t");
+ _builder.append("if(");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ Attribute _attribute_1 = attrConfig.getAttribute();
+ String _name_13 = _attribute_1.getName();
+ String _plus_5 = (_name_13 + "Lock");
+ CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_plus_5, null);
+ _builder.append(_invokeGetter_1, " ");
+ _builder.append(".isUpdate()){");
+ _builder.newLineIfNotEmpty();
+ {
+ Map<Attribute,List<String>> _allAttributes_1 = this.getAllAttributes(attrConfig);
+ Set<Entry<Attribute,List<String>>> _entrySet_1 = _allAttributes_1.entrySet();
+ for(final Entry<Attribute,List<String>> entry_1 : _entrySet_1) {
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("if(_");
+ Attribute _key = entry_1.getKey();
+ String _name_14 = _key.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(" != null){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append(aiName, " ");
+ List<String> _value_1 = entry_1.getValue();
+ String _invoke = this.toInvoke(_value_1);
+ _builder.append(_invoke, " ");
+ _builder.append(".");
+ Attribute _key_1 = entry_1.getKey();
+ String _name_15 = _key_1.getName();
+ Attribute _key_2 = entry_1.getKey();
+ String _name_16 = _key_2.getName();
+ String _plus_6 = ("_" + _name_16);
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name_15, null, _plus_6);
+ _builder.append(_invokeSetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("getDiffMap().put(\"");
+ List<String> _path_9 = this.configExt.getPath(attrConfig, true, true, true, false);
+ String _path_10 = this.configExt.toPath(_path_9, "/");
+ List<String> _value_2 = entry_1.getValue();
+ String _path_11 = this.configExt.toPath(_value_2, "/");
+ String _plus_7 = (_path_10 + _path_11);
+ String _plus_8 = (_plus_7 + "/");
+ Attribute _key_3 = entry_1.getKey();
+ String _name_17 = _key_3.getName();
+ String _plus_9 = (_plus_8 + _name_17);
+ _builder.append(_plus_9, " ");
+ _builder.append("\", _");
+ Attribute _key_4 = entry_1.getKey();
+ String _name_18 = _key_4.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _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();
+ {
+ Iterable<AttrInstanceConfig> _attrDynConfigs_1 = this.configExt.getAttrDynConfigs(cc, true, false);
+ for(final AttrInstanceConfig attrConfig_1 : _attrDynConfigs_1) {
+ _builder.append("\t\t");
+ EObject _eContainer_2 = attrConfig_1.eContainer();
+ RefPath _path_12 = ((ActorInstanceConfig) _eContainer_2).getPath();
+ EList<String> _refs_1 = _path_12.getRefs();
+ String aiName_1 = this.configExt.toPath(_refs_1, "_");
+ _builder.newLineIfNotEmpty();
+ {
+ Map<Attribute,List<String>> _allAttributes_2 = this.getAllAttributes(attrConfig_1);
+ Set<Entry<Attribute,List<String>>> _entrySet_2 = _allAttributes_2.entrySet();
+ for(final Entry<Attribute,List<String>> entry_2 : _entrySet_2) {
+ _builder.append("\t\t");
+ Attribute _key_5 = entry_2.getKey();
+ int _size_6 = _key_5.getSize();
+ boolean array = (_size_6 > 0);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ List<String> _path_13 = this.configExt.getPath(attrConfig_1, true, true, true, false);
+ String _path_14 = this.configExt.toPath(_path_13, "/");
+ List<String> _value_3 = entry_2.getValue();
+ String _path_15 = this.configExt.toPath(_value_3, "/");
+ String _plus_10 = (_path_14 + _path_15);
+ String _plus_11 = (_plus_10 + "/");
+ Attribute _key_6 = entry_2.getKey();
+ String _name_19 = _key_6.getName();
+ String aPath_1 = (_plus_11 + _name_19);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("values.put(\"");
+ _builder.append(aPath_1, " ");
+ _builder.append("\", ");
+ {
+ if (array) {
+ _builder.append("toObjectArray(");
+ }
+ }
+ _builder.append(aiName_1, " ");
+ List<String> _value_4 = entry_2.getValue();
+ String _invoke_1 = this.toInvoke(_value_4);
+ _builder.append(_invoke_1, " ");
+ _builder.append(".");
+ Attribute _key_7 = entry_2.getKey();
+ String _name_20 = _key_7.getName();
+ CharSequence _invokeGetter_2 = this.helpers.invokeGetter(_name_20, null);
+ _builder.append(_invokeGetter_2, " ");
+ {
+ if (array) {
+ _builder.append(")");
+ }
+ }
+ _builder.append(");");
+ _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();
+ {
+ HashSet<DataClass> _dynDataClasses = this.getDynDataClasses(comp);
+ for(final DataClass dc : _dynDataClasses) {
+ _builder.append("\t\t");
+ _builder.append("if(dcObject.getClass().equals(");
+ String _typeName_5 = this._typeHelpers.typeName(dc);
+ _builder.append(_typeName_5, " ");
+ _builder.append(".class))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("writeDataClass(id, (");
+ String _typeName_6 = this._typeHelpers.typeName(dc);
+ _builder.append(_typeName_6, " ");
+ _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> _allDynDataClasses = this.getAllDynDataClasses(comp);
+ for(final DataClass dc_1 : _allDynDataClasses) {
+ _builder.append("\t");
+ _builder.append("private void writeDataClass(String id, ");
+ String _typeName_7 = this._typeHelpers.typeName(dc_1);
+ _builder.append(_typeName_7, " ");
+ _builder.append(" object, Map<String, Object> map){");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<Attribute> _attributes = dc_1.getAttributes();
+ for(final Attribute a_1 : _attributes) {
+ {
+ RefableType _refType_5 = a_1.getRefType();
+ DataType _type_5 = _refType_5.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type_5);
+ if (_isPrimitive) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("map.put(id+\"/");
+ String _name_21 = a_1.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("\", ");
+ {
+ int _size_7 = a_1.getSize();
+ boolean _greaterThan_2 = (_size_7 > 0);
+ if (_greaterThan_2) {
+ _builder.append("toObjectArray(");
+ }
+ }
+ _builder.append("object.");
+ String _name_22 = a_1.getName();
+ CharSequence _invokeGetter_3 = this.helpers.invokeGetter(_name_22, null);
+ _builder.append(_invokeGetter_3, " ");
+ {
+ int _size_8 = a_1.getSize();
+ boolean _greaterThan_3 = (_size_8 > 0);
+ if (_greaterThan_3) {
+ _builder.append(")");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("writeDataClass(id+\"/");
+ String _name_23 = a_1.getName();
+ _builder.append(_name_23, " ");
+ _builder.append("\", object.");
+ String _name_24 = a_1.getName();
+ CharSequence _invokeGetter_4 = this.helpers.invokeGetter(_name_24, null);
+ _builder.append(_invokeGetter_4, " ");
+ _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 ");
+ int _polling = dynConfig.getPolling();
+ _builder.append(_polling, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence genMinMaxCheck(final AttrInstanceConfig instConf, final ActorClassConfig acConf) {
+ CharSequence _xblockexpression = null;
+ {
+ List<String> _path = this.configExt.getPath(instConf, false, false, true, true);
+ AttrClassConfig config = acConf==null?(AttrClassConfig)null:this.resolve(acConf, ((String[])Conversions.unwrapArray(_path, String.class)));
+ boolean _and = false;
+ NumberLiteral _min = config==null?(NumberLiteral)null:config.getMin();
+ boolean _equals = Objects.equal(_min, null);
+ if (!_equals) {
+ _and = false;
+ } else {
+ NumberLiteral _max = config==null?(NumberLiteral)null:config.getMax();
+ boolean _equals_1 = Objects.equal(_max, null);
+ _and = (_equals && _equals_1);
+ }
+ if (_and) {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+ List<String> _path_1 = this.configExt.getPath(config, false, false, true, true);
+ String path = this.configExt.toPath(_path_1, "_");
+ EObject _eContainer = config.eContainer();
+ ActorClass _actor = ((ActorClassConfig) _eContainer).getActor();
+ String acName = _actor.getName();
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("checkMinMax(_");
+ Attribute _attribute = config.getAttribute();
+ String _name = _attribute.getName();
+ _builder_1.append(_name, "");
+ _builder_1.append(", ");
+ {
+ NumberLiteral _min_1 = config.getMin();
+ boolean _notEquals = (!Objects.equal(_min_1, null));
+ if (_notEquals) {
+ _builder_1.append(acName, "");
+ _builder_1.append(".MIN");
+ _builder_1.append(path, "");
+ } else {
+ _builder_1.append("null");
+ }
+ }
+ _builder_1.append(", ");
+ {
+ NumberLiteral _max_1 = config.getMax();
+ boolean _notEquals_1 = (!Objects.equal(_max_1, null));
+ if (_notEquals_1) {
+ _builder_1.append(acName, "");
+ _builder_1.append(".MAX");
+ _builder_1.append(path, "");
+ } else {
+ _builder_1.append("null");
+ }
+ }
+ _builder_1.append(");");
+ _builder_1.newLineIfNotEmpty();
+ _xblockexpression = (_builder_1);
+ }
+ return _xblockexpression;
+ }
+
+ private Map<Attribute,List<String>> getAllAttributes(final AttrInstanceConfig config) {
+ HashMap<Attribute,List<String>> _hashMap = new HashMap<Attribute,List<String>>();
+ HashMap<Attribute,List<String>> map = _hashMap;
+ Attribute _attribute = config.getAttribute();
+ RefableType _refType = _attribute.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ Attribute _attribute_1 = config.getAttribute();
+ ArrayList<String> _arrayList = new ArrayList<String>();
+ map.put(_attribute_1, _arrayList);
+ } else {
+ Attribute _attribute_2 = config.getAttribute();
+ LinkedList<String> _linkedList = new LinkedList<String>();
+ this.getAllAttributes(_attribute_2, _linkedList, map);
+ }
+ return map;
+ }
+
+ private void getAllAttributes(final Attribute attribute, final List<String> path, final Map<Attribute,List<String>> map) {
+ RefableType _refType = attribute.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ map.put(attribute, path);
+ } else {
+ RefableType _refType_1 = attribute.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type_1);
+ if (_isDataClass) {
+ ArrayList<String> _arrayList = new ArrayList<String>(path);
+ ArrayList<String> new_path = _arrayList;
+ String _name = attribute.getName();
+ new_path.add(_name);
+ RefableType _refType_2 = attribute.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(((DataClass) _type_2));
+ for (final Attribute dc : _allAttributes) {
+ this.getAllAttributes(dc, new_path, map);
+ }
+ }
+ }
+ }
+
+ private String toInvoke(final List<String> path) {
+ StringBuilder _stringBuilder = new StringBuilder();
+ StringBuilder builder = _stringBuilder;
+ for (final String p : path) {
+ CharSequence _invokeGetter = this.helpers.invokeGetter(p, null);
+ String _plus = ("." + _invokeGetter);
+ builder.append(_plus);
+ }
+ return builder.toString();
+ }
+
+ private List<ActorInstance> dynConfigsAIs(final SubSystemInstance comp) {
+ HashSet<String> _hashSet = new HashSet<String>();
+ final HashSet<String> aiPaths = _hashSet;
+ SubSystemClass _subSystemClass = comp.getSubSystemClass();
+ Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(_subSystemClass, true, false);
+ for (final AttrInstanceConfig attrConfig : _attrDynConfigs) {
+ List<String> _path = this.configExt.getPath(attrConfig, true, true, false, false);
+ String _path_1 = this.configExt.toPath(_path, "/");
+ aiPaths.add(_path_1);
+ }
+ ArrayList<ActorInstance> _arrayList = new ArrayList<ActorInstance>();
+ ArrayList<ActorInstance> ais = _arrayList;
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ for (final ActorInstance ai : _allContainedInstances) {
+ String _path_2 = ai.getPath();
+ boolean _contains = aiPaths.contains(_path_2);
+ if (_contains) {
+ ais.add(ai);
+ }
+ }
+ return ais;
+ }
+
+ private HashSet<DataClass> getDynDataClasses(final SubSystemInstance comp) {
+ HashSet<DataClass> _hashSet = new HashSet<DataClass>();
+ HashSet<DataClass> dcs = _hashSet;
+ SubSystemClass _subSystemClass = comp.getSubSystemClass();
+ Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(_subSystemClass, false, true);
+ for (final AttrInstanceConfig config : _attrDynConfigs) {
+ Attribute _attribute = config.getAttribute();
+ RefableType _refType = _attribute.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ Attribute _attribute_1 = config.getAttribute();
+ RefableType _refType_1 = _attribute_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ dcs.add(((DataClass) _type_1));
+ }
+ }
+ return dcs;
+ }
+
+ private HashSet<DataClass> getAllDynDataClasses(final SubSystemInstance comp) {
+ HashSet<DataClass> _hashSet = new HashSet<DataClass>();
+ HashSet<DataClass> dcs = _hashSet;
+ LinkedList<DataClass> _linkedList = new LinkedList<DataClass>();
+ LinkedList<DataClass> stack = _linkedList;
+ HashSet<DataClass> _dynDataClasses = this.getDynDataClasses(comp);
+ stack.addAll(_dynDataClasses);
+ Iterables.<DataClass>addAll(dcs, stack);
+ boolean _isEmpty = stack.isEmpty();
+ boolean _not = (!_isEmpty);
+ boolean _while = _not;
+ while (_while) {
+ {
+ DataClass dc = stack.pop();
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
+ for (final Attribute a : _allAttributes) {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ dcs.add(((DataClass) _type_1));
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ stack.push(((DataClass) _type_2));
+ }
+ }
+ }
+ boolean _isEmpty_1 = stack.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ _while = _not_1;
+ }
+ return dcs;
+ }
+
+ private AttrClassConfig resolve(final ActorClassConfig config, final String[] path) {
+ EList<AttrClassConfig> _attributes = config.getAttributes();
+ final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig c) {
+ Attribute _attribute = c.getAttribute();
+ String _name = _attribute.getName();
+ String _head = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(path)));
+ boolean _equals = _name.equals(_head);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ AttrClassConfig result = IterableExtensions.<AttrClassConfig>findFirst(_attributes, _function);
+ Iterable<String> _tail = IterableExtensions.<String>tail(((Iterable<String>)Conversions.doWrapArray(path)));
+ for (final String ref : _tail) {
+ {
+ EList<AttrClassConfig> _attributes_1 = result==null?(EList<AttrClassConfig>)null:result.getAttributes();
+ final Function1<AttrClassConfig,Boolean> _function_1 = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig c) {
+ Attribute _attribute = c.getAttribute();
+ String _name = _attribute.getName();
+ boolean _equals = _name.equals(ref);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ AttrClassConfig _findFirst = IterableExtensions.<AttrClassConfig>findFirst(_attributes_1, _function_1);
+ result = _findFirst;
+ boolean _equals = Objects.equal(result, null);
+ if (_equals) {
+ return null;
+ }
+ }
+ }
+ return result;
+ }
+
+ private HashSet<RoomModel> getRoomModels(final List<ActorInstance> ais) {
+ HashSet<RoomModel> _hashSet = new HashSet<RoomModel>();
+ final HashSet<RoomModel> models = _hashSet;
+ final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
+ public void apply(final ActorInstance ai) {
+ ActorClass _actorClass = ai.getActorClass();
+ EObject _eContainer = _actorClass.eContainer();
+ models.add(((RoomModel) _eContainer));
+ }
+ };
+ IterableExtensions.<ActorInstance>forEach(ais, _function);
+ return models;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java
index 05c86bc..49e7710 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java
@@ -129,7 +129,7 @@ public class ConfigHelper {
return !error;
}
- public static String toPath(List<String> path, String pathDelim) {
+ public static String toPath(Iterable<String> path, String pathDelim) {
StringBuilder b = new StringBuilder();
for (String p : path)
b.append(pathDelim + p);
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend
index 796242e..1a794cb 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend
@@ -11,226 +11,196 @@
*******************************************************************************/
-package org.eclipse.etrice.generator.generic
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
+package org.eclipse.etrice.generator.generic
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
import java.util.ArrayList
-import java.util.LinkedList
-import java.util.List
-import org.eclipse.etrice.core.config.ActorClassConfig
-import org.eclipse.etrice.core.config.ActorInstanceConfig
-import org.eclipse.etrice.core.config.AttrClassConfig
-import org.eclipse.etrice.core.config.AttrConfig
-import org.eclipse.etrice.core.config.AttrInstanceConfig
-import org.eclipse.etrice.core.config.BooleanLiteral
-import org.eclipse.etrice.core.config.IntLiteral
-import org.eclipse.etrice.core.config.Literal
-import org.eclipse.etrice.core.config.LiteralArray
-import org.eclipse.etrice.core.config.PortInstanceConfig
-import org.eclipse.etrice.core.config.ProtocolClassConfig
-import org.eclipse.etrice.core.config.RealLiteral
-import org.eclipse.etrice.core.config.StringLiteral
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
-import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.core.room.Attribute
-import org.eclipse.etrice.core.room.DataClass
-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.SubSystemClass
-import org.eclipse.etrice.generator.base.ConfigHelper
-
-@Singleton
-class ConfigExtension {
-
- @Inject ILanguageExtension languageExt
- @Inject TypeHelpers typeHelpers
- @Inject RoomExtensions roomExt
-
+import java.util.HashSet
+import java.util.LinkedList
+import java.util.List
+import org.eclipse.etrice.core.config.ActorClassConfig
+import org.eclipse.etrice.core.config.ActorInstanceConfig
+import org.eclipse.etrice.core.config.AttrClassConfig
+import org.eclipse.etrice.core.config.AttrConfig
+import org.eclipse.etrice.core.config.AttrInstanceConfig
+import org.eclipse.etrice.core.config.BooleanLiteral
+import org.eclipse.etrice.core.config.IntLiteral
+import org.eclipse.etrice.core.config.Literal
+import org.eclipse.etrice.core.config.LiteralArray
+import org.eclipse.etrice.core.config.PortInstanceConfig
+import org.eclipse.etrice.core.config.ProtocolClassConfig
+import org.eclipse.etrice.core.config.RealLiteral
+import org.eclipse.etrice.core.config.StringLiteral
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.DataClass
+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.SubSystemClass
+import org.eclipse.etrice.generator.base.ConfigHelper
+
+@Singleton
+class ConfigExtension {
+ @Inject ILanguageExtension languageExt
+ @Inject TypeHelpers typeHelpers
+ @Inject RoomExtensions roomExt
+
// language operations
- def String toArrayValueLiteral(PrimitiveType type, String[] values){
- '''«FOR v : values BEFORE '{' SEPARATOR ', ' AFTER '}'»«languageExt.toValueLiteral(type, v)»«ENDFOR»'''.toString
- }
-
+ def String toArrayValueLiteral(PrimitiveType type, String[] values){
+ '''«FOR v : values BEFORE '{' SEPARATOR ', ' AFTER '}'»«languageExt.toValueLiteral(type, v)»«ENDFOR»'''.toString
+ }
+
// ConfigHelper
- def ActorClassConfig getClassConfig(ActorClass ac){
- ConfigHelper::ac2acConfMap.get(ac)
- }
- def ProtocolClassConfig getProtocolConfig(ProtocolClass prc){
- ConfigHelper::pc2pcConfMap.get(prc);
- }
- def getSubSystemConfig(SubSystemClass ssc){
- ConfigHelper::ssc2ssConfMap.get(ssc)
- }
- def ActorClassConfig getActorClassConfig(ActorInstanceConfig ai){
- return ConfigHelper::ac2acConfMap.get(ConfigHelper::aiConf2acMap.get(ai))
- }
-
+ def ActorClassConfig getClassConfig(ActorClass ac){
+ ConfigHelper::ac2acConfMap.get(ac)
+ }
+
+ def ProtocolClassConfig getProtocolConfig(ProtocolClass prc){
+ ConfigHelper::pc2pcConfMap.get(prc);
+ }
+
+ def getSubSystemConfig(SubSystemClass ssc){
+ ConfigHelper::ssc2ssConfMap.get(ssc)
+ }
+
+ def ActorClassConfig getActorClassConfig(ActorInstanceConfig ai){
+ ConfigHelper::ac2acConfMap.get(ConfigHelper::aiConf2acMap.get(ai))
+ }
+
// config operations
- def String getInitValueLiteral(Attribute a){
- var result = a.defaultValueLiteral
+ def String getInitValueLiteral(Attribute a){
var configValues = a.configClassValues
-
- if(configValues != null && a.refType.type instanceof PrimitiveType){
- var type = a.refType.type as PrimitiveType
- if(a.size != configValues.size)
- result = languageExt.toValueLiteral(type, configValues.get(0))
- else
- result = toArrayValueLiteral(type, configValues)
+ var type = a.refType.type
+ var configValue = switch type{
+ case configValues == null:
+ null
+ PrimitiveType case a.size != configValues.size:
+ languageExt.toValueLiteral(type, configValues.get(0))
+ PrimitiveType:
+ toArrayValueLiteral(type, configValues)
}
- return result
- }
-
- def String[] getConfigClassValues(Attribute attr){
- if(attr.eContainer instanceof DataClass)
- return null;
-
- if (attr.eContainer instanceof ActorClass){
- var ac = attr.eContainer as ActorClass;
- return ac.classConfig?.attributes?.getConfigValue(attr);
- }
- else if(attr.eContainer instanceof PortClass){
- var pc = attr.eContainer as PortClass;
- var protocol = pc.eContainer as ProtocolClass
- var prcConfig = getProtocolConfig(protocol as ProtocolClass);
- if(pc.equals(protocol.regular)){
- return prcConfig?.regular?.attributes?.getConfigValue(attr);
- } else
- return prcConfig?.conjugated?.attributes?.getConfigValue(attr);
- }
- }
-
- def String[] getConfigValue(List<AttrClassConfig> attrConfigs, Attribute attr){
- attrConfigs.findFirst(attrConfig | attrConfig.attribute.equals(attr))?.value?.getValues;
- }
-
- def String[] getValues(LiteralArray literalArray){
- var values = new ArrayList<String>();
- var literals = literalArray.literals
- if(literals.get(0) instanceof StringLiteral)
- values.add(literals.get(0).value)
- else
- for(l : literalArray.literals)
- values.add(l.value)
-
- if(values.empty)
- return null
- return values
- }
-
- def String getValue(Literal literal){
- switch literal{
- BooleanLiteral:
- return String::valueOf(literal.isTrue)
- IntLiteral:
- return String::valueOf(literal.value)
- RealLiteral:
- return String::valueOf(literal.value)
- StringLiteral:
- return String::valueOf(literal.value)
- }
- return null
- }
-
- def List<AttrInstanceConfig> getConfigAttributes(ActorInstance ai){
- var attrConfigs = new ArrayList<AttrInstanceConfig>()
+ return if(configValue != null) configValue else a.defaultValueLiteral
+ }
+
+ def String[] getConfigClassValues(Attribute attr){
+ if(attr.eContainer instanceof DataClass)
+ return null
+
+ if (attr.eContainer instanceof ActorClass) {
+ var ac = attr.eContainer as ActorClass
+ return ac.classConfig?.attributes?.getConfigValue(attr)
+ } else
+ if(attr.eContainer instanceof PortClass) {
+ var pc = attr.eContainer as PortClass;
+ var protocol = pc.eContainer as ProtocolClass
+ var prcConfig = getProtocolConfig(protocol as ProtocolClass)
+ if(pc.equals(protocol.regular)) {
+ return prcConfig?.regular?.attributes?.getConfigValue(attr)
+ } else
+ return prcConfig?.conjugated?.attributes?.getConfigValue(attr)
+ }
+ }
+
+ def String[] getConfigValue(List<AttrClassConfig> attrConfigs, Attribute attr){
+ attrConfigs.findFirst(attrConfig | attrConfig.attribute.equals(attr))?.value?.getValues;
+ }
+
+ def String[] getValues(LiteralArray literalArray){
+ val result = new ArrayList<String>()
+ literalArray.literals.forEach(l | result.add(l.value))
+ return if(!result.empty) result else null
+ }
+
+ def String getValue(Literal literal){
+ return switch literal {
+ BooleanLiteral:
+ String::valueOf(literal.isTrue)
+ IntLiteral:
+ String::valueOf(literal.value)
+ RealLiteral:
+ String::valueOf(literal.value)
+ StringLiteral:
+ String::valueOf(literal.value)
+ }
+ }
+
+ def List<AttrInstanceConfig> getConfigAttributes(ActorInstance ai){
+ var config = ConfigHelper::path2aiConfMap.get(ai.path)
+ return if(config != null) config.attributes else new ArrayList<AttrInstanceConfig>()
+ }
+
+ def List<PortInstanceConfig> getConfigPorts(ActorInstance ai){
+ val result = new ArrayList<PortInstanceConfig>()
var config = ConfigHelper::path2aiConfMap.get(ai.path)
- if(config != null)
- return config.attributes
-
- return attrConfigs
- }
-
- def List<PortInstanceConfig> getConfigPorts(ActorInstance ai){
- var portConfigs = new ArrayList<PortInstanceConfig>()
- var config = ConfigHelper::path2aiConfMap.get(ai.path)
- if(config != null){
- for(portConfig : config.ports)
- portConfigs.add(portConfig)
- }
-
- return portConfigs
- }
-
- def hasVariableService(SubSystemClass ssc){
- ssc.getSubSystemConfig?.dynConfig != null
- }
-
- def List<AttrClassConfig> getAllAttrConfigFlat(ActorClass ac){
- var result = new ArrayList<AttrClassConfig>()
- if(ac.classConfig != null){
- var stack = new LinkedList<AttrClassConfig>()
- stack.addAll(ac.classConfig.attributes)
- while(!stack.empty){
- var c = stack.pop
- result.add(c)
- stack.addAll(c.attributes)
- }
- }
-
- return result
- }
-
- def List<AttrInstanceConfig> getAttrDynConfigs(SubSystemClass ssc, boolean read, boolean write){
- var configs = ConfigHelper::ssc2attrInstConfMap.get(ssc)
- val result = new ArrayList<AttrInstanceConfig>(configs.size)
- if(configs != null)
- configs.forEach(c | if((read && c.readOnly) || (write && !c.readOnly)) result.add(c))
-
- return result
- }
-
- def List<String> getPath(AttrConfig config, boolean ss, boolean actor, boolean dc, boolean attr){
- var result = new LinkedList<String>()
- var c = config
- while(c.eContainer instanceof AttrConfig){
- c = c.eContainer as AttrConfig
- if(dc)
- result.addFirst(c.attribute.name)
- }
- if(c.eContainer instanceof ActorInstanceConfig){
- var aic = c.eContainer as ActorInstanceConfig
- if(actor)
- result.addAll(0, aic.path.refs)
- if(ss)
- result.addFirst(aic.root.name)
- } else if(c.eContainer instanceof ActorClassConfig){
- var ac= c.eContainer as ActorClassConfig
- if(actor)
- result.addFirst(ac.actor.name)
- }
- if(attr)
- result.add(config.attribute.name)
-
- return result
- }
-
- def String toPath(List<String> path, String pathDelim){
- ConfigHelper::toPath(path, pathDelim)
- }
-
- def List<Attribute> getDynConfigAttributes(ActorClass ac, boolean read, boolean write){
- var attributes = new ArrayList<Attribute>()
-
- var instanceConfigs = ConfigHelper::ac2aiConfMap.get(ac)
- if(instanceConfigs != null){
- for(instanceConfig : instanceConfigs)
- for(attrConfig : instanceConfig.attributes)
- if(attrConfig.dynConfig)
- if((read && attrConfig.readOnly) || (write && !attrConfig.readOnly))
- attributes.add(attrConfig.attribute)
- }
-
- return attributes;
- }
-
-
-
-
-}
-
-
+ config?.ports?.forEach(portConf | result.add(portConf))
+ return result
+ }
+
+ def hasVariableService(SubSystemClass ssc){
+ ssc.getSubSystemConfig?.dynConfig != null
+ }
+
+ def List<AttrClassConfig> getAllAttrConfigFlat(ActorClass ac){
+ var result = new ArrayList<AttrClassConfig>()
+ if(ac.classConfig != null) {
+ var stack = new LinkedList<AttrClassConfig>()
+ stack.addAll(ac.classConfig.attributes)
+ while(!stack.empty){
+ var c = stack.pop
+ result.add(c)
+ stack.addAll(c.attributes)
+ }
+ }
+ return result
+ }
+
+ def Iterable<AttrInstanceConfig> getAttrDynConfigs(SubSystemClass ssc, boolean read, boolean write){
+ ConfigHelper::ssc2attrInstConfMap.get(ssc).filter(c |
+ c.dynConfig && ((read && c.readOnly) || (write && !c.readOnly))
+ )
+ }
+
+ def List<String> getPath(AttrConfig config, boolean ss, boolean actor, boolean dc, boolean attr){
+ var result = new LinkedList<String>()
+ var c = config
+ while(c.eContainer instanceof AttrConfig){
+ c = c.eContainer as AttrConfig
+ if(dc)
+ result.addFirst(c.attribute.name)
+ }
+ if(c.eContainer instanceof ActorInstanceConfig) {
+ var aic = c.eContainer as ActorInstanceConfig
+ if(actor)
+ result.addAll(0, aic.path.refs)
+ if(ss)
+ result.addFirst(aic.root.name)
+ } else
+ if(c.eContainer instanceof ActorClassConfig) {
+ var ac= c.eContainer as ActorClassConfig
+ if(actor)
+ result.addFirst(ac.actor.name)
+ }
+ if(attr)
+ result.add(config.attribute.name)
+ return result
+ }
+
+ def String toPath(Iterable<String> path, String pathDelim){
+ ConfigHelper::toPath(path, pathDelim)
+ }
+
+ def getDynConfigAttributes(ActorClass ac, boolean read, boolean write){
+ val result = new HashSet<Attribute>()
+ ConfigHelper::ac2aiConfMap.get(ac)?.
+ forEach(aiConf | aiConf.attributes.
+ filter(c | c.dynConfig && ((read && c.readOnly) || (write && !c.readOnly))).
+ forEach(dynConf | result.add(dynConf.attribute)))
+ return result
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
index cfc0dca..5af9d7c 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
@@ -4,6 +4,7 @@ import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
@@ -96,40 +97,57 @@ public class ConfigExtension {
public ActorClassConfig getActorClassConfig(final ActorInstanceConfig ai) {
ActorClass _get = ConfigHelper.aiConf2acMap.get(ai);
- return ConfigHelper.ac2acConfMap.get(_get);
+ ActorClassConfig _get_1 = ConfigHelper.ac2acConfMap.get(_get);
+ return _get_1;
}
public String getInitValueLiteral(final Attribute a) {
- String result = a.getDefaultValueLiteral();
String[] configValues = this.getConfigClassValues(a);
- boolean _and = false;
- boolean _notEquals = (!Objects.equal(configValues, null));
- if (!_notEquals) {
- _and = false;
- } else {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- _and = (_notEquals && (_type instanceof PrimitiveType));
+ RefableType _refType = a.getRefType();
+ DataType type = _refType.getType();
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ boolean _equals = Objects.equal(configValues, null);
+ if (_equals) {
+ _matched=true;
+ _switchResult = null;
+ }
+ }
+ if (!_matched) {
+ if (type instanceof PrimitiveType) {
+ final PrimitiveType _primitiveType = (PrimitiveType)type;
+ int _size = a.getSize();
+ final String[] _converted_configValues = (String[])configValues;
+ int _size_1 = ((List<String>)Conversions.doWrapArray(_converted_configValues)).size();
+ boolean _notEquals = (_size != _size_1);
+ if (_notEquals) {
+ _matched=true;
+ final String[] _converted_configValues_1 = (String[])configValues;
+ String _get = ((List<String>)Conversions.doWrapArray(_converted_configValues_1)).get(0);
+ String _valueLiteral = this.languageExt.toValueLiteral(_primitiveType, _get);
+ _switchResult = _valueLiteral;
+ }
+ }
}
- if (_and) {
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- PrimitiveType type = ((PrimitiveType) _type_1);
- int _size = a.getSize();
- final String[] _converted_configValues = (String[])configValues;
- int _size_1 = ((List<String>)Conversions.doWrapArray(_converted_configValues)).size();
- boolean _notEquals_1 = (_size != _size_1);
- if (_notEquals_1) {
- final String[] _converted_configValues_1 = (String[])configValues;
- String _get = ((List<String>)Conversions.doWrapArray(_converted_configValues_1)).get(0);
- String _valueLiteral = this.languageExt.toValueLiteral(type, _get);
- result = _valueLiteral;
- } else {
- String _arrayValueLiteral = this.toArrayValueLiteral(type, configValues);
- result = _arrayValueLiteral;
+ if (!_matched) {
+ if (type instanceof PrimitiveType) {
+ final PrimitiveType _primitiveType = (PrimitiveType)type;
+ _matched=true;
+ String _arrayValueLiteral = this.toArrayValueLiteral(_primitiveType, configValues);
+ _switchResult = _arrayValueLiteral;
}
}
- return result;
+ String configValue = _switchResult;
+ String _xifexpression = null;
+ boolean _notEquals = (!Objects.equal(configValue, null));
+ if (_notEquals) {
+ _xifexpression = configValue;
+ } else {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ _xifexpression = _defaultValueLiteral;
+ }
+ return _xifexpression;
}
public String[] getConfigClassValues(final Attribute attr) {
@@ -184,35 +202,36 @@ public class ConfigExtension {
public String[] getValues(final LiteralArray literalArray) {
ArrayList<String> _arrayList = new ArrayList<String>();
- ArrayList<String> values = _arrayList;
- EList<Literal> literals = literalArray.getLiterals();
- Literal _get = literals.get(0);
- if ((_get instanceof StringLiteral)) {
- Literal _get_1 = literals.get(0);
- String _value = this.getValue(_get_1);
- values.add(_value);
+ final ArrayList<String> result = _arrayList;
+ EList<Literal> _literals = literalArray.getLiterals();
+ final Procedure1<Literal> _function = new Procedure1<Literal>() {
+ public void apply(final Literal l) {
+ String _value = ConfigExtension.this.getValue(l);
+ result.add(_value);
+ }
+ };
+ IterableExtensions.<Literal>forEach(_literals, _function);
+ ArrayList<String> _xifexpression = null;
+ boolean _isEmpty = result.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _xifexpression = result;
} else {
- EList<Literal> _literals = literalArray.getLiterals();
- for (final Literal l : _literals) {
- String _value_1 = this.getValue(l);
- values.add(_value_1);
- }
+ _xifexpression = null;
}
- boolean _isEmpty = values.isEmpty();
- if (_isEmpty) {
- return null;
- }
- return ((String[])Conversions.unwrapArray(values, String.class));
+ return ((String[])Conversions.unwrapArray(_xifexpression, String.class));
}
public String getValue(final Literal literal) {
+ String _switchResult = null;
boolean _matched = false;
if (!_matched) {
if (literal instanceof BooleanLiteral) {
final BooleanLiteral _booleanLiteral = (BooleanLiteral)literal;
_matched=true;
boolean _isIsTrue = _booleanLiteral.isIsTrue();
- return String.valueOf(_isIsTrue);
+ String _valueOf = String.valueOf(_isIsTrue);
+ _switchResult = _valueOf;
}
}
if (!_matched) {
@@ -220,7 +239,8 @@ public class ConfigExtension {
final IntLiteral _intLiteral = (IntLiteral)literal;
_matched=true;
long _value = _intLiteral.getValue();
- return String.valueOf(_value);
+ String _valueOf = String.valueOf(_value);
+ _switchResult = _valueOf;
}
}
if (!_matched) {
@@ -228,7 +248,8 @@ public class ConfigExtension {
final RealLiteral _realLiteral = (RealLiteral)literal;
_matched=true;
double _value = _realLiteral.getValue();
- return String.valueOf(_value);
+ String _valueOf = String.valueOf(_value);
+ _switchResult = _valueOf;
}
}
if (!_matched) {
@@ -236,37 +257,41 @@ public class ConfigExtension {
final StringLiteral _stringLiteral = (StringLiteral)literal;
_matched=true;
String _value = _stringLiteral.getValue();
- return String.valueOf(_value);
+ String _valueOf = String.valueOf(_value);
+ _switchResult = _valueOf;
}
}
- return null;
+ return _switchResult;
}
public List<AttrInstanceConfig> getConfigAttributes(final ActorInstance ai) {
- ArrayList<AttrInstanceConfig> _arrayList = new ArrayList<AttrInstanceConfig>();
- ArrayList<AttrInstanceConfig> attrConfigs = _arrayList;
String _path = ai.getPath();
ActorInstanceConfig config = ConfigHelper.path2aiConfMap.get(_path);
+ List<AttrInstanceConfig> _xifexpression = null;
boolean _notEquals = (!Objects.equal(config, null));
if (_notEquals) {
- return config.getAttributes();
+ EList<AttrInstanceConfig> _attributes = config.getAttributes();
+ _xifexpression = _attributes;
+ } else {
+ ArrayList<AttrInstanceConfig> _arrayList = new ArrayList<AttrInstanceConfig>();
+ _xifexpression = _arrayList;
}
- return attrConfigs;
+ return _xifexpression;
}
public List<PortInstanceConfig> getConfigPorts(final ActorInstance ai) {
ArrayList<PortInstanceConfig> _arrayList = new ArrayList<PortInstanceConfig>();
- ArrayList<PortInstanceConfig> portConfigs = _arrayList;
+ final ArrayList<PortInstanceConfig> result = _arrayList;
String _path = ai.getPath();
ActorInstanceConfig config = ConfigHelper.path2aiConfMap.get(_path);
- boolean _notEquals = (!Objects.equal(config, null));
- if (_notEquals) {
- EList<PortInstanceConfig> _ports = config.getPorts();
- for (final PortInstanceConfig portConfig : _ports) {
- portConfigs.add(portConfig);
- }
- }
- return portConfigs;
+ EList<PortInstanceConfig> _ports = config==null?(EList<PortInstanceConfig>)null:config.getPorts();
+ final Procedure1<PortInstanceConfig> _function = new Procedure1<PortInstanceConfig>() {
+ public void apply(final PortInstanceConfig portConf) {
+ result.add(portConf);
+ }
+ };
+ if (_ports!=null) IterableExtensions.<PortInstanceConfig>forEach(_ports, _function);
+ return result;
}
public boolean hasVariableService(final SubSystemClass ssc) {
@@ -305,44 +330,43 @@ public class ConfigExtension {
return result;
}
- public List<AttrInstanceConfig> getAttrDynConfigs(final SubSystemClass ssc, final boolean read, final boolean write) {
- List<AttrInstanceConfig> configs = ConfigHelper.ssc2attrInstConfMap.get(ssc);
- int _size = configs.size();
- ArrayList<AttrInstanceConfig> _arrayList = new ArrayList<AttrInstanceConfig>(_size);
- final ArrayList<AttrInstanceConfig> result = _arrayList;
- boolean _notEquals = (!Objects.equal(configs, null));
- if (_notEquals) {
- final Procedure1<AttrInstanceConfig> _function = new Procedure1<AttrInstanceConfig>() {
- public void apply(final AttrInstanceConfig c) {
+ public Iterable<AttrInstanceConfig> getAttrDynConfigs(final SubSystemClass ssc, final boolean read, final boolean write) {
+ List<AttrInstanceConfig> _get = ConfigHelper.ssc2attrInstConfMap.get(ssc);
+ final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
+ public Boolean apply(final AttrInstanceConfig c) {
+ boolean _and = false;
+ boolean _isDynConfig = c.isDynConfig();
+ if (!_isDynConfig) {
+ _and = false;
+ } else {
boolean _or = false;
- boolean _and = false;
+ boolean _and_1 = false;
if (!read) {
- _and = false;
+ _and_1 = false;
} else {
boolean _isReadOnly = c.isReadOnly();
- _and = (read && _isReadOnly);
+ _and_1 = (read && _isReadOnly);
}
- if (_and) {
+ if (_and_1) {
_or = true;
} else {
- boolean _and_1 = false;
+ boolean _and_2 = false;
if (!write) {
- _and_1 = false;
+ _and_2 = false;
} else {
boolean _isReadOnly_1 = c.isReadOnly();
boolean _not = (!_isReadOnly_1);
- _and_1 = (write && _not);
+ _and_2 = (write && _not);
}
- _or = (_and || _and_1);
- }
- if (_or) {
- result.add(c);
+ _or = (_and_1 || _and_2);
}
+ _and = (_isDynConfig && _or);
}
- };
- IterableExtensions.<AttrInstanceConfig>forEach(configs, _function);
- }
- return result;
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<AttrInstanceConfig> _filter = IterableExtensions.<AttrInstanceConfig>filter(_get, _function);
+ return _filter;
}
public List<String> getPath(final AttrConfig config, final boolean ss, final boolean actor, final boolean dc, final boolean attr) {
@@ -398,51 +422,62 @@ public class ConfigExtension {
return result;
}
- public String toPath(final List<String> path, final String pathDelim) {
+ public String toPath(final Iterable<String> path, final String pathDelim) {
String _path = ConfigHelper.toPath(path, pathDelim);
return _path;
}
- public List<Attribute> getDynConfigAttributes(final ActorClass ac, final boolean read, final boolean write) {
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- ArrayList<Attribute> attributes = _arrayList;
- List<ActorInstanceConfig> instanceConfigs = ConfigHelper.ac2aiConfMap.get(ac);
- boolean _notEquals = (!Objects.equal(instanceConfigs, null));
- if (_notEquals) {
- for (final ActorInstanceConfig instanceConfig : instanceConfigs) {
- EList<AttrInstanceConfig> _attributes = instanceConfig.getAttributes();
- for (final AttrInstanceConfig attrConfig : _attributes) {
- boolean _isDynConfig = attrConfig.isDynConfig();
- if (_isDynConfig) {
- boolean _or = false;
- boolean _and = false;
- if (!read) {
- _and = false;
- } else {
- boolean _isReadOnly = attrConfig.isReadOnly();
- _and = (read && _isReadOnly);
- }
- if (_and) {
- _or = true;
- } else {
- boolean _and_1 = false;
- if (!write) {
- _and_1 = false;
- } else {
- boolean _isReadOnly_1 = attrConfig.isReadOnly();
- boolean _not = (!_isReadOnly_1);
- _and_1 = (write && _not);
+ public HashSet<Attribute> getDynConfigAttributes(final ActorClass ac, final boolean read, final boolean write) {
+ HashSet<Attribute> _hashSet = new HashSet<Attribute>();
+ final HashSet<Attribute> result = _hashSet;
+ List<ActorInstanceConfig> _get = ConfigHelper.ac2aiConfMap.get(ac);
+ final Procedure1<ActorInstanceConfig> _function = new Procedure1<ActorInstanceConfig>() {
+ public void apply(final ActorInstanceConfig aiConf) {
+ EList<AttrInstanceConfig> _attributes = aiConf.getAttributes();
+ final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
+ public Boolean apply(final AttrInstanceConfig c) {
+ boolean _and = false;
+ boolean _isDynConfig = c.isDynConfig();
+ if (!_isDynConfig) {
+ _and = false;
+ } else {
+ boolean _or = false;
+ boolean _and_1 = false;
+ if (!read) {
+ _and_1 = false;
+ } else {
+ boolean _isReadOnly = c.isReadOnly();
+ _and_1 = (read && _isReadOnly);
+ }
+ if (_and_1) {
+ _or = true;
+ } else {
+ boolean _and_2 = false;
+ if (!write) {
+ _and_2 = false;
+ } else {
+ boolean _isReadOnly_1 = c.isReadOnly();
+ boolean _not = (!_isReadOnly_1);
+ _and_2 = (write && _not);
+ }
+ _or = (_and_1 || _and_2);
+ }
+ _and = (_isDynConfig && _or);
+ }
+ return Boolean.valueOf(_and);
}
- _or = (_and || _and_1);
- }
- if (_or) {
- Attribute _attribute = attrConfig.getAttribute();
- attributes.add(_attribute);
- }
- }
+ };
+ Iterable<AttrInstanceConfig> _filter = IterableExtensions.<AttrInstanceConfig>filter(_attributes, _function);
+ final Procedure1<AttrInstanceConfig> _function_1 = new Procedure1<AttrInstanceConfig>() {
+ public void apply(final AttrInstanceConfig dynConf) {
+ Attribute _attribute = dynConf.getAttribute();
+ result.add(_attribute);
+ }
+ };
+ IterableExtensions.<AttrInstanceConfig>forEach(_filter, _function_1);
}
- }
- }
- return attributes;
+ };
+ if (_get!=null) IterableExtensions.<ActorInstanceConfig>forEach(_get, _function);
+ return result;
}
}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
new file mode 100644
index 0000000..fb9ff20
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
@@ -0,0 +1,90 @@
+package org.eclipse.etrice.generator.generic;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+
+@SuppressWarnings("all")
+public class GenericActorClassGenerator {
+ @Inject
+ private ILanguageExtension langExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public String genInterfaceItemConstants(final ExpandedActorClass xpac, final ActorClass ac) {
+ List<Port> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ List<Port> _endPorts = this.roomExt.getEndPorts(ac);
+ _xifexpression = _endPorts;
+ } else {
+ List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
+ _xifexpression = _allEndPorts;
+ }
+ List<Port> endPorts = _xifexpression;
+ List<SAPRef> _xifexpression_1 = null;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ _xifexpression_1 = _strSAPs;
+ } else {
+ List<SAPRef> _allSAPs = this.roomExt.getAllSAPs(ac);
+ _xifexpression_1 = _allSAPs;
+ }
+ List<SAPRef> strSAPs = _xifexpression_1;
+ List<ServiceImplementation> _xifexpression_2 = null;
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ if (_usesInheritance_2) {
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ _xifexpression_2 = _serviceImplementations;
+ } else {
+ List<ServiceImplementation> _allServiceImplementations = this.roomExt.getAllServiceImplementations(ac);
+ _xifexpression_2 = _allServiceImplementations;
+ }
+ List<ServiceImplementation> svcImpls = _xifexpression_2;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ for (final Port ep : endPorts) {
+ String _name = ep.getName();
+ String _plus = ("IFITEM_" + _name);
+ int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep);
+ int _plus_1 = (1 + _interfaceItemLocalId);
+ String _string = Integer.valueOf(_plus_1).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_plus, _string);
+ list.add(_pair);
+ }
+ for (final SAPRef sap : strSAPs) {
+ String _name_1 = sap.getName();
+ String _plus_2 = ("IFITEM_" + _name_1);
+ int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap);
+ int _plus_3 = (1 + _interfaceItemLocalId_1);
+ String _string_1 = Integer.valueOf(_plus_3).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_plus_2, _string_1);
+ list.add(_pair_1);
+ }
+ for (final ServiceImplementation svc : svcImpls) {
+ SPPRef _spp = svc.getSpp();
+ String _name_2 = _spp.getName();
+ String _plus_4 = ("IFITEM_" + _name_2);
+ SPPRef _spp_1 = svc.getSpp();
+ int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_1);
+ int _plus_5 = (1 + _interfaceItemLocalId_2);
+ String _string_2 = Integer.valueOf(_plus_5).toString();
+ Pair<String,String> _pair_2 = Tuples.<String, String>pair(_plus_4, _string_2);
+ list.add(_pair_2);
+ }
+ return this.langExt.genEnumeration("interface_items", list);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
new file mode 100644
index 0000000..66a2003
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
@@ -0,0 +1,119 @@
+package org.eclipse.etrice.generator.generic;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+
+@SuppressWarnings("all")
+public class GenericProtocolClassGenerator {
+ @Inject
+ private ILanguageExtension langExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public String genMessageIDs(final ProtocolClass pc) {
+ int offset = 0;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ String _name = pc.getName();
+ String _memberInDeclaration = this.langExt.memberInDeclaration(_name, "MSG_MIN");
+ String _string = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_memberInDeclaration, _string);
+ list.add(_pair);
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for (final Message msg : _allOutgoingMessages) {
+ {
+ int _plus = (offset + 1);
+ offset = _plus;
+ String _name_1 = pc.getName();
+ String _name_2 = msg.getName();
+ String _plus_1 = ("OUT_" + _name_2);
+ String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _plus_1);
+ String _string_1 = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
+ list.add(_pair_1);
+ }
+ }
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for (final Message msg_1 : _allIncomingMessages) {
+ {
+ int _plus = (offset + 1);
+ offset = _plus;
+ String _name_1 = pc.getName();
+ String _name_2 = msg_1.getName();
+ String _plus_1 = ("IN_" + _name_2);
+ String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, _plus_1);
+ String _string_1 = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
+ list.add(_pair_1);
+ }
+ }
+ int _plus = (offset + 1);
+ offset = _plus;
+ String _name_1 = pc.getName();
+ String _memberInDeclaration_1 = this.langExt.memberInDeclaration(_name_1, "MSG_MAX");
+ String _string_1 = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_memberInDeclaration_1, _string_1);
+ list.add(_pair_1);
+ String _name_2 = pc.getName();
+ String _memberInDeclaration_2 = this.langExt.memberInDeclaration(_name_2, "msg_ids");
+ return this.langExt.genEnumeration(_memberInDeclaration_2, list);
+ }
+
+ public String getMessageID(final MessageFromIf mif) {
+ Message _message = mif.getMessage();
+ InterfaceItem _from = mif.getFrom();
+ return this.getMessageID(_message, _from);
+ }
+
+ public String getMessageID(final Message msg, final InterfaceItem item) {
+ if ((item instanceof Port)) {
+ Port p = ((Port) item);
+ String _xifexpression = null;
+ boolean _isConjugated = p.isConjugated();
+ if (_isConjugated) {
+ _xifexpression = "OUT_";
+ } else {
+ _xifexpression = "IN_";
+ }
+ String direction = _xifexpression;
+ GeneralProtocolClass _protocol = p.getProtocol();
+ String _name = _protocol.getName();
+ String _name_1 = msg.getName();
+ String _plus = (direction + _name_1);
+ return this.langExt.memberInUse(_name, _plus);
+ } else {
+ if ((item instanceof SAPRef)) {
+ SAPRef sap = ((SAPRef) item);
+ ProtocolClass _protocol_1 = sap.getProtocol();
+ String _name_2 = _protocol_1.getName();
+ String _name_3 = msg.getName();
+ String _plus_1 = ("OUT_" + _name_3);
+ return this.langExt.memberInUse(_name_2, _plus_1);
+ } else {
+ if ((item instanceof SPPRef)) {
+ SPPRef spp = ((SPPRef) item);
+ ProtocolClass _protocol_2 = spp.getProtocol();
+ String _name_4 = _protocol_2.getName();
+ String _name_5 = msg.getName();
+ String _plus_2 = ("IN_" + _name_5);
+ return this.langExt.memberInUse(_name_4, _plus_2);
+ }
+ }
+ }
+ return "unknown interface item";
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
new file mode 100644
index 0000000..37a70ec
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
@@ -0,0 +1,1392 @@
+package org.eclipse.etrice.generator.generic;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.genmodel.etricegen.ActiveTrigger;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedRefinedState;
+import org.eclipse.etrice.core.genmodel.etricegen.TransitionChain;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Guard;
+import org.eclipse.etrice.core.room.GuardedTransition;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.NonInitialTransition;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.Transition;
+import org.eclipse.etrice.core.room.Trigger;
+import org.eclipse.etrice.core.room.TriggeredTransition;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.base.CodegenHelpers;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@SuppressWarnings("all")
+public class GenericStateMachineGenerator {
+ @Inject
+ protected ILanguageExtension langExt;
+
+ @Inject
+ protected RoomExtensions _roomExtensions;
+
+ @Inject
+ protected GenericProtocolClassGenerator pcGen;
+
+ @Inject
+ protected AbstractTransitionChainGenerator languageGen;
+
+ private String genStateIdConstants(final ExpandedActorClass xpac) {
+ final ActorClass ac = xpac.getActorClass();
+ int _xifexpression = (int) 0;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ int _numberOfInheritedBaseStates = this._roomExtensions.getNumberOfInheritedBaseStates(ac);
+ _xifexpression = _numberOfInheritedBaseStates;
+ } else {
+ _xifexpression = 0;
+ }
+ int offset = (2 + _xifexpression);
+ List<State> _xifexpression_1 = null;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ StateGraph _stateMachine = ac.getStateMachine();
+ List<State> _baseStateList = this._roomExtensions.getBaseStateList(_stateMachine);
+ _xifexpression_1 = _baseStateList;
+ } else {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this._roomExtensions.getBaseStateList(_stateMachine_1);
+ _xifexpression_1 = _baseStateList_1;
+ }
+ List<State> baseStates = _xifexpression_1;
+ ArrayList<State> _leafStatesLast = this._roomExtensions.getLeafStatesLast(baseStates);
+ baseStates = _leafStatesLast;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ boolean _not = (!_usesInheritance_2);
+ if (_not) {
+ Pair<String,String> _pair = Tuples.<String, String>pair("NO_STATE", "0");
+ list.add(_pair);
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair("STATE_TOP", "1");
+ list.add(_pair_1);
+ }
+ for (final State state : baseStates) {
+ {
+ String _stateId = this._roomExtensions.getStateId(state);
+ String _string = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair_2 = Tuples.<String, String>pair(_stateId, _string);
+ list.add(_pair_2);
+ int _plus = (offset + 1);
+ offset = _plus;
+ }
+ }
+ return this.langExt.genEnumeration("state_ids", list);
+ }
+
+ private String genTransitionChainConstants(final ExpandedActorClass xpac) {
+ final ActorClass ac = xpac.getActorClass();
+ EList<TransitionChain> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
+ _xifexpression = _ownTransitionChains;
+ } else {
+ EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
+ _xifexpression = _transitionChains;
+ }
+ EList<TransitionChain> chains = _xifexpression;
+ int _xifexpression_1 = (int) 0;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
+ int _size = _transitionChains_1.size();
+ int _size_1 = chains.size();
+ int _minus = (_size - _size_1);
+ _xifexpression_1 = _minus;
+ } else {
+ _xifexpression_1 = 0;
+ }
+ int offset = _xifexpression_1;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ ArrayList<Pair<String,String>> list = _arrayList;
+ for (final TransitionChain chain : chains) {
+ {
+ int _plus = (offset + 1);
+ offset = _plus;
+ String _chainId = this._roomExtensions.getChainId(chain);
+ String _string = Integer.valueOf(offset).toString();
+ Pair<String,String> _pair = Tuples.<String, String>pair(_chainId, _string);
+ list.add(_pair);
+ }
+ }
+ return this.langExt.genEnumeration("chain_ids", list);
+ }
+
+ private String genTriggerConstants(final ExpandedActorClass xpac) {
+ final ActorClass ac = xpac.getActorClass();
+ EList<MessageFromIf> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
+ _xifexpression = _ownTriggers;
+ } else {
+ EList<MessageFromIf> _triggers = xpac.getTriggers();
+ _xifexpression = _triggers;
+ }
+ final EList<MessageFromIf> triggers = _xifexpression;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ final ArrayList<Pair<String,String>> list = _arrayList;
+ Pair<String,String> _pair = Tuples.<String, String>pair("POLLING", "0");
+ list.add(_pair);
+ for (final MessageFromIf mif : triggers) {
+ String _triggerCodeName = xpac.getTriggerCodeName(mif);
+ InterfaceItem _from = mif.getFrom();
+ String _name = _from.getName();
+ String _plus = ("IFITEM_" + _name);
+ String _plus_1 = (_plus + " + EVT_SHIFT*");
+ String _messageID = this.pcGen.getMessageID(mif);
+ String _plus_2 = (_plus_1 + _messageID);
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_triggerCodeName, _plus_2);
+ list.add(_pair_1);
+ }
+ return this.langExt.genEnumeration("triggers", list);
+ }
+
+ public CharSequence genStateMachine(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ ActorCommunicationType _commType = ac.getCommType();
+ final boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ ActorCommunicationType _commType_1 = ac.getCommType();
+ final boolean eventDriven = Objects.equal(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ ActorCommunicationType _commType_2 = ac.getCommType();
+ final boolean dataDriven = Objects.equal(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ boolean _or = false;
+ if (async) {
+ _or = true;
+ } else {
+ _or = (async || eventDriven);
+ }
+ final boolean handleEvents = _or;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* state IDs */");
+ _builder.newLine();
+ String _genStateIdConstants = this.genStateIdConstants(xpac);
+ _builder.append(_genStateIdConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* transition chains */");
+ _builder.newLine();
+ String _genTransitionChainConstants = this.genTransitionChainConstants(xpac);
+ _builder.append(_genTransitionChainConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* triggers */");
+ _builder.newLine();
+ String _genTriggerConstants = this.genTriggerConstants(xpac);
+ _builder.append(_genTriggerConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ CharSequence _genExtra = this.genExtra(xpac);
+ _builder.append(_genExtra, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* Entry and Exit Codes */");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ List<State> _stateList = this._roomExtensions.getStateList(_stateMachine);
+ for(final State state : _stateList) {
+ {
+ boolean _or_1 = false;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ boolean _not = (!_usesInheritance);
+ if (_not) {
+ _or_1 = true;
+ } else {
+ boolean _isOwnObject = xpac.isOwnObject(state);
+ _or_1 = (_not || _isOwnObject);
+ }
+ if (_or_1) {
+ CharSequence _genActionCodeMethods = this.genActionCodeMethods(xpac, state);
+ _builder.append(_genActionCodeMethods, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* Action Codes */");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<Transition> _transitionList = this._roomExtensions.getTransitionList(_stateMachine_1);
+ for(final Transition tr : _transitionList) {
+ {
+ boolean _and = false;
+ boolean _or_2 = false;
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ boolean _not_1 = (!_usesInheritance_1);
+ if (_not_1) {
+ _or_2 = true;
+ } else {
+ boolean _isOwnObject_1 = xpac.isOwnObject(tr);
+ _or_2 = (_not_1 || _isOwnObject_1);
+ }
+ if (!_or_2) {
+ _and = false;
+ } else {
+ boolean _hasActionCode = this._roomExtensions.hasActionCode(tr);
+ _and = (_or_2 && _hasActionCode);
+ }
+ if (_and) {
+ TransitionChain _chain = xpac.getChain(tr);
+ Transition start = _chain.getTransition();
+ _builder.newLineIfNotEmpty();
+ boolean _and_1 = false;
+ if (!(start instanceof NonInitialTransition)) {
+ _and_1 = false;
+ } else {
+ boolean _not_2 = (!(start instanceof GuardedTransition));
+ _and_1 = ((start instanceof NonInitialTransition) && _not_2);
+ }
+ boolean hasArgs = _and_1;
+ _builder.newLineIfNotEmpty();
+ String _accessLevelProtected = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ _builder.append("void ");
+ String _actionCodeOperationName = CodegenHelpers.getActionCodeOperationName(tr);
+ _builder.append(_actionCodeOperationName, "");
+ _builder.append("(");
+ String _name = ac.getName();
+ String _selfPointer = this.langExt.selfPointer(_name, hasArgs);
+ _builder.append(_selfPointer, "");
+ {
+ if (hasArgs) {
+ _builder.append("InterfaceItemBase ifitem");
+ String _generateArgumentList = this.languageGen.generateArgumentList(xpac, tr);
+ _builder.append(_generateArgumentList, "");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ DetailCode _action = tr.getAction();
+ String _translatedCode = _instance.getTranslatedCode(_action);
+ _builder.append(_translatedCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls exit codes while exiting from the current state to one of its");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* parent states while remembering the history");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param current - the current state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param to - the final parent state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void exitTo(");
+ String _name_1 = ac.getName();
+ String _selfPointer_1 = this.langExt.selfPointer(_name_1, true);
+ _builder.append(_selfPointer_1, "");
+ _builder.append("int current, int to, boolean handler) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("while (current!=to) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (current) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ List<State> _baseStateList = this._roomExtensions.getBaseStateList(_stateMachine_2);
+ for(final State state_1 : _baseStateList) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId = this._roomExtensions.getStateId(state_1);
+ _builder.append(_stateId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasExitCode = this._roomExtensions.hasExitCode(state_1);
+ if (_hasExitCode) {
+ _builder.append("if (!handler) ");
+ String _exitCodeOperationName = CodegenHelpers.getExitCodeOperationName(state_1);
+ _builder.append(_exitCodeOperationName, " ");
+ _builder.append("(");
+ String _selfPointer_2 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_2, " ");
+ _builder.append(");");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ String _memberAccess = this.langExt.memberAccess();
+ _builder.append(_memberAccess, " ");
+ _builder.append("history[");
+ String _parentStateId = CodegenHelpers.getParentStateId(state_1);
+ _builder.append(_parentStateId, " ");
+ _builder.append("] = ");
+ String _stateId_1 = this._roomExtensions.getStateId(state_1);
+ _builder.append(_stateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("current = ");
+ String _parentStateId_1 = CodegenHelpers.getParentStateId(state_1);
+ _builder.append(_parentStateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param chain - the chain ID");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param generic_data - the generic data pointer");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return the ID of the final state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_1, "");
+ _builder.append("int executeTransitionChain(");
+ String _name_2 = ac.getName();
+ String _selfPointer_3 = this.langExt.selfPointer(_name_2, true);
+ _builder.append(_selfPointer_3, "");
+ _builder.append("int chain");
+ {
+ if (handleEvents) {
+ _builder.append(", InterfaceItemBase ifitem, ");
+ String _voidPointer = this.langExt.voidPointer();
+ _builder.append(_voidPointer, "");
+ _builder.append(" generic_data");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("switch (chain) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<TransitionChain> allchains = xpac.getTransitionChains();
+ _builder.newLineIfNotEmpty();
+ {
+ for(final TransitionChain tc : allchains) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ String _chainId = this._roomExtensions.getChainId(tc);
+ _builder.append(_chainId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String _generateExecuteChain = this.languageGen.generateExecuteChain(xpac, tc);
+ _builder.append(_generateExecuteChain, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return NO_STATE;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param state - the state which is entered");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry code is executed if not handler");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return - the ID of the final leaf state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate_2 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_2, "");
+ _builder.append("int enterHistory(");
+ String _name_3 = ac.getName();
+ String _selfPointer_4 = this.langExt.selfPointer(_name_3, true);
+ _builder.append(_selfPointer_4, "");
+ _builder.append("int state, boolean handler, boolean skip_entry) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("while (");
+ String _booleanConstant = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant, " ");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_3 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this._roomExtensions.getBaseStateList(_stateMachine_3);
+ for(final State state_2 : _baseStateList_1) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_2 = this._roomExtensions.getStateId(state_2);
+ _builder.append(_stateId_2, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasEntryCode = this._roomExtensions.hasEntryCode(state_2);
+ if (_hasEntryCode) {
+ _builder.append("if (!(skip_entry || handler)) ");
+ String _entryCodeOperationName = CodegenHelpers.getEntryCodeOperationName(state_2);
+ _builder.append(_entryCodeOperationName, " ");
+ _builder.append("(");
+ String _selfPointer_5 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_5, " ");
+ _builder.append(");");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isLeaf = this._roomExtensions.isLeaf(state_2);
+ if (_isLeaf) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// in leaf state: return state id");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("return ");
+ String _stateId_3 = this._roomExtensions.getStateId(state_2);
+ _builder.append(_stateId_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// state has a sub graph");
+ _builder.newLine();
+ {
+ StateGraph _subgraph = state_2.getSubgraph();
+ boolean _hasInitTransition = this._roomExtensions.hasInitTransition(_subgraph);
+ if (_hasInitTransition) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// with init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("if (");
+ String _memberAccess_1 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_1, " ");
+ _builder.append("history[");
+ String _stateId_4 = this._roomExtensions.getStateId(state_2);
+ _builder.append(_stateId_4, " ");
+ _builder.append("]==NO_STATE) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StateGraph _subgraph_1 = state_2.getSubgraph();
+ Transition sub_initt = this._roomExtensions.getInitTransition(_subgraph_1);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = executeTransitionChain(");
+ String _selfPointer_6 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_6, " ");
+ TransitionChain _chain_1 = xpac.getChain(sub_initt);
+ String _chainId_1 = this._roomExtensions.getChainId(_chain_1);
+ _builder.append(_chainId_1, " ");
+ {
+ if (handleEvents) {
+ _builder.append(", ");
+ String _nullPointer = this.langExt.nullPointer();
+ _builder.append(_nullPointer, " ");
+ _builder.append(", ");
+ String _nullPointer_1 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_1, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = ");
+ String _memberAccess_2 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_2, " ");
+ _builder.append("history[");
+ String _stateId_5 = this._roomExtensions.getStateId(state_2);
+ _builder.append(_stateId_5, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// without init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("state = ");
+ String _memberAccess_3 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_3, " ");
+ _builder.append("history[");
+ String _stateId_6 = this._roomExtensions.getStateId(state_2);
+ _builder.append(_stateId_6, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("case STATE_TOP:");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("state = ");
+ String _memberAccess_4 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_4, " ");
+ _builder.append("history[STATE_TOP];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("skip_entry = ");
+ String _booleanConstant_1 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ if (_usesInheritance_2) {
+ String _accessLevelPublic = this.langExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic, "");
+ } else {
+ String _accessLevelPrivate_3 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_3, "");
+ }
+ }
+ _builder.append("void executeInitTransition(");
+ String _name_4 = ac.getName();
+ String _selfPointer_7 = this.langExt.selfPointer(_name_4, false);
+ _builder.append(_selfPointer_7, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ StateGraph _stateMachine_4 = xpac.getStateMachine();
+ Transition initt = this._roomExtensions.getInitTransition(_stateMachine_4);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int chain = ");
+ TransitionChain _chain_2 = xpac.getChain(initt);
+ String _chainId_2 = this._roomExtensions.getChainId(_chain_2);
+ _builder.append(_chainId_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int next = executeTransitionChain(");
+ String _selfPointer_8 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_8, " ");
+ _builder.append("chain");
+ {
+ if (handleEvents) {
+ _builder.append(", ");
+ String _nullPointer_2 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_2, " ");
+ _builder.append(", ");
+ String _nullPointer_3 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_3, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("next = enterHistory(");
+ String _selfPointer_9 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_9, " ");
+ _builder.append("next, ");
+ String _booleanConstant_2 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_2, " ");
+ _builder.append(", ");
+ String _booleanConstant_3 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_3, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("setState(");
+ String _selfPointer_10 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_10, " ");
+ _builder.append("next);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* receiveEvent contains the main implementation of the FSM */");
+ _builder.newLine();
+ {
+ boolean _usesInheritance_3 = this.langExt.usesInheritance();
+ if (_usesInheritance_3) {
+ String _accessLevelPublic_1 = this.langExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic_1, "");
+ } else {
+ String _accessLevelPrivate_4 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_4, "");
+ }
+ }
+ _builder.append("void receiveEvent(");
+ String _name_5 = ac.getName();
+ String _selfPointer_11 = this.langExt.selfPointer(_name_5, handleEvents);
+ _builder.append(_selfPointer_11, "");
+ {
+ if (handleEvents) {
+ _builder.append("InterfaceItemBase ifitem, int evt, ");
+ String _voidPointer_1 = this.langExt.voidPointer();
+ _builder.append(_voidPointer_1, "");
+ _builder.append(" generic_data");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ {
+ if (async) {
+ _builder.append("\t");
+ _builder.append("int trigger = (ifitem==");
+ String _nullPointer_4 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_4, " ");
+ _builder.append(")? POLLING : ");
+ {
+ boolean _usesInheritance_4 = this.langExt.usesInheritance();
+ if (_usesInheritance_4) {
+ _builder.append("ifitem.getLocalId()");
+ } else {
+ _builder.append("ifitem->localId");
+ }
+ }
+ _builder.append(" + EVT_SHIFT*evt;");
+ _builder.newLineIfNotEmpty();
+ } else {
+ if (eventDriven) {
+ _builder.append("\t");
+ _builder.append("int trigger = ");
+ {
+ boolean _usesInheritance_5 = this.langExt.usesInheritance();
+ if (_usesInheritance_5) {
+ _builder.append("ifitem.getLocalId()");
+ } else {
+ _builder.append("ifitem->localId");
+ }
+ }
+ _builder.append(" + EVT_SHIFT*evt;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("int chain = NOT_CAUGHT;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int catching_state = NO_STATE;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean is_handler = ");
+ String _booleanConstant_4 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_4, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("boolean skip_entry = ");
+ String _booleanConstant_5 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_5, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if (handleEvents) {
+ _builder.append("\t");
+ _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genStateSwitch = this.genStateSwitch(xpac);
+ _builder.append(_genStateSwitch, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ CharSequence _genStateSwitch_1 = this.genStateSwitch(xpac);
+ _builder.append(_genStateSwitch_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("if (chain != NOT_CAUGHT) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("exitTo(");
+ String _selfPointer_12 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_12, " ");
+ String _memberAccess_5 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_5, " ");
+ _builder.append("state, catching_state, is_handler);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("int next = executeTransitionChain(");
+ String _selfPointer_13 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_13, " ");
+ _builder.append("chain");
+ {
+ if (handleEvents) {
+ _builder.append(", ifitem, generic_data");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("next = enterHistory(");
+ String _selfPointer_14 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_14, " ");
+ _builder.append("next, is_handler, skip_entry);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("setState(");
+ String _selfPointer_15 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_15, " ");
+ _builder.append("next);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.append("// END of generated code for FSM");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genStateSwitch(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ ActorCommunicationType _commType = _actorClass.getCommType();
+ boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ ActorCommunicationType _commType_1 = _actorClass_1.getCommType();
+ boolean eventDriven = Objects.equal(_commType_1, ActorCommunicationType.EVENT_DRIVEN);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ ActorCommunicationType _commType_2 = _actorClass_2.getCommType();
+ boolean dataDriven = Objects.equal(_commType_2, ActorCommunicationType.DATA_DRIVEN);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("switch (");
+ String _memberAccess = this.langExt.memberAccess();
+ _builder.append(_memberAccess, "");
+ _builder.append("state) {");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ List<State> _leafStateList = this._roomExtensions.getLeafStateList(_stateMachine);
+ for(final State state : _leafStateList) {
+ _builder.append("\t");
+ _builder.append("case ");
+ String _stateId = this._roomExtensions.getStateId(state);
+ _builder.append(_stateId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ {
+ if (async) {
+ _builder.append("\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> atlist = xpac.getActiveTriggers(state);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty = atlist.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("case POLLING:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genDataDrivenTriggers = this.genDataDrivenTriggers(xpac, state);
+ _builder.append(_genDataDrivenTriggers, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genEventDrivenTriggers = this.genEventDrivenTriggers(xpac, state, atlist);
+ _builder.append(_genEventDrivenTriggers, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genDataDrivenTriggers_1 = this.genDataDrivenTriggers(xpac, state);
+ _builder.append(_genDataDrivenTriggers_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ if (dataDriven) {
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genDataDrivenTriggers_2 = this.genDataDrivenTriggers(xpac, state);
+ _builder.append(_genDataDrivenTriggers_2, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ if (eventDriven) {
+ _builder.append("\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> atlist_1 = xpac.getActiveTriggers(state);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty_1 = atlist_1.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ CharSequence _genEventDrivenTriggers_1 = this.genEventDrivenTriggers(xpac, state, atlist_1);
+ _builder.append(_genEventDrivenTriggers_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenTriggers(final ExpandedActorClass xpac, final State state) {
+ StringConcatenation _builder = new StringConcatenation();
+ CharSequence _genDoCodes = this.genDoCodes(state);
+ _builder.append(_genDoCodes, "");
+ _builder.newLineIfNotEmpty();
+ List<Transition> _outgoingTransitionsHierarchical = this._roomExtensions.getOutgoingTransitionsHierarchical(xpac, state);
+ final Function1<Transition,Boolean> _function = new Function1<Transition,Boolean>() {
+ public Boolean apply(final Transition t) {
+ return Boolean.valueOf((t instanceof GuardedTransition));
+ }
+ };
+ Iterable<Transition> transitions = IterableExtensions.<Transition>filter(_outgoingTransitionsHierarchical, _function);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final Transition tr : transitions) {
+ _builder.append("if (");
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ DetailCode _guard = ((GuardedTransition) tr).getGuard();
+ String _translatedCode = _instance.getTranslatedCode(_guard);
+ _builder.append(_translatedCode, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ TransitionChain chain = xpac.getChain(tr);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId = this._roomExtensions.getChainId(chain);
+ _builder.append(_chainId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("catching_state = ");
+ String _contextId = this._roomExtensions.getContextId(chain);
+ _builder.append(_contextId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = TRUE;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = TRUE;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ {
+ Transition _last = IterableExtensions.<Transition>last(transitions);
+ boolean _notEquals = (!Objects.equal(tr, _last));
+ if (_notEquals) {
+ _builder.append("else ");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence genEventDrivenTriggers(final ExpandedActorClass xpac, final State state, final List<ActiveTrigger> atlist) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final ActiveTrigger at : atlist) {
+ _builder.append("case ");
+ String _trigger = at.getTrigger();
+ String _triggerCodeName = xpac.getTriggerCodeName(_trigger);
+ _builder.append(_triggerCodeName, "");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ boolean needData = this._roomExtensions.hasGuard(xpac, at);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("{ ");
+ Message _msg = at.getMsg();
+ String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
+ _builder.append(_typedDataDefinition, " ");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ boolean _hasElements = false;
+ for(final TriggeredTransition tt : _transitions) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(" else ", " ");
+ }
+ _builder.append("\t");
+ TransitionChain chain = xpac.getChain(tt);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ Transition _transition = chain.getTransition();
+ String _trigger_1 = at.getTrigger();
+ CharSequence _guard = this.guard(_transition, _trigger_1, xpac);
+ _builder.append(_guard, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId = this._roomExtensions.getChainId(chain);
+ _builder.append(_chainId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("catching_state = ");
+ String _contextId = this._roomExtensions.getContextId(chain);
+ _builder.append(_contextId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = ");
+ String _booleanConstant = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant, " ");
+ _builder.append(";");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = ");
+ String _booleanConstant_1 = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant_1, " ");
+ _builder.append(";");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("}");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence genExtra(final ExpandedActorClass xpac) {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+
+ private CharSequence _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<Trigger> _triggers = tt.getTriggers();
+ final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
+ public Boolean apply(final Trigger e) {
+ boolean _isMatching = ac.isMatching(e, trigger);
+ return Boolean.valueOf(_isMatching);
+ }
+ };
+ Trigger tr = IterableExtensions.<Trigger>findFirst(_triggers, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasGuard = this._roomExtensions.hasGuard(tr);
+ if (_hasGuard) {
+ _builder.append("if (");
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ Guard _guard = tr.getGuard();
+ DetailCode _guard_1 = _guard.getGuard();
+ String _translatedCode = _instance.getTranslatedCode(_guard_1);
+ _builder.append(_translatedCode, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* error */");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence genDoCodes(final State state) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasDoCode = this._roomExtensions.hasDoCode(state);
+ if (_hasDoCode) {
+ String _doCodeOperationName = CodegenHelpers.getDoCodeOperationName(state);
+ _builder.append(_doCodeOperationName, "");
+ _builder.append("(self);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EObject _eContainer = state.eContainer();
+ EObject _eContainer_1 = _eContainer.eContainer();
+ if ((_eContainer_1 instanceof State)) {
+ EObject _eContainer_2 = state.eContainer();
+ EObject _eContainer_3 = _eContainer_2.eContainer();
+ CharSequence _genDoCodes = this.genDoCodes(((State) _eContainer_3));
+ _builder.append(_genDoCodes, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence genActionCodeMethods(final ExpandedActorClass xpac, final State state) {
+ CharSequence _xblockexpression = null;
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _name = _actorClass.getName();
+ final String selfPtr = this.langExt.selfPointer(_name, false);
+ final String entryOp = CodegenHelpers.getEntryCodeOperationName(state);
+ final String exitOp = CodegenHelpers.getExitCodeOperationName(state);
+ final String doOp = CodegenHelpers.getDoCodeOperationName(state);
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ DetailCode _entryCode = state.getEntryCode();
+ String entry = _instance.getTranslatedCode(_entryCode);
+ AbstractGenerator _instance_1 = AbstractGenerator.getInstance();
+ DetailCode _exitCode = state.getExitCode();
+ String exit = _instance_1.getTranslatedCode(_exitCode);
+ AbstractGenerator _instance_2 = AbstractGenerator.getInstance();
+ DetailCode _doCode = state.getDoCode();
+ String docode = _instance_2.getTranslatedCode(_doCode);
+ if ((state instanceof ExpandedRefinedState)) {
+ final ExpandedRefinedState rs = ((ExpandedRefinedState) state);
+ AbstractGenerator _instance_3 = AbstractGenerator.getInstance();
+ DetailCode _inheritedEntry = rs.getInheritedEntry();
+ final String inhEntry = _instance_3.getTranslatedCode(_inheritedEntry);
+ AbstractGenerator _instance_4 = AbstractGenerator.getInstance();
+ DetailCode _inheritedExit = rs.getInheritedExit();
+ final String inhExit = _instance_4.getTranslatedCode(_inheritedExit);
+ AbstractGenerator _instance_5 = AbstractGenerator.getInstance();
+ DetailCode _inheritedDo = rs.getInheritedDo();
+ final String inhDo = _instance_5.getTranslatedCode(_inheritedDo);
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ ActorClass _base = _actorClass_1.getBase();
+ final String baseName = _base.getName();
+ DetailCode _inheritedEntry_1 = rs.getInheritedEntry();
+ boolean _empty = this._roomExtensions.empty(_inheritedEntry_1);
+ boolean _not = (!_empty);
+ if (_not) {
+ String _superCall = this.langExt.superCall(baseName, entryOp, "");
+ String _plus = (_superCall + entry);
+ entry = _plus;
+ }
+ DetailCode _inheritedExit_1 = rs.getInheritedExit();
+ boolean _empty_1 = this._roomExtensions.empty(_inheritedExit_1);
+ boolean _not_1 = (!_empty_1);
+ if (_not_1) {
+ String _superCall_1 = this.langExt.superCall(baseName, exitOp, "");
+ String _plus_1 = (exit + _superCall_1);
+ exit = _plus_1;
+ }
+ DetailCode _inheritedDo_1 = rs.getInheritedDo();
+ boolean _empty_2 = this._roomExtensions.empty(_inheritedDo_1);
+ boolean _not_2 = (!_empty_2);
+ if (_not_2) {
+ String _superCall_2 = this.langExt.superCall(baseName, doOp, "");
+ String _plus_2 = (_superCall_2 + docode);
+ docode = _plus_2;
+ }
+ } else {
+ String _plus_3 = (inhEntry + entry);
+ entry = _plus_3;
+ String _plus_4 = (exit + inhExit);
+ exit = _plus_4;
+ String _plus_5 = (inhDo + docode);
+ docode = _plus_5;
+ }
+ }
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = entry.isEmpty();
+ boolean _not_3 = (!_isEmpty);
+ if (_not_3) {
+ String _accessLevelProtected = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ _builder.append("void ");
+ _builder.append(entryOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(entry, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _isEmpty_1 = exit.isEmpty();
+ boolean _not_4 = (!_isEmpty_1);
+ if (_not_4) {
+ String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_1, "");
+ _builder.append("void ");
+ _builder.append(exitOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(exit, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _isEmpty_2 = docode.isEmpty();
+ boolean _not_5 = (!_isEmpty_2);
+ if (_not_5) {
+ String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_2, "");
+ _builder.append(" void ");
+ _builder.append(doOp, "");
+ _builder.append("(");
+ _builder.append(selfPtr, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(docode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
+ if (tt instanceof TriggeredTransition) {
+ return _guard((TriggeredTransition)tt, trigger, ac);
+ } else if (tt != null) {
+ return _guard(tt, trigger, ac);
+ } else {
+ throw new IllegalArgumentException("Unhandled parameter types: " +
+ Arrays.<Object>asList(tt, trigger, ac).toString());
+ }
+ }
+}
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
new file mode 100644
index 0000000..828ac29
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/PrepareFileSystem.java
@@ -0,0 +1,81 @@
+package org.eclipse.etrice.generator.generic;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.io.File;
+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.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+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;
+
+@Singleton
+@SuppressWarnings("all")
+public class PrepareFileSystem {
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private ILogger logger;
+
+ public void prepare(final Resource resource) {
+ HashSet<String> _hashSet = new HashSet<String>();
+ Set<String> pathes = _hashSet;
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ EList<RoomModel> _usedRoomModels = ((Root) e).getUsedRoomModels();
+ for (final RoomModel mdl : _usedRoomModels) {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(mdl);
+ pathes.add(_generationTargetPath);
+ }
+ }
+ }
+ for (final String path : pathes) {
+ {
+ String _plus = ("clearing " + path);
+ this.logger.logInfo(_plus);
+ File _file = new File(path);
+ File f = _file;
+ this.eraseContents(f);
+ this.fileAccess.setOutputPath(path);
+ CharSequence _readmeText = this.readmeText();
+ this.fileAccess.generateFile("readme.txt", _readmeText);
+ }
+ }
+ }
+
+ public void eraseContents(final File f) {
+ boolean _isDirectory = f.isDirectory();
+ if (_isDirectory) {
+ File[] children = f.listFiles();
+ for (final File child : children) {
+ {
+ this.eraseContents(child);
+ child.delete();
+ }
+ }
+ }
+ }
+
+ public 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.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
index 3fc2216..e99dc02 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
index feac54a..0fab285 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
index 6c2b88c..2ec0933 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
index ee2ebde..e1fb146 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.zip
index c14e621..2a203bd 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.zip
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/ConfigSourceFile.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/ConfigSourceFile.java
index d865b5e..79891f7 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/ConfigSourceFile.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/ConfigSourceFile.java
@@ -42,7 +42,7 @@ public class ConfigSourceFile implements IConfigSource {
}
@Override
- public int getPolling() {
+ public int getPollingTimer() {
return 0;
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/IConfigSource.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/IConfigSource.java
index 022d760..42fb0c6 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/IConfigSource.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/IConfigSource.java
@@ -20,7 +20,7 @@ public interface IConfigSource {
* Polling interval [ms] <br>
* default case use <= 0
*/
- public int getPolling();
+ public int getPollingTimer();
Map<String, Object> readValues();
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/VariableService.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/VariableService.java
index 727362d..7ec8b42 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/VariableService.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/config/VariableService.java
@@ -12,46 +12,44 @@
package org.eclipse.etrice.runtime.java.config;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Set;
public abstract class VariableService {
- private final static String POLLING_KEY = "polling_time";
- private final static int defaultPolling = 5000;
+ private final static String POLLINGTIMER_KEY = "polling_timer[ms]";
+ private final static int defaultPollingTimer = 5000;
private final boolean logging = true;
- private volatile int polling;
+ private volatile int pollingTimer;
private PollingThread thread;
+ protected Map<String, Object> writeTasks;
+ private Map<String, Object> diffMap;
- protected ConcurrentHashMap<String, Object> writeTasks = new ConcurrentHashMap<String, Object>();
+ private IConfigSource source;
- // ----------- generated -----------
- protected IConfigSource source;
-
- protected abstract void getInstances();
-
- protected abstract void setAttributeValues(Map<String, Object> values);
-
- public abstract void write(String id, Object object);
-
- /**
- * called on init
- */
- protected abstract Map<String, Object> getAttributeValues();
+ public VariableService(IConfigSource source) {
+ this.source = source;
+ diffMap = new HashMap<String, Object>();
+ writeTasks = new HashMap<String, Object>();
+ }
public void init() {
- getInstances();
+ initInstances();
Map<String, Object> initalValues = source.readValues();
- if (setPolling(initalValues.get(POLLING_KEY))) {
- } else if (source.getPolling() > 0)
- this.polling = source.getPolling();
+ if (setPolling(initalValues.get(POLLINGTIMER_KEY))) {
+ } else if (getPollingTimerUser() > 0)
+ this.pollingTimer = getPollingTimerUser();
+ else if (source.getPollingTimer() > 0)
+ this.pollingTimer = source.getPollingTimer();
else
- this.polling = defaultPolling;
+ this.pollingTimer = defaultPollingTimer;
setAttributeValues(initalValues);
Map<String, Object> initValues = getAttributeValues();
- initValues.put(POLLING_KEY, polling);
+ initValues.put(POLLINGTIMER_KEY, pollingTimer);
source.createConfig(initValues);
start();
@@ -73,6 +71,35 @@ public abstract class VariableService {
thread.interrupt();
}
+ public void write(String id, Object object) {
+ if (PRIMITIVE_TYPES.contains(object.getClass()))
+ addWriteTask(id, object);
+ else if (object.getClass().isArray()) {
+ if (object instanceof boolean[])
+ addWriteTask(id, toObjectArray((boolean[]) object));
+ else if (object instanceof byte[])
+ addWriteTask(id, toObjectArray((byte[]) object));
+ else if (object instanceof short[])
+ addWriteTask(id, toObjectArray((short[]) object));
+ else if (object instanceof int[])
+ addWriteTask(id, toObjectArray((int[]) object));
+ else if (object instanceof long[])
+ addWriteTask(id, toObjectArray((long[]) object));
+ else if (object instanceof float[])
+ addWriteTask(id, toObjectArray((float[]) object));
+ else if (object instanceof double[])
+ addWriteTask(id, toObjectArray((double[]) object));
+ else if (object instanceof char[])
+ addWriteTask(id, toObjectArray((char[]) object));
+ else if (object instanceof String[])
+ addWriteTask(id, object);
+ } else {
+ Map<String, Object> writeTasks = new HashMap<String, Object>();
+ writeDataClass(id, object, writeTasks);
+ addWriteTasks(writeTasks);
+ }
+ }
+
private class PollingThread extends Thread {
private boolean stop = false;
@@ -92,7 +119,7 @@ public abstract class VariableService {
diff = (int) (System.currentTimeMillis() - time);
try {
- sleep(polling - ((diff > polling) ? 0 : diff));
+ sleep(pollingTimer - ((diff > pollingTimer) ? 0 : diff));
} catch (InterruptedException e) {
}
}
@@ -101,7 +128,7 @@ public abstract class VariableService {
}
private void apply(Map<String, Object> values) {
- Object pollingValue = values.remove(POLLING_KEY);
+ Object pollingValue = values.remove(POLLINGTIMER_KEY);
setPolling(pollingValue);
if (values.isEmpty())
return;
@@ -109,12 +136,13 @@ public abstract class VariableService {
}
private void write() {
- Map<String, Object> writeMap = new HashMap<String, Object>();
+ HashMap<String, Object> writeMap = new HashMap<String, Object>();
synchronized (writeTasks) {
- for (String key : writeTasks.keySet())
- writeMap.put(key, writeTasks.remove(key));
+ writeMap.putAll(writeTasks);
+ writeTasks.clear();
}
- source.writeValues(writeMap);
+ if (!writeMap.isEmpty())
+ source.writeValues(writeMap);
}
}
@@ -123,7 +151,7 @@ public abstract class VariableService {
try {
int result = ensureInt(value);
if (result > 0) {
- polling = result;
+ pollingTimer = result;
return true;
}
} catch (IllegalArgumentException e) {
@@ -134,6 +162,36 @@ public abstract class VariableService {
return false;
}
+ protected Map<String, Object> getDiffMap() {
+ return diffMap;
+ }
+
+ protected void addWriteTask(String id, Object value) {
+ synchronized (writeTasks) {
+ writeTasks.put(id, value);
+ }
+ }
+
+ protected void addWriteTasks(Map<String, Object> values) {
+ synchronized (writeTasks) {
+ writeTasks.putAll(values);
+ }
+ }
+
+ protected abstract void initInstances();
+
+ protected abstract void setAttributeValues(Map<String, Object> values);
+
+ protected abstract int getPollingTimerUser();
+
+ /**
+ * called on init
+ */
+ protected abstract Map<String, Object> getAttributeValues();
+
+ protected abstract void writeDataClass(String id, Object dcObject,
+ Map<String, Object> writeMap);
+
protected void checkMinMax(int value, Integer min, Integer max)
throws IllegalArgumentException {
if (min != null && value < min)
@@ -500,4 +558,10 @@ public abstract class VariableService {
+ ((id != null) ? " (" + id + ")" : ""));
}
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private static final Set<Class> PRIMITIVE_TYPES = new HashSet<Class>(
+ Arrays.asList(Boolean.class, Character.class, String.class,
+ Byte.class, Short.class, Integer.class, Long.class,
+ Float.class, Double.class));
+
}
diff --git a/tests/org.eclipse.etrice.core.config.tests/.classpath b/tests/org.eclipse.etrice.core.config.tests/.classpath
index cedf0d0..afb9bb4 100644
--- a/tests/org.eclipse.etrice.core.config.tests/.classpath
+++ b/tests/org.eclipse.etrice.core.config.tests/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/tests/org.eclipse.etrice.core.config.tests/.gitignore b/tests/org.eclipse.etrice.core.config.tests/.gitignore
new file mode 100644
index 0000000..b0b3b47
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.config.tests/.gitignore
@@ -0,0 +1,2 @@
+gerritKeys
+gerritKeys.pub \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.config b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.config
index 01a8834..bdae3dc 100644
--- a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.config
+++ b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.config
@@ -83,6 +83,18 @@ ActorInstanceConfig SubSystemConfigTest / top / testee2 {
Attr blocker = false {
dynamic configuration read
}
+ Attr dc_dump{
+ dynamic configuration write
+ Attr dc_i {
+ Attr char_i = "dummy"
+ Attr double_i = 0.0e-100
+ }
+ Attr long_array_i = 1000
+ Attr int_i = 123
+ }
+ Attr int_dump = 3 {
+ dynamic configuration write
+ }
}
diff --git a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.room b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.room
index 99c9da5..1290d60 100644
--- a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.room
+++ b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.ConfigTest.room
@@ -28,7 +28,10 @@ RoomModel org.eclipse.etrice.integration.ConfigTest {
Attribute dc_i : Dyn_DC1
// manual test
Attribute blockMe : int32
- Attribute blocker : boolean
+ Attribute blocker : boolean
+ // not explicit test
+ Attribute dc_dump : Dyn_DC1
+ Attribute int_dump : int32
}
Behavior {
StateMachine {
@@ -38,6 +41,11 @@ RoomModel org.eclipse.etrice.integration.ConfigTest {
<test : Conj_DynConfigPort>
}
action {
+ // write without test
+ "Dyn_DC1 tmp = new Dyn_DC1(123, new long[]{1000}, new Dyn_DC2(0.0e-100, \"dummy out\".toCharArray()));"
+ "setAndWriteDc_dump(tmp);"
+ "setAndWriteInt_dump(888);"
+ // read test
"if(blocker)getBlockMeLock().forbidUpdate(); else getBlockMeLock().allowUpdate();"
"int testValue = 0;"
"if(int_i != 401 || getDc_i().getLong_array_i()[0] != 403)"
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
index 2614ba4..f8b9178 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
@@ -43,7 +43,6 @@ public class CPTest_Top extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
index 7d000c5..4d8496f 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
@@ -47,7 +47,6 @@ public class CPTester extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
index bba5874..8bedc81 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
@@ -56,7 +56,6 @@ public class CPUser extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
public void setCounter (int counter) {
this.counter = counter;
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/AC1_ac.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/AC1_ac.java
index 64ebdc3..e264294 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/AC1_ac.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/AC1_ac.java
@@ -47,7 +47,6 @@ public class AC1_ac extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/ConfigText_Top_ac.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/ConfigText_Top_ac.java
index a638075..abd515e 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/ConfigText_Top_ac.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/ConfigText_Top_ac.java
@@ -43,7 +43,6 @@ public class ConfigText_Top_ac extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/DynTestee_ac.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/DynTestee_ac.java
index 4be9aaf..0a35ec3 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/DynTestee_ac.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/DynTestee_ac.java
@@ -21,6 +21,7 @@ import org.eclipse.etrice.runtime.java.messaging.RTServices;
public class DynTestee_ac extends ActorClassBase {
+ private VariableService variableService;
//--------------------- ports
protected TestCommProtocolConjPort Conj_DynConfigPort = null;
@@ -38,10 +39,12 @@ public class DynTestee_ac extends ActorClassBase {
Dyn_DC1 dc_i;
int blockMe;
boolean blocker;
- private DynConfigLock lock_int_i;
+ Dyn_DC1 dc_dump;
+ int int_dump;
+ private DynConfigLock lock_blocker;
private DynConfigLock lock_dc_i;
+ private DynConfigLock lock_int_i;
private DynConfigLock lock_blockMe;
- private DynConfigLock lock_blocker;
/*--------------------- operations ---------------------*/
//--------------------- construction
@@ -54,6 +57,8 @@ public class DynTestee_ac extends ActorClassBase {
dc_i = new Dyn_DC1();
blockMe = 0;
blocker = false;
+ dc_dump = new Dyn_DC1();
+ int_dump = 0;
// own ports
Conj_DynConfigPort = new TestCommProtocolConjPort(this, "Conj_DynConfigPort", IFITEM_Conj_DynConfigPort, 0, port_addr[IFITEM_Conj_DynConfigPort][0], peer_addr[IFITEM_Conj_DynConfigPort][0]);
@@ -66,33 +71,45 @@ public class DynTestee_ac extends ActorClassBase {
public DynTestee_ac(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr, VariableService variableService){
this(parent, name, port_addr, peer_addr);
- lock_int_i = new DynConfigLock();
+ this.variableService = variableService;
+ lock_blocker = new DynConfigLock();
lock_dc_i = new DynConfigLock();
+ lock_int_i = new DynConfigLock();
lock_blockMe = new DynConfigLock();
- lock_blocker = new DynConfigLock();
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
+ public void setDc_dump (Dyn_DC1 dc_dump) {
+ this.dc_dump = dc_dump;
+ }
+ public Dyn_DC1 getDc_dump () {
+ return this.dc_dump;
+ }
+ public void setInt_dump (int int_dump) {
+ this.int_dump = int_dump;
+ }
+ public int getInt_dump () {
+ return this.int_dump;
+ }
- public int getInt_i(){
- if(lock_int_i == null)
- return int_i;
+ public boolean getBlocker(){
+ if(lock_blocker == null)
+ return blocker;
else
- synchronized(lock_int_i){
- return int_i;
+ synchronized(lock_blocker){
+ return blocker;
}
}
- public void setInt_i(int int_i){
- if(lock_int_i == null)
- this.int_i = int_i;
+ public void setBlocker(boolean blocker){
+ if(lock_blocker == null)
+ this.blocker = blocker;
else
- synchronized(lock_int_i){
- this.int_i = int_i;
+ synchronized(lock_blocker){
+ this.blocker = blocker;
}
}
- public DynConfigLock getInt_iLock(){
- return lock_int_i;
+ public DynConfigLock getBlockerLock(){
+ return lock_blocker;
}
public Dyn_DC1 getDc_i(){
if(lock_dc_i == null)
@@ -113,6 +130,25 @@ public class DynTestee_ac extends ActorClassBase {
public DynConfigLock getDc_iLock(){
return lock_dc_i;
}
+ public int getInt_i(){
+ if(lock_int_i == null)
+ return int_i;
+ else
+ synchronized(lock_int_i){
+ return int_i;
+ }
+ }
+ public void setInt_i(int int_i){
+ if(lock_int_i == null)
+ this.int_i = int_i;
+ else
+ synchronized(lock_int_i){
+ this.int_i = int_i;
+ }
+ }
+ public DynConfigLock getInt_iLock(){
+ return lock_int_i;
+ }
public int getBlockMe(){
if(lock_blockMe == null)
return blockMe;
@@ -132,25 +168,14 @@ public class DynTestee_ac extends ActorClassBase {
public DynConfigLock getBlockMeLock(){
return lock_blockMe;
}
- public boolean getBlocker(){
- if(lock_blocker == null)
- return blocker;
- else
- synchronized(lock_blocker){
- return blocker;
- }
+ public void setAndWriteDc_dump(Dyn_DC1 dc_dump){
+ setDc_dump(dc_dump);
+ variableService.write(this.getInstancePath()+"/dc_dump", dc_dump);
}
- public void setBlocker(boolean blocker){
- if(lock_blocker == null)
- this.blocker = blocker;
- else
- synchronized(lock_blocker){
- this.blocker = blocker;
- }
+ public void setAndWriteInt_dump(int int_dump){
+ setInt_dump(int_dump);
+ variableService.write(this.getInstancePath()+"/int_dump", int_dump);
}
- public DynConfigLock getBlockerLock(){
- return lock_blocker;
- }
//--------------------- port getters
public TestCommProtocolConjPort getConj_DynConfigPort (){
@@ -206,6 +231,9 @@ public class DynTestee_ac extends ActorClassBase {
/* Action Codes */
protected void action_TRANS_tr0_FROM_First_TO_Done_BY_testConj_DynConfigPort(InterfaceItemBase ifitem) {
+ Dyn_DC1 tmp = new Dyn_DC1(123, new long[]{1000}, new Dyn_DC2(0.0e-100, "dummy out".toCharArray()));
+ setAndWriteDc_dump(tmp);
+ setAndWriteInt_dump(888);
if(blocker)getBlockMeLock().forbidUpdate(); else getBlockMeLock().allowUpdate();
int testValue = 0;
if(int_i != 401 || getDc_i().getLong_array_i()[0] != 403)
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTest.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTest.java
index e6f9e80..65ccc19 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTest.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTest.java
@@ -156,6 +156,11 @@ public class SubSystemConfigTest extends SubSystemClassBase{
inst.getDc_i().getDc_i().setDouble_i(0.304d);
inst.setBlockMe(0);
inst.setBlocker(false);
+ inst.getDc_dump().getDc_i().setChar_i("dummy".toCharArray());
+ inst.getDc_dump().getDc_i().setDouble_i(0.0d);
+ inst.getDc_dump().setLong_array_i(new long[]{1000L});
+ inst.getDc_dump().setInt_i(123);
+ inst.setInt_dump(3);
}
// create the subsystem system port
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTestVariableService.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTestVariableService.java
index 7ddea2e..a16a825 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTestVariableService.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/SubSystemConfigTestVariableService.java
@@ -5,26 +5,25 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.etrice.runtime.java.config.VariableService;
-import org.eclipse.etrice.runtime.java.config.ConfigSourceFile
- ;
+import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;
+import org.eclipse.etrice.integration.ConfigTest.*;
+
public class SubSystemConfigTestVariableService extends VariableService{
private SubSystemConfigTest subSystem;
- private Map<String, Object> diffMap;
- // Actor instances
- private DynTestee_ac testee2;
+ // Actor instances
+ private DynTestee_ac _top_testee2;
public SubSystemConfigTestVariableService(SubSystemConfigTest subSystem) {
+ super(new ConfigSourceFile("tmp/subSystemConfigTest"));
this.subSystem = subSystem;
- source = new ConfigSourceFile("tmp/subSystemConfigTest");
- diffMap = new HashMap<String, Object>();
}
@Override
- protected void getInstances(){
- testee2 = (DynTestee_ac)subSystem.getInstance("/SubSystemConfigTest/top/testee2");
+ protected void initInstances(){
+ _top_testee2 = (DynTestee_ac)subSystem.getInstance("/SubSystemConfigTest/top/testee2");
}
@@ -39,16 +38,16 @@ public class SubSystemConfigTestVariableService extends VariableService{
object = values.get(id);
if(object != null){
_int_i = ensureInt(object);
- if(!_int_i.equals((Integer)diffMap.get(id)))
+ if(!_int_i.equals((Integer)getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
if(changed)
- synchronized(testee2.getInt_iLock()){
- if(testee2.getInt_iLock().isUpdate()){
+ synchronized(_top_testee2.getInt_iLock()){
+ if(_top_testee2.getInt_iLock().isUpdate()){
if(_int_i != null){
- testee2.setInt_i(_int_i);
- diffMap.put("/SubSystemConfigTest/int_i", _int_i);
+ _top_testee2.setInt_i(_int_i);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/int_i", _int_i);
}
}
}
@@ -57,12 +56,21 @@ public class SubSystemConfigTestVariableService extends VariableService{
}
try{
boolean changed = false;
+ id = "/SubSystemConfigTest/top/testee2/dc_i/long_array_i";
+ long[] _long_array_i = null;
+ object = values.get(id);
+ if(object != null){
+ _long_array_i = ensureLongArray(object, 1);
+ if(!Arrays.equals(_long_array_i, (long[])getDiffMap().get(id)))
+ changed = true;
+ } else
+ warning(id, "is missing");
id = "/SubSystemConfigTest/top/testee2/dc_i/dc_i/double_i";
Double _double_i = null;
object = values.get(id);
if(object != null){
_double_i = ensureDouble(object);
- if(!_double_i.equals((Double)diffMap.get(id)))
+ if(!_double_i.equals((Double)getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
@@ -71,16 +79,7 @@ public class SubSystemConfigTestVariableService extends VariableService{
object = values.get(id);
if(object != null){
_char_i = ensureCharArray(object, 10);
- if(!Arrays.equals(_char_i, (char[])diffMap.get(id)))
- changed = true;
- } else
- warning(id, "is missing");
- id = "/SubSystemConfigTest/top/testee2/dc_i/long_array_i";
- long[] _long_array_i = null;
- object = values.get(id);
- if(object != null){
- _long_array_i = ensureLongArray(object, 1);
- if(!Arrays.equals(_long_array_i, (long[])diffMap.get(id)))
+ if(!Arrays.equals(_char_i, (char[])getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
@@ -89,28 +88,28 @@ public class SubSystemConfigTestVariableService extends VariableService{
object = values.get(id);
if(object != null){
_int_i = ensureInt(object);
- if(!_int_i.equals((Integer)diffMap.get(id)))
+ if(!_int_i.equals((Integer)getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
if(changed)
- synchronized(testee2.getDc_iLock()){
- if(testee2.getDc_iLock().isUpdate()){
+ synchronized(_top_testee2.getDc_iLock()){
+ if(_top_testee2.getDc_iLock().isUpdate()){
+ if(_long_array_i != null){
+ _top_testee2.getDc_i().setLong_array_i(_long_array_i);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/dc_i/long_array_i", _long_array_i);
+ }
if(_double_i != null){
- testee2.getDc_i().getDc_i().setDouble_i(_double_i);
- diffMap.put("/SubSystemConfigTest/dc_i/dc_i/double_i", _double_i);
+ _top_testee2.getDc_i().getDc_i().setDouble_i(_double_i);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/dc_i/dc_i/double_i", _double_i);
}
if(_char_i != null){
- testee2.getDc_i().getDc_i().setChar_i(_char_i);
- diffMap.put("/SubSystemConfigTest/dc_i/dc_i/char_i", _char_i);
- }
- if(_long_array_i != null){
- testee2.getDc_i().setLong_array_i(_long_array_i);
- diffMap.put("/SubSystemConfigTest/dc_i/long_array_i", _long_array_i);
+ _top_testee2.getDc_i().getDc_i().setChar_i(_char_i);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/dc_i/dc_i/char_i", _char_i);
}
if(_int_i != null){
- testee2.getDc_i().setInt_i(_int_i);
- diffMap.put("/SubSystemConfigTest/dc_i/int_i", _int_i);
+ _top_testee2.getDc_i().setInt_i(_int_i);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/dc_i/int_i", _int_i);
}
}
}
@@ -124,16 +123,16 @@ public class SubSystemConfigTestVariableService extends VariableService{
object = values.get(id);
if(object != null){
_blockMe = ensureInt(object);
- if(!_blockMe.equals((Integer)diffMap.get(id)))
+ if(!_blockMe.equals((Integer)getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
if(changed)
- synchronized(testee2.getBlockMeLock()){
- if(testee2.getBlockMeLock().isUpdate()){
+ synchronized(_top_testee2.getBlockMeLock()){
+ if(_top_testee2.getBlockMeLock().isUpdate()){
if(_blockMe != null){
- testee2.setBlockMe(_blockMe);
- diffMap.put("/SubSystemConfigTest/blockMe", _blockMe);
+ _top_testee2.setBlockMe(_blockMe);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/blockMe", _blockMe);
}
}
}
@@ -147,16 +146,16 @@ public class SubSystemConfigTestVariableService extends VariableService{
object = values.get(id);
if(object != null){
_blocker = ensureBoolean(object);
- if(!_blocker.equals((Boolean)diffMap.get(id)))
+ if(!_blocker.equals((Boolean)getDiffMap().get(id)))
changed = true;
} else
warning(id, "is missing");
if(changed)
- synchronized(testee2.getBlockerLock()){
- if(testee2.getBlockerLock().isUpdate()){
+ synchronized(_top_testee2.getBlockerLock()){
+ if(_top_testee2.getBlockerLock().isUpdate()){
if(_blocker != null){
- testee2.setBlocker(_blocker);
- diffMap.put("/SubSystemConfigTest/blocker", _blocker);
+ _top_testee2.setBlocker(_blocker);
+ getDiffMap().put("/SubSystemConfigTest/top/testee2/blocker", _blocker);
}
}
}
@@ -168,28 +167,38 @@ public class SubSystemConfigTestVariableService extends VariableService{
@Override
protected Map<String, Object> getAttributeValues(){
Map<String, Object> values = new HashMap<String, Object>();
- values.put("/SubSystemConfigTest/top/testee2/int_i", testee2.getInt_i());
- values.put("/SubSystemConfigTest/top/testee2/dc_i/dc_i/double_i", testee2.getDc_i().getDc_i().getDouble_i());
- values.put("/SubSystemConfigTest/top/testee2/dc_i/dc_i/char_i", toObjectArray(testee2.getDc_i().getDc_i().getChar_i()));
- values.put("/SubSystemConfigTest/top/testee2/dc_i/long_array_i", toObjectArray(testee2.getDc_i().getLong_array_i()));
- values.put("/SubSystemConfigTest/top/testee2/dc_i/int_i", testee2.getDc_i().getInt_i());
- values.put("/SubSystemConfigTest/top/testee2/blockMe", testee2.getBlockMe());
- values.put("/SubSystemConfigTest/top/testee2/blocker", testee2.getBlocker());
+ values.put("/SubSystemConfigTest/top/testee2/int_i", _top_testee2.getInt_i());
+ values.put("/SubSystemConfigTest/top/testee2/dc_i/long_array_i", toObjectArray(_top_testee2.getDc_i().getLong_array_i()));
+ values.put("/SubSystemConfigTest/top/testee2/dc_i/dc_i/double_i", _top_testee2.getDc_i().getDc_i().getDouble_i());
+ values.put("/SubSystemConfigTest/top/testee2/dc_i/dc_i/char_i", toObjectArray(_top_testee2.getDc_i().getDc_i().getChar_i()));
+ values.put("/SubSystemConfigTest/top/testee2/dc_i/int_i", _top_testee2.getDc_i().getInt_i());
+ values.put("/SubSystemConfigTest/top/testee2/blockMe", _top_testee2.getBlockMe());
+ values.put("/SubSystemConfigTest/top/testee2/blocker", _top_testee2.getBlocker());
return values;
}
@Override
- public void write(String id, Object object){
- if(object.getClass().isPrimitive() || object.getClass().isArray())
- writeTasks.put(id, object);
- else {
- synchronized(writeTasks){
- }
- }
+ public void writeDataClass(String id, Object dcObject, Map<String, Object> writeMap) {
+ if(dcObject.getClass().equals(Dyn_DC1.class))
+ writeDataClass(id, (Dyn_DC1) dcObject, writeTasks);
}
// DataClasses write operations
+ private void writeDataClass(String id, Dyn_DC1 object, Map<String, Object> map){
+ map.put(id+"/int_i", object.getInt_i());
+ map.put(id+"/long_array_i", toObjectArray(object.getLong_array_i()));
+ writeDataClass(id+"/dc_i", object.getDc_i(), map);
+ }
+ private void writeDataClass(String id, Dyn_DC2 object, Map<String, Object> map){
+ map.put(id+"/double_i", object.getDouble_i());
+ map.put(id+"/char_i", toObjectArray(object.getChar_i()));
+ }
+
+ @Override
+ protected int getPollingTimerUser(){
+ return 4000;
+ }
}
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/Testee_ac.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/Testee_ac.java
index b875cc4..3e564be 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/Testee_ac.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ConfigTest/Testee_ac.java
@@ -105,7 +105,6 @@ public class Testee_ac extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
public void setBool_r (boolean bool_r) {
this.bool_r = bool_r;
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
index 44e5004..a876b6c 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
@@ -43,7 +43,6 @@ public class HandlerTest_Top extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
index 5c56538..a417c6e 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
@@ -56,7 +56,6 @@ public class HandlerUser extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
public void setCounter (int counter) {
this.counter = counter;
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
index 026037b..d03c74b 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
@@ -52,7 +52,6 @@ public class Tester extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
index 0af724b..66d48c9 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
@@ -65,7 +65,6 @@ public class MrPingActor extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
public void setCount (int count) {
this.count = count;
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
index 6bde6bd..12f9dbd 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
@@ -47,7 +47,6 @@ public class MrPongActor1 extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
index 26433d9..fd31198 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
@@ -47,7 +47,6 @@ public class MrPongActor2 extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
index efb287a..bdba3f2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
@@ -43,7 +43,6 @@ public class PingPongTop extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
index 98f7c70..c48510a 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
@@ -59,7 +59,6 @@ public class MrPingActor extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
public void setCount (int count) {
this.count = count;
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
index faca403..752de30 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
@@ -47,7 +47,6 @@ public class MrPongActor1 extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
index a5fa270..ff4dfc0 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
@@ -43,7 +43,6 @@ public class PingPongTop extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
index 995c4d5..9ec7832 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
@@ -73,7 +73,6 @@ public class MrPing extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
public void setI32Array (int[] i32Array) {
this.i32Array = i32Array;
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
index 9464d29..cf07f2d 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
@@ -59,7 +59,6 @@ public class MrPong extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
index 2a6a52d..f8ce40a 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
@@ -43,7 +43,6 @@ public class SendingDataTop extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
index 3ac4641..b909c5d 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
@@ -43,7 +43,6 @@ public class App_SubSystemHFSMTest extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
index 97e1d82..fcd9668 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
@@ -47,7 +47,6 @@ public class a_HFSM extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
index 1bb6337..f32c430 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
@@ -50,7 +50,6 @@ public class a_HFSM_Tester extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
index e1c99a3..7f746ac 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
@@ -43,7 +43,6 @@ public class a_HFSM_Tests extends ActorClassBase {
}
- //--------------------- attributes getter and setter
//--------------------- attribute setters and getters
diff --git a/tests/org.eclipse.etrice.integration.tests/tmp/subSystemConfigTest b/tests/org.eclipse.etrice.integration.tests/tmp/subSystemConfigTest
index 5eba058..060e215 100644
--- a/tests/org.eclipse.etrice.integration.tests/tmp/subSystemConfigTest
+++ b/tests/org.eclipse.etrice.integration.tests/tmp/subSystemConfigTest
@@ -1,8 +1,13 @@
/SubSystemConfigTest/top/testee2/blockMe=0
/SubSystemConfigTest/top/testee2/blocker=false
+/SubSystemConfigTest/top/testee2/dc_dump/dc_i/char_i="dummy out"
+/SubSystemConfigTest/top/testee2/dc_dump/dc_i/double_i=0.0
+/SubSystemConfigTest/top/testee2/dc_dump/int_i=123
+/SubSystemConfigTest/top/testee2/dc_dump/long_array_i={ 1000 }
/SubSystemConfigTest/top/testee2/dc_i/dc_i/char_i="instance4"
/SubSystemConfigTest/top/testee2/dc_i/dc_i/double_i=0.404
/SubSystemConfigTest/top/testee2/dc_i/int_i=402
/SubSystemConfigTest/top/testee2/dc_i/long_array_i={ 403 }
+/SubSystemConfigTest/top/testee2/int_dump=888
/SubSystemConfigTest/top/testee2/int_i=401
-polling_time=5000
+polling_timer[ms]=4000