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

Fix merging networks if one has no feeder.

For some reason this was disallowed and even tested to throw.
parent 2d5a3c8f
No related branches found
No related tags found
No related merge requests found
......@@ -312,7 +312,7 @@ namespace ChimeraTK {
bool VariableNetwork::merge(VariableNetwork& other) {
// check if merging is possible
if(hasFeedingNode() || !other.hasFeedingNode()) {
if(hasFeedingNode() && other.hasFeedingNode()) {
if((getFeedingNode().getType() == NodeType::ControlSystem &&
other.getFeedingNode().getType() == NodeType::ControlSystem) ||
(getFeedingNode().getType() != NodeType::ControlSystem &&
......
......@@ -363,3 +363,34 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(testPseudoArray, T, test_types) {
app.testModule.consumingPush.read();
BOOST_CHECK(app.testModule.consumingPush == 33);
}
/*********************************************************************************************************************/
/* test case for "merging" two networks */
BOOST_AUTO_TEST_CASE_TEMPLATE(testMergeNetworks, T, test_types) {
ChimeraTK::BackendFactory::getInstance().setDMapFilePath("test.dmap");
TestApplication<T> app;
// This creates a first network
app.testModule.feedingPush >> app.testModule.consumingPush;
// This creates a second network with only consumers
app.testModule.consumingPush2 >> app.testModule.consumingPush3;
// This merges the two networks
app.testModule.consumingPush >> app.testModule.consumingPush2;
// run the app
app.initialise();
app.run();
app.testModule.mainLoopStarted.wait(); // make sure the module's mainLoop() is entered
// test data transfer
app.testModule.feedingPush = 44;
app.testModule.feedingPush.write();
BOOST_CHECK(app.testModule.consumingPush.readLatest() == true);
BOOST_CHECK(app.testModule.consumingPush == 44);
BOOST_CHECK(app.testModule.consumingPush2.readLatest() == true);
BOOST_CHECK(app.testModule.consumingPush2 == 44);
BOOST_CHECK(app.testModule.consumingPush3.readLatest() == true);
BOOST_CHECK(app.testModule.consumingPush3 == 44);
}
......@@ -148,24 +148,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(testDifferentNrElements, T, test_types) {
}
}
/*********************************************************************************************************************/
/* test case for "merging" two networks */
BOOST_AUTO_TEST_CASE_TEMPLATE(testMergeNetworks, T, test_types) {
ChimeraTK::BackendFactory::getInstance().setDMapFilePath("test.dmap");
TestApplication<T> app;
app.testModule.feedingPush >> app.testModule.consumingPush;
app.testModule.consumingPush2 >> app.testModule.consumingPush3;
try {
app.testModule.consumingPush >> app.testModule.consumingPush2;
BOOST_ERROR("Exception expected.");
}
catch(ChimeraTK::logic_error& e) {
BOOST_CHECK_NO_THROW(e.what(););
}
}
/*********************************************************************************************************************/
/* test case for constant as trigger */
......
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