Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.cpp')
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.cproject5
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp18
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h9
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h1
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp60
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.h17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h2
-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/SubSystemRunnerBase.cpp8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etTimer.c39
18 files changed, 120 insertions, 86 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.cproject b/runtime/org.eclipse.etrice.runtime.cpp/.cproject
index 66d3daac4..c6d7573ce 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/.cproject
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.cproject
@@ -54,7 +54,6 @@
</toolChain>
</folderInfo>
<sourceEntries>
- <entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
@@ -83,7 +82,7 @@
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.release.2033657787" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.release"/>
<builder buildPath="${workspace_loc:/org.eclipse.etrice.runtime.cpp/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.629737011" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release.1791075014" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release">
- <option id="gnu.both.asm.option.include.paths.227502240" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath"/>
+ <option id="gnu.both.asm.option.include.paths.227502240" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1768068662" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release.633341399" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release"/>
@@ -100,8 +99,8 @@
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.lib.release.option.optimization.level.180068255" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.lib.release.option.debugging.level.1290753638" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1098867338" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platforms/generic}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/platforms/generic}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1857566126" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
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 e1835e344..17593038c 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
@@ -7,6 +7,7 @@
#include "DebuggingService.h"
#include "common/modelbase/ActorClassBase.h"
+#include <iostream>
namespace etRuntime {
@@ -54,6 +55,7 @@ void DebuggingService::addActorState(const ActorClassBase& actor,
void DebuggingService::addPortInstance(PortBase& port) {
portInstances[port.getAddress()] = &port;
+ std::cout << "adding " << port.getAddress().toID() << " " << &port << " " << port.getParent()->getInstancePathName()<< std::endl;
}
MSCLogger& DebuggingService::getSyncLogger() {
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 dc64afa95..aa1c49e22 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
@@ -7,6 +7,7 @@
#include "Address.h"
#include <sstream>
+#include <iostream>
namespace etRuntime {
@@ -48,13 +49,13 @@ bool Address::operator< (const Address& right) const {
Address::~Address() {
}
-std::string Address::toString(){
+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(){
+std::string Address::toID() const{
std::stringstream strm;
strm << m_nodeID << "_" << m_threadID << "_" << m_objectID;
return strm.str();
@@ -64,5 +65,18 @@ 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 857f7daab..66a164b16 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
@@ -9,6 +9,7 @@
#define ADDRESS_H_
#include <string>
+#include <vector>
namespace etRuntime {
@@ -20,8 +21,8 @@ public:
bool operator< (const Address& right) const;
~Address();
- std::string toString();
- std::string toID();
+ std::string toString() const;
+ std::string toID()const;
Address createInc(int i);
bool isValid() const {
@@ -32,6 +33,10 @@ public:
int m_threadID;
int m_objectID;
+ //debug helper function
+ static void printAddrVector(const std::vector<std::vector<etRuntime::Address> >& addresses);
+
+
private:
};
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 7b38e047c..f709d47b6 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
@@ -68,5 +68,6 @@ if (receiver!=0)
// 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 2408e34e4..1a246e959 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,6 +22,7 @@ public:
MessageDispatcher(IRTObject* parent, Address addr, std::string name);
void addMessageReceiver(IMessageReceiver& receiver);
void receive(Message* msg);
+
Address getAddress() const { return m_address; };
private:
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 cbba84a92..264b4fbce 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
@@ -21,7 +21,9 @@ MessageService::MessageService(IRTObject* parent, Address addr, std::string name
Address(addr.m_nodeID, addr.m_threadID, addr.m_objectID + 1),
"Dispatcher"),
m_address(addr),
- m_lastMessageTimestamp(0) {
+ m_lastMessageTimestamp(0),
+ m_asyncActors()
+{
// check and set priority
// assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (1)");
@@ -42,6 +44,7 @@ void MessageService::run() {
}
void MessageService::runOnce() {
+ pollAsyncActors();
while (m_messageQueue.isNotEmpty()){
pollOneMessage();
}
@@ -100,5 +103,17 @@ void MessageService::pollOneMessage() {
}
+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 75fbff240..a9d25cb62 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
@@ -9,8 +9,10 @@
#define MESSAGESERVICE_H_
#include <string>
+#include <vector>
#include "common/messaging/MessageDispatcher.h"
#include "common/messaging/Address.h"
+#include "common/modelbase/IEventReceiver.h"
#include "MessageSeQueue.h"
namespace etRuntime {
@@ -38,6 +40,10 @@ public:
virtual std::string getInstancePathName() const ;
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; }
@@ -59,6 +65,8 @@ private:
Address m_address;
long m_lastMessageTimestamp;
+ std::vector<IEventReceiver*> m_asyncActors;
+
MessageService();
MessageService(const MessageService& right);
MessageService& operator=(const MessageService& right);
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 3a47e7d57..e095ed02b 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
@@ -108,7 +108,7 @@ void MessageServiceController::runOnce() {
if (!m_running) {
return;
}
- m_running = false;
+ //m_running = false;
// terminate all message services
for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
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 57fd7cb10..a0668838c 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
@@ -26,6 +26,9 @@ public:
//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
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 24fd082b3..5b2bc9f74 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
@@ -44,17 +44,21 @@ RTSystemServicesProtocol::~RTSystemServicesProtocol() {
//------------------------------------------------------------------
RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, Address addr, Address peerAddress)
+ int localId, Address addr, Address peerAddress, bool doRegistration)
:PortBase(actor, parent, name, localId, 0, addr, peerAddress)
{
- DebuggingService::getInstance().addPortInstance(*this);
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
};
RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, int idx, Address addr, Address peerAddress)
+ int localId, int idx, Address addr, Address peerAddress, bool doRegistration)
: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
{
- DebuggingService::getInstance().addPortInstance(*this);
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
};
void RTSystemServicesProtocolPort::receive(Message* msg) {
@@ -65,7 +69,7 @@ void RTSystemServicesProtocolPort::receive(Message* msg) {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
}
- getActor().receiveEvent(*this, msg->getEvtId(), msg->getData());
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
}
};
@@ -89,14 +93,19 @@ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::
{
char numstr[10]; // enough to hold all numbers up to 32-bits
- m_ports.reserve(m_replication);
+ //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);
- m_ports.push_back(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));
+ 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));
+// }
};
@@ -104,7 +113,7 @@ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::
void RTSystemServicesProtocolPortRepl::dummy() {
for (int i = 0; i < m_replication; ++i) {
- m_ports.at(i).dummy();
+ m_ports[i].dummy();
}
};
@@ -113,17 +122,21 @@ void RTSystemServicesProtocolPortRepl::dummy() {
//------------------------------------------------------------------
RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
- std::string name, int localId, Address addr, Address peerAddress)
+ std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)
: PortBase(actor, parent, name, localId, 0, addr, peerAddress)
{
- DebuggingService::getInstance().addPortInstance(*this);
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
}
RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
std::string name, int localId, int idx, Address addr,
- Address peerAddress)
+ Address peerAddress, bool doRegistration)
: PortBase(actor, parent, name, localId, idx, addr, peerAddress)
{
- DebuggingService::getInstance().addPortInstance(*this);
+ if (doRegistration) {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
}
void RTSystemServicesProtocolConjPort::receive(Message* msg) {
@@ -134,7 +147,7 @@ void RTSystemServicesProtocolConjPort::receive(Message* msg) {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
}
- getActor().receiveEvent(*this, msg->getEvtId(), msg->getData());
+ getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
}
}
@@ -169,14 +182,11 @@ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, s
m_ports()
{
char numstr[10]; // enough to hold all numbers up to 32-bits
-
- m_ports.reserve(m_replication);
+ 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);
- m_ports.push_back(RTSystemServicesProtocolConjPort(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));
+ //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]);
}
};
@@ -185,19 +195,19 @@ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, s
void RTSystemServicesProtocolConjPortRepl::executeInitialTransition() {
for (int i = 0; i < m_replication; ++i) {
- m_ports.at(i).executeInitialTransition();
+ m_ports[i].executeInitialTransition();
}
}
void RTSystemServicesProtocolConjPortRepl::startDebugging() {
for (int i = 0; i < m_replication; ++i) {
- m_ports.at(i).startDebugging();
+ m_ports[i].startDebugging();
}
}
void RTSystemServicesProtocolConjPortRepl::stopDebugging() {
for (int i = 0; i < m_replication; ++i) {
- m_ports.at(i).stopDebugging();
+ m_ports[i].stopDebugging();
}
}
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 ef1bf8d60..f8852c5ca 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
@@ -13,6 +13,7 @@
#include "common/messaging/Address.h"
#include <vector>
#include <string>
+#include <memory>
namespace etRuntime {
@@ -72,10 +73,10 @@ public:
class RTSystemServicesProtocolPort : public PortBase , public IRTSystemServicesProtocolPort {
public:
RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
- int localId, Address addr, Address peerAddress);
+ 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);
+ int localId, int idx, Address addr, Address peerAddress, bool doRegistration = true);
virtual void receive(Message* m);
// sent messages
@@ -88,7 +89,7 @@ public:
class RTSystemServicesProtocolPortRepl: public IRTSystemServicesProtocolPort {
private:
int m_replication;
- std::vector<RTSystemServicesProtocolPort> m_ports;
+ RTSystemServicesProtocolPort* m_ports;
public:
//TODO: data type of addr and peerAddress?
@@ -96,7 +97,7 @@ public:
const std::vector<Address>& addr, const std::vector<Address> peerAddress);
int getReplication() const { return m_replication; } ;
- RTSystemServicesProtocolPort& get(int i) { return m_ports.at(i); };
+ RTSystemServicesProtocolPort& get(int i) { return m_ports[i]; };
// outgoing messages
void dummy();
};
@@ -108,10 +109,10 @@ public:
class RTSystemServicesProtocolConjPort : public PortBase, public IRTSystemServicesProtocolConjPort{
public:
RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
- std::string name, int localId, Address addr, Address peerAddress);
+ 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);
+ Address peerAddress, bool doRegistration = true);
virtual void receive(Message* m);
void executeInitialTransition();
@@ -125,7 +126,7 @@ public:
class RTSystemServicesProtocolConjPortRepl : public IRTSystemServicesProtocolConjPort{
private:
int m_replication;
- std::vector<RTSystemServicesProtocolConjPort> m_ports;
+ RTSystemServicesProtocolConjPort* m_ports; //dynamic array used instead of vector to avoid copy construction
public:
//TODO: data type of addr and peerAddress
@@ -133,7 +134,7 @@ public:
const std::vector<Address>& addr, const std::vector<Address>& peerAddress);
int getReplication() const { return m_replication; } ;
- RTSystemServicesProtocolConjPort& get(int i) { return m_ports.at(i); };
+ RTSystemServicesProtocolConjPort& get(int i) { return m_ports[i]; };
void executeInitialTransition();
void startDebugging();
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
index b3805dc3d..1a7879f3a 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
@@ -28,8 +28,8 @@ ActorClassBase::~ActorClassBase() {
m_RTSystemPort = 0;
}
-bool ActorClassBase::handleSystemEvent(const InterfaceItemBase& ifitem, int evt, void* generic_data) {
- if (ifitem.getLocalId() != 0) {
+bool ActorClassBase::handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
+ if ((ifitem != 0) && (ifitem->getLocalId() != 0)) {
return false;
}
@@ -41,6 +41,8 @@ bool ActorClassBase::handleSystemEvent(const InterfaceItemBase& ifitem, int evt,
break;
case RTSystemServicesProtocol::IN_stopDebugging:
break;
+ default:
+ return false;
}
return true;
}
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
index 2a7de727a..85cc8f136 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
@@ -61,7 +61,7 @@ protected:
int m_state;
RTSystemServicesProtocolPort* m_RTSystemPort;
- virtual bool handleSystemEvent(const InterfaceItemBase& ifitem, int evt, void* generic_data);
+ virtual bool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
private:
std::string m_className;
Address m_ownAddr;
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 52ebb937a..c6966c38b 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
@@ -18,7 +18,7 @@ public:
IEventReceiver();
virtual ~IEventReceiver();
- virtual void receiveEvent(const InterfaceItemBase& ifitem, int evt, void* data) = 0;
+ virtual void receiveEvent(InterfaceItemBase* ifitem, int evt, void* data) = 0;
};
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
index 90b642585..f3e91ad77 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
@@ -7,6 +7,7 @@
#include "SubSystemRunnerBase.h"
#include "SubSystemClassBase.h"
+#include "common/platform/etTimer.h"
namespace etRuntime {
@@ -28,7 +29,12 @@ void SubSystemRunnerBase::waitMultiThreaded() {
}
void SubSystemRunnerBase::waitAndPollSingleThreaded(SubSystemClassBase& mainComponent) {
- mainComponent.runOnce();
+ for (int i=0; i< 100; ++i) {
+ if (etTimer_executeNeeded()) {
+ mainComponent.runOnce();
+ }
+ Sleep(100);
+ }
std::string token = "";
std::cout << "type 'quit' to exit" << std::endl;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h
index 0d212c593..4f2c25bb9 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/platform/etTimer.h
@@ -20,6 +20,9 @@ typedef struct etTargetTime {
unsigned long sec;
} etTargetTime_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
void etTimer_init(void);
uint32 getNSecFromTarget(void);
@@ -37,4 +40,7 @@ uint32 getTimeBaseUS(void);
uint32 getTimeBaseMS(void);
+#ifdef __cplusplus
+}
+#endif
#endif /* __ETTIMER_H__ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etTimer.c b/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etTimer.c
deleted file mode 100644
index 39989b4c9..000000000
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etTimer.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "common/platform/etTimer.h"
-
-#include <sys/time.h>
-
-#include "config/etRuntimeConfig.h"
-
-void etTimer_init(void){
-}
-
-uint64 getTargetTimeUs(void){
- struct timeval currentTime;
- gettimeofday(&currentTime, NULL);
-
- return currentTime.tv_sec * 1000000L + currentTime.tv_usec;
-}
-
-etBool etTimer_executeNeeded(void){
-
- static uint64 lastTime = 0L;
-
- uint64 currentTime = getTargetTimeUs();
-
- uint64 timestep = 1000000L/FREQUENCY;
-
- if (currentTime >= lastTime + timestep) {
- lastTime = currentTime;
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-void getTimeFromTarget(etTargetTime_t *t){
- struct timeval currentTime;
- gettimeofday(&currentTime, NULL);
- t->sec = currentTime.tv_sec;
- t->nSec = currentTime.tv_usec*1000;
-}

Back to the top