mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
WIP
This commit is contained in:
@ -1109,9 +1109,7 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
case MEASUREMENTS_NUMBER:
|
||||
throw RuntimeError("Cannot set number of frames, cycles,storage cells or "
|
||||
"measurements individually.");
|
||||
throw RuntimeError("Cannot set number of frames, cycles or storage cells individually.");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1129,7 +1127,6 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
case MEASUREMENTS_NUMBER:
|
||||
setTotalProgress();
|
||||
break;
|
||||
default:
|
||||
@ -3969,7 +3966,6 @@ int multiSlsDetector::dumpDetectorSetup(const std::string &fname, int level) {
|
||||
names.emplace_back("period");
|
||||
names.emplace_back("frames");
|
||||
names.emplace_back("cycles");
|
||||
names.emplace_back("measurements");
|
||||
names.emplace_back("timing");
|
||||
|
||||
switch (type) {
|
||||
@ -4075,12 +4071,6 @@ void multiSlsDetector::registerAcquisitionFinishedCallback(void (*func)(double,
|
||||
acqFinished_p = pArg;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerMeasurementFinishedCallback(void (*func)(int, void *),
|
||||
void *pArg) {
|
||||
measurement_finished = func;
|
||||
measFinished_p = pArg;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerProgressCallback(void (*func)(double, void *), void *pArg) {
|
||||
progress_call = func;
|
||||
pProgressCallArg = pArg;
|
||||
@ -4102,7 +4092,7 @@ void multiSlsDetector::registerDataCallback(void (*userCallback)(detectorData *,
|
||||
}
|
||||
|
||||
int multiSlsDetector::setTotalProgress() {
|
||||
int nf = 1, nc = 1, ns = 1, nm = 1;
|
||||
int nf = 1, nc = 1, ns = 1;
|
||||
|
||||
if (multi_shm()->timerValue[FRAME_NUMBER] != 0) {
|
||||
nf = multi_shm()->timerValue[FRAME_NUMBER];
|
||||
@ -4116,13 +4106,9 @@ int multiSlsDetector::setTotalProgress() {
|
||||
ns = multi_shm()->timerValue[STORAGE_CELL_NUMBER] + 1;
|
||||
}
|
||||
|
||||
if (multi_shm()->timerValue[MEASUREMENTS_NUMBER] > 0) {
|
||||
nm = multi_shm()->timerValue[MEASUREMENTS_NUMBER];
|
||||
}
|
||||
totalProgress = nf * nc * ns;
|
||||
|
||||
totalProgress = nm * nf * nc * ns;
|
||||
|
||||
FILE_LOG(logDEBUG1) << "nm " << nm << " nf " << nf << " nc " << nc << " ns " << ns;
|
||||
FILE_LOG(logDEBUG1) << "nf " << nf << " nc " << nc << " ns " << ns;
|
||||
FILE_LOG(logDEBUG1) << "Set total progress " << totalProgress << std::endl;
|
||||
return totalProgress;
|
||||
}
|
||||
@ -4170,11 +4156,6 @@ int multiSlsDetector::acquire() {
|
||||
multi_shm()->stoppedFlag = 0;
|
||||
setJoinThreadFlag(false);
|
||||
|
||||
int nm = multi_shm()->timerValue[MEASUREMENTS_NUMBER];
|
||||
if (nm < 1) {
|
||||
nm = 1;
|
||||
}
|
||||
|
||||
// verify receiver is idle
|
||||
if (receiver) {
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
@ -4188,58 +4169,44 @@ int multiSlsDetector::acquire() {
|
||||
startProcessingThread();
|
||||
|
||||
// resets frames caught in receiver
|
||||
if (receiver) {
|
||||
if (receiver && multi_shm()->stoppedFlag == 0) {
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
if (resetFramesCaught() == FAIL) {
|
||||
multi_shm()->stoppedFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// loop through measurements
|
||||
for (int im = 0; im < nm; ++im) {
|
||||
if (multi_shm()->stoppedFlag != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// start receiver
|
||||
if (receiver) {
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
if (startReceiver() == FAIL) {
|
||||
FILE_LOG(logERROR) << "Start receiver failed ";
|
||||
stopReceiver();
|
||||
multi_shm()->stoppedFlag = 1;
|
||||
break;
|
||||
}
|
||||
// let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
// start receiver
|
||||
if (receiver && multi_shm()->stoppedFlag == 0) {
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
if (startReceiver() == FAIL) {
|
||||
FILE_LOG(logERROR) << "Start receiver failed ";
|
||||
stopReceiver();
|
||||
multi_shm()->stoppedFlag = 1;
|
||||
}
|
||||
// let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
}
|
||||
|
||||
if (multi_shm()->stoppedFlag == 0)
|
||||
startAndReadAll();
|
||||
|
||||
// stop receiver
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
if (receiver) {
|
||||
if (stopReceiver() == FAIL) {
|
||||
multi_shm()->stoppedFlag = 1;
|
||||
} else {
|
||||
if (dataReady != nullptr) {
|
||||
sem_wait(&sem_endRTAcquisition); // waits for receiver's
|
||||
}
|
||||
// external process to be
|
||||
// done sending data to gui
|
||||
// stop receiver
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
if (receiver) {
|
||||
if (stopReceiver() == FAIL) {
|
||||
multi_shm()->stoppedFlag = 1;
|
||||
} else {
|
||||
if (dataReady != nullptr) {
|
||||
sem_wait(&sem_endRTAcquisition); // waits for receiver's
|
||||
}
|
||||
// external process to be
|
||||
// done sending data to gui
|
||||
}
|
||||
int findex = 0;
|
||||
findex = incrementFileIndex();
|
||||
}
|
||||
|
||||
incrementFileIndex();
|
||||
|
||||
if (measurement_finished != nullptr) {
|
||||
measurement_finished(im, measFinished_p);
|
||||
}
|
||||
if (multi_shm()->stoppedFlag != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
} // end measurements loop im
|
||||
|
||||
// waiting for the data processing thread to finish!
|
||||
setJoinThreadFlag(true);
|
||||
|
@ -312,7 +312,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->timerValue[ACTUAL_TIME] = 0;
|
||||
shm()->timerValue[MEASUREMENT_TIME] = 0;
|
||||
shm()->timerValue[PROGRESS] = 0;
|
||||
shm()->timerValue[MEASUREMENTS_NUMBER] = 1;
|
||||
shm()->timerValue[FRAMES_FROM_START] = 0;
|
||||
shm()->timerValue[FRAMES_FROM_START_PG] = 0;
|
||||
shm()->timerValue[ANALOG_SAMPLES] = 1;
|
||||
@ -1522,15 +1521,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
FILE_LOG(logDEBUG1) << "Setting " << getTimerType(index) << " to " << t
|
||||
<< " ns/value";
|
||||
|
||||
// meausurement is only shm level
|
||||
if (index == MEASUREMENTS_NUMBER) {
|
||||
if (t >= 0) {
|
||||
shm()->timerValue[index] = t;
|
||||
FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << t;
|
||||
}
|
||||
return shm()->timerValue[index];
|
||||
}
|
||||
|
||||
// send to detector
|
||||
int64_t oldtimer = shm()->timerValue[index];
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
|
@ -610,13 +610,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>measurements [i]</b> sets/gets number of measurements. \c Returns \c (long long int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "measurements";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>samples [i]</b> sets/gets number of samples (both analog and digital) expected from the ctb. Used in CHIP TEST BOARD and MOENCH only. \c Returns \c (long long int)
|
||||
*/
|
||||
@ -4484,8 +4477,6 @@ std::string slsDetectorCommand::cmdTimer(int narg, const char * const args[], in
|
||||
index = FRAME_NUMBER;
|
||||
else if (cmd == "cycles")
|
||||
index = CYCLES_NUMBER;
|
||||
else if (cmd == "measurements")
|
||||
index = MEASUREMENTS_NUMBER;
|
||||
// also does digital sample
|
||||
else if (cmd == "samples")
|
||||
index = ANALOG_SAMPLES;
|
||||
|
@ -406,10 +406,6 @@ void slsDetectorUsers::registerAcquisitionFinishedCallback(void( *func)(double,i
|
||||
detector.registerAcquisitionFinishedCallback(func,pArg);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::registerMeasurementFinishedCallback(void( *func)(int,void*), void *pArg) {
|
||||
detector.registerMeasurementFinishedCallback(func,pArg);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::registerProgressCallback(void( *func)(double,void*), void *pArg) {
|
||||
detector.registerProgressCallback(func,pArg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user