Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging')
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h96
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp174
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h102
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp46
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h68
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp40
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h70
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp66
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h124
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp156
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h96
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp128
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h98
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp314
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h166
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp238
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h140
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp146
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h98
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp88
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h104
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp438
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h296
23 files changed, 1646 insertions, 1646 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
index f9d46a43f..7086a8ac3 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
@@ -1,48 +1,48 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef ABSTRACTMESSAGERECEIVER_H_
-#define ABSTRACTMESSAGERECEIVER_H_
-
-#include "common/messaging/Address.h"
-#include "common/messaging/IMessageReceiver.h"
-#include "common/messaging/RTObject.h"
-#include <string>
-
-namespace etRuntime {
-
-class AbstractMessageReceiver: public RTObject, public virtual IMessageReceiver {
-
-public:
- Address getAddress() const {
- return m_address;
- }
- virtual ~AbstractMessageReceiver() {};
-
-protected:
- AbstractMessageReceiver(IRTObject* parent, Address address, std::string name)
- : IMessageReceiver(),
- RTObject(parent, name),
- m_address(address)
- {
-
- }
-
-private:
- Address m_address;
-
- AbstractMessageReceiver();
-};
-
-
-}
-#endif /* ABSTRACTMESSAGERECEIVER_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef ABSTRACTMESSAGERECEIVER_H_
+#define ABSTRACTMESSAGERECEIVER_H_
+
+#include "common/messaging/Address.h"
+#include "common/messaging/IMessageReceiver.h"
+#include "common/messaging/RTObject.h"
+#include <string>
+
+namespace etRuntime {
+
+class AbstractMessageReceiver: public RTObject, public virtual IMessageReceiver {
+
+public:
+ Address getAddress() const {
+ return m_address;
+ }
+ virtual ~AbstractMessageReceiver() {};
+
+protected:
+ AbstractMessageReceiver(IRTObject* parent, Address address, std::string name)
+ : IMessageReceiver(),
+ RTObject(parent, name),
+ m_address(address)
+ {
+
+ }
+
+private:
+ Address m_address;
+
+ AbstractMessageReceiver();
+};
+
+
+}
+#endif /* ABSTRACTMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
index 529f5b72c..4adbf895e 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
@@ -1,87 +1,87 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "Address.h"
-#include <sstream>
-#include <iostream>
-
-namespace etRuntime {
-
-Address::Address(int nodeID, int threadID, int objectID) :
- m_nodeID(nodeID),
- m_threadID(threadID),
- m_objectID(objectID) {
-};
-
-Address::Address(const Address & right) :
- m_nodeID(right.m_nodeID),
- m_threadID(right.m_threadID),
- m_objectID(right.m_objectID) {
-};
-
-Address & Address::operator = (const Address& right) {
- if (this != &right) {
- m_nodeID = right.m_nodeID;
- m_threadID = right.m_threadID;
- m_objectID = right.m_objectID;
- }
- return *this;
-}
-
-bool Address::operator< (const Address& right) const {
- if (m_nodeID == right.m_nodeID) {
- if (m_threadID == right.m_threadID) {
- return (m_objectID < right.m_objectID);
- }
- else {
- return (m_threadID < right.m_threadID);
- }
- }
- else {
- return (m_nodeID < right.m_nodeID);
- }
-}
-
-Address::~Address() {
-}
-
-std::string Address::toString() const{
- std::stringstream strm;
- strm << "Address(nodeID=" << m_nodeID
- << ",threadID=" << m_threadID << ",objectID=" << m_objectID+")";
- return strm.str();
-}
-std::string Address::toID() const{
- std::stringstream strm;
- strm << m_nodeID << "_" << m_threadID << "_" << m_objectID;
- return strm.str();
-}
-
-Address Address::createInc(int i) {
- return Address(m_nodeID, m_threadID, m_objectID+i);
-}
-
-void Address::printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses){
- std::vector<std::vector<etRuntime::Address> >::const_iterator outerIt = addresses.begin();
- std::cout << "{" ;
- for (int i=0; outerIt!= addresses.end(); ++outerIt,++i) {
- std::cout << "{" ;
- std::vector<etRuntime::Address>::const_iterator it = (*outerIt).begin();
- for (int j=0; it!=(*outerIt).end(); ++it,++j) {
- std::cout << (*it).toID() << ":" << addresses[i][j].toID() << ",";
- }
- std::cout << "}" << std::endl;
- }
- std::cout << "}" << std::endl;
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "Address.h"
+#include <sstream>
+#include <iostream>
+
+namespace etRuntime {
+
+Address::Address(int nodeID, int threadID, int objectID) :
+ m_nodeID(nodeID),
+ m_threadID(threadID),
+ m_objectID(objectID) {
+};
+
+Address::Address(const Address & right) :
+ m_nodeID(right.m_nodeID),
+ m_threadID(right.m_threadID),
+ m_objectID(right.m_objectID) {
+};
+
+Address & Address::operator = (const Address& right) {
+ if (this != &right) {
+ m_nodeID = right.m_nodeID;
+ m_threadID = right.m_threadID;
+ m_objectID = right.m_objectID;
+ }
+ return *this;
+}
+
+bool Address::operator< (const Address& right) const {
+ if (m_nodeID == right.m_nodeID) {
+ if (m_threadID == right.m_threadID) {
+ return (m_objectID < right.m_objectID);
+ }
+ else {
+ return (m_threadID < right.m_threadID);
+ }
+ }
+ else {
+ return (m_nodeID < right.m_nodeID);
+ }
+}
+
+Address::~Address() {
+}
+
+std::string Address::toString() const{
+ std::stringstream strm;
+ strm << "Address(nodeID=" << m_nodeID
+ << ",threadID=" << m_threadID << ",objectID=" << m_objectID+")";
+ return strm.str();
+}
+std::string Address::toID() const{
+ std::stringstream strm;
+ strm << m_nodeID << "_" << m_threadID << "_" << m_objectID;
+ return strm.str();
+}
+
+Address Address::createInc(int i) {
+ return Address(m_nodeID, m_threadID, m_objectID+i);
+}
+
+void Address::printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses){
+ std::vector<std::vector<etRuntime::Address> >::const_iterator outerIt = addresses.begin();
+ std::cout << "{" ;
+ for (int i=0; outerIt!= addresses.end(); ++outerIt,++i) {
+ std::cout << "{" ;
+ std::vector<etRuntime::Address>::const_iterator it = (*outerIt).begin();
+ for (int j=0; it!=(*outerIt).end(); ++it,++j) {
+ std::cout << (*it).toID() << ":" << addresses[i][j].toID() << ",";
+ }
+ std::cout << "}" << std::endl;
+ }
+ std::cout << "}" << std::endl;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
index d26acf52d..870e25500 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef ADDRESS_H_
-#define ADDRESS_H_
-
-#include <string>
-#include <vector>
-
-namespace etRuntime {
-
-class Address {
- public:
- explicit Address(int nodeID=0, int threadID=0, int objectID=0);
- Address(const Address & right);
- ~Address();
-
- Address & operator = (const Address& right);
- bool operator< (const Address& right) const;
-
- std::string toString() const;
- std::string toID()const;
-
- Address createInc(int i);
- bool isValid() const {
- return (m_nodeID != 0) || (m_threadID != 0) || (m_objectID != 0);
- };
-
- int m_nodeID;
- int m_threadID;
- int m_objectID;
-
- //debug helper function
- static void printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses);
-
- private:
-};
-
-} /* namespace etRuntime */
-#endif /* ADDRESS_H_ */
-
-
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef ADDRESS_H_
+#define ADDRESS_H_
+
+#include <string>
+#include <vector>
+
+namespace etRuntime {
+
+class Address {
+ public:
+ explicit Address(int nodeID=0, int threadID=0, int objectID=0);
+ Address(const Address & right);
+ ~Address();
+
+ Address & operator = (const Address& right);
+ bool operator< (const Address& right) const;
+
+ std::string toString() const;
+ std::string toID()const;
+
+ Address createInc(int i);
+ bool isValid() const {
+ return (m_nodeID != 0) || (m_threadID != 0) || (m_objectID != 0);
+ };
+
+ int m_nodeID;
+ int m_threadID;
+ int m_objectID;
+
+ //debug helper function
+ static void printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses);
+
+ private:
+};
+
+} /* namespace etRuntime */
+#endif /* ADDRESS_H_ */
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp
index 640628392..40e97cf86 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.cpp
@@ -1,23 +1,23 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "IMessageReceiver.h"
-
-namespace etRuntime {
-
-IMessageReceiver::IMessageReceiver() {
-}
-
-IMessageReceiver::~IMessageReceiver() {
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "IMessageReceiver.h"
+
+namespace etRuntime {
+
+IMessageReceiver::IMessageReceiver() {
+}
+
+IMessageReceiver::~IMessageReceiver() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h
index cc6bdcd48..a1136ab7a 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h
@@ -1,34 +1,34 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef IMESSAGERECEIVER_H_
-#define IMESSAGERECEIVER_H_
-
-#include "common/messaging/Address.h"
-#include "common/messaging/Message.h"
-#include "common/messaging/IRTObject.h"
-
-namespace etRuntime {
-
-class IMessageReceiver{
-public:
- IMessageReceiver();
- virtual ~IMessageReceiver();
-
- virtual void receive(Message* msg) = 0;
- virtual Address getAddress() const = 0;
- virtual bool isMsgService() const { return false;};
-
-};
-
-} /* namespace etRuntime */
-#endif /* IMESSAGERECEIVER_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef IMESSAGERECEIVER_H_
+#define IMESSAGERECEIVER_H_
+
+#include "common/messaging/Address.h"
+#include "common/messaging/Message.h"
+#include "common/messaging/IRTObject.h"
+
+namespace etRuntime {
+
+class IMessageReceiver{
+public:
+ IMessageReceiver();
+ virtual ~IMessageReceiver();
+
+ virtual void receive(Message* msg) = 0;
+ virtual Address getAddress() const = 0;
+ virtual bool isMsgService() const { return false;};
+
+};
+
+} /* namespace etRuntime */
+#endif /* IMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
index 7f7e1259f..edf5ee57d 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
@@ -1,20 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "IRTObject.h"
-
-namespace etRuntime {
-
-const std::string IRTObject::NO_NAME = "<no name>";
-
-}
-
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "IRTObject.h"
+
+namespace etRuntime {
+
+const std::string IRTObject::NO_NAME = "<no name>";
+
+}
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
index 8553052d6..d10dd8022 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
@@ -1,35 +1,35 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef IRTOBJECT_H_
-#define IRTOBJECT_H_
-
-#include <string>
-
-namespace etRuntime {
-
-class IRTObject {
-
-public:
- virtual ~IRTObject() {};
-
- static const char PATH_DELIM = '/';
- static const char PATHNAME_DELIM = '_';
- static const std::string NO_NAME;
-
- virtual const std::string& getInstancePath() const = 0;
- virtual const std::string& getInstancePathName() const = 0;
-};
-
-}
-
-#endif /* IRTOBJECT_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef IRTOBJECT_H_
+#define IRTOBJECT_H_
+
+#include <string>
+
+namespace etRuntime {
+
+class IRTObject {
+
+public:
+ virtual ~IRTObject() {};
+
+ static const char PATH_DELIM = '/';
+ static const char PATHNAME_DELIM = '_';
+ static const std::string NO_NAME;
+
+ virtual const std::string& getInstancePath() const = 0;
+ virtual const std::string& getInstancePathName() const = 0;
+};
+
+}
+
+#endif /* IRTOBJECT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
index bef4ff1fa..0a4aa42bb 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
@@ -1,33 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "Message.h"
-
-#include <sstream>
-
-namespace etRuntime {
-
-
-Message::~Message() {
- m_next = 0;
-}
-
-std::string Message::toString(){
- std::stringstream strm;
- strm << "EventMessage(" << m_address.toString() << ", evt=" << m_evtId << ")";
- if (m_data) {
- strm << std::showbase << std::hex << m_data;
- }
- return strm.str();
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "Message.h"
+
+#include <sstream>
+
+namespace etRuntime {
+
+
+Message::~Message() {
+ m_next = 0;
+}
+
+std::string Message::toString(){
+ std::stringstream strm;
+ strm << "EventMessage(" << m_address.toString() << ", evt=" << m_evtId << ")";
+ if (m_data) {
+ strm << std::showbase << std::hex << m_data;
+ }
+ return strm.str();
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
index 0b900a5b7..2307a1ead 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
@@ -1,62 +1,62 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef MESSAGE_H_
-#define MESSAGE_H_
-
-#include "common/messaging/Address.h"
-#include "etDatatypes.h"
-#include <string>
-
-namespace etRuntime {
-
-class Message {
-public:
- Message(Address addr, int evtId, void* data, size_t dataSize) :
- m_address(addr), m_evtId(evtId), m_next(0),
- m_dataSize(dataSize), m_data(data), m_logFlag(true)
- {}
- Message(Address addr, int evtId) :
- m_address(addr), m_evtId(evtId), m_next(0),
- m_dataSize(0), m_data(0), m_logFlag(true)
- {}
- virtual ~Message();
-
- void setNext(Message* msg){m_next = msg;}
- Message* getNext() const {return m_next;}
-
- void setAddress(Address address){m_address = address; }
- Address getAddress() const { return m_address; };
-
- int getEvtId() const { return m_evtId; }
- void* getData() const { return m_data; }
- bool hasDebugFlagSet() const { return m_logFlag; };
-
- std::string toString();
-
-private:
- Address m_address;
- int m_evtId;
-
- Message* m_next;
- size_t m_dataSize;
- void* m_data;
- bool m_logFlag;
-
- Message();
- Message(const Message & right);
- Message & operator = (const Message& right);
-
-};
-
-} /* namespace etRuntime */
-#endif /* MESSAGE_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef MESSAGE_H_
+#define MESSAGE_H_
+
+#include "common/messaging/Address.h"
+#include "etDatatypes.h"
+#include <string>
+
+namespace etRuntime {
+
+class Message {
+public:
+ Message(Address addr, int evtId, void* data, size_t dataSize) :
+ m_address(addr), m_evtId(evtId), m_next(0),
+ m_dataSize(dataSize), m_data(data), m_logFlag(true)
+ {}
+ Message(Address addr, int evtId) :
+ m_address(addr), m_evtId(evtId), m_next(0),
+ m_dataSize(0), m_data(0), m_logFlag(true)
+ {}
+ virtual ~Message();
+
+ void setNext(Message* msg){m_next = msg;}
+ Message* getNext() const {return m_next;}
+
+ void setAddress(Address address){m_address = address; }
+ Address getAddress() const { return m_address; };
+
+ int getEvtId() const { return m_evtId; }
+ void* getData() const { return m_data; }
+ bool hasDebugFlagSet() const { return m_logFlag; };
+
+ std::string toString();
+
+private:
+ Address m_address;
+ int m_evtId;
+
+ Message* m_next;
+ size_t m_dataSize;
+ void* m_data;
+ bool m_logFlag;
+
+ Message();
+ Message(const Message & right);
+ Message & operator = (const Message& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
index 045e4dbf9..9f5e2b759 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "MessageDispatcher.h"
-
-namespace etRuntime {
-
-
-MessageDispatcher::~MessageDispatcher() {
-}
-
-MessageDispatcher::MessageDispatcher(IRTObject* parent, Address addr, std::string name)
-: RTObject(parent, name) ,
- IMessageReceiver(),
- m_local_map(),
- m_thread_map(),
- m_node_map(),
- m_address(addr)
-{};
-
-void MessageDispatcher::addMessageReceiver(IMessageReceiver& receiver){
-if (! receiver.getAddress().isValid() )
- return;
-
-// TODO: does only work same thread (else)
-if (receiver.getAddress().m_nodeID != m_address.m_nodeID){
- m_node_map[receiver.getAddress().m_objectID] = &receiver;
-}
-else if(receiver.getAddress().m_threadID != m_address.m_threadID){
- m_thread_map[receiver.getAddress().m_threadID] = &receiver;
-}
-else {
- m_local_map[receiver.getAddress().m_objectID] = &receiver;
-}
-};
-
-void MessageDispatcher::receive(Message* msg) {
-// TODO: does only work same thread (else)
- //TODO: assert msg != 0
-IMessageReceiver* receiver = 0;
-std::map<int, IMessageReceiver*>::iterator it;
-if (msg->getAddress().m_nodeID != m_address.m_nodeID){
- it = m_node_map.find(msg->getAddress().m_objectID);
- if (it != m_node_map.end() ) {
- receiver = (*it).second;
- }
-}
-else if(msg->getAddress().m_threadID != m_address.m_threadID){
- it = m_thread_map.find(msg->getAddress().m_objectID);
- if (it != m_thread_map.end() ) {
- receiver = (*it).second;
- }
-}
-else {
- // Same node, same thread -> local call Dispatch Map
- it = m_local_map.find(msg->getAddress().m_objectID);
- if (it != m_local_map.end() ) {
- receiver = (*it).second;
- }
-}
-if (receiver!=0)
-{
- receiver->receive(msg);
- // TODO: error handling for not found addresses
-}
-}
-
-} /* namespace etRuntime */
-
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "MessageDispatcher.h"
+
+namespace etRuntime {
+
+
+MessageDispatcher::~MessageDispatcher() {
+}
+
+MessageDispatcher::MessageDispatcher(IRTObject* parent, Address addr, std::string name)
+: RTObject(parent, name) ,
+ IMessageReceiver(),
+ m_local_map(),
+ m_thread_map(),
+ m_node_map(),
+ m_address(addr)
+{};
+
+void MessageDispatcher::addMessageReceiver(IMessageReceiver& receiver){
+if (! receiver.getAddress().isValid() )
+ return;
+
+// TODO: does only work same thread (else)
+if (receiver.getAddress().m_nodeID != m_address.m_nodeID){
+ m_node_map[receiver.getAddress().m_objectID] = &receiver;
+}
+else if(receiver.getAddress().m_threadID != m_address.m_threadID){
+ m_thread_map[receiver.getAddress().m_threadID] = &receiver;
+}
+else {
+ m_local_map[receiver.getAddress().m_objectID] = &receiver;
+}
+};
+
+void MessageDispatcher::receive(Message* msg) {
+// TODO: does only work same thread (else)
+ //TODO: assert msg != 0
+IMessageReceiver* receiver = 0;
+std::map<int, IMessageReceiver*>::iterator it;
+if (msg->getAddress().m_nodeID != m_address.m_nodeID){
+ it = m_node_map.find(msg->getAddress().m_objectID);
+ if (it != m_node_map.end() ) {
+ receiver = (*it).second;
+ }
+}
+else if(msg->getAddress().m_threadID != m_address.m_threadID){
+ it = m_thread_map.find(msg->getAddress().m_objectID);
+ if (it != m_thread_map.end() ) {
+ receiver = (*it).second;
+ }
+}
+else {
+ // Same node, same thread -> local call Dispatch Map
+ it = m_local_map.find(msg->getAddress().m_objectID);
+ if (it != m_local_map.end() ) {
+ receiver = (*it).second;
+ }
+}
+if (receiver!=0)
+{
+ receiver->receive(msg);
+ // TODO: error handling for not found addresses
+}
+}
+
+} /* namespace etRuntime */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
index c49628a09..57b50e5f6 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
@@ -1,48 +1,48 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef MESSAGEDISPATCHER_H_
-#define MESSAGEDISPATCHER_H_
-
-#include "common/messaging/IMessageReceiver.h"
-#include "common/messaging/IRTObject.h"
-#include "common/messaging/RTObject.h"
-#include <map>
-#include <string>
-
-namespace etRuntime {
-
-class MessageDispatcher : public RTObject, public IMessageReceiver {
- public:
- MessageDispatcher(IRTObject* parent, Address addr, std::string name);
- virtual ~MessageDispatcher();
-
- void addMessageReceiver(IMessageReceiver& receiver);
- void receive(Message* msg);
-
- Address getAddress() const { return m_address; };
-
- private:
- std::map<int, IMessageReceiver*> m_local_map;
- std::map<int, IMessageReceiver*> m_thread_map;
- std::map<int, IMessageReceiver*> m_node_map;
- Address m_address;
-
- MessageDispatcher();
- MessageDispatcher(const MessageDispatcher& right);
- MessageDispatcher& operator=(const MessageDispatcher& right);
-};
-
-} /* namespace etRuntime */
-#endif /* MESSAGEDISPATCHER_H_ */
-
-
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef MESSAGEDISPATCHER_H_
+#define MESSAGEDISPATCHER_H_
+
+#include "common/messaging/IMessageReceiver.h"
+#include "common/messaging/IRTObject.h"
+#include "common/messaging/RTObject.h"
+#include <map>
+#include <string>
+
+namespace etRuntime {
+
+class MessageDispatcher : public RTObject, public IMessageReceiver {
+ public:
+ MessageDispatcher(IRTObject* parent, Address addr, std::string name);
+ virtual ~MessageDispatcher();
+
+ void addMessageReceiver(IMessageReceiver& receiver);
+ void receive(Message* msg);
+
+ Address getAddress() const { return m_address; };
+
+ private:
+ std::map<int, IMessageReceiver*> m_local_map;
+ std::map<int, IMessageReceiver*> m_thread_map;
+ std::map<int, IMessageReceiver*> m_node_map;
+ Address m_address;
+
+ MessageDispatcher();
+ MessageDispatcher(const MessageDispatcher& right);
+ MessageDispatcher& operator=(const MessageDispatcher& right);
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGEDISPATCHER_H_ */
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
index fcf619c9c..ab2f54a8b 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
@@ -1,64 +1,64 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "MessageSeQueue.h"
-
-namespace etRuntime {
-
-
-MessageSeQueue::~MessageSeQueue() {
- m_first = 0;
- m_last = 0;
-}
-
-MessageSeQueue::MessageSeQueue(IRTObject* parent, std::string name)
- : RTObject(parent, name),
- m_first(0),
- m_last(0),
- m_highWaterMark(0),
- m_size(0)
-{
-}
-
-void MessageSeQueue::push(Message* msg) {
- // TODO: optimize queue for concurrent push / pop
- if (m_first == 0) {
- m_first = m_last = msg;
- } else {
- m_last->setNext(msg);
- m_last = msg;
- }
- if (++m_size > m_highWaterMark)
- m_highWaterMark++;
-
-}
-
-Message* MessageSeQueue::pop() {
- // TODO: optimize queue for concurrent push / pop
- Message* pop_msg = m_first;
- if (m_first == 0) {
- return m_first;
- }
- if (m_first->getNext() == 0) {
- m_first = m_last = 0;
- } else {
- m_first = m_first->getNext();
- }
-
- pop_msg->setNext(0);
- m_size--;
-
- return pop_msg;
-}
-
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "MessageSeQueue.h"
+
+namespace etRuntime {
+
+
+MessageSeQueue::~MessageSeQueue() {
+ m_first = 0;
+ m_last = 0;
+}
+
+MessageSeQueue::MessageSeQueue(IRTObject* parent, std::string name)
+ : RTObject(parent, name),
+ m_first(0),
+ m_last(0),
+ m_highWaterMark(0),
+ m_size(0)
+{
+}
+
+void MessageSeQueue::push(Message* msg) {
+ // TODO: optimize queue for concurrent push / pop
+ if (m_first == 0) {
+ m_first = m_last = msg;
+ } else {
+ m_last->setNext(msg);
+ m_last = msg;
+ }
+ if (++m_size > m_highWaterMark)
+ m_highWaterMark++;
+
+}
+
+Message* MessageSeQueue::pop() {
+ // TODO: optimize queue for concurrent push / pop
+ Message* pop_msg = m_first;
+ if (m_first == 0) {
+ return m_first;
+ }
+ if (m_first->getNext() == 0) {
+ m_first = m_last = 0;
+ } else {
+ m_first = m_first->getNext();
+ }
+
+ pop_msg->setNext(0);
+ m_size--;
+
+ return pop_msg;
+}
+
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
index 3e63a6b28..1468cea16 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
@@ -1,49 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef MESSAGESEQUEUE_H_
-#define MESSAGESEQUEUE_H_
-
-#include "common/messaging/RTObject.h"
-#include <string>
-#include "common/messaging/Message.h"
-
-namespace etRuntime {
-
-class MessageSeQueue: public RTObject {
- public:
- MessageSeQueue(IRTObject* parent, std::string name);
- virtual ~MessageSeQueue();
-
- void push(Message* msg);
- Message* pop();
-
- long getSize() const {return m_size; }
- Message* getFirst() const {return m_first; }
- Message* getLast() const { return m_last; }
- bool isNotEmpty() const { return m_last != 0; }
- long getHightWaterMark() const { return m_highWaterMark; }
-
- private:
- Message* m_first;
- Message* m_last;
- long m_highWaterMark;
- long m_size;
-
- MessageSeQueue();
- MessageSeQueue(const MessageSeQueue& right);
- MessageSeQueue& operator=(const MessageSeQueue& right);
-
-};
-
-} /* namespace etRuntime */
-#endif /* MESSAGESEQUEUE_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef MESSAGESEQUEUE_H_
+#define MESSAGESEQUEUE_H_
+
+#include "common/messaging/RTObject.h"
+#include <string>
+#include "common/messaging/Message.h"
+
+namespace etRuntime {
+
+class MessageSeQueue: public RTObject {
+ public:
+ MessageSeQueue(IRTObject* parent, std::string name);
+ virtual ~MessageSeQueue();
+
+ void push(Message* msg);
+ Message* pop();
+
+ long getSize() const {return m_size; }
+ Message* getFirst() const {return m_first; }
+ Message* getLast() const { return m_last; }
+ bool isNotEmpty() const { return m_last != 0; }
+ long getHightWaterMark() const { return m_highWaterMark; }
+
+ private:
+ Message* m_first;
+ Message* m_last;
+ long m_highWaterMark;
+ long m_size;
+
+ MessageSeQueue();
+ MessageSeQueue(const MessageSeQueue& right);
+ MessageSeQueue& operator=(const MessageSeQueue& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGESEQUEUE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
index cd516c7bf..21153ce56 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
@@ -1,157 +1,157 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "MessageService.h"
-#include <iostream>
-#include <stdlib.h>
-#include <unistd.h>
-
-namespace etRuntime {
-
-extern "C" {
- void* threadStarter(void* arg) {
- MessageService* thisPtr = static_cast<MessageService*>(arg);
- std::cout << "Thread " << thisPtr->getName() << " is started." << std::endl;
- thisPtr->run();
- return arg;
- // pthread_exit(NULL);
- }
-}
-
-MessageService::MessageService(IRTObject* parent, Address addr, std::string name, int priority)
- : IMessageReceiver(),
- RTObject(parent, name),
- m_running(false),
- m_thread(),
- m_mutex(),
- m_mutexAttr(),
- m_conditionVar(),
- m_threadAttr(),
- m_messageQueue(this, "Queue"),
- m_messageDispatcher( this,
- Address(addr.m_nodeID, addr.m_threadID, addr.m_objectID + 1),
- "Dispatcher"),
- m_address(addr),
- m_lastMessageTimestamp(0),
- m_asyncActors()
-{
- pthread_mutexattr_init(&m_mutexAttr);
- pthread_mutexattr_settype(&m_mutexAttr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&m_mutex, &m_mutexAttr);
- pthread_cond_init (&m_conditionVar, NULL);
- pthread_attr_init(&m_threadAttr);
- pthread_attr_setdetachstate(&m_threadAttr, PTHREAD_CREATE_JOINABLE);
-
- // check and set priority
-// assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (1)");
-// assert priority <= Thread.MAX_PRIORITY : ("priority bigger than Thread.MAX_PRIORITY (10)");
-// this.setPriority(priority);
-
-}
-
-MessageService::~MessageService() {
- pthread_attr_destroy(&m_threadAttr);
- pthread_mutex_destroy(&m_mutex);
- pthread_cond_destroy(&m_conditionVar);
- pthread_exit(NULL);
-
-}
-
-void MessageService::start(bool singlethreaded) {
- if (singlethreaded) {
- std::cout << "starting message service " << getName() << " singlethreaded" << std::endl;
- }
- else {
- std::cout << "starting message service " << getName() << " on own thread" << std::endl;
- int rc = pthread_create(&m_thread, &m_threadAttr, threadStarter, static_cast<void *>(this));
- if (rc){
- std::cout << "ERROR; return code from pthread_create() is " << rc << std::endl;
- exit(-1);
- }
- }
-}
-
-void MessageService::join() {
- void *status;
- int rc = pthread_join(m_thread, &status);
- if (rc){
- std::cout << "ERROR; return code from pthread_join() is " << rc << std::endl;
- exit(-1);
- }
-}
-void MessageService::run() {
- m_running = true;
- while (m_running) {
- pollOneMessage();
- usleep(10000);
- }
- std::cout << "ending message service " << getName() << " on own thread" << std::endl;
-}
-
-void MessageService::runOnce() {
- pollAsyncActors();
- while (m_messageQueue.isNotEmpty()){
- Message* msg = m_messageQueue.pop(); // get next Message from Queue
- if (msg != 0) {
- m_messageDispatcher.receive(msg);
- }
- }
-}
-
-void MessageService::receive(Message* msg) {
- pthread_mutex_lock(&m_mutex);
- if (msg != 0) {
- m_messageQueue.push(msg);
- pthread_cond_signal(&m_conditionVar); // wake up thread to compute message
- }
- pthread_mutex_unlock(&m_mutex);
-}
-
-
-// TODO: synchronized
-void MessageService::terminate() {
- pthread_mutex_lock(&m_mutex);
- if (m_running) {
- m_running = false;
- pthread_cond_signal(&m_conditionVar); // wake up thread to terminate
- }
- pthread_mutex_unlock(&m_mutex);
-}
-
-void MessageService::pollOneMessage() {
- pthread_mutex_lock(&m_mutex);
- Message* msg = m_messageQueue.pop(); // get next Message from Queue
- if (msg == 0) {
- // no message in queue -> wait till Thread is notified
- pthread_cond_wait(&m_conditionVar, &m_mutex);
- } else {
- //TODO: set timestamp
- // m_lastMessageTimestamp = System.currentTimeMillis();
- m_messageDispatcher.receive(msg);
- }
- pthread_mutex_unlock(&m_mutex);
-
-}
-
-void MessageService::addAsyncActor(IEventReceiver& evtReceiver) {
- m_asyncActors.push_back(&evtReceiver);
-}
-
-void MessageService::pollAsyncActors() {
- std::vector<IEventReceiver*>::iterator it = m_asyncActors.begin();
- for ( ; it != m_asyncActors.end(); ++it) {
- // polling event
- (*it)->receiveEvent(0,0,0);
- }
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "MessageService.h"
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+
+namespace etRuntime {
+
+extern "C" {
+ void* threadStarter(void* arg) {
+ MessageService* thisPtr = static_cast<MessageService*>(arg);
+ std::cout << "Thread " << thisPtr->getName() << " is started." << std::endl;
+ thisPtr->run();
+ return arg;
+ // pthread_exit(NULL);
+ }
+}
+
+MessageService::MessageService(IRTObject* parent, Address addr, std::string name, int priority)
+ : IMessageReceiver(),
+ RTObject(parent, name),
+ m_running(false),
+ m_thread(),
+ m_mutex(),
+ m_mutexAttr(),
+ m_conditionVar(),
+ m_threadAttr(),
+ m_messageQueue(this, "Queue"),
+ m_messageDispatcher( this,
+ Address(addr.m_nodeID, addr.m_threadID, addr.m_objectID + 1),
+ "Dispatcher"),
+ m_address(addr),
+ m_lastMessageTimestamp(0),
+ m_asyncActors()
+{
+ pthread_mutexattr_init(&m_mutexAttr);
+ pthread_mutexattr_settype(&m_mutexAttr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&m_mutex, &m_mutexAttr);
+ pthread_cond_init (&m_conditionVar, NULL);
+ pthread_attr_init(&m_threadAttr);
+ pthread_attr_setdetachstate(&m_threadAttr, PTHREAD_CREATE_JOINABLE);
+
+ // check and set priority
+// assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (1)");
+// assert priority <= Thread.MAX_PRIORITY : ("priority bigger than Thread.MAX_PRIORITY (10)");
+// this.setPriority(priority);
+
+}
+
+MessageService::~MessageService() {
+ pthread_attr_destroy(&m_threadAttr);
+ pthread_mutex_destroy(&m_mutex);
+ pthread_cond_destroy(&m_conditionVar);
+ pthread_exit(NULL);
+
+}
+
+void MessageService::start(bool singlethreaded) {
+ if (singlethreaded) {
+ std::cout << "starting message service " << getName() << " singlethreaded" << std::endl;
+ }
+ else {
+ std::cout << "starting message service " << getName() << " on own thread" << std::endl;
+ int rc = pthread_create(&m_thread, &m_threadAttr, threadStarter, static_cast<void *>(this));
+ if (rc){
+ std::cout << "ERROR; return code from pthread_create() is " << rc << std::endl;
+ exit(-1);
+ }
+ }
+}
+
+void MessageService::join() {
+ void *status;
+ int rc = pthread_join(m_thread, &status);
+ if (rc){
+ std::cout << "ERROR; return code from pthread_join() is " << rc << std::endl;
+ exit(-1);
+ }
+}
+void MessageService::run() {
+ m_running = true;
+ while (m_running) {
+ pollOneMessage();
+ usleep(10000);
+ }
+ std::cout << "ending message service " << getName() << " on own thread" << std::endl;
+}
+
+void MessageService::runOnce() {
+ pollAsyncActors();
+ while (m_messageQueue.isNotEmpty()){
+ Message* msg = m_messageQueue.pop(); // get next Message from Queue
+ if (msg != 0) {
+ m_messageDispatcher.receive(msg);
+ }
+ }
+}
+
+void MessageService::receive(Message* msg) {
+ pthread_mutex_lock(&m_mutex);
+ if (msg != 0) {
+ m_messageQueue.push(msg);
+ pthread_cond_signal(&m_conditionVar); // wake up thread to compute message
+ }
+ pthread_mutex_unlock(&m_mutex);
+}
+
+
+// TODO: synchronized
+void MessageService::terminate() {
+ pthread_mutex_lock(&m_mutex);
+ if (m_running) {
+ m_running = false;
+ pthread_cond_signal(&m_conditionVar); // wake up thread to terminate
+ }
+ pthread_mutex_unlock(&m_mutex);
+}
+
+void MessageService::pollOneMessage() {
+ pthread_mutex_lock(&m_mutex);
+ Message* msg = m_messageQueue.pop(); // get next Message from Queue
+ if (msg == 0) {
+ // no message in queue -> wait till Thread is notified
+ pthread_cond_wait(&m_conditionVar, &m_mutex);
+ } else {
+ //TODO: set timestamp
+ // m_lastMessageTimestamp = System.currentTimeMillis();
+ m_messageDispatcher.receive(msg);
+ }
+ pthread_mutex_unlock(&m_mutex);
+
+}
+
+void MessageService::addAsyncActor(IEventReceiver& evtReceiver) {
+ m_asyncActors.push_back(&evtReceiver);
+}
+
+void MessageService::pollAsyncActors() {
+ std::vector<IEventReceiver*>::iterator it = m_asyncActors.begin();
+ for ( ; it != m_asyncActors.end(); ++it) {
+ // polling event
+ (*it)->receiveEvent(0,0,0);
+ }
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
index e34b17ab6..3a9a91f61 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
@@ -1,83 +1,83 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef MESSAGESERVICE_H_
-#define MESSAGESERVICE_H_
-
-#include <string>
-#include <vector>
-#include <pthread.h>
-#include "common/messaging/MessageDispatcher.h"
-#include "common/messaging/Address.h"
-#include "common/modelbase/IEventReceiver.h"
-#include "MessageSeQueue.h"
-
-namespace etRuntime {
-
-//TODO: abstraction from posix threads missing
-
-class MessageService: public IMessageReceiver, public RTObject {
-public:
- MessageService(IRTObject* parent, Address addr, std::string name, int priority = 0);
- virtual ~MessageService();
-
- Address getAddress() const { return m_address; } ;
-
- void start(bool singlethreaded);
- void run();
- // for single threaded configuration only
- void runOnce();
-
- void join();
- void terminate();
- void receive(Message* msg);
-
- virtual MessageDispatcher& getMessageDispatcher() { return m_messageDispatcher; }
- virtual bool isMsgService() const { return true;};
-
- void addAsyncActor(IEventReceiver& evtReceiver);
- void pollAsyncActors();
-
-
- // protected methods for sole use by test cases
-protected:
- MessageSeQueue& getMessageQueue() { return m_messageQueue; }
- long getLastMessageTimestamp() const { return m_lastMessageTimestamp; }
-
-private:
- //TODO: synchronized
- void pollOneMessage();
-
- bool m_running;
- pthread_t m_thread;
- pthread_mutex_t m_mutex;
- pthread_mutexattr_t m_mutexAttr;
- pthread_cond_t m_conditionVar;
- pthread_attr_t m_threadAttr;
-
- // TODO: add internal message queue for less locks (faster thread internal
- // messaging)
- MessageSeQueue m_messageQueue;
- MessageDispatcher m_messageDispatcher;
- Address m_address;
- long m_lastMessageTimestamp;
-
- std::vector<IEventReceiver*> m_asyncActors;
-
- MessageService();
- MessageService(const MessageService& right);
- MessageService& operator=(const MessageService& right);
-
-};
-
-} /* namespace etRuntime */
-#endif /* MESSAGESERVICE_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef MESSAGESERVICE_H_
+#define MESSAGESERVICE_H_
+
+#include <string>
+#include <vector>
+#include <pthread.h>
+#include "common/messaging/MessageDispatcher.h"
+#include "common/messaging/Address.h"
+#include "common/modelbase/IEventReceiver.h"
+#include "MessageSeQueue.h"
+
+namespace etRuntime {
+
+//TODO: abstraction from posix threads missing
+
+class MessageService: public IMessageReceiver, public RTObject {
+public:
+ MessageService(IRTObject* parent, Address addr, std::string name, int priority = 0);
+ virtual ~MessageService();
+
+ Address getAddress() const { return m_address; } ;
+
+ void start(bool singlethreaded);
+ void run();
+ // for single threaded configuration only
+ void runOnce();
+
+ void join();
+ void terminate();
+ void receive(Message* msg);
+
+ virtual MessageDispatcher& getMessageDispatcher() { return m_messageDispatcher; }
+ virtual bool isMsgService() const { return true;};
+
+ void addAsyncActor(IEventReceiver& evtReceiver);
+ void pollAsyncActors();
+
+
+ // protected methods for sole use by test cases
+protected:
+ MessageSeQueue& getMessageQueue() { return m_messageQueue; }
+ long getLastMessageTimestamp() const { return m_lastMessageTimestamp; }
+
+private:
+ //TODO: synchronized
+ void pollOneMessage();
+
+ bool m_running;
+ pthread_t m_thread;
+ pthread_mutex_t m_mutex;
+ pthread_mutexattr_t m_mutexAttr;
+ pthread_cond_t m_conditionVar;
+ pthread_attr_t m_threadAttr;
+
+ // TODO: add internal message queue for less locks (faster thread internal
+ // messaging)
+ MessageSeQueue m_messageQueue;
+ MessageDispatcher m_messageDispatcher;
+ Address m_address;
+ long m_lastMessageTimestamp;
+
+ std::vector<IEventReceiver*> m_asyncActors;
+
+ MessageService();
+ MessageService(const MessageService& right);
+ MessageService& operator=(const MessageService& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
index fbf903313..6a71f9a81 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
@@ -1,119 +1,119 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "MessageServiceController.h"
-
-namespace etRuntime {
-
-
-MessageServiceController::~MessageServiceController() {
- // TODO Auto-generated destructor stub
-}
-
-MessageServiceController::MessageServiceController(/*IRTObject parent*/)
- : m_messageServiceList(),
- m_running(false) {
- // TODO: Who is parent of MessageServices and Controller?
- // this.parent = parent;
-}
-
-void MessageServiceController::addMsgSvc(MessageService& msgSvc) {
- // TODO TS: Who is parent of MessageServices ?
- //TODO assert
- //assert(msgSvc.getAddress().m_threadID == m_messageServiceList.size());
- m_messageServiceList.push_back(&msgSvc);
-}
-
-MessageService* MessageServiceController::getMsgSvc(int threadID) {
- return m_messageServiceList.at(threadID);
-}
-
-void MessageServiceController::connectAll() {
- for (size_t i = 0; i < m_messageServiceList.size(); i++) {
- MessageDispatcher& dispatcher = getMsgSvc(i)->getMessageDispatcher();
- for (size_t j = 0; j < m_messageServiceList.size(); j++) {
- if (i != j) {
- dispatcher.addMessageReceiver(*RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(j));
- }
- }
- }
-}
-
-void MessageServiceController::start(bool singlethreaded) {
- // start all message services
- for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
- it != m_messageServiceList.end(); ++it) {
- (*it)->start(singlethreaded);
- // TODO TS: start in order of priorities
- }
- m_running = true;
-}
-
-void MessageServiceController::stop(bool singlethreaded) {
- //dumpThreads("org.eclipse.etrice.runtime.java.messaging.MessageServiceController.stop()");
- if (! singlethreaded) {
- terminate();
- waitTerminate();
- }
-}
-
-void MessageServiceController::waitTerminate() {
- for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
- it != m_messageServiceList.end(); ++it) {
- (*it)->join();
- }
-}
-
-void MessageServiceController::dumpThreads(std::string msg) {
- std::cout << "<<< begin dump threads <<<" << std::endl;
- std::cout << "=== " << msg << std::endl;
- //TODO dump stack traces
-// Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
-// for (Thread thread : traces.keySet()) {
-// std::cout << "thread " << thread.getName() << std::endl;
-// StackTraceElement[] elements = traces.get(thread);
-// int n = 2;
-// if (elements.length < n)
-// n = elements.length;
-// for (int i = 0; i < n; i++) {
-// std::cout << " " << elements[i].toString() << std::endl;
-// }
-// }
- std::cout <<(">>> end dump threads >>>");
-}
-
-void MessageServiceController::terminate() {
- if (!m_running) {
- return;
- }
- m_running = false;
-
- // terminate all message services
- for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
- it != m_messageServiceList.end(); ++it) {
- (*it)->terminate();
- //TODO TS: stop in order of priorities
- }
-}
-
-void MessageServiceController::runOnce() {
- if (!m_running) {
- return;
- }
-
- for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
- it != m_messageServiceList.end(); ++it) {
- (*it)->runOnce();
- }
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "MessageServiceController.h"
+
+namespace etRuntime {
+
+
+MessageServiceController::~MessageServiceController() {
+ // TODO Auto-generated destructor stub
+}
+
+MessageServiceController::MessageServiceController(/*IRTObject parent*/)
+ : m_messageServiceList(),
+ m_running(false) {
+ // TODO: Who is parent of MessageServices and Controller?
+ // this.parent = parent;
+}
+
+void MessageServiceController::addMsgSvc(MessageService& msgSvc) {
+ // TODO TS: Who is parent of MessageServices ?
+ //TODO assert
+ //assert(msgSvc.getAddress().m_threadID == m_messageServiceList.size());
+ m_messageServiceList.push_back(&msgSvc);
+}
+
+MessageService* MessageServiceController::getMsgSvc(int threadID) {
+ return m_messageServiceList.at(threadID);
+}
+
+void MessageServiceController::connectAll() {
+ for (size_t i = 0; i < m_messageServiceList.size(); i++) {
+ MessageDispatcher& dispatcher = getMsgSvc(i)->getMessageDispatcher();
+ for (size_t j = 0; j < m_messageServiceList.size(); j++) {
+ if (i != j) {
+ dispatcher.addMessageReceiver(*RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(j));
+ }
+ }
+ }
+}
+
+void MessageServiceController::start(bool singlethreaded) {
+ // start all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ (*it)->start(singlethreaded);
+ // TODO TS: start in order of priorities
+ }
+ m_running = true;
+}
+
+void MessageServiceController::stop(bool singlethreaded) {
+ //dumpThreads("org.eclipse.etrice.runtime.java.messaging.MessageServiceController.stop()");
+ if (! singlethreaded) {
+ terminate();
+ waitTerminate();
+ }
+}
+
+void MessageServiceController::waitTerminate() {
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ (*it)->join();
+ }
+}
+
+void MessageServiceController::dumpThreads(std::string msg) {
+ std::cout << "<<< begin dump threads <<<" << std::endl;
+ std::cout << "=== " << msg << std::endl;
+ //TODO dump stack traces
+// Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
+// for (Thread thread : traces.keySet()) {
+// std::cout << "thread " << thread.getName() << std::endl;
+// StackTraceElement[] elements = traces.get(thread);
+// int n = 2;
+// if (elements.length < n)
+// n = elements.length;
+// for (int i = 0; i < n; i++) {
+// std::cout << " " << elements[i].toString() << std::endl;
+// }
+// }
+ std::cout <<(">>> end dump threads >>>");
+}
+
+void MessageServiceController::terminate() {
+ if (!m_running) {
+ return;
+ }
+ m_running = false;
+
+ // terminate all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ (*it)->terminate();
+ //TODO TS: stop in order of priorities
+ }
+}
+
+void MessageServiceController::runOnce() {
+ if (!m_running) {
+ return;
+ }
+
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ (*it)->runOnce();
+ }
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
index d975233a5..5f79bbea0 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef MESSAGESERVICECONTROLLER_H_
-#define MESSAGESERVICECONTROLLER_H_
-
-#include "common/messaging/MessageService.h"
-#include "common/messaging/RTServices.h"
-#include <vector>
-#include <string>
-#include <iostream>
-#include <algorithm>
-
-namespace etRuntime {
-
-class MessageServiceController {
-public:
- MessageServiceController(/*IRTObject parent*/);
- virtual ~MessageServiceController();
-
- void addMsgSvc(MessageService& msgSvc);
- //raises an exception if the service does not exist for this threadID
- MessageService* getMsgSvc(int threadID);
-
- void addAsyncActor(IEventReceiver& evtReceiver);
- void pollAsyncActors();
-
- //the connectAll method connects all messageServices
- //it is included for test purposes
- //currently it is not called
- void connectAll();
- void start(bool singlethreaded);
- void stop(bool singlethreaded);
-
- //TODO: this is only for single threaded configurations
- void runOnce();
-
- /**
- * waitTerminate waits blocking for all MessageServices to terminate
- * ! not threadsafe !
- */
- void waitTerminate();
-
-protected:
- void dumpThreads(std::string msg);
-
-private:
- void terminate();
-
- MessageServiceController(const MessageServiceController& right);
- MessageServiceController& operator=(const MessageServiceController& right);
-
-
- std::vector<MessageService*> m_messageServiceList;
- // IRTObject parent = null;
- bool m_running;
-
-};
-
-} /* namespace etRuntime */
-#endif /* MESSAGESERVICECONTROLLER_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef MESSAGESERVICECONTROLLER_H_
+#define MESSAGESERVICECONTROLLER_H_
+
+#include "common/messaging/MessageService.h"
+#include "common/messaging/RTServices.h"
+#include <vector>
+#include <string>
+#include <iostream>
+#include <algorithm>
+
+namespace etRuntime {
+
+class MessageServiceController {
+public:
+ MessageServiceController(/*IRTObject parent*/);
+ virtual ~MessageServiceController();
+
+ void addMsgSvc(MessageService& msgSvc);
+ //raises an exception if the service does not exist for this threadID
+ MessageService* getMsgSvc(int threadID);
+
+ void addAsyncActor(IEventReceiver& evtReceiver);
+ void pollAsyncActors();
+
+ //the connectAll method connects all messageServices
+ //it is included for test purposes
+ //currently it is not called
+ void connectAll();
+ void start(bool singlethreaded);
+ void stop(bool singlethreaded);
+
+ //TODO: this is only for single threaded configurations
+ void runOnce();
+
+ /**
+ * waitTerminate waits blocking for all MessageServices to terminate
+ * ! not threadsafe !
+ */
+ void waitTerminate();
+
+protected:
+ void dumpThreads(std::string msg);
+
+private:
+ void terminate();
+
+ MessageServiceController(const MessageServiceController& right);
+ MessageServiceController& operator=(const MessageServiceController& right);
+
+
+ std::vector<MessageService*> m_messageServiceList;
+ // IRTObject parent = null;
+ bool m_running;
+
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGESERVICECONTROLLER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
index 2ccccb590..68ba311fa 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
@@ -1,73 +1,73 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "RTObject.h"
-
-namespace etRuntime {
-
-RTObject::RTObject() :
- IRTObject(),
- m_parent(0),
- m_name(NO_NAME) ,
- m_instancePath(),
- m_instancePathName()
-{
- setPathNames();
-}
-
-RTObject::RTObject(IRTObject* parent, std::string name) :
- IRTObject(),
- m_parent(parent),
- m_name(name),
- m_instancePath(),
- m_instancePathName()
-{
- setPathNames();
-}
-
-RTObject::RTObject(const RTObject & right) :
- m_parent(right.m_parent),
- m_name(right.m_name),
- m_instancePath(right.m_instancePath),
- m_instancePathName(right.m_instancePathName)
-{
-}
-
-RTObject & RTObject::operator = (RTObject right) {
- std::swap(right, *this);
- return *this;
-}
-
-RTObject::~RTObject() {
- m_parent = 0;
-}
-
-void RTObject::setPathNames() {
- if (m_parent != 0) {
- m_instancePath = m_parent->getInstancePath() + PATH_DELIM + m_name;
- m_instancePathName = m_parent->getInstancePathName() + PATHNAME_DELIM + m_name;
- }
- else {
- m_instancePath = PATH_DELIM + m_name;
- m_instancePathName = PATHNAME_DELIM + m_name;
- }
-}
-
-const std::string& RTObject::getInstancePath() const{
- return m_instancePath;
-}
-
-const std::string& RTObject::getInstancePathName() const{
- return m_instancePathName;
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "RTObject.h"
+
+namespace etRuntime {
+
+RTObject::RTObject() :
+ IRTObject(),
+ m_parent(0),
+ m_name(NO_NAME) ,
+ m_instancePath(),
+ m_instancePathName()
+{
+ setPathNames();
+}
+
+RTObject::RTObject(IRTObject* parent, std::string name) :
+ IRTObject(),
+ m_parent(parent),
+ m_name(name),
+ m_instancePath(),
+ m_instancePathName()
+{
+ setPathNames();
+}
+
+RTObject::RTObject(const RTObject & right) :
+ m_parent(right.m_parent),
+ m_name(right.m_name),
+ m_instancePath(right.m_instancePath),
+ m_instancePathName(right.m_instancePathName)
+{
+}
+
+RTObject & RTObject::operator = (RTObject right) {
+ std::swap(right, *this);
+ return *this;
+}
+
+RTObject::~RTObject() {
+ m_parent = 0;
+}
+
+void RTObject::setPathNames() {
+ if (m_parent != 0) {
+ m_instancePath = m_parent->getInstancePath() + PATH_DELIM + m_name;
+ m_instancePathName = m_parent->getInstancePathName() + PATHNAME_DELIM + m_name;
+ }
+ else {
+ m_instancePath = PATH_DELIM + m_name;
+ m_instancePathName = PATHNAME_DELIM + m_name;
+ }
+}
+
+const std::string& RTObject::getInstancePath() const{
+ return m_instancePath;
+}
+
+const std::string& RTObject::getInstancePathName() const{
+ return m_instancePathName;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
index 60266b14f..e70059035 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
@@ -1,49 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef RTOBJECT_H_
-#define RTOBJECT_H_
-
-#include <string>
-#include "common/messaging/IRTObject.h"
-
-namespace etRuntime {
-
-class RTObject : public virtual IRTObject{
-public:
- RTObject();
- RTObject(IRTObject* parent, std::string name);
- RTObject(const RTObject & right);
- RTObject & operator = (RTObject right);
-
- virtual ~RTObject();
-
- IRTObject* getParent() const { return m_parent; };
- const std::string& getName() const { return m_name; };
-
- virtual const std::string& getInstancePath() const;
- virtual const std::string& getInstancePathName() const;
-
-private:
- void setPathNames();
-
- IRTObject* m_parent;
- std::string m_name;
- // for speed optimization the instance paths are created at instantiation
- // and used as const ref parameters in the logging methods to avoid copying
- std::string m_instancePath;
- std::string m_instancePathName;
-
-};
-
-} /* namespace etRuntime */
-#endif /* RTOBJECT_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef RTOBJECT_H_
+#define RTOBJECT_H_
+
+#include <string>
+#include "common/messaging/IRTObject.h"
+
+namespace etRuntime {
+
+class RTObject : public virtual IRTObject{
+public:
+ RTObject();
+ RTObject(IRTObject* parent, std::string name);
+ RTObject(const RTObject & right);
+ RTObject & operator = (RTObject right);
+
+ virtual ~RTObject();
+
+ IRTObject* getParent() const { return m_parent; };
+ const std::string& getName() const { return m_name; };
+
+ virtual const std::string& getInstancePath() const;
+ virtual const std::string& getInstancePathName() const;
+
+private:
+ void setPathNames();
+
+ IRTObject* m_parent;
+ std::string m_name;
+ // for speed optimization the instance paths are created at instantiation
+ // and used as const ref parameters in the logging methods to avoid copying
+ std::string m_instancePath;
+ std::string m_instancePathName;
+
+};
+
+} /* namespace etRuntime */
+#endif /* RTOBJECT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp
index 0d7ad9865..6aa7b5656 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.cpp
@@ -1,44 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "RTServices.h"
-
-namespace etRuntime {
-
-RTServices* RTServices::s_instance = 0;
-
-RTServices::RTServices()
- : m_subSystem(0),
- m_messageServiceController( new MessageServiceController())
-{
-}
-
-RTServices::~RTServices() {
- // TODO Auto-generated destructor stub
-}
-
-void RTServices::destroy() {
- // TODO: also clean up all sub elements
- m_subSystem = 0;
- m_messageServiceController = 0;
- //TODO is delete necessary here??
- //delete s_instance;
- s_instance = 0;
-}
-
-MessageServiceController& RTServices::getMsgSvcCtrl() {
- //TODO
- //assert(m_messageServiceController != 0);
- return *m_messageServiceController;
-}
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "RTServices.h"
+
+namespace etRuntime {
+
+RTServices* RTServices::s_instance = 0;
+
+RTServices::RTServices()
+ : m_subSystem(0),
+ m_messageServiceController( new MessageServiceController())
+{
+}
+
+RTServices::~RTServices() {
+ // TODO Auto-generated destructor stub
+}
+
+void RTServices::destroy() {
+ // TODO: also clean up all sub elements
+ m_subSystem = 0;
+ m_messageServiceController = 0;
+ //TODO is delete necessary here??
+ //delete s_instance;
+ s_instance = 0;
+}
+
+MessageServiceController& RTServices::getMsgSvcCtrl() {
+ //TODO
+ //assert(m_messageServiceController != 0);
+ return *m_messageServiceController;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h
index 8bebd49c4..fe9c36395 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h
@@ -1,52 +1,52 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef RTSERVICES_H_
-#define RTSERVICES_H_
-#include "common/messaging/MessageServiceController.h"
-
-namespace etRuntime {
-
-class SubSystemClassBase;
-class MessageServiceController;
-
-
-class RTServices {
-public:
- virtual ~RTServices();
-
- static RTServices& getInstance() {
- if (s_instance == 0) {
- s_instance = new RTServices();
- }
- return *s_instance;
- }
-
- void destroy();
- MessageServiceController& getMsgSvcCtrl();
- SubSystemClassBase* getSubSystem() { return m_subSystem; };
- void setSubSystem(SubSystemClassBase* subSystem) { m_subSystem = subSystem; };
-
-private:
- static RTServices* s_instance;
-
- SubSystemClassBase* m_subSystem;
- MessageServiceController* m_messageServiceController;
-
- RTServices();
- RTServices(const RTServices & right);
- RTServices & operator = (const RTServices& right);
-
-};
-
-} /* namespace etRuntime */
-#endif /* RTSERVICES_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef RTSERVICES_H_
+#define RTSERVICES_H_
+#include "common/messaging/MessageServiceController.h"
+
+namespace etRuntime {
+
+class SubSystemClassBase;
+class MessageServiceController;
+
+
+class RTServices {
+public:
+ virtual ~RTServices();
+
+ static RTServices& getInstance() {
+ if (s_instance == 0) {
+ s_instance = new RTServices();
+ }
+ return *s_instance;
+ }
+
+ void destroy();
+ MessageServiceController& getMsgSvcCtrl();
+ SubSystemClassBase* getSubSystem() { return m_subSystem; };
+ void setSubSystem(SubSystemClassBase* subSystem) { m_subSystem = subSystem; };
+
+private:
+ static RTServices* s_instance;
+
+ SubSystemClassBase* m_subSystem;
+ MessageServiceController* m_messageServiceController;
+
+ RTServices();
+ RTServices(const RTServices & right);
+ RTServices & operator = (const RTServices& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* RTSERVICES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
index 963340860..34ab12c46 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
@@ -1,219 +1,219 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#include "RTSystemServicesProtocol.h"
-#include "common/debugging/DebuggingService.h"
-
-namespace etRuntime {
-
-std::string RTSystemServicesProtocol::s_messageStrings[] =
- { "MIN",
- "dummy",
- "executeInitialTransition",
- "startDebugging",
- "stopDebugging",
- "MAX"};
-
-std::string RTSystemServicesProtocol::getMessageString(int msg_id) {
- if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
- return s_messageStrings[msg_id];
- } else {
- // id out of range
- return "Message ID out of range";
- }
-}
-
-//------------------------------------------------------------------
-// RTSystemServicesProtocol: surrounding class
-//------------------------------------------------------------------
-
-
-RTSystemServicesProtocol::RTSystemServicesProtocol() {
-}
-
-RTSystemServicesProtocol::~RTSystemServicesProtocol() {
-}
-
-
-//------------------------------------------------------------------
-// RTSystemServicesProtocolPort
-//------------------------------------------------------------------
-
-RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, Address addr, Address peerAddress, bool doRegistration)
-:PortBase(actor, parent, name, localId, 0, addr, peerAddress)
-{
- if (doRegistration) {
- DebuggingService::getInstance().addPortInstance(*this);
- }
-};
-
-RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
-: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
-{
- if (doRegistration) {
- DebuggingService::getInstance().addPortInstance(*this);
- }
-};
-
-void RTSystemServicesProtocolPort::receive(Message* msg) {
- if (! RTSystemServicesProtocol::isValidIncomingEvtID(msg->getEvtId())) {
- std::cout << "unknown" << std::endl;
- }
- else {
- if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
- }
- getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
- }
-};
-
-// sent messages
-
-void RTSystemServicesProtocolPort::dummy() {
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::OUT_dummy));
- PortBase::send(RTSystemServicesProtocol::OUT_dummy);
-};
-
-//------------------------------------------------------------------
-// RTSystemServicesProtocolPortRepl
-//------------------------------------------------------------------
-
-
-RTSystemServicesProtocolPortRepl::
-RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress)
-: m_replication(addr.size()),
- m_ports()
-{
- char numstr[10]; // enough to hold all numbers up to 32-bits
-
- //m_ports.reserve(m_replication);
- m_ports = reinterpret_cast<RTSystemServicesProtocolPort*> (new char[sizeof(RTSystemServicesProtocolPort) * addr.size()]);
-
- for (int i = 0; i < m_replication; ++i) {
- snprintf(numstr, sizeof(numstr), "%d", i);
- new (&m_ports[i]) RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
-
- //m_ports.push_back(std::auto_ptr_ref<RTSystemServicesProtocolPort>(new RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i], false)));
- //m_ports[i] = std::auto_ptr<RTSystemServicesProtocolPort>(new RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]));
- }
-// for (int i = 0; i < m_replication; ++i) {
-// DebuggingService::getInstance().addPortInstance(m_ports.at(i));
-// }
-
-};
-
-// outgoing messages
-
-void RTSystemServicesProtocolPortRepl::dummy() {
- for (int i = 0; i < m_replication; ++i) {
- m_ports[i].dummy();
- }
-};
-
-//------------------------------------------------------------------
-// RTSystemServicesProtocolConjPort
-//------------------------------------------------------------------
-
-RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
- std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
- : PortBase(actor, parent, name, localId, 0, addr, peerAddress)
-{
- if (doRegistration) {
- DebuggingService::getInstance().addPortInstance(*this);
- }
-}
-RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
- std::string name, int localId, int idx, Address addr,
- Address peerAddress, bool doRegistration)
-: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
-{
- if (doRegistration) {
- DebuggingService::getInstance().addPortInstance(*this);
- }
-}
-
-void RTSystemServicesProtocolConjPort::receive(Message* msg) {
- if (! RTSystemServicesProtocol::isValidOutgoingEvtID(msg->getEvtId())) { //conjugated port receives out-messages
- std::cout << "unknown" << std::endl;
- }
- else {
- if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
- }
- getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
- }
-}
-
-// sent messages
-
-void RTSystemServicesProtocolConjPort::executeInitialTransition() {
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_executeInitialTransition));
- PortBase::send(RTSystemServicesProtocol::IN_executeInitialTransition);
-}
-
-void RTSystemServicesProtocolConjPort::startDebugging() {
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_startDebugging));
- PortBase::send(RTSystemServicesProtocol::IN_startDebugging);
-}
-
-void RTSystemServicesProtocolConjPort::stopDebugging() {
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_stopDebugging));
- PortBase::send(RTSystemServicesProtocol::IN_stopDebugging);
-}
-
-//------------------------------------------------------------------
-// RTSystemServicesProtocolConjPortRepl
-//------------------------------------------------------------------
-
-RTSystemServicesProtocolConjPortRepl::
-RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address>& peerAddress)
-: m_replication(addr.size()),
- m_ports()
-{
- char numstr[10]; // enough to hold all numbers up to 32-bits
- m_ports = reinterpret_cast<RTSystemServicesProtocolConjPort*> (new char[sizeof(RTSystemServicesProtocolConjPort) * addr.size()]);
- for (int i = 0; i < m_replication; ++i) {
- snprintf(numstr, sizeof(numstr), "%d", i);
- //placement new to avoid copy construction, therefore no vector is used
- new (&m_ports[i]) RTSystemServicesProtocolConjPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
- }
-
-};
-
-// sent messages
-
-void RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
- for (int i = 0; i < m_replication; ++i) {
- m_ports[i].executeInitialTransition();
- }
-}
-
-void RTSystemServicesProtocolConjPortRepl::startDebugging() {
- for (int i = 0; i < m_replication; ++i) {
- m_ports[i].startDebugging();
- }
-}
-
-void RTSystemServicesProtocolConjPortRepl::stopDebugging() {
- for (int i = 0; i < m_replication; ++i) {
- m_ports[i].stopDebugging();
- }
-}
-
-
-} /* namespace etRuntime */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "RTSystemServicesProtocol.h"
+#include "common/debugging/DebuggingService.h"
+
+namespace etRuntime {
+
+std::string RTSystemServicesProtocol::s_messageStrings[] =
+ { "MIN",
+ "dummy",
+ "executeInitialTransition",
+ "startDebugging",
+ "stopDebugging",
+ "MAX"};
+
+std::string RTSystemServicesProtocol::getMessageString(int msg_id) {
+ if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
+ return s_messageStrings[msg_id];
+ } else {
+ // id out of range
+ return "Message ID out of range";
+ }
+}
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocol: surrounding class
+//------------------------------------------------------------------
+
+
+RTSystemServicesProtocol::RTSystemServicesProtocol() {
+}
+
+RTSystemServicesProtocol::~RTSystemServicesProtocol() {
+}
+
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolPort
+//------------------------------------------------------------------
+
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, Address addr, Address peerAddress, bool doRegistration)
+:PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+};
+
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
+: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+};
+
+void RTSystemServicesProtocolPort::receive(Message* msg) {
+ if (! RTSystemServicesProtocol::isValidIncomingEvtID(msg->getEvtId())) {
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
+ }
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+};
+
+// sent messages
+
+void RTSystemServicesProtocolPort::dummy() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::OUT_dummy));
+ PortBase::send(RTSystemServicesProtocol::OUT_dummy);
+};
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolPortRepl
+//------------------------------------------------------------------
+
+
+RTSystemServicesProtocolPortRepl::
+RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress)
+: m_replication(addr.size()),
+ m_ports()
+{
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+
+ //m_ports.reserve(m_replication);
+ m_ports = reinterpret_cast<RTSystemServicesProtocolPort*> (new char[sizeof(RTSystemServicesProtocolPort) * addr.size()]);
+
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ new (&m_ports[i]) RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+
+ //m_ports.push_back(std::auto_ptr_ref<RTSystemServicesProtocolPort>(new RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i], false)));
+ //m_ports[i] = std::auto_ptr<RTSystemServicesProtocolPort>(new RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]));
+ }
+// for (int i = 0; i < m_replication; ++i) {
+// DebuggingService::getInstance().addPortInstance(m_ports.at(i));
+// }
+
+};
+
+// outgoing messages
+
+void RTSystemServicesProtocolPortRepl::dummy() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].dummy();
+ }
+};
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolConjPort
+//------------------------------------------------------------------
+
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
+ : PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+}
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, int idx, Address addr,
+ Address peerAddress, bool doRegistration)
+: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+{
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+}
+
+void RTSystemServicesProtocolConjPort::receive(Message* msg) {
+ if (! RTSystemServicesProtocol::isValidOutgoingEvtID(msg->getEvtId())) { //conjugated port receives out-messages
+ std::cout << "unknown" << std::endl;
+ }
+ else {
+ if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
+ }
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
+ }
+}
+
+// sent messages
+
+void RTSystemServicesProtocolConjPort::executeInitialTransition() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_executeInitialTransition));
+ PortBase::send(RTSystemServicesProtocol::IN_executeInitialTransition);
+}
+
+void RTSystemServicesProtocolConjPort::startDebugging() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_startDebugging));
+ PortBase::send(RTSystemServicesProtocol::IN_startDebugging);
+}
+
+void RTSystemServicesProtocolConjPort::stopDebugging() {
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_stopDebugging));
+ PortBase::send(RTSystemServicesProtocol::IN_stopDebugging);
+}
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolConjPortRepl
+//------------------------------------------------------------------
+
+RTSystemServicesProtocolConjPortRepl::
+RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address>& peerAddress)
+: m_replication(addr.size()),
+ m_ports()
+{
+ char numstr[10]; // enough to hold all numbers up to 32-bits
+ m_ports = reinterpret_cast<RTSystemServicesProtocolConjPort*> (new char[sizeof(RTSystemServicesProtocolConjPort) * addr.size()]);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ //placement new to avoid copy construction, therefore no vector is used
+ new (&m_ports[i]) RTSystemServicesProtocolConjPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);
+ }
+
+};
+
+// sent messages
+
+void RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].executeInitialTransition();
+ }
+}
+
+void RTSystemServicesProtocolConjPortRepl::startDebugging() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].startDebugging();
+ }
+}
+
+void RTSystemServicesProtocolConjPortRepl::stopDebugging() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports[i].stopDebugging();
+ }
+}
+
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
index ccdb38876..d2646df61 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
@@ -1,148 +1,148 @@
-/*******************************************************************************
- * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
- * 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:
- * Peter Karlitschek (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef RTSYSTEMSERVICESPROTOCOL_H_
-#define RTSYSTEMSERVICESPROTOCOL_H_
-
-#include "common/modelbase/PortBase.h"
-#include "common/modelbase/IEventReceiver.h"
-#include "common/messaging/Address.h"
-#include <vector>
-#include <string>
-#include <memory>
-
-namespace etRuntime {
-
-//---------------------------------------------------
-// interface for port class
-//---------------------------------------------------
-class IRTSystemServicesProtocolPort {
-public:
- virtual ~IRTSystemServicesProtocolPort() {};
- virtual void dummy() = 0;
-};
-
-//---------------------------------------------------
-// interface for conjugated port class
-//---------------------------------------------------
-class IRTSystemServicesProtocolConjPort {
-public:
- virtual ~IRTSystemServicesProtocolConjPort() {};
- virtual void executeInitialTransition() = 0;
- virtual void startDebugging() = 0;
- virtual void stopDebugging() = 0;
-};
-
-
-class RTSystemServicesProtocol {
-public:
- enum eventIDs {
- MSG_MIN = 0,
- OUT_dummy = 1,
- MSG_SEP = 2,
- IN_executeInitialTransition = 2,
- IN_startDebugging = 3,
- IN_stopDebugging = 4,
- MSG_MAX = 5
- };
- static bool isValidEvtID(int evtId) {
- return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
- };
- static bool isValidOutgoingEvtID(int evtId) {
- return ((MSG_MIN < evtId) && (evtId < MSG_SEP));
- };
- static bool isValidIncomingEvtID(int evtId) {
- return ((MSG_SEP <= evtId) && (evtId < MSG_MAX));
- };
- static std::string getMessageString(int msg_id);
-
- private:
- static std::string s_messageStrings[];
-
- RTSystemServicesProtocol();
- virtual ~RTSystemServicesProtocol();
-};
-
- //---------------------------------------------------
- // port class
- //---------------------------------------------------
- class RTSystemServicesProtocolPort : public PortBase , public IRTSystemServicesProtocolPort {
- public:
- RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, Address addr, Address peerAddress, bool doRegistration = true);
-
- RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, int idx, Address addr, Address peerAddress, bool doRegistration = true);
-
- virtual void receive(Message* m);
- // sent messages
- void dummy();
- };
-
- //---------------------------------------------------
- // replicated port class
- //---------------------------------------------------
- class RTSystemServicesProtocolPortRepl: public IRTSystemServicesProtocolPort {
- private:
- int m_replication;
- RTSystemServicesProtocolPort* m_ports;
-
- public:
- RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
- const std::vector<Address>& addr, const std::vector<Address> peerAddress);
-
- int getReplication() const { return m_replication; } ;
- RTSystemServicesProtocolPort& get(int i) { return m_ports[i]; };
- // outgoing messages
- void dummy();
- };
-
-
- //---------------------------------------------------
- // conjugated port class
- //---------------------------------------------------
- class RTSystemServicesProtocolConjPort : public PortBase, public IRTSystemServicesProtocolConjPort{
- public:
- RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
- std::string name, int localId, Address addr, Address peerAddress, bool doRegistration = true);
- RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
- std::string name, int localId, int idx, Address addr,
- Address peerAddress, bool doRegistration = true);
-
- virtual void receive(Message* m);
- void executeInitialTransition();
- void startDebugging();
- void stopDebugging();
- };
-
- //---------------------------------------------------
- // replicated conjugated port class
- //---------------------------------------------------
- class RTSystemServicesProtocolConjPortRepl : public IRTSystemServicesProtocolConjPort{
- private:
- int m_replication;
- RTSystemServicesProtocolConjPort* m_ports; //dynamic array used instead of vector to avoid copy construction
-
- public:
- RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
- const std::vector<Address>& addr, const std::vector<Address>& peerAddress);
-
- int getReplication() const { return m_replication; } ;
- RTSystemServicesProtocolConjPort& get(int i) { return m_ports[i]; };
-
- void executeInitialTransition();
- void startDebugging();
- void stopDebugging();
- };
-
-} /* namespace etRuntime */
-#endif /* RTSYSTEMSERVICESPROTOCOL_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
+ * 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:
+ * Peter Karlitschek (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef RTSYSTEMSERVICESPROTOCOL_H_
+#define RTSYSTEMSERVICESPROTOCOL_H_
+
+#include "common/modelbase/PortBase.h"
+#include "common/modelbase/IEventReceiver.h"
+#include "common/messaging/Address.h"
+#include <vector>
+#include <string>
+#include <memory>
+
+namespace etRuntime {
+
+//---------------------------------------------------
+// interface for port class
+//---------------------------------------------------
+class IRTSystemServicesProtocolPort {
+public:
+ virtual ~IRTSystemServicesProtocolPort() {};
+ virtual void dummy() = 0;
+};
+
+//---------------------------------------------------
+// interface for conjugated port class
+//---------------------------------------------------
+class IRTSystemServicesProtocolConjPort {
+public:
+ virtual ~IRTSystemServicesProtocolConjPort() {};
+ virtual void executeInitialTransition() = 0;
+ virtual void startDebugging() = 0;
+ virtual void stopDebugging() = 0;
+};
+
+
+class RTSystemServicesProtocol {
+public:
+ enum eventIDs {
+ MSG_MIN = 0,
+ OUT_dummy = 1,
+ MSG_SEP = 2,
+ IN_executeInitialTransition = 2,
+ IN_startDebugging = 3,
+ IN_stopDebugging = 4,
+ MSG_MAX = 5
+ };
+ static bool isValidEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
+ };
+ static bool isValidOutgoingEvtID(int evtId) {
+ return ((MSG_MIN < evtId) && (evtId < MSG_SEP));
+ };
+ static bool isValidIncomingEvtID(int evtId) {
+ return ((MSG_SEP <= evtId) && (evtId < MSG_MAX));
+ };
+ static std::string getMessageString(int msg_id);
+
+ private:
+ static std::string s_messageStrings[];
+
+ RTSystemServicesProtocol();
+ virtual ~RTSystemServicesProtocol();
+};
+
+ //---------------------------------------------------
+ // port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolPort : public PortBase , public IRTSystemServicesProtocolPort {
+ public:
+ RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, Address addr, Address peerAddress, bool doRegistration = true);
+
+ RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, int idx, Address addr, Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(Message* m);
+ // sent messages
+ void dummy();
+ };
+
+ //---------------------------------------------------
+ // replicated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolPortRepl: public IRTSystemServicesProtocolPort {
+ private:
+ int m_replication;
+ RTSystemServicesProtocolPort* m_ports;
+
+ public:
+ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
+ const std::vector<Address>& addr, const std::vector<Address> peerAddress);
+
+ int getReplication() const { return m_replication; } ;
+ RTSystemServicesProtocolPort& get(int i) { return m_ports[i]; };
+ // outgoing messages
+ void dummy();
+ };
+
+
+ //---------------------------------------------------
+ // conjugated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolConjPort : public PortBase, public IRTSystemServicesProtocolConjPort{
+ public:
+ RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, Address addr, Address peerAddress, bool doRegistration = true);
+ RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, int idx, Address addr,
+ Address peerAddress, bool doRegistration = true);
+
+ virtual void receive(Message* m);
+ void executeInitialTransition();
+ void startDebugging();
+ void stopDebugging();
+ };
+
+ //---------------------------------------------------
+ // replicated conjugated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolConjPortRepl : public IRTSystemServicesProtocolConjPort{
+ private:
+ int m_replication;
+ RTSystemServicesProtocolConjPort* m_ports; //dynamic array used instead of vector to avoid copy construction
+
+ public:
+ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
+ const std::vector<Address>& addr, const std::vector<Address>& peerAddress);
+
+ int getReplication() const { return m_replication; } ;
+ RTSystemServicesProtocolConjPort& get(int i) { return m_ports[i]; };
+
+ void executeInitialTransition();
+ void startDebugging();
+ void stopDebugging();
+ };
+
+} /* namespace etRuntime */
+#endif /* RTSYSTEMSERVICESPROTOCOL_H_ */

Back to the top