Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-07-19 08:33:11 +0000
committerHenrik Rentz-Reichert2013-07-19 14:17:45 +0000
commitcdc96c87ec214de91c55b361ed712ddc1fbc75aa (patch)
treed60791202d316e30e1782227f34575111ea70f13 /runtime/org.eclipse.etrice.runtime.java/src
parent66e8825e8de6d01e9c182f8c6a7ec59bf2c13902 (diff)
downloadorg.eclipse.etrice-cdc96c87ec214de91c55b361ed712ddc1fbc75aa.tar.gz
org.eclipse.etrice-cdc96c87ec214de91c55b361ed712ddc1fbc75aa.tar.xz
org.eclipse.etrice-cdc96c87ec214de91c55b361ed712ddc1fbc75aa.zip
[runtime.java][generator.java] bug 413297: [runtime.java][generator.java] Let Java generator and and runtime support dynamic actors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=413297
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java317
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemOwner.java24
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IOptionalActorFactory.java28
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java45
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java46
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java65
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java107
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java53
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToThread.java24
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PortBase.java55
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/RTSystemProtocol.java104
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java38
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBroker.java38
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java102
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedPortBase.java65
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java68
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java51
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SystemMessage.java45
18 files changed, 938 insertions, 337 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 b15f2ebce..9ed2410a0 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
@@ -1,158 +1,159 @@
-/*******************************************************************************
- * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-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;
-import org.eclipse.etrice.runtime.java.messaging.Message;
-import org.eclipse.etrice.runtime.java.modelbase.RTSystemProtocol.RTSystemPort;
-
-
-/**
- * The base class for model actor classes.
- *
- * @author Thomas Schuetz
- *
- */
-public abstract class ActorClassBase extends EventReceiver implements IMessageReceiver {
-
- protected static final int EVT_SHIFT = 1000; // TODOHRR: use 256 or shift operation later
-
- protected static final int NO_STATE = 0;
- protected static final int STATE_TOP = 1;
-
- protected static final int NOT_CAUGHT = 0;
-
- protected static final int IFITEM_RTSystemPort = 0;
-
- private String className = "noname";
-
- /**
- * the current state
- */
- protected int state;
-
- protected RTSystemPort rtSystemPort = null;
-
- public ActorClassBase(IRTObject parent, String name) {
- super(parent, name);
-
- // own ports
- rtSystemPort = new RTSystemPort(this, IFITEM_RTSystemPort);
- }
-
- public String toString(){
- return "ActorClass(className="+className+", instancePath="+getInstancePath()+")";
- }
-
- public String getClassName() {
- return className;
- }
- public void setClassName(String className) {
- this.className = className;
- }
-
- @Override
- public Address getAddress() {
- // TODO: Actor should have its own address for services and debugging
- 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
- 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
- // are called, but with empty implementation -> can be overridden by user
- public void initUser(){}
- public void startUser(){}
- public void stopUser(){}
-
- @Override
- public void receive(Message msg) {
- }
-
- public int getState() {
- return state;
- }
-
- protected boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, Object generic_data){
- if (ifitem.getLocalId()!=0){
- return false;
- }
-
- switch (evt){
- case RTSystemServicesProtocol.IN_executeInitialTransition :
- executeInitTransition();
- break;
- case RTSystemServicesProtocol.IN_startDebugging :
- break;
- case RTSystemServicesProtocol.IN_stopDebugging :
- break;
- }
- return true;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+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;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.modelbase.RTSystemProtocol.RTSystemPort;
+
+
+/**
+ * The base class for model actor classes.
+ *
+ * @author Thomas Schuetz
+ *
+ */
+public abstract class ActorClassBase extends EventReceiver implements IMessageReceiver, IInterfaceItemOwner {
+
+ protected static final int EVT_SHIFT = 1000; // TODOHRR: use 256 or shift operation later
+
+ protected static final int NO_STATE = 0;
+ protected static final int STATE_TOP = 1;
+
+ protected static final int NOT_CAUGHT = 0;
+
+ protected static final int IFITEM_RTSystemPort = 0;
+
+ private String className = "noname";
+
+ /**
+ * the current state
+ */
+ protected int state;
+
+ protected RTSystemPort rtSystemPort = null;
+
+ public ActorClassBase(IRTObject parent, String name) {
+ super(parent, name);
+
+ // own ports
+ rtSystemPort = new RTSystemPort(this, IFITEM_RTSystemPort);
+ }
+
+ public String toString(){
+ return "ActorClass(className="+className+", instancePath="+getInstancePath()+")";
+ }
+
+ public String getClassName() {
+ return className;
+ }
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ @Override
+ public Address getAddress() {
+ // TODO: Actor should have its own address for services and debugging
+ 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
+ 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() {
+ super.destroy();
+ }
+
+ public abstract void executeInitTransition();
+
+ // not automatically generated lifecycle functions
+ // are called, but with empty implementation -> can be overridden by user
+ public void initUser(){}
+ public void startUser(){}
+ public void stopUser(){}
+
+ @Override
+ public void receive(Message msg) {
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ protected boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, Object generic_data){
+ if (ifitem.getLocalId()!=0){
+ return false;
+ }
+
+ switch (evt){
+ case RTSystemServicesProtocol.IN_executeInitialTransition :
+ executeInitTransition();
+ break;
+ case RTSystemServicesProtocol.IN_startDebugging :
+ break;
+ case RTSystemServicesProtocol.IN_stopDebugging :
+ break;
+ }
+ return true;
+ }
+
+ public IEventReceiver getEventReceiver() {
+ return this;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemOwner.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemOwner.java
new file mode 100644
index 000000000..4c8260c26
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemOwner.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IInterfaceItemOwner extends IRTObject {
+
+ IEventReceiver getEventReceiver();
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IOptionalActorFactory.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IOptionalActorFactory.java
new file mode 100644
index 000000000..cd954102b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IOptionalActorFactory.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IOptionalActorFactory {
+
+ /**
+ * @param replicatedOptionalActorInterfaceBase
+ * @param name
+ * @return
+ */
+ ActorClassBase create(OptionalActorInterfaceBase parent, String name);
+
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java
index e028b46f8..0899f67bc 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java
@@ -1,22 +1,23 @@
-/*******************************************************************************
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.modelbase;
-
-/**
- * @author Henrik Rentz-Reichert
- *
- */
-public interface IReplicatedInterfaceItem {
-
- InterfaceItemBase createSubInterfaceItem();
-}
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IReplicatedInterfaceItem {
+
+ InterfaceItemBase createSubInterfaceItem();
+ void removeItem(InterfaceItemBase item);
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java
index d3fe06780..3bc1bda46 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java
@@ -17,6 +17,7 @@ import org.eclipse.etrice.runtime.java.messaging.IMessageService;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
+import org.eclipse.etrice.runtime.java.modelbase.SystemMessage.Reason;
/**
* The abstract base class for actor class interface items like ports and saps.
@@ -26,18 +27,22 @@ import org.eclipse.etrice.runtime.java.messaging.RTServices;
*/
public abstract class InterfaceItemBase extends AbstractMessageReceiver {
- private IMessageReceiver ownMsgReceiver;
- private IMessageReceiver peerMsgReceiver;
+ private IReplicatedInterfaceItem replicator = null;
+ protected IMessageReceiver ownMsgReceiver;
+ protected IMessageReceiver peerMsgReceiver;
private int localId;
private int idx;
- private Address peerAddress = null;
+ protected Address peerAddress = null;
- public InterfaceItemBase (IEventReceiver actor, String name, int localId, int idx) {
- super(actor, name);
+ public InterfaceItemBase (IInterfaceItemOwner owner, String name, int localId, int idx) {
+ super(owner.getEventReceiver(), name);
this.localId = localId;
this.idx = idx;
+ if (owner instanceof IReplicatedInterfaceItem)
+ replicator = (IReplicatedInterfaceItem) owner;
+
int thread = getParent().getThreadForPath(getParent().getInstancePath());
if (thread>=0) {
IMessageService msgSvc = RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(thread);
@@ -67,6 +72,16 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
}
}
+
+ protected void handleSystemMessage(SystemMessage msg) {
+ switch (msg.getReason()) {
+ case DISCONNECT:
+ disconnect();
+ if (replicator!=null)
+ destroy();
+ break;
+ }
+ }
protected void connectWith(InterfaceItemBase peer) {
if (peer!=null) {
@@ -77,6 +92,16 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
peer.peerMsgReceiver = ownMsgReceiver;
}
}
+
+ protected void disconnect() {
+ peerMsgReceiver.receive(new SystemMessage(peerAddress, Reason.DISCONNECT));
+ peerAddress = null;
+ peerMsgReceiver = null;
+
+ if (replicator!=null) {
+ replicator.removeItem(this);
+ }
+ }
protected IMessageReceiver getMsgReceiver() {
return ownMsgReceiver;
@@ -105,4 +130,15 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
protected Address getPeerAddress() {
return peerAddress;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.messaging.RTObject#destroy()
+ */
+ @Override
+ protected void destroy() {
+ if (peerAddress!=null)
+ disconnect();
+
+ super.destroy();
+ }
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java
new file mode 100644
index 000000000..dcae4782d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.Message;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class InterfaceItemBroker extends InterfaceItemBase {
+
+ private InterfaceItemBase firstPeer = null;
+
+ public InterfaceItemBroker(IInterfaceItemOwner parent, String name, int localId) {
+ this(parent, name, localId, 0);
+ }
+
+ /**
+ * @param actor
+ * @param name
+ * @param localId
+ * @param idx
+ */
+ public InterfaceItemBroker(IInterfaceItemOwner parent, String name, int localId, int idx) {
+ super(parent, name, localId, idx);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.messaging.IMessageReceiver#receive(org.eclipse.etrice.runtime.java.messaging.Message)
+ */
+ @Override
+ public void receive(Message msg) {
+ // ignore this, will never receive a message
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase#connectWith(org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase)
+ */
+ @Override
+ protected void connectWith(InterfaceItemBase peer) {
+ if (firstPeer==null) {
+ firstPeer = peer;
+ super.connectWith(peer);
+ }
+ else {
+ // we are already connected, lets connect our new peer with the previous one
+ peer.peerAddress = firstPeer.getAddress();
+ peer.peerMsgReceiver = firstPeer.ownMsgReceiver;
+ firstPeer.peerAddress = peer.getAddress();
+ firstPeer.peerMsgReceiver = peer.ownMsgReceiver;
+ firstPeer = null;
+ }
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java
new file mode 100644
index 000000000..b842a7e40
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.etrice.runtime.java.messaging.RTObject;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public abstract class OptionalActorInterfaceBase extends RTObject implements IInterfaceItemOwner {
+
+ private String className;
+ private PathToPeers path2peers = null;
+ private String ownPath;
+ private int subtreeThread = -1;
+
+ /**
+ * @param parent
+ * @param name
+ */
+ protected OptionalActorInterfaceBase(IEventReceiver parent, String name, String clsname) {
+ super(parent, name);
+ className = clsname;
+ setOwnPath(getInstancePath());
+ }
+
+ /**
+ * Get list of peer paths
+ *
+ * @param path
+ * @return list of peer paths or {@code null} if not mapped
+ */
+ public List<String> getPeersForPath(String path) {
+ if (getPath2peers()==null)
+ return null;
+
+ path = path.substring(getOwnPath().length());
+ return getPath2peers().get(path);
+ }
+
+ /**
+ * get thread for path
+ * @param path
+ * @return thread id or {@code -1} if not mapped
+ */
+ public int getThreadForPath(String path) {
+ return subtreeThread;
+ }
+
+ public void setPath2peers(PathToPeers path2peers) {
+ this.path2peers = path2peers;
+ }
+
+ /**
+ * @return the path2peers
+ */
+ protected PathToPeers getPath2peers() {
+ return path2peers;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.IInterfaceItemOwner#getEventReceiver()
+ */
+ @Override
+ public IEventReceiver getEventReceiver() {
+ return (IEventReceiver) getParent();
+ }
+
+ /**
+ * @return the ownPath
+ */
+ public String getOwnPath() {
+ return ownPath;
+ }
+
+ /**
+ * @param ownPath the ownPath to set
+ */
+ public void setOwnPath(String ownPath) {
+ this.ownPath = ownPath;
+ }
+
+ protected int getSubtreeThread() {
+ return subtreeThread;
+ }
+
+ protected void setSubtreeThread(int subtreeThread) {
+ this.subtreeThread = subtreeThread;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java
new file mode 100644
index 000000000..0007b34ca
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class PathToPeers extends HashMap<String, ArrayList<String>> {
+
+ private static final long serialVersionUID = 1L;
+
+ public void put(String key, String value) {
+ ArrayList<String> list = get(key);
+ if (list==null) {
+ list = new ArrayList<String>();
+ put(key, list);
+ }
+ list.add(value);
+ }
+
+ public void put(String key, Collection<String> values) {
+ ArrayList<String> list = get(key);
+ if (list==null) {
+ list = new ArrayList<String>(values);
+ put(key, list);
+ }
+ else
+ list.addAll(values);
+ }
+
+ public void put(String key, String[] values) {
+ List<String> list = Arrays.asList(values);
+ put(key, list);
+ }
+
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToThread.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToThread.java
new file mode 100644
index 000000000..a71fadd40
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToThread.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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 java.util.HashMap;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class PathToThread extends HashMap<String, Integer> {
+
+ private static final long serialVersionUID = 1L;
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PortBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PortBase.java
index 5d1a0feab..90e13b9a9 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PortBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PortBase.java
@@ -1,27 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.modelbase;
-
-
-/**
- * An abstract base class for port instances.
- *
- * @author Thomas Schuetz
- *
- */
-public abstract class PortBase extends InterfaceItemBase {
-
- public PortBase (IEventReceiver actor, String name, int localId){
- super(actor, name, localId, 0);
- }
-
- public PortBase (IEventReceiver actor, String name, int localId, int idx){
- super(actor, name, localId, idx);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+
+
+/**
+ * An abstract base class for port instances.
+ *
+ * @author Thomas Schuetz
+ *
+ */
+public abstract class PortBase extends InterfaceItemBase {
+
+ public PortBase (IInterfaceItemOwner actor, String name, int localId){
+ super(actor, name, localId, 0);
+ }
+
+ public PortBase (IInterfaceItemOwner actor, String name, int localId, int idx){
+ super(actor, name, localId, idx);
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/RTSystemProtocol.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/RTSystemProtocol.java
index 2a9163160..574e4e022 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/RTSystemProtocol.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/RTSystemProtocol.java
@@ -1,52 +1,52 @@
-/*******************************************************************************
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.modelbase;
-
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
-import org.eclipse.etrice.runtime.java.modelbase.RTSystemServicesProtocol.RTSystemServicesProtocolConjReplPort;
-import org.eclipse.etrice.runtime.java.modelbase.RTSystemServicesProtocol.RTSystemServicesProtocolPort;
-
-/**
- * @author Henrik Rentz-Reichert
- *
- */
-public class RTSystemProtocol {
-
- private static final String RT_SYSTEM_PORT_NAME = "RTSystemPort";
-
- public static class RTSystemPort extends RTSystemServicesProtocolPort {
-
- public RTSystemPort(IEventReceiver actor, int localId) {
- super(actor, RT_SYSTEM_PORT_NAME, localId);
-
- // since we have no mapping for the system ports we connect them directly here
- IRTObject root = getRoot();
- if (root instanceof RTSystem)
- root = root.getChildren().get(0);
- IRTObject sysport = root.getChild(RT_SYSTEM_PORT_NAME);
- if (sysport!=null) {
- InterfaceItemBase peer = ((IReplicatedInterfaceItem) sysport).createSubInterfaceItem();
- connectWith(peer);
- }
- }
-
- }
-
- public static class RTSystemConjPort extends RTSystemServicesProtocolConjReplPort {
-
- public RTSystemConjPort(IEventReceiver actor, int localId) {
- super(actor, RT_SYSTEM_PORT_NAME, localId);
- }
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.modelbase.RTSystemServicesProtocol.RTSystemServicesProtocolConjReplPort;
+import org.eclipse.etrice.runtime.java.modelbase.RTSystemServicesProtocol.RTSystemServicesProtocolPort;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class RTSystemProtocol {
+
+ private static final String RT_SYSTEM_PORT_NAME = "RTSystemPort";
+
+ public static class RTSystemPort extends RTSystemServicesProtocolPort {
+
+ public RTSystemPort(IInterfaceItemOwner actor, int localId) {
+ super(actor, RT_SYSTEM_PORT_NAME, localId);
+
+ // since we have no mapping for the system ports we connect them directly here
+ IRTObject root = getRoot();
+ if (root instanceof RTSystem)
+ root = root.getChildren().get(0);
+ IRTObject sysport = root.getChild(RT_SYSTEM_PORT_NAME);
+ if (sysport!=null) {
+ InterfaceItemBase peer = ((IReplicatedInterfaceItem) sysport).createSubInterfaceItem();
+ connectWith(peer);
+ }
+ }
+
+ }
+
+ public static class RTSystemConjPort extends RTSystemServicesProtocolConjReplPort {
+
+ public RTSystemConjPort(IInterfaceItemOwner actor, int localId) {
+ super(actor, RT_SYSTEM_PORT_NAME, localId);
+ }
+
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java
index 10d8a6e4d..c223915fb 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java
@@ -13,6 +13,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
@@ -22,18 +23,19 @@ import org.eclipse.etrice.runtime.java.messaging.RTObject;
* @author Henrik Rentz-Reichert
*
*/
-public abstract class ReplicatedInterfaceItemBase extends RTObject implements IReplicatedInterfaceItem {
+public abstract class ReplicatedInterfaceItemBase extends RTObject implements IReplicatedInterfaceItem, IInterfaceItemOwner {
private int localId;
private ArrayList<InterfaceItemBase> items = new ArrayList<InterfaceItemBase>();
+ private LinkedList<Integer> releasedIndices = new LinkedList<Integer>();
/**
- * @param parent
+ * @param owner
* @param name
* @param localId
*/
- protected ReplicatedInterfaceItemBase(IEventReceiver parent, String name, int localId) {
- super(parent, name);
+ protected ReplicatedInterfaceItemBase(IInterfaceItemOwner owner, String name, int localId) {
+ super(owner, name);
this.localId = localId;
@@ -61,14 +63,29 @@ public abstract class ReplicatedInterfaceItemBase extends RTObject implements IR
*/
@Override
public InterfaceItemBase createSubInterfaceItem() {
- InterfaceItemBase item = createInterfaceItem((IEventReceiver)getParent(), getName()+items.size(), localId, items.size());
+ InterfaceItemBase item = createInterfaceItem(this, getName()+items.size(), localId, getFreeIndex());
items.add(item);
return item;
}
+ public void removeItem(InterfaceItemBase item) {
+ assert(item.getParent()==this): "is own child";
+ releasedIndices.push(item.getIdx());
+ items.remove(item);
+ }
+
+ private int getFreeIndex() {
+ if (releasedIndices.isEmpty())
+ return items.size();
+ else
+ return releasedIndices.pop();
+ }
+
public InterfaceItemBase getInterfaceItem(int idx) {
- if (0<=idx && idx<items.size())
- return items.get(idx);
+ for (InterfaceItemBase item : items) {
+ if (item.getIdx()==idx)
+ return item;
+ }
return null;
}
@@ -81,5 +98,10 @@ public abstract class ReplicatedInterfaceItemBase extends RTObject implements IR
return localId;
}
- protected abstract InterfaceItemBase createInterfaceItem(IEventReceiver rcv, String name, int lid, int idx);
+ @Override
+ public IEventReceiver getEventReceiver() {
+ return (IEventReceiver) getParent();
+ }
+
+ protected abstract InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx);
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBroker.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBroker.java
new file mode 100644
index 000000000..15a7e4591
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBroker.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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;
+
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class ReplicatedInterfaceItemBroker extends ReplicatedInterfaceItemBase {
+
+ /**
+ * @param parent
+ * @param name
+ * @param localId
+ */
+ public ReplicatedInterfaceItemBroker(IInterfaceItemOwner parent, String name, int localId) {
+ super(parent, name, localId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.ReplicatedInterfaceItemBase#createInterfaceItem(org.eclipse.etrice.runtime.java.messaging.IRTObject, java.lang.String, int, int)
+ */
+ @Override
+ protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) {
+ return new InterfaceItemBroker(this, name, lid, idx);
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java
new file mode 100644
index 000000000..884688f96
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class ReplicatedOptionalActorInterfaceBase extends OptionalActorInterfaceBase {
+
+ private static final char INDEX_SEP = ':';
+ private LinkedList<Integer> releasedIndices = new LinkedList<Integer>();
+ private ArrayList<ActorClassBase> actors = new ArrayList<ActorClassBase>();
+
+ /**
+ * @param parent
+ * @param name
+ * @param clsname
+ */
+ public ReplicatedOptionalActorInterfaceBase(IEventReceiver parent, String name, String clsname) {
+ super(parent, name, clsname);
+ }
+
+ protected int createOptionalActor(String actorClass, int thread) {
+ setSubtreeThread(thread);
+
+ // make sure the path is up to date
+ setOwnPath(getInstancePath());
+
+ IOptionalActorFactory factory = RTServices.getInstance().getSubSystem().getFactory(getClassName(), actorClass);
+ if (factory==null)
+ return -1;
+
+ // the factory will set our path2peers map
+ int index = getFreeIndex();
+ String name = getChildName(index);
+ ActorClassBase actor = factory.create(this, name);
+ if (actor==null)
+ return -1;
+
+ actors.add(actor);
+
+ return index;
+ }
+
+ /**
+ * @param idx
+ * @return
+ */
+ protected boolean destroyOptionalActor(int idx) {
+ IRTObject child = getChild(getChildName(idx));
+ if (!(child instanceof ActorClassBase))
+ return false;
+
+ ((ActorClassBase)child).destroy();
+ releasedIndices.push(idx);
+ actors.remove(child);
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.OptionalActorInterfaceBase#getPeersForPath(java.lang.String)
+ */
+ @Override
+ public List<String> getPeersForPath(String path) {
+ if (getPath2peers()==null)
+ return null;
+
+ path = path.substring(getOwnPath().length(), path.lastIndexOf(INDEX_SEP));
+ return getPath2peers().get(path);
+ }
+
+ public String getChildName(int idx) {
+ return getName()+INDEX_SEP+idx;
+ }
+
+ private int getFreeIndex() {
+ if (releasedIndices.isEmpty())
+ return actors.size();
+ else
+ return releasedIndices.pop();
+ }
+
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedPortBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedPortBase.java
index 048342281..deb7d4f5d 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedPortBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedPortBase.java
@@ -1,32 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.modelbase;
-
-/**
- * An abstract base class for instances of replicated ports.
- *
- * @author Henrik Rentz-Reichert
- *
- */
-public abstract class ReplicatedPortBase extends ReplicatedInterfaceItemBase {
-
- /**
- * @param parent
- * @param name
- * @param localId
- */
- public ReplicatedPortBase(IEventReceiver parent, String name, int localId) {
- super(parent, name, localId);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+
+/**
+ * An abstract base class for instances of replicated ports.
+ *
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public abstract class ReplicatedPortBase extends ReplicatedInterfaceItemBase {
+
+ /**
+ * @param parent
+ * @param name
+ * @param localId
+ */
+ public ReplicatedPortBase(IInterfaceItemOwner parent, String name, int localId) {
+ super(parent, name, localId);
+ }
+
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java
new file mode 100644
index 000000000..bb966300c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.RTServices;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class ScalarOptionalActorInterfaceBase extends OptionalActorInterfaceBase {
+
+ private ActorClassBase actor = null;
+
+ /**
+ * @param parent
+ * @param name
+ * @param clsname
+ */
+ public ScalarOptionalActorInterfaceBase(IEventReceiver parent, String name, String clsname) {
+ super(parent, name, clsname);
+ }
+
+ protected boolean createOptionalActor(String actorClass, int thread) {
+ if (actor!=null)
+ return false;
+
+ setSubtreeThread(thread);
+
+ // make sure the path is up to date
+ setOwnPath(getInstancePath());
+
+ // SubSystemClass.createOptionalActor() will set our PathTo* maps
+ IOptionalActorFactory factory = RTServices.getInstance().getSubSystem().getFactory(getClassName(), actorClass);
+ if (factory==null)
+ return false;
+
+ // the factory will set our path2peers map
+ actor = factory.create(this, getName());
+
+ return actor!=null;
+ }
+
+ /**
+ * @param idx
+ * @return
+ */
+ protected boolean destroyOptionalActor() {
+ if (actor==null)
+ return false;
+
+ actor.destroy();
+ actor = null;
+
+ return true;
+ }
+
+}
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 ce70ec889..0c207fed4 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,10 +8,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
import org.eclipse.etrice.runtime.java.config.IVariableService;
@@ -30,36 +27,7 @@ import org.eclipse.etrice.runtime.java.modelbase.RTSystemProtocol.RTSystemConjPo
* @author Henrik Rentz-Reichert
*
*/
-public abstract class SubSystemClassBase extends RTObject implements IEventReceiver{
-
- @SuppressWarnings("serial")
- private static class PathToThread extends HashMap<String, Integer> {}
- @SuppressWarnings("serial")
- private static class PathToPeers extends HashMap<String, ArrayList<String>> {
- public void put(String key, String value) {
- ArrayList<String> list = get(key);
- if (list==null) {
- list = new ArrayList<String>();
- put(key, list);
- }
- list.add(value);
- }
-
- public void put(String key, Collection<String> values) {
- ArrayList<String> list = get(key);
- if (list==null) {
- list = new ArrayList<String>(values);
- put(key, list);
- }
- else
- list.addAll(values);
- }
-
- public void put(String key, String[] values) {
- List<String> list = Arrays.asList(values);
- put(key, list);
- }
- }
+public abstract class SubSystemClassBase extends RTObject implements IEventReceiver, IInterfaceItemOwner {
// variable service (is only instantiated if needed)
protected IVariableService variableService = null;
@@ -259,8 +227,25 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
return path2peers.get(path);
}
+ /**
+ * Clears thread and peer mappings.
+ */
public void resetAll() {
path2peers.clear();
path2thread.clear();
}
+ /**
+ * @param optionalActorClass
+ * @param instanceActorClass
+ * @return
+ */
+ abstract public IOptionalActorFactory getFactory(String optionalActorClass, String instanceActorClass);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.IInterfaceItemOwner#getEventReceiver()
+ */
+ @Override
+ public IEventReceiver getEventReceiver() {
+ return this;
+ }
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SystemMessage.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SystemMessage.java
new file mode 100644
index 000000000..fc0b0976a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SystemMessage.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.Address;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class SystemMessage extends Message {
+
+ enum Reason {
+ DISCONNECT
+ }
+
+ private Reason reason;
+
+ /**
+ * @param address
+ */
+ public SystemMessage(Address address, Reason reason) {
+ super(address);
+ this.reason = reason;
+ }
+
+ /**
+ * @return the reason
+ */
+ public Reason getReason() {
+ return reason;
+ }
+
+}

Back to the top