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