mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-09 03:20:42 +02:00
format and removed nullptr check before delete
This commit is contained in:
parent
b74aed91dc
commit
d2ed245d1d
@ -2,20 +2,20 @@
|
|||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#include "ZmqSocket.h"
|
#include "ZmqSocket.h"
|
||||||
#include "detectorData.h"
|
#include "detectorData.h"
|
||||||
|
#include "file_utils.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "multiSlsDetectorClient.h"
|
#include "multiSlsDetectorClient.h"
|
||||||
#include "slsDetectorCommand.h"
|
|
||||||
#include "slsDetector.h"
|
#include "slsDetector.h"
|
||||||
|
#include "slsDetectorCommand.h"
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
#include "file_utils.h"
|
|
||||||
|
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <rapidjson/document.h> //json header in zmq stream
|
#include <rapidjson/document.h> //json header in zmq stream
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstring>
|
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -45,8 +45,6 @@ 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...),
|
||||||
typename NonDeduced<CT>::type... Args) {
|
typename NonDeduced<CT>::type... Args) {
|
||||||
@ -323,8 +321,8 @@ void multiSlsDetector::initSharedMemory(bool verify) {
|
|||||||
(sharedMultiSlsDetector *)sharedMemory->OpenSharedMemory(sz);
|
(sharedMultiSlsDetector *)sharedMemory->OpenSharedMemory(sz);
|
||||||
if (verify && thisMultiDetector->shmversion != MULTI_SHMVERSION) {
|
if (verify && thisMultiDetector->shmversion != MULTI_SHMVERSION) {
|
||||||
FILE_LOG(logERROR) << "Multi shared memory (" << detId << ") version mismatch "
|
FILE_LOG(logERROR) << "Multi shared memory (" << detId << ") version mismatch "
|
||||||
"(expected 0x" << std::hex << MULTI_SHMVERSION <<
|
"(expected 0x"
|
||||||
" but got 0x" << thisMultiDetector->shmversion << std::dec;
|
<< std::hex << MULTI_SHMVERSION << " but got 0x" << thisMultiDetector->shmversion << std::dec;
|
||||||
throw SharedMemoryException();
|
throw SharedMemoryException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -517,7 +515,6 @@ std::string multiSlsDetector::getDetectorTypeAsString(int detPos) {
|
|||||||
return sls::concatenateIfDifferent(r);
|
return sls::concatenateIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::getNumberOfDetectors() const {
|
int multiSlsDetector::getNumberOfDetectors() const {
|
||||||
return detectors.size();
|
return detectors.size();
|
||||||
}
|
}
|
||||||
@ -601,10 +598,7 @@ void multiSlsDetector::updateOffsets() {
|
|||||||
thisMultiDetector->numberOfChannelInclGapPixels[Y] = 0;
|
thisMultiDetector->numberOfChannelInclGapPixels[Y] = 0;
|
||||||
|
|
||||||
for (size_t idet = 0; idet < detectors.size(); ++idet) {
|
for (size_t idet = 0; idet < detectors.size(); ++idet) {
|
||||||
FILE_LOG(logDEBUG1) << "offsetX:" << offsetX << " prevChanX:" << prevChanX <<
|
FILE_LOG(logDEBUG1) << "offsetX:" << offsetX << " prevChanX:" << prevChanX << " offsetY:" << offsetY << " prevChanY:" << prevChanY << " offsetX_gp:" << offsetX_gp << " prevChanX_gp:" << prevChanX_gp << " offsetY_gp:" << offsetY_gp << " prevChanY_gp:" << prevChanY_gp;
|
||||||
" offsetY:" << offsetY << " prevChanY:" << prevChanY <<
|
|
||||||
" offsetX_gp:" << offsetX_gp << " prevChanX_gp:" << prevChanX_gp <<
|
|
||||||
" offsetY_gp:" << offsetY_gp << " prevChanY_gp:" << prevChanY_gp;
|
|
||||||
|
|
||||||
// incrementing in both direction
|
// incrementing in both direction
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
@ -708,14 +702,7 @@ void multiSlsDetector::updateOffsets() {
|
|||||||
if (numY_gp > thisMultiDetector->numberOfChannelInclGapPixels[Y])
|
if (numY_gp > thisMultiDetector->numberOfChannelInclGapPixels[Y])
|
||||||
thisMultiDetector->numberOfChannelInclGapPixels[Y] = numY_gp;
|
thisMultiDetector->numberOfChannelInclGapPixels[Y] = numY_gp;
|
||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG1) << "\n\tNumber of Channels in X direction:" <<
|
FILE_LOG(logDEBUG1) << "\n\tNumber of Channels in X direction:" << thisMultiDetector->numberOfChannel[X] << "\n\tNumber of Channels in Y direction:" << thisMultiDetector->numberOfChannel[Y] << "\n\tNumber of Channels in X direction with Gap Pixels:" << thisMultiDetector->numberOfChannelInclGapPixels[X] << "\n\tNumber of Channels in Y direction with Gap Pixels:" << thisMultiDetector->numberOfChannelInclGapPixels[Y];
|
||||||
thisMultiDetector->numberOfChannel[X] <<
|
|
||||||
"\n\tNumber of Channels in Y direction:" <<
|
|
||||||
thisMultiDetector->numberOfChannel[Y] <<
|
|
||||||
"\n\tNumber of Channels in X direction with Gap Pixels:" <<
|
|
||||||
thisMultiDetector->numberOfChannelInclGapPixels[X] <<
|
|
||||||
"\n\tNumber of Channels in Y direction with Gap Pixels:" <<
|
|
||||||
thisMultiDetector->numberOfChannelInclGapPixels[Y];
|
|
||||||
|
|
||||||
thisMultiDetector->numberOfChannels =
|
thisMultiDetector->numberOfChannels =
|
||||||
thisMultiDetector->numberOfChannel[0] *
|
thisMultiDetector->numberOfChannel[0] *
|
||||||
@ -2039,9 +2026,8 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) {
|
|||||||
|
|
||||||
// check roi max values
|
// check roi max values
|
||||||
idet = decodeNChannel(xmax, ymax, channelX, channelY);
|
idet = decodeNChannel(xmax, ymax, channelX, channelY);
|
||||||
FILE_LOG(logDEBUG1) << "Decoded Channel max vals: " << std::endl <<
|
FILE_LOG(logDEBUG1) << "Decoded Channel max vals: " << std::endl
|
||||||
"det:" << idet << "\t" << xmax << "\t" << ymax << "\t" <<
|
<< "det:" << idet << "\t" << xmax << "\t" << ymax << "\t" << channelX << "\t" << channelY;
|
||||||
channelX << "\t" << channelY;
|
|
||||||
if (idet == -1) {
|
if (idet == -1) {
|
||||||
FILE_LOG(logERROR) << "invalid roi";
|
FILE_LOG(logERROR) << "invalid roi";
|
||||||
continue;
|
continue;
|
||||||
@ -2055,9 +2041,8 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) {
|
|||||||
while (ymin <= ymax) {
|
while (ymin <= ymax) {
|
||||||
// get offset for each detector
|
// get offset for each detector
|
||||||
idet = decodeNChannel(xmin, ymin, channelX, channelY);
|
idet = decodeNChannel(xmin, ymin, channelX, channelY);
|
||||||
FILE_LOG(logDEBUG1) << "Decoded Channel min vals: " << std::endl <<
|
FILE_LOG(logDEBUG1) << "Decoded Channel min vals: " << std::endl
|
||||||
"det:" << idet << "\t" << xmin << "\t" << ymin <<
|
<< "det:" << idet << "\t" << xmin << "\t" << ymin << "\t" << channelX << "\t" << channelY;
|
||||||
"\t" << channelX << "\t" << channelY;
|
|
||||||
if (idet < 0 || idet >= (int)detectors.size()) {
|
if (idet < 0 || idet >= (int)detectors.size()) {
|
||||||
FILE_LOG(logDEBUG1) << "invalid roi";
|
FILE_LOG(logDEBUG1) << "invalid roi";
|
||||||
invalidroi = true;
|
invalidroi = true;
|
||||||
@ -2082,8 +2067,8 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) {
|
|||||||
if ((offsetY + lastChannelY) >= ymax)
|
if ((offsetY + lastChannelY) >= ymax)
|
||||||
lastChannelY = ymax - offsetY;
|
lastChannelY = ymax - offsetY;
|
||||||
|
|
||||||
FILE_LOG(logDEBUG1) << "lastChannelX:" << lastChannelX << "\t" <<
|
FILE_LOG(logDEBUG1) << "lastChannelX:" << lastChannelX << "\t"
|
||||||
"lastChannelY:" << lastChannelY;
|
<< "lastChannelY:" << lastChannelY;
|
||||||
|
|
||||||
// creating the list of roi for corresponding detector
|
// creating the list of roi for corresponding detector
|
||||||
index = nroi[idet];
|
index = nroi[idet];
|
||||||
@ -2173,7 +2158,6 @@ slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
|
|||||||
<< roiLimits[j].ymin << "\t" << roiLimits[j].ymax;
|
<< roiLimits[j].ymin << "\t" << roiLimits[j].ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// combine all the adjacent rois in x direction
|
// combine all the adjacent rois in x direction
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
// since the ones combined are replaced by -1
|
// since the ones combined are replaced by -1
|
||||||
@ -2886,8 +2870,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
|
|||||||
->getClientStreamingIP()
|
->getClientStreamingIP()
|
||||||
.c_str(),
|
.c_str(),
|
||||||
portnum));
|
portnum));
|
||||||
FILE_LOG(logINFO) << "Zmq Client[" << iSocket << "] at " <<
|
FILE_LOG(logINFO) << "Zmq Client[" << iSocket << "] at " << zmqSocket.back()->GetZmqServerAddress();
|
||||||
zmqSocket.back()->GetZmqServerAddress();
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum;
|
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum;
|
||||||
createReceivingDataSockets(true);
|
createReceivingDataSockets(true);
|
||||||
@ -2989,14 +2972,9 @@ void multiSlsDetector::readFrameFromReceiver() {
|
|||||||
nPixelsX = doc["shape"][0].GetUint();
|
nPixelsX = doc["shape"][0].GetUint();
|
||||||
nPixelsY = doc["shape"][1].GetUint();
|
nPixelsY = doc["shape"][1].GetUint();
|
||||||
|
|
||||||
FILE_LOG(logDEBUG1) <<
|
FILE_LOG(logDEBUG1) << "One Time Header Info:"
|
||||||
"One Time Header Info:"
|
"\n\tsize: "
|
||||||
"\n\tsize: " << size <<
|
<< size << "\n\tmultisize: " << multisize << "\n\tdynamicRange: " << dynamicRange << "\n\tbytesPerPixel: " << bytesPerPixel << "\n\tnPixelsX: " << nPixelsX << "\n\tnPixelsY: " << nPixelsY;
|
||||||
"\n\tmultisize: " << multisize <<
|
|
||||||
"\n\tdynamicRange: " << dynamicRange <<
|
|
||||||
"\n\tbytesPerPixel: " << bytesPerPixel <<
|
|
||||||
"\n\tnPixelsX: " << nPixelsX <<
|
|
||||||
"\n\tnPixelsY: " << nPixelsY;
|
|
||||||
}
|
}
|
||||||
// each time, parse rest of header
|
// each time, parse rest of header
|
||||||
currentFileName = doc["fname"].GetString();
|
currentFileName = doc["fname"].GetString();
|
||||||
@ -3009,16 +2987,9 @@ void multiSlsDetector::readFrameFromReceiver() {
|
|||||||
if (eiger)
|
if (eiger)
|
||||||
coordY = (nY - 1) - coordY;
|
coordY = (nY - 1) - coordY;
|
||||||
flippedDataX = doc["flippedDataX"].GetUint();
|
flippedDataX = doc["flippedDataX"].GetUint();
|
||||||
FILE_LOG(logDEBUG1) <<
|
FILE_LOG(logDEBUG1) << "Header Info:"
|
||||||
"Header Info:"
|
"\n\tcurrentFileName: "
|
||||||
"\n\tcurrentFileName: " << currentFileName <<
|
<< currentFileName << "\n\tcurrentAcquisitionIndex: " << currentAcquisitionIndex << "\n\tcurrentFrameIndex: " << currentFrameIndex << "\n\tcurrentFileIndex: " << currentFileIndex << "\n\tcurrentSubFrameIndex: " << currentSubFrameIndex << "\n\tcoordX: " << coordX << "\n\tcoordY: " << coordY << "\n\tflippedDataX: " << flippedDataX;
|
||||||
"\n\tcurrentAcquisitionIndex: " << currentAcquisitionIndex <<
|
|
||||||
"\n\tcurrentFrameIndex: " << currentFrameIndex <<
|
|
||||||
"\n\tcurrentFileIndex: " << currentFileIndex <<
|
|
||||||
"\n\tcurrentSubFrameIndex: " << currentSubFrameIndex <<
|
|
||||||
"\n\tcoordX: " << coordX <<
|
|
||||||
"\n\tcoordY: " << coordY <<
|
|
||||||
"\n\tflippedDataX: " << flippedDataX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DATA
|
// DATA
|
||||||
@ -3031,12 +3002,9 @@ void multiSlsDetector::readFrameFromReceiver() {
|
|||||||
uint32_t yoffset = coordY * nPixelsY;
|
uint32_t yoffset = coordY * nPixelsY;
|
||||||
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
|
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
|
||||||
uint32_t rowoffset = nX * singledetrowoffset;
|
uint32_t rowoffset = nX * singledetrowoffset;
|
||||||
FILE_LOG(logDEBUG1) <<
|
FILE_LOG(logDEBUG1) << "Multi Image Info:"
|
||||||
"Multi Image Info:"
|
"\n\txoffset: "
|
||||||
"\n\txoffset: " << xoffset <<
|
<< xoffset << "\n\tyoffset: " << yoffset << "\n\tsingledetrowoffset: " << singledetrowoffset << "\n\trowoffset: " << rowoffset;
|
||||||
"\n\tyoffset: " << yoffset <<
|
|
||||||
"\n\tsingledetrowoffset: " << singledetrowoffset <<
|
|
||||||
"\n\trowoffset: " << rowoffset;
|
|
||||||
|
|
||||||
if (eiger && flippedDataX) {
|
if (eiger && flippedDataX) {
|
||||||
for (uint32_t i = 0; i < nPixelsY; ++i) {
|
for (uint32_t i = 0; i < nPixelsY; ++i) {
|
||||||
@ -3111,11 +3079,8 @@ void multiSlsDetector::readFrameFromReceiver() {
|
|||||||
zmqSocket[i]->Disconnect();
|
zmqSocket[i]->Disconnect();
|
||||||
|
|
||||||
// free resources
|
// free resources
|
||||||
if (image != nullptr)
|
|
||||||
delete[] image;
|
delete[] image;
|
||||||
if (multiframe != nullptr)
|
|
||||||
delete[] multiframe;
|
delete[] multiframe;
|
||||||
if (multigappixels != nullptr)
|
|
||||||
delete[] multigappixels;
|
delete[] multigappixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3456,7 +3421,8 @@ int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
|
|||||||
iline++;
|
iline++;
|
||||||
FILE_LOG(logDEBUG1) << str;
|
FILE_LOG(logDEBUG1) << str;
|
||||||
if (str.find('#') != std::string::npos) {
|
if (str.find('#') != std::string::npos) {
|
||||||
FILE_LOG(logDEBUG1) << "Line is a comment \n" << str;
|
FILE_LOG(logDEBUG1) << "Line is a comment \n"
|
||||||
|
<< str;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
std::istringstream ssstr(str);
|
std::istringstream ssstr(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user