mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 15:50:03 +02:00
ctb: validate asampes and dsamples > 0 for romode; client: exception caught in acquire to stop receiver and clear busy flag
This commit is contained in:
parent
5cf1502287
commit
504fc2d095
Binary file not shown.
@ -1743,6 +1743,22 @@ int start_acquisition(int file_des) {
|
|||||||
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
|
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||||
|
int mode = getReadoutMode();
|
||||||
|
int asamples = getNumAnalogSamples();
|
||||||
|
int dsamples = getNumDigitalSamples();
|
||||||
|
if ((mode == ANALOG_AND_DIGITAL || mode == ANALOG_ONLY) && (asamples <= 0)) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", asamples);
|
||||||
|
FILE_LOG(logERROR,(mess));
|
||||||
|
}
|
||||||
|
else if ((mode == ANALOG_AND_DIGITAL || mode == DIGITAL_ONLY) && (dsamples <= 0)) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not start acquisition. Invalid number of digital samples: %d.\n", dsamples);
|
||||||
|
FILE_LOG(logERROR,(mess));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
// check for hardware mac and hardware ip
|
// check for hardware mac and hardware ip
|
||||||
if (udpDetails.srcmac != getDetectorMAC()) {
|
if (udpDetails.srcmac != getDetectorMAC()) {
|
||||||
@ -1861,6 +1877,22 @@ int start_and_read_all(int file_des) {
|
|||||||
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
|
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||||
|
int mode = getReadoutMode();
|
||||||
|
int asamples = getNumAnalogSamples();
|
||||||
|
int dsamples = getNumDigitalSamples();
|
||||||
|
if ((mode == ANALOG_AND_DIGITAL || mode == ANALOG_ONLY) && (asamples <= 0)) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not start acquisition. Invalid number of analog samples: %d.\n", asamples);
|
||||||
|
FILE_LOG(logERROR,(mess));
|
||||||
|
}
|
||||||
|
else if ((mode == ANALOG_AND_DIGITAL || mode == DIGITAL_ONLY) && (dsamples <= 0)) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not start acquisition. Invalid number of digital samples: %d.\n", dsamples);
|
||||||
|
FILE_LOG(logERROR,(mess));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
// check for hardware mac and hardware ip
|
// check for hardware mac and hardware ip
|
||||||
if (udpDetails.srcmac != getDetectorMAC()) {
|
if (udpDetails.srcmac != getDetectorMAC()) {
|
||||||
|
@ -1008,82 +1008,90 @@ int multiSlsDetector::acquire() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec begin, end;
|
try {
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
struct timespec begin, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
|
||||||
// in the real time acquisition loop, processing thread will wait for a post
|
// in the real time acquisition loop, processing thread will wait for a post
|
||||||
// each time
|
// each time
|
||||||
sem_init(&sem_newRTAcquisition, 1, 0);
|
sem_init(&sem_newRTAcquisition, 1, 0);
|
||||||
// in the real time acquistion loop, main thread will wait for processing
|
// in the real time acquistion loop, main thread will wait for processing
|
||||||
// thread to be done each time (which in turn waits for receiver/ext
|
// thread to be done each time (which in turn waits for receiver/ext
|
||||||
// process)
|
// process)
|
||||||
sem_init(&sem_endRTAcquisition, 1, 0);
|
sem_init(&sem_endRTAcquisition, 1, 0);
|
||||||
|
|
||||||
bool receiver = Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false);
|
bool receiver = Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false);
|
||||||
progressIndex = 0;
|
progressIndex = 0;
|
||||||
setJoinThreadFlag(false);
|
setJoinThreadFlag(false);
|
||||||
|
|
||||||
// verify receiver is idle
|
// verify receiver is idle
|
||||||
if (receiver) {
|
if (receiver) {
|
||||||
if (Parallel(&slsDetector::getReceiverStatus, {}).squash(ERROR) != IDLE) {
|
if (Parallel(&slsDetector::getReceiverStatus, {}).squash(ERROR) != IDLE) {
|
||||||
|
Parallel(&slsDetector::stopReceiver, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTotalProgress();
|
||||||
|
|
||||||
|
startProcessingThread();
|
||||||
|
|
||||||
|
// start receiver
|
||||||
|
if (receiver) {
|
||||||
|
Parallel(&slsDetector::startReceiver, {});
|
||||||
|
// let processing thread listen to these packets
|
||||||
|
sem_post(&sem_newRTAcquisition);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start and read all
|
||||||
|
try {
|
||||||
|
if (multi_shm()->multiDetectorType == EIGER) {
|
||||||
|
Parallel(&slsDetector::prepareAcquisition, {});
|
||||||
|
}
|
||||||
|
Parallel(&slsDetector::startAndReadAll, {});
|
||||||
|
} catch (...) {
|
||||||
Parallel(&slsDetector::stopReceiver, {});
|
Parallel(&slsDetector::stopReceiver, {});
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
setTotalProgress();
|
|
||||||
|
|
||||||
startProcessingThread();
|
// stop receiver
|
||||||
|
if (receiver) {
|
||||||
|
Parallel(&slsDetector::stopReceiver, {});
|
||||||
|
if (dataReady != nullptr) {
|
||||||
|
sem_wait(&sem_endRTAcquisition); // waits for receiver's
|
||||||
|
}
|
||||||
|
// external process to be
|
||||||
|
// done sending data to gui
|
||||||
|
|
||||||
// start receiver
|
Parallel(&slsDetector::incrementFileIndex, {});
|
||||||
if (receiver) {
|
}
|
||||||
Parallel(&slsDetector::startReceiver, {});
|
|
||||||
// let processing thread listen to these packets
|
// waiting for the data processing thread to finish!
|
||||||
|
setJoinThreadFlag(true);
|
||||||
sem_post(&sem_newRTAcquisition);
|
sem_post(&sem_newRTAcquisition);
|
||||||
}
|
dataProcessingThread.join();
|
||||||
|
|
||||||
// start and read all
|
if (acquisition_finished != nullptr) {
|
||||||
if (multi_shm()->multiDetectorType == EIGER) {
|
// same status for all, else error
|
||||||
Parallel(&slsDetector::prepareAcquisition, {});
|
int status = static_cast<int>(ERROR);
|
||||||
}
|
auto t = Parallel(&slsDetector::getRunStatus, {});
|
||||||
Parallel(&slsDetector::startAndReadAll, {});
|
if (t.equal())
|
||||||
|
status = t.front();
|
||||||
// stop receiver
|
acquisition_finished(getCurrentProgress(), status,
|
||||||
if (receiver) {
|
acqFinished_p);
|
||||||
Parallel(&slsDetector::stopReceiver, {});
|
|
||||||
if (dataReady != nullptr) {
|
|
||||||
sem_wait(&sem_endRTAcquisition); // waits for receiver's
|
|
||||||
}
|
}
|
||||||
// external process to be
|
|
||||||
// done sending data to gui
|
|
||||||
|
|
||||||
Parallel(&slsDetector::incrementFileIndex, {});
|
sem_destroy(&sem_newRTAcquisition);
|
||||||
|
sem_destroy(&sem_endRTAcquisition);
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
FILE_LOG(logDEBUG1) << "Elapsed time for acquisition:"
|
||||||
|
<< ((end.tv_sec - begin.tv_sec) +
|
||||||
|
(end.tv_nsec - begin.tv_nsec) / 1000000000.0)
|
||||||
|
<< " seconds";
|
||||||
|
} catch (...) {
|
||||||
|
setAcquiringFlag(false);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// waiting for the data processing thread to finish!
|
|
||||||
setJoinThreadFlag(true);
|
|
||||||
sem_post(&sem_newRTAcquisition);
|
|
||||||
dataProcessingThread.join();
|
|
||||||
|
|
||||||
if (acquisition_finished != nullptr) {
|
|
||||||
// same status for all, else error
|
|
||||||
int status = static_cast<int>(ERROR);
|
|
||||||
auto t = Parallel(&slsDetector::getRunStatus, {});
|
|
||||||
if (t.equal())
|
|
||||||
status = t.front();
|
|
||||||
acquisition_finished(getCurrentProgress(), status,
|
|
||||||
acqFinished_p);
|
|
||||||
}
|
|
||||||
|
|
||||||
sem_destroy(&sem_newRTAcquisition);
|
|
||||||
sem_destroy(&sem_endRTAcquisition);
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
FILE_LOG(logDEBUG1) << "Elapsed time for acquisition:"
|
|
||||||
<< ((end.tv_sec - begin.tv_sec) +
|
|
||||||
(end.tv_nsec - begin.tv_nsec) / 1000000000.0)
|
|
||||||
<< " seconds";
|
|
||||||
|
|
||||||
setAcquiringFlag(false);
|
setAcquiringFlag(false);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,4 +9,4 @@
|
|||||||
#define APIGOTTHARD 0x191127
|
#define APIGOTTHARD 0x191127
|
||||||
#define APIJUNGFRAU 0x191127
|
#define APIJUNGFRAU 0x191127
|
||||||
#define APIEIGER 0x191129
|
#define APIEIGER 0x191129
|
||||||
#define APICTB 0x191209
|
#define APICTB 0x191210
|
||||||
|
Loading…
x
Reference in New Issue
Block a user