summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-09-05 02:52:04 (EDT)
committerPeter Karlitschek2012-09-05 02:52:04 (EDT)
commit584c547ca50bed54d0d5a1e23175d4d41e9e8be6 (patch)
treecaaf9a140568c18245ee97cf37f8434e72659a7f
parentf7f4e2845f08204472f0f839a678f873d973ded3 (diff)
downloadorg.eclipse.etrice-584c547ca50bed54d0d5a1e23175d4d41e9e8be6.zip
org.eclipse.etrice-584c547ca50bed54d0d5a1e23175d4d41e9e8be6.tar.gz
org.eclipse.etrice-584c547ca50bed54d0d5a1e23175d4d41e9e8be6.tar.bz2
c++ runtime: first compiled versionrefs/changes/30/8130/1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h15
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp14
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageReceiver.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp5
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp94
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h100
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTServices.h1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp261
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h138
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp52
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h73
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.cpp23
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.h37
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h34
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.cpp31
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.h40
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp19
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h12
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp146
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h70
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h39
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h43
36 files changed, 1243 insertions, 154 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
index 52ab745..551256c 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
@@ -6,6 +6,7 @@
*/
#include "DebuggingService.h"
+#include "common/modelbase/ActorClassBase.h"
namespace etRuntime {
@@ -24,22 +25,26 @@ DebuggingService::~DebuggingService() {
void DebuggingService::addMessageAsyncOut(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageAsyncOut(portInstances[source].getActor().getInstancePath(), portInstances[target].getActor().getInstancePath(), msg);
+ asyncLogger.addMessageAsyncOut(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
}
void DebuggingService::addMessageAsyncIn(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageAsyncIn(portInstances[source].getActor().getInstancePath(), portInstances[target].getActor().getInstancePath(), msg);
+ asyncLogger.addMessageAsyncIn(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
}
void DebuggingService::addMessageSyncCall(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageSyncCall(portInstances[source].getActor().getInstancePath(), portInstances[target].getActor().getInstancePath(), msg);
+ asyncLogger.addMessageSyncCall(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
}
void DebuggingService::addMessageSyncReturn(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageSyncReturn(portInstances[source].getActor().getInstancePath(), portInstances[target].getActor().getInstancePath(), msg);
+ asyncLogger.addMessageSyncReturn(portInstances.at(source)->getActorRTObject().getInstancePath(),
+ portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
}
void DebuggingService::addActorState(const ActorClassBase& actor,
@@ -47,15 +52,15 @@ void DebuggingService::addActorState(const ActorClassBase& actor,
asyncLogger.addActorState(actor.getInstancePath(), state);
}
-void DebuggingService::addPortInstance(const PortBase& port) {
- portInstances[port.getAddress()] = port;
+void DebuggingService::addPortInstance(PortBase& port) {
+ portInstances.at(port.getAddress()) = &port;
}
-const MSCLogger& DebuggingService::getSyncLogger() {
+MSCLogger& DebuggingService::getSyncLogger() {
return syncLogger;
}
-const MSCLogger& DebuggingService::getAsyncLogger() {
+MSCLogger& DebuggingService::getAsyncLogger() {
return asyncLogger;
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
index 6a1cfb9..ebfeb0f 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
@@ -37,15 +37,15 @@ public:
void addMessageSyncCall(Address source, Address target, std::string msg);
void addMessageSyncReturn(Address source, Address target, std::string msg);
void addActorState(const ActorClassBase& actor, std::string state);
- void addPortInstance(const PortBase& port);
- const MSCLogger& getSyncLogger();
- const MSCLogger& getAsyncLogger();
+ void addPortInstance(PortBase& port);
+ MSCLogger& getSyncLogger();
+ MSCLogger& getAsyncLogger();
private:
MSCLogger asyncLogger;
MSCLogger syncLogger;
- std::map<Address, PortBase> portInstances;
+ std::map<Address, PortBase*> portInstances;
DebuggingService();
DebuggingService(const DebuggingService& right);
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 191b51d..0095f8c 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
@@ -15,26 +15,27 @@
namespace etRuntime {
-class AbstractMessageReceiver: public RTObject, public IMessageReceiver {
+class AbstractMessageReceiver: public RTObject, public virtual IMessageReceiver {
public:
Address getAddress() const {
- return address_;
+ return m_address;
}
virtual ~AbstractMessageReceiver();
protected:
- AbstractMessageReceiver(IRTObject* parent, Address address, std::string name) :
- RTObject(parent, name), IMessageReceiver(), address_(address) {
+ AbstractMessageReceiver(IRTObject* parent, Address address, std::string name)
+ : IMessageReceiver(),
+ RTObject(parent, name),
+ m_address(address)
+ {
}
private:
- Address address_;
+ Address m_address;
AbstractMessageReceiver();
- AbstractMessageReceiver(const AbstractMessageReceiver& right);
- AbstractMessageReceiver& operator=(const AbstractMessageReceiver& right);
};
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 ae22624..df978c0 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
@@ -27,6 +27,20 @@ Address & Address::operator = (Address s) {
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() {
}
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 66aa9e7..1556a31 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
@@ -17,6 +17,7 @@ public:
Address(int nodeID, int threadID, int objectID);
Address(const Address & right);
Address & operator = (Address s);
+ bool operator< (const Address& right) const;
~Address();
std::string toString();
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 dd4447e..16fbe75 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
@@ -14,13 +14,14 @@
namespace etRuntime {
-class IMessageReceiver : public IRTObject{
+class IMessageReceiver{
public:
IMessageReceiver();
virtual ~IMessageReceiver();
virtual void receive(Message* msg);
virtual Address getAddress();
+ virtual bool isMsgService() { return false;};
};
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 6f242a5..e7168c9 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
@@ -15,12 +15,14 @@ namespace etRuntime {
class IRTObject {
public:
+ virtual ~IRTObject() {};
+
static const char PATH_DELIM = '/';
static const char PATHNAME_DELIM = '_';
static const std::string NO_NAME;
- std::string getInstancePath();
- std::string getInstancePathName();
+ virtual std::string getInstancePath() const = 0;
+ virtual std::string getInstancePathName() const = 0;
};
}
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 4cb814c..0b26887 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
@@ -17,16 +17,10 @@ namespace etRuntime {
class Message {
public:
// Message(Address addr) : m_address(addr), m_evtID(0), m_next(0) {};
- Message(Address addr, etInt16 evtID) :
- m_address(addr), m_evtID(evtID), m_next(0) {
- };
- Message(Address addr, etInt16 evtID, void* data) :
- m_address(addr), m_evtID(evtID), m_next(0) {
- };
- ~Message();
- etInt16 getEvtId() const {return m_evtID; };
- void* getData() const { return 0; }
- ; //TODO handling of events with data
+ Message(Address addr) :
+ m_address(addr), m_next(0)
+ {}
+ virtual ~Message();
void setNext(Message* msg){m_next = msg;}
Message* getNext() const {return m_next;}
@@ -34,11 +28,12 @@ public:
void setAddress(Address address){m_address = address; }
Address getAddress() const { return m_address; };
+ virtual bool isEvtMessage() {return false;};
+ virtual bool isEvtMessageWithData() {return false;};
std::string toString();
private:
Address m_address;
- etInt16 m_evtID;
Message* m_next;
Message();
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 a18c718..2408e34 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
@@ -22,7 +22,7 @@ public:
MessageDispatcher(IRTObject* parent, Address addr, std::string name);
void addMessageReceiver(IMessageReceiver& receiver);
void receive(Message* msg);
- Address getAddress() { return m_address; };
+ Address getAddress() const { return m_address; };
private:
std::map<int, IMessageReceiver*> m_local_map;
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 5e01704..a777a08 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
@@ -12,6 +12,7 @@ namespace etRuntime {
MessageService::MessageService(IRTObject* parent, Address addr, std::string name, int priority)
: // super("MessageService "+name),
IMessageReceiver(),
+ IRTObject(),
m_parent(parent),
m_name(name),
m_running(false),
@@ -49,7 +50,7 @@ void MessageService::receive(Message* msg) {
}
}
-std::string MessageService::getInstancePath() {
+std::string MessageService::getInstancePath() const {
std::string path = PATH_DELIM + m_name;
if (m_parent != 0)
@@ -58,7 +59,7 @@ std::string MessageService::getInstancePath() {
return path;
}
-std::string MessageService::getInstancePathName() {
+std::string MessageService::getInstancePathName() const {
std::string path = PATHNAME_DELIM + m_name;
if (m_parent != 0)
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 9f87095..01eec6a 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
@@ -17,31 +17,30 @@ namespace etRuntime {
//TODO: implementation missing yet for threads
-class MessageService: public IMessageReceiver {
+class MessageService: public IMessageReceiver, public IRTObject {
public:
- virtual ~MessageService();
-
MessageService(IRTObject* parent, Address addr, std::string name, int priority = 0);
+ virtual ~MessageService();
- Address getAddress() { return m_address; } ;
+ Address getAddress() const { return m_address; } ;
void run();
//TODO: synchronized
- void receive(Message* msg);
+ void terminate();
//TODO: synchronized
- MessageDispatcher& getMessageDispatcher() { return m_messageDispatcher; }
- std::string getInstancePath();
- std::string getInstancePathName();
-
+ void receive(Message* msg);
//TODO: synchronized
- void terminate();
+ virtual MessageDispatcher& getMessageDispatcher() { return m_messageDispatcher; }
+ virtual std::string getInstancePath() const ;
+ virtual std::string getInstancePathName() const ;
+ virtual bool isMsgService() const { return true;};
// protected methods for sole use by test cases
protected:
MessageSeQueue& getMessageQueue() { return m_messageQueue; }
//TODO: synchronized
- long getLastMessageTimestamp() { return m_lastMessageTimestamp; }
+ long getLastMessageTimestamp() const { return m_lastMessageTimestamp; }
private:
//TODO: synchronized
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 b06ffdb..e022f61 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
@@ -9,13 +9,99 @@
namespace etRuntime {
-MessageServiceController::MessageServiceController() {
- // TODO Auto-generated constructor stub
-
-}
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) {
+ // TODOTS: 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() {
+ // start all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ //TODO start thread
+ //msgSvc.start();
+ // TODOTS: start in order of priorities
+ }
+ m_running = true;
+}
+
+void MessageServiceController::stop() {
+ //dumpThreads("org.eclipse.etrice.runtime.java.messaging.MessageServiceController.stop()");
+ terminate();
+ waitTerminate();
+}
+
+void MessageServiceController::waitTerminate() {
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ //try {
+ //TODO thread join
+ //msgSvc.join();
+ //} catch (InterruptedException e1) {
+ //}
+ }
+}
+
+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) {
+ //TODO: terminate thread
+ //msgSvc.terminate();
+ // TODOTS: stop in order of priorities
+ }
+}
+
} /* 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 5d0b8bb..87c46e8 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
@@ -9,113 +9,47 @@
#define MESSAGESERVICECONTROLLER_H_
#include "common/messaging/MessageService.h"
-#include <list>
+#include "common/messaging/RTServices.h"
+#include <vector>
#include <string>
#include <iostream>
+#include <algorithm>
namespace etRuntime {
class MessageServiceController {
public:
+ MessageServiceController(/*IRTObject parent*/);
virtual ~MessageServiceController();
- MessageServiceController(/*IRTObject parent*/)
- : m_messageServiceList(),
- m_running(false) {
- // TODO: Who is parent of MessageServices and Controller?
- // this.parent = parent;
- }
-
- void addMsgSvc(MessageService msgSvc) {
- // TODOTS: Who is parent of MessageServices ?
- //TODO assert
- //assert(msgSvc.getAddress().m_threadID == m_messageServiceList.size());
- m_messageServiceList.push_back(msgSvc);
- }
-
- MessageService getMsgSvc(int threadID) {
- //TODO
- //assert(threadID < m_messageServiceList.size());
- return m_messageServiceList.get(threadID);
- }
+ void addMsgSvc(MessageService& msgSvc);
+ //raises an exception if the service does not exist for this threadID
+ MessageService* getMsgSvc(int threadID);
//the connectAll method connects all messageServices
//it is included for test purposes
//currently it is not called
- void connectAll() {
- for (size_t i = 0; i < m_messageServiceList.size(); i++) {
- MessageDispatcher& dispatcher = getMsgSvc(i).getMessageDispatcher();
- for (int j = 0; j < m_messageServiceList.size(); j++) {
- if (i != j) {
- dispatcher.addMessageReceiver(RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(j));
- }
- }
- }
- }
-
- void start() {
- // start all message services
- for (MessageService msgSvc : m_messageServiceList) {
- msgSvc.start();
- // TODOTS: start in order of priorities
- }
- m_running = true;
- }
-
- void stop() {
- //dumpThreads("org.eclipse.etrice.runtime.java.messaging.MessageServiceController.stop()");
- terminate();
- waitTerminate();
- }
+ void connectAll();
+ void start();
+ void stop();
/**
* waitTerminate waits blocking for all MessageServices to terminate
* ! not threadsafe !
*/
-public:
- void waitTerminate() {
- for (MessageService msgSvc : m_messageServiceList) {
- try {
- msgSvc.join();
- } catch (InterruptedException e1) {
- }
- }
- }
+ void waitTerminate();
protected:
- void 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 dumpThreads(std::string msg);
private:
- void terminate() {
- if (!m_running) {
- return;
- }
- m_running = false;
+ void terminate();
+
+ MessageServiceController(const MessageServiceController& right);
+ MessageServiceController& operator=(const MessageServiceController& right);
- // terminate all message services
- for (MessageService msgSvc : m_messageServiceList) {
- msgSvc.terminate();
- // TODOTS: stop in order of priorities
- }
- }
- std::list<MessageService> m_messageServiceList;
+ std::vector<MessageService*> m_messageServiceList;
// IRTObject parent = null;
bool m_running;
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 f49c876..490d5ae 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
@@ -33,7 +33,7 @@ RTObject::~RTObject() {
m_parent = 0;
}
-std::string RTObject::getInstancePath() {
+std::string RTObject::getInstancePath() const{
std::string path = PATH_DELIM + m_name;
if (m_parent != 0)
@@ -42,7 +42,7 @@ std::string RTObject::getInstancePath() {
return path;
}
-std::string RTObject::getInstancePathName() {
+std::string RTObject::getInstancePathName() const{
std::string path = PATHNAME_DELIM + m_name;
if (m_parent != 0)
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 3c555ec..530fb66 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
@@ -13,7 +13,7 @@
namespace etRuntime {
-class RTObject : public IRTObject{
+class RTObject : public virtual IRTObject{
public:
RTObject();
RTObject(IRTObject* parent, std::string name);
@@ -22,9 +22,9 @@ public:
virtual ~RTObject();
- IRTObject* getParent() { return m_parent; };
- std::string getInstancePath();
- std::string getInstancePathName();
+ virtual IRTObject* getParent() const { return m_parent; };
+ virtual std::string getInstancePath() const;
+ virtual std::string getInstancePathName() const;
private:
IRTObject* m_parent;
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 7c2a9d0..05348de 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
@@ -12,6 +12,7 @@
namespace etRuntime {
class SubSystemClassBase;
+class MessageServiceController;
class RTServices {
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
new file mode 100644
index 0000000..fcaf8cc
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
@@ -0,0 +1,261 @@
+/*
+ * RTSystemServicesProtocol.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "RTSystemServicesProtocol.h"
+#include "common/modelbase/EventMessage.h"
+#include "common/modelbase/EventWithDataMessage.h"
+
+namespace etRuntime {
+
+std::string RTSystemServicesProtocol::s_messageStrings[] =
+ { "MIN",
+ "dummy",
+ "executeInitialTransition",
+ "startDebugging",
+ "stopDebugging",
+ "MAX"};
+
+RTSystemServicesProtocol::RTSystemServicesProtocol() {
+}
+
+RTSystemServicesProtocol::~RTSystemServicesProtocol() {
+}
+
+std::string RTSystemServicesProtocol::getMessageString(int msg_id) {
+ if (msg_id < MSG_MIN || msg_id > MSG_MAX + 1) {
+ // id out of range
+ return "Message ID out of range";
+ } else {
+ return s_messageStrings[msg_id];
+ }
+}
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolPort
+//------------------------------------------------------------------
+
+RTSystemServicesProtocol::RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, Address addr, Address peerAddress)
+:PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+{
+ DebuggingService::getInstance().addPortInstance(*this);
+};
+
+RTSystemServicesProtocol::RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, int idx, Address addr, Address peerAddress)
+: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+{
+ DebuggingService::getInstance().addPortInstance(*this);
+};
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolPort::receive(Message m) {
+ if (!(m.isEvtMessage()))
+ return;
+ EventMessage& msg(static_cast<EventMessage&>(m));
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ std::cout << "unknown" << std::endl;
+ else {
+ if (s_messageStrings[msg.getEvtId()] != "timerTick") {
+ // TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncIn(
+ getPeerAddress(), getAddress(),
+ s_messageStrings[msg.getEvtId()]);
+ }
+
+ if (msg.isEvtMessageWithData())
+ getActor().receiveEvent(*this, msg.getEvtId(),
+ (static_cast<EventWithDataMessage&>(msg)).getData());
+ else
+ getActor().receiveEvent(*this, msg.getEvtId(), 0);
+
+ }
+};
+
+// sent messages
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolPort::dummy() {
+
+ if (s_messageStrings[OUT_dummy] != "timerTick") {
+ // TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), s_messageStrings[OUT_dummy]);
+ }
+ if (getPeerAddress().isValid())
+ getPeerMsgReceiver()->receive(
+ new EventMessage(getPeerAddress(), OUT_dummy));
+
+};
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolPortRepl
+//------------------------------------------------------------------
+
+
+RTSystemServicesProtocol::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);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ m_ports.push_back(RTSystemServicesProtocolPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]));
+ }
+};
+
+int RTSystemServicesProtocol::RTSystemServicesProtocolPortRepl::getReplication() {
+ return m_replication;
+};
+
+RTSystemServicesProtocol::RTSystemServicesProtocolPort& RTSystemServicesProtocol::RTSystemServicesProtocolPortRepl::get(int i) {
+ return m_ports.at(i);
+};
+
+// outgoing messages
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolPortRepl::dummy() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports.at(i).dummy();
+ }
+};
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolConjPort
+//------------------------------------------------------------------
+
+RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, Address addr, Address peerAddress)
+ : PortBase(actor, parent, name, localId, 0, addr, peerAddress)
+{
+ DebuggingService::getInstance().addPortInstance(*this);
+}
+RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, int idx, Address addr,
+ Address peerAddress)
+: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
+{
+ DebuggingService::getInstance().addPortInstance(*this);
+}
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::receive(Message m) {
+ if (!(m.isEvtMessage()))
+ return;
+ EventMessage& msg(static_cast<EventMessage&>(m));
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ std::cout << "unknown" << std::endl;
+ else {
+ if (s_messageStrings[msg.getEvtId()] != "timerTick") {
+ // TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncIn(
+ getPeerAddress(), getAddress(),
+ s_messageStrings[msg.getEvtId()]);
+ }
+
+ if (msg.isEvtMessageWithData())
+ getActor().receiveEvent(*this, msg.getEvtId(),
+ (static_cast<EventWithDataMessage&>(msg)).getData());
+ else
+ getActor().receiveEvent(*this, msg.getEvtId(), 0);
+
+
+ }
+}
+
+// sent messages
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::executeInitialTransition() {
+
+ if (s_messageStrings[IN_executeInitialTransition] != "timerTick") {
+ // TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(),
+ s_messageStrings[IN_executeInitialTransition]);
+ }
+ if (getPeerAddress().isValid())
+ getPeerMsgReceiver()->receive(
+ new EventMessage(getPeerAddress(),
+ IN_executeInitialTransition));
+
+}
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::startDebugging() {
+
+ if (s_messageStrings[IN_startDebugging] != "timerTick") {
+ // TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), s_messageStrings[IN_startDebugging]);
+ }
+ if (getPeerAddress().isValid())
+ getPeerMsgReceiver()->receive(
+ new EventMessage(getPeerAddress(), IN_startDebugging));
+
+}
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPort::stopDebugging() {
+
+ if (s_messageStrings[IN_stopDebugging] != "timerTick") {
+ // TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), s_messageStrings[IN_stopDebugging]);
+ }
+ if (getPeerAddress().isValid())
+ getPeerMsgReceiver()->receive(
+ new EventMessage(getPeerAddress(), IN_stopDebugging));
+
+}
+
+//------------------------------------------------------------------
+// RTSystemServicesProtocolConjPortRepl
+//------------------------------------------------------------------
+
+//TODO: data type of addr and peerAddress
+RTSystemServicesProtocol::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.reserve(m_replication);
+ for (int i = 0; i < m_replication; ++i) {
+ snprintf(numstr, sizeof(numstr), "%d", i);
+ m_ports.push_back(RTSystemServicesProtocolConjPort(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]));
+ }
+};
+
+int RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::getReplication() {
+ return m_replication;
+}
+
+RTSystemServicesProtocol::RTSystemServicesProtocolConjPort& RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::get(int i) {
+ return m_ports.at(i);
+}
+
+// incoming messages
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports.at(i).executeInitialTransition();
+ }
+}
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::startDebugging() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports.at(i).startDebugging();
+ }
+}
+
+void RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl::stopDebugging() {
+ for (int i = 0; i < m_replication; ++i) {
+ m_ports.at(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
new file mode 100644
index 0000000..dcf5fe4
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h
@@ -0,0 +1,138 @@
+/*
+ * RTSystemServicesProtocol.h
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef RTSYSTEMSERVICESPROTOCOL_H_
+#define RTSYSTEMSERVICESPROTOCOL_H_
+#include "common/debugging/DebuggingService.h"
+#include "common/modelbase/PortBase.h"
+#include "common/modelbase/IEventReceiver.h"
+#include "common/messaging/Address.h"
+#include <vector>
+
+namespace etRuntime {
+
+class RTSystemServicesProtocol {
+public:
+ RTSystemServicesProtocol();
+ virtual ~RTSystemServicesProtocol();
+
+ // message IDs
+ // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
+ // error if msgID <= MSG_MIN
+ static const int MSG_MIN = 0;
+ //IDs for outgoing messages
+ static const int OUT_dummy = 1;
+
+ //IDs for incoming messages
+ static const int IN_executeInitialTransition = 2;
+ static const int IN_startDebugging = 3;
+ static const int IN_stopDebugging = 4;
+
+ //error if msgID >= MSG_MAX
+ static const int MSG_MAX = 5;
+
+private:
+ static std::string s_messageStrings[];
+
+public:
+ static std::string getMessageString(int msg_id);
+
+ //---------------------------------------------------
+ // port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolPort : public PortBase {
+ public:
+ RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, Address addr, Address peerAddress);
+
+ RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
+ int localId, int idx, Address addr, Address peerAddress);
+
+ void receive(Message m); // sent messages
+ void dummy();
+ };
+
+ //---------------------------------------------------
+ // replicated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolPortRepl {
+ private:
+ int m_replication;
+ std::vector<RTSystemServicesProtocolPort> m_ports;
+
+ public:
+ //TODO: data type of addr and peerAddress?
+ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress);
+
+ int getReplication();
+ RTSystemServicesProtocolPort& get(int i); // outgoing messages
+ void dummy();
+ };
+
+ //---------------------------------------------------
+ // interface for port class
+ //---------------------------------------------------
+ class IRTSystemServicesProtocolPort {
+ public:
+ virtual void executeInitialTransition() = 0;
+ virtual void startDebugging() = 0;
+ virtual void stopDebugging() = 0;
+
+ };
+
+ //---------------------------------------------------
+ // port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolConjPort : public PortBase {
+ public:
+ RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, Address addr, Address peerAddress);
+ RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, int idx, Address addr,
+ Address peerAddress);
+
+ void receive(Message m);
+ void executeInitialTransition();
+ void startDebugging();
+ void stopDebugging();
+ };
+
+ //---------------------------------------------------
+ // replicated port class
+ //---------------------------------------------------
+ class RTSystemServicesProtocolConjPortRepl {
+ private:
+ int m_replication;
+ std::vector<RTSystemServicesProtocolConjPort> m_ports;
+
+ public:
+ //TODO: data type of addr and peerAddress
+ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent,
+ std::string name, int localId, const std::vector<Address>& addr, const std::vector<Address> peerAddress);
+
+ int getReplication();
+ RTSystemServicesProtocolConjPort& get(int i);
+
+ void executeInitialTransition();
+ void startDebugging();
+ void stopDebugging();
+
+ };
+
+ //---------------------------------------------------
+ // interface for conjugated port class
+ //---------------------------------------------------
+ class IRTSystemServicesProtocolConjPort {
+ public:
+ virtual void dummy() = 0;
+
+ };
+
+ };
+
+} /* namespace etRuntime */
+#endif /* RTSYSTEMSERVICESPROTOCOL_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
new file mode 100644
index 0000000..771c8b3
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
@@ -0,0 +1,52 @@
+/*
+ * ActorClassBase.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "ActorClassBase.h"
+
+namespace etRuntime {
+
+ActorClassBase::ActorClassBase(IRTObject* parent, std::string name, Address ownAddr, Address systemPortPeerAddr)
+ : EventReceiver(parent, name),
+ IMessageReceiver(),
+ m_state(),
+ m_RTSystemPort(0),
+ m_className("noname"),
+ m_ownAddr(ownAddr),
+ m_ownMsgsvc(RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(ownAddr.m_threadID)) {
+
+ // own ports
+ m_RTSystemPort = new RTSystemServicesProtocol::RTSystemServicesProtocolPort(*this, this, "RTSystemPort", 0, 0, ownAddr,
+ systemPortPeerAddr);
+}
+
+ActorClassBase::~ActorClassBase() {
+ delete m_RTSystemPort;
+ m_RTSystemPort = 0;
+}
+
+bool ActorClassBase::handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data) {
+ if (ifitem.getLocalId() != 0) {
+ return false;
+ }
+
+ switch (evt) {
+ case RTSystemServicesProtocol::IN_executeInitialTransition:
+ executeInitTransition();
+ break;
+ case RTSystemServicesProtocol::IN_startDebugging:
+ break;
+ case RTSystemServicesProtocol::IN_stopDebugging:
+ break;
+ }
+ return true;
+}
+
+std::string ActorClassBase::toString() {
+ return "ActorClass(className=" + m_className + ", instancePath=" + getInstancePath() + ")";
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
new file mode 100644
index 0000000..28dc8a1
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
@@ -0,0 +1,73 @@
+/*
+ * ActorClassBase.h
+ *
+ * The base class for model actor classes.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef ACTORCLASSBASE_H_
+#define ACTORCLASSBASE_H_
+
+#include "common/modelbase/EventReceiver.h"
+#include "common/messaging/IMessageReceiver.h"
+#include "common/messaging/RTServices.h"
+#include "common/messaging/RTSystemServicesProtocol.h"
+
+namespace etRuntime {
+
+class ActorClassBase: public EventReceiver, public IMessageReceiver {
+public:
+ ActorClassBase(IRTObject* parent, std::string name, Address ownAddr, Address systemPortPeerAddr);
+ virtual ~ActorClassBase();
+
+ std::string toString();
+ std::string getClassName() const { return m_className; }
+ void setClassName(std::string className) { m_className = className; }
+ Address getAddress() const {
+ // TODO: Actor should have its own address for services and debugging
+ return Address(0,0,0);
+ }
+
+ //--------------------- lifecycle functions
+ // automatically generated lifecycle functions
+ virtual void init() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
+ virtual void destroy() = 0;
+ virtual void executeInitTransition() = 0;
+
+ // not automatically generated lifecycle functions
+ // are called, but with empty implementation -> can be overridden by user
+ void initUser() { }
+ void startUser() { }
+ void stopUser() { }
+ void destroyUser() { }
+ void receive(Message msg) { }
+
+ int getState() const { return m_state; }
+ MessageService* getMsgsvc() const { return m_ownMsgsvc; }
+
+protected:
+ static const int EVT_SHIFT = 1000; // TODOHRR: use 256 or shift operation later
+ static const int NO_STATE = 0;
+ static const int STATE_TOP = 1;
+ static const int NOT_CAUGHT = 0;
+
+ /**
+ * the current state
+ */
+ int m_state;
+ RTSystemServicesProtocol::RTSystemServicesProtocolPort* m_RTSystemPort;
+
+ bool handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data);
+private:
+ std::string m_className;
+ Address m_ownAddr;
+ MessageService* m_ownMsgsvc;
+
+};
+
+} /* namespace etRuntime */
+#endif /* ACTORCLASSBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.cpp
new file mode 100644
index 0000000..02300b8
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.cpp
@@ -0,0 +1,23 @@
+/*
+ * EventMessage.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "EventMessage.h"
+#include <sstream>
+
+namespace etRuntime {
+
+std::string EventMessage::toString() {
+ std::stringstream strm;
+ strm << "EventMessage(" << getAddress().toString() << ", evt=" << m_evtId << ")";
+ return strm.str();
+
+}
+
+EventMessage::~EventMessage() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.h
new file mode 100644
index 0000000..5fa7b85
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventMessage.h
@@ -0,0 +1,37 @@
+/*
+ * EventMessage.h
+ *
+ * A message carrying an event id.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef EVENTMESSAGE_H_
+#define EVENTMESSAGE_H_
+
+#include "common/messaging/Message.h"
+#include <string>
+
+namespace etRuntime {
+
+class EventMessage: public Message {
+public:
+ EventMessage(Address address, int evtId)
+ : Message(address),
+ m_evtId(evtId) {
+ }
+ virtual ~EventMessage();
+ int getEvtId() { return m_evtId; }
+ virtual bool isEvtMessage() {return true;};
+
+ std::string toString();
+
+private:
+ int m_evtId;
+
+ EventMessage();
+};
+
+} /* namespace etRuntime */
+#endif /* EVENTMESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
new file mode 100644
index 0000000..64026d8
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
@@ -0,0 +1,16 @@
+/*
+ * EventReceiver.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "EventReceiver.h"
+
+namespace etRuntime {
+
+
+EventReceiver::~EventReceiver() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
new file mode 100644
index 0000000..05cad0c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
@@ -0,0 +1,34 @@
+/*
+ * EventReceiver.h
+ *
+ * The abstract base class for event receivers.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef EVENTRECEIVER_H_
+#define EVENTRECEIVER_H_
+
+#include "common/messaging/RTObject.h"
+#include "common/modelbase/IEventReceiver.h"
+#include <string>
+
+namespace etRuntime {
+
+class EventReceiver : public RTObject, public IEventReceiver{
+public:
+ EventReceiver(IRTObject* parent, std::string name)
+ : RTObject(parent, name),
+ IEventReceiver()
+ {};
+ virtual ~EventReceiver();
+
+private:
+ EventReceiver(const EventReceiver& right);
+ EventReceiver& operator=(const EventReceiver& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* EVENTRECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.cpp
new file mode 100644
index 0000000..e2f90fb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.cpp
@@ -0,0 +1,31 @@
+/*
+ * EventWithDataMessage.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "EventWithDataMessage.h"
+#include <sstream>
+
+namespace etRuntime {
+
+EventWithDataMessage::~EventWithDataMessage() {
+}
+
+std::string EventWithDataMessage::toString() {
+ std::stringstream strm;
+ strm << "EventWithDataMessage(" << getAddress().toString() << ", evt=" << getEvtId() + ", m_data=" << dataToString() << ")";
+ return strm.str();
+}
+
+std::string EventWithDataMessage::dataToString() {
+ if (m_data == 0) {
+ return "()";
+ }
+ //TODO: how to do this with all kinds of data??
+ //return "(" + m_data + ")";
+ return "()";
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.h
new file mode 100644
index 0000000..01ed3fd
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventWithDataMessage.h
@@ -0,0 +1,40 @@
+/*
+ * EventWithDataMessage.h
+ *
+ * An event message carrying an arbitrary number of objects.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef EVENTWITHDATAMESSAGE_H_
+#define EVENTWITHDATAMESSAGE_H_
+#include "common/modelbase/EventMessage.h"
+#include <string>
+
+namespace etRuntime {
+
+class EventWithDataMessage: public EventMessage {
+public:
+ virtual ~EventWithDataMessage();
+
+ EventWithDataMessage(Address address, int evtId, void* data)
+ : EventMessage(address, evtId),
+ m_data(data) {
+ }
+ virtual bool isEvtMessageWithData() {return true;};
+
+ void* getData() { return m_data; }
+
+ std::string toString();
+ std::string dataToString();
+
+private:
+ void* m_data;
+
+ EventWithDataMessage();
+
+};
+
+} /* namespace etRuntime */
+#endif /* EVENTWITHDATAMESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h
index 177716f..6e2863a 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/IEventReceiver.h
@@ -14,7 +14,7 @@
namespace etRuntime {
class InterfaceItemBase;
-class IEventReceiver : public IRTObject{
+class IEventReceiver {
public:
IEventReceiver();
virtual ~IEventReceiver();
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
index 1cc2af0..c5c2bc6 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
@@ -6,23 +6,28 @@
*/
#include "InterfaceItemBase.h"
+#include "common/messaging/AbstractMessageReceiver.h"
+#include "common/messaging/RTServices.h"
namespace etRuntime {
-InterfaceItemBase::InterfaceItemBase (const IEventReceiver& actor, std::string name, int localId, int idx, Address ownAddress, Address peerAddress)
-: AbstractMessageReceiver(actor, ownAddress, name),
+InterfaceItemBase::InterfaceItemBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress)
+: AbstractMessageReceiver(parent, ownAddress, name),
m_idx(idx),
m_localId(localId),
m_peerAddress(peerAddress),
- m_ownMsgReceiver(RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(ownAddress.m_threadID)),
- m_peerMsgReceiver(peerAddress.isValid()? RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(peerAddress.m_threadID): 0)
+ m_ownMsgReceiver(RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(ownAddress.m_threadID)),
+ m_peerMsgReceiver(peerAddress.isValid()? RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(peerAddress.m_threadID): 0),
+ m_actor(&actor)
{
- if (getAddress()!=null && this.ownMsgReceiver instanceof MessageService) {
- MessageService ms = (MessageService) this.ownMsgReceiver;
+ if (getAddress().isValid() && m_ownMsgReceiver->isMsgService()) {
+ MessageService* ms = static_cast<MessageService*>(m_ownMsgReceiver);
// register at the own dispatcher to receive messages
- ms.getMessageDispatcher().addMessageReceiver(this);
+ ms->getMessageDispatcher().addMessageReceiver(*this);
+ }
}
+
InterfaceItemBase::~InterfaceItemBase() {
// TODO Auto-generated destructor stub
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
index 620a53d..7f144dc 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
@@ -20,12 +20,13 @@ class IEventReceiver;
class InterfaceItemBase : public AbstractMessageReceiver{
public:
- InterfaceItemBase (const IEventReceiver& actor, std::string name, int localId, int idx, Address ownAddress, Address peerAddress);
+ InterfaceItemBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress);
virtual ~InterfaceItemBase();
int getIdx() const { return m_idx; } ;
- IEventReceiver* getActor() { return static_cast<IEventReceiver*>(getParent()); };
- int getLocalId() {return m_localId; };
+ IEventReceiver& getActor() { return *m_actor; };
+ IRTObject& getActorRTObject() { return *this; };
+ int getLocalId() const {return m_localId; };
void setMsgReceiver(IMessageReceiver& msgReceiver) { m_ownMsgReceiver = &msgReceiver; };
@@ -35,7 +36,6 @@ protected:
Address getPeerAddress() const { return m_peerAddress; };
private:
- InterfaceItemBase();
int m_idx;
int m_localId;
@@ -43,6 +43,10 @@ private:
Address m_peerAddress;
IMessageReceiver* m_ownMsgReceiver;
IMessageReceiver* m_peerMsgReceiver;
+ IEventReceiver* m_actor;
+
+ InterfaceItemBase();
+
};
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
index b472820..96b510c 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
@@ -17,8 +17,8 @@ class IEventReceiver;
class PortBase : public InterfaceItemBase{
public:
- PortBase (const IEventReceiver& actor, std::string name, int localId, int idx, Address address, Address peerAddress)
- : InterfaceItemBase(actor, name, localId, idx, address, peerAddress){};
+ PortBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address address, Address peerAddress)
+ : InterfaceItemBase(actor, parent, name, localId, idx, address, peerAddress){};
virtual ~PortBase();
private:
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
new file mode 100644
index 0000000..173cb77
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
@@ -0,0 +1,146 @@
+/*
+ * SubSystemClassBase.cpp
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#include "SubSystemClassBase.h"
+#include "common/messaging/MessageService.h"
+#include "common/messaging/RTServices.h"
+#include "ActorClassBase.h"
+
+namespace etRuntime {
+
+
+SubSystemClassBase::~SubSystemClassBase() {
+ // TODO Auto-generated destructor stub
+}
+
+SubSystemClassBase::SubSystemClassBase(IRTObject* parent, std::string name)
+ : RTObject(parent, name),
+ IEventReceiver(),
+ m_RTSystemPort(0),
+ m_instances(),
+ m_testSem(0),
+ m_testErrorCode(0)
+{
+ DebuggingService::getInstance().getAsyncLogger().setMSC(name + "_Async", "");
+ DebuggingService::getInstance().getAsyncLogger().open();
+ DebuggingService::getInstance().getSyncLogger().setMSC(name + "_Sync", "");
+ DebuggingService::getInstance().getSyncLogger().open();
+
+ RTServices::getInstance().setSubSystem(this);
+}
+
+void SubSystemClassBase::init() {
+
+ std::cout << "*** MainComponent " << getInstancePath() << "::init ***" << std::endl;
+
+ // MessageService
+ instantiateMessageServices();
+
+ // this is the place to connect the message services if necessary
+ // normaly the ports will address the correct target message service directly
+ // it is just for test purposes
+ // RTServices::getInstance().getMsgSvcCtrl().connectAll();
+
+ instantiateActors();
+
+ // initialize all actor m_instances
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ m_instances[i]->init();
+ }
+}
+
+void SubSystemClassBase::start() {
+ // start all actors instances
+ m_RTSystemPort->executeInitialTransition();
+
+ // start all message services
+ RTServices::getInstance().getMsgSvcCtrl().start();
+
+}
+
+void SubSystemClassBase::stop() {
+ std::cout << "*** MainComponent " << this->getInstancePath() << "::stop ***" << std::endl;
+
+ RTServices::getInstance().getMsgSvcCtrl().stop();
+ std::cout << "=== done stop MsgSvcCtrl" << std::endl;
+
+ // stop all actor instances
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ m_instances[i]->stop();
+ }
+ std::cout << "=== done stop actor instances" << std::endl;
+}
+
+void SubSystemClassBase::destroy() {
+ std::cout << "*** MainComponent " << this->getInstancePath() << "::destroy ***" << std::endl;
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ m_instances[i]->destroy();
+ }
+ std::cout << "=== done destroy actor instances" << std::endl;
+
+ DebuggingService::getInstance().getAsyncLogger().close();
+ DebuggingService::getInstance().getSyncLogger().close();
+ std::cout << "=== done close loggers" << std::endl;
+
+ RTServices::getInstance().destroy();
+ std::cout << "=== done destroy RTServices\n\n\n" << std::endl;
+}
+
+MessageService* SubSystemClassBase::getMsgService(int idx) const {
+ return RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(idx);
+}
+
+ActorClassBase* SubSystemClassBase::getInstance(unsigned int i) {
+ if (i < 0 || i >= m_instances.size())
+ return 0;
+
+ return m_instances[i];
+}
+
+ActorClassBase* SubSystemClassBase::getInstance(std::string path) {
+ for (unsigned int i = 0; i < m_instances.size(); i++) {
+ if (m_instances[i]->getInstancePath() == path)
+ return m_instances[i];
+ }
+
+ return 0;
+}
+
+// this is to run integration tests
+// TODO synchronized
+void SubSystemClassBase::setTestSemaphore(TestSemaphore* sem) {
+ m_testErrorCode = -1;
+ m_testSem = sem;
+}
+
+//TODO synchronized
+int SubSystemClassBase::getTestErrorCode() const {
+ return m_testErrorCode;
+}
+
+void SubSystemClassBase::testFinished(int errorCode) {
+ if (m_testSem != 0) {
+ std::cout
+ << "org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): before releasing semaphore"
+ << std::endl;
+ //m_testSem.printWaitingThreads();
+ //TODO synchronized (this) {
+ m_testErrorCode = errorCode;
+ m_testSem->release(1);
+ //}
+ std::cout
+ << "org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): semaphore released"
+ << std::endl;
+ //m_testSem.printWaitingThreads();
+ //TODO
+ //Thread.yield();
+ }
+}
+
+
+} /* namespace etRuntime */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
new file mode 100644
index 0000000..c1da895
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
@@ -0,0 +1,70 @@
+/*
+ * SubSystemClassBase.h
+ *
+ * The base class for all SubSystems.
+ * It and its derived classes take care of the instantiation, binding (connection) and complete lifecycle of all Actor Classes of a SubSystem
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef SUBSYSTEMCLASSBASE_H_
+#define SUBSYSTEMCLASSBASE_H_
+
+#include "common/messaging/RTSystemServicesProtocol.h"
+#include "common/messaging/IRTObject.h"
+#include "common/debugging/MSCLogger.h"
+#include "common/modelbase/TestSemaphore.h"
+#include <string>
+#include <vector>
+#include <iostream>
+
+namespace etRuntime {
+
+class MessageService;
+class ActorClassBase;
+
+class SubSystemClassBase: public RTObject, public IEventReceiver {
+public:
+ SubSystemClassBase(IRTObject* parent, std::string name);
+ virtual ~SubSystemClassBase();
+
+ void init();
+ virtual void instantiateMessageServices() = 0;
+ virtual void instantiateActors() = 0;
+
+ void start();
+ void stop();
+
+ void destroy();
+
+ MessageService* getMsgService(int idx) const;
+
+ ActorClassBase* getInstance(unsigned int i);
+ ActorClassBase* getInstance(std::string path);
+
+ //---------------------------------------------
+ // this is to run integration tests
+ //---------------------------------------------
+ // TODO synchronized
+ void setTestSemaphore(TestSemaphore* sem);
+ //TODO synchronized
+ int getTestErrorCode() const;
+ void testFinished(int errorCode);
+
+protected:
+ RTSystemServicesProtocol::RTSystemServicesProtocolConjPortRepl* m_RTSystemPort;
+ //--------------------- interface item IDs
+ static const int IFITEM_RTSystemPort = 0;
+ std::vector<ActorClassBase*> m_instances;
+private:
+ TestSemaphore* m_testSem;
+ int m_testErrorCode;
+
+ SubSystemClassBase();
+ SubSystemClassBase(const SubSystemClassBase& right);
+ SubSystemClassBase& operator=(const SubSystemClassBase& right);
+};
+
+} /* namespace etRuntime */
+#endif /* SUBSYSTEMCLASSBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
new file mode 100644
index 0000000..8af196b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
@@ -0,0 +1,21 @@
+/*
+ * SubSystemRunnerBase.cpp
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#include "SubSystemRunnerBase.h"
+
+namespace etRuntime {
+
+SubSystemRunnerBase::SubSystemRunnerBase() {
+ // TODO Auto-generated constructor stub
+
+}
+
+SubSystemRunnerBase::~SubSystemRunnerBase() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
new file mode 100644
index 0000000..ffc6d23
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
@@ -0,0 +1,39 @@
+/*
+ * SubSystemRunnerBase.h
+ *
+ * The base class for running components.
+ *
+ * Created on: 29.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef SUBSYSTEMRUNNERBASE_H_
+#define SUBSYSTEMRUNNERBASE_H_
+
+#include <iostream>
+
+namespace etRuntime {
+
+class SubSystemRunnerBase {
+public:
+ SubSystemRunnerBase();
+ ~SubSystemRunnerBase();
+
+ /**
+ * blocks until the String "quit" is entered on the console
+ */
+protected:
+ static void waitForQuit() {
+ // waiting for command line input
+ std::string token = "";
+ std::cout << "type 'quit' to exit" << std::endl;
+ while (token != "quit") {
+ std::getline(std::cin, token);
+ std::cout << "echo: " << token << std::endl;
+ }
+ }
+
+};
+
+} /* namespace etRuntime */
+#endif /* SUBSYSTEMRUNNERBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
new file mode 100644
index 0000000..e513816
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
@@ -0,0 +1,16 @@
+/*
+ * TestSemaphore.cpp
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#include "TestSemaphore.h"
+
+namespace etRuntime {
+
+
+TestSemaphore::~TestSemaphore() {
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
new file mode 100644
index 0000000..e10b04d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
@@ -0,0 +1,43 @@
+/*
+ * TestSemaphore.h
+ *
+ * Created on: 31.08.2012
+ * Author: karlitsc
+ */
+
+#ifndef TESTSEMAPHORE_H_
+#define TESTSEMAPHORE_H_
+
+#include <iostream>
+
+namespace etRuntime {
+
+class TestSemaphore { //extends Semaphore
+public:
+ virtual ~TestSemaphore();
+
+ TestSemaphore(int permits) {
+ }
+ void release(int count) {};
+
+ void printWaitingThreads() {
+ std::cout << ">>> begin semaphore info >>>" << std::endl;
+// std::cout << "current thread is " + Thread.currentThread().getName() << std::endl;
+// Collection < Thread > threads = getQueuedThreads();
+// if (threads.isEmpty())
+// std::cout << " no waiting threads" << std::endl;
+// else
+// for (Thread thread : threads) {
+// std::cout << " blocked: " << thread.getName() << std::endl;
+// }
+ std::cout << "<<< end semaphore info <<<" << std::endl;
+ }
+private:
+ TestSemaphore();
+ TestSemaphore(const TestSemaphore& right);
+ TestSemaphore& operator=(const TestSemaphore& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* TESTSEMAPHORE_H_ */