Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-01-03 09:25:33 +0000
committerHenrik Rentz-Reichert2013-01-03 09:25:33 +0000
commite01f41a4c1f1db634918848db3bd67e2580afd7c (patch)
tree80fc0bf9bfe47d51bb22a3a9247f52114ce98e9f /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase
parent4c7b6eedad49db65aa6223ff24523d28d502b680 (diff)
downloadorg.eclipse.etrice-e01f41a4c1f1db634918848db3bd67e2580afd7c.tar.gz
org.eclipse.etrice-e01f41a4c1f1db634918848db3bd67e2580afd7c.tar.xz
org.eclipse.etrice-e01f41a4c1f1db634918848db3bd67e2580afd7c.zip
[generator.java, runtime.java] introduced IVariableService, recursive instantiation
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java62
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java53
2 files changed, 84 insertions, 31 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java
index c2d975598..b15f2ebce 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java
@@ -8,6 +8,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
+import org.eclipse.etrice.runtime.java.config.IVariableService;
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
@@ -65,12 +66,63 @@ public abstract class ActorClassBase extends EventReceiver implements IMessageRe
return null;
}
+ public SubSystemClassBase getSubSystem() {
+ // the sub system could be cached
+ // but it is rarely used so we just compute it every time
+ IRTObject p = getParent();
+ while (p!=null) {
+ if (p instanceof SubSystemClassBase)
+ return (SubSystemClassBase) p;
+ p = p.getParent();
+ }
+ return null;
+ }
+
+ public IVariableService getVariableService() {
+ // the variable service could be cached
+ // but variable service operations are costly so it doesn't hurt if we compute it every time
+ SubSystemClassBase ssc = getSubSystem();
+ if (ssc==null)
+ return null;
+
+ return ssc.getVariableService();
+ }
+
//--------------------- lifecycle functions
- // automatically generated lifecycle functions
- public abstract void init();
- public abstract void start();
- public abstract void stop();
- public abstract void destroy();
+ public void init() {
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).init();
+ }
+
+ initUser();
+ }
+
+ public void start() {
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).start();
+ }
+
+ startUser();
+ }
+
+ public void stop() {
+ stopUser();
+
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).stop();
+ }
+ }
+
+ public void destroy() {
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).destroy();
+ }
+ }
+
public abstract void executeInitTransition();
// not automatically generated lifecycle functions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
index 9d69b281a..39a0b703a 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
@@ -8,6 +8,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
+import org.eclipse.etrice.runtime.java.config.IVariableService;
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
@@ -24,13 +25,17 @@ import org.eclipse.etrice.runtime.java.modelbase.RTSystemProtocol.RTSystemConjPo
*
*/
public abstract class SubSystemClassBase extends RTObject implements IEventReceiver{
+
+ // variable service (is only instantiated if needed)
+ protected IVariableService variableService = null;
//--------------------- ports
protected RTSystemConjPort RTSystemPort = null;
//--------------------- interface item IDs
protected static final int IFITEM_RTSystemPort = 0;
- protected ActorClassBase[] instances = null;
+
+ // for tests only
private TestSemaphore testSem=null;
private int testErrorCode;
@@ -65,10 +70,10 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
instantiateActors();
// initialize all actor instances
- if (instances!=null)
- for (int i = 0; i < instances.length; i++) {
- instances[i].init();
- }
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).init();
+ }
}
public abstract void instantiateMessageServices();
@@ -91,19 +96,19 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
System.out.println("=== done stop MsgSvcCtrl");
// stop all actor instances
- if (instances!=null)
- for (int i = 0; i < instances.length; i++) {
- instances[i].stop();
- }
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).stop();
+ }
System.out.println("=== done stop actor instances");
}
public void destroy() {
System.out.println("*** MainComponent "+getInstancePath()+"::destroy ***");
- if (instances!=null)
- for (int i = 0; i < instances.length; i++) {
- instances[i].destroy();
- }
+ for (IRTObject child : getChildren()) {
+ if (child instanceof ActorClassBase)
+ ((ActorClassBase) child).destroy();
+ }
System.out.println("=== done destroy actor instances");
DebuggingService.getInstance().getAsyncLogger().close();
@@ -121,20 +126,12 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
public Address getFreeAddress(int msgSvcId) {
return getMsgService(msgSvcId).getFreeAddress();
}
-
- public ActorClassBase getInstance(int i) {
- if (instances==null || i<0 || i>= instances.length)
- return null;
-
- return instances[i];
- }
-
+
public ActorClassBase getInstance(String path) {
- if (instances!=null)
- for (int i = 0; i < instances.length; i++) {
- if (instances[i].getInstancePath().equals(path))
- return instances[i];
- }
+ IRTObject object = getObject(path);
+
+ if (object instanceof ActorClassBase)
+ return (ActorClassBase) object;
return null;
}
@@ -162,4 +159,8 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
Thread.yield();
}
}
+
+ public IVariableService getVariableService() {
+ return variableService;
+ }
}

Back to the top