This commit is contained in:
2019-08-09 12:01:01 +02:00
parent 8c40c02fc5
commit a3c5c16417
2 changed files with 12 additions and 23 deletions

View File

@ -107,6 +107,10 @@ template <class T, class Allocator = std::allocator<T>> class Result {
*/ */
T squash() const { return Squash(vec); } T squash() const { return Squash(vec); }
/**
* If all elements are equal it returns the front value
* otherwise throws an exception with custom message provided
*/
T tsquash(const std::string &error_msg) { T tsquash(const std::string &error_msg) {
if (equal()) if (equal())
return vec.front(); return vec.front();

View File

@ -4160,34 +4160,19 @@ void multiSlsDetector::registerDataCallback(
} }
int multiSlsDetector::setTotalProgress() { int multiSlsDetector::setTotalProgress() {
int nf = 1, nc = 1, ns = 1; int nf = Parallel(&slsDetector::setTimer, {}, FRAME_NUMBER, -1).tsquash("Inconsistent number of frames");
int nc = Parallel(&slsDetector::setTimer, {}, CYCLES_NUMBER, -1).tsquash("Inconsistent number of cycles");
Result<int64_t> temp = Parallel(&slsDetector::setTimer, {}, FRAME_NUMBER, -1);
if (!temp.equal()) {
throw RuntimeError("Inconsistent number of frames");
}
nf = temp.squash();
temp = Parallel(&slsDetector::setTimer, {}, CYCLES_NUMBER, -1);
if (!temp.equal()) {
throw RuntimeError("Inconsistent number of cycles");
}
nc = temp.squash();
if (getDetectorTypeAsEnum() == JUNGFRAU) {
temp = Parallel(&slsDetector::setTimer, {}, STORAGE_CELL_NUMBER, -1);
if (!temp.equal()) {
throw RuntimeError("Inconsistent number of additional storage cells");
}
ns = temp.squash() + 1;
}
if (nf == 0 || nc == 0) { if (nf == 0 || nc == 0) {
throw RuntimeError("Number of frames or cycles is 0"); throw RuntimeError("Number of frames or cycles is 0");
} }
totalProgress = nf * nc * ns; int ns = 1;
if (getDetectorTypeAsEnum() == JUNGFRAU) {
ns = Parallel(&slsDetector::setTimer, {}, STORAGE_CELL_NUMBER, -1).tsquash("Inconsistent number of additional storage cells");
++ns;
}
totalProgress = nf * nc * ns;
FILE_LOG(logDEBUG1) << "nf " << nf << " nc " << nc << " ns " << ns; FILE_LOG(logDEBUG1) << "nf " << nf << " nc " << nc << " ns " << ns;
FILE_LOG(logDEBUG1) << "Set total progress " << totalProgress << std::endl; FILE_LOG(logDEBUG1) << "Set total progress " << totalProgress << std::endl;
return totalProgress; return totalProgress;