Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java4
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java4
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java192
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java84
4 files changed, 148 insertions, 136 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java
index ab3ec7c26..5ba4115cf 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageDispatcher.java
@@ -38,7 +38,7 @@ public class MessageDispatcher extends RTObject implements IMessageReceiver {
node_map.put(receiver.getAddress().objectID, receiver);
}
else if(receiver.getAddress().threadID != address.threadID){
- thread_map.put(receiver.getAddress().objectID, receiver);
+ thread_map.put(receiver.getAddress().threadID, receiver);
}
else {
local_map.put(receiver.getAddress().objectID, receiver);
@@ -53,7 +53,7 @@ public class MessageDispatcher extends RTObject implements IMessageReceiver {
receiver = node_map.get(msg.getAddress().objectID);
}
else if(msg.getAddress().threadID != address.threadID){
- receiver = thread_map.get(msg.getAddress().objectID);
+ receiver = thread_map.get(msg.getAddress().threadID);
}
else {
// Same node, same thread -> local call Dispatch Map
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
index f709f3d87..a12463a3c 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
@@ -38,8 +38,7 @@ public class MessageService extends Thread implements IMessageReceiver,
this.parent = parent;
address = addr;
this.name = name;
- messageDispatcher = new MessageDispatcher(this, new Address(addr.nodeID,
- addr.threadID, addr.objectID + 1), "Dispatcher");
+ messageDispatcher = new MessageDispatcher(this, new Address(addr.nodeID,addr.threadID, addr.objectID + 1), "Dispatcher");
messageQueue = new MessageSeQueue(this, "Queue");
}
@@ -75,6 +74,7 @@ public class MessageService extends Thread implements IMessageReceiver,
}
else {
lastMessageTimestamp = System.currentTimeMillis();
+ //System.out.printf("%i. msgServ %i addr.Thread \n",address.threadID,msg.getAddress().threadID);
messageDispatcher.receive(msg);
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java
index f941cadee..20986d0ba 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java
@@ -1,90 +1,102 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.messaging;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The MessageServiceController controls lifecycle of and access to all MessageServices in one SubSystem
- *
- * @author Thomas Schuetz
- *
- */
-
-public class MessageServiceController {
-
- public MessageServiceController(/*IRTObject parent*/){
- // TODOTS: Who is parent of MessageServices and Controller?
- // this.parent = parent;
- messageServiceList = new ArrayList<MessageService>();
- }
-
- public void addMsgSrv(MessageService msgSrv){
- // TODOTS: Who is parent of MessageServices ?
- assert(msgSrv.getAddress().threadID == messageServiceList.size());
- messageServiceList.add(msgSrv);
- }
-
- public MessageService getMessageService(int threadID){
- assert(threadID < messageServiceList.size());
- return messageServiceList.get(threadID);
- }
-
-
-
- public void start() {
- // start all message services
- for (MessageService msgSrv : messageServiceList){
- msgSrv.start();
- // TODOTS: start in order of priorities
- }
- running = true;
- }
-
- public void stop() {
- terminate();
- waitTerminate();
- }
-
- private void terminate() {
- if (!running){
- return;
- }
- running = false;
-
- // terminate all message services
- for (MessageService msgSrv : messageServiceList){
- msgSrv.terminate();
- // TODOTS: stop in order of priorities
- }
- }
-
- /**
- * waitTerminate waits blocking for all MessageServices to terminate
- * ! not threadsafe !
- */
- public void waitTerminate() {
- for (MessageService msgSrv : messageServiceList){
- try {
- msgSrv.join();
- }
- catch (InterruptedException e1) {
- }
- }
- }
-
- private List<MessageService> messageServiceList = null;
-// private IRTObject parent = null;
- private boolean running = false;
-}
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.messaging;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The MessageServiceController controls lifecycle of and access to all MessageServices in one SubSystem
+ *
+ * @author Thomas Schuetz
+ *
+ */
+
+public class MessageServiceController {
+
+ public MessageServiceController(/*IRTObject parent*/){
+ // TODOTS: Who is parent of MessageServices and Controller?
+ // this.parent = parent;
+ messageServiceList = new ArrayList<MessageService>();
+ }
+
+ public void addMsgSvc(MessageService msgSvc){
+ // TODOTS: Who is parent of MessageServices ?
+ assert(msgSvc.getAddress().threadID == messageServiceList.size());
+ messageServiceList.add(msgSvc);
+ }
+
+ public MessageService getMsgSvc(int threadID){
+ assert(threadID < messageServiceList.size());
+ return messageServiceList.get(threadID);
+ }
+
+ //the connectAll method connects all messageServices
+ //it is included for test purposes
+ //currently it is not called
+ public void connectAll(){
+ for (int i=0; i < messageServiceList.size(); i++){
+ MessageDispatcher dispatcher = getMsgSvc(i).getMessageDispatcher();
+ for (int j=0;j < messageServiceList.size();j++){
+ if(i!=j){
+ dispatcher.addMessageReceiver(RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(j));
+ }
+ }
+ }
+ }
+
+ public void start() {
+ // start all message services
+ for (MessageService msgSvc : messageServiceList){
+ msgSvc.start();
+ // TODOTS: start in order of priorities
+ }
+ running = true;
+ }
+
+ public void stop() {
+ terminate();
+ waitTerminate();
+ }
+
+ private void terminate() {
+ if (!running){
+ return;
+ }
+ running = false;
+
+ // terminate all message services
+ for (MessageService msgSvc : messageServiceList){
+ msgSvc.terminate();
+ // TODOTS: stop in order of priorities
+ }
+ }
+
+ /**
+ * waitTerminate waits blocking for all MessageServices to terminate
+ * ! not threadsafe !
+ */
+ public void waitTerminate() {
+ for (MessageService msgSvc : messageServiceList){
+ try {
+ msgSvc.join();
+ }
+ catch (InterruptedException e1) {
+ }
+ }
+ }
+
+ private List<MessageService> messageServiceList = null;
+// private IRTObject parent = null;
+ private boolean running = false;
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java
index b029c7257..910aaf1e7 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.messaging;
-
-/**
- * RTServices is the single point of access to all runtime services in one SubSystem
- * e.g. MessageServices, DebuggingService, ...
- *
- * @author Thomas Schuetz
- *
- */
-public class RTServices {
-
- private RTServices(){
- messageServiceController = new MessageServiceController();
- }
-
- public static RTServices getInstance(){
- if (instance == null){
- instance = new RTServices();
- }
- return instance;
- }
-
- public MessageServiceController getMsgSrvCtrl(){
- assert(messageServiceController != null);
- return messageServiceController;
- }
-
- private static RTServices instance = null;
- private MessageServiceController messageServiceController = null;
-}
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.messaging;
+
+/**
+ * RTServices is the single point of access to all runtime services in one SubSystem
+ * e.g. MessageServices, DebuggingService, ...
+ *
+ * @author Thomas Schuetz
+ *
+ */
+public class RTServices {
+
+ private RTServices(){
+ messageServiceController = new MessageServiceController();
+ }
+
+ public static RTServices getInstance(){
+ if (instance == null){
+ instance = new RTServices();
+ }
+ return instance;
+ }
+
+ public MessageServiceController getMsgSvcCtrl(){
+ assert(messageServiceController != null);
+ return messageServiceController;
+ }
+
+ private static RTServices instance = null;
+ private MessageServiceController messageServiceController = null;
+}

Back to the top