mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-03 15:38:11 +02:00
fix in gui that wont wait for disabled ports
This commit is contained in:
@@ -1126,10 +1126,17 @@ int DetectorImpl::acquire() {
|
||||
|
||||
// start receiver
|
||||
if (receiver) {
|
||||
Parallel(&Module::startReceiver, {});
|
||||
}
|
||||
|
||||
startProcessingThread(receiver);
|
||||
// to catch dummy zmq packets for disabled ports,
|
||||
// start processing thread before startReceiver
|
||||
if (dataReady != nullptr)
|
||||
startRxZmqProcessingThread();
|
||||
|
||||
Parallel(&Module::startReceiver, {});
|
||||
|
||||
if (dataReady == nullptr)
|
||||
startRxProgressThread();
|
||||
}
|
||||
|
||||
// start and read all
|
||||
try {
|
||||
@@ -1314,53 +1321,46 @@ void DetectorImpl::printProgress(double progress) {
|
||||
std::cout << '\r' << std::flush;
|
||||
}
|
||||
|
||||
void DetectorImpl::startProcessingThread(bool receiver) {
|
||||
void DetectorImpl::startRxZmqProcessingThread() {
|
||||
dataProcessingThread =
|
||||
std::thread(&DetectorImpl::processData, this, receiver);
|
||||
std::thread(&DetectorImpl::readFrameFromReceiver, this);
|
||||
}
|
||||
|
||||
void DetectorImpl::processData(bool receiver) {
|
||||
if (receiver) {
|
||||
if (dataReady != nullptr) {
|
||||
readFrameFromReceiver();
|
||||
}
|
||||
// only update progress
|
||||
else {
|
||||
LOG(logINFO) << "Type 'q' and hit enter to stop acquisition";
|
||||
double progress = 0;
|
||||
printProgress(progress);
|
||||
void DetectorImpl::startRxProgressThread() {
|
||||
dataProcessingThread = std::thread(&DetectorImpl::printRxProgress, this);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
// to exit acquire by typing q
|
||||
if (kbhit() != 0) {
|
||||
if (fgetc(stdin) == 'q') {
|
||||
LOG(logINFO)
|
||||
<< "Caught the command to stop acquisition";
|
||||
stopDetector({});
|
||||
}
|
||||
}
|
||||
// get and print progress
|
||||
double temp =
|
||||
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||
.squash();
|
||||
if (temp != progress) {
|
||||
printProgress(progress);
|
||||
progress = temp;
|
||||
}
|
||||
void DetectorImpl::printRxProgress() {
|
||||
LOG(logINFO) << "Type 'q' and hit enter to stop acquisition";
|
||||
double progress = 0;
|
||||
printProgress(progress);
|
||||
|
||||
// exiting loop
|
||||
if (getJoinThreadFlag()) {
|
||||
// print progress one final time before exiting
|
||||
progress =
|
||||
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||
.squash();
|
||||
printProgress(progress);
|
||||
break;
|
||||
}
|
||||
// otherwise error when connecting to the receiver too fast
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
while (true) {
|
||||
// to exit acquire by typing q
|
||||
if (kbhit() != 0) {
|
||||
if (fgetc(stdin) == 'q') {
|
||||
LOG(logINFO) << "Caught the command to stop acquisition";
|
||||
stopDetector({});
|
||||
}
|
||||
}
|
||||
// get and print progress
|
||||
double temp =
|
||||
(double)Parallel(&Module::getReceiverProgress, {0}).squash();
|
||||
if (temp != progress) {
|
||||
printProgress(progress);
|
||||
progress = temp;
|
||||
}
|
||||
|
||||
// exiting loop
|
||||
if (getJoinThreadFlag()) {
|
||||
// print progress one final time before exiting
|
||||
progress =
|
||||
(double)Parallel(&Module::getReceiverProgress, {0}).squash();
|
||||
printProgress(progress);
|
||||
break;
|
||||
}
|
||||
// otherwise error when connecting to the receiver too fast
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,10 +278,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
void stopDetector(Positions pos);
|
||||
|
||||
/**
|
||||
* Combines data from all readouts and gives it to the gui
|
||||
* or just gives progress of acquisition by polling receivers
|
||||
* gives progress of acquisition by polling receivers
|
||||
*/
|
||||
void processData(bool receiver);
|
||||
void printRxProgress();
|
||||
|
||||
/**
|
||||
* Convert raw file
|
||||
@@ -450,7 +449,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
|
||||
void printProgress(double progress);
|
||||
|
||||
void startProcessingThread(bool receiver);
|
||||
void startRxZmqProcessingThread();
|
||||
void startRxProgressThread();
|
||||
|
||||
/**
|
||||
* Check if processing thread is ready to join main thread
|
||||
|
||||
Reference in New Issue
Block a user