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