diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 94e537482..f43d5929f 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -72,6 +72,538 @@ bool multiSlsDetector::isMultiSlsDetectorClass() return true; } +std::string multiSlsDetector::concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos) +{ + if (pos >= 0 && pos < detectors.size()) { + return (detectors[pos]->*somefunc)(pos); + } else { + std::string s; + for (int i = 0; i < detectors.size(); ++i) { + s += (detectors[i]->*somefunc)(pos) + "+"; + } + return s; + } +} + +template +T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)()) +{ + //(Erik) to handle enums, probably a bad idea but follow previous code + T defaultValue = static_cast(-1); + std::vector values(detectors.size(), defaultValue); + for (int idet = 0; idet < detectors.size(); ++idet) { + values[idet] = (detectors[idet]->*somefunc)(); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return minusOneIfDifferent(values); +} + +std::string multiSlsDetector::callDetectorMember(string (slsDetector::*somefunc)()) +{ + string concatenatedValue, firstValue; + bool valueNotSame = false; + + for (int idet = 0; idet < detectors.size(); ++idet) { + string thisValue = (detectors[idet]->*somefunc)(); + ; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + + if (firstValue.empty()) { + concatenatedValue = thisValue; + firstValue = thisValue; + } else { + concatenatedValue += "+" + thisValue; + } + if (firstValue != thisValue) + valueNotSame = true; + } + if (valueNotSame) + return concatenatedValue; + else + return firstValue; +} + +template +T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)(V), V value) +{ + //(Erik) to handle enums, probably a bad idea but follow previous code + T defaultValue = static_cast(-1); + std::vector values(detectors.size(), defaultValue); + for (int idet = 0; idet < detectors.size(); ++idet) { + values[idet] = (detectors[idet]->*somefunc)(value); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return minusOneIfDifferent(values); +} + +template +T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2) +{ + //(Erik) to handle enums, probably a bad idea but follow previous code + T defaultValue = static_cast(-1); + std::vector values(detectors.size(), defaultValue); + for (int idet = 0; idet < detectors.size(); ++idet) { + values[idet] = (detectors[idet]->*somefunc)(par1, par2); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return minusOneIfDifferent(values); +} + +template +T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)()) +{ + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } else { + std::vector return_values(detectors.size(), -1); + for (int idet = 0; idet < detectors.size(); ++idet) { + Task* task = new Task(new func0_t(somefunc, + detectors[idet], &return_values[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + return minusOneIfDifferent(return_values); + } +} + +template +T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1), P1 value) +{ + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } else { + std::vector return_values(detectors.size(), -1); + for (int idet = 0; idet < detectors.size(); ++idet) { + Task* task = new Task(new func1_t(somefunc, + detectors[idet], value, &return_values[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + return minusOneIfDifferent(return_values); + } +} + +template +T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2) +{ + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } else { + std::vector return_values(detectors.size(), -1); + for (int idet = 0; idet < detectors.size(); ++idet) { + Task* task = new Task(new func2_t(somefunc, + detectors[idet], par1, par2, &return_values[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + return minusOneIfDifferent(return_values); + } +} + +int multiSlsDetector::parallelCallDetectorMember(int (slsDetector::*somefunc)(int, int, int), int v0, int v1, int v2) +{ + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } else { + std::vector return_values(detectors.size(), -1); + for (int idet = 0; idet < detectors.size(); ++idet) { + Task* task = new Task(new func3_t(somefunc, + detectors[idet], v0, v1, v2, &return_values[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + return minusOneIfDifferent(return_values); + } +} + +template +T multiSlsDetector::minusOneIfDifferent(const std::vector& return_values) +{ + T ret = static_cast(-100); + for (int idet = 0; idet < detectors.size(); ++idet) { + if (ret == static_cast(-100)) + ret = return_values[idet]; + else if (ret != return_values[idet]) + ret = static_cast(-1); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return ret; +} + + +int multiSlsDetector::decodeNMod(int i, int& id, int& im) +{ +#ifdef VERBOSE + cout << " Module " << i << " belongs to detector " << id << endl; + ; + cout << getMaxMods(); +#endif + + if (i < 0 || i >= getMaxMods()) { + id = -1; + im = -1; +#ifdef VERBOSE + cout << " A---------" << id << " position " << im << endl; +#endif + + return -1; + } + int nm; + for (int idet = 0; idet < detectors.size(); ++idet) { + nm = detectors[idet]->getNMods(); + if (nm > i) { + id = idet; + im = i; +#ifdef VERBOSE + cout << " B---------" << id << " position " << im << endl; +#endif + return im; + } else { + i -= nm; + } + } + id = -1; + im = -1; +#ifdef VERBOSE + cout << " C---------" << id << " position " << im << endl; +#endif + return -1; +} + + +int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int& channelX, int& channelY) +{ + channelX = -1; + channelY = -1; + //loop over + for (int i = 0; i < detectors.size(); ++i) { + //check x offset range + if ((offsetX >= thisMultiDetector->offsetX[i]) && + (offsetX < (thisMultiDetector->offsetX[i] + detectors[i]->getMaxNumberOfChannelsInclGapPixels(X)))) { + if (offsetY == -1) { + channelX = offsetX - thisMultiDetector->offsetX[i]; + return i; + } else { + //check y offset range + if ((offsetY >= thisMultiDetector->offsetY[i]) && + (offsetY < (thisMultiDetector->offsetY[i] + detectors[i]->getMaxNumberOfChannelsInclGapPixels(Y)))) { + channelX = offsetX - thisMultiDetector->offsetX[i]; + channelY = offsetY - thisMultiDetector->offsetY[i]; + return i; + } + } + } + } + return -1; +} + + +double* multiSlsDetector::decodeData(int* datain, int& nn, double* fdata) +{ + double* dataout; + + if (fdata) + dataout = fdata; + else { + if (detectors[0]->getDetectorsType() == JUNGFRAUCTB) { + nn = thisMultiDetector->dataBytes / 2; + dataout = new double[nn]; + } else { + nn = thisMultiDetector->numberOfChannels; + dataout = new double[nn]; + } + } + + int n; + double* detp = dataout; + int* datap = datain; + + for (int i = 0; i < detectors.size(); ++i) { + detectors[i]->decodeData(datap, n, detp); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); +#ifdef VERBOSE + cout << "increment pointers " << endl; +#endif + datap += detectors[i]->getDataBytes() / sizeof(int); + detp += n; +#ifdef VERBOSE + cout << "done " << endl; +#endif + } + + return dataout; +} + + + +int multiSlsDetector::writeDataFile(string fname, double* data, double* err, + double* ang, char dataformat, int nch) +{ +#ifdef VERBOSE + cout << "using overloaded multiSlsDetector function to write formatted data file " + << getTotalNumberOfChannels() << endl; +#endif + + ofstream outfile; + int choff = 0, off = 0; //idata, + double *pe = err, *pa = ang; + int nch_left = nch, n; //, nd; + + if (nch_left <= 0) + nch_left = getTotalNumberOfChannels(); + + if (data == NULL) + return FAIL; + + outfile.open(fname.c_str(), ios_base::out); + if (outfile.is_open()) { + + for (int i = 0; i < detectors.size(); ++i) { + n = detectors[i]->getTotalNumberOfChannels(); + if (nch_left < n) + n = nch_left; +#ifdef VERBOSE + cout << " write " << i << " position " << off << " offset " << choff << endl; +#endif + fileIOStatic::writeDataFile(outfile, n, data + off, pe, pa, dataformat, choff); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + + nch_left -= n; + + choff += detectors[i]->getMaxNumberOfChannels(); + + off += n; + + if (pe) + pe = err + off; + + if (pa) + pa = ang + off; + } + outfile.close(); + return OK; + } else { + std::cout << "Could not open file " << fname << "for writing" << std::endl; + return FAIL; + } +} + +int multiSlsDetector::writeDataFile(string fname, int* data) +{ + ofstream outfile; + int choff = 0, off = 0; +#ifdef VERBOSE + cout << "using overloaded multiSlsDetector function to write raw data file " << endl; +#endif + + if (data == NULL) + return FAIL; + + outfile.open(fname.c_str(), ios_base::out); + if (outfile.is_open()) { + for (int i = 0; i < detectors.size(); ++i) { +#ifdef VERBOSE + cout << " write " << i << " position " << off << " offset " << choff << endl; +#endif + detectors[i]->writeDataFile(outfile, detectors[i]->getTotalNumberOfChannels(), data + off, choff); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + choff += detectors[i]->getMaxNumberOfChannels(); + off += detectors[i]->getTotalNumberOfChannels(); + } + outfile.close(); + return OK; + } else { + std::cout << "Could not open file " << fname << "for writing" << std::endl; + return FAIL; + } +} + +int multiSlsDetector::readDataFile(string fname, double* data, double* err, double* ang, char dataformat) +{ +#ifdef VERBOSE + cout << "using overloaded multiSlsDetector function to read formatted data file " << endl; +#endif + + ifstream infile; + int iline = 0; + string str; + int choff = 0, off = 0; + double *pe = err, *pa = ang; + +#ifdef VERBOSE + std::cout << "Opening file " << fname << std::endl; +#endif + infile.open(fname.c_str(), ios_base::in); + if (infile.is_open()) { + + for (int i = 0; i < detectors.size(); ++i) { + iline += detectors[i]->readDataFile(detectors[i]->getTotalNumberOfChannels(), infile, data + off, pe, pa, dataformat, choff); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + choff += detectors[i]->getMaxNumberOfChannels(); + off += detectors[i]->getTotalNumberOfChannels(); + if (pe) + pe = pe + off; + if (pa) + pa = pa + off; + } + + infile.close(); + } else { + std::cout << "Could not read file " << fname << std::endl; + return -1; + } + return iline; +} + +int multiSlsDetector::readDataFile(string fname, int* data) +{ +#ifdef VERBOSE + cout << "using overloaded multiSlsDetector function to read raw data file " << endl; +#endif + ifstream infile; + int iline = 0; + string str; + int choff = 0, off = 0; + +#ifdef VERBOSE + std::cout << "Opening file " << fname << std::endl; +#endif + infile.open(fname.c_str(), ios_base::in); + if (infile.is_open()) { + + for (int i = 0; i < detectors.size(); ++i) { + iline += detectors[i]->readDataFile(infile, data + off, detectors[i]->getTotalNumberOfChannels(), choff); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + choff += detectors[i]->getMaxNumberOfChannels(); + off += detectors[i]->getTotalNumberOfChannels(); + } + infile.close(); + } else { + std::cout << "Could not read file " << fname << std::endl; + return -1; + } + return iline; +} + + +string multiSlsDetector::getErrorMessage(int& critical) +{ + int64_t multiMask, slsMask = 0; + string retval = ""; + char sNumber[100]; + critical = 0; + + multiMask = getErrorMask(); + if (multiMask) { + if (multiMask & MULTI_DETECTORS_NOT_ADDED) { + retval.append("Detectors not added:\n" + string(getNotAddedList()) + string("\n")); + critical = 1; + } + if (multiMask & MULTI_HAVE_DIFFERENT_VALUES) { + retval.append("A previous multi detector command gave different values\n" + "Please check the console\n"); + critical = 0; + } + if (multiMask & MULTI_CONFIG_FILE_ERROR) { + retval.append("Could not load Config File\n"); + critical = 0; + } + + for (int idet = 0; idet < detectors.size(); ++idet) { + //if the detector has error + if (multiMask & (1 << idet)) { + //append detector id + sprintf(sNumber, "%d", idet); + retval.append("Detector " + string(sNumber) + string(":\n")); + //get sls det error mask + slsMask = detectors[idet]->getErrorMask(); +#ifdef VERYVERBOSE + //append sls det error mask + sprintf(sNumber, "0x%lx", slsMask); + retval.append("Error Mask " + string(sNumber) + string("\n")); +#endif + //get the error critical level + if ((slsMask > 0xFFFFFFFF) | critical) + critical = 1; + //append error message + retval.append(errorDefs::getErrorMessage(slsMask)); + } + } + } + return retval; +} + +int64_t multiSlsDetector::clearAllErrorMask() +{ + clearErrorMask(); + clearNotAddedList(); + for (int idet = 0; idet < detectors.size(); ++idet) + detectors[idet]->clearErrorMask(); + + return getErrorMask(); +} + +void multiSlsDetector::setAcquiringFlag(bool b) +{ + thisMultiDetector->acquiringFlag = b; +} + +bool multiSlsDetector::getAcquiringFlag() +{ + return thisMultiDetector->acquiringFlag; +} + +bool multiSlsDetector::isAcquireReady() +{ + if (thisMultiDetector->acquiringFlag) { + std::cout << "Acquire has already started. " + "If previous acquisition terminated unexpectedly, " + "reset busy flag to restart.(sls_detector_put busy 0)" << std::endl; + return FAIL; + } + thisMultiDetector->acquiringFlag = true; + return OK; +} + +int multiSlsDetector::checkVersionCompatibility(portType t) +{ + return parallelCallDetectorMember(&slsDetector::checkVersionCompatibility, t); +} + +int64_t multiSlsDetector::getId(idMode mode, int imod) +{ + int id, im; + int64_t ret; + if (decodeNMod(imod, id, im) >= 0) { + if (id < 0 && id >= detectors.size()) + return -1; + ret = detectors[id]->getId(mode, im); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + return ret; + } + + return callDetectorMember(&slsDetector::getId, mode, imod); +} + slsDetector* multiSlsDetector::getSlsDetector(unsigned int pos) { @@ -81,6 +613,11 @@ slsDetector* multiSlsDetector::getSlsDetector(unsigned int pos) return 0; } +slsDetector *multiSlsDetector::operator()(int pos) { + if (pos >= 0 && pos < detectors.size()) + return detectors[pos]; + return NULL; +} void multiSlsDetector::freeSharedMemory(int multiId) @@ -531,7 +1068,7 @@ void multiSlsDetector::destroyThreadPool() int multiSlsDetector::getNumberOfDetectors() { - return thisMultiDetector->numberOfDetectors; + return detectors.size(); } int multiSlsDetector::getNumberOfDetectors(dimension d) @@ -606,11 +1143,11 @@ int multiSlsDetector::setNumberOfModules(int p, dimension d) thisMultiDetector->dataBytesInclGapPixels = 0; thisMultiDetector->numberOfChannels = 0; - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { + for (int idet = 0; idet < detectors.size(); ++idet) { if (p < 0) nm = p; else { - mm = (*it)->getMaxNumberOfModules(); + mm = detectors[idet]->getMaxNumberOfModules(); if (nt > mm) { nm = mm; nt -= nm; @@ -619,12 +1156,12 @@ int multiSlsDetector::setNumberOfModules(int p, dimension d) nt -= nm; } } - ret += (*it)->setNumberOfModules(nm); - if ((*it)->getErrorMask()) - setErrorMask(getErrorMask() | (1 << (it-detectors.begin()))); - thisMultiDetector->dataBytes += (*it)->getDataBytes(); - thisMultiDetector->dataBytesInclGapPixels += (*it)->getDataBytesInclGapPixels(); - thisMultiDetector->numberOfChannels += (*it)->getTotalNumberOfChannels(); + ret += detectors[idet]->setNumberOfModules(nm); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + thisMultiDetector->dataBytes += detectors[idet]->getDataBytes(); + thisMultiDetector->dataBytesInclGapPixels += detectors[idet]->getDataBytesInclGapPixels(); + thisMultiDetector->numberOfChannels += detectors[idet]->getTotalNumberOfChannels(); } if (p != -1) @@ -719,33 +1256,41 @@ void multiSlsDetector::updateOffsets() thisMultiDetector->maxNumberOfChannelInclGapPixels[X] = 0; thisMultiDetector->maxNumberOfChannelInclGapPixels[Y] = 0; - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - int currentIndex = (it - detectors.begin()); + for (int idet = 0; idet < detectors.size(); ++idet) { #ifdef VERBOSE - cout << "offsetX:" << offsetX << " prevChanX:" << prevChanX << " offsetY:" << offsetY << " prevChanY:" << prevChanY << endl; - cout << "offsetX_gp:" << offsetX_gp << " prevChanX_gp:" << prevChanX_gp << " offsetY_gp:" << offsetY_gp << " prevChanY_gp:" << prevChanY_gp << endl; + cout << "offsetX:" << offsetX << " prevChanX:" << prevChanX << " " + "offsetY:" << offsetY << " prevChanY:" << prevChanY << endl; + cout << "offsetX_gp:" << offsetX_gp << " " + "prevChanX_gp:" << prevChanX_gp << " " + "offsetY_gp:" << offsetY_gp << " " + "prevChanY_gp:" << prevChanY_gp << endl; #endif - //cout<<" totalchan:"<< (*it)->getTotalNumberOfChannels(Y) <<" maxChanY:"<getTotalNumberOfChannels(Y) + <<" maxChanY:"< 0) && ((offsetX + (*it)->getTotalNumberOfChannels(X)) > maxChanX)) - cout << "\nDetector[" << currentIndex << "] exceeds maximum channels allowed for complete detector set in X dimension!" << endl; - if ((maxChanY > 0) && ((offsetY + (*it)->getTotalNumberOfChannels(Y)) > maxChanY)) - cout << "\nDetector[" << currentIndex << "] exceeds maximum channels allowed for complete detector set in Y dimension!" << endl; - prevChanX = (*it)->getTotalNumberOfChannels(X); - prevChanY = (*it)->getTotalNumberOfChannels(Y); - prevChanX_gp = (*it)->getTotalNumberOfChannelsInclGapPixels(X); - prevChanY_gp = (*it)->getTotalNumberOfChannelsInclGapPixels(Y); - numX += (*it)->getTotalNumberOfChannels(X); - numY += (*it)->getTotalNumberOfChannels(Y); - numX_gp += (*it)->getTotalNumberOfChannelsInclGapPixels(X); - numY_gp += (*it)->getTotalNumberOfChannelsInclGapPixels(Y); - maxX += (*it)->getMaxNumberOfChannels(X); - maxY += (*it)->getMaxNumberOfChannels(Y); - maxX_gp += (*it)->getMaxNumberOfChannelsInclGapPixels(X); - maxY_gp += (*it)->getMaxNumberOfChannelsInclGapPixels(Y); + if ((maxChanX > 0) && ((offsetX + detectors[idet]->getTotalNumberOfChannels(X)) + > maxChanX)) + cout << "\nDetector[" << idet << "] exceeds maximum channels " + "allowed for complete detector set in X dimension!" << endl; + if ((maxChanY > 0) && ((offsetY + detectors[idet]->getTotalNumberOfChannels(Y)) + > maxChanY)) + cout << "\nDetector[" << idet << "] exceeds maximum channels " + "allowed for complete detector set in Y dimension!" << endl; + prevChanX = detectors[idet]->getTotalNumberOfChannels(X); + prevChanY = detectors[idet]->getTotalNumberOfChannels(Y); + prevChanX_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); + prevChanY_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); + numX += detectors[idet]->getTotalNumberOfChannels(X); + numY += detectors[idet]->getTotalNumberOfChannels(Y); + numX_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); + numY_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); + maxX += detectors[idet]->getMaxNumberOfChannels(X); + maxY += detectors[idet]->getMaxNumberOfChannels(Y); + maxX_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(X); + maxY_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(Y); ++thisMultiDetector->numberOfDetector[X]; ++thisMultiDetector->numberOfDetector[Y]; #ifdef VERBOSE @@ -754,15 +1299,17 @@ cout << "incrementing in both direction" << endl; } //incrementing in y direction - else if ((maxChanY == -1) || ((maxChanY > 0) && ((offsetY + prevChanY + (*it)->getTotalNumberOfChannels(Y)) <= maxChanY))) { + else if ((maxChanY == -1) || ((maxChanY > 0) && + ((offsetY + prevChanY + detectors[idet]->getTotalNumberOfChannels(Y)) + <= maxChanY))) { offsetY += prevChanY; offsetY_gp += prevChanY_gp; - prevChanY = (*it)->getTotalNumberOfChannels(Y); - prevChanY_gp = (*it)->getTotalNumberOfChannelsInclGapPixels(Y); - numY += (*it)->getTotalNumberOfChannels(Y); - numY_gp += (*it)->getTotalNumberOfChannelsInclGapPixels(Y); - maxY += (*it)->getMaxNumberOfChannels(Y); - maxY_gp += (*it)->getMaxNumberOfChannelsInclGapPixels(Y); + prevChanY = detectors[idet]->getTotalNumberOfChannels(Y); + prevChanY_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); + numY += detectors[idet]->getTotalNumberOfChannels(Y); + numY_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); + maxY += detectors[idet]->getMaxNumberOfChannels(Y); + maxY_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(Y); ++thisMultiDetector->numberOfDetector[Y]; #ifdef VERBOSE cout << "incrementing in y direction" << endl; @@ -771,35 +1318,44 @@ cout << "incrementing in y direction" << endl; //incrementing in x direction else { - if ((maxChanX > 0) && ((offsetX + prevChanX + (*it)->getTotalNumberOfChannels(X)) > maxChanX)) - cout << "\nDetector[" << currentIndex << "] exceeds maximum channels allowed for complete detector set in X dimension!" << endl; + if ((maxChanX > 0) && + ((offsetX + prevChanX + detectors[idet]->getTotalNumberOfChannels(X)) + > maxChanX)) + cout << "\nDetector[" << idet << "] exceeds maximum channels " + "allowed for complete detector set in X dimension!" << endl; offsetY = 0; offsetY_gp = 0; - prevChanY = (*it)->getTotalNumberOfChannels(Y); - prevChanY_gp = (*it)->getTotalNumberOfChannelsInclGapPixels(Y); - numY = 0; //assuming symmetry with this statement. whats on 1st column should be on 2nd column + prevChanY = detectors[idet]->getTotalNumberOfChannels(Y); + prevChanY_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); + numY = 0; //assuming symmetry with this statement. + //whats on 1st column should be on 2nd column numY_gp = 0; maxY = 0; maxY_gp = 0; offsetX += prevChanX; offsetX_gp += prevChanX_gp; - prevChanX = (*it)->getTotalNumberOfChannels(X); - prevChanX_gp = (*it)->getTotalNumberOfChannelsInclGapPixels(X); - numX += (*it)->getTotalNumberOfChannels(X); - numX_gp += (*it)->getTotalNumberOfChannelsInclGapPixels(X); - maxX += (*it)->getMaxNumberOfChannels(X); - maxX_gp += (*it)->getMaxNumberOfChannelsInclGapPixels(X); + prevChanX = detectors[idet]->getTotalNumberOfChannels(X); + prevChanX_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); + numX += detectors[idet]->getTotalNumberOfChannels(X); + numX_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); + maxX += detectors[idet]->getMaxNumberOfChannels(X); + maxX_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(X); ++thisMultiDetector->numberOfDetector[X]; #ifdef VERBOSE cout << "incrementing in x direction" << endl; #endif } - double bytesperchannel = (double)(*it)->getDataBytes() / (double)((*it)->getMaxNumberOfChannels(X) * (*it)->getMaxNumberOfChannels(Y)); + double bytesperchannel = (double)detectors[idet]->getDataBytes() / + (double)(detectors[idet]->getMaxNumberOfChannels(X) + * detectors[idet]->getMaxNumberOfChannels(Y)); #ifdef VERBOSE - cout << "Detector[" << currentIndex << "] has offsets (" << thisMultiDetector->offsetX[currentIndex] << ", " << thisMultiDetector->offsetY[currentIndex] << ")" << endl; + cout << "Detector[" << idet << "] has offsets (" << + thisMultiDetector->offsetX[idet] << ", " << + thisMultiDetector->offsetY[idet] << ")" << endl; #endif - //offsetY has been reset sometimes and offsetX the first time, but remember the highest values + //offsetY has been reset sometimes and offsetX the first time, + //but remember the highest values if (numX > thisMultiDetector->numberOfChannel[X]) thisMultiDetector->numberOfChannel[X] = numX; if (numY > thisMultiDetector->numberOfChannel[Y]) @@ -821,54 +1377,15 @@ cout << "incrementing in x direction" << endl; cout << "Number of Channels in X direction:" << thisMultiDetector->numberOfChannel[X] << endl; cout << "Number of Channels in Y direction:" << thisMultiDetector->numberOfChannel[Y] << endl << endl; - cout << "Number of Channels in X direction with Gap Pixels:" << thisMultiDetector->numberOfChannelInclGapPixels[X] << endl; - cout << "Number of Channels in Y direction with Gap Pixels:" << thisMultiDetector->numberOfChannelInclGapPixels[Y] << endl + cout << "Number of Channels in X direction with Gap Pixels:" << + thisMultiDetector->numberOfChannelInclGapPixels[X] << endl; + cout << "Number of Channels in Y direction with Gap Pixels:" << + thisMultiDetector->numberOfChannelInclGapPixels[Y] << endl << endl; #endif } - -int multiSlsDetector::decodeNMod(int i, int& id, int& im) -{ -#ifdef VERBOSE - cout << " Module " << i << " belongs to detector " << id << endl; - ; - cout << getMaxMods(); -#endif - - if (i < 0 || i >= getMaxMods()) { - id = -1; - im = -1; -#ifdef VERBOSE - cout << " A---------" << id << " position " << im << endl; -#endif - - return -1; - } - int nm; - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - nm = (*it)->getNMods(); - if (nm > i) { - id = (it - detectors.begin()); - im = i; -#ifdef VERBOSE - cout << " B---------" << id << " position " << im << endl; -#endif - return im; - } else { - i -= nm; - } - } - id = -1; - im = -1; -#ifdef VERBOSE - cout << " C---------" << id << " position " << im << endl; -#endif - return -1; -} - - int multiSlsDetector::setOnline(int off) { if (off != GET_ONLINE_FLAG) @@ -889,11 +1406,31 @@ string multiSlsDetector::checkOnline() } -int multiSlsDetector::activate(int const enable) +int multiSlsDetector::setPort(portType t, int p) { - return callDetectorMember(&slsDetector::activate, enable); + return callDetectorMember(&slsDetector::setPort, t, p); } +int multiSlsDetector::lockServer(int p) +{ + return callDetectorMember(&slsDetector::lockServer, p); +} + +string multiSlsDetector::getLastClientIP() +{ + return callDetectorMember(&slsDetector::getLastClientIP); +} + +int multiSlsDetector::exitServer() +{ + int ival = FAIL, iv; + for (int idet = 0; idet < detectors.size(); ++idet) { + iv = detectors[idet]->exitServer(); + if (iv == OK) + ival = iv; + } + return ival; +} int multiSlsDetector::readConfigurationFile(string const fname) { @@ -1030,11 +1567,11 @@ int multiSlsDetector::writeConfigurationFile(string const fname) ++iline; // single detector configuration - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { + for (int idet = 0; idet < detectors.size(); ++idet) { outfile << endl; - ret1 = detectors[i]->writeConfigurationFile(outfile, (it - detectors.begin())); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << (it - detectors.begin()))); + ret1 = detectors[idet]->writeConfigurationFile(outfile, idet); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); if (ret1 == FAIL) ret = FAIL; } @@ -1068,6 +1605,305 @@ int multiSlsDetector::writeConfigurationFile(string const fname) +string multiSlsDetector::getSettingsFile() +{ + return callDetectorMember(&slsDetector::getSettingsFile); +} + + +slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) +{ + int ret = -100; + int posmin = 0, posmax = detectors.size(); + if (pos >= 0) { + posmin = pos; + posmax = pos + 1; + } + + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return GET_SETTINGS; + } else { + //return storage values + detectorSettings* iret[posmax - posmin]; + for (int idet = posmin; idet < posmax; ++idet) { + iret[idet] = new detectorSettings(GET_SETTINGS); + Task* task = new Task(new func1_t(&slsDetector::getSettings, + detectors[idet], -1, iret[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for (int idet = posmin; idet < posmax; ++idet) { + if (iret[idet] != NULL) { + if (ret == -100) + ret = *iret[idet]; + else if (ret != *iret[idet]) + ret = GET_SETTINGS; + delete iret[idet]; + } else + ret = GET_SETTINGS; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } + + thisMultiDetector->currentSettings = (detectorSettings)ret; + return (detectorSettings)ret; +} + +slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings isettings, int pos) +{ + int ret = -100; + int posmin = 0, posmax = detectors.size(); + if (pos >= 0) { + posmin = pos; + posmax = pos + 1; + } + + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return GET_SETTINGS; + } else { + //return storage values + detectorSettings* iret[posmax - posmin]; + for (int idet = posmin; idet < posmax; ++idet) { + if (detectors[idet]) { + iret[idet] = new detectorSettings(GET_SETTINGS); + Task* task = new Task(new func2_t + (&slsDetector::setSettings, detectors[idet], isettings, -1, iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for (int idet = posmin; idet < posmax; ++idet) { + if (detectors[idet]) { + if (iret[idet] != NULL) { + if (ret == -100) + ret = *iret[idet]; + else if (ret != *iret[idet]) + ret = GET_SETTINGS; + delete iret[idet]; + } else + ret = GET_SETTINGS; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } + } + + thisMultiDetector->currentSettings = (detectorSettings)ret; + return (detectorSettings)ret; +} + + +string multiSlsDetector::getSettingsDir() +{ + return callDetectorMember(&slsDetector::getSettingsDir); +} + + +string multiSlsDetector::setSettingsDir(string s) +{ + + if (s.find('+') == string::npos) { + for (int idet = 0; idet < detectors.size(); ++idet) { + detectors[idet]->setSettingsDir(s); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } else { + size_t p1 = 0; + size_t p2 = s.find('+', p1); + int id = 0; + while (p2 != string::npos) { + detectors[id]->setSettingsDir(s.substr(p1, p2 - p1)); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + ++id; + s = s.substr(p2 + 1); + p2 = s.find('+'); + if (id >= detectors.size()) + break; + } + } + return getSettingsDir(); +} + +string multiSlsDetector::getCalDir() +{ + return callDetectorMember(&slsDetector::getCalDir); +} + +string multiSlsDetector::setCalDir(string s) +{ + + if (s.find('+') == string::npos) { + for (int idet = 0; idet < detectors.size(); ++idet) { + detectors[idet]->setCalDir(s); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } else { + size_t p1 = 0; + size_t p2 = s.find('+', p1); + int id = 0; + while (p2 != string::npos) { + + if (detectors[id]) { + detectors[id]->setCalDir(s.substr(p1, p2 - p1)); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + } + ++id; + s = s.substr(p2 + 1); + p2 = s.find('+'); + if (id >= detectors.size()) + break; + } + } + return getCalDir(); +} + + +int multiSlsDetector::loadSettingsFile(string fname, int imod) +{ + int ret = OK; + + // single + { + int id = -1, im = -1; + if (decodeNMod(imod, id, im) >= 0) { + if (id < 0 || id > detectors.size()) + return -1; + ret = detectors[id]->loadSettingsFile(fname, im); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + return ret; + } + } + + // multi + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } + + int* iret[detectors.size()]; + for (int idet = 0; idet < detectors.size(); ++idet) { + iret[idet] = new int(OK); + Task* task = new Task(new func2_t(&slsDetector::loadSettingsFile, + detectors[idet], fname, imod, iret[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for (int idet = 0; idet < detectors.size(); ++idet) { + if (iret[idet] != NULL) { + if (*iret[idet] != OK) + ret = FAIL; + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + + return ret; +} + +int multiSlsDetector::saveSettingsFile(string fname, int imod) +{ + int id = -1, im = -1, ret; + + if (decodeNMod(imod, id, im) >= 0) { + if (id < 0 || id > detectors.size()) + return -1; + ret = detectors[id]->saveSettingsFile(fname, im); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + return ret; + + } + for (int idet = 0; idet < detectors.size(); ++idet) { + ret = detectors[idet]->saveSettingsFile(fname, imod); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return ret; +} + + +int multiSlsDetector::loadCalibrationFile(string fname, int imod) +{ + int ret = OK; + + // single + { + int id = -1, im = -1; + if (decodeNMod(imod, id, im) >= 0) { + if (id < 0 || id > detectors.size()) + return -1; + ret = detectors[id]->loadCalibrationFile(fname, im); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + return ret; + } + } + + // multi + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } + + int* iret[detectors.size()]; + for (int idet = 0; idet < detectors.size(); ++idet) { + if (detectors[idet]) { + iret[idet] = new int(OK); + Task* task = new Task(new func2_t(&slsDetector::loadCalibrationFile, + detectors[idet], fname, imod, iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for (int idet = 0; idet < detectors.size(); ++idet) { + if (detectors[idet]) { + if (iret[idet] != NULL) { + if (*iret[idet] != OK) + ret = FAIL; + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } + + return ret; +} + +int multiSlsDetector::saveCalibrationFile(string fname, int imod) +{ + int id = -1, im = -1, ret; + if (decodeNMod(imod, id, im) >= 0) { + if (id < 0 || id > detectors.size()) + return -1; + ret = detectors[id]->saveCalibrationFile(fname, im); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + return ret; + } + for (int idet = 0; idet < detectors.size(); ++idet) { + ret = detectors[idet]->saveCalibrationFile(fname, imod); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return ret; +} + int multiSlsDetector::setMaster(int i) @@ -1086,38 +1922,37 @@ int multiSlsDetector::setMaster(int i) if (detectors[i]->getErrorMask()) setErrorMask(getErrorMask() | (1 << i)); - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - int currentIndex = (it - detectors.begin()); - if (i != currentIndex) { + for (int idet = 0; idet < detectors.size(); ++idet) { + if (i != idet) { #ifdef VERBOSE - cout << "detector position " << currentIndex << " "; + cout << "detector position " << idet << " "; #endif - (*it)->setMaster(IS_SLAVE); - if ((*it)->getErrorMask()) - setErrorMask(getErrorMask() | (1 << currentIndex)); + detectors[idet]->setMaster(IS_SLAVE); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } } else if (i == -2) { - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { + for (int idet = 0; idet < detectors.size(); ++idet) { #ifdef VERBOSE - cout << "detector position " << (it - detectors.begin()) << " "; + cout << "detector position " << idet << " "; #endif - (*it)->setMaster(NO_MASTER); - if ((*it)->getErrorMask()) - setErrorMask(getErrorMask() | (1 << (it - detectors.begin()))); + detectors[idet]->setMaster(NO_MASTER); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } // check return value - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { + for (int idet = 0; idet < detectors.size(); ++idet) { #ifdef VERBOSE - cout << "detector position " << (it - detectors.begin()) << " "; + cout << "detector position " << idet << " "; #endif - f = (*it)->setMaster(GET_MASTER); - if ((*it)->getErrorMask()) - setErrorMask(getErrorMask() | (1 << (it - detectors.begin()))); + f = detectors[idet]->setMaster(GET_MASTER); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); switch (f) { case NO_MASTER: @@ -1126,7 +1961,7 @@ int multiSlsDetector::setMaster(int i) break; case IS_MASTER: if (ret == -1) - ret = (it - detectors.begin()); + ret = idet; else ret = -2; break; @@ -1154,10 +1989,10 @@ slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchr { synchronizationMode ret = GET_SYNCHRONIZATION_MODE, ret1 = GET_SYNCHRONIZATION_MODE; - for (vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - ret1 = (*it)->setSynchronization(sync); - if ((*it)->getErrorMask()) - setErrorMask(getErrorMask() | (1 << (it - detectors.begin()))); + for (int idet = 0; idet < detectors.size(); ++idet) { + ret1 = detectors[idet]->setSynchronization(sync); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); if (id == 0) ret = ret1; @@ -1170,249 +2005,35 @@ slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchr return thisMultiDetector->syncMode; } - - - - - - - - - - - - -int64_t multiSlsDetector::getId(idMode mode, int imod) +slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() { - - int id, im; - int64_t ret; - - if (decodeNMod(imod, id, im) >= 0) { - if (detectors[id]) { - ret = detectors[id]->getId(mode, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; - } + runStatus s = IDLE, s1 = IDLE; + if (thisMultiDetector->masterPosition >= 0) { + s = detectors[thisMultiDetector->masterPosition]->getRunStatus(); + if (detectors[thisMultiDetector->masterPosition]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << thisMultiDetector->masterPosition)); + return s; } - return -1; + for (int i = 0; i < detectors.size(); ++i) { + s1 = detectors[i]->getRunStatus(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (s1 == ERROR) { + return ERROR; + } + if (s1 != IDLE) + s = s1; + } + return s; } - - - - - - - -// Initialization functions -int multiSlsDetector::getThresholdEnergy(int pos) -{ - - int i, posmin, posmax; - int ret1 = -100, ret; - - if (pos < 0) { - posmin = 0; - posmax = thisMultiDetector->numberOfDetectors; - } else { - posmin = pos; - posmax = pos + 1; - } - - for (i = posmin; i < posmax; ++i) { - if (detectors[i]) { - ret = detectors[i]->getThresholdEnergy(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 == -100) - ret1 = ret; - else if (ret < (ret1 - 200) || ret > (ret1 + 200)) - ret1 = -1; - } - } - thisMultiDetector->currentThresholdEV = ret1; - return ret1; -} - -int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) -{ - - int posmin, posmax; - int ret = -100; - if (pos < 0) { - posmin = 0; - posmax = thisMultiDetector->numberOfDetectors; - } else { - posmin = pos; - posmax = pos + 1; - } - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } else { - //return storage values - int* iret[posmax - posmin]; - for (int idet = posmin; idet < posmax; ++idet) { - if (detectors[idet]) { - iret[idet] = new int(-1); - Task* task = new Task(new func4_t(&slsDetector::setThresholdEnergy, - detectors[idet], e_eV, -1, isettings, tb, iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = posmin; idet < posmax; ++idet) { - if (detectors[idet]) { - if (iret[idet] != NULL) { - if (ret == -100) - ret = *iret[idet]; - else if (*iret[idet] < (ret - 200) || *iret[idet] > (ret + 200)) - ret = -1; - delete iret[idet]; - } else - ret = -1; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } - - thisMultiDetector->currentThresholdEV = ret; - return ret; -} - -slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) -{ - - int posmin, posmax; - int ret = -100; - - if (pos < 0) { - posmin = 0; - posmax = thisMultiDetector->numberOfDetectors; - } else { - posmin = pos; - posmax = pos + 1; - } - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return GET_SETTINGS; - } else { - //return storage values - detectorSettings* iret[posmax - posmin]; - for (int idet = posmin; idet < posmax; ++idet) { - if (detectors[idet]) { - iret[idet] = new detectorSettings(GET_SETTINGS); - Task* task = new Task(new func1_t(&slsDetector::getSettings, - detectors[idet], -1, iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = posmin; idet < posmax; ++idet) { - if (detectors[idet]) { - if (iret[idet] != NULL) { - if (ret == -100) - ret = *iret[idet]; - else if (ret != *iret[idet]) - ret = GET_SETTINGS; - delete iret[idet]; - } else - ret = GET_SETTINGS; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } - - thisMultiDetector->currentSettings = (detectorSettings)ret; - return (detectorSettings)ret; -} - -slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings isettings, int pos) -{ - - int posmin, posmax; - int ret = -100; - - if (pos < 0) { - posmin = 0; - posmax = thisMultiDetector->numberOfDetectors; - } else { - posmin = pos; - posmax = pos + 1; - } - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return GET_SETTINGS; - } else { - //return storage values - detectorSettings* iret[posmax - posmin]; - for (int idet = posmin; idet < posmax; ++idet) { - if (detectors[idet]) { - iret[idet] = new detectorSettings(GET_SETTINGS); - Task* task = new Task(new func2_t(&slsDetector::setSettings, - detectors[idet], isettings, -1, iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = posmin; idet < posmax; ++idet) { - if (detectors[idet]) { - if (iret[idet] != NULL) { - if (ret == -100) - ret = *iret[idet]; - else if (ret != *iret[idet]) - ret = GET_SETTINGS; - delete iret[idet]; - } else - ret = GET_SETTINGS; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } - - thisMultiDetector->currentSettings = (detectorSettings)ret; - return (detectorSettings)ret; -} - -int multiSlsDetector::getChanRegs(double* retval, bool fromDetector) -{ - //nChansDet and currentNumChans is because of varying channel size per detector - int n = thisMultiDetector->numberOfChannels, nChansDet, currentNumChans = 0; - double retval1[n]; - - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - nChansDet = detectors[idet]->getChanRegs(retval1, fromDetector); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - - memcpy(retval + (currentNumChans), retval1, nChansDet * sizeof(double)); - currentNumChans += nChansDet; - } - } - return n; -} - -/* Communication to server */ - int multiSlsDetector::prepareAcquisition() { int i = 0; int ret = OK; - int posmin = 0, posmax = thisMultiDetector->numberOfDetectors; + int posmin = 0, posmax = detectors.size(); if (!threadpool) { cout << "Error in creating threadpool. Exiting" << endl; @@ -1420,7 +2041,7 @@ int multiSlsDetector::prepareAcquisition() } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { iret[idet] = new int(OK); Task* task = new Task(new func0_t(&slsDetector::prepareAcquisition, detectors[idet], iret[idet])); @@ -1430,7 +2051,7 @@ int multiSlsDetector::prepareAcquisition() threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { if (iret[idet] != NULL) { if (*iret[idet] != OK) ret = FAIL; @@ -1445,15 +2066,13 @@ int multiSlsDetector::prepareAcquisition() //master int ret1 = OK; - i = thisMultiDetector->masterPosition; + i = thisMultiDetector->masterPosition; if (thisMultiDetector->masterPosition >= 0) { - if (detectors[i]) { - ret1 = detectors[i]->prepareAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } + ret1 = detectors[i]->prepareAcquisition(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret1 != OK) + ret = FAIL; } return ret; @@ -1463,17 +2082,15 @@ int multiSlsDetector::cleanupAcquisition() { int i = 0; int ret = OK, ret1 = OK; - int posmin = 0, posmax = thisMultiDetector->numberOfDetectors; + int posmin = 0, posmax = detectors.size(); i = thisMultiDetector->masterPosition; if (thisMultiDetector->masterPosition >= 0) { - if (detectors[i]) { - ret1 = detectors[i]->cleanupAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } + ret1 = detectors[i]->cleanupAcquisition(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret1 != OK) + ret = FAIL; } if (!threadpool) { @@ -1482,7 +2099,7 @@ int multiSlsDetector::cleanupAcquisition() } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { iret[idet] = new int(OK); Task* task = new Task(new func0_t(&slsDetector::cleanupAcquisition, detectors[idet], iret[idet])); @@ -1492,7 +2109,7 @@ int multiSlsDetector::cleanupAcquisition() threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { if (iret[idet] != NULL) { if (*iret[idet] != OK) ret = FAIL; @@ -1504,12 +2121,9 @@ int multiSlsDetector::cleanupAcquisition() } } } - return ret; } -// Acquisition functions -/* change these funcs accepting also ok/fail */ int multiSlsDetector::startAcquisition() { @@ -1520,7 +2134,7 @@ int multiSlsDetector::startAcquisition() int i = 0; int ret = OK; - int posmin = 0, posmax = thisMultiDetector->numberOfDetectors; + int posmin = 0, posmax = detectors.size(); if (!threadpool) { cout << "Error in creating threadpool. Exiting" << endl; @@ -1528,7 +2142,7 @@ int multiSlsDetector::startAcquisition() } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { iret[idet] = new int(OK); Task* task = new Task(new func0_t(&slsDetector::startAcquisition, detectors[idet], iret[idet])); @@ -1538,7 +2152,7 @@ int multiSlsDetector::startAcquisition() threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { if (iret[idet] != NULL) { if (*iret[idet] != OK) ret = FAIL; @@ -1555,33 +2169,30 @@ int multiSlsDetector::startAcquisition() int ret1 = OK; i = thisMultiDetector->masterPosition; if (thisMultiDetector->masterPosition >= 0) { - if (detectors[i]) { - ret1 = detectors[i]->startAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } + ret1 = detectors[i]->startAcquisition(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret1 != OK) + ret = FAIL; } return ret; -}; +} + int multiSlsDetector::stopAcquisition() { pthread_mutex_lock(&mg); // locks due to processing thread using threadpool when in use int i = 0; int ret = OK, ret1 = OK; - int posmin = 0, posmax = thisMultiDetector->numberOfDetectors; + int posmin = 0, posmax = detectors.size(); i = thisMultiDetector->masterPosition; if (thisMultiDetector->masterPosition >= 0) { - if (detectors[i]) { - ret1 = detectors[i]->stopAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } + ret1 = detectors[i]->stopAcquisition(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret1 != OK) + ret = FAIL; } if (!threadpool) { @@ -1590,7 +2201,7 @@ int multiSlsDetector::stopAcquisition() } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { iret[idet] = new int(OK); Task* task = new Task(new func0_t(&slsDetector::stopAcquisition, detectors[idet], iret[idet])); @@ -1600,7 +2211,7 @@ int multiSlsDetector::stopAcquisition() threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { + if (idet != thisMultiDetector->masterPosition) { if (iret[idet] != NULL) { if (*iret[idet] != OK) ret = FAIL; @@ -1616,35 +2227,120 @@ int multiSlsDetector::stopAcquisition() *stoppedFlag = 1; pthread_mutex_unlock(&mg); return ret; -}; +} + int multiSlsDetector::startReadOut() { - int i = 0; int ret = OK, ret1 = OK; i = thisMultiDetector->masterPosition; if (i >= 0) { - if (detectors[i]) { - ret = detectors[i]->startReadOut(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret != OK) - ret1 = FAIL; - } + ret = detectors[i]->startReadOut(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret != OK) + ret1 = FAIL; } - for (i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) { - ret = detectors[i]->startReadOut(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret != OK) - ret1 = FAIL; - } + for (i = 0; i < detectors.size(); ++i) { + ret = detectors[i]->startReadOut(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret != OK) + ret1 = FAIL; } return ret1; -}; +} + + +int* multiSlsDetector::startAndReadAll() +{ +#ifdef VERBOSE + cout << "Start and read all " << endl; +#endif + int* retval = NULL; + int i = 0; + if (thisMultiDetector->onlineFlag == ONLINE_FLAG) { + + if (getDetectorsType() == EIGER) { + if (prepareAcquisition() == FAIL) + return NULL; + } + startAndReadAllNoWait(); + + while ((retval = getDataFromDetector())) { + ++i; +#ifdef VERBOSE + std::cout << i << std::endl; +#endif + dataQueue.push(retval); + } + + for (int id = 0; id < detectors.size(); ++id) { + if (detectors[id]) { + detectors[id]->disconnectControl(); + } + } + } +#ifdef VERBOSE + std::cout << "Recieved " << i << " frames" << std::endl; +#endif + return dataQueueFront(); +} + + +int multiSlsDetector::startAndReadAllNoWait() +{ + pthread_mutex_lock(&mg); // locks due to processing thread using threadpool when in use + int i = 0; + int ret = OK; + int posmin = 0, posmax = detectors.size(); + + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return FAIL; + } else { + int* iret[posmax - posmin]; + for (int idet = posmin; idet < posmax; ++idet) { + if (idet != thisMultiDetector->masterPosition){ + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::startAndReadAllNoWait, + detectors[idet], iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for (int idet = posmin; idet < posmax; ++idet) { + if (idet != thisMultiDetector->masterPosition) { + if (iret[idet] != NULL) { + if (*iret[idet] != OK) + ret = FAIL; + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } + } + + //master + int ret1 = OK; + i = thisMultiDetector->masterPosition; + if (thisMultiDetector->masterPosition >= 0) { + ret1 = detectors[i]->startAndReadAllNoWait(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret1 != OK) + ret = FAIL; + } + pthread_mutex_unlock(&mg); + return ret; +} + + int* multiSlsDetector::getDataFromDetector() { @@ -1663,29 +2359,26 @@ int* multiSlsDetector::getDataFromDetector() if (!nodatadetectortype) retval = new int[nel]; p = retval; - // cout << "multi: " << thisMultiDetector->dataBytes << endl; - for (int id = 0; id < thisMultiDetector->numberOfDetectors; ++id) { - if (detectors[id]) { - retdet = detectors[id]->getDataFromDetector(p); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - if (!nodatadetectortype) { - n = detectors[id]->getDataBytes(); - if (retdet) { - ; + for (int id = 0; id < detectors.size(); ++id) { + retdet = detectors[id]->getDataFromDetector(p); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + if (!nodatadetectortype) { + n = detectors[id]->getDataBytes(); + if (retdet) { + ; #ifdef VERBOSE - cout << "Detector " << id << " returned " << n << " bytes " << endl; +cout << "Detector " << id << " returned " << n << " bytes " << endl; #endif - } else { - nodatadet = id; + } else { + nodatadet = id; #ifdef VERBOSE - cout << "Detector " << id << " does not have data left " << endl; + cout << "Detector " << id << " does not have data left " << endl; #endif - } - p += n / sizeof(int); - } - } + } + p += n / sizeof(int); + } } //eiger returns only null @@ -1694,7 +2387,7 @@ int* multiSlsDetector::getDataFromDetector() } if (nodatadet >= 0) { - for (int id = 0; id < thisMultiDetector->numberOfDetectors; ++id) { + for (int id = 0; id < detectors.size(); ++id) { if (id != nodatadet) { if (detectors[id]) { //#ifdef VERBOSE @@ -1707,7 +2400,6 @@ int* multiSlsDetector::getDataFromDetector() while ((retdet = detectors[id]->getDataFromDetector())) { if (detectors[id]->getErrorMask()) setErrorMask(getErrorMask() | (1 << id)); - #ifdef VERBOSE cout << "Detector " << id << " still sent data " << endl; #endif @@ -1723,7 +2415,8 @@ int* multiSlsDetector::getDataFromDetector() } return retval; -}; +} + int* multiSlsDetector::readFrame() { @@ -1732,9 +2425,7 @@ int* multiSlsDetector::readFrame() int* retval = new int[nel]; int *retdet, *p = retval; - /** probably it's always better to have one integer per channel in any case! */ - - for (int id = 0; id < thisMultiDetector->numberOfDetectors; ++id) { + for (int id = 0; id < detectors.size(); ++id) { if (detectors[id]) { retdet = detectors[id]->readFrame(); if (detectors[id]->getErrorMask()) @@ -1757,179 +2448,41 @@ int* multiSlsDetector::readFrame() } dataQueue.push(retval); return retval; -}; +} + int* multiSlsDetector::readAll() { - - /** Thread for each detector?!?!?! */ - - // int fnum=F_READ_ALL; - int* retval; // check what we return! - // int ret=OK, ret1=OK; - + int* retval = NULL; int i = 0; #ifdef VERBOSE std::cout << "Reading all frames " << std::endl; #endif if (thisMultiDetector->onlineFlag == ONLINE_FLAG) { - for (int id = 0; id < thisMultiDetector->numberOfDetectors; ++id) { - if (detectors[id]) { - detectors[id]->readAllNoWait(); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - } - } + for (int id = 0; id < detectors.size(); ++id) { + detectors[id]->readAllNoWait(); + if (detectors[id]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << id)); + } while ((retval = getDataFromDetector())) { ++i; #ifdef VERBOSE std::cout << i << std::endl; - //#else - //std::cout << "-" << flush; #endif dataQueue.push(retval); } - for (int id = 0; id < thisMultiDetector->numberOfDetectors; ++id) { - if (detectors[id]) { - detectors[id]->disconnectControl(); - } + for (int id = 0; id < detectors.size(); ++id) { + detectors[id]->disconnectControl(); } } #ifdef VERBOSE std::cout << "received " << i << " frames" << std::endl; - //#else - // std::cout << std::endl; #endif - return dataQueueFront(); // check what we return! -}; - -int* multiSlsDetector::startAndReadAll() -{ - - /** Thread for each detector?!?!?! */ -#ifdef VERBOSE - cout << "Start and read all " << endl; -#endif - - int* retval; - int i = 0; - if (thisMultiDetector->onlineFlag == ONLINE_FLAG) { - - if (getDetectorsType() == EIGER) { - if (prepareAcquisition() == FAIL) - return NULL; - } - startAndReadAllNoWait(); - - while ((retval = getDataFromDetector())) { - ++i; -#ifdef VERBOSE - std::cout << i << std::endl; - //#else - //std::cout << "-" << flush; -#endif - dataQueue.push(retval); - } - - for (int id = 0; id < thisMultiDetector->numberOfDetectors; ++id) { - if (detectors[id]) { - detectors[id]->disconnectControl(); - } - } - } - -#ifdef VERBOSE - std::cout << "MMMM recieved " << i << " frames" << std::endl; - //#else - // std::cout << std::endl; -#endif - return dataQueueFront(); // check what we return! -}; - -int multiSlsDetector::startAndReadAllNoWait() -{ - pthread_mutex_lock(&mg); // locks due to processing thread using threadpool when in use - int i = 0; - int ret = OK; - int posmin = 0, posmax = thisMultiDetector->numberOfDetectors; - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return FAIL; - } else { - int* iret[posmax - posmin]; - for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startAndReadAllNoWait, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = posmin; idet < posmax; ++idet) { - if ((idet != thisMultiDetector->masterPosition) && (detectors[idet])) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else - ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } - - //master - int ret1 = OK; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - if (detectors[i]) { - ret1 = detectors[i]->startAndReadAllNoWait(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } - } - pthread_mutex_unlock(&mg); - return ret; + return dataQueueFront(); } -/** - get run status - \returns status mask -*/ -slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() -{ - - runStatus s = IDLE, s1 = IDLE; - if (thisMultiDetector->masterPosition >= 0) - if (detectors[thisMultiDetector->masterPosition]) { - s = detectors[thisMultiDetector->masterPosition]->getRunStatus(); - if (detectors[thisMultiDetector->masterPosition]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << thisMultiDetector->masterPosition)); - return s; - } - - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - s1 = detectors[i]->getRunStatus(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (s1 == ERROR) { - return ERROR; - } - if (s1 != IDLE) - s = s1; - // if (s1==IDLE && s!=IDLE) - // s=ERROR; - } - return s; -} int* multiSlsDetector::popDataQueue() { @@ -1971,6 +2524,198 @@ void multiSlsDetector::resetFinalDataQueue() } } +int multiSlsDetector::configureMAC() +{ + return callDetectorMember(&slsDetector::configureMAC); +} + +int multiSlsDetector::getThresholdEnergy(int pos) +{ + int i, posmin, posmax; + int ret1 = -100, ret; + + if (pos < 0) { + posmin = 0; + posmax = detectors.size(); + } else { + posmin = pos; + posmax = pos + 1; + } + + for (i = posmin; i < posmax; ++i) { + ret = detectors[i]->getThresholdEnergy(); + if (detectors[i]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << i)); + if (ret1 == -100) + ret1 = ret; + else if (ret < (ret1 - 200) || ret > (ret1 + 200)) + ret1 = -1; + } + thisMultiDetector->currentThresholdEV = ret1; + return ret1; +} + + +int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) +{ + int posmin, posmax; + int ret = -100; + if (pos < 0) { + posmin = 0; + posmax = detectors.size(); + } else { + posmin = pos; + posmax = pos + 1; + } + + if (!threadpool) { + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + } else { + //return storage values + int* iret[posmax - posmin]; + for (int idet = posmin; idet < posmax; ++idet) { + iret[idet] = new int(-1); + Task* task = new Task(new func4_t(&slsDetector::setThresholdEnergy, + detectors[idet], e_eV, -1, isettings, tb, iret[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for (int idet = posmin; idet < posmax; ++idet) { + if (iret[idet] != NULL) { + if (ret == -100) + ret = *iret[idet]; + else if (*iret[idet] < (ret - 200) || *iret[idet] > (ret + 200)) + ret = -1; + delete iret[idet]; + } else + ret = -1; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + } + + thisMultiDetector->currentThresholdEV = ret; + return ret; +} + + + + + + + + + + + + + + + +int multiSlsDetector::activate(int const enable) +{ + return callDetectorMember(&slsDetector::activate, enable); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// Initialization functions + + +int multiSlsDetector::getChanRegs(double* retval, bool fromDetector) +{ + //nChansDet and currentNumChans is because of varying channel size per detector + int n = thisMultiDetector->numberOfChannels, nChansDet, currentNumChans = 0; + double retval1[n]; + + for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { + if (detectors[idet]) { + nChansDet = detectors[idet]->getChanRegs(retval1, fromDetector); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + + memcpy(retval + (currentNumChans), retval1, nChansDet * sizeof(double)); + currentNumChans += nChansDet; + } + } + return n; +} + +/* Communication to server */ + + + + + + + +/** + get run status + \returns status mask +*/ + + + int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t) { int64_t ret = parallelCallDetectorMember(&slsDetector::setTimer, index, t); @@ -2095,31 +2840,6 @@ void multiSlsDetector::verifyMinMaxROI(int n, ROI r[]) } } -int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int& channelX, int& channelY) -{ - channelX = -1; - channelY = -1; - //loop over - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) { - //check x offset range - if ((offsetX >= thisMultiDetector->offsetX[i]) && (offsetX < (thisMultiDetector->offsetX[i] + detectors[i]->getMaxNumberOfChannelsInclGapPixels(X)))) { - if (offsetY == -1) { - channelX = offsetX - thisMultiDetector->offsetX[i]; - return i; - } else { - //check y offset range - if ((offsetY >= thisMultiDetector->offsetY[i]) && (offsetY < (thisMultiDetector->offsetY[i] + detectors[i]->getMaxNumberOfChannelsInclGapPixels(Y)))) { - channelX = offsetX - thisMultiDetector->offsetX[i]; - channelY = offsetY - thisMultiDetector->offsetY[i]; - return i; - } - } - } - } - } - return -1; -} int multiSlsDetector::setROI(int n, ROI roiLimits[]) { @@ -2396,55 +3116,7 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) return retval; } -double* multiSlsDetector::decodeData(int* datain, int& nn, double* fdata) -{ - double* dataout; - if (fdata) - dataout = fdata; - else { - if (detectors[0]->getDetectorsType() == JUNGFRAUCTB) { - nn = thisMultiDetector->dataBytes / 2; - dataout = new double[nn]; - } else { - nn = thisMultiDetector->numberOfChannels; - dataout = new double[nn]; - } - } - - // int ich=0; - int n; - double* detp = dataout; - int* datap = datain; - - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) { - detectors[i]->decodeData(datap, n, detp); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); -#ifdef VERBOSE - cout << "increment pointers " << endl; -#endif - datap += detectors[i]->getDataBytes() / sizeof(int); - detp += n; - // if (detectors[0]->getDetectorsType()==JUNGFRAUCTB) { - // detp+=detectors[i]->getDataBytes()/2; - // } else { - // detp+=detectors[i]->getTotalNumberOfChannels(); - // } -#ifdef VERBOSE - cout << "done " << endl; -#endif - // for (int j=0; jgetTotalNumberOfChannels(); ++j) { - // dataout[ich]=detp[j]; - // ++ich; - // } - //delete [] detp; - } - } - - return dataout; -} //Correction int multiSlsDetector::setFlatFieldCorrection(string fname) @@ -3401,37 +4073,9 @@ int multiSlsDetector::getBadChannelCorrection(int* bad) return ntot; } -int multiSlsDetector::exitServer() -{ - int ival = FAIL, iv; - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - iv = detectors[idet]->exitServer(); - if (iv == OK) - ival = iv; - } - } - return ival; -} -/* utility function to check a range of return values*/ -template -T multiSlsDetector::minusOneIfDifferent(const std::vector& return_values) -{ - T ret = static_cast(-100); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - if (ret == static_cast(-100)) - ret = return_values[idet]; - else if (ret != return_values[idet]) - ret = static_cast(-1); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - return ret; -} + void multiSlsDetector::setErrorMaskFromAllDetectors() { @@ -3443,215 +4087,25 @@ void multiSlsDetector::setErrorMaskFromAllDetectors() } } -std::string multiSlsDetector::concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos) -{ - if (pos >= 0) { - if (detectors[pos]) - return (detectors[pos]->*somefunc)(pos); - } else { - std::string s; - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) - s += (detectors[i]->*somefunc)(pos) + "+"; - } - return s; - } -} -template -T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)()) -{ - //(Erik) to handle enums, probably a bad idea but follow previous code - T defaultValue = static_cast(-1); - std::vector values(thisMultiDetector->numberOfDetectors, defaultValue); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) - if (detectors[idet]) { - values[idet] = (detectors[idet]->*somefunc)(); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - return minusOneIfDifferent(values); -} -template -T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)(V), V value) -{ - //(Erik) to handle enums, probably a bad idea but follow previous code - T defaultValue = static_cast(-1); - std::vector values(thisMultiDetector->numberOfDetectors, defaultValue); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) - if (detectors[idet]) { - values[idet] = (detectors[idet]->*somefunc)(value); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - return minusOneIfDifferent(values); -} -template -T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2) -{ - //(Erik) to handle enums, probably a bad idea but follow previous code - T defaultValue = static_cast(-1); - std::vector values(thisMultiDetector->numberOfDetectors, defaultValue); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) - if (detectors[idet]) { - values[idet] = (detectors[idet]->*somefunc)(par1, par2); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - return minusOneIfDifferent(values); -} -std::string multiSlsDetector::callDetectorMember(string (slsDetector::*somefunc)()) -{ - string concatenatedValue, firstValue; - bool valueNotSame = false; - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - string thisValue = (detectors[idet]->*somefunc)(); - ; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - if (firstValue.empty()) { - concatenatedValue = thisValue; - firstValue = thisValue; - } else { - concatenatedValue += "+" + thisValue; - } - if (firstValue != thisValue) - valueNotSame = true; - } - } - if (valueNotSame) - return concatenatedValue; - else - return firstValue; -} -template -T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)()) -{ - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } else { - std::vector return_values(thisMultiDetector->numberOfDetectors, -1); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - Task* task = new Task(new func0_t(somefunc, - detectors[idet], &return_values[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - return minusOneIfDifferent(return_values); - } -} -template -T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1), P1 value) -{ - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } else { - std::vector return_values(thisMultiDetector->numberOfDetectors, -1); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - Task* task = new Task(new func1_t(somefunc, - detectors[idet], value, &return_values[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - return minusOneIfDifferent(return_values); - } -} -template -T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2) -{ - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } else { - std::vector return_values(thisMultiDetector->numberOfDetectors, -1); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - Task* task = new Task(new func2_t(somefunc, - detectors[idet], par1, par2, &return_values[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - return minusOneIfDifferent(return_values); - } -} -int multiSlsDetector::parallelCallDetectorMember(int (slsDetector::*somefunc)(int, int, int), int v0, int v1, int v2) -{ - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } else { - std::vector return_values(thisMultiDetector->numberOfDetectors, -1); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - Task* task = new Task(new func3_t(somefunc, - detectors[idet], v0, v1, v2, &return_values[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - return minusOneIfDifferent(return_values); - } -} + + + + + + /** returns the detector trimbit/settings directory */ -string multiSlsDetector::getSettingsDir() -{ - return callDetectorMember(&slsDetector::getSettingsDir); -} -/** sets the detector trimbit/settings directory \sa sharedSlsDetector */ -string multiSlsDetector::setSettingsDir(string s) -{ - - if (s.find('+') == string::npos) { - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - detectors[idet]->setSettingsDir(s); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } else { - size_t p1 = 0; - size_t p2 = s.find('+', p1); - int id = 0; - while (p2 != string::npos) { - - if (detectors[id]) { - detectors[id]->setSettingsDir(s.substr(p1, p2 - p1)); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - } - ++id; - s = s.substr(p2 + 1); - p2 = s.find('+'); - if (id >= thisMultiDetector->numberOfDetectors) - break; - } - } - return getSettingsDir(); -} int multiSlsDetector::setTrimEn(int ne, int* ene) { @@ -3691,46 +4145,6 @@ int multiSlsDetector::getTrimEn(int* ene) returns the location of the calibration files \sa sharedSlsDetector */ -string multiSlsDetector::getCalDir() -{ - return callDetectorMember(&slsDetector::getCalDir); -} - -/** - sets the location of the calibration files - \sa sharedSlsDetector -*/ -string multiSlsDetector::setCalDir(string s) -{ - - if (s.find('+') == string::npos) { - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - detectors[idet]->setCalDir(s); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } else { - size_t p1 = 0; - size_t p2 = s.find('+', p1); - int id = 0; - while (p2 != string::npos) { - - if (detectors[id]) { - detectors[id]->setCalDir(s.substr(p1, p2 - p1)); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - } - ++id; - s = s.substr(p2 + 1); - p2 = s.find('+'); - if (id >= thisMultiDetector->numberOfDetectors) - break; - } - } - return getCalDir(); -} /** returns the location of the calibration files @@ -3823,20 +4237,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s) return getNetworkParameter(p); } -int multiSlsDetector::setPort(portType t, int p) -{ - return callDetectorMember(&slsDetector::setPort, t, p); -} -int multiSlsDetector::lockServer(int p) -{ - return callDetectorMember(&slsDetector::lockServer, p); -} - -string multiSlsDetector::getLastClientIP() -{ - return callDetectorMember(&slsDetector::getLastClientIP); -} int multiSlsDetector::setReadOutFlags(readOutFlags flag) { @@ -3903,15 +4304,9 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(ext return ret; } -string multiSlsDetector::getSettingsFile() -{ - return callDetectorMember(&slsDetector::getSettingsFile); -} -int multiSlsDetector::configureMAC() -{ - return callDetectorMember(&slsDetector::configureMAC); -} + + int multiSlsDetector::loadImageToDetector(imageType index, string const fname) { @@ -4232,79 +4627,6 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival) return ret1; } -int multiSlsDetector::loadSettingsFile(string fname, int imod) -{ - int ret = OK; - - // single - { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (detectors[id]) { - ret = detectors[id]->loadSettingsFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; - } - return -1; - } - } - - // multi - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } - - int* iret[thisMultiDetector->numberOfDetectors]; - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - iret[idet] = new int(OK); - Task* task = new Task(new func2_t(&slsDetector::loadSettingsFile, - detectors[idet], fname, imod, iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else - ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - - return ret; -} - -int multiSlsDetector::saveSettingsFile(string fname, int imod) -{ - int id = -1, im = -1, ret; - - if (decodeNMod(imod, id, im) >= 0) { - if (detectors[id]) { - ret = detectors[id]->saveSettingsFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; - } - return -1; - } - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - ret = detectors[idet]->saveSettingsFile(fname, imod); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - return ret; -} int multiSlsDetector::setAllTrimbits(int val, int imod) { @@ -4358,80 +4680,6 @@ int multiSlsDetector::setAllTrimbits(int val, int imod) return ret; } -int multiSlsDetector::loadCalibrationFile(string fname, int imod) -{ - int ret = OK; - - // single - { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (detectors[id]) { - ret = detectors[id]->loadCalibrationFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; - } - return -1; - } - } - - // multi - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } - - int* iret[thisMultiDetector->numberOfDetectors]; - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - iret[idet] = new int(OK); - Task* task = new Task(new func2_t(&slsDetector::loadCalibrationFile, - detectors[idet], fname, imod, iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else - ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - - return ret; -} - -int multiSlsDetector::saveCalibrationFile(string fname, int imod) -{ - int id = -1, im = -1, ret; - - if (decodeNMod(imod, id, im) >= 0) { - if (detectors[id]) { - ret = detectors[id]->saveCalibrationFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; - } - return -1; - } - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - ret = detectors[idet]->saveCalibrationFile(fname, imod); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - return ret; -} - uint32_t multiSlsDetector::writeRegister(uint32_t addr, uint32_t val) { @@ -4571,175 +4819,6 @@ int multiSlsDetector::printReceiverConfiguration() -int multiSlsDetector::writeDataFile(string fname, double* data, double* err, double* ang, char dataformat, int nch) -{ - -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to write formatted data file " << getTotalNumberOfChannels() << endl; -#endif - - ofstream outfile; - int choff = 0, off = 0; //idata, - double *pe = err, *pa = ang; - int nch_left = nch, n; //, nd; - - if (nch_left <= 0) - nch_left = getTotalNumberOfChannels(); - - if (data == NULL) - return FAIL; - - outfile.open(fname.c_str(), ios_base::out); - if (outfile.is_open()) { - - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - - if (detectors[i]) { - n = detectors[i]->getTotalNumberOfChannels(); - if (nch_left < n) - n = nch_left; - -#ifdef VERBOSE - cout << " write " << i << " position " << off << " offset " << choff << endl; -#endif - //detectors[i]->writeDataFile(outfile,n, data+off, pe, pa, dataformat, choff); - fileIOStatic::writeDataFile(outfile, n, data + off, pe, pa, dataformat, choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - - nch_left -= n; - - choff += detectors[i]->getMaxNumberOfChannels(); - - off += n; - - if (pe) - pe = err + off; - - if (pa) - pa = ang + off; - } - } - outfile.close(); - return OK; - } else { - std::cout << "Could not open file " << fname << "for writing" << std::endl; - return FAIL; - } -} - -int multiSlsDetector::writeDataFile(string fname, int* data) -{ - ofstream outfile; - int choff = 0, off = 0; - -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to write raw data file " << endl; -#endif - - if (data == NULL) - return FAIL; - - outfile.open(fname.c_str(), ios_base::out); - if (outfile.is_open()) { - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) { -#ifdef VERBOSE - cout << " write " << i << " position " << off << " offset " << choff << endl; -#endif - detectors[i]->writeDataFile(outfile, detectors[i]->getTotalNumberOfChannels(), data + off, choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - choff += detectors[i]->getMaxNumberOfChannels(); - off += detectors[i]->getTotalNumberOfChannels(); - } - } - - outfile.close(); - return OK; - } else { - std::cout << "Could not open file " << fname << "for writing" << std::endl; - return FAIL; - } -} - -int multiSlsDetector::readDataFile(string fname, double* data, double* err, double* ang, char dataformat) -{ - -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to read formatted data file " << endl; -#endif - - ifstream infile; - int iline = 0; //ichan, - //int interrupt=0; - string str; - int choff = 0, off = 0; - double *pe = err, *pa = ang; - -#ifdef VERBOSE - std::cout << "Opening file " << fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) { - iline += detectors[i]->readDataFile(detectors[i]->getTotalNumberOfChannels(), infile, data + off, pe, pa, dataformat, choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - choff += detectors[i]->getMaxNumberOfChannels(); - off += detectors[i]->getTotalNumberOfChannels(); - if (pe) - pe = pe + off; - if (pa) - pa = pa + off; - } - } - - infile.close(); - } else { - std::cout << "Could not read file " << fname << std::endl; - return -1; - } - return iline; -} - -int multiSlsDetector::readDataFile(string fname, int* data) -{ - -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to read raw data file " << endl; -#endif - - ifstream infile; - int iline = 0; //ichan, - //int interrupt=0; - string str; - int choff = 0, off = 0; - -#ifdef VERBOSE - std::cout << "Opening file " << fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - - for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) { - if (detectors[i]) { - iline += detectors[i]->readDataFile(infile, data + off, detectors[i]->getTotalNumberOfChannels(), choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - choff += detectors[i]->getMaxNumberOfChannels(); - off += detectors[i]->getTotalNumberOfChannels(); - } - } - infile.close(); - } else { - std::cout << "Could not read file " << fname << std::endl; - return -1; - } - return iline; -} //receiver @@ -5548,66 +5627,6 @@ int multiSlsDetector::overwriteFile(int enable) return callDetectorMember(&slsDetector::overwriteFile, enable); } -string multiSlsDetector::getErrorMessage(int& critical) -{ - - int64_t multiMask, slsMask = 0; - string retval = ""; - char sNumber[100]; - critical = 0; - - multiMask = getErrorMask(); - if (multiMask) { - if (multiMask & MULTI_DETECTORS_NOT_ADDED) { - retval.append("Detectors not added:\n" + string(getNotAddedList()) + string("\n")); - critical = 1; - } - if (multiMask & MULTI_HAVE_DIFFERENT_VALUES) { - retval.append("A previous multi detector command gave different values\n" - "Please check the console\n"); - critical = 0; - } - if (multiMask & MULTI_CONFIG_FILE_ERROR) { - retval.append("Could not load Config File\n"); - critical = 0; - } - - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { - if (detectors[idet]) { - //if the detector has error - if (multiMask & (1 << idet)) { - //append detector id - sprintf(sNumber, "%d", idet); - retval.append("Detector " + string(sNumber) + string(":\n")); - //get sls det error mask - slsMask = detectors[idet]->getErrorMask(); -#ifdef VERYVERBOSE - //append sls det error mask - sprintf(sNumber, "0x%lx", slsMask); - retval.append("Error Mask " + string(sNumber) + string("\n")); -#endif - //get the error critical level - if ((slsMask > 0xFFFFFFFF) | critical) - critical = 1; - //append error message - retval.append(errorDefs::getErrorMessage(slsMask)); - } - } - } - } - return retval; -} - -int64_t multiSlsDetector::clearAllErrorMask() -{ - clearErrorMask(); - clearNotAddedList(); - for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) - if (detectors[idet]) - detectors[idet]->clearErrorMask(); - - return getErrorMask(); -} int multiSlsDetector::calibratePedestal(int frames) { @@ -5765,27 +5784,5 @@ int multiSlsDetector::pulseChip(int n) return parallelCallDetectorMember(&slsDetector::pulseChip, n); } -void multiSlsDetector::setAcquiringFlag(bool b) -{ - thisMultiDetector->acquiringFlag = b; -} -bool multiSlsDetector::getAcquiringFlag() -{ - return thisMultiDetector->acquiringFlag; -} -bool multiSlsDetector::isAcquireReady() -{ - if (thisMultiDetector->acquiringFlag) { - std::cout << "Acquire has already started. If previous acquisition terminated unexpectedly, reset busy flag to restart.(sls_detector_put busy 0)" << std::endl; - return FAIL; - } - thisMultiDetector->acquiringFlag = true; - return OK; -} - -int multiSlsDetector::checkVersionCompatibility(portType t) -{ - return parallelCallDetectorMember(&slsDetector::checkVersionCompatibility, t); -} diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 5653ee040..55884b6c8 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -65,10 +65,12 @@ class multiSlsDetector : public slsDetectorUtils { /** Number of detectors operated at once */ int numberOfDetector[2]; - /** online flag - is set if the detector is connected, unset if socket connection is not possible */ + /** online flag - is set if the detector is connected, unset if socket + * connection is not possible */ int onlineFlag; - /** stopped flag - is set if an acquisition error occurs or the detector is stopped manually. Is reset to 0 at the start of the acquisition */ + /** stopped flag - is set if an acquisition error occurs or the detector + * is stopped manually. Is reset to 0 at the start of the acquisition */ int stoppedFlag; /** position of the master detector */ @@ -104,10 +106,12 @@ class multiSlsDetector : public slsDetectorUtils { /** max number of channels for all detectors in one dimension*/ int maxNumberOfChannel[2]; - /** max number of channels including gap pixels for all detectors in one dimension*/ + /** max number of channels including gap pixels for all detectors in + * one dimension*/ int maxNumberOfChannelInclGapPixels[2]; - /** max number of channels allowed for the complete set of detectors in one dimension */ + /** max number of channels allowed for the complete set of detectors in + * one dimension */ int maxNumberOfChannelsPerDetector[2]; /** timer values */ @@ -119,7 +123,9 @@ class multiSlsDetector : public slsDetectorUtils { /** detector threshold (eV) */ int currentThresholdEV; - /** indicator for the acquisition progress - set to 0 at the beginning of the acquisition and incremented every time that the data are written to file */ + /** indicator for the acquisition progress - set to 0 at the beginning + * of the acquisition and incremented every time that the data are written + * to file */ int progressIndex; /** total number of frames to be acquired */ @@ -143,7 +149,8 @@ class multiSlsDetector : public slsDetectorUtils { /** corrections to be applied to the data \see ::correctionFlags */ int correctionMask; - /** threaded processing flag (i.e. if data are processed and written to file in a separate thread) */ + /** threaded processing flag (i.e. if data are processed and written to + * file in a separate thread) */ int threadedProcessing; /** dead time (in ns) for rate corrections */ @@ -161,13 +168,16 @@ class multiSlsDetector : public slsDetectorUtils { /** angular conversion file */ char angConvFile[MAX_STR_LENGTH]; - /** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ + /** angular direction (1 if it corresponds to the encoder direction + * i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ int angDirection; - /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ + /** beamline fine offset (of the order of mdeg, might be adjusted for + * each measurements) */ double fineOffset; - /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ + /** beamline offset (might be a few degrees beacuse of encoder offset - + * normally it is kept fixed for a long period of time) */ double globalOffset; /** bin size for data merging */ @@ -200,7 +210,8 @@ class multiSlsDetector : public slsDetectorUtils { /** external gui */ bool externalgui; - /** receiver online flag - is set if the receiver is connected, unset if socket connection is not possible */ + /** receiver online flag - is set if the receiver is connected, + * unset if socket connection is not possible */ int receiverOnlineFlag; /** data streaming (up stream) enable in receiver */ @@ -222,7 +233,8 @@ public: using slsDetectorUtils::writeAngularConversion; /* - @short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!) + @short Structure allocated in shared memory to store detector settings and + be accessed in parallel by several applications */ @@ -241,10 +253,238 @@ public: virtual ~multiSlsDetector(); /** - * returns true. Used when reference is slsDetectorUtils and to determine if command can be implemented as slsDetector/multiSlsDetector object/ + * returns true. Used when reference is slsDetectorUtils and to determine + * if command can be implemented as slsDetector/multiSlsDetector object/ */ bool isMultiSlsDetectorClass(); + /** + * If specific position, then provide result with that detector at position pos + * else concatenate the result of all detectors + * @param somefunc function pointer + * @param pos positin of detector in array (-1 is for all) + * @returns result for detector at that position or concatenated string of all detectors + */ + std::string concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos); + + /** + * Loop serially through all the detectors in calling a particular method + * @param somefunc function pointer + * @returns -1 if values are different, otherwise result in calling method + */ + template + T callDetectorMember(T (slsDetector::*somefunc)()); + + /** + * Loop serially through all the detectors in calling a particular method + * with string as return + * @param somefunc function pointer + * @returns concatenated string of results ifdifferent, otherwise result in + * calling method + */ + std::string callDetectorMember(std::string(slsDetector::*somefunc)()); + + /** + * Loop serially through all the detectors in calling a particular method + * with an extra argument + * @param somefunc function pointer + * @param value argument for calling method + * @returns -1 if values are different, otherwise result in calling method + */ + template + T callDetectorMember(T (slsDetector::*somefunc)(V), V value); + + /** + * Loop serially through all the detectors in calling a particular method + * with two extra arguments + * @param somefunc function pointer + * @param par1 argument for calling method + * @param par2 second argument for calling method + * @returns -1 if values are different, otherwise result in calling method + */ + template + T callDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2); + + + /** + * Parallel calls to all the detectors in calling a particular method + * @param somefunc function pointer + * @returns -1 if values are different, otherwise result in calling method + */ + template + T parallelCallDetectorMember(T (slsDetector::*somefunc)()); + + /** + * Loop serially through all the detectors in calling a particular method + * with an extra argument + * @param somefunc function pointer + * @param value argument for calling method + * @returns -1 if values are different, otherwise result in calling method + */ + template + T parallelCallDetectorMember(T (slsDetector::*somefunc)(P1), P1 value); + + /** + * Loop serially through all the detectors in calling a particular method + * with two extra arguments + * @param somefunc function pointer + * @param par1 argument for calling method + * @param par2 second argument for calling method + * @returns -1 if values are different, otherwise result in calling method + */ + template + T parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2); + + /** + * Loop serially through all the detectors in calling a particular method + * with three int arguments + * @param somefunc function pointer + * @param v0 argument for calling method + * @param v1 second argument for calling method + * @param v2 third argument for calling method + * @returns -1 if values are different, otherwise result in calling method + */ + int parallelCallDetectorMember(int (slsDetector::*somefunc)(int, int, int), + int v0, int v1, int v2); + + /** + * Loop serially through all results and + * return a value if they are all same, else return -1 + * @param return_values vector of results + * @returns -1 if values are different, otherwise result + */ + template + T minusOneIfDifferent(const std::vector&); + + /** + * Calculate the detector position index in multi vector and the module index + * using an index for all entire modules in list (Mythen) + * @param i position index of all modules in list + * @param idet position index in multi vector list + * @param imod module index in the sls detector + */ + int decodeNMod(int i, int &idet, int &imod); + + /** + * Decodes which detector and the corresponding channel numbers for it + * Mainly useful in a multi detector setROI (Gotthard, Mythen?) + * @param offsetX channel number or total channel offset in x direction + * @param offsetY channel number or total channel offset in y direction + * @param channelX channel number from detector offset in x direction + * @param channelY channel number from detector offset in x direction + * @returns detector id or -1 if channel number out of range + */ + int decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY); + + /** + * Decode data from the detector converting them to an array of doubles, + * one for each channel (Mythen only) + * @param datain data from the detector + * @param nn size of datain array + * @param fdata double array of decoded data + * @returns pointer to a double array with a data per channel + */ + double* decodeData(int *datain, int &nn, double *fdata=NULL); + + /** + * Writes a data file + * @param name of the file to be written + * @param data array of data values + * @param err array of errors on the data. If NULL no errors will be written + * @param ang array of angular values. If NULL data will be in the form + * chan-val(-err) otherwise ang-val(-err) + * @param dataformat format of the data: can be 'i' integer or 'f' double (default) + * @param nch number of channels to be written to file. if -1 defaults to + * the number of installed channels of the detector + * @returns OK or FAIL if it could not write the file or data=NULL + * \sa mythenDetector::writeDataFile + */ + int writeDataFile(std::string fname, double *data, double *err=NULL, + double *ang=NULL, char dataformat='f', int nch=-1); + + /** + * Writes a data file with an integer pointer to an array + * @param name of the file to be written + * @param data array of data values + * @returns OK or FAIL if it could not write the file or data=NULL + * \sa mythenDetector::writeDataFile + */ + int writeDataFile(std::string fname, int *data); + + /** + * Reads a data file + * @param name of the file to be read + * @param data array of data values to be filled + * @param err array of arrors on the data. If NULL no errors are expected + * on the file + * @param ang array of angular values. If NULL data are expected in the + * form chan-val(-err) otherwise ang-val(-err) + * @param dataformat format of the data: can be 'i' integer or 'f' double (default) + * @param nch number of channels to be written to file. if <=0 defaults + * to the number of installed channels of the detector + * @returns OK or FAIL if it could not read the file or data=NULL + *\sa mythenDetector::readDataFile + */ + int readDataFile(std::string fname, double *data, double *err=NULL, + double *ang=NULL, char dataformat='f'); + + + /** + * Reads a data file + * @param name of the file to be read + * @param data array of data values + * @returns OK or FAIL if it could not read the file or data=NULL + * \sa mythenDetector::readDataFile + */ + int readDataFile(std::string fname, int *data); + + /** + * Checks error mask and returns error message and its severity if it exists + * @param critical is 1 if any of the messages is critical + * @returns error message else an empty std::string + */ + std::string getErrorMessage(int &critical); + + /** + * Clears error mask of both multi and sls + * @returns error mask + */ + int64_t clearAllErrorMask(); + + /** + Set acquiring flag in shared memory + \param b acquiring flag + */ + void setAcquiringFlag(bool b=false); + + /** + Get acquiring flag from shared memory + \returns acquiring flag + */ + bool getAcquiringFlag(); + + /** + * Check if acquiring flag is set, set error if set + * \returns FAIL if not ready, OK if ready + */ + bool isAcquireReady(); + + /** + * Check version compatibility with detector/receiver software + * (if hostname/rx_hostname has been set/ sockets created) + * @param p port type control port or receiver port + * @returns FAIL for incompatibility, OK for compatibility + */ + int checkVersionCompatibility(portType t); + + /** + * Get ID or version numbers + * @param mode version type + * @param imod module number in entire module list (gets decoded) (-1 for all) + * @returns Id or version number of that type + */ + int64_t getId(idMode mode, int imod=0); + /** * Get sls detector object from position in detectors array * @param pos position in detectors array @@ -252,6 +492,13 @@ public: */ slsDetector* getSlsDetector(unsigned int pos); + /** + * Accessing the sls detector from the multi list using position + * @param pos position in the multi list + * @returns slsDetector object + */ + slsDetector *operator(); + /** * Free shared memory from the command line * avoiding creating the constructor classes and mapping @@ -467,16 +714,6 @@ public: */ void updateOffsets(); - /** - * Calculate the detector position index in multi vector and the module index - * using an index for all entire modules in list (Mythen) - * @param i position index of all modules in list - * @param idet position index in multi vector list - * @param imod module index in the sls detector - */ - int decodeNMod(int i, int &idet, int &imod); - - /** * Checks if the multi detectors are online and sets the online flag * @param online if GET_ONLINE_FLAG, only returns shared memory online flag, @@ -495,11 +732,31 @@ public: std::string checkOnline(); /** - * Activates the detector (Eiger only) - * @param enable active (1) or inactive (0), -1 gets - * @returns 0 (inactive) or 1 (active) + * Set TCP Port of detector or receiver + * @param t port type + * @param p port number + * @returns port number */ - int activate(int const enable=GET_ONLINE_FLAG); + int setPort(portType t, int p); + + /** + * Lock server for this client IP + * @param p 0 to unlock, 1 to lock + * @returns 1 for locked or 0 for unlocked + */ + int lockServer(int p); + + /** + * Get last client IP saved on detector server + * @returns last client IP saved on detector server + */ + std::string getLastClientIP(); + + /** + * Exit detector server + * @returns OK or FAIL + */ + int exitServer(); /** * Load configuration from a configuration File @@ -515,6 +772,93 @@ public: */ int writeConfigurationFile(std::string const fname); + /** + * Returns the trimfile or settings file name (Useless??) + * @returns the trimfile or settings file name + */ + std::string getSettingsFile(); + + /** + * Get detector settings + * @param ipos position in multi list (-1 all) + * @returns current settings + */ + detectorSettings getSettings(int pos=-1); + + /** + * Load detector settings from the settings file picked from the trimdir/settingsdir + * @param isettings settings + * @param ipos position in multi list (-1 all) + * @returns current settings + */ + detectorSettings setSettings(detectorSettings isettings, int pos=-1); + + /** + * Returns the detector trimbit/settings directory \sa sharedSlsDetector + * @returns the trimbit/settings directory + */ + std::string getSettingsDir(); + + /** + * Sets the detector trimbit/settings directory \sa sharedSlsDetector + * @param s trimbits/settings directory + * @returns the trimbit/settings directory + */ + std::string setSettingsDir(std::string s); + + /** + * Returns the calibration files directory \sa sharedSlsDetector (Mythen) + * @returns the calibration files directory + */ + std::string getCalDir(); + + /** + * Sets the calibration files directory \sa sharedSlsDetector (Mythen) + * @param s the calibration files directory + * @returns the calibration files directory + */ + std::string setCalDir(std::string s); + + /** + * Loads the modules settings/trimbits reading from a specific file + * file name extension is automatically generated. + * @param fname specific settings/trimbits file + * @param imod module index of the entire list, + * from which will be calculated the detector index and the module index (-1 for all) + * returns OK or FAIL + */ + int loadSettingsFile(std::string fname, int imod=-1); + + /** + * Saves the modules settings/trimbits to a specific file + * file name extension is automatically generated. + * @param fname specific settings/trimbits file + * @param imod module index of the entire list, + * from which will be calculated the detector index and the module index (-1 for all) + * returns OK or FAIL + */ + int saveSettingsFile(std::string fname, int imod=-1); + + /** + * Loads the modules calibration data reading from a specific file (Mythen) + * file name extension is automatically generated. + * @param fname specific calibration file + * @param imod module index of the entire list, + * from which will be calculated the detector index and the module index (-1 for all) + * returns OK or FAIL + */ + int loadCalibrationFile(std::string fname, int imod=-1); + + /** + * Saves the modules calibration data to a specific file (Mythen) + * file name extension is automatically generated. + * @param fname specific calibration file + * @param imod module index of the entire list, + * from which will be calculated the detector index and the module index (-1 for all) + * returns OK or FAIL + */ + int saveCalibrationFile(std::string fname, int imod=-1); + /** * (Not implemented in any detector from the client) * Sets/gets the detector in position i as master of the structure @@ -532,277 +876,138 @@ public: */ synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE); - - - - - - - - - - - - - - angleConversionConstant *getAngularConversionPointer(int imod=0); - - - - - /** returns the enable if data will be flipped across x or y axis - * \param d axis across which data is flipped - * returns 1 or 0 + /** + * Get Detector run status + * @returns status */ - int getFlippedData(dimension d=X); - - - double getScanStep(int index, int istep){return thisMultiDetector->scanSteps[index][istep];}; - - - + runStatus getRunStatus(); /** - Prints receiver configuration - \returns OK or FAIL - */ - int printReceiverConfiguration(); - - - - /* I/O */ - - - - /* Communication to server */ - - // Expert Initialization functions - - /** - get threshold energy - \param imod module number (-1 all) - \returns current threshold value for imod in ev (-1 failed) - */ - int getThresholdEnergy(int imod=-1); - - /** - set threshold energy - \param e_eV threshold in eV - \param imod module number (-1 all) - \param isettings ev. change settings - \param tb 1 to include trimbits, 0 to exclude - \returns current threshold value for imod in ev (-1 failed) - */ - int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS,int tb=1); - - /** - get detector settings - \param imod module number (-1 all) - \returns current settings - */ - detectorSettings getSettings(int imod=-1); - - /** - set detector settings - \param isettings settings - \param imod module number (-1 all) - \returns current settings - - in this function trimbits and calibration files are searched in the trimDir and calDir directories and the detector is initialized - */ - detectorSettings setSettings(detectorSettings isettings, int imod=-1); - - - /** - Returns the trimbits from the detector's shared memmory - \param retval is the array with the trimbits - \param fromDetector is true if the trimbits shared memory have to be uploaded from detector - \returns the total number of channels for the detector - */ - int getChanRegs(double* retval,bool fromDetector); - - - - - int64_t getId(idMode mode, int imod=0); - int digitalTest(digitalTestMode mode, int imod=0); - int executeTrimming(trimMode mode, int par1, int par2, int imod=-1); - std::string getSettingsFile(); - - - - /** programs FPGA with pof file - \param fname file name - \returns OK or FAIL - */ - int programFPGA(std::string fname); - - /** resets FPGA - \returns OK or FAIL - */ - int resetFPGA(); - - /** power on/off the chip - \param ival on is 1, off is 0, -1 to get - \returns OK or FAIL - */ - int powerChip(int ival= -1); - - /** automatic comparator disable for Jungfrau only - \param ival on is 1, off is 0, -1 to get - \returns OK or FAIL - */ - int setAutoComparatorDisableMode(int ival= -1); - - /** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */ - int loadSettingsFile(std::string fname, int nmod=-1); - - /** gets the modules settings/trimbits and writes them to file - file name extension is automatically generated! */ - int saveSettingsFile(std::string fname, int nmod=-1); - - - /** sets all the trimbits to a particular value - \param val trimbit value - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - int setAllTrimbits(int val, int imod=-1); - - - /** loads the modules calibration data reading from a file - file name extension is automatically generated! */ - int loadCalibrationFile(std::string fname, int nmod=-1); - - /** gets the modules calibration data and writes them to file - file name extension is automatically generated! */ - int saveCalibrationFile(std::string fname, int nmod=-1); - - - - - - - - - - - - - - - - - - - - // Acquisition functions - /** - prepares detector for acquisition - \returns OK if all detectors are properly started, FAIL otherwise + * Prepares detector for acquisition (Eiger and Gotthard) + * For Gotthard, it sets the detector data transmission mode (CPU or receiver) + * @returns OK if all detectors are ready for acquisition, FAIL otherwise */ int prepareAcquisition(); /** - prepares detector for acquisition - \returns OK if all detectors are properly started, FAIL otherwise + * Cleans up after acquisition (Gotthard only) + * For Gotthard, it sets the detector data transmission to default (via CPU) + * @returns OK or FAIL */ int cleanupAcquisition(); /** - start detector acquisition (master is started as last) - \returns OK if all detectors are properly started, FAIL otherwise + * Start detector acquisition (Non blocking) + * @returns OK or FAIL if even one does not start properly */ int startAcquisition(); /** - stop detector acquisition (master firtst) - \returns OK/FAIL + * Stop detector acquisition + * @returns OK or FAIL */ int stopAcquisition(); /** - start readout (without exposure or interrupting exposure) (master first) - \returns OK/FAIL + * Start readout (without exposure or interrupting exposure) (Mythen) + * @returns OK or FAIL */ int startReadOut(); - - /** - start detector acquisition and read all data putting them a data queue - \returns pointer to the front of the data queue - \sa startAndReadAllNoWait getDataFromDetector dataQueue + * Start detector acquisition and read all data (Blocking until end of acquisition) + * (Mythen, puts all data into a data queue. Others, data at receiver via udp packets) + * @returns pointer to the front of the data queue (return significant only for Mythen) + * \sa startAndReadAllNoWait getDataFromDetector dataQueue */ int* startAndReadAll(); /** - start detector acquisition and read out, but does not read data from socket - + * Start detector acquisition and call read out, but not reading (data for Mythen, + * and status for other detectors) from the socket. + * (startAndReadAll calls this and getDataFromDetector. Client is not blocking, + * but server is blocked until getDataFromDetector is called. so not recommended + * for users) + * @returns OK or FAIL */ int startAndReadAllNoWait(); /** - receives a data frame from the detector socket - \returns pointer to the data or NULL. If NULL disconnects the socket - \sa getDataFromDetector - */ - //int* getDataFromDetectorNoWait(); - /** - receives a data frame from the detector socket - \returns pointer to the data or NULL. If NULL disconnects the socket - \sa getDataFromDetector + * Reads from the detector socket (data frame for Mythen and status for other + * detectors) + * @returns pointer to the data or NULL. If NULL disconnects the socket + * (return significant only for Mythen) + * Other detectors return NULL + * \sa getDataFromDetector */ int* getDataFromDetector(); /** - asks and receives a data frame from the detector and puts it in the data queue - \returns pointer to the data or NULL. - \sa getDataFromDetector + * Requests and receives a single data frame from the detector + * (Mythen: and puts it in the data queue) + * @returns pointer to the data or NULL. (return Mythen significant) + * Other detectors return NULL + * \sa getDataFromDetector */ int* readFrame(); /** - asks and receives all data from the detector and puts them in a data queue - \returns pointer to the front of the queue or NULL. - \sa getDataFromDetector dataQueue + * Requests and receives all data from the detector + * (Mythen: and puts them in a data queue) + * @returns pointer to the front of the queue or NULL (return Mythen significant) + * Other detectors return NULL + * \sa getDataFromDetector dataQueue */ int* readAll(); - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue + * Pops the data from the data queue (Mythen) + * @returns pointer to the popped data or NULL if the queue is empty. + * \sa dataQueue */ int* popDataQueue(); /** - pops the data from thepostprocessed data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa finalDataQueue + * Pops the data from the postprocessed data queue (Mythen) + * @returns pointer to the popped data or NULL if the queue is empty. + * \sa finalDataQueue */ detectorData* popFinalDataQueue(); - - - /** - resets the raw data queue - \sa dataQueue + * Resets the raw data queue (Mythen) + * \sa dataQueue */ void resetDataQueue(); /** - resets the postprocessed data queue - \sa finalDataQueue + * Resets the post processed data queue (Mythen) + * \sa finalDataQueue */ void resetFinalDataQueue(); + /** + * Configures in detector the destination for UDP packets + * @returns OK or FAIL + */ + int configureMAC(); + /** + * Get threshold energy + * @param imod module number (-1 all) + * @returns current threshold value for imod in ev (-1 failed) + */ + int getThresholdEnergy(int imod=-1); - - - - - int setSpeed(speedVariable sp, int value=-1); + /** + * Set threshold energy + * @param e_eV threshold in eV + * @param imod module number (-1 all) + * @param isettings ev. change settings + * @param tb 1 to include trimbits, 0 to exclude + * @returns current threshold value for imod in ev (-1 failed) + */ + int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS,int tb=1); /** @@ -820,23 +1025,10 @@ public: */ int64_t getTimeLeft(timerIndex index); - /** - * set storage cell that stores first acquisition of the series (Jungfrau only) - * \param value storage cell index. Value can be 0 to 15. (-1 gets) - * \returns the storage cell that stores the first acquisition of the series - */ - int setStoragecellStart(int pos=-1); - /* /\** */ - /* get current timer value */ - /* \param index timer index */ - /* \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) */ - /* *\/ */ - /* int64_t getTimeLeft(timerIndex index); */ + int setSpeed(speedVariable sp, int value=-1); - - // Flags /** set/get dynamic range and updates the number of dataBytes \param n dynamic range (-1 get) @@ -847,17 +1039,115 @@ public: */ int setDynamicRange(int n, int pos); + int setDynamicRange(int i=-1); + int getDataBytes(); + /** - decodes which detector and the corresponding channel numbers for it - \param offsetX channel number or total channel offset in x direction - \param offsetY channel number or total channel offset in y direction - \param channelX channel number from detector offset in x direction - \param channelY channel number from detector offset in x direction - \returns detector id or -1 if channel number out of range + set dacs value + \param val value (in V) + \param index DAC index + \param mV 0 in dac units or 1 in mV + \param imod module number (if -1 alla modules) + \returns current DAC value */ - int decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY); + dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1); + + /** + set dacs value + \param val value (in V) + \param index DAC index + \param imod module number (if -1 alla modules) + \returns current DAC value (temperature for eiger and jungfrau in millidegrees) + */ + dacs_t getADC(dacIndex index, int imod=-1); + + externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE); + + externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0); + + int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS); + + + + uint32_t writeRegister(uint32_t addr, uint32_t val); + + uint32_t readRegister(uint32_t addr); + + + /** + sets a bit in a register + \param addr address + \param n nth bit ranging from 0 to 31 + \returns current register value + + DO NOT USE!!! ONLY EXPERT USER!!! + */ + uint32_t setBit(uint32_t addr, int n); + + + /** + clear a bit in a register + \param addr address + \param n nth bit ranging from 0 to 31 + \returns current register value + + DO NOT USE!!! ONLY EXPERT USER!!! + */ + uint32_t clearBit(uint32_t addr, int n); + + /** + sets the network parameters + must restart streaming in client/receiver if to do with zmq after calling this function + \param i network parameter type + \param s value to be set + \returns parameter + + */ + std::string setNetworkParameter(networkParameter, std::string); + + std::string getNetworkParameter(networkParameter); + + + + + + int digitalTest(digitalTestMode mode, int imod=0); + int executeTrimming(trimMode mode, int par1, int par2, int imod=-1); + + /** + Loads dark image or gain image to the detector + \param index can be DARK_IMAGE or GAIN_IMAGE + \fname file name to load data from + \returns OK or FAIL + */ + int loadImageToDetector(imageType index,std::string const fname); + + + + /** + writes the counter memory block from the detector + \param startACQ is 1 to start acquisition after reading counter + \param fname file name to load data from + \returns OK or FAIL + */ + int writeCounterBlockFile(std::string const fname,int startACQ=0); + + + /** + Resets counter in detector + \param startACQ is 1 to start acquisition after resetting counter + \returns OK or FAIL + */ + int resetCounterBlock(int startACQ=0); + + /** set/get counter bit in detector + * @param i is -1 to get, 0 to reset and any other value to set the counter bit + /returns the counter bit in detector + */ + int setCounterBit(int i = -1); + /** verifies that min is less than max @@ -882,207 +1172,73 @@ public: ROI* getROI(int &n); - //Corrections + int writeAdcRegister(int addr, int val); + + /** + * Activates the detector (Eiger only) + * @param enable active (1) or inactive (0), -1 gets + * @returns 0 (inactive) or 1 (active) + */ + int activate(int const enable=GET_ONLINE_FLAG); + + /** returns the enable if data will be flipped across x or y axis + * \param d axis across which data is flipped + * returns 1 or 0 + */ + int getFlippedData(dimension d=X); + + /** sets the enable which determines if data will be flipped across x or y axis + * \param d axis across which data is flipped + * \param value 0 or 1 to reset/set or -1 to get value + * \return enable flipped data across x or y axis + */ + int setFlippedData(dimension d=X, int value=-1); + + + /** sets all the trimbits to a particular value + \param val trimbit value + \param imod module number, -1 means all modules + \returns OK or FAIL + */ + int setAllTrimbits(int val, int imod=-1); /** - set flat field corrections - \param fname name of the flat field file (or "" if disable) - \returns 0 if disable (or file could not be read), >0 otherwise + * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. 4 bit mode gap pixels only in gui call back + * @param val 1 sets, 0 unsets, -1 gets + * @return gap pixel enable or -1 for error */ - int setFlatFieldCorrection(std::string fname=""); + int enableGapPixels(int val=-1); + + int setTrimEn(int nen, int *en=NULL); + int getTrimEn(int *en=NULL); /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - int setFlatFieldCorrection(double *corr, double *ecorr=NULL); + Pulse Pixel + \param n is number of times to pulse + \param x is x coordinate + \param y is y coordinate + \returns OK or FAIL + */ + int pulsePixel(int n=0,int x=0,int y=0); - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL); + /** + Pulse Pixel and move by a relative value + \param n is number of times to pulse + \param x is relative x value + \param y is relative y value + \returns OK or FAIL + */ + int pulsePixelNMove(int n=0,int x=0,int y=0); + /** + Pulse Chip + \param n is number of times to pulse + \returns OK or FAIL + */ + int pulseChip(int n=0); - - - - - - /** - set rate correction - \param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings - \returns 0 if rate correction disabled, >0 otherwise - */ - int setRateCorrection(double t=0); - - - /** - get rate correction - \param t reference for dead time - \returns 0 if rate correction disabled, >0 otherwise - */ - int getRateCorrection(double &t); - - - /** - get rate correction tau - \returns 0 if rate correction disabled, otherwise the tau used for the correction - */ - double getRateCorrectionTau(); - /** - get rate correction - \returns 0 if rate correction disabled, >0 otherwise - */ - int getRateCorrection(); - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - int setBadChannelCorrection(std::string fname=""); - - - int setBadChannelCorrection(int nch, int *chs, int ff); - - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - int getBadChannelCorrection(int *bad=NULL); - - - - /** - pure virtual function - get angular conversion - \param reference to diffractometer direction - \param angconv array that will be filled with the angular conversion constants - \returns 0 if angular conversion disabled, >0 otherwise - \sa mythenDetector::getAngularConversion - */ - /////////////////////////////////////////////////// virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL); - - - - int readAngularConversionFile(std::string fname); - - int writeAngularConversion(std::string fname); - - // double* convertAngles(double pos); - - - - - /** - decode data from the detector converting them to an array of doubles, one for each channle - \param datain data from the detector - \returns pointer to a double array with a data per channel - */ - double* decodeData(int *datain, int &nn, double *fdata=NULL); - - - - - /** - flat field correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param ffcoefficient flat field correction coefficient - \param fferr erro on ffcoefficient - \returns 0 - */ - // int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); - - /** - flat field correct data - \param datain data array - \param errin error array on data (if NULL will default to sqrt(datain) - \param dataout array of corrected data - \param errout error on corrected data (if not NULL) - \returns 0 - */ - int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); - - - - /** - rate correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param tau dead time 9in ns) - \param t acquisition time (in ns) - \returns 0 - */ - // int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); - - /** - rate correct data - \param datain data array - \param errin error array on data (if NULL will default to sqrt(datain) - \param dataout array of corrected data - \param errout error on corrected data (if not NULL) - \returns 0 - */ - int rateCorrect(double* datain, double *errin, double* dataout, double *errout); - - /** - turns off server - */ - int exitServer(); - - /** pure /////////////////////////////////////////////////// virtual function - function for processing data - /param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue - \sa mythenDetector::processData - */ - /////////////////////////////////////////////////// virtual void* processData(int delflag=1); // thread function - - - /////////////////////////////////////////////////// virtual void acquire(int delflag=1); - - /** calcualtes the total number of steps of the acquisition. - called when number of frames, number of cycles, number of positions and scan steps change - */ - /////////////////////////////////////// int setTotalProgress(); ////////////// from slsDetectorUtils! - - /** returns the current progress in % */ - ////////////////////////////////double getCurrentProgress();////////////// from slsDetectorUtils! - - - /** - set dacs value - \param val value (in V) - \param index DAC index - \param mV 0 in dac units or 1 in mV - \param imod module number (if -1 alla modules) - \returns current DAC value - */ - dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1); - - /** - set dacs value - \param val value (in V) - \param index DAC index - \param imod module number (if -1 alla modules) - \returns current DAC value (temperature for eiger and jungfrau in millidegrees) - */ - dacs_t getADC(dacIndex index, int imod=-1); - /** set/gets threshold temperature (Jungfrau only) \param val value in millidegrees, -1 gets @@ -1107,6 +1263,53 @@ public: */ int setTemperatureEvent(int val=-1, int imod=-1); + /** + * set storage cell that stores first acquisition of the series (Jungfrau only) + * \param value storage cell index. Value can be 0 to 15. (-1 gets) + * \returns the storage cell that stores the first acquisition of the series + */ + int setStoragecellStart(int pos=-1); + + + /** programs FPGA with pof file + \param fname file name + \returns OK or FAIL + */ + int programFPGA(std::string fname); + + /** resets FPGA + \returns OK or FAIL + */ + int resetFPGA(); + + /** power on/off the chip + \param ival on is 1, off is 0, -1 to get + \returns OK or FAIL + */ + int powerChip(int ival= -1); + + /** automatic comparator disable for Jungfrau only + \param ival on is 1, off is 0, -1 to get + \returns OK or FAIL + */ + int setAutoComparatorDisableMode(int ival= -1); + + + + + double getScanStep(int index, int istep){return thisMultiDetector->scanSteps[index][istep];}; + + + /** + Returns the trimbits from the detector's shared memmory + \param retval is the array with the trimbits + \param fromDetector is true if the trimbits shared memory have to be uploaded from detector + \returns the total number of channels for the detector + */ + int getChanRegs(double* retval,bool fromDetector); + + + /** configure channel \param reg channel register @@ -1117,268 +1320,147 @@ public: \sa ::sls_detector_channel */ int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1); - /** - pure virtual function - get angular conversion - \param reference to diffractometer direction - \param angconv array that will be filled with the angular conversion constants - \returns 0 if angular conversion disabled, >0 otherwise - \sa mythenDetector::getAngularConversion - */ - int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ; - - - - /** - get run status - \returns status mask - */ - //virtual runStatus getRunStatus()=0; - runStatus getRunStatus(); void setErrorMaskFromAllDetectors(); - std::string concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos); - - template - bool allElemetsEqual(const std::vector&); - - template - T callDetectorMember(T (slsDetector::*somefunc)()); - - std::string callDetectorMember(std::string(slsDetector::*somefunc)()); - - template - T callDetectorMember(T (slsDetector::*somefunc)(V), V value); - - template - T callDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2); - - - //func0_t - template - T parallelCallDetectorMember(T (slsDetector::*somefunc)()); - - //func1_t - template - T parallelCallDetectorMember(T (slsDetector::*somefunc)(P1), P1 value); //Should probably be templated - - //func2_t - template - T parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2); - - - int parallelCallDetectorMember(int (slsDetector::*somefunc)(int, int, int), int v0, int v1, int v2); //Should probably be templated - - template - T minusOneIfDifferent(const std::vector&); - - /** returns the detector trimbit/settings directory \sa sharedSlsDetector */ - std::string getSettingsDir(); - /** sets the detector trimbit/settings directory \sa sharedSlsDetector */ - std::string setSettingsDir(std::string s); - /** - returns the location of the calibration files - \sa sharedSlsDetector - */ - std::string getCalDir(); - /** - sets the location of the calibration files - \sa sharedSlsDetector - */ - std::string setCalDir(std::string s); - - - std::string getNetworkParameter(networkParameter); - - /** - sets the network parameters - must restart streaming in client/receiver if to do with zmq after calling this function - \param i network parameter type - \param s value to be set - \returns parameter - - */ - std::string setNetworkParameter(networkParameter, std::string); - int setPort(portType, int); - int lockServer(int); - - std::string getLastClientIP(); - - /** - configures mac for gotthard readout - \returns OK or FAIL - */ - int configureMAC(); - - - /** sets the enable which determines if data will be flipped across x or y axis - * \param d axis across which data is flipped - * \param value 0 or 1 to reset/set or -1 to get value - * \return enable flipped data across x or y axis - */ - int setFlippedData(dimension d=X, int value=-1); - - /** - * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. 4 bit mode gap pixels only in gui call back - * @param val 1 sets, 0 unsets, -1 gets - * @return gap pixel enable or -1 for error - */ - int enableGapPixels(int val=-1); - - - int setDynamicRange(int i=-1); - - - - - - uint32_t writeRegister(uint32_t addr, uint32_t val); - - - int writeAdcRegister(int addr, int val); - - - uint32_t readRegister(uint32_t addr); - - /** - sets a bit in a register - \param addr address - \param n nth bit ranging from 0 to 31 - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - uint32_t setBit(uint32_t addr, int n); - - - /** - clear a bit in a register - \param addr address - \param n nth bit ranging from 0 to 31 - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - uint32_t clearBit(uint32_t addr, int n); - - - - int setTrimEn(int nen, int *en=NULL); - int getTrimEn(int *en=NULL); - - - externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0); - int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS); - - - externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE); - - /** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \fname file name to load data from - \returns OK or FAIL - */ - int loadImageToDetector(imageType index,std::string const fname); - - /** - sets the value of s angular conversion parameter - \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - \param v the value to be set - \returns the actual value - */ - - double setAngularConversionParameter(angleConversionParameter c, double v); - - /** - - writes a data file - \param name of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - \sa mythenDetector::writeDataFile - - */ - int writeDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); - - - /** - - writes a data file - \param name of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - \sa mythenDetector::writeDataFile - */ - int writeDataFile(std::string fname, int *data); - - /** - - reads a data file - \param name of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not read the file or data=NULL - - \sa mythenDetector::readDataFile - */ - int readDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - - - /** - - reads a data file - \param name of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - \sa mythenDetector::readDataFile - */ - int readDataFile(std::string fname, int *data); - - - /** - writes the counter memory block from the detector - \param startACQ is 1 to start acquisition after reading counter - \param fname file name to load data from - \returns OK or FAIL - */ - int writeCounterBlockFile(std::string const fname,int startACQ=0); - - - /** - Resets counter in detector - \param startACQ is 1 to start acquisition after resetting counter - \returns OK or FAIL - */ - int resetCounterBlock(int startACQ=0); - - /** set/get counter bit in detector - * @param i is -1 to get, 0 to reset and any other value to set the counter bit - /returns the counter bit in detector - */ - int setCounterBit(int i = -1); - - int getMoveFlag(int imod); - - //additional way of accessing - slsDetector *operator()(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;}; + int fillModuleMask(int *mM); - //receiver + /** Starts acquisition, calibrates pedestal and writes to fpga + /returns number of frames + */ + int calibratePedestal(int frames = 0); + + + + /** + set rate correction + \param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings + \returns 0 if rate correction disabled, >0 otherwise + */ + int setRateCorrection(double t=0); + + + /** + get rate correction + \param t reference for dead time + \returns 0 if rate correction disabled, >0 otherwise + */ + int getRateCorrection(double &t); + + + /** + get rate correction tau + \returns 0 if rate correction disabled, otherwise the tau used for the correction + */ + double getRateCorrectionTau(); + /** + get rate correction + \returns 0 if rate correction disabled, >0 otherwise + */ + int getRateCorrection(); + /** + set flat field corrections + \param fname name of the flat field file (or "" if disable) + \returns 0 if disable (or file could not be read), >0 otherwise + */ + int setFlatFieldCorrection(std::string fname=""); + + /** + set flat field corrections + \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) + \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) + \returns 0 if ff correction disabled, >0 otherwise + */ + int setFlatFieldCorrection(double *corr, double *ecorr=NULL); + + /** + get flat field corrections + \param corr if !=NULL will be filled with the correction coefficients + \param ecorr if !=NULL will be filled with the correction coefficients errors + \returns 0 if ff correction disabled, >0 otherwise + */ + int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL); + + + /** + set bad channels correction + \param fname file with bad channel list ("" disable) + \returns 0 if bad channel disabled, >0 otherwise + */ + int setBadChannelCorrection(std::string fname=""); + + int setBadChannelCorrection(int nch, int *chs, int ff); + + + /** + get bad channels correction + \param bad pointer to array that if bad!=NULL will be filled with the bad channel list + \returns 0 if bad channel disabled or no bad channels, >0 otherwise + */ + int getBadChannelCorrection(int *bad=NULL); + + + int readAngularConversionFile(std::string fname); + + int writeAngularConversion(std::string fname); + + /** + pure virtual function + get angular conversion + \param reference to diffractometer direction + \param angconv array that will be filled with the angular conversion constants + \returns 0 if angular conversion disabled, >0 otherwise + \sa mythenDetector::getAngularConversion + */ + int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ; + + + /** + sets the value of s angular conversion parameter + \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE + \param v the value to be set + \returns the actual value + */ + + double setAngularConversionParameter(angleConversionParameter c, double v); + + angleConversionConstant *getAngularConversionPointer(int imod=0); + + /** + flat field correct data + \param datain data array + \param errin error array on data (if NULL will default to sqrt(datain) + \param dataout array of corrected data + \param errout error on corrected data (if not NULL) + \returns 0 + */ + int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); + + /** + rate correct data + \param datain data array + \param errin error array on data (if NULL will default to sqrt(datain) + \param dataout array of corrected data + \param errout error on corrected data (if not NULL) + \returns 0 + */ + int rateCorrect(double* datain, double *errin, double* dataout, double *errout); + + + + + + /** + Prints receiver configuration + \returns OK or FAIL + */ + int printReceiverConfiguration(); + /** calls setReceiverTCPSocket if online and sets the flag @@ -1390,6 +1472,22 @@ public: */ std::string checkReceiverOnline(); + /** Locks/Unlocks the connection to the receiver + /param lock sets (1), usets (0), gets (-1) the lock + /returns lock status of the receiver + */ + int lockReceiver(int lock=-1); + + /** + Returns the IP of the last client connecting to the receiver + */ + std::string getReceiverLastClientIP(); + + /** + Turns off the receiver server! + */ + int exitReceiver(); + /** Sets up the file directory @@ -1502,21 +1600,7 @@ public: */ void readFrameFromReceiver(); - /** Locks/Unlocks the connection to the receiver - /param lock sets (1), usets (0), gets (-1) the lock - /returns lock status of the receiver - */ - int lockReceiver(int lock=-1); - /** - Returns the IP of the last client connecting to the receiver - */ - std::string getReceiverLastClientIP(); - - /** - Turns off the receiver server! - */ - int exitReceiver(); /** Sets/Gets receiver file write enable @@ -1532,24 +1616,6 @@ public: */ int overwriteFile(int enable=-1); - int fillModuleMask(int *mM); - - /**checks error mask and returns error message if it exists - * @param myDet is the multidetector object - * @param critical is 1 if any of the messages is critical - /returns error message else an empty std::string - */ - std::string getErrorMessage(int &critical); - - /** Clears error mask of both multi and sls - /returns error mask - */ - int64_t clearAllErrorMask(); - - /** Starts acquisition, calibrates pedestal and writes to fpga - /returns number of frames - */ - int calibratePedestal(int frames = 0); /** Sets the read receiver frequency if data required from receiver randomly readRxrFrequency=0, @@ -1610,6 +1676,12 @@ public: + + + + + + /******** CTB funcs */ /** opens pattern file and sends pattern to CTB @@ -1650,56 +1722,9 @@ public: */ int setCTBPatWaitTime(int level, uint64_t t=-1); - /** - Pulse Pixel - \param n is number of times to pulse - \param x is x coordinate - \param y is y coordinate - \returns OK or FAIL - */ - int pulsePixel(int n=0,int x=0,int y=0); - /** - Pulse Pixel and move by a relative value - \param n is number of times to pulse - \param x is relative x value - \param y is relative y value - \returns OK or FAIL - */ - int pulsePixelNMove(int n=0,int x=0,int y=0); - /** - Pulse Chip - \param n is number of times to pulse - \returns OK or FAIL - */ - int pulseChip(int n=0); - /** - Set acquiring flag in shared memory - \param b acquiring flag - */ - void setAcquiringFlag(bool b=false); - - /** - Get acquiring flag from shared memory - \returns acquiring flag - */ - bool getAcquiringFlag(); - - /** - * Check if acquiring flag is set, set error if set - * \returns FAIL if not ready, OK if ready - */ - bool isAcquireReady(); - - /** - * Check version compatibility with detector/receiver software - * (if hostname/rx_hostname has been set/ sockets created) - * \param p port type control port or receiver port - * \returns FAIL for incompatibility, OK for compatibility - */ - int checkVersionCompatibility(portType t); private: diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index a9e540f32..4d77bd56c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4580,27 +4580,6 @@ int slsDetector::startAndReadAllNoWait(){ return FAIL; }; -// int* slsDetector::getDataFromDetectorNoWait() { -// int *retval=getDataFromDetector(); -// if (thisDetector->onlineFlag==ONLINE_FLAG) { -// if (controlSocket) { -// if (retval==NULL){ -// disconnectControl(); - -// #ifdef VERBOSE -// std::cout<< "Run finished "<< std::endl; -// #endif -// } else { -// #ifdef VERBOSE -// std::cout<< "Frame received "<< std::endl; -// #endif -// } -// } -// } -// return retval; // check what we return! -// }; - - /*