clang-tidy nullptr

This commit is contained in:
Erik Frojdh 2019-01-10 15:28:43 +01:00
parent 58f97d4f46
commit 0f50b9f161
2 changed files with 134 additions and 134 deletions

View File

@ -25,17 +25,17 @@
slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify)
: detId(id), : detId(id),
sharedMemory(0), sharedMemory(nullptr),
thisDetector(0), thisDetector(nullptr),
thisDetectorControl(0), thisDetectorControl(nullptr),
thisDetectorStop(0), thisDetectorStop(nullptr),
thisReceiver(0), thisReceiver(nullptr),
controlSocket(0), controlSocket(nullptr),
stopSocket(0), stopSocket(nullptr),
dataSocket(0), dataSocket(nullptr),
detectorModules(0), detectorModules(nullptr),
dacs(0), dacs(nullptr),
chanregs(0) { chanregs(nullptr) {
/* called from put hostname command, /* called from put hostname command,
* so sls shared memory will be created */ * so sls shared memory will be created */
@ -56,17 +56,17 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify)
slsDetector::slsDetector(int multiId, int id, bool verify) slsDetector::slsDetector(int multiId, int id, bool verify)
: detId(id), : detId(id),
sharedMemory(0), sharedMemory(nullptr),
thisDetector(0), thisDetector(nullptr),
thisDetectorControl(0), thisDetectorControl(nullptr),
thisDetectorStop(0), thisDetectorStop(nullptr),
thisReceiver(0), thisReceiver(nullptr),
controlSocket(0), controlSocket(nullptr),
stopSocket(0), stopSocket(nullptr),
dataSocket(0), dataSocket(nullptr),
detectorModules(0), detectorModules(nullptr),
dacs(0), dacs(nullptr),
chanregs(0) { chanregs(nullptr) {
/* called from multi constructor to populate structure, /* called from multi constructor to populate structure,
* so sls shared memory will be opened, not created */ * so sls shared memory will be opened, not created */
@ -128,7 +128,7 @@ int slsDetector::checkVersionCompatibility(portType t) {
// control server // control server
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0, mess); ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), nullptr, 0, mess);
disconnectControl(); disconnectControl();
if (ret == FAIL) if (ret == FAIL)
thisDetector->detectorControlAPIVersion = 0; thisDetector->detectorControlAPIVersion = 0;
@ -138,7 +138,7 @@ int slsDetector::checkVersionCompatibility(portType t) {
thisDetector->detectorControlAPIVersion = arg; thisDetector->detectorControlAPIVersion = arg;
ret = FAIL; ret = FAIL;
if (connectStop() == OK) { if (connectStop() == OK) {
ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), NULL, 0, mess); ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), nullptr, 0, mess);
disconnectStop(); disconnectStop();
if (ret == FAIL) if (ret == FAIL)
thisDetector->detectorStopAPIVersion = 0; thisDetector->detectorStopAPIVersion = 0;
@ -157,7 +157,7 @@ int slsDetector::checkVersionCompatibility(portType t) {
"value " << std::hex << arg << std::dec; "value " << std::hex << arg << std::dec;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), nullptr, 0);
disconnectData(); disconnectData();
if (ret == FAIL) if (ret == FAIL)
thisDetector->receiverAPIVersion = 0; thisDetector->receiverAPIVersion = 0;
@ -168,7 +168,7 @@ int slsDetector::checkVersionCompatibility(portType t) {
if (ret == FAIL) { if (ret == FAIL) {
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
if (strstr(mess,"Unrecognized Function") != NULL) { if (strstr(mess,"Unrecognized Function") != nullptr) {
FILE_LOG(logERROR) << "The " << ((t == CONTROL_PORT) ? "detector" : "receiver") << FILE_LOG(logERROR) << "The " << ((t == CONTROL_PORT) ? "detector" : "receiver") <<
" server is too old to get API version. Please update detector server!"; " server is too old to get API version. Please update detector server!";
} }
@ -198,7 +198,7 @@ int64_t slsDetector::getId( idMode mode) {
else if (mode==RECEIVER_VERSION) { else if (mode==RECEIVER_VERSION) {
fnum = F_GET_RECEIVER_ID; fnum = F_GET_RECEIVER_ID;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisReceiver->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectData(); disconnectData();
// handle ret // handle ret
@ -242,9 +242,9 @@ void slsDetector::freeSharedMemory() {
sharedMemory->UnmapSharedMemory(thisDetector); sharedMemory->UnmapSharedMemory(thisDetector);
sharedMemory->RemoveSharedMemory(); sharedMemory->RemoveSharedMemory();
delete sharedMemory; delete sharedMemory;
sharedMemory = 0; sharedMemory = nullptr;
} }
thisDetector = 0; thisDetector = nullptr;
} }
@ -295,11 +295,11 @@ void slsDetector::initSharedMemory(bool created, detectorType type, int multiId,
// unmap // unmap
if (thisDetector) { if (thisDetector) {
sharedMemory->UnmapSharedMemory(thisDetector); sharedMemory->UnmapSharedMemory(thisDetector);
thisDetector = 0; thisDetector = nullptr;
} }
// delete // delete
delete sharedMemory; delete sharedMemory;
sharedMemory = 0; sharedMemory = nullptr;
} }
throw; throw;
} }
@ -524,15 +524,15 @@ void slsDetector::initializeMembers() {
chanregs = (int*)(goff + thisDetector->chanoff); chanregs = (int*)(goff + thisDetector->chanoff);
if (thisDetectorControl) { if (thisDetectorControl) {
delete thisDetectorControl; delete thisDetectorControl;
thisDetectorControl = 0; thisDetectorControl = nullptr;
} }
if (thisDetectorStop) { if (thisDetectorStop) {
delete thisDetectorStop; delete thisDetectorStop;
thisDetectorStop = 0; thisDetectorStop = nullptr;
} }
if (thisReceiver) { if (thisReceiver) {
delete thisReceiver; delete thisReceiver;
thisReceiver = 0; thisReceiver = nullptr;
} }
thisDetectorControl = new ClientInterface(controlSocket, detId, "Detector (Control server)"); thisDetectorControl = new ClientInterface(controlSocket, detId, "Detector (Control server)");
thisDetectorStop = new ClientInterface(stopSocket, detId, "Detector (Stop server)"); thisDetectorStop = new ClientInterface(stopSocket, detId, "Detector (Stop server)");
@ -586,7 +586,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty
nc = detlist.nChipX * detlist.nChipY; nc = detlist.nChipX * detlist.nChipY;
nd = detlist.nDacs; nd = detlist.nDacs;
} catch(...) { } catch(...) {
return NULL; return nullptr;
} }
int *dacs = new int[nd]; int *dacs = new int[nd];
int *chanregs = new int[nch*nc]; int *chanregs = new int[nch*nc];
@ -781,7 +781,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int
int fnum = F_GET_DETECTOR_TYPE; int fnum = F_GET_DETECTOR_TYPE;
int ret = FAIL; int ret = FAIL;
detectorType retval = GENERIC; detectorType retval = GENERIC;
MySocketTCP* mySocket = 0; MySocketTCP* mySocket = nullptr;
try { try {
mySocket = new MySocketTCP(name, cport); mySocket = new MySocketTCP(name, cport);
@ -818,7 +818,7 @@ int slsDetector::setDetectorType(detectorType const type) {
// if unspecified, then get from detector // if unspecified, then get from detector
if (type == GET_DETECTOR_TYPE) { if (type == GET_DETECTOR_TYPE) {
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -994,7 +994,7 @@ std::string slsDetector::checkOnline() {
controlSocket->SetTimeOut(5); controlSocket->SetTimeOut(5);
thisDetector->onlineFlag = OFFLINE_FLAG; thisDetector->onlineFlag = OFFLINE_FLAG;
delete controlSocket; delete controlSocket;
controlSocket = 0; controlSocket = nullptr;
retval = std::string(thisDetector->hostname); retval = std::string(thisDetector->hostname);
FILE_LOG(logDEBUG1) << "offline!"; FILE_LOG(logDEBUG1) << "offline!";
} else { } else {
@ -1010,7 +1010,7 @@ std::string slsDetector::checkOnline() {
stopSocket->SetTimeOut(5); stopSocket->SetTimeOut(5);
thisDetector->onlineFlag = OFFLINE_FLAG; thisDetector->onlineFlag = OFFLINE_FLAG;
delete stopSocket; delete stopSocket;
stopSocket = 0; stopSocket = nullptr;
retval = std::string(thisDetector->hostname); retval = std::string(thisDetector->hostname);
FILE_LOG(logDEBUG1) << "stop offline!"; FILE_LOG(logDEBUG1) << "stop offline!";
} else { } else {
@ -1038,11 +1038,11 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
strcpy(thisDetector->hostname, thisName); strcpy(thisDetector->hostname, thisName);
if (controlSocket) { if (controlSocket) {
delete controlSocket; delete controlSocket;
controlSocket = 0; controlSocket = nullptr;
} }
if (stopSocket) { if (stopSocket) {
delete stopSocket; delete stopSocket;
stopSocket = 0; stopSocket = nullptr;
} }
} }
@ -1055,7 +1055,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
thisDetector->controlPort = thisCP; thisDetector->controlPort = thisCP;
if (controlSocket) { if (controlSocket) {
delete controlSocket; delete controlSocket;
controlSocket = 0; controlSocket = nullptr;
} }
} }
@ -1068,7 +1068,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
thisDetector->stopPort = thisSP; thisDetector->stopPort = thisSP;
if (stopSocket) { if (stopSocket) {
delete stopSocket; delete stopSocket;
stopSocket = 0; stopSocket = nullptr;
} }
} }
@ -1079,7 +1079,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
FILE_LOG(logDEBUG1) << "Control socket connected " << thisName << " " << thisCP; FILE_LOG(logDEBUG1) << "Control socket connected " << thisName << " " << thisCP;
} catch(...) { } catch(...) {
FILE_LOG(logERROR) << "Could not connect control socket " << thisName << " " << thisCP; FILE_LOG(logERROR) << "Could not connect control socket " << thisName << " " << thisCP;
controlSocket = 0; controlSocket = nullptr;
ret = FAIL; ret = FAIL;
} }
} }
@ -1092,7 +1092,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
FILE_LOG(logDEBUG1) << "Stop socket connected " << thisName << " " << thisSP; FILE_LOG(logDEBUG1) << "Stop socket connected " << thisName << " " << thisSP;
} catch(...) { } catch(...) {
FILE_LOG(logERROR) << "Could not connect Stop socket " << thisName << " " << thisSP; FILE_LOG(logERROR) << "Could not connect Stop socket " << thisName << " " << thisSP;
stopSocket = 0; stopSocket = nullptr;
ret = FAIL; ret = FAIL;
} }
} }
@ -1301,7 +1301,7 @@ std::string slsDetector::getLastClientIP() {
FILE_LOG(logDEBUG1) << "Getting last client ip to detector server"; FILE_LOG(logDEBUG1) << "Getting last client ip to detector server";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -1324,7 +1324,7 @@ int slsDetector::exitServer() {
FILE_LOG(logDEBUG1) << "Sending exit command to detector server"; FILE_LOG(logDEBUG1) << "Sending exit command to detector server";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// no ret handling as ret never fail // no ret handling as ret never fail
FILE_LOG(logINFO) << "Shutting down the Detector server"; FILE_LOG(logINFO) << "Shutting down the Detector server";
@ -1430,7 +1430,7 @@ int slsDetector::updateDetector() {
FILE_LOG(logDEBUG1) << "Sending update client to detector server"; FILE_LOG(logDEBUG1) << "Sending update client to detector server";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
// if it returns ok (jungfrau in programming mode), dont update // if it returns ok (jungfrau in programming mode), dont update
if (ret == FORCE_UPDATE) if (ret == FORCE_UPDATE)
ret = updateDetectorNoWait(); ret = updateDetectorNoWait();
@ -1604,7 +1604,7 @@ int slsDetector::getThresholdEnergy() {
FILE_LOG(logDEBUG1) << "Getting threshold energy"; FILE_LOG(logDEBUG1) << "Getting threshold energy";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -1687,7 +1687,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
} }
//fill detector module structure //fill detector module structure
sls_detector_module *myMod = NULL; sls_detector_module *myMod = nullptr;
//normal //normal
if (!interpolate) { if (!interpolate) {
@ -1700,7 +1700,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
//read the files //read the files
myMod = createModule(); // readSettings also checks if create module is null myMod = createModule(); // readSettings also checks if create module is null
if (NULL == readSettingsFile(settingsfname, myMod, tb)) { if (nullptr == readSettingsFile(settingsfname, myMod, tb)) {
if (myMod) if (myMod)
deleteModule(myMod); deleteModule(myMod);
return FAIL; return FAIL;
@ -1734,13 +1734,13 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
FILE_LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and " << settingsfname2; FILE_LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and " << settingsfname2;
sls_detector_module *myMod1=createModule(); sls_detector_module *myMod1=createModule();
sls_detector_module *myMod2=createModule(); sls_detector_module *myMod2=createModule();
if (NULL == readSettingsFile(settingsfname1, myMod1, tb)) { if (nullptr == readSettingsFile(settingsfname1, myMod1, tb)) {
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
deleteModule(myMod1); deleteModule(myMod1);
deleteModule(myMod2); deleteModule(myMod2);
return FAIL; return FAIL;
} }
if (NULL == readSettingsFile(settingsfname2, myMod2, tb)) { if (nullptr == readSettingsFile(settingsfname2, myMod2, tb)) {
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
deleteModule(myMod1); deleteModule(myMod1);
deleteModule(myMod2); deleteModule(myMod2);
@ -1757,7 +1757,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
//interpolate module //interpolate module
myMod = interpolateTrim( myMod1, myMod2, e_eV, trim1, trim2, tb); myMod = interpolateTrim( myMod1, myMod2, e_eV, trim1, trim2, tb);
if (myMod == NULL) { if (myMod == nullptr) {
FILE_LOG(logERROR) << "Could not interpolate, different dac values in files"; FILE_LOG(logERROR) << "Could not interpolate, different dac values in files";
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
deleteModule(myMod1); deleteModule(myMod1);
@ -1813,12 +1813,12 @@ int slsDetector::loadSettingsFile(std::string fname) {
fn = ostfn.str(); fn = ostfn.str();
// read settings file // read settings file
sls_detector_module *myMod=NULL; sls_detector_module *myMod=nullptr;
myMod = readSettingsFile(fn, myMod); myMod = readSettingsFile(fn, myMod);
// set module // set module
int ret = FAIL; int ret = FAIL;
if (myMod != NULL) { if (myMod != nullptr) {
myMod->reg = -1; myMod->reg = -1;
myMod->eV = -1; myMod->eV = -1;
ret = setModule(*myMod); ret = setModule(*myMod);
@ -1842,7 +1842,7 @@ int slsDetector::saveSettingsFile(std::string fname) {
// get module // get module
int ret = FAIL; int ret = FAIL;
sls_detector_module *myMod = NULL; sls_detector_module *myMod = nullptr;
if ((myMod = getModule())) { if ((myMod = getModule())) {
ret = writeSettingsFile(fn, *myMod); ret = writeSettingsFile(fn, *myMod);
deleteModule(myMod); deleteModule(myMod);
@ -1858,7 +1858,7 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus() {
FILE_LOG(logDEBUG1) << "Getting status"; FILE_LOG(logDEBUG1) << "Getting status";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) {
ret = thisDetectorStop->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisDetectorStop->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectStop(); disconnectStop();
// handle ret // handle ret
@ -1880,7 +1880,7 @@ int slsDetector::prepareAcquisition() {
FILE_LOG(logDEBUG1) << "Preparing Detector for Acquisition"; FILE_LOG(logDEBUG1) << "Preparing Detector for Acquisition";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -1906,7 +1906,7 @@ int slsDetector::startAcquisition() {
thisDetector->stoppedFlag = 0; thisDetector->stoppedFlag = 0;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -1935,7 +1935,7 @@ int slsDetector::stopAcquisition() {
FILE_LOG(logDEBUG1) << "Stopping Acquisition"; FILE_LOG(logDEBUG1) << "Stopping Acquisition";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) {
ret = thisDetectorStop->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorStop->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectStop(); disconnectStop();
// handle ret // handle ret
@ -1964,7 +1964,7 @@ int slsDetector::sendSoftwareTrigger() {
thisDetector->stoppedFlag = 0; thisDetector->stoppedFlag = 0;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -1987,7 +1987,7 @@ int slsDetector::startAndReadAll() {
thisDetector->stoppedFlag = 0; thisDetector->stoppedFlag = 0;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -2010,7 +2010,7 @@ int slsDetector::startReadOut() {
FILE_LOG(logDEBUG1) << "Starting readout"; FILE_LOG(logDEBUG1) << "Starting readout";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -2032,7 +2032,7 @@ int slsDetector::readAll() {
FILE_LOG(logDEBUG1) << "Reading all frames"; FILE_LOG(logDEBUG1) << "Reading all frames";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -2062,7 +2062,7 @@ int slsDetector::configureMAC() {
// if rx_udpip is none // if rx_udpip is none
if (!(strcmp(thisDetector->receiverUDPIP,"none"))) { if (!(strcmp(thisDetector->receiverUDPIP,"none"))) {
//hostname is an ip address //hostname is an ip address
if (strchr(thisDetector->receiver_hostname,'.') != NULL) if (strchr(thisDetector->receiver_hostname,'.') != nullptr)
strcpy(thisDetector->receiverUDPIP, thisDetector->receiver_hostname); strcpy(thisDetector->receiverUDPIP, thisDetector->receiver_hostname);
//if hostname not ip, convert it to ip //if hostname not ip, convert it to ip
else { else {
@ -2408,9 +2408,9 @@ int slsDetector::setDynamicRange(int n) {
if (ret == FAIL) { if (ret == FAIL) {
// eiger: dr set correctly, consequent rate correction was a problem // eiger: dr set correctly, consequent rate correction was a problem
if ((thisDetector->myDetectorType == EIGER && if ((thisDetector->myDetectorType == EIGER &&
strstr(mess,"Rate Correction") != NULL)) { strstr(mess,"Rate Correction") != nullptr)) {
// rate correction is switched off if not 32 bit mode // rate correction is switched off if not 32 bit mode
if (strstr(mess,"32") != NULL) if (strstr(mess,"32") != nullptr)
setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT));
else else
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
@ -2848,7 +2848,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() {
FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size to receiver"; FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size to receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisReceiver->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectData(); disconnectData();
// handle ret // handle ret
@ -3004,7 +3004,7 @@ std::string slsDetector::setReceiver(std::string receiverIP) {
setAdditionalJsonHeader(getAdditionalJsonHeader()); setAdditionalJsonHeader(getAdditionalJsonHeader());
enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1)); enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1));
if (thisDetector->myDetectorType == GOTTHARD) if (thisDetector->myDetectorType == GOTTHARD)
sendROI(-1, NULL); sendROI(-1, nullptr);
} }
} }
return std::string(thisDetector->receiver_hostname); return std::string(thisDetector->receiver_hostname);
@ -3277,7 +3277,7 @@ int slsDetector::setUDPConnection() {
// if no udp ip given, use hostname // if no udp ip given, use hostname
if (!strcmp(thisDetector->receiverUDPIP, "none")) { if (!strcmp(thisDetector->receiverUDPIP, "none")) {
// hostname is an ip address // hostname is an ip address
if (strchr(thisDetector->receiver_hostname,'.') != NULL) if (strchr(thisDetector->receiver_hostname,'.') != nullptr)
strcpy(thisDetector->receiverUDPIP, thisDetector->receiver_hostname); strcpy(thisDetector->receiverUDPIP, thisDetector->receiver_hostname);
// if hostname not ip, convert it to ip // if hostname not ip, convert it to ip
else { else {
@ -3439,7 +3439,7 @@ int slsDetector::resetCounterBlock(int startACQ) {
FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ; FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -3505,7 +3505,7 @@ int slsDetector::setROI(int n,ROI roiLimits[]) {
slsDetectorDefs::ROI* slsDetector::getROI(int &n) { slsDetectorDefs::ROI* slsDetector::getROI(int &n) {
sendROI(-1,NULL); sendROI(-1,nullptr);
n = thisDetector->nROI; n = thisDetector->nROI;
if (thisDetector->myDetectorType == CHIPTESTBOARD) if (thisDetector->myDetectorType == CHIPTESTBOARD)
getTotalNumberOfChannels(); getTotalNumberOfChannels();
@ -3523,7 +3523,7 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) {
int ret = FAIL; int ret = FAIL;
int narg = n; int narg = n;
// send roiLimits if given, else from shm // send roiLimits if given, else from shm
ROI* arg = (roiLimits != NULL) ? roiLimits : thisDetector->roiLimits; ROI* arg = (roiLimits != nullptr) ? roiLimits : thisDetector->roiLimits;
int nretval = 0; int nretval = 0;
ROI retval[MAX_ROIS]; ROI retval[MAX_ROIS];
FILE_LOG(logDEBUG1) << "Sending ROI to detector" << narg; FILE_LOG(logDEBUG1) << "Sending ROI to detector" << narg;
@ -3623,7 +3623,7 @@ int slsDetector::writeAdcRegister(int addr, int val) {
addr << "data: 0x" << std::hex << val << std::dec; addr << "data: 0x" << std::hex << val << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), NULL, 0); ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -3837,7 +3837,7 @@ int slsDetector::pulsePixel(int n, int x, int y) {
x << "," << y << ")"; x << "," << y << ")";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), NULL, 0); ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -3858,7 +3858,7 @@ int slsDetector::pulsePixelNMove(int n, int x, int y) {
x << "," << y << ")"; x << "," << y << ")";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), NULL, 0); ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -3878,7 +3878,7 @@ int slsDetector::pulseChip(int n) {
FILE_LOG(logDEBUG1) << "Pulsing chip " << n << " number of times"; FILE_LOG(logDEBUG1) << "Pulsing chip " << n << " number of times";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -3990,7 +3990,7 @@ int slsDetector::programFPGA(std::string fname) {
} }
FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname; FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
size_t filesize = 0; size_t filesize = 0;
char* fpgasrc = NULL; char* fpgasrc = nullptr;
//check if it exists //check if it exists
{ {
@ -4005,7 +4005,7 @@ int slsDetector::programFPGA(std::string fname) {
{ {
// open src // open src
FILE* src = fopen(fname.c_str(),"rb"); FILE* src = fopen(fname.c_str(),"rb");
if (src == NULL) { if (src == nullptr) {
FILE_LOG(logERROR) << "Could not open source file for programming: " << fname; FILE_LOG(logERROR) << "Could not open source file for programming: " << fname;
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
return FAIL; return FAIL;
@ -4062,7 +4062,7 @@ int slsDetector::programFPGA(std::string fname) {
//loading dst file to memory //loading dst file to memory
FILE* fp = fopen(destfname,"r"); FILE* fp = fopen(destfname,"r");
if (fp == NULL) { if (fp == nullptr) {
FILE_LOG(logERROR) << "Could not open rawbin file"; FILE_LOG(logERROR) << "Could not open rawbin file";
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
return FAIL; return FAIL;
@ -4080,7 +4080,7 @@ int slsDetector::programFPGA(std::string fname) {
} }
rewind(fp); rewind(fp);
fpgasrc = (char*)malloc(filesize + 1); fpgasrc = (char*)malloc(filesize + 1);
if (fpgasrc == NULL) { if (fpgasrc == nullptr) {
FILE_LOG(logERROR) << "Could not allocate size of program"; FILE_LOG(logERROR) << "Could not allocate size of program";
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
return FAIL; return FAIL;
@ -4088,7 +4088,7 @@ int slsDetector::programFPGA(std::string fname) {
if (fread(fpgasrc, sizeof(char), filesize, fp) != filesize) { if (fread(fpgasrc, sizeof(char), filesize, fp) != filesize) {
FILE_LOG(logERROR) << "Could not read rawbin file"; FILE_LOG(logERROR) << "Could not read rawbin file";
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
if (fpgasrc != NULL) if (fpgasrc != nullptr)
free(fpgasrc); free(fpgasrc);
return FAIL; return FAIL;
} }
@ -4096,7 +4096,7 @@ int slsDetector::programFPGA(std::string fname) {
if (fclose(fp)) { if (fclose(fp)) {
FILE_LOG(logERROR) << "Could not close destination file after converting"; FILE_LOG(logERROR) << "Could not close destination file after converting";
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
if (fpgasrc != NULL) if (fpgasrc != nullptr)
free(fpgasrc); free(fpgasrc);
return FAIL; return FAIL;
} }
@ -4181,9 +4181,9 @@ int slsDetector::programFPGA(std::string fname) {
//check ending error //check ending error
if ((ret == FAIL) && if ((ret == FAIL) &&
(strstr(mess,"not implemented") == NULL) && (strstr(mess,"not implemented") == nullptr) &&
(strstr(mess,"locked") == NULL) && (strstr(mess,"locked") == nullptr) &&
(strstr(mess,"-update") == NULL)) { (strstr(mess,"-update") == nullptr)) {
controlSocket->ReceiveDataOnly(&ret, sizeof(ret)); controlSocket->ReceiveDataOnly(&ret, sizeof(ret));
if (ret == FAIL) { if (ret == FAIL) {
controlSocket->ReceiveDataOnly(mess, sizeof(mess)); controlSocket->ReceiveDataOnly(mess, sizeof(mess));
@ -4199,9 +4199,9 @@ int slsDetector::programFPGA(std::string fname) {
//remapping stop server //remapping stop server
if ((ret == FAIL) && if ((ret == FAIL) &&
(strstr(mess,"not implemented") == NULL) && (strstr(mess,"not implemented") == nullptr) &&
(strstr(mess,"locked") == NULL) && (strstr(mess,"locked") == nullptr) &&
(strstr(mess,"-update") == NULL)) { (strstr(mess,"-update") == nullptr)) {
fnum = F_RESET_FPGA; fnum = F_RESET_FPGA;
int stopret = FAIL; int stopret = FAIL;
if (connectStop() == OK) { if (connectStop() == OK) {
@ -4221,7 +4221,7 @@ int slsDetector::programFPGA(std::string fname) {
} }
//free resources //free resources
if (fpgasrc != NULL) if (fpgasrc != nullptr)
free(fpgasrc); free(fpgasrc);
return ret; return ret;
@ -4234,7 +4234,7 @@ int slsDetector::resetFPGA() {
FILE_LOG(logDEBUG1) << "Sending reset FPGA"; FILE_LOG(logDEBUG1) << "Sending reset FPGA";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -4332,7 +4332,7 @@ int slsDetector::setModule(sls_detector_module module, int tb) {
char mess[MAX_STR_LENGTH] = {0}; char mess[MAX_STR_LENGTH] = {0};
controlSocket->ReceiveDataOnly(mess,sizeof(mess)); controlSocket->ReceiveDataOnly(mess,sizeof(mess));
FILE_LOG(logERROR) << "Detector " << detId << " returned error: " << mess; FILE_LOG(logERROR) << "Detector " << detId << " returned error: " << mess;
if (strstr(mess,"default tau") != NULL) if (strstr(mess,"default tau") != nullptr)
setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED));
else else
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
@ -4381,15 +4381,15 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() {
FILE_LOG(logDEBUG1) << "Getting module"; FILE_LOG(logDEBUG1) << "Getting module";
sls_detector_module *myMod = createModule(); sls_detector_module *myMod = createModule();
if (myMod == NULL) { if (myMod == nullptr) {
FILE_LOG(logERROR) << "Could not create module"; FILE_LOG(logERROR) << "Could not create module";
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
return NULL; return nullptr;
} }
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum,NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum,nullptr, 0, nullptr, 0);
// handle ret // handle ret
if (ret == FAIL) { if (ret == FAIL) {
@ -4426,7 +4426,7 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() {
} }
} else { } else {
deleteModule(myMod); deleteModule(myMod);
myMod = NULL; myMod = nullptr;
} }
return myMod; return myMod;
} }
@ -4440,14 +4440,14 @@ int slsDetector::setRateCorrection(int64_t t) {
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
char mess[MAX_STR_LENGTH] = {0}; char mess[MAX_STR_LENGTH] = {0};
ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0, mess); ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), nullptr, 0, mess);
disconnectControl(); disconnectControl();
// handle ret // handle ret
if (ret == FAIL) { if (ret == FAIL) {
if (strstr(mess,"default tau")!=NULL) if (strstr(mess,"default tau")!=nullptr)
setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED));
if (strstr(mess,"32")!=NULL) if (strstr(mess,"32")!=nullptr)
setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT));
else else
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
@ -4465,7 +4465,7 @@ int64_t slsDetector::getRateCorrection() {
FILE_LOG(logDEBUG1) << "Getting rate correction"; FILE_LOG(logDEBUG1) << "Getting rate correction";
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisDetectorControl->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -4530,7 +4530,7 @@ std::string slsDetector::checkReceiverOnline() {
dataSocket->SetTimeOut(5); dataSocket->SetTimeOut(5);
thisDetector->receiverOnlineFlag = OFFLINE_FLAG; thisDetector->receiverOnlineFlag = OFFLINE_FLAG;
delete dataSocket; delete dataSocket;
dataSocket = 0; dataSocket = nullptr;
FILE_LOG(logDEBUG1) << "receiver " << detId << " offline!"; FILE_LOG(logDEBUG1) << "receiver " << detId << " offline!";
return std::string(thisDetector->receiver_hostname); return std::string(thisDetector->receiver_hostname);
} else { } else {
@ -4563,7 +4563,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver
strcpy(thisDetector->receiver_hostname, thisName); strcpy(thisDetector->receiver_hostname, thisName);
if (dataSocket) { if (dataSocket) {
delete dataSocket; delete dataSocket;
dataSocket = 0; dataSocket = nullptr;
} }
} }
@ -4576,7 +4576,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver
thisDetector->receiverTCPPort = thisRP; thisDetector->receiverTCPPort = thisRP;
if (dataSocket) { if (dataSocket) {
delete dataSocket; delete dataSocket;
dataSocket = 0; dataSocket = nullptr;
} }
} }
@ -4587,7 +4587,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver
FILE_LOG(logDEBUG1) << "Data socket connected " << thisName << " " << thisRP; FILE_LOG(logDEBUG1) << "Data socket connected " << thisName << " " << thisRP;
} catch(...) { } catch(...) {
FILE_LOG(logERROR) << "Could not connect Data socket " << thisName << " " << thisRP; FILE_LOG(logERROR) << "Could not connect Data socket " << thisName << " " << thisRP;
dataSocket = 0; dataSocket = nullptr;
ret = FAIL; ret = FAIL;
} }
} }
@ -4641,7 +4641,7 @@ std::string slsDetector::getReceiverLastClientIP() {
FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server"; FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisReceiver->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectData(); disconnectData();
// handle ret // handle ret
@ -4663,7 +4663,7 @@ int slsDetector::exitReceiver() {
FILE_LOG(logDEBUG1) << "Sending exit command to receiver server"; FILE_LOG(logDEBUG1) << "Sending exit command to receiver server";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisReceiver->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectData(); disconnectData();
// no ret handling as ret never fail // no ret handling as ret never fail
FILE_LOG(logINFO) << "Shutting down the receiver server"; FILE_LOG(logINFO) << "Shutting down the receiver server";
@ -4792,7 +4792,7 @@ int slsDetector::updateReceiver() {
FILE_LOG(logDEBUG1) << "Sending update client to receiver server"; FILE_LOG(logDEBUG1) << "Sending update client to receiver server";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisReceiver->Client_Send(fnum, nullptr, 0, nullptr, 0);
if (ret == FAIL) if (ret == FAIL)
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
else else
@ -5101,14 +5101,14 @@ int slsDetector::startReceiver() {
FILE_LOG(logDEBUG1) << "Starting Receiver"; FILE_LOG(logDEBUG1) << "Starting Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); ret = thisReceiver->Client_Send(fnum, nullptr, 0, nullptr, 0, mess);
disconnectData(); disconnectData();
// handle ret // handle ret
if (ret == FAIL) { if (ret == FAIL) {
if (strstr(mess,"UDP")!=NULL) if (strstr(mess,"UDP")!=nullptr)
setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET)); setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET));
else if (strstr(mess,"file")!=NULL) else if (strstr(mess,"file")!=nullptr)
setErrorMask((getErrorMask())|(COULDNOT_CREATE_FILE)); setErrorMask((getErrorMask())|(COULDNOT_CREATE_FILE));
else else
setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER)); setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER));
@ -5125,7 +5125,7 @@ int slsDetector::stopReceiver() {
FILE_LOG(logDEBUG1) << "Stopping Receiver"; FILE_LOG(logDEBUG1) << "Stopping Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisReceiver->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectData(); disconnectData();
// handle ret // handle ret
@ -5145,7 +5145,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() {
FILE_LOG(logDEBUG1) << "Getting Receiver Status"; FILE_LOG(logDEBUG1) << "Getting Receiver Status";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisReceiver->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectData(); disconnectData();
// handle ret // handle ret
@ -5168,7 +5168,7 @@ int slsDetector::getFramesCaughtByReceiver() {
FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver"; FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisReceiver->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectData(); disconnectData();
// handle ret // handle ret
@ -5191,7 +5191,7 @@ int slsDetector::getReceiverCurrentFrameIndex() {
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver"; FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); ret = thisReceiver->Client_Send(fnum, nullptr, 0, &retval, sizeof(retval));
disconnectData(); disconnectData();
// handle ret // handle ret
@ -5213,7 +5213,7 @@ int slsDetector::resetFramesCaught() {
FILE_LOG(logDEBUG1) << "Reset Frames Caught by Receiver"; FILE_LOG(logDEBUG1) << "Reset Frames Caught by Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisReceiver->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectData(); disconnectData();
// handle ret // handle ret
@ -5468,7 +5468,7 @@ int slsDetector::restreamStopFromReceiver() {
FILE_LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq"; FILE_LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisReceiver->Client_Send(fnum, nullptr, 0, nullptr, 0);
disconnectData(); disconnectData();
// handle ret // handle ret
@ -5613,14 +5613,14 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim(
if (thisDetector->myDetectorType != EIGER) { if (thisDetector->myDetectorType != EIGER) {
FILE_LOG(logERROR) << "Interpolation of Trim values not implemented for this detector!"; FILE_LOG(logERROR) << "Interpolation of Trim values not implemented for this detector!";
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
return NULL; return nullptr;
} }
sls_detector_module* myMod = createModule(thisDetector->myDetectorType); sls_detector_module* myMod = createModule(thisDetector->myDetectorType);
if (myMod == NULL) { if (myMod == nullptr) {
FILE_LOG(logERROR) << "Could not create module"; FILE_LOG(logERROR) << "Could not create module";
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
return NULL; return nullptr;
} }
enum eiger_DacIndex{SVP, VTR, VRF, VRS, SVN, VTGSTV, VCMP_LL, VCMP_LR, CAL, enum eiger_DacIndex{SVP, VTR, VRF, VRS, SVN, VTGSTV, VCMP_LL, VCMP_LR, CAL,
@ -5632,7 +5632,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim(
for (int i = 0; i < num_dacs_to_copy; ++i) { for (int i = 0; i < num_dacs_to_copy; ++i) {
if (a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { if (a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) {
deleteModule(myMod); deleteModule(myMod);
return NULL; return nullptr;
} }
myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]]; myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]];
} }
@ -5671,12 +5671,12 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
// flag creating module to delete later // flag creating module to delete later
bool modCreated = false; bool modCreated = false;
if (myMod == NULL) { if (myMod == nullptr) {
myMod = createModule(thisDetector->myDetectorType); myMod = createModule(thisDetector->myDetectorType);
if (myMod == NULL) { if (myMod == nullptr) {
FILE_LOG(logERROR) << "Could not create module"; FILE_LOG(logERROR) << "Could not create module";
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
return NULL; return nullptr;
} }
modCreated = true; modCreated = true;
@ -5709,7 +5709,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
default: default:
FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file"; FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file";
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
return NULL; return nullptr;
} }
@ -5724,7 +5724,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
if (modCreated) if (modCreated)
deleteModule(myMod); deleteModule(myMod);
return NULL; return nullptr;
} }
// eiger // eiger
@ -5752,7 +5752,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
if (modCreated) if (modCreated)
deleteModule(myMod); deleteModule(myMod);
infile.close(); infile.close();
return NULL; return nullptr;
} }
for(int i = 0; i < myMod->ndac; ++i) for(int i = 0; i < myMod->ndac; ++i)
FILE_LOG(logDEBUG1) << "dac " << i << ":" << myMod->dacs[i]; FILE_LOG(logDEBUG1) << "dac " << i << ":" << myMod->dacs[i];
@ -5788,7 +5788,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
if (modCreated) if (modCreated)
deleteModule(myMod); deleteModule(myMod);
infile.close(); infile.close();
return NULL; return nullptr;
} }
} }
// not all read // not all read
@ -5798,7 +5798,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
if (modCreated) if (modCreated)
deleteModule(myMod); deleteModule(myMod);
infile.close(); infile.close();
return NULL; return nullptr;
} }
} }

View File

@ -1081,7 +1081,7 @@ public:
* @param roiLimits array of roi * @param roiLimits array of roi
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int setROI(int n=-1,ROI roiLimits[]=NULL); int setROI(int n=-1,ROI roiLimits[]=nullptr);
/** /**
* Get ROI from each detector and convert it to the multi detector scale (Gotthard) * Get ROI from each detector and convert it to the multi detector scale (Gotthard)
@ -1103,7 +1103,7 @@ public:
* @param roiLimits ROI * @param roiLimits ROI
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int sendROI(int n=-1,ROI roiLimits[]=NULL); int sendROI(int n=-1,ROI roiLimits[]=nullptr);
/** /**
* Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users
@ -1165,7 +1165,7 @@ public:
* @param en array of energies * @param en array of energies
* @returns number of trim energies * @returns number of trim energies
*/ */
int setTrimEn(int nen, int *en=NULL); int setTrimEn(int nen, int *en=nullptr);
/** /**
* Returns the number of trim energies and their value (Eiger) * Returns the number of trim energies and their value (Eiger)
@ -1173,7 +1173,7 @@ public:
* @param en array of energies * @param en array of energies
* @returns number of trim energies * @returns number of trim energies
*/ */
int getTrimEn(int *en=NULL); int getTrimEn(int *en=nullptr);
/** /**
* Pulse Pixel (Eiger) * Pulse Pixel (Eiger)
@ -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=NULL, int tb=1); sls_detector_module* readSettingsFile(std::string fname, sls_detector_module* myMod=nullptr, int tb=1);
/** /**
* writes a trim/settings file * writes a trim/settings file