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

fix: bidirectional network and readable device consumers

parent 4df7f61a
No related branches found
No related tags found
No related merge requests found
...@@ -102,7 +102,7 @@ namespace ChimeraTK { ...@@ -102,7 +102,7 @@ namespace ChimeraTK {
template<typename UserType> template<typename UserType>
void FeedingFanOut<UserType>::addSlave( void FeedingFanOut<UserType>::addSlave(
boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> slave, VariableNetworkNode&) { boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> slave, VariableNetworkNode& node) {
// check if array shape is compatible, unless the receiver is a trigger // check if array shape is compatible, unless the receiver is a trigger
// node, so no data is expected // node, so no data is expected
if(slave->getNumberOfSamples() != 0 && if(slave->getNumberOfSamples() != 0 &&
...@@ -120,12 +120,13 @@ namespace ChimeraTK { ...@@ -120,12 +120,13 @@ namespace ChimeraTK {
// handle return channels // handle return channels
if(_withReturn) { if(_withReturn) {
if(slave->isReadable()) { if(node.getDirection().withReturn) {
if(_hasReturnSlave) { if(_hasReturnSlave) {
throw ChimeraTK::logic_error("FeedingFanOut: Cannot add multiple slaves with return channel!"); throw ChimeraTK::logic_error("FeedingFanOut: Cannot add multiple slaves with return channel!");
} }
// Assert the assumption about the return channel made in the constructor // These assumptions should be guaranteed by the connection making code which created the PV
assert(slave->isReadable());
assert(slave->getAccessModeFlags().has(AccessMode::wait_for_new_data)); assert(slave->getAccessModeFlags().has(AccessMode::wait_for_new_data));
_hasReturnSlave = true; _hasReturnSlave = true;
...@@ -176,7 +177,7 @@ namespace ChimeraTK { ...@@ -176,7 +177,7 @@ namespace ChimeraTK {
// distribute return-channel update to the other slaves // distribute return-channel update to the other slaves
for(auto& slave : FanOut<UserType>::slaves) { // send out copies to slaves for(auto& slave : FanOut<UserType>::slaves) { // send out copies to slaves
if(slave == _returnSlave) continue; if(slave == _returnSlave) continue;
if(slave->getNumberOfSamples() != 0) { // do not send copy if no data is expected (e.g. trigger) if(slave->getNumberOfSamples() != 0) { // do not send copy if no data is expected (e.g. trigger)
slave->accessChannel(0) = ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0]; slave->accessChannel(0) = ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0];
} }
slave->writeDestructively(_returnSlave->getVersionNumber()); slave->writeDestructively(_returnSlave->getVersionNumber());
......
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