Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor

This commit is contained in:
maliakal_d 2019-01-11 14:49:09 +01:00
commit 363f4f1da0
8 changed files with 88 additions and 88 deletions

View File

@ -45,9 +45,11 @@ void multiSlsDetector::setupMultiDetector(bool verify, bool update) {
updateUserdetails(); updateUserdetails();
} }
template <typename RT, typename... CT> 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) { typename NonDeduced<CT>::type... Args) {
std::vector<RT> result; std::vector<RT> result;
result.reserve(detectors.size()); result.reserve(detectors.size());
for (auto &d : detectors) for (auto &d : detectors)
@ -57,7 +59,7 @@ std::vector<RT> multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...),
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> std::vector<RT>
multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...), CT... Args) { multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...), typename NonDeduced<CT>::type... Args) {
std::vector<std::future<RT>> futures; std::vector<std::future<RT>> futures;
for (auto &d : detectors) for (auto &d : detectors)
futures.push_back( futures.push_back(

View File

@ -141,8 +141,10 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* Loop through the detectors serially * Loop through the detectors serially
* and return a vector of results * and return a vector of results
*/ */
template <class CT>
struct NonDeduced { using type = CT; };
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...), CT... Args); std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...), typename NonDeduced<CT>::type... Args);
/** /**
* Loop through the detectors in parallel threads * Loop through the detectors in parallel threads
@ -150,7 +152,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/ */
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...), std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...),
CT... Args); typename NonDeduced<CT>::type... Args);
/** /**
* If specific position, then provide result with that detector at position * If specific position, then provide result with that detector at position

View File

@ -1003,18 +1003,14 @@ std::string slsDetector::checkOnline() {
} }
int slsDetector::setTCPSocket(std::string const name, int const control_port, int const stop_port) { int slsDetector::setTCPSocket(const std::string& hostname, int control_port, int stop_port) {
char thisName[MAX_STR_LENGTH] = {0};
int thisCP = 0, thisSP = 0; int thisCP = 0, thisSP = 0;
int ret = OK; int ret = OK;
// hostname // hostname
if (name.empty()) { if (!hostname.empty()) {
strcpy(thisName,thisDetector->hostname);
} else {
FILE_LOG(logDEBUG1) << "Setting hostname"; FILE_LOG(logDEBUG1) << "Setting hostname";
strcpy(thisName, name.c_str()); sls::strcpy_safe(thisDetector->hostname, hostname.c_str());
strcpy(thisDetector->hostname, thisName);
if (controlSocket) { if (controlSocket) {
delete controlSocket; delete controlSocket;
controlSocket = nullptr; controlSocket = nullptr;
@ -1054,10 +1050,10 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
// create control socket // create control socket
if (!controlSocket) { if (!controlSocket) {
try { try {
controlSocket = new MySocketTCP(thisName, thisCP); controlSocket = new MySocketTCP(thisDetector->hostname, thisCP);
FILE_LOG(logDEBUG1) << "Control socket connected " << thisName << " " << thisCP; FILE_LOG(logDEBUG1) << "Control socket connected " << thisDetector->hostname << " " << thisCP;
} catch(...) { } catch(...) {
FILE_LOG(logERROR) << "Could not connect control socket " << thisName << " " << thisCP; FILE_LOG(logERROR) << "Could not connect control socket " << thisDetector->hostname << " " << thisCP;
controlSocket = nullptr; controlSocket = nullptr;
ret = FAIL; ret = FAIL;
} }
@ -1067,10 +1063,10 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
// create stop socket // create stop socket
if (!stopSocket) { if (!stopSocket) {
try { try {
stopSocket = new MySocketTCP(thisName, thisSP); stopSocket = new MySocketTCP(thisDetector->hostname, thisSP);
FILE_LOG(logDEBUG1) << "Stop socket connected " << thisName << " " << thisSP; FILE_LOG(logDEBUG1) << "Stop socket connected " << thisDetector->hostname << " " << thisSP;
} catch(...) { } catch(...) {
FILE_LOG(logERROR) << "Could not connect Stop socket " << thisName << " " << thisSP; FILE_LOG(logERROR) << "Could not connect Stop socket " << thisDetector->hostname << " " << thisSP;
stopSocket = nullptr; stopSocket = nullptr;
ret = FAIL; ret = FAIL;
} }
@ -1312,12 +1308,12 @@ int slsDetector::exitServer() {
} }
int slsDetector::execCommand(std::string cmd) { int slsDetector::execCommand(const std::string& cmd) {
int fnum = F_EXEC_COMMAND; int fnum = F_EXEC_COMMAND;
int ret = FAIL; int ret = FAIL;
char arg[MAX_STR_LENGTH] = {0}; char arg[MAX_STR_LENGTH] = {0};
char retval[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0};
strcpy(arg, cmd.c_str()); sls::strcpy_safe(arg, cmd.c_str());
FILE_LOG(logDEBUG1) << "Sending command to detector " << arg; FILE_LOG(logDEBUG1) << "Sending command to detector " << arg;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
@ -1419,7 +1415,7 @@ int slsDetector::updateDetector() {
} }
int slsDetector::writeConfigurationFile(std::string const fname, multiSlsDetector* m) { int slsDetector::writeConfigurationFile(const std::string& fname, multiSlsDetector* m) {
int iline = 0; int iline = 0;
std::ofstream outfile; std::ofstream outfile;
outfile.open(fname.c_str(),std::ios_base::out); outfile.open(fname.c_str(),std::ios_base::out);
@ -1511,7 +1507,7 @@ std::string slsDetector::getSettingsFile() {
} }
int slsDetector::writeSettingsFile(std::string fname) { int slsDetector::writeSettingsFile(const std::string& fname) {
return writeSettingsFile(fname, detectorModules[0]); return writeSettingsFile(fname, detectorModules[0]);
} }
@ -1770,13 +1766,13 @@ std::string slsDetector::getSettingsDir() {
} }
std::string slsDetector::setSettingsDir(std::string s) { std::string slsDetector::setSettingsDir(const std::string& dir) {
sls::strcpy_safe(thisDetector->settingsDir, s.c_str()); sls::strcpy_safe(thisDetector->settingsDir, dir.c_str());
return thisDetector->settingsDir; return thisDetector->settingsDir;
} }
int slsDetector::loadSettingsFile(std::string fname) { int slsDetector::loadSettingsFile(const std::string& fname) {
std::string fn = fname; std::string fn = fname;
std::ostringstream ostfn; std::ostringstream ostfn;
ostfn << fname; ostfn << fname;
@ -1807,7 +1803,7 @@ int slsDetector::loadSettingsFile(std::string fname) {
} }
int slsDetector::saveSettingsFile(std::string fname) { int slsDetector::saveSettingsFile(const std::string& fname) {
std::string fn = fname; std::string fn = fname;
std::ostringstream ostfn; std::ostringstream ostfn;
ostfn << fname; ostfn << fname;
@ -2666,7 +2662,7 @@ uint32_t slsDetector::clearBit(uint32_t addr, int n) {
} }
std::string slsDetector::setNetworkParameter(networkParameter index, std::string value) { std::string slsDetector::setNetworkParameter(networkParameter index, const std::string& value) {
switch (index) { switch (index) {
case DETECTOR_MAC: case DETECTOR_MAC:
return setDetectorMAC(value); return setDetectorMAC(value);
@ -2844,7 +2840,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() {
} }
std::string slsDetector::setDetectorMAC(std::string detectorMAC) { std::string slsDetector::setDetectorMAC(const std::string& detectorMAC) {
// invalid format // invalid format
if ((detectorMAC.length() != 17) || if ((detectorMAC.length() != 17) ||
@ -2866,7 +2862,7 @@ std::string slsDetector::setDetectorMAC(std::string detectorMAC) {
} }
std::string slsDetector::setDetectorIP(std::string detectorIP) { std::string slsDetector::setDetectorIP(const std::string& detectorIP) {
struct sockaddr_in sa; struct sockaddr_in sa;
if (detectorIP.length() && detectorIP.length() < 16) { if (detectorIP.length() && detectorIP.length() < 16) {
int result = inet_pton(AF_INET, detectorIP.c_str(), &(sa.sin_addr)); int result = inet_pton(AF_INET, detectorIP.c_str(), &(sa.sin_addr));
@ -2890,12 +2886,12 @@ std::string slsDetector::setDetectorIP(std::string detectorIP) {
} }
std::string slsDetector::setReceiver(std::string receiverIP) { std::string slsDetector::setReceiver(const std::string& receiverIP) {
FILE_LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP; FILE_LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP;
// recieverIP is none // recieverIP is none
if (receiverIP == "none") { if (receiverIP == "none") {
memset(thisDetector->receiver_hostname, 0, MAX_STR_LENGTH); memset(thisDetector->receiver_hostname, 0, MAX_STR_LENGTH);
strcpy(thisDetector->receiver_hostname, "none"); sls::strcpy_safe(thisDetector->receiver_hostname, "none");
thisDetector->receiverOnlineFlag = OFFLINE_FLAG; thisDetector->receiverOnlineFlag = OFFLINE_FLAG;
return std::string(thisDetector->receiver_hostname); return std::string(thisDetector->receiver_hostname);
} }
@ -2991,7 +2987,7 @@ std::string slsDetector::setReceiver(std::string receiverIP) {
} }
std::string slsDetector::setReceiverUDPIP(std::string udpip) { std::string slsDetector::setReceiverUDPIP(const std::string& udpip) {
struct sockaddr_in sa; struct sockaddr_in sa;
if (udpip.length() && udpip.length() < 16) { if (udpip.length() && udpip.length() < 16) {
int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr)); int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr));
@ -3003,7 +2999,7 @@ std::string slsDetector::setReceiverUDPIP(std::string udpip) {
} }
// valid format // valid format
else { else {
strcpy(thisDetector->receiverUDPIP,udpip.c_str()); sls::strcpy_safe(thisDetector->receiverUDPIP,udpip.c_str());
if (!strcmp(thisDetector->receiver_hostname, "none")) { if (!strcmp(thisDetector->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) { } else if (setUDPConnection() == FAIL) {
@ -3015,7 +3011,7 @@ std::string slsDetector::setReceiverUDPIP(std::string udpip) {
} }
std::string slsDetector::setReceiverUDPMAC(std::string udpmac) { std::string slsDetector::setReceiverUDPMAC(const std::string& udpmac) {
// invalid format // invalid format
if ((udpmac.length() != 17) || if ((udpmac.length() != 17) ||
(udpmac[2] != ':') || (udpmac[5] != ':') || (udpmac[8] != ':') || (udpmac[2] != ':') || (udpmac[5] != ':') || (udpmac[8] != ':') ||
@ -3060,13 +3056,13 @@ int slsDetector::setReceiverUDPPort2(int udpport) {
} }
std::string slsDetector::setClientStreamingPort(std::string port) { std::string slsDetector::setClientStreamingPort(const std::string& port) {
thisDetector->zmqport = stoi(port); thisDetector->zmqport = stoi(port);
return getClientStreamingPort(); return getClientStreamingPort();
} }
std::string slsDetector::setReceiverStreamingPort(std::string port) { std::string slsDetector::setReceiverStreamingPort(const std::string& port) {
// copy now else it is lost if rx_hostname not set yet // copy now else it is lost if rx_hostname not set yet
thisDetector->receiver_zmqport = stoi(port); thisDetector->receiver_zmqport = stoi(port);
@ -3094,7 +3090,7 @@ std::string slsDetector::setReceiverStreamingPort(std::string port) {
} }
std::string slsDetector::setClientStreamingIP(std::string sourceIP) { std::string slsDetector::setClientStreamingIP(const std::string& sourceIP) {
struct addrinfo *result; struct addrinfo *result;
// on failure to convert to a valid ip // on failure to convert to a valid ip
if (dataSocket->ConvertHostnameToInternetAddress(sourceIP.c_str(), &result)) { if (dataSocket->ConvertHostnameToInternetAddress(sourceIP.c_str(), &result)) {
@ -3167,7 +3163,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) {
} }
std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { std::string slsDetector::setAdditionalJsonHeader(const std::string& jsonheader) {
int fnum = F_ADDITIONAL_JSON_HEADER; int fnum = F_ADDITIONAL_JSON_HEADER;
int ret = FAIL; int ret = FAIL;
char args[MAX_STR_LENGTH] = {0}; char args[MAX_STR_LENGTH] = {0};
@ -3331,7 +3327,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int ival) {
} }
int slsDetector::loadImageToDetector(imageType index,std::string const fname) { int slsDetector::loadImageToDetector(imageType index, const std::string& fname) {
int ret = FAIL; int ret = FAIL;
int nChan = getTotalNumberOfChannels(); int nChan = getTotalNumberOfChannels();
short int args[nChan]; short int args[nChan];
@ -3374,7 +3370,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) {
} }
int slsDetector::writeCounterBlockFile(std::string const fname,int startACQ) { int slsDetector::writeCounterBlockFile(const std::string& fname,int startACQ) {
int ret = FAIL; int ret = FAIL;
int nChan = getTotalNumberOfChannels(); int nChan = getTotalNumberOfChannels();
short int retvals[nChan]; short int retvals[nChan];
@ -3961,7 +3957,7 @@ int slsDetector::setStoragecellStart(int pos) {
} }
int slsDetector::programFPGA(std::string fname) { int slsDetector::programFPGA(const std::string& fname) {
// only jungfrau implemented (client processing, so check now) // only jungfrau implemented (client processing, so check now)
if (thisDetector->myDetectorType != JUNGFRAU && thisDetector->myDetectorType != CHIPTESTBOARD) { if (thisDetector->myDetectorType != JUNGFRAU && thisDetector->myDetectorType != CHIPTESTBOARD) {
FILE_LOG(logERROR) << "Not implemented for this detector"; FILE_LOG(logERROR) << "Not implemented for this detector";
@ -4524,7 +4520,7 @@ std::string slsDetector::checkReceiverOnline() {
} }
int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver_port) { int slsDetector::setReceiverTCPSocket(const std::string& name, int const receiver_port) {
char thisName[MAX_STR_LENGTH] = {0}; char thisName[MAX_STR_LENGTH] = {0};
int thisRP = 0; int thisRP = 0;
int ret = OK; int ret = OK;
@ -4652,7 +4648,7 @@ int slsDetector::exitReceiver() {
} }
int slsDetector::execReceiverCommand(std::string cmd) { int slsDetector::execReceiverCommand(const std::string& cmd) {
int fnum = F_EXEC_RECEIVER_COMMAND; int fnum = F_EXEC_RECEIVER_COMMAND;
int ret = FAIL; int ret = FAIL;
char arg[MAX_STR_LENGTH] = {0}; char arg[MAX_STR_LENGTH] = {0};
@ -4859,13 +4855,13 @@ std::string slsDetector::getFilePath() {
} }
std::string slsDetector::setFilePath(std::string s) { std::string slsDetector::setFilePath(const std::string& path) {
if (!s.empty()) { if (!path.empty()) {
int fnum = F_SET_RECEIVER_FILE_PATH; int fnum = F_SET_RECEIVER_FILE_PATH;
int ret = FAIL; int ret = FAIL;
char args[MAX_STR_LENGTH] = {0}; char args[MAX_STR_LENGTH] = {0};
char retvals[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0};
strcpy(args, s.c_str()); strcpy(args, path.c_str());
FILE_LOG(logDEBUG1) << "Sending file path to receiver: " << args; FILE_LOG(logDEBUG1) << "Sending file path to receiver: " << args;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
@ -4874,7 +4870,7 @@ std::string slsDetector::setFilePath(std::string s) {
// handle ret // handle ret
if (ret == FAIL) { if (ret == FAIL) {
if (!s.empty()) { if (!path.empty()) {
FILE_LOG(logERROR) << "file path does not exist"; FILE_LOG(logERROR) << "file path does not exist";
setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST));
} else } else
@ -4896,13 +4892,13 @@ std::string slsDetector::getFileName() {
} }
std::string slsDetector::setFileName(std::string s) { std::string slsDetector::setFileName(const std::string& fname) {
if (!s.empty()) { if (!fname.empty()) {
int fnum = F_SET_RECEIVER_FILE_NAME; int fnum = F_SET_RECEIVER_FILE_NAME;
int ret = FAIL; int ret = FAIL;
char args[MAX_STR_LENGTH] = {0}; char args[MAX_STR_LENGTH] = {""};
char retvals[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {""};
strcpy(args, s.c_str()); strcpy(args, fname.c_str());
FILE_LOG(logDEBUG1) << "Sending file name to receiver: " << args; FILE_LOG(logDEBUG1) << "Sending file name to receiver: " << args;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
@ -5462,7 +5458,7 @@ int slsDetector::restreamStopFromReceiver() {
int slsDetector::setCTBPattern(std::string fname) { int slsDetector::setCTBPattern(const std::string& fname) {
uint64_t word; uint64_t word;
int addr = 0; int addr = 0;
FILE *fd = fopen(fname.c_str(),"r"); FILE *fd = fopen(fname.c_str(),"r");
@ -5644,7 +5640,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim(
} }
slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname, slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(const std::string& fname,
sls_detector_module* myMod, int tb) { sls_detector_module* myMod, int tb) {
FILE_LOG(logDEBUG1) << "Read settings file " << fname; FILE_LOG(logDEBUG1) << "Read settings file " << fname;
@ -5789,7 +5785,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
} }
int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod) { int slsDetector::writeSettingsFile(const std::string& fname, sls_detector_module mod) {
FILE_LOG(logDEBUG1) << "Write settings file " << fname; FILE_LOG(logDEBUG1) << "Write settings file " << fname;

View File

@ -510,7 +510,7 @@ public:
* @returns OK or FAIL * @returns OK or FAIL
* \sa sharedSlsDetector * \sa sharedSlsDetector
*/ */
int setTCPSocket(std::string const name="", int const control_port=-1, int const stop_port=-1); int setTCPSocket(const std::string& hostname="", int control_port=-1, int stop_port=-1);
/** /**
* Set/Gets TCP Port of detector or receiver * Set/Gets TCP Port of detector or receiver
@ -563,7 +563,7 @@ public:
* @param cmd command to be executed * @param cmd command to be executed
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int execCommand(std::string cmd); int execCommand(const std::string& cmd);
/** /**
* Updates some of the shared memory receiving the data from the detector * Updates some of the shared memory receiving the data from the detector
@ -585,7 +585,7 @@ public:
* @param m multiSlsDetector reference to parse commands * @param m multiSlsDetector reference to parse commands
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int writeConfigurationFile(std::string const fname, multiSlsDetector* m); int writeConfigurationFile(const std::string& fname, multiSlsDetector* m);
/** /**
* Write current configuration to a stream * Write current configuration to a stream
@ -608,7 +608,7 @@ public:
* @returns OK or FAIL if the file could not be written * @returns OK or FAIL if the file could not be written
* \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) * \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
*/ */
int writeSettingsFile(std::string fname); int writeSettingsFile(const std::string& fname);
/** /**
* Get detector settings * Get detector settings
@ -672,7 +672,7 @@ public:
* @param s trimbits/settings directory * @param s trimbits/settings directory
* @returns the trimbit/settings directory * @returns the trimbit/settings directory
*/ */
std::string setSettingsDir(std::string s); std::string setSettingsDir(const std::string& dir);
/** /**
* Loads the modules settings/trimbits reading from a specific file * Loads the modules settings/trimbits reading from a specific file
@ -680,7 +680,7 @@ public:
* @param fname specific settings/trimbits file * @param fname specific settings/trimbits file
* returns OK or FAIL * returns OK or FAIL
*/ */
int loadSettingsFile(std::string fname); int loadSettingsFile(const std::string& fname);
/** /**
* Saves the modules settings/trimbits to a specific file * Saves the modules settings/trimbits to a specific file
@ -688,7 +688,7 @@ public:
* @param fname specific settings/trimbits file * @param fname specific settings/trimbits file
* returns OK or FAIL * returns OK or FAIL
*/ */
int saveSettingsFile(std::string fname); int saveSettingsFile(const std::string& fname);
/** /**
* Get run status of the detector * Get run status of the detector
@ -864,7 +864,7 @@ public:
* @param value network parameter value * @param value network parameter value
* @returns network parameter value set (from getNetworkParameter) * @returns network parameter value set (from getNetworkParameter)
*/ */
std::string setNetworkParameter(networkParameter index, std::string value); std::string setNetworkParameter(networkParameter index, const std::string& value);
/** /**
* Get network parameter * Get network parameter
@ -944,14 +944,14 @@ public:
* @param detectorMAC detector MAC address * @param detectorMAC detector MAC address
* @returns the detector MAC address * @returns the detector MAC address
*/ */
std::string setDetectorMAC(std::string detectorMAC); std::string setDetectorMAC(const std::string& detectorMAC);
/** /**
* Validates the format of the detector IP address and sets it \sa sharedSlsDetector * Validates the format of the detector IP address and sets it \sa sharedSlsDetector
* @param detectorIP detector IP address * @param detectorIP detector IP address
* @returns the detector IP address * @returns the detector IP address
*/ */
std::string setDetectorIP(std::string detectorIP); std::string setDetectorIP(const std::string& detectorIP);
/** /**
* Validates and sets the receiver. * Validates and sets the receiver.
@ -960,21 +960,21 @@ public:
* @param receiver receiver hostname or IP address * @param receiver receiver hostname or IP address
* @returns the receiver IP address from shared memory * @returns the receiver IP address from shared memory
*/ */
std::string setReceiver(std::string receiver); std::string setReceiver(const std::string& receiver);
/** /**
* Validates the format of the receiver UDP IP address and sets it \sa sharedSlsDetector * Validates the format of the receiver UDP IP address and sets it \sa sharedSlsDetector
* @param udpip receiver UDP IP address * @param udpip receiver UDP IP address
* @returns the receiver UDP IP address * @returns the receiver UDP IP address
*/ */
std::string setReceiverUDPIP(std::string udpip); std::string setReceiverUDPIP(const std::string& udpip);
/** /**
* Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector * Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector
* @param udpmac receiver UDP MAC address * @param udpmac receiver UDP MAC address
* @returns the receiver UDP MAC address * @returns the receiver UDP MAC address
*/ */
std::string setReceiverUDPMAC(std::string udpmac); std::string setReceiverUDPMAC(const std::string& udpmac);
/** /**
* Sets the receiver UDP port\sa sharedSlsDetector * Sets the receiver UDP port\sa sharedSlsDetector
@ -996,7 +996,7 @@ public:
* calculate individual ports) * calculate individual ports)
* @returns the client zmq port * @returns the client zmq port
*/ */
std::string setClientStreamingPort(std::string port); std::string setClientStreamingPort(const std::string& port);
/** /**
* Sets the receiver zmq port\sa sharedSlsDetector * Sets the receiver zmq port\sa sharedSlsDetector
@ -1004,14 +1004,14 @@ public:
* calculate individual ports) * calculate individual ports)
* @returns the receiver zmq port * @returns the receiver zmq port
*/ */
std::string setReceiverStreamingPort(std::string port); std::string setReceiverStreamingPort(const std::string& port);
/** /**
* Sets the client zmq ip\sa sharedSlsDetector * Sets the client zmq ip\sa sharedSlsDetector
* @param sourceIP client zmq ip * @param sourceIP client zmq ip
* @returns the client zmq ip, returns "none" if default setting and no custom ip set * @returns the client zmq ip, returns "none" if default setting and no custom ip set
*/ */
std::string setClientStreamingIP(std::string sourceIP); std::string setClientStreamingIP(const std::string& sourceIP);
/** /**
* Sets the receiver zmq ip\sa sharedSlsDetector * Sets the receiver zmq ip\sa sharedSlsDetector
@ -1034,7 +1034,7 @@ public:
* @param fname file name from which to load image * @param fname file name from which to load image
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int loadImageToDetector(imageType index,std::string const fname); int loadImageToDetector(imageType index, const std::string& fname);
/** /**
* Called from loadImageToDetector to send the image to detector * Called from loadImageToDetector to send the image to detector
@ -1050,7 +1050,7 @@ public:
* @param startACQ is 1 to start acquisition after reading counter * @param startACQ is 1 to start acquisition after reading counter
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int writeCounterBlockFile(std::string const fname,int startACQ=0); int writeCounterBlockFile(const std::string& fname,int startACQ=0);
/** /**
* Gets counter memory block in detector (Gotthard) * Gets counter memory block in detector (Gotthard)
@ -1233,7 +1233,7 @@ public:
* @param fname file name * @param fname file name
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int programFPGA(std::string fname); int programFPGA(const std::string& fname);
/** /**
* Resets FPGA (Jungfrau) * Resets FPGA (Jungfrau)
@ -1323,7 +1323,7 @@ public:
* @returns OK is connection succeded, FAIL otherwise * @returns OK is connection succeded, FAIL otherwise
* \sa sharedSlsDetector * \sa sharedSlsDetector
*/ */
int setReceiverTCPSocket(std::string const name="", int const receiver_port=-1); int setReceiverTCPSocket(const std::string& name="", int const receiver_port=-1);
/** /**
* Locks/Unlocks the connection to the receiver * Locks/Unlocks the connection to the receiver
@ -1350,7 +1350,7 @@ public:
* @param cmd command to be executed * @param cmd command to be executed
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int execReceiverCommand(std::string cmd); int execReceiverCommand(const std::string& cmd);
/** /**
updates the shared memory receiving the data from the detector (without asking and closing the connection updates the shared memory receiving the data from the detector (without asking and closing the connection
@ -1394,7 +1394,7 @@ public:
* @param s file directory * @param s file directory
* @returns file dir * @returns file dir
*/ */
std::string setFilePath(std::string s); std::string setFilePath(const std::string& path);
/** /**
* Returns file name prefix * Returns file name prefix
@ -1407,7 +1407,7 @@ public:
* @param s file name prefix * @param s file name prefix
* @returns file name prefix * @returns file name prefix
*/ */
std::string setFileName(std::string s); std::string setFileName(const std::string& fname);
/** /**
* Sets the max frames per file in receiver * Sets the max frames per file in receiver
@ -1574,7 +1574,7 @@ public:
* @param fname pattern file to open * @param fname pattern file to open
* @returns OK/FAIL * @returns OK/FAIL
*/ */
int setCTBPattern(std::string fname); int setCTBPattern(const std::string& fname);
/** /**
* Writes a pattern word to the CTB * Writes a pattern word to the CTB
@ -1723,7 +1723,7 @@ private:
* @param jsonheader additional json header * @param jsonheader additional json header
* @returns additional json header, returns "none" if default setting and no custom ip set * @returns additional json header, returns "none" if default setting and no custom ip set
*/ */
std::string setAdditionalJsonHeader(std::string jsonheader); std::string setAdditionalJsonHeader(const std::string& jsonheader);
/** /**
* Sets the receiver UDP socket buffer size * Sets the receiver UDP socket buffer size
@ -1782,7 +1782,7 @@ private:
* @returns the pointer to myMod or NULL if reading the file failed * @returns the pointer to myMod or NULL if reading the file failed
*/ */
sls_detector_module* readSettingsFile(std::string fname, sls_detector_module* myMod=nullptr, int tb=1); sls_detector_module* readSettingsFile(const std::string& fname, sls_detector_module* myMod=nullptr, int tb=1);
/** /**
* writes a trim/settings file * writes a trim/settings file
@ -1790,7 +1790,7 @@ private:
* @param mod module structure which has to be written to file * @param mod module structure which has to be written to file
* @returns OK or FAIL if the file could not be written * @returns OK or FAIL if the file could not be written
*/ */
int writeSettingsFile(std::string fname, sls_detector_module mod); int writeSettingsFile(const std::string& fname, sls_detector_module mod);
/** slsDetector Id or position in the detectors list */ /** slsDetector Id or position in the detectors list */

View File

@ -2606,7 +2606,7 @@ std::string slsDetectorCommand::helpThreaded(int action) {
std::string slsDetectorCommand::cmdImage(int narg, char *args[], int action, int detPos) { std::string slsDetectorCommand::cmdImage(int narg, char *args[], int action, int detPos) {
std::string sval; std::string sval;
int retval; int retval = FAIL;
if (action == HELP_ACTION) if (action == HELP_ACTION)
return helpImage(HELP_ACTION); return helpImage(HELP_ACTION);
else if (action == GET_ACTION) else if (action == GET_ACTION)
@ -2643,7 +2643,7 @@ std::string slsDetectorCommand::cmdCounter(int narg, char *args[], int action, i
int ival; int ival;
char answer[100]; char answer[100];
std::string sval; std::string sval;
int retval; int retval = FAIL;
if (action == HELP_ACTION) if (action == HELP_ACTION)
return helpCounter(HELP_ACTION); return helpCounter(HELP_ACTION);
else if (action == PUT_ACTION) else if (action == PUT_ACTION)

View File

@ -47,7 +47,7 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi
/** /**
* Print all member values * Print all member values
*/ */
void PrintMembers(); void PrintMembers(TLogLevel level = logDEBUG1);
/** /**
* Create file * Create file

View File

@ -31,8 +31,8 @@ BinaryFile::~BinaryFile() {
CloseAllFiles(); CloseAllFiles();
} }
void BinaryFile::PrintMembers() { void BinaryFile::PrintMembers(TLogLevel level) {
File::PrintMembers(); File::PrintMembers(level);
FILE_LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile; FILE_LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile;
FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile; FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
} }

View File

@ -705,8 +705,8 @@ int slsReceiverTCPIPInterface::set_roi() {
int slsReceiverTCPIPInterface::setup_udp(){ int slsReceiverTCPIPInterface::setup_udp(){
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
char args[3][MAX_STR_LENGTH] = {0}; char args[3][MAX_STR_LENGTH] = {{""}, {""}, {""}};
char retvals[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {""};
// get args, return if socket crashed, ret is fail if receiver is not null // get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, args, sizeof(args), true, receiver) == FAIL) if (interface->Server_ReceiveArg(ret, mess, args, sizeof(args), true, receiver) == FAIL)