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

make use of the new blocking read() implementation of the ControlSystemAdapter

parent af15c55a
No related branches found
No related tags found
No related merge requests found
......@@ -32,10 +32,8 @@ namespace ChimeraTK {
void read() {
if(Accessor<UserType>::_mode == UpdateMode::push) {
while(impl->readNonBlocking() == false) { /// @todo TODO proper blocking implementation
boost::this_thread::yield();
boost::this_thread::interruption_point();
}
impl->read();
boost::this_thread::interruption_point();
}
else {
/// @todo TODO empty the queue to always receive the latest value
......
......@@ -110,34 +110,22 @@ namespace ChimeraTK {
void run() {
assert(_direction == VariableDirection::consuming);
while(true) {
boost::this_thread::yield();
boost::this_thread::interruption_point();
if(hasExternalTrigger) {
// wait for external trigger (if present)
/// @todo TODO replace with proper blocking implementation when supported by the CSA
while(externalTrigger->readNonBlocking() == false) {
boost::this_thread::yield();
boost::this_thread::interruption_point();
}
externalTrigger->read();
// receive data
impl->readNonBlocking();
}
else {
// receive data
while(impl->readNonBlocking() == false) {
boost::this_thread::yield();
boost::this_thread::interruption_point();
}
impl->read();
}
boost::this_thread::yield();
boost::this_thread::interruption_point();
for(auto &slave : slaves) { // send out copies to slaves
// do not send copy if no data is expected (e.g. trigger)
if(slave->getNumberOfSamples() != 0) {
slave->accessChannel(0) = impl->accessChannel(0);
}
boost::this_thread::yield();
boost::this_thread::interruption_point();
slave->write();
}
}
......@@ -180,7 +168,15 @@ namespace ChimeraTK {
}
void read() {
throw std::logic_error("Blocking read is not supported by process array.");
impl->read();
mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0].swap(impl->accessChannel(0));
for(auto &slave : slaves) { // send out copies to slaves
// do not send copy if no data is expected (e.g. trigger)
if(slave->getNumberOfSamples() != 0) {
slave->accessChannel(0) = mtca4u::NDRegisterAccessor<UserType>::buffer_2D[0];
}
slave->write();
}
}
bool readNonBlocking() {
......
......@@ -51,10 +51,7 @@ namespace ChimeraTK {
/** Synchronise sender and receiver. This function is executed in the separate thread. */
void run() {
while(true) {
while(!_receiver->readNonBlocking()) {
boost::this_thread::yield();
boost::this_thread::interruption_point();
}
_receiver->read();
_sender->accessChannel(0) = _receiver->accessChannel(0);
_sender->write();
}
......
......@@ -32,10 +32,8 @@ namespace ChimeraTK {
void read() {
if(Accessor<UserType>::_mode == UpdateMode::push) {
while(impl->readNonBlocking() == false) { /// @todo TODO proper blocking implementation
boost::this_thread::yield();
boost::this_thread::interruption_point();
}
impl->read();
boost::this_thread::interruption_point();
}
else {
/// @todo TODO empty the queue to always receive the latest value
......
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