shadowing variables

This commit is contained in:
Erik Frojdh 2019-04-05 17:01:29 +02:00
parent cbacf471d6
commit 33f726ff7e
6 changed files with 73 additions and 75 deletions

View File

@ -2293,7 +2293,7 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
// multi // multi
n = 0; n = 0;
int num = 0, i, j; int num = 0;
int ndet = detectors.size(); int ndet = detectors.size();
int maxroi = ndet * MAX_ROIS; int maxroi = ndet * MAX_ROIS;
ROI temproi; ROI temproi;
@ -2309,7 +2309,7 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
if (index) { if (index) {
FILE_LOG(logINFO) << "detector " << idet << ":"; FILE_LOG(logINFO) << "detector " << idet << ":";
} }
for (j = 0; j < index; ++j) { for (int j = 0; j < index; ++j) {
FILE_LOG(logINFO) << temp[j].xmin << "\t" << temp[j].xmax << "\t" << temp[j].ymin FILE_LOG(logINFO) << temp[j].xmin << "\t" << temp[j].xmax << "\t" << temp[j].ymin
<< "\t" << temp[j].ymax; << "\t" << temp[j].ymax;
int x = detectors[idet]->getDetectorOffset(X); int x = detectors[idet]->getDetectorOffset(X);
@ -2335,12 +2335,12 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
} }
// combine all the adjacent rois in x direction // combine all the adjacent rois in x direction
for (i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
// since the ones combined are replaced by -1 // since the ones combined are replaced by -1
if ((roiLimits[i].xmin) == -1) { if ((roiLimits[i].xmin) == -1) {
continue; continue;
} }
for (j = i + 1; j < n; ++j) { for (int j = i + 1; j < n; ++j) {
// since the ones combined are replaced by -1 // since the ones combined are replaced by -1
if ((roiLimits[j].xmin) == -1) { if ((roiLimits[j].xmin) == -1) {
continue; continue;
@ -2368,19 +2368,19 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
} }
} }
FILE_LOG(logDEBUG1) << "Combined along x axis Getting ROI :\ndetector " << i; FILE_LOG(logDEBUG1) << "Combined along x axis Getting ROI :\ndetector " << n;
for (int j = 0; j < n; ++j) { for (int j = 0; j < n; ++j) {
FILE_LOG(logDEBUG1) << roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t" FILE_LOG(logDEBUG1) << roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t"
<< roiLimits[j].ymin << "\t" << roiLimits[j].ymax; << roiLimits[j].ymin << "\t" << roiLimits[j].ymax;
} }
// combine all the adjacent rois in y direction // combine all the adjacent rois in y direction
for (i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
// since the ones combined are replaced by -1 // since the ones combined are replaced by -1
if ((roiLimits[i].ymin) == -1) { if ((roiLimits[i].ymin) == -1) {
continue; continue;
} }
for (j = i + 1; j < n; ++j) { for (int j = i + 1; j < n; ++j) {
// since the ones combined are replaced by -1 // since the ones combined are replaced by -1
if ((roiLimits[j].ymin) == -1) { if ((roiLimits[j].ymin) == -1) {
continue; continue;
@ -2409,15 +2409,15 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
} }
// get rid of -1s // get rid of -1s
for (i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
if ((roiLimits[i].xmin) != -1) { if ((roiLimits[i].xmin) != -1) {
retval[num] = roiLimits[i]; retval[num] = roiLimits[i];
++num; ++num;
} }
} }
// sort final roi // sort final roi
for (i = 0; i < num; ++i) { for (int i = 0; i < num; ++i) {
for (j = i + 1; j < num; ++j) { for (int j = i + 1; j < num; ++j) {
if (retval[j].xmin < retval[i].xmin) { if (retval[j].xmin < retval[i].xmin) {
temproi = retval[i]; temproi = retval[i];
retval[i] = retval[j]; retval[i] = retval[j];
@ -2428,7 +2428,7 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
n = num; n = num;
FILE_LOG(logDEBUG1) << "\nxmin\txmax\tymin\tymax"; FILE_LOG(logDEBUG1) << "\nxmin\txmax\tymin\tymax";
for (i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
FILE_LOG(logDEBUG1) << retval[i].xmin << "\t" << retval[i].xmax << "\t" << retval[i].ymin FILE_LOG(logDEBUG1) << retval[i].xmin << "\t" << retval[i].xmax << "\t" << retval[i].ymin
<< "\t" << retval[i].ymax; << "\t" << retval[i].ymax;
} }
@ -2525,8 +2525,8 @@ int multiSlsDetector::enableGapPixels(int val, int detPos) {
// update data bytes incl gap pixels // update data bytes incl gap pixels
if (val != -1) { if (val != -1) {
auto r = serialCall(&slsDetector::getDataBytesInclGapPixels); auto r2 = serialCall(&slsDetector::getDataBytesInclGapPixels);
multi_shm()->dataBytesInclGapPixels = sls::sum(r); multi_shm()->dataBytesInclGapPixels = sls::sum(r2);
// update // update
updateOffsets(); updateOffsets();

View File

@ -2553,7 +2553,7 @@ std::string slsDetector::setAdditionalJsonParameter(const std::string &key,
std::string slsDetector::getAdditionalJsonParameter(const std::string &key) { std::string slsDetector::getAdditionalJsonParameter(const std::string &key) {
// additional json header is empty // additional json header is empty
if (!strlen(detector_shm()->receiver_additionalJsonHeader)) if (!strlen(detector_shm()->receiver_additionalJsonHeader))
return std::string(""); return std::string();
// add quotations before and after the key value // add quotations before and after the key value
std::string keyLiteral = key; std::string keyLiteral = key;
@ -2575,7 +2575,7 @@ std::string slsDetector::getAdditionalJsonParameter(const std::string &key) {
} }
// return empty string as no match found with key // return empty string as no match found with key
return std::string(""); return std::string();
} }
int64_t slsDetector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize) { int64_t slsDetector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize) {

View File

@ -106,8 +106,8 @@ TEST_CASE("Set ROI", "[detector]") {
slsDetector d(slsDetectorDefs::detectorType::EIGER, 0, 0); slsDetector d(slsDetectorDefs::detectorType::EIGER, 0, 0);
int n{0}; int n{0};
auto res = d.getROI(n); d.getROI(n);
// CHECK(n == 0); CHECK(n == 0);
CHECK(d.getNRoi() == 0); CHECK(d.getNRoi() == 0);
// set one ROI // set one ROI

View File

@ -472,38 +472,38 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
* @param i ROI * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
int setROI(const std::vector<ROI> i); int setROI(const std::vector<ROI> new_roi);
/** /**
* Set the streaming frequency * Set the streaming frequency
* @param freq 0 for timer, n for nth frame frequency * @param freq 0 for timer, n for nth frame frequency
* @return OK or FAIL * @return OK or FAIL
*/ */
int setStreamingFrequency(const uint32_t freq); int setStreamingFrequency(const uint32_t freq);
/** /**
* Sets the timer between frames streamed when frequency is set to 0 * Sets the timer between frames streamed when frequency is set to 0
* @param time_in_ms timer between frames streamed * @param time_in_ms timer between frames streamed
*/ */
void setStreamingTimer(const uint32_t time_in_ms); void setStreamingTimer(const uint32_t time_in_ms);
/** /**
* Set the data stream enable * Set the data stream enable
* @param enable data stream enable * @param enable data stream enable
* @return OK or FAIL * @return OK or FAIL
*/ */
int setDataStreamEnable(const bool enable); int setDataStreamEnable(const bool enable);
/** /**
* Set streaming port * Set streaming port
* @param i streaming port * @param i streaming port
*/ */
void setStreamingPort(const uint32_t i); void setStreamingPort(const uint32_t i);
/** /**
* Set streaming source ip * Set streaming source ip
* @param c streaming source ip * @param c streaming source ip
*/ */
void setStreamingSourceIP(const char* c); void setStreamingSourceIP(const char *c);
/** /**
* Set additional json header * Set additional json header

View File

@ -737,40 +737,38 @@ int slsReceiverImplementation::setUDPSocketBufferSize(const int64_t s) {
/***acquisition parameters***/ /***acquisition parameters***/
int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i) { int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> new_roi) {
bool change = false; bool change = false;
if (roi.size() != i.size()) if (roi.size() != new_roi.size())
change = true; change = true;
else { else {
for (unsigned int iloop = 0; iloop < i.size(); ++iloop) { for (size_t i = 0; i != new_roi.size(); ++i) {
if ( if ((roi[i].xmin != new_roi[i].xmin) ||
(roi[iloop].xmin != i[iloop].xmin) || (roi[i].xmax != new_roi[i].xmax) ||
(roi[iloop].xmax != i[iloop].xmax) || (roi[i].ymin != new_roi[i].ymin) ||
(roi[iloop].ymin != i[iloop].ymin) || (roi[i].xmax != new_roi[i].xmax)) {
(roi[iloop].xmax != i[iloop].xmax)) { change = true;
change = true; break;
break; }
}
} }
} }
if (change) { if (change) {
roi = new_roi;
roi = i; switch (myDetectorType) {
case GOTTHARD:
switch(myDetectorType) { generalData->SetROI(new_roi);
case GOTTHARD: framesPerFile = generalData->maxFramesPerFile;
generalData->SetROI(i); break;
framesPerFile = generalData->maxFramesPerFile; case MOENCH:
break; generalData->setImageSize(roi, numberOfSamples, tengigaEnable);
case MOENCH: break;
generalData->setImageSize(roi, numberOfSamples, tengigaEnable); case CHIPTESTBOARD:
break; generalData->setImageSize(roi, numberOfSamples, tengigaEnable,
case CHIPTESTBOARD: readoutFlags);
generalData->setImageSize(roi, numberOfSamples, tengigaEnable, readoutFlags); break;
break; default:
default: break;
break;
} }
for (const auto& it : dataProcessor) for (const auto& it : dataProcessor)
it->SetPixelDimension(); it->SetPixelDimension();
@ -784,7 +782,7 @@ int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i)
if (!roi.size()) if (!roi.size())
sstm << "0"; sstm << "0";
else { else {
for (unsigned int i = 0; i < roi.size(); ++i) { for (size_t i = 0; i < roi.size(); ++i) {
sstm << "( " << sstm << "( " <<
roi[i].xmin << ", " << roi[i].xmin << ", " <<
roi[i].xmax << ", " << roi[i].xmax << ", " <<

View File

@ -789,7 +789,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
receiver->setUDPPortNumber2(port2); receiver->setUDPPortNumber2(port2);
FILE_LOG(logINFO) << "Receiver UDP IP 2: " << ip2; FILE_LOG(logINFO) << "Receiver UDP IP 2: " << ip2;
// get eth // get eth
std::string temp = genericSocket::ipToName(ip2); temp = genericSocket::ipToName(ip2);
if (temp == "none"){ if (temp == "none"){
ret = FAIL; ret = FAIL;
strcpy(mess, "Failed to get 2nd ethernet interface or IP \n"); strcpy(mess, "Failed to get 2nd ethernet interface or IP \n");