summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-10-17 02:51:21 (EDT)
committerPeter Karlitschek2012-12-05 04:10:49 (EST)
commit01772687c54228db7fa1cbd631dd85539a9761a2 (patch)
treef8cf87c8d67ed2fe2d4b44816ecd0a05763b9d8d
parent16ca683812a81ae5772801085cd6fedd02a2e14c (diff)
downloadorg.eclipse.etrice-01772687c54228db7fa1cbd631dd85539a9761a2.zip
org.eclipse.etrice-01772687c54228db7fa1cbd631dd85539a9761a2.tar.gz
org.eclipse.etrice-01772687c54228db7fa1cbd631dd85539a9761a2.tar.bz2
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend15
-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.cpp10
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h7
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp13
-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.cpp8
9 files changed, 52 insertions, 14 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
index c16c79b..6dcfcc4 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.xtend
@@ -236,11 +236,11 @@ class SubSystemClassGen {
// addresses for the subsystem system port
//----------------------------------------------------------------------------------------------
- std::vector<Address> ownAddresses;
+ std::vector<Address> ownAddresses(«comp.allContainedInstances.size»);
«FOR ai : comp.allContainedInstances»
ownAddresses[«comp.allContainedInstances.indexOf(ai)»] = addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)»;
«ENDFOR»
- std::vector<Address> peerAddresses;
+ std::vector<Address> peerAddresses(«comp.allContainedInstances.size»);
«FOR ai : comp.allContainedInstances»
peerAddresses[«comp.allContainedInstances.indexOf(ai)»] = addr_item_«ai.path.getPathName()»;
«ENDFOR»
@@ -260,20 +260,22 @@ class SubSystemClassGen {
def generateOwnInterfaceItemAddresses(ActorInstance ai) '''
std::vector<std::vector<Address> > «ai.name»_ownInterfaceItemAddresses;
- std::vector<Address> «ai.name»_actorInstanceAddresses;
+ std::vector<Address> «ai.name»_actorInstanceAddresses(1);
«ai.name»_actorInstanceAddresses[0] = addr_item_«ai.path.getPathName()»;
«ai.name»_ownInterfaceItemAddresses.push_back(«ai.name»_actorInstanceAddresses);
«FOR pi : ai.orderedIfItemInstances»
- std::vector<Address> «ai.name»_«pi.name»Addresses;
«IF pi.replicated»
«IF pi.peers.empty»
+ std::vector<Address> «ai.name»_«pi.name»Addresses;
«ELSE»
+ std::vector<Address> «ai.name»_«pi.name»Addresses(«pi.peers.size»);
«FOR peer : pi.peers»
«ai.name»_«pi.name»Addresses[«pi.peers.indexOf(peer)»] = addr_item_«pi.path.getPathName()»_«pi.peers.indexOf(peer)»;
«ENDFOR»
«ENDIF»
«ELSE»
+ std::vector<Address> «ai.name»_«pi.name»Addresses(1);
«ai.name»_«pi.name»Addresses[0] = addr_item_«pi.path.getPathName()»;
«ENDIF»
«ai.name»_ownInterfaceItemAddresses.push_back(«ai.name»_«pi.name»Addresses);
@@ -284,16 +286,17 @@ class SubSystemClassGen {
def generatePeerInterfaceItemAddresses(ActorInstance ai, SubSystemInstance comp) '''
std::vector<std::vector<Address> > «ai.name»_peerInterfaceItemAddresses;
- std::vector<Address> «ai.name»_systemPortAddresses;
+ std::vector<Address> «ai.name»_systemPortAddresses(1);
«ai.name»_systemPortAddresses[0] = addr_item_SystemPort_«comp.allContainedInstances.indexOf(ai)»;
«ai.name»_peerInterfaceItemAddresses.push_back(«ai.name»_systemPortAddresses);
«FOR pi : ai.orderedIfItemInstances »
«IF pi.replicated && pi.peers.isEmpty»
«ELSE»
- std::vector<Address> «ai.name»_«pi.name»PeerAddresses;
«IF pi.peers.empty»
+ std::vector<Address> «ai.name»_«pi.name»PeerAddresses;
«ELSE»
+ std::vector<Address> «ai.name»_«pi.name»PeerAddresses(«pi.peers.size»);
«FOR pp : pi.peers»
«IF pp.replicated»
«ai.name»_«pi.name»PeerAddresses[«pi.peers.indexOf(pp)»] = addr_item_«pp.path.getPathName()»_«pp.peers.indexOf(pi)»;
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 551256c..e1835e3 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
@@ -53,7 +53,7 @@ void DebuggingService::addActorState(const ActorClassBase& actor,
}
void DebuggingService::addPortInstance(PortBase& port) {
- portInstances.at(port.getAddress()) = &port;
+ portInstances[port.getAddress()] = &port;
}
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 df978c0..dc64afa 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
@@ -22,9 +22,13 @@ Address::Address(const Address & right) :
m_objectID(right.m_objectID) {
};
-Address & Address::operator = (Address s) {
- std::swap(s, *this);
- return *this;
+Address & Address::operator = (const Address& right) {
+ if (this != &right) {
+ m_nodeID = right.m_nodeID;
+ m_threadID = right.m_threadID;
+ m_objectID = right.m_objectID;
+ }
+ return *this;
}
bool Address::operator< (const Address& right) const {
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 1556a31..857f7da 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
@@ -14,9 +14,9 @@ namespace etRuntime {
class Address {
public:
- Address(int nodeID, int threadID, int objectID);
+ explicit Address(int nodeID=0, int threadID=0, int objectID=0);
Address(const Address & right);
- Address & operator = (Address s);
+ Address & operator = (const Address& right);
bool operator< (const Address& right) const;
~Address();
@@ -25,7 +25,7 @@ public:
Address createInc(int i);
bool isValid() const {
- return (m_nodeID != 0) && (m_threadID != 0) && (m_objectID != 0);
+ return (m_nodeID != 0) || (m_threadID != 0) || (m_objectID != 0);
};
int m_nodeID;
@@ -33,7 +33,6 @@ public:
int m_objectID;
private:
- Address();
};
} /* namespace etRuntime */
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 a777a08..cbba84a 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
@@ -41,6 +41,12 @@ void MessageService::run() {
}
}
+void MessageService::runOnce() {
+ while (m_messageQueue.isNotEmpty()){
+ pollOneMessage();
+ }
+}
+
//TODO: synchronized
void MessageService::receive(Message* msg) {
if (msg != 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 01eec6a..0f239d3 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
@@ -25,6 +25,8 @@ public:
Address getAddress() const { return m_address; } ;
void run();
+ //TODO: for single threaded configuration only
+ void runOnce();
//TODO: synchronized
void terminate();
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 e022f61..3a47e7d 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
@@ -104,4 +104,17 @@ void MessageServiceController::terminate() {
}
}
+void MessageServiceController::runOnce() {
+ if (!m_running) {
+ return;
+ }
+ m_running = false;
+
+ // terminate all message services
+ for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
+ it != m_messageServiceList.end(); ++it) {
+ (*it)->runOnce();
+ }
+}
+
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
index 87c46e8..57fd7cb 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
@@ -33,6 +33,9 @@ public:
void start();
void stop();
+ //TODO: this is only for single threaded configurations
+ void runOnce();
+
/**
* waitTerminate waits blocking for all MessageServices to terminate
* ! not threadsafe !
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 6ea54ed..24fd082 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
@@ -94,6 +94,10 @@ RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::
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));
+ }
+
};
// outgoing messages
@@ -171,6 +175,10 @@ RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, s
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));
+ }
+
};
// sent messages