Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-11-18 11:51:11 -0500
committerHenrik Rentz-Reichert2013-11-19 12:36:56 -0500
commitaf70a003bffc78a40b716f493069545a9d94ad5c (patch)
tree43f8136fec492fd07aed57122c0e5f07b7c1770a
parent6a31f677cdc6076eb2c16d0e5642acc237b3ac5e (diff)
downloadorg.eclipse.etrice-af70a003bffc78a40b716f493069545a9d94ad5c.tar.gz
org.eclipse.etrice-af70a003bffc78a40b716f493069545a9d94ad5c.tar.xz
org.eclipse.etrice-af70a003bffc78a40b716f493069545a9d94ad5c.zip
[runtime.java][generator.java] Bug 422044: add possibility to
store/restore an actor's extended state using POJOs https://bugs.eclipse.org/422044 Change-Id: Iba98c6dff98da807098a82d37e7d8dd8489df180
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java7
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend97
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend116
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/GlobalSettings.java15
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java231
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java640
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java11
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java16
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorConfigTab.java9
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorLaunchConfigurationDelegate.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java12
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin417972 -> 417917 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin66516 -> 68569 bytes
-rw-r--r--releng/org.eclipse.etrice.parent/pom.xml158
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/install_org.eclipse.etrice.runtime.java.launch4
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java75
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java23
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/make.xml49
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/StaticConfigTest_Java.room2
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/StoreRestore.room219
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap3
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room2
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys1
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/make.xml32
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/src/StoreRestore/ObjectHolder.java32
30 files changed, 1537 insertions, 248 deletions
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
index 8d415b086..e224e7d50 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
@@ -36,6 +36,7 @@ import com.google.inject.Inject;
public class Main extends AbstractGenerator {
public static final String OPTION_GEN_PERSIST = "-persistable";
+ public static final String OPTION_GEN_STORE_DATA_OBJ = "-storeDataObj";
/**
* print usage message to output/console
@@ -43,9 +44,11 @@ public class Main extends AbstractGenerator {
protected void printUsage() {
output.println(this.getClass().getName()+getCommonOptions()
+" ["+OPTION_GEN_PERSIST+"]"
+ +" ["+OPTION_GEN_STORE_DATA_OBJ+"]"
+" <list of model file paths>");
output.println(getCommonOptionDescriptions());
output.println(" -persistable # if specified make actor classes persistable");
+ output.println(" -storeDataObj # if specified equip actor classes with store/restore using POJOs");
}
/**
@@ -87,6 +90,10 @@ public class Main extends AbstractGenerator {
getSettings().setGeneratePersistenceInterface(true);
return true;
}
+ else if (arg.equals(OPTION_GEN_STORE_DATA_OBJ)) {
+ getSettings().setGenerateStoreDataObj(true);
+ return true;
+ }
return super.parseOption(arg, it);
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend
new file mode 100644
index 000000000..733b93df1
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.java.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.HashMap
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+
+
+@Singleton
+class ActorClassDataGen {
+
+ @Inject IGeneratorFileIo fileIO
+ @Inject extension RoomExtensions
+ @Inject IDataConfiguration dataConfigExt
+
+ @Inject extension ProcedureHelpers
+
+ def doGenerate(Root root) {
+ val HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>
+ root.wiredInstances.filter(w|w instanceof WiredActorClass).forEach[w|ac2wired.put((w as WiredActorClass).actorClass, w as WiredActorClass)]
+ for (xpac: root.xpActorClasses) {
+ val wired = ac2wired.get(xpac.actorClass)
+ val path = xpac.actorClass.generationTargetPath+xpac.actorClass.getPath
+ val infopath = xpac.actorClass.generationInfoPath+xpac.actorClass.getPath
+ var file = xpac.actorClass.name+"_DataObject.java"
+ fileIO.generateFile("generating ActorClass implementation", path, infopath, file, root.generate(xpac, wired))
+ }
+ }
+
+ def generate(Root root, ExpandedActorClass xpac, WiredActorClass wired) {
+ val ac = xpac.actorClass
+ val clsname = ac.name+"_DataObject"
+ val models = root.getReferencedModels(ac)
+ val baseClass = if (ac.base!=null) "extends "+ac.base.name+"_DataObject " else ""
+
+ '''
+ package «ac.getPackage»;
+
+ import org.eclipse.etrice.runtime.java.modelbase.IActorClassDataObject;
+ «FOR model : models»
+ import «model.name».*;
+ «ENDFOR»
+
+ public class «clsname» «baseClass»implements IActorClassDataObject {
+
+ «IF ac.hasNonEmptyStateMachine»
+ // state and history
+ private int state;
+ private int[] history;
+
+ «ENDIF»
+ «ac.attributes.attributes»
+
+ «IF ac.hasNonEmptyStateMachine»
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int state) {
+ this.state = state;
+ }
+
+ public int[] getHistory() {
+ return history;
+ }
+
+ public void setHistory(int[] history) {
+ this.history = history;
+ }
+
+ «ENDIF»
+ «attributeSettersGettersImplementation(ac.attributes, ac.name)»
+
+ };
+ '''
+ }
+}
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 6d8d6ef6a..d92006022 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
@@ -69,10 +69,11 @@ class ActorClassGen extends GenericActorClassGenerator {
val dtor = ac.operations.filter(op|op.destructor).head
val models = root.getReferencedModels(ac)
val impPersist = if (Main::settings.generatePersistenceInterface) "implements IPersistable " else ""
- val baseClass = if (ac.base!=null) ac.base.name else
- if (ac.getAttribute("ActorBaseClass", "class").empty) "ActorClassBase" else ac.getAttribute("ActorBaseClass", "class")
- val baseClassImport = if (ac.getAttribute("ActorBaseClass", "class").empty) "org.eclipse.etrice.runtime.java.modelbase.ActorClassBase"
- else ac.getAttribute("ActorBaseClass", "package")+"."+ac.getAttribute("ActorBaseClass", "class")
+ val dataObjClass = ac.name+"_DataObject"
+ val baseClass = if (ac.base!=null) ac.base.name
+ else if (!ac.getAttribute("ActorBaseClass", "class").empty) ac.getAttribute("ActorBaseClass", "class")
+ else if (Main::settings.generateStoreDataObj) "ActorClassFinalActionBase"
+ else "ActorClassBase"
'''
package «ac.getPackage»;
@@ -86,14 +87,13 @@ class ActorClassGen extends GenericActorClassGenerator {
import java.io.ObjectInput;
import java.io.ObjectOutput;
«ENDIF»
- import org.eclipse.etrice.runtime.java.messaging.Address;
- import org.eclipse.etrice.runtime.java.messaging.IRTObject;
- import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
- import «baseClassImport»;
- import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
- import org.eclipse.etrice.runtime.java.modelbase.DataPortBase;
- import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
- import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+ «IF Main::settings.isGenerateStoreDataObj»
+ import java.util.Arrays;
+ «ENDIF»
+ import org.eclipse.etrice.runtime.java.messaging.*;
+ import org.eclipse.etrice.runtime.java.modelbase.*;
+ import org.eclipse.etrice.runtime.java.debugging.*;
+
import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;
«FOR model : models»
@@ -322,6 +322,90 @@ class ActorClassGen extends GenericActorClassGenerator {
«xpac.genLoadImpl»
}
«ENDIF»
+ «IF Main::settings.isGenerateStoreDataObj»
+
+ protected void store(IActorClassDataObject obj) {
+ if (!(obj instanceof «dataObjClass»))
+ return;
+
+ «dataObjClass» dataObject = («dataObjClass») obj;
+ «IF ac.base!=null»
+
+ super.store(dataObject);
+ «ENDIF»
+ «IF ac.hasNonEmptyStateMachine»
+
+ dataObject.setState(getState());
+ dataObject.setHistory(Arrays.copyOf(history, history.length));
+ «ENDIF»
+ «IF !ac.attributes.empty»
+
+ «FOR att : ac.attributes»
+ «IF att.type.type.enumerationOrPrimitive»
+ «IF att.size>1»
+ dataObject.set«att.name.toFirstUpper»(Arrays.copyOf(«att.name», «att.name».length));
+ «ELSE»
+ dataObject.set«att.name.toFirstUpper»(«att.name»);
+ «ENDIF»
+ «ELSE»
+««« DataClass and ExternalType
+ «IF att.size>1»
+ {
+ «att.type.type.name»[] arr = Arrays.copyOf(«att.name», «att.name».length);
+ for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();
+ dataObject.set«att.name.toFirstUpper»(arr);
+ }
+ «ELSE»
+ dataObject.set«att.name.toFirstUpper»(«att.name».deepCopy());
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ }
+
+ protected void restore(IActorClassDataObject obj) {
+ if (!(obj instanceof «dataObjClass»))
+ return;
+
+ «dataObjClass» dataObject = («dataObjClass») obj;
+ «IF ac.base!=null»
+
+ super.restore(dataObject);
+ «ENDIF»
+ «IF ac.hasNonEmptyStateMachine»
+
+ setState(dataObject.getState());
+ history = Arrays.copyOf(dataObject.getHistory(), dataObject.getHistory().length);
+ «ENDIF»
+ «IF !ac.attributes.empty»
+
+ «FOR att : ac.attributes»
+ «IF att.type.type.enumerationOrPrimitive»
+ «IF att.size>1»
+ set«att.name.toFirstUpper»(Arrays.copyOf(dataObject.get«att.name.toFirstUpper»(), «att.name».length));
+ «ELSE»
+ set«att.name.toFirstUpper»(dataObject.get«att.name.toFirstUpper»());
+ «ENDIF»
+ «ELSE»
+««« DataClass and ExternalType
+ «IF att.size>1»
+ {
+ «att.type.type.name»[] arr = Arrays.copyOf(dataObject.get«att.name.toFirstUpper»(), «att.name».length);
+ for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();
+ set«att.name.toFirstUpper»(arr);
+ }
+ «ELSE»
+ set«att.name.toFirstUpper»(dataObject.get«att.name.toFirstUpper»().deepCopy());
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ }
+
+ protected «dataObjClass» newDataObject() {
+ return new «dataObjClass»();
+ }
+ «ENDIF»
};
'''
}
@@ -330,8 +414,8 @@ class ActorClassGen extends GenericActorClassGenerator {
val ac = xpac.actorClass
'''
«IF ac.base!=null»
- super.saveAttributes(output);
-
+ super.saveAttributes(output);
+
«ENDIF»
«IF !ac.attributes.empty»
«FOR att : ac.attributes»
@@ -354,8 +438,8 @@ class ActorClassGen extends GenericActorClassGenerator {
val ac = xpac.actorClass
'''
«IF ac.base!=null»
- super.loadAttributes(input);
-
+ super.loadAttributes(input);
+
«ENDIF»
«IF !ac.attributes.empty»
«FOR att : ac.attributes»
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/GlobalSettings.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/GlobalSettings.java
index 1c313aa39..5fef705c7 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/GlobalSettings.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/GlobalSettings.java
@@ -21,6 +21,7 @@ import org.eclipse.etrice.generator.base.GlobalGeneratorSettings;
public class GlobalSettings extends GlobalGeneratorSettings {
private boolean generatePersistenceInterface = false;
+ private boolean generateStoreDataObj = false;
/**
* @return the generatePersistenceInterface
@@ -35,4 +36,18 @@ public class GlobalSettings extends GlobalGeneratorSettings {
public void setGeneratePersistenceInterface(boolean generatePersistenceInterface) {
this.generatePersistenceInterface = generatePersistenceInterface;
}
+
+ /**
+ * @return the generateStoreDataObj
+ */
+ public boolean isGenerateStoreDataObj() {
+ return generateStoreDataObj;
+ }
+
+ /**
+ * @param generateStoreDataObj the generateStoreDataObj to set
+ */
+ public void setGenerateStoreDataObj(boolean generateStoreDataObj) {
+ this.generateStoreDataObj = generateStoreDataObj;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend
index e6edc1372..4f568e58f 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend
@@ -19,6 +19,7 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.generator.IGenerator
import org.eclipse.etrice.generator.generic.PrepareFileSystem
+import org.eclipse.etrice.generator.java.Main
@Singleton
class MainGen implements IGenerator {
@@ -27,6 +28,7 @@ class MainGen implements IGenerator {
@Inject EnumerationTypeGen enumTypeGen
@Inject ProtocolClassGen protocolClassGen
@Inject ActorClassGen actorClassGen
+ @Inject ActorClassDataGen actorClassDataGen
@Inject OptionalActorInterfaceGen optionalActorInterfaceGen
@Inject OptionalActorFactoryGen optionalActorFactoryGen
@Inject NodeGen nodeGen
@@ -47,6 +49,8 @@ class MainGen implements IGenerator {
enumTypeGen.doGenerate(e)
protocolClassGen.doGenerate(e)
actorClassGen.doGenerate(e)
+ if (Main::settings.isGenerateStoreDataObj)
+ actorClassDataGen.doGenerate(e)
optionalActorInterfaceGen.doGenerate(e)
optionalActorFactoryGen.doGenerate(e)
nodeGen.doGenerate(e);
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
index 2522d8ab1..c4df9521e 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
@@ -69,6 +69,17 @@ class StateMachineGen extends GenericStateMachineGenerator {
}
'''}
+ /**
+ * if {@code -storeDataObj} is set then a call to {@code finalAction()} is generated
+ */
+ override finalAction() {
+ '''
+ «IF Main::settings.generateStoreDataObj»
+ finalAction();
+ «ENDIF»
+ '''
+ }
+
def getHistorySize(ExpandedActorClass xpac) {
xpac.actorClass.getAllBaseStates().size+2
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java
new file mode 100644
index 000000000..53deaaaf7
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.java
@@ -0,0 +1,231 @@
+/**
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ */
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashMap;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.WiredStructureClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Extension;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+
+@Singleton
+@SuppressWarnings("all")
+public class ActorClassDataGen {
+ @Inject
+ private IGeneratorFileIo fileIO;
+
+ @Inject
+ @Extension
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private IDataConfiguration dataConfigExt;
+
+ @Inject
+ @Extension
+ private ProcedureHelpers _procedureHelpers;
+
+ public void doGenerate(final Root root) {
+ HashMap<ActorClass,WiredActorClass> _hashMap = new HashMap<ActorClass, WiredActorClass>();
+ final HashMap<ActorClass,WiredActorClass> ac2wired = _hashMap;
+ EList<WiredStructureClass> _wiredInstances = root.getWiredInstances();
+ final Function1<WiredStructureClass,Boolean> _function = new Function1<WiredStructureClass,Boolean>() {
+ public Boolean apply(final WiredStructureClass w) {
+ return Boolean.valueOf((w instanceof WiredActorClass));
+ }
+ };
+ Iterable<WiredStructureClass> _filter = IterableExtensions.<WiredStructureClass>filter(_wiredInstances, _function);
+ final Procedure1<WiredStructureClass> _function_1 = new Procedure1<WiredStructureClass>() {
+ public void apply(final WiredStructureClass w) {
+ ActorClass _actorClass = ((WiredActorClass) w).getActorClass();
+ ac2wired.put(_actorClass, ((WiredActorClass) w));
+ }
+ };
+ IterableExtensions.<WiredStructureClass>forEach(_filter, _function_1);
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ final WiredActorClass wired = ac2wired.get(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_actorClass_1);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _path = this._roomExtensions.getPath(_actorClass_2);
+ final String path = (_generationTargetPath + _path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ String _path_1 = this._roomExtensions.getPath(_actorClass_4);
+ final String infopath = (_generationInfoPath + _path_1);
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _name = _actorClass_5.getName();
+ String file = (_name + "_DataObject.java");
+ CharSequence _generate = this.generate(root, xpac, wired);
+ this.fileIO.generateFile("generating ActorClass implementation", path, infopath, file, _generate);
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final ExpandedActorClass xpac, final WiredActorClass wired) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ String _name = ac.getName();
+ final String clsname = (_name + "_DataObject");
+ final EList<RoomModel> models = root.getReferencedModels(ac);
+ String _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ ActorClass _base_1 = ac.getBase();
+ String _name_1 = _base_1.getName();
+ String _plus = ("extends " + _name_1);
+ String _plus_1 = (_plus + "_DataObject ");
+ _xifexpression = _plus_1;
+ } else {
+ _xifexpression = "";
+ }
+ final String baseClass = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(ac);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IActorClassDataObject;");
+ _builder.newLine();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name_2 = model.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("public class ");
+ _builder.append(clsname, "");
+ _builder.append(" ");
+ _builder.append(baseClass, "");
+ _builder.append("implements IActorClassDataObject {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\t");
+ _builder.append("// state and history");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private int state;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private int[] history;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine_1 = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine_1) {
+ _builder.append("\t");
+ _builder.append("public int getState() {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("return state;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void setState(int state) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("this.state = state;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int[] getHistory() {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("return history;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void setHistory(int[] history) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("this.history = history;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ EList<Attribute> _attributes_2 = ac.getAttributes();
+ String _name_3 = ac.getName();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
+ _builder.append(_attributeSettersGettersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index c9b5f5737..a6a990bb9 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -59,6 +59,7 @@ import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
@Singleton
@SuppressWarnings("all")
@@ -184,39 +185,37 @@ public class ActorClassGen extends GenericActorClassGenerator {
_xifexpression_1 = "";
}
final String impPersist = _xifexpression_1;
+ String _name_2 = ac.getName();
+ final String dataObjClass = (_name_2 + "_DataObject");
String _xifexpression_2 = null;
ActorClass _base = ac.getBase();
boolean _notEquals = (!Objects.equal(_base, null));
if (_notEquals) {
ActorClass _base_1 = ac.getBase();
- String _name_2 = _base_1.getName();
- _xifexpression_2 = _name_2;
+ String _name_3 = _base_1.getName();
+ _xifexpression_2 = _name_3;
} else {
String _xifexpression_3 = null;
String _attribute = RoomHelpers.getAttribute(ac, "ActorBaseClass", "class");
boolean _isEmpty = _attribute.isEmpty();
- if (_isEmpty) {
- _xifexpression_3 = "ActorClassBase";
- } else {
+ boolean _not = (!_isEmpty);
+ if (_not) {
String _attribute_1 = RoomHelpers.getAttribute(ac, "ActorBaseClass", "class");
_xifexpression_3 = _attribute_1;
+ } else {
+ String _xifexpression_4 = null;
+ GlobalSettings _settings_1 = Main.getSettings();
+ boolean _isGenerateStoreDataObj = _settings_1.isGenerateStoreDataObj();
+ if (_isGenerateStoreDataObj) {
+ _xifexpression_4 = "ActorClassFinalActionBase";
+ } else {
+ _xifexpression_4 = "ActorClassBase";
+ }
+ _xifexpression_3 = _xifexpression_4;
}
_xifexpression_2 = _xifexpression_3;
}
final String baseClass = _xifexpression_2;
- String _xifexpression_4 = null;
- String _attribute_2 = RoomHelpers.getAttribute(ac, "ActorBaseClass", "class");
- boolean _isEmpty_1 = _attribute_2.isEmpty();
- if (_isEmpty_1) {
- _xifexpression_4 = "org.eclipse.etrice.runtime.java.modelbase.ActorClassBase";
- } else {
- String _attribute_3 = RoomHelpers.getAttribute(ac, "ActorBaseClass", "package");
- String _plus_1 = (_attribute_3 + ".");
- String _attribute_4 = RoomHelpers.getAttribute(ac, "ActorBaseClass", "class");
- String _plus_2 = (_plus_1 + _attribute_4);
- _xifexpression_4 = _plus_2;
- }
- final String baseClassImport = _xifexpression_4;
StringConcatenation _builder = new StringConcatenation();
_builder.append("package ");
String _package = this._roomExtensions.getPackage(ac);
@@ -226,16 +225,16 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
{
List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac);
- boolean _isEmpty_2 = _dynConfigReadAttributes.isEmpty();
- boolean _not = (!_isEmpty_2);
- if (_not) {
+ boolean _isEmpty_1 = _dynConfigReadAttributes.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
_builder.append("import org.eclipse.etrice.runtime.java.config.DynConfigLock;");
_builder.newLine();
}
}
{
- GlobalSettings _settings_1 = Main.getSettings();
- boolean _isGeneratePersistenceInterface_1 = _settings_1.isGeneratePersistenceInterface();
+ GlobalSettings _settings_2 = Main.getSettings();
+ boolean _isGeneratePersistenceInterface_1 = _settings_2.isGeneratePersistenceInterface();
if (_isGeneratePersistenceInterface_1) {
_builder.append("import org.eclipse.etrice.runtime.java.modelbase.IPersistable;");
_builder.newLine();
@@ -247,23 +246,20 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
}
}
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
- _builder.newLine();
- _builder.append("import ");
- _builder.append(baseClassImport, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ {
+ GlobalSettings _settings_3 = Main.getSettings();
+ boolean _isGenerateStoreDataObj_1 = _settings_3.isGenerateStoreDataObj();
+ if (_isGenerateStoreDataObj_1) {
+ _builder.append("import java.util.Arrays;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.*;");
_builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.DataPortBase;");
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;");
_builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.append("import org.eclipse.etrice.runtime.java.debugging.*;");
_builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
_builder.newLine();
_builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;");
_builder.newLine();
@@ -271,8 +267,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
{
for(final RoomModel model : models) {
_builder.append("import ");
- String _name_3 = model.getName();
- _builder.append(_name_3, "");
+ String _name_4 = model.getName();
+ _builder.append(_name_4, "");
_builder.append(".*;");
_builder.newLineIfNotEmpty();
}
@@ -284,8 +280,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
String _package_1 = this._roomExtensions.getPackage(pc);
_builder.append(_package_1, "");
_builder.append(".");
- String _name_4 = pc.getName();
- _builder.append(_name_4, "");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, "");
_builder.append(".*;");
_builder.newLineIfNotEmpty();
}
@@ -307,8 +303,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append(_package_2, "");
_builder.append(".");
ActorClass _type_1 = sub.getType();
- String _name_5 = _type_1.getName();
- _builder.append(_name_5, "");
+ String _name_6 = _type_1.getName();
+ _builder.append(_name_6, "");
_builder.append("Interface;");
_builder.newLineIfNotEmpty();
}
@@ -358,8 +354,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
String _portClassName = this._roomExtensions.getPortClassName(ep);
_builder.append(_portClassName, " ");
_builder.append(" ");
- String _name_6 = ep.getName();
- _builder.append(_name_6, " ");
+ String _name_7 = ep.getName();
+ _builder.append(_name_7, " ");
_builder.append(" = null;");
_builder.newLineIfNotEmpty();
}
@@ -377,8 +373,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
String _portClassName_1 = this._roomExtensions.getPortClassName(sap);
_builder.append(_portClassName_1, " ");
_builder.append(" ");
- String _name_7 = sap.getName();
- _builder.append(_name_7, " ");
+ String _name_8 = sap.getName();
+ _builder.append(_name_8, " ");
_builder.append(" = null;");
_builder.newLineIfNotEmpty();
}
@@ -397,8 +393,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append(_portClassName_2, " ");
_builder.append(" ");
SPP _spp = svc.getSpp();
- String _name_8 = _spp.getName();
- _builder.append(_name_8, " ");
+ String _name_9 = _spp.getName();
+ _builder.append(_name_9, " ");
_builder.append(" = null;");
_builder.newLineIfNotEmpty();
}
@@ -422,8 +418,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.append("protected ");
ActorClass _type_2 = sub_1.getType();
- String _name_9 = _type_2.getName();
- _builder.append(_name_9, " ");
+ String _name_10 = _type_2.getName();
+ _builder.append(_name_10, " ");
{
int _multiplicity = sub_1.getMultiplicity();
boolean _notEquals_1 = (_multiplicity != 1);
@@ -432,8 +428,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
}
_builder.append("Interface ");
- String _name_10 = sub_1.getName();
- _builder.append(_name_10, " ");
+ String _name_11 = sub_1.getName();
+ _builder.append(_name_11, " ");
_builder.append(" = null;");
_builder.newLineIfNotEmpty();
}
@@ -463,8 +459,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
for(final Attribute a : _dynConfigReadAttributes_1) {
_builder.append("\t");
_builder.append("private DynConfigLock lock_");
- String _name_11 = a.getName();
- _builder.append(_name_11, " ");
+ String _name_12 = a.getName();
+ _builder.append(_name_12, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
@@ -487,8 +483,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("\t\t");
_builder.append("setClassName(\"");
- String _name_12 = ac.getName();
- _builder.append(_name_12, " ");
+ String _name_13 = ac.getName();
+ _builder.append(_name_13, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
@@ -506,17 +502,17 @@ public class ActorClassGen extends GenericActorClassGenerator {
List<Port> _endPorts_1 = RoomHelpers.getEndPorts(ac);
for(final Port ep_1 : _endPorts_1) {
_builder.append("\t\t");
- String _name_13 = ep_1.getName();
- _builder.append(_name_13, " ");
+ String _name_14 = ep_1.getName();
+ _builder.append(_name_14, " ");
_builder.append(" = new ");
String _portClassName_3 = this._roomExtensions.getPortClassName(ep_1);
_builder.append(_portClassName_3, " ");
_builder.append("(this, \"");
- String _name_14 = ep_1.getName();
- _builder.append(_name_14, " ");
- _builder.append("\", IFITEM_");
String _name_15 = ep_1.getName();
_builder.append(_name_15, " ");
+ _builder.append("\", IFITEM_");
+ String _name_16 = ep_1.getName();
+ _builder.append(_name_16, " ");
_builder.append(");");
_builder.newLineIfNotEmpty();
}
@@ -530,17 +526,17 @@ public class ActorClassGen extends GenericActorClassGenerator {
EList<SAP> _serviceAccessPoints_1 = ac.getServiceAccessPoints();
for(final SAP sap_1 : _serviceAccessPoints_1) {
_builder.append("\t\t");
- String _name_16 = sap_1.getName();
- _builder.append(_name_16, " ");
+ String _name_17 = sap_1.getName();
+ _builder.append(_name_17, " ");
_builder.append(" = new ");
String _portClassName_4 = this._roomExtensions.getPortClassName(sap_1);
_builder.append(_portClassName_4, " ");
_builder.append("(this, \"");
- String _name_17 = sap_1.getName();
- _builder.append(_name_17, " ");
- _builder.append("\", IFITEM_");
String _name_18 = sap_1.getName();
_builder.append(_name_18, " ");
+ _builder.append("\", IFITEM_");
+ String _name_19 = sap_1.getName();
+ _builder.append(_name_19, " ");
_builder.append(", 0);");
_builder.newLineIfNotEmpty();
}
@@ -555,19 +551,19 @@ public class ActorClassGen extends GenericActorClassGenerator {
for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
_builder.append("\t\t");
SPP _spp_1 = svc_1.getSpp();
- String _name_19 = _spp_1.getName();
- _builder.append(_name_19, " ");
+ String _name_20 = _spp_1.getName();
+ _builder.append(_name_20, " ");
_builder.append(" = new ");
String _portClassName_5 = this._roomExtensions.getPortClassName(svc_1);
_builder.append(_portClassName_5, " ");
_builder.append("(this, \"");
SPP _spp_2 = svc_1.getSpp();
- String _name_20 = _spp_2.getName();
- _builder.append(_name_20, " ");
+ String _name_21 = _spp_2.getName();
+ _builder.append(_name_21, " ");
_builder.append("\", IFITEM_");
SPP _spp_3 = svc_1.getSpp();
- String _name_21 = _spp_3.getName();
- _builder.append(_name_21, " ");
+ String _name_22 = _spp_3.getName();
+ _builder.append(_name_22, " ");
_builder.append(");");
_builder.newLineIfNotEmpty();
}
@@ -585,12 +581,12 @@ public class ActorClassGen extends GenericActorClassGenerator {
boolean _equals = Objects.equal(_refType, ReferenceType.OPTIONAL);
if (_equals) {
_builder.append("\t\t");
- String _name_22 = sub_2.getName();
- _builder.append(_name_22, " ");
+ String _name_23 = sub_2.getName();
+ _builder.append(_name_23, " ");
_builder.append(" = new ");
ActorClass _type_3 = sub_2.getType();
- String _name_23 = _type_3.getName();
- _builder.append(_name_23, " ");
+ String _name_24 = _type_3.getName();
+ _builder.append(_name_24, " ");
{
int _multiplicity_1 = sub_2.getMultiplicity();
boolean _notEquals_2 = (_multiplicity_1 != 1);
@@ -599,8 +595,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
}
_builder.append("Interface(this, \"");
- String _name_24 = sub_2.getName();
- _builder.append(_name_24, " ");
+ String _name_25 = sub_2.getName();
+ _builder.append(_name_25, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
} else {
@@ -614,14 +610,14 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("; ++i) {");
_builder.newLineIfNotEmpty();
{
- GlobalSettings _settings_2 = Main.getSettings();
- boolean _generateMSCInstrumentation = _settings_2.generateMSCInstrumentation();
+ GlobalSettings _settings_4 = Main.getSettings();
+ boolean _generateMSCInstrumentation = _settings_4.generateMSCInstrumentation();
if (_generateMSCInstrumentation) {
_builder.append("\t\t");
_builder.append("\t");
_builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \"");
- String _name_25 = sub_2.getName();
- _builder.append(_name_25, " ");
+ String _name_26 = sub_2.getName();
+ _builder.append(_name_26, " ");
_builder.append(GenmodelConstants.INDEX_SEP, " ");
_builder.append("\"+i);");
_builder.newLineIfNotEmpty();
@@ -631,11 +627,11 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.append("new ");
ActorClass _type_4 = sub_2.getType();
- String _name_26 = _type_4.getName();
- _builder.append(_name_26, " ");
- _builder.append("(this, \"");
- String _name_27 = sub_2.getName();
+ String _name_27 = _type_4.getName();
_builder.append(_name_27, " ");
+ _builder.append("(this, \"");
+ String _name_28 = sub_2.getName();
+ _builder.append(_name_28, " ");
_builder.append(GenmodelConstants.INDEX_SEP, " ");
_builder.append("\"+i);");
_builder.newLineIfNotEmpty();
@@ -644,13 +640,13 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
} else {
{
- GlobalSettings _settings_3 = Main.getSettings();
- boolean _generateMSCInstrumentation_1 = _settings_3.generateMSCInstrumentation();
+ GlobalSettings _settings_5 = Main.getSettings();
+ boolean _generateMSCInstrumentation_1 = _settings_5.generateMSCInstrumentation();
if (_generateMSCInstrumentation_1) {
_builder.append("\t\t");
_builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \"");
- String _name_28 = sub_2.getName();
- _builder.append(_name_28, " ");
+ String _name_29 = sub_2.getName();
+ _builder.append(_name_29, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
}
@@ -658,11 +654,11 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t\t");
_builder.append("new ");
ActorClass _type_5 = sub_2.getType();
- String _name_29 = _type_5.getName();
- _builder.append(_name_29, " ");
- _builder.append("(this, \"");
- String _name_30 = sub_2.getName();
+ String _name_30 = _type_5.getName();
_builder.append(_name_30, " ");
+ _builder.append("(this, \"");
+ String _name_31 = sub_2.getName();
+ _builder.append(_name_31, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
}
@@ -729,15 +725,15 @@ public class ActorClassGen extends GenericActorClassGenerator {
{
boolean _or_1 = false;
List<Attribute> _dynConfigReadAttributes_2 = this.dataConfigExt.getDynConfigReadAttributes(ac);
- boolean _isEmpty_3 = _dynConfigReadAttributes_2.isEmpty();
- boolean _not_1 = (!_isEmpty_3);
- if (_not_1) {
+ boolean _isEmpty_2 = _dynConfigReadAttributes_2.isEmpty();
+ boolean _not_2 = (!_isEmpty_2);
+ if (_not_2) {
_or_1 = true;
} else {
List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac);
- boolean _isEmpty_4 = _dynConfigWriteAttributes.isEmpty();
- boolean _not_2 = (!_isEmpty_4);
- _or_1 = (_not_1 || _not_2);
+ boolean _isEmpty_3 = _dynConfigWriteAttributes.isEmpty();
+ boolean _not_3 = (!_isEmpty_3);
+ _or_1 = (_not_2 || _not_3);
}
if (_or_1) {
{
@@ -745,8 +741,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
for(final Attribute a_1 : _dynConfigReadAttributes_3) {
_builder.append("\t\t");
_builder.append("lock_");
- String _name_31 = a_1.getName();
- _builder.append(_name_31, " ");
+ String _name_32 = a_1.getName();
+ _builder.append(_name_32, " ");
_builder.append(" = new DynConfigLock();");
_builder.newLineIfNotEmpty();
}
@@ -762,8 +758,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
EList<Attribute> _attributes_3 = ac.getAttributes();
List<Attribute> _dynConfigReadAttributes_4 = this.dataConfigExt.getDynConfigReadAttributes(ac);
List<Attribute> _minus = this._roomExtensions.<Attribute>minus(_attributes_3, _dynConfigReadAttributes_4);
- String _name_32 = ac.getName();
- CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_32);
+ String _name_33 = ac.getName();
+ CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_33);
_builder.append(_attributeSettersGettersImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -782,9 +778,9 @@ public class ActorClassGen extends GenericActorClassGenerator {
for(final Port ep_2 : _endPorts_2) {
_builder.append("\t");
String _portClassName_6 = this._roomExtensions.getPortClassName(ep_2);
- String _name_33 = ep_2.getName();
- String _name_34 = ac.getName();
- CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_33, _name_34);
+ String _name_34 = ep_2.getName();
+ String _name_35 = ac.getName();
+ CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_34, _name_35);
_builder.append(_terImplementation, " ");
_builder.newLineIfNotEmpty();
}
@@ -794,9 +790,9 @@ public class ActorClassGen extends GenericActorClassGenerator {
for(final SAP sap_2 : _serviceAccessPoints_2) {
_builder.append("\t");
String _portClassName_7 = this._roomExtensions.getPortClassName(sap_2);
- String _name_35 = sap_2.getName();
- String _name_36 = ac.getName();
- CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_35, _name_36);
+ String _name_36 = sap_2.getName();
+ String _name_37 = ac.getName();
+ CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_36, _name_37);
_builder.append(_terImplementation_1, " ");
_builder.newLineIfNotEmpty();
}
@@ -807,9 +803,9 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
String _portClassName_8 = this._roomExtensions.getPortClassName(svc_2);
SPP _spp_4 = svc_2.getSpp();
- String _name_37 = _spp_4.getName();
- String _name_38 = ac.getName();
- CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_37, _name_38);
+ String _name_38 = _spp_4.getName();
+ String _name_39 = ac.getName();
+ CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_38, _name_39);
_builder.append(_terImplementation_2, " ");
_builder.newLineIfNotEmpty();
}
@@ -820,8 +816,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
{
boolean _overridesStop = this._roomExtensions.overridesStop(ac);
- boolean _not_3 = (!_overridesStop);
- if (_not_3) {
+ boolean _not_4 = (!_overridesStop);
+ if (_not_4) {
{
if (manualBehavior) {
_builder.append("\t");
@@ -862,14 +858,14 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
- String _name_39 = ac.getName();
- String _destructorCall = this._procedureHelpers.destructorCall(_name_39);
+ String _name_40 = ac.getName();
+ String _destructorCall = this._procedureHelpers.destructorCall(_name_40);
_builder.append(_destructorCall, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
{
- GlobalSettings _settings_4 = Main.getSettings();
- boolean _generateMSCInstrumentation_2 = _settings_4.generateMSCInstrumentation();
+ GlobalSettings _settings_6 = Main.getSettings();
+ boolean _generateMSCInstrumentation_2 = _settings_6.generateMSCInstrumentation();
if (_generateMSCInstrumentation_2) {
_builder.append("\t");
_builder.append("\t");
@@ -887,8 +883,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
}
} else {
- GlobalSettings _settings_5 = Main.getSettings();
- boolean _generateMSCInstrumentation_3 = _settings_5.generateMSCInstrumentation();
+ GlobalSettings _settings_7 = Main.getSettings();
+ boolean _generateMSCInstrumentation_3 = _settings_7.generateMSCInstrumentation();
if (_generateMSCInstrumentation_3) {
_builder.append("\t");
_builder.append("public void destroy() {");
@@ -925,8 +921,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.append("\t");
_builder.append("if (ifitem==");
- String _name_40 = ifitem.getName();
- _builder.append(_name_40, " ");
+ String _name_41 = ifitem.getName();
+ _builder.append(_name_41, " ");
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -942,8 +938,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t\t");
_builder.append("case ");
ProtocolClass _protocolClass = RoomHelpers.getProtocolClass(msg);
- String _name_41 = _protocolClass.getName();
- _builder.append(_name_41, " ");
+ String _name_42 = _protocolClass.getName();
+ _builder.append(_name_42, " ");
_builder.append(".");
String _xifexpression_6 = null;
boolean _isIncoming = this._roomExtensions.isIncoming(msg);
@@ -953,8 +949,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_xifexpression_6 = "OUT_";
}
_builder.append(_xifexpression_6, " ");
- String _name_42 = msg.getName();
- _builder.append(_name_42, " ");
+ String _name_43 = msg.getName();
+ _builder.append(_name_43, " ");
_builder.append(":");
_builder.newLineIfNotEmpty();
{
@@ -976,11 +972,11 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t\t");
_builder.append("\t");
_builder.append("on_");
- String _name_43 = ifitem.getName();
- _builder.append(_name_43, " ");
- _builder.append("_");
- String _name_44 = msg.getName();
+ String _name_44 = ifitem.getName();
_builder.append(_name_44, " ");
+ _builder.append("_");
+ String _name_45 = msg.getName();
+ _builder.append(_name_45, " ");
_builder.append("(ifitem");
{
VarDecl _data_1 = msg.getData();
@@ -988,8 +984,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
if (_notEquals_6) {
_builder.append(", ");
VarDecl _data_2 = msg.getData();
- String _name_45 = _data_2.getName();
- _builder.append(_name_45, " ");
+ String _name_46 = _data_2.getName();
+ _builder.append(_name_46, " ");
}
}
_builder.append(");");
@@ -1036,11 +1032,11 @@ public class ActorClassGen extends GenericActorClassGenerator {
for(final Message msg_1 : _incoming_1) {
_builder.append("\t");
_builder.append("protected void on_");
- String _name_46 = ifitem_1.getName();
- _builder.append(_name_46, " ");
- _builder.append("_");
- String _name_47 = msg_1.getName();
+ String _name_47 = ifitem_1.getName();
_builder.append(_name_47, " ");
+ _builder.append("_");
+ String _name_48 = msg_1.getName();
+ _builder.append(_name_48, " ");
_builder.append("(InterfaceItemBase ifitem");
{
VarDecl _data_4 = msg_1.getData();
@@ -1073,8 +1069,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLineIfNotEmpty();
} else {
StateGraph _stateMachine = xpac.getStateMachine();
- boolean _isEmpty_5 = RoomHelpers.isEmpty(_stateMachine);
- if (_isEmpty_5) {
+ boolean _isEmpty_4 = RoomHelpers.isEmpty(_stateMachine);
+ if (_isEmpty_4) {
_builder.append("\t");
_builder.append("//--------------------- no state machine");
_builder.newLine();
@@ -1099,8 +1095,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
}
{
- GlobalSettings _settings_6 = Main.getSettings();
- boolean _isGeneratePersistenceInterface_2 = _settings_6.isGeneratePersistenceInterface();
+ GlobalSettings _settings_8 = Main.getSettings();
+ boolean _isGeneratePersistenceInterface_2 = _settings_8.isGeneratePersistenceInterface();
if (_isGeneratePersistenceInterface_2) {
_builder.append("\t");
_builder.newLine();
@@ -1200,6 +1196,366 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
}
}
+ {
+ GlobalSettings _settings_9 = Main.getSettings();
+ boolean _isGenerateStoreDataObj_2 = _settings_9.isGenerateStoreDataObj();
+ if (_isGenerateStoreDataObj_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected void store(IActorClassDataObject obj) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("if (!(obj instanceof ");
+ _builder.append(dataObjClass, " ");
+ _builder.append("))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("return;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(dataObjClass, " ");
+ _builder.append(" dataObject = (");
+ _builder.append(dataObjClass, " ");
+ _builder.append(") obj;");
+ _builder.newLineIfNotEmpty();
+ {
+ ActorClass _base_2 = ac.getBase();
+ boolean _notEquals_9 = (!Objects.equal(_base_2, null));
+ if (_notEquals_9) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("super.store(dataObject);");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _hasNonEmptyStateMachine_1 = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine_1) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("dataObject.setState(getState());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("dataObject.setHistory(Arrays.copyOf(history, history.length));");
+ _builder.newLine();
+ }
+ }
+ {
+ EList<Attribute> _attributes_4 = ac.getAttributes();
+ boolean _isEmpty_5 = _attributes_4.isEmpty();
+ boolean _not_5 = (!_isEmpty_5);
+ if (_not_5) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<Attribute> _attributes_5 = ac.getAttributes();
+ for(final Attribute att : _attributes_5) {
+ {
+ RefableType _type_6 = att.getType();
+ DataType _type_7 = _type_6.getType();
+ boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(_type_7);
+ if (_isEnumerationOrPrimitive) {
+ {
+ int _size = att.getSize();
+ boolean _greaterThan_1 = (_size > 1);
+ if (_greaterThan_1) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("dataObject.set");
+ String _name_49 = att.getName();
+ String _firstUpper = StringExtensions.toFirstUpper(_name_49);
+ _builder.append(_firstUpper, " ");
+ _builder.append("(Arrays.copyOf(");
+ String _name_50 = att.getName();
+ _builder.append(_name_50, " ");
+ _builder.append(", ");
+ String _name_51 = att.getName();
+ _builder.append(_name_51, " ");
+ _builder.append(".length));");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("dataObject.set");
+ String _name_52 = att.getName();
+ String _firstUpper_1 = StringExtensions.toFirstUpper(_name_52);
+ _builder.append(_firstUpper_1, " ");
+ _builder.append("(");
+ String _name_53 = att.getName();
+ _builder.append(_name_53, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ {
+ int _size_1 = att.getSize();
+ boolean _greaterThan_2 = (_size_1 > 1);
+ if (_greaterThan_2) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ RefableType _type_8 = att.getType();
+ DataType _type_9 = _type_8.getType();
+ String _name_54 = _type_9.getName();
+ _builder.append(_name_54, " ");
+ _builder.append("[] arr = Arrays.copyOf(");
+ String _name_55 = att.getName();
+ _builder.append(_name_55, " ");
+ _builder.append(", ");
+ String _name_56 = att.getName();
+ _builder.append(_name_56, " ");
+ _builder.append(".length);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("dataObject.set");
+ String _name_57 = att.getName();
+ String _firstUpper_2 = StringExtensions.toFirstUpper(_name_57);
+ _builder.append(_firstUpper_2, " ");
+ _builder.append("(arr);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("dataObject.set");
+ String _name_58 = att.getName();
+ String _firstUpper_3 = StringExtensions.toFirstUpper(_name_58);
+ _builder.append(_firstUpper_3, " ");
+ _builder.append("(");
+ String _name_59 = att.getName();
+ _builder.append(_name_59, " ");
+ _builder.append(".deepCopy());");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected void restore(IActorClassDataObject obj) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("if (!(obj instanceof ");
+ _builder.append(dataObjClass, " ");
+ _builder.append("))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("return;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(dataObjClass, " ");
+ _builder.append(" dataObject = (");
+ _builder.append(dataObjClass, " ");
+ _builder.append(") obj;");
+ _builder.newLineIfNotEmpty();
+ {
+ ActorClass _base_3 = ac.getBase();
+ boolean _notEquals_10 = (!Objects.equal(_base_3, null));
+ if (_notEquals_10) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("super.restore(dataObject);");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _hasNonEmptyStateMachine_2 = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine_2) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("setState(dataObject.getState());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("history = Arrays.copyOf(dataObject.getHistory(), dataObject.getHistory().length);");
+ _builder.newLine();
+ }
+ }
+ {
+ EList<Attribute> _attributes_6 = ac.getAttributes();
+ boolean _isEmpty_6 = _attributes_6.isEmpty();
+ boolean _not_6 = (!_isEmpty_6);
+ if (_not_6) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<Attribute> _attributes_7 = ac.getAttributes();
+ for(final Attribute att_1 : _attributes_7) {
+ {
+ RefableType _type_10 = att_1.getType();
+ DataType _type_11 = _type_10.getType();
+ boolean _isEnumerationOrPrimitive_1 = this._typeHelpers.isEnumerationOrPrimitive(_type_11);
+ if (_isEnumerationOrPrimitive_1) {
+ {
+ int _size_2 = att_1.getSize();
+ boolean _greaterThan_3 = (_size_2 > 1);
+ if (_greaterThan_3) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("set");
+ String _name_60 = att_1.getName();
+ String _firstUpper_4 = StringExtensions.toFirstUpper(_name_60);
+ _builder.append(_firstUpper_4, " ");
+ _builder.append("(Arrays.copyOf(dataObject.get");
+ String _name_61 = att_1.getName();
+ String _firstUpper_5 = StringExtensions.toFirstUpper(_name_61);
+ _builder.append(_firstUpper_5, " ");
+ _builder.append("(), ");
+ String _name_62 = att_1.getName();
+ _builder.append(_name_62, " ");
+ _builder.append(".length));");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("set");
+ String _name_63 = att_1.getName();
+ String _firstUpper_6 = StringExtensions.toFirstUpper(_name_63);
+ _builder.append(_firstUpper_6, " ");
+ _builder.append("(dataObject.get");
+ String _name_64 = att_1.getName();
+ String _firstUpper_7 = StringExtensions.toFirstUpper(_name_64);
+ _builder.append(_firstUpper_7, " ");
+ _builder.append("());");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ {
+ int _size_3 = att_1.getSize();
+ boolean _greaterThan_4 = (_size_3 > 1);
+ if (_greaterThan_4) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ RefableType _type_12 = att_1.getType();
+ DataType _type_13 = _type_12.getType();
+ String _name_65 = _type_13.getName();
+ _builder.append(_name_65, " ");
+ _builder.append("[] arr = Arrays.copyOf(dataObject.get");
+ String _name_66 = att_1.getName();
+ String _firstUpper_8 = StringExtensions.toFirstUpper(_name_66);
+ _builder.append(_firstUpper_8, " ");
+ _builder.append("(), ");
+ String _name_67 = att_1.getName();
+ _builder.append(_name_67, " ");
+ _builder.append(".length);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("set");
+ String _name_68 = att_1.getName();
+ String _firstUpper_9 = StringExtensions.toFirstUpper(_name_68);
+ _builder.append(_firstUpper_9, " ");
+ _builder.append("(arr);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("set");
+ String _name_69 = att_1.getName();
+ String _firstUpper_10 = StringExtensions.toFirstUpper(_name_69);
+ _builder.append(_firstUpper_10, " ");
+ _builder.append("(dataObject.get");
+ String _name_70 = att_1.getName();
+ String _firstUpper_11 = StringExtensions.toFirstUpper(_name_70);
+ _builder.append(_firstUpper_11, " ");
+ _builder.append("().deepCopy());");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected ");
+ _builder.append(dataObjClass, " ");
+ _builder.append(" newDataObject() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("return new ");
+ _builder.append(dataObjClass, " ");
+ _builder.append("();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
_builder.append("};");
_builder.newLine();
_xblockexpression = (_builder);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
index 13533b9af..19438456e 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
@@ -17,9 +17,12 @@ 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.Main;
+import org.eclipse.etrice.generator.java.gen.ActorClassDataGen;
import org.eclipse.etrice.generator.java.gen.ActorClassGen;
import org.eclipse.etrice.generator.java.gen.DataClassGen;
import org.eclipse.etrice.generator.java.gen.EnumerationTypeGen;
+import org.eclipse.etrice.generator.java.gen.GlobalSettings;
import org.eclipse.etrice.generator.java.gen.NodeGen;
import org.eclipse.etrice.generator.java.gen.NodeRunnerGen;
import org.eclipse.etrice.generator.java.gen.OptionalActorFactoryGen;
@@ -44,6 +47,9 @@ public class MainGen implements IGenerator {
private ActorClassGen actorClassGen;
@Inject
+ private ActorClassDataGen actorClassDataGen;
+
+ @Inject
private OptionalActorInterfaceGen optionalActorInterfaceGen;
@Inject
@@ -73,6 +79,11 @@ public class MainGen implements IGenerator {
this.enumTypeGen.doGenerate(e);
this.protocolClassGen.doGenerate(e);
this.actorClassGen.doGenerate(e);
+ GlobalSettings _settings = Main.getSettings();
+ boolean _isGenerateStoreDataObj = _settings.isGenerateStoreDataObj();
+ if (_isGenerateStoreDataObj) {
+ this.actorClassDataGen.doGenerate(e);
+ }
this.optionalActorInterfaceGen.doGenerate(e);
this.optionalActorFactoryGen.doGenerate(e);
this.nodeGen.doGenerate(e);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
index 76a5e5430..bc55b71bd 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
@@ -143,6 +143,22 @@ public class StateMachineGen extends GenericStateMachineGenerator {
return _xblockexpression;
}
+ /**
+ * if {@code -storeDataObj} is set then a call to {@code finalAction()} is generated
+ */
+ public CharSequence finalAction() {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ GlobalSettings _settings = Main.getSettings();
+ boolean _isGenerateStoreDataObj = _settings.isGenerateStoreDataObj();
+ if (_isGenerateStoreDataObj) {
+ _builder.append("finalAction();");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
public int getHistorySize(final ExpandedActorClass xpac) {
ActorClass _actorClass = xpac.getActorClass();
List<State> _allBaseStates = RoomHelpers.getAllBaseStates(_actorClass);
diff --git a/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorConfigTab.java b/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorConfigTab.java
index 5f6b89de2..e2408f799 100644
--- a/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorConfigTab.java
+++ b/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorConfigTab.java
@@ -28,9 +28,12 @@ import org.eclipse.swt.widgets.Composite;
public class JavaGeneratorConfigTab extends GeneratorConfigTab {
public static final String PERSIST = "Persist";
+ public static final String DATA_OBJ = "DataObj";
private Button genPersist;
+ private Button genDataObj;
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
@@ -48,6 +51,10 @@ public class JavaGeneratorConfigTab extends GeneratorConfigTab {
genPersist = createCheckButton(mainComposite, "generate persistence interface");
genPersist.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
genPersist.addSelectionListener(new UpdateConfig());
+
+ genDataObj = createCheckButton(mainComposite, "generate store to/from POJO data objects");
+ genDataObj.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
+ genDataObj.addSelectionListener(new UpdateConfig());
}
/* (non-Javadoc)
@@ -59,6 +66,7 @@ public class JavaGeneratorConfigTab extends GeneratorConfigTab {
try {
genPersist.setSelection(configuration.getAttribute(PERSIST, false));
+ genPersist.setSelection(configuration.getAttribute(DATA_OBJ, false));
}
catch (CoreException e) {
e.printStackTrace();
@@ -73,5 +81,6 @@ public class JavaGeneratorConfigTab extends GeneratorConfigTab {
super.performApply(configuration);
configuration.setAttribute(PERSIST, genPersist.getSelection());
+ configuration.setAttribute(DATA_OBJ, genDataObj.getSelection());
}
}
diff --git a/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorLaunchConfigurationDelegate.java b/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorLaunchConfigurationDelegate.java
index 84e227a9f..a0f27d86a 100644
--- a/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.etrice.generator.launch.java/src/org/eclipse/etrice/generator/launch/java/JavaGeneratorLaunchConfigurationDelegate.java
@@ -34,6 +34,10 @@ public class JavaGeneratorLaunchConfigurationDelegate extends GeneratorLaunchCon
if (configuration.getAttribute(JavaGeneratorConfigTab.PERSIST, false)) {
argString.append(" "+Main.OPTION_GEN_PERSIST);
}
+
+ if (configuration.getAttribute(JavaGeneratorConfigTab.DATA_OBJ, false)) {
+ argString.append(" "+Main.OPTION_GEN_STORE_DATA_OBJ);
+ }
}
/* (non-Javadoc)
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend
index efc2d06b2..4bb0f2e49 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend
@@ -142,7 +142,7 @@ class ProjectFileFragments {
<artifactId>«mdlName»</artifactId>
<version>1.0.0</version>
<build>
- <sourceDirectory>src-gen</sourceDirectory>
+ <sourceDirectory>src,src-gen</sourceDirectory>
<resources>
<resource>
<directory>src-gen</directory>
diff --git a/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java b/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java
index e49bd85f3..1a8f96c17 100644
--- a/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java
+++ b/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java
@@ -317,7 +317,7 @@ public class ProjectFileFragments {
_builder.append("<build>");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("<sourceDirectory>src-gen</sourceDirectory>");
+ _builder.append("<sourceDirectory>src,src-gen</sourceDirectory>");
_builder.newLine();
_builder.append("\t\t");
_builder.append("<resources>");
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
index 702caa223..d4e054262 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
@@ -339,10 +339,18 @@ class GenericStateMachineGenerator {
«stateType» next = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain«IF handleEvents», ifitem, generic_data«ENDIF»);
next = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next«IF usesHdlr», is_handler«ENDIF»);
setState(«langExt.selfPointer(true)»next);
+ «finalAction()»
}
}
}
'''}
+
+ /**
+ * empty, but may be overridden
+ */
+ def finalAction() {
+ ''''''
+ }
/**
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
index 9fb716c72..21097f599 100644
--- 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
@@ -1094,6 +1094,10 @@ public class GenericStateMachineGenerator {
_builder.append(_selfPointer_12, " ");
_builder.append("next);");
_builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ CharSequence _finalAction = this.finalAction();
+ _builder.append(_finalAction, " ");
+ _builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
@@ -1108,6 +1112,14 @@ public class GenericStateMachineGenerator {
}
/**
+ * empty, but may be overridden
+ */
+ public CharSequence finalAction() {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+
+ /**
* helper method which generates the state switch.
* Asynchronous, data driven and event driven state machines are distinguished
*
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 0ed85157b..b0789c023 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.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
index a664291f3..6e1c8793e 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/releng/org.eclipse.etrice.parent/pom.xml b/releng/org.eclipse.etrice.parent/pom.xml
index aecaf0a08..69303554e 100644
--- a/releng/org.eclipse.etrice.parent/pom.xml
+++ b/releng/org.eclipse.etrice.parent/pom.xml
@@ -60,39 +60,21 @@
<developers>
<developer>
<name>Thomas Schuetz</name>
- <email>ts@protos.de</email>
- <organization>Protos Software GmbH</organization>
- <organizationUrl>http://www.protos.de/index.php/en</organizationUrl>
</developer>
<developer>
<name>Henrik Rentz-Reichert</name>
- <email>hrr@protos.de</email>
- <organization>Protos Software GmbH</organization>
- <organizationUrl>http://www.protos.de/index.php/en</organizationUrl>
</developer>
<developer>
<name>Thomas Jung</name>
- <email>tj@protos.de</email>
- <organization>Protos Software GmbH</organization>
- <organizationUrl>http://www.protos.de/index.php/en</organizationUrl>
</developer>
<developer>
<name>Juergen Haug</name>
- <email>juergen.markus.haug@student.uni-augsburg.de</email>
- <organization>Protos Software GmbH</organization>
- <organizationUrl>http://www.protos.de/index.php/en</organizationUrl>
</developer>
<developer>
<name>Eyrak Paen</name>
- <email>ep@protos.de</email>
- <organization>Protos Software GmbH</organization>
- <organizationUrl>http://www.protos.de/index.php/en</organizationUrl>
</developer>
<developer>
<name>Peter Karlitschek</name>
- <email>Peter.Karlitschek@draeger.com</email>
- <organization>Draeger Medical GmbH</organization>
- <organizationUrl>http://www.draeger.com</organizationUrl>
</developer>
</developers>
@@ -133,6 +115,84 @@
<module>../../runtime/org.eclipse.etrice.runtime.java</module>
</modules>
+ <profiles>
+ <profile>
+ <id>fast</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ </profile>
+ <profile>
+ <id>full</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9.1</version>
+ <configuration>
+ <tags>
+ <tag>
+ <name>generated</name>
+ <placement>a</placement>
+ <head>Generated:</head>
+ </tag>
+ <tag>
+ <name>ordered</name>
+ <placement>X</placement>
+ <head>Ordered:</head>
+ </tag>
+ <tag>
+ <name>model</name>
+ <placement>X</placement>
+ <head>Model:</head>
+ </tag>
+ <tag>
+ <name>parameter</name>
+ <placement>X</placement>
+ <head>Parameter:</head>
+ </tag>
+ </tags>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.eclipse.etrice</groupId>
+ <artifactId>org.eclipse.etrice.core.genmodel</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.eclipse.etrice</groupId>
+ <artifactId>org.eclipse.etrice.generator</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<build>
<plugins>
<plugin>
@@ -141,68 +201,6 @@
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- <configuration>
- <tags>
- <tag>
- <name>generated</name>
- <placement>a</placement>
- <head>Generated:</head>
- </tag>
- <tag>
- <name>ordered</name>
- <placement>X</placement>
- <head>Ordered:</head>
- </tag>
- <tag>
- <name>model</name>
- <placement>X</placement>
- <head>Model:</head>
- </tag>
- <tag>
- <name>parameter</name>
- <placement>X</placement>
- <head>Parameter:</head>
- </tag>
- </tags>
- <additionalDependencies>
- <additionalDependency>
- <groupId>org.eclipse.etrice</groupId>
- <artifactId>org.eclipse.etrice.core.genmodel</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </additionalDependency>
- <additionalDependency>
- <groupId>org.eclipse.etrice</groupId>
- <artifactId>org.eclipse.etrice.generator</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </additionalDependency>
- </additionalDependencies>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
<pluginManagement>
<plugins>
diff --git a/runtime/org.eclipse.etrice.runtime.java/install_org.eclipse.etrice.runtime.java.launch b/runtime/org.eclipse.etrice.runtime.java/install_org.eclipse.etrice.runtime.java.launch
index 5e11784fa..7732d84d6 100644
--- a/runtime/org.eclipse.etrice.runtime.java/install_org.eclipse.etrice.runtime.java.launch
+++ b/runtime/org.eclipse.etrice.runtime.java/install_org.eclipse.etrice.runtime.java.launch
@@ -4,12 +4,12 @@
<stringAttribute key="M2_GOALS" value="clean install"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
-<stringAttribute key="M2_PROFILES" value=""/>
+<stringAttribute key="M2_PROFILES" value="full"/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
-<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="C:/Users/hrentz/Documents/protos/Entwicklung/Projekte/protos/eTrice/workspace/eTrice0.3.0/eTrice-mvn-rt/org.eclipse.etrice.runtime.java"/>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/org.eclipse.etrice.runtime.java}"/>
</launchConfiguration>
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java
new file mode 100644
index 000000000..3fad7b002
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+
+/**
+ * A base class that is used by the generator if the {@code -storeDataObj} switch is used.
+ * After a state transition is completed {@link #finalAction()} is called which in turn
+ * executes the {@link FinalAction} which was stored using {@link #setFinalAction(FinalAction)}.
+ * If the final action is derived from {@link SingleFinalAction} then it is invoked only once.
+ * If it is derived from {@link RepeatedFinalAction} it is invoked after every state transition
+ * until {@link #setFinalAction(FinalAction)} is called with {@code null}.
+ *
+ * @author Henrik Rentz-Reichert
+ */
+public abstract class ActorClassFinalActionBase extends ActorClassBase {
+
+ /**
+ * The interface for final actions (called after a state transition is completed).
+ * This interface inherits from {@link Runnable}.
+ *
+ * @author Henrik Rentz-Reichert
+ */
+ public interface FinalAction extends Runnable {}
+
+ /**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+ public interface SingleFinalAction extends FinalAction {}
+ public interface RepeatedFinalAction extends FinalAction {}
+
+ private FinalAction finalAction = null;
+
+ /**
+ * @param parent
+ * @param name
+ */
+ public ActorClassFinalActionBase(IRTObject parent, String name) {
+ super(parent, name);
+ }
+
+ /**
+ * @param finalAction the final action to be executed or {@code null} if no action should be executed.
+ */
+ public void setFinalAction(FinalAction finalAction) {
+ this.finalAction = finalAction;
+ }
+
+ /**
+ * This method is called right after a state transition occurred. It executes the {@link FinalAction} that
+ * was set with {@link #setFinalAction(FinalAction)}. If the final action is a {@link SingleFinalAction}
+ * it is executed only once.
+ */
+ protected void finalAction() {
+ if (finalAction==null)
+ return;
+
+ finalAction.run();
+
+ if (finalAction instanceof SingleFinalAction)
+ finalAction = null;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java
new file mode 100644
index 000000000..a52fea781
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+/**
+ * All <actor class>_DataObjects implement this interface.
+ *
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IActorClassDataObject {
+
+}
diff --git a/tests/org.eclipse.etrice.generator.c.tests/make.xml b/tests/org.eclipse.etrice.generator.c.tests/make.xml
index 75186023b..d5d3dc8c9 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/make.xml
+++ b/tests/org.eclipse.etrice.generator.c.tests/make.xml
@@ -317,6 +317,42 @@
<arg value="-lpthread"/>
<arg value="-lrt"/>
</exec>
+
+ <!-- compile and link EnumTest -->
+ <mkdir dir="bin/EnumTest"/>
+ <exec dir="bin/EnumTest" executable="${gcc.path}/gcc" failonerror="true" output="${output}/build.txt">
+ <arg value="-I../../src-gen/"/>
+ <arg value="-I../../src-gen/room/basic/service/timing/"/>
+ <arg value="-I${c-runtime.path}/src/common"/>
+ <arg value="-I${c-runtime.path}/src/config"/>
+ <arg value="-I${c-runtime.path}/src/platforms/${runtime.platform}"/>
+ <arg value="-c"/>
+ <arg value="-g3"/>
+ <arg value="-O0"/>
+ <arg value="-Wall"/>
+ <!--<arg value="-ansi"/>-->
+ <arg value="../../src-gen/EnumTest/EnumTest_Top.c"/>
+ <arg value="../../src-gen/EnumTest/EnumUser.c"/>
+ <arg value="../../src-gen/EnumTest/node7_enTest.c"/>
+ <arg value="../../src-gen/EnumTest/node7_enTest_Runner.c"/>
+ <arg value="../../src-gen/EnumTest/PC.c"/>
+ <arg value="../../src-gen/room/basic/service/timing/ATimingService.c"/>
+ <arg value="../../src-gen/room/basic/service/timing/PTimer.c"/>
+ </exec>
+ <exec dir="bin/EnumTest" executable="${gcc.path}/gcc" failonerror="true" output="${output}/build.txt" append="true">
+ <arg value="-L${c-runtime.path}/bin"/>
+ <arg value="-oEnumTest.exe"/>
+ <arg value="EnumTest_Top.o"/>
+ <arg value="EnumUser.o"/>
+ <arg value="node7_enTest.o"/>
+ <arg value="node7_enTest_Runner.o"/>
+ <arg value="PC.o"/>
+
+ <!-- library has to be in the last position -->
+ <arg value="-lorg.eclipse.etrice.runtime.c"/>
+ <arg value="-lpthread"/>
+ <arg value="-lrt"/>
+ </exec>
<!-- compile and link SendingDataTestC -->
<mkdir dir="bin/SendingDataTestC"/>
@@ -465,6 +501,11 @@
<arg value="-run_as_test"/>
</exec>
<echo>end ChoicePointTest</echo>
+ <echo>start EnumTest</echo>
+ <exec dir="./" resolveexecutable="true" executable="./bin/EnumTest/EnumTest.exe">
+ <arg value="-run_as_test"/>
+ </exec>
+ <echo>end EnumTest</echo>
<!--
<echo>start SendingDataTestC</echo>
<exec dir="./" resolveexecutable="true" executable="./bin/SendingDataTestC/SendingDataTestC.exe">
@@ -512,6 +553,13 @@
<classpath refid="clspath"/>
</java>
+ <java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.c.tests.EnumTest"/>
+ <arg value="./tmp/EnumTest.etu"/>
+ <classpath refid="clspath"/>
+ </java>
+
<!--
<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
<arg value="-suite"/>
@@ -542,6 +590,7 @@
<target name="copy_results" depends="set_tr">
<move file="./tmp/HandlerTest.xml" tofile="./tmp/CHandlerTest.xml"/>
<move file="./tmp/ChoicePointTest.xml" tofile="./tmp/CChoicePointTest.xml"/>
+ <move file="./tmp/EnumTest.xml" tofile="./tmp/CEnumTest.xml"/>
<!--
<move file="./tmp/SendingDataTestC.xml" tofile="./tmp/CSendingDataTest.xml"/>
-->
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/StaticConfigTest_Java.room b/tests/org.eclipse.etrice.generator.common.tests/models/StaticConfigTest_Java.room
index 489a1a209..5c396a422 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/StaticConfigTest_Java.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/StaticConfigTest_Java.room
@@ -50,7 +50,7 @@ RoomModel StaticConfigTest {
State s1 {
entry {
"data_3.varCheck3(caseId);"
- "SubSystemClassBase subSystem = (SubSystemClassBase) ((ActorClassBase)getParent()).getParent();"
+ "SubSystemClassBase subSystem = (SubSystemClassBase) RTServices.getInstance().getSubSystem();"
"Testee_Super2_ac testee_super2 = (Testee_Super2_ac) subSystem.getInstance(\"/System_StaticConfigTest/subSystem/top/tester/testee_super2\");"
"int caseId_2 = testee_super2.getCaseId();"
"testee_super2.getReg_port().varCheck(caseId_2);"
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/StoreRestore.room b/tests/org.eclipse.etrice.generator.common.tests/models/StoreRestore.room
new file mode 100644
index 000000000..c67843e64
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/StoreRestore.room
@@ -0,0 +1,219 @@
+RoomModel StoreRestore {
+
+ SubSystemClass SubSystem_StoreRestore {
+ ActorRef top: StoreRestore_Top
+ LogicalThread defaultThread
+ }
+
+ ActorClass StoreRestore_Top {
+ Structure {
+ ActorRef tester: Tester
+ ActorRef testee: Testee
+ Binding tester.prt and testee.prt
+ }
+ Behavior { }
+ }
+
+ ActorClass Testee {
+ Interface {
+ Port prt: PC
+ }
+ Structure {
+ usercode1 { "import StoreRestore.ObjectHolder;" }
+
+ external Port prt
+
+ Attribute ival: int16
+ Attribute iarr [ 3 ]: int32
+ Attribute sdval: SomeData
+ Attribute sdarr [ 5 ]: SomeData
+ Attribute cdval: ComplexData
+ }
+ Behavior {
+ Operation doStore() {
+ "System.out.println(\"doStore()\");"
+ "IActorClassDataObject dataObject = newDataObject();"
+ "store(dataObject);"
+ "ObjectHolder.setObject(dataObject);"
+ }
+ Operation doRestore() {
+ "System.out.println(\"doRestore()\");"
+ "IActorClassDataObject dataObject = ObjectHolder.getObject();"
+ "restore(dataObject);"
+ }
+ StateMachine {
+ Transition tr0: my tp0 -> Restore {
+ triggers {
+ <restore: prt>
+ }
+ }
+ Transition init: initial -> Begin { }
+ Transition tr1: Begin -> Store {
+ triggers {
+ <step: prt>
+ }
+ }
+ Transition tr2: Store -> state2 {
+ triggers {
+ <step: prt>
+ }
+ }
+ Transition tr3: state2 -> state3 {
+ triggers {
+ <step: prt>
+ }
+ }
+ TransitionPoint tp0
+ State Begin {
+ entry {
+ "ival = 3;"
+ }
+ }
+ State Store {
+ entry {
+ "System.out.println(\"<|MODEL_LOCATION|>\");"
+ "setFinalAction(new SingleFinalAction() {"
+ "\tpublic void run() {"
+ "\t\tdoStore();"
+ "\t}"
+ "});"
+ }
+ }
+ State state2 {
+ entry {
+ "prt.valueIs(ival);"
+ ""
+ "ival = 123;"
+ }
+ }
+ State Restore {
+ entry {
+ "System.out.println(\"<|MODEL_LOCATION|>\");"
+ "setFinalAction(new SingleFinalAction() {"
+ "\tpublic void run() {"
+ "\t\tdoRestore();"
+ "\t}"
+ "});"
+ }
+ }
+ State state3 {
+ entry {
+ "ival = 456;"
+ ""
+ "prt.answer();"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass Tester {
+ Interface {
+ conjugated Port prt: PC
+ }
+ Structure {
+ external Port prt
+
+ Attribute caseId: int32
+ Attribute counter: int32 = "0"
+ }
+ Behavior {
+ Operation Tester() {
+ "caseId = etUnit_openAll(\"tmp\", \"StoreRestore\", \"org.eclipse.etrice.generator.common.tests.StoreRestore\", \"StoreRestore_case\");"
+ }
+ Operation ~Tester() {
+ "etUnit_closeAll(caseId);"
+ }
+
+ StateMachine {
+ Transition init: initial -> Prepare { }
+ Transition tr1: Loop2 -> cp cp0 {
+ triggers {
+ <answer: prt>
+ }
+ }
+ Transition tr2: cp cp0 -> Done
+ Transition tr3: cp cp0 -> Loop {
+ cond {
+ "++counter<10"
+ }
+ }
+ Transition tr0: Prepare -> Prepare2 {
+ triggers {
+ <valueIs: prt>
+ }
+ action {
+ "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, val);"
+ }
+ }
+ Transition tr4: Prepare2 -> Loop {
+ triggers {
+ <answer: prt>
+ }
+ }
+ Transition tr5: Loop -> Loop2 {
+ triggers {
+ <valueIs: prt>
+ }
+ action {
+ "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, val);"
+ }
+ }
+ ChoicePoint cp0
+ State Prepare {
+ entry {
+ "prt.step();"
+ "prt.step();"
+ }
+ }
+ State Loop {
+ entry {
+ "prt.restore();"
+ ""
+ "prt.step();"
+ "prt.step();"
+ }
+ }
+ State Done {
+ entry {
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ State Prepare2 {
+ entry {
+ "prt.step();"
+ }
+ }
+ State Loop2 {
+ entry {
+ "prt.step();"
+ }
+ }
+ }
+ }
+ }
+
+ ProtocolClass PC {
+ incoming {
+ Message step()
+ Message restore()
+ }
+ outgoing {
+ Message answer()
+ Message valueIs(val: int16)
+ }
+ }
+
+ DataClass SomeData {
+ Attribute ival: int16
+ Attribute iarr [ 3 ]: int32
+ }
+
+ DataClass ComplexData {
+ Attribute sdval: SomeData
+ Attribute sdarr [ 5 ]: SomeData
+ }
+
+ PrimitiveType int16: ptInteger -> short(Short) default "0"
+ PrimitiveType int32: ptInteger -> int(Integer) default "0"
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap
index f4251adae..a2f816eca 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap
@@ -64,5 +64,8 @@ MappingModel JavaGenTest {
SubSystemMapping enTest -> node18 {
ThreadMapping defaultThread -> DfltThread
}
+ SubSystemMapping stTest -> node19 {
+ ThreadMapping defaultThread -> DfltThread
+ }
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room
index c0dc2d191..9ee97a6a2 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room
@@ -3,6 +3,7 @@ RoomModel JavaGenTests {
import HandlerTest.* from "HandlerTest.room"
import ChoicePointTest.* from "ChoicePointTest.room"
import EnumTest.* from "EnumTest.room"
+ import StoreRestore.* from "StoreRestore.room"
import ChoicePointTestExtended.* from "ChoicePointTestExtended.room"
import PingPongThreadTest.* from "PingPongThreadTest.room"
import PingPongThreadTestReplPort.* from "PingPongThreadReplPortTest.room"
@@ -23,6 +24,7 @@ RoomModel JavaGenTests {
SubSystemRef hdTest: SubSystem_HandlerTest
SubSystemRef cpTest: SubSystem_CPTest
SubSystemRef enTest: SubSystem_EnumTest
+ SubSystemRef stTest: SubSystem_StoreRestore
SubSystemRef cpExtTest : SubSystem_CPTestExtended
SubSystemRef ppTest: SubSystem_PingPong
SubSystemRef prTest: SubSystem_PingPongReplPort
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys b/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys
index 640f5c120..f31b064b8 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys
@@ -19,6 +19,7 @@ PhysicalModel Standard {
NodeRef node16: PC
NodeRef node17: PC
NodeRef node18: PC
+ NodeRef node19: PC
}
NodeClass PC {
diff --git a/tests/org.eclipse.etrice.generator.java.tests/make.xml b/tests/org.eclipse.etrice.generator.java.tests/make.xml
index 879c31779..174ad1750 100644
--- a/tests/org.eclipse.etrice.generator.java.tests/make.xml
+++ b/tests/org.eclipse.etrice.generator.java.tests/make.xml
@@ -113,6 +113,7 @@
<arg value="${java.tests.model.path}/generator.java.tests.config"/>
<arg value="${java.tests.model.path}/generator.java.tests.etmap"/>
<arg value="-persistable"/>
+ <arg value="-storeDataObj"/>
<arg value="-gen_as_verbose"/>
<arg value="-msc_instr"/>
<classpath refid="clspath"/>
@@ -168,6 +169,12 @@
<classpath path="${bin.path};${runtime.path}/target/classes;${modellib.path}/bin"/>
</java>
<echo>end EnumTest</echo>
+ <echo>start StoreRestore</echo>
+ <java output="${output}/runStoreRestore.txt" classname="StoreRestore.Node_node19_stTestRunner" fork="true" failonerror="true">
+ <arg value="-headless"/>
+ <classpath path="${bin.path};${runtime.path}/target/classes;${modellib.path}/bin"/>
+ </java>
+ <echo>end StoreRestore</echo>
<echo>start ChoicePointTestExtended</echo>
<java output="${output}/runChoicePointTestExtended.txt" classname="ChoicePointTestExtended.Node_node17_cpExtTestRunner" fork="true" failonerror="true">
<arg value="-headless"/>
@@ -274,13 +281,27 @@
<arg value="./tmp/ChoicePointTest.etu"/>
<classpath refid="clspath"/>
</java>
+
+ <java output="${output}/convert.txt" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.EnumTest"/>
+ <arg value="./tmp/EnumTest.etu"/>
+ <classpath refid="clspath"/>
+ </java>
+
+ <java output="${output}/convert.txt" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.StoreRestore"/>
+ <arg value="./tmp/StoreRestore.etu"/>
+ <classpath refid="clspath"/>
+ </java>
<java output="${output}/convert.txt" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
- <arg value="-suite"/>
- <arg value="org.eclipse.etrice.generator.java.tests.ChoicePointTestExtended"/>
- <arg value="./tmp/ChoicePointTestExtended.etu"/>
- <classpath refid="clspath"/>
- </java>
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.ChoicePointTestExtended"/>
+ <arg value="./tmp/ChoicePointTestExtended.etu"/>
+ <classpath refid="clspath"/>
+ </java>
<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
<arg value="-suite"/>
@@ -393,6 +414,7 @@
-->
<target name="copy_results" depends="set_tr">
<move file="./tmp/HandlerTest.xml" tofile="./tmp/JavaHandlerTest.xml"/>
+ <move file="./tmp/EnumTest.xml" tofile="./tmp/JavaEnumTest.xml"/>
<move file="./tmp/ChoicePointTest.xml" tofile="./tmp/JavaChoicePointTest.xml"/>
<move file="./tmp/ChoicePointTestExtended.xml" tofile="./tmp/JavaChoicePointTestExtended.xml"/>
<move file="./tmp/StaticConfigTest.xml" tofile="./tmp/JavaStaticConfigTest.xml"/>
diff --git a/tests/org.eclipse.etrice.generator.java.tests/src/StoreRestore/ObjectHolder.java b/tests/org.eclipse.etrice.generator.java.tests/src/StoreRestore/ObjectHolder.java
new file mode 100644
index 000000000..18df93cb5
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/src/StoreRestore/ObjectHolder.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * hrentz (initial contribution)
+ *
+ *******************************************************************************/
+
+package StoreRestore;
+
+import org.eclipse.etrice.runtime.java.modelbase.IActorClassDataObject;
+
+/**
+ * @author hrentz
+ *
+ */
+public class ObjectHolder {
+
+ private static IActorClassDataObject object = null;
+
+ public static IActorClassDataObject getObject() {
+ return object;
+ }
+
+ public static void setObject(IActorClassDataObject object) {
+ ObjectHolder.object = object;
+ }
+}

Back to the top