Skip to content
Snippets Groups Projects
Commit 0fec4417 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

When optimising the connections (i.e. merging networks), the trigger receivers...

When optimising the connections (i.e. merging networks), the trigger receivers for triggered networks are now removed from the trigger network. This was previously leading to crashes.
parent 970e3ffa
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,12 @@ namespace ChimeraTK {
/** Add a trigger receiver node */
void addNodeToTrigger(VariableNetworkNode& nodeToTrigger);
/** Remove a node from the network */
void removeNode(const VariableNetworkNode &a);
/** Remove a trigger receiver node from the network */
void removeNodeToTrigger(const VariableNetworkNode &nodeToNoLongerTrigger);
/** Check if the network already has a feeding node connected to it. */
bool hasFeedingNode() const;
......
......@@ -410,6 +410,12 @@ void Application::optimiseConnections() {
it2->addNode(consumer);
}
// if trigger present, remove corresponding trigger receiver node from the trigger network
for(auto &itTrig : networkList) {
if(itTrig.getFeedingNode() != feeder1.getExternalTrigger()) continue;
itTrig.removeNodeToTrigger(it1->getFeedingNode());
}
// schedule the outer loop network for deletion and stop processing it
deleteNetworks.push_back(&(*it1));
break;
......
......@@ -71,6 +71,35 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void VariableNetwork::removeNode(const VariableNetworkNode &a) {
auto nNodes = nodeList.size();
nodeList.remove(a);
// check if a node was actually removed, if not, throw exception
if(nodeList.size() == nNodes) {
std::stringstream msg;
msg << "Trying remove a VariableNetworkNode from the VariableNetwork which is not in the network." << std::endl;
msg << "The network you were trying to remove the node from:" << std::endl;
dump("", msg);
msg << "The node you were trying to remove:" << std::endl;
a.dump(msg);
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>(msg.str());
}
}
/*********************************************************************************************************************/
void VariableNetwork::removeNodeToTrigger(const VariableNetworkNode &nodeToNoLongerTrigger) {
for(auto &node : nodeList) {
if(node.getType() != NodeType::TriggerReceiver) continue;
if(node.getNodeToTrigger() == nodeToNoLongerTrigger) {
removeNode(node);
break;
}
}
}
/*********************************************************************************************************************/
void VariableNetwork::dump(const std::string& linePrefix, std::ostream& stream) const {
stream << linePrefix << "VariableNetwork";
stream << " [ptr: " << this << "]";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment