mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
const std::string& for filenames etc.
This commit is contained in:
@ -49,6 +49,7 @@ template <typename RT, typename... CT>
|
|||||||
std::vector<RT> multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...),
|
std::vector<RT> multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...),
|
||||||
CT... Args) {
|
CT... Args) {
|
||||||
std::vector<RT> result;
|
std::vector<RT> result;
|
||||||
|
result.reserve(detectors.size());
|
||||||
for (auto &d : detectors)
|
for (auto &d : detectors)
|
||||||
result.push_back((d.get()->*somefunc)(Args...));
|
result.push_back((d.get()->*somefunc)(Args...));
|
||||||
return result;
|
return result;
|
||||||
@ -62,6 +63,7 @@ multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...), CT... Args) {
|
|||||||
futures.push_back(
|
futures.push_back(
|
||||||
std::async(std::launch::async, somefunc, d.get(), Args...));
|
std::async(std::launch::async, somefunc, d.get(), Args...));
|
||||||
std::vector<RT> result;
|
std::vector<RT> result;
|
||||||
|
result.reserve(detectors.size());
|
||||||
for (auto &i : futures)
|
for (auto &i : futures)
|
||||||
result.push_back(i.get());
|
result.push_back(i.get());
|
||||||
return result;
|
return result;
|
||||||
@ -454,12 +456,12 @@ void multiSlsDetector::addMultipleDetectors(const char *name) {
|
|||||||
updateOffsets();
|
updateOffsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiSlsDetector::addSlsDetector(std::string s) {
|
void multiSlsDetector::addSlsDetector(const std::string& hostname) {
|
||||||
FILE_LOG(logDEBUG1) << "Adding detector " << s;
|
FILE_LOG(logDEBUG1) << "Adding detector " << hostname;
|
||||||
|
|
||||||
for (auto &d : detectors) {
|
for (auto &d : detectors) {
|
||||||
if (d->getHostname() == s) {
|
if (d->getHostname() == hostname) {
|
||||||
FILE_LOG(logWARNING) << "Detector " << s
|
FILE_LOG(logWARNING) << "Detector " << hostname
|
||||||
<< "already part of the multiDetector!" << std::endl
|
<< "already part of the multiDetector!" << std::endl
|
||||||
<< "Remove it before adding it back in a new position!";
|
<< "Remove it before adding it back in a new position!";
|
||||||
return;
|
return;
|
||||||
@ -471,19 +473,19 @@ void multiSlsDetector::addSlsDetector(std::string s) {
|
|||||||
// slsdetector in initsharedmemory
|
// slsdetector in initsharedmemory
|
||||||
|
|
||||||
// get type by connecting
|
// get type by connecting
|
||||||
detectorType type = slsDetector::getDetectorType(s.c_str(), DEFAULT_PORTNO);
|
detectorType type = slsDetector::getDetectorType(hostname.c_str(), DEFAULT_PORTNO);
|
||||||
if (type == GENERIC) {
|
if (type == GENERIC) {
|
||||||
FILE_LOG(logERROR) << "Could not connect to Detector " << s
|
FILE_LOG(logERROR) << "Could not connect to Detector " << hostname
|
||||||
<< " to determine the type!";
|
<< " to determine the type!";
|
||||||
setErrorMask(getErrorMask() | MULTI_DETECTORS_NOT_ADDED);
|
setErrorMask(getErrorMask() | MULTI_DETECTORS_NOT_ADDED);
|
||||||
appendNotAddedList(s.c_str());
|
appendNotAddedList(hostname.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = (int)detectors.size();
|
int pos = (int)detectors.size();
|
||||||
detectors.push_back(sls::make_unique<slsDetector>(type, detId, pos, false));
|
detectors.push_back(sls::make_unique<slsDetector>(type, detId, pos, false));
|
||||||
thisMultiDetector->numberOfDetectors = detectors.size();
|
thisMultiDetector->numberOfDetectors = detectors.size();
|
||||||
detectors[pos]->setHostname(s.c_str()); // also updates client
|
detectors[pos]->setHostname(hostname.c_str()); // also updates client
|
||||||
thisMultiDetector->dataBytes += detectors[pos]->getDataBytes();
|
thisMultiDetector->dataBytes += detectors[pos]->getDataBytes();
|
||||||
thisMultiDetector->dataBytesInclGapPixels +=
|
thisMultiDetector->dataBytesInclGapPixels +=
|
||||||
detectors[pos]->getDataBytesInclGapPixels();
|
detectors[pos]->getDataBytesInclGapPixels();
|
||||||
@ -787,7 +789,7 @@ int multiSlsDetector::exitServer(int detPos) {
|
|||||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::execCommand(std::string cmd, int detPos) {
|
int multiSlsDetector::execCommand(const std::string& cmd, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->execCommand(cmd);
|
return detectors[detPos]->execCommand(cmd);
|
||||||
@ -981,7 +983,7 @@ std::string multiSlsDetector::getSettingsDir(int detPos) {
|
|||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::setSettingsDir(std::string directory,
|
std::string multiSlsDetector::setSettingsDir(const std::string& directory,
|
||||||
int detPos) {
|
int detPos) {
|
||||||
if (detPos >= 0)
|
if (detPos >= 0)
|
||||||
return detectors[detPos]->setSettingsDir(directory);
|
return detectors[detPos]->setSettingsDir(directory);
|
||||||
@ -990,7 +992,7 @@ std::string multiSlsDetector::setSettingsDir(std::string directory,
|
|||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::loadSettingsFile(std::string fname, int detPos) {
|
int multiSlsDetector::loadSettingsFile(const std::string& fname, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->loadSettingsFile(fname);
|
return detectors[detPos]->loadSettingsFile(fname);
|
||||||
@ -1001,7 +1003,7 @@ int multiSlsDetector::loadSettingsFile(std::string fname, int detPos) {
|
|||||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::saveSettingsFile(std::string fname, int detPos) {
|
int multiSlsDetector::saveSettingsFile(const std::string& fname, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->saveSettingsFile(fname);
|
return detectors[detPos]->saveSettingsFile(fname);
|
||||||
@ -1540,7 +1542,7 @@ uint32_t multiSlsDetector::clearBit(uint32_t addr, int n, int detPos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::setNetworkParameter(networkParameter parameter,
|
std::string multiSlsDetector::setNetworkParameter(networkParameter parameter,
|
||||||
std::string value,
|
const std::string& value,
|
||||||
int detPos) {
|
int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0)
|
if (detPos >= 0)
|
||||||
@ -1604,7 +1606,7 @@ int multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) {
|
|||||||
return stoi(getNetworkParameter(CLIENT_STREAMING_PORT, detPos));
|
return stoi(getNetworkParameter(CLIENT_STREAMING_PORT, detPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::setReceiverDataStreamingOutIP(std::string ip,
|
std::string multiSlsDetector::setReceiverDataStreamingOutIP(const std::string& ip,
|
||||||
int detPos) {
|
int detPos) {
|
||||||
if (ip.length()) {
|
if (ip.length()) {
|
||||||
int prev_streaming = enableDataStreamingFromReceiver(-1, detPos);
|
int prev_streaming = enableDataStreamingFromReceiver(-1, detPos);
|
||||||
@ -1617,7 +1619,7 @@ std::string multiSlsDetector::setReceiverDataStreamingOutIP(std::string ip,
|
|||||||
return getNetworkParameter(RECEIVER_STREAMING_SRC_IP, detPos);
|
return getNetworkParameter(RECEIVER_STREAMING_SRC_IP, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::setClientDataStreamingInIP(std::string ip,
|
std::string multiSlsDetector::setClientDataStreamingInIP(const std::string& ip,
|
||||||
int detPos) {
|
int detPos) {
|
||||||
if (ip.length()) {
|
if (ip.length()) {
|
||||||
int prev_streaming = enableDataStreamingToClient(-1);
|
int prev_streaming = enableDataStreamingToClient(-1);
|
||||||
@ -2220,7 +2222,7 @@ int multiSlsDetector::setStoragecellStart(int pos, int detPos) {
|
|||||||
return sls::minusOneIfDifferent(r);
|
return sls::minusOneIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::programFPGA(std::string fname, int detPos) {
|
int multiSlsDetector::programFPGA(const std::string& fname, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->programFPGA(fname);
|
return detectors[detPos]->programFPGA(fname);
|
||||||
@ -2368,7 +2370,7 @@ int multiSlsDetector::exitReceiver(int detPos) {
|
|||||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::execReceiverCommand(std::string cmd, int detPos) {
|
int multiSlsDetector::execReceiverCommand(const std::string& cmd, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->execReceiverCommand(cmd);
|
return detectors[detPos]->execReceiverCommand(cmd);
|
||||||
@ -2390,17 +2392,17 @@ std::string multiSlsDetector::getFilePath(int detPos) {
|
|||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::setFilePath(std::string s, int detPos) {
|
std::string multiSlsDetector::setFilePath(const std::string& path, int detPos) {
|
||||||
if (s.empty())
|
if (path.empty())
|
||||||
return getFilePath(detPos);
|
return getFilePath(detPos);
|
||||||
|
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->setFilePath(s);
|
return detectors[detPos]->setFilePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// multi
|
// multi
|
||||||
auto r = parallelCall(&slsDetector::setFilePath, s);
|
auto r = parallelCall(&slsDetector::setFilePath, path);
|
||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2415,17 +2417,17 @@ std::string multiSlsDetector::getFileName(int detPos) {
|
|||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::setFileName(std::string s, int detPos) {
|
std::string multiSlsDetector::setFileName(const std::string& fname, int detPos) {
|
||||||
if (s.empty())
|
if (fname.empty())
|
||||||
return getFileName(detPos);
|
return getFileName(detPos);
|
||||||
|
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->setFileName(s);
|
return detectors[detPos]->setFileName(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// multi
|
// multi
|
||||||
auto r = parallelCall(&slsDetector::setFileName, s);
|
auto r = parallelCall(&slsDetector::setFileName, fname);
|
||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3099,7 +3101,7 @@ int multiSlsDetector::setReceiverSilentMode(int i, int detPos) {
|
|||||||
return sls::minusOneIfDifferent(r);
|
return sls::minusOneIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::setCTBPattern(std::string fname, int detPos) {
|
int multiSlsDetector::setCTBPattern(const std::string& fname, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->setCTBPattern(fname);
|
return detectors[detPos]->setCTBPattern(fname);
|
||||||
|
@ -453,7 +453,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int execCommand(std::string cmd, int detPos);
|
int execCommand(const std::string& cmd, int detPos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configuration from a configuration File
|
* Load configuration from a configuration File
|
||||||
@ -524,7 +524,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns the trimbit/settings directory
|
* @returns the trimbit/settings directory
|
||||||
*/
|
*/
|
||||||
std::string setSettingsDir(std::string directory, int detPos = -1);
|
std::string setSettingsDir(const std::string& directory, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the modules settings/trimbits reading from a specific file
|
* Loads the modules settings/trimbits reading from a specific file
|
||||||
@ -533,7 +533,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* returns OK or FAIL
|
* returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int loadSettingsFile(std::string fname, int detPos = -1);
|
int loadSettingsFile(const std::string& fname, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the modules settings/trimbits to a specific file
|
* Saves the modules settings/trimbits to a specific file
|
||||||
@ -542,7 +542,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* returns OK or FAIL
|
* returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int saveSettingsFile(std::string fname, int detPos = -1);
|
int saveSettingsFile(const std::string& fname, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Detector run status
|
* Get Detector run status
|
||||||
@ -869,7 +869,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @returns network parameter value set (from getNetworkParameter)
|
* @returns network parameter value set (from getNetworkParameter)
|
||||||
*/
|
*/
|
||||||
std::string setNetworkParameter(networkParameter parameter,
|
std::string setNetworkParameter(networkParameter parameter,
|
||||||
std::string value, int detPos = -1);
|
const std::string& value, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get network parameter
|
* Get network parameter
|
||||||
@ -911,7 +911,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns receiver streaming out ZMQ IP
|
* @returns receiver streaming out ZMQ IP
|
||||||
*/
|
*/
|
||||||
std::string setReceiverDataStreamingOutIP(std::string ip = "",
|
std::string setReceiverDataStreamingOutIP(const std::string& ip = "",
|
||||||
int detPos = -1);
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -922,7 +922,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns client streaming in ZMQ IP
|
* @returns client streaming in ZMQ IP
|
||||||
*/
|
*/
|
||||||
std::string setClientDataStreamingInIP(std::string ip = "",
|
std::string setClientDataStreamingInIP(const std::string& ip = "",
|
||||||
int detPos = -1);
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1152,7 +1152,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int programFPGA(std::string fname, int detPos = -1);
|
int programFPGA(const std::string& fname, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets FPGA (Jungfrau)
|
* Resets FPGA (Jungfrau)
|
||||||
@ -1253,7 +1253,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int execReceiverCommand(std::string cmd, int detPos = -1);
|
int execReceiverCommand(const std::string& cmd, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns output file directory
|
* Returns output file directory
|
||||||
@ -1268,7 +1268,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param s file directory
|
* @param s file directory
|
||||||
* @returns file dir
|
* @returns file dir
|
||||||
*/
|
*/
|
||||||
std::string setFilePath(std::string s, int detPos = -1);
|
std::string setFilePath(const std::string& path, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns file name prefix
|
* Returns file name prefix
|
||||||
@ -1283,7 +1283,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param s file name prefix
|
* @param s file name prefix
|
||||||
* @returns file name prefix
|
* @returns file name prefix
|
||||||
*/
|
*/
|
||||||
std::string setFileName(std::string s, int detPos = -1);
|
std::string setFileName(const std::string& fname, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the max frames per file in receiver
|
* Sets the max frames per file in receiver
|
||||||
@ -1485,7 +1485,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK/FAIL
|
* @returns OK/FAIL
|
||||||
*/
|
*/
|
||||||
int setCTBPattern(std::string fname, int detPos = -1);
|
int setCTBPattern(const std::string& fname, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a pattern word to the CTB
|
* Writes a pattern word to the CTB
|
||||||
@ -1642,7 +1642,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
* Add sls detector
|
* Add sls detector
|
||||||
* @param s hostname of the single detector
|
* @param s hostname of the single detector
|
||||||
*/
|
*/
|
||||||
void addSlsDetector(std::string s);
|
void addSlsDetector(const std::string& hostname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add gap pixels to the image (only for Eiger in 4 bit mode)
|
* add gap pixels to the image (only for Eiger in 4 bit mode)
|
||||||
|
Reference in New Issue
Block a user