removed the allocating of memory for eiger and jungfrau to receive data via tcp from detector as this will not happen

This commit is contained in:
Dhanya Maliakal
2016-12-02 12:47:01 +01:00
parent dd9387ef29
commit a67f9d50de
2 changed files with 38 additions and 30 deletions

View File

@ -1420,40 +1420,45 @@ int multiSlsDetector::startReadOut(){
int* multiSlsDetector::getDataFromDetector() { int* multiSlsDetector::getDataFromDetector() {
int nel=thisMultiDetector->dataBytes/sizeof(int); int nel=thisMultiDetector->dataBytes/sizeof(int);
int n; int n = 0;
int* retval=new int[nel]; int* retval= NULL;
int *retdet, *p=retval; int *retdet, *p=retval;
int nodata=1, nodatadet=-1;; int nodata=1, nodatadet=-1;
int nodatadetectortype = false;
detectorType types = getDetectorsType();
if(types == EIGER || types == JUNGFRAU){
nodatadetectortype = true;
}
if(!nodatadetectortype)
retval=new int[nel];
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) { for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
if (detectors[id]) { if (detectors[id]) {
retdet=detectors[id]->getDataFromDetector(p); retdet=detectors[id]->getDataFromDetector(p);
n=detectors[id]->getDataBytes();
if(detectors[id]->getErrorMask()) if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id)); setErrorMask(getErrorMask()|(1<<id));
if(!nodatadetectortype){
if (retdet) { n=detectors[id]->getDataBytes();
nodata=0; if (retdet) {
nodata=0;
#ifdef VERBOSE #ifdef VERBOSE
cout << "Detector " << id << " returned " << n << " bytes " << endl; cout << "Detector " << id << " returned " << n << " bytes " << endl;
#endif #endif
} else { } else {
nodatadet=id; nodatadet=id;
#ifdef VERBOSE #ifdef VERBOSE
cout << "Detector " << id << " does not have data left " << endl; cout << "Detector " << id << " does not have data left " << endl;
#endif #endif
/*if((detectors[id]->getDetectorsType() != EIGER)||(detectors[id]->getDetectorsType() != JUNGFRAU)) }
break;*/ p+=n/sizeof(int);
} }
p+=n/sizeof(int);
} }
} }
//eiger returns only null //eiger returns only null
detectorType types = getDetectorsType(); if(nodatadetectortype){
if(types == EIGER || types == JUNGFRAU){
delete [] retval;
return NULL; return NULL;
} }

View File

@ -3807,19 +3807,21 @@ int* slsDetector::readFrame(){
int* slsDetector::getDataFromDetector(int *retval){ int* slsDetector::getDataFromDetector(int *retval){
int nel=thisDetector->dataBytes/sizeof(int);
int n;
int *r=retval;
// int* retval=new int[nel];
if (retval==NULL)
retval=new int[nel];
int ret=FAIL; int ret=FAIL;
char mess[MAX_STR_LENGTH]="Nothing"; char mess[MAX_STR_LENGTH]="Nothing";
int nel=thisDetector->dataBytes/sizeof(int);
int n;
int *r=retval;
int nodatadetectortype = false;
detectorType types = getDetectorsType();
if(types == EIGER || types == JUNGFRAU){
nodatadetectortype = true;
}
if (!nodatadetectortype && retval==NULL)
retval=new int[nel];
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl; std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
@ -3841,11 +3843,12 @@ int* slsDetector::getDataFromDetector(int *retval){
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl; std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
#endif #endif
} }
if (r==NULL) { if ((!nodatadetectortype) && (r==NULL)){
delete [] retval; delete [] retval;
} }
return NULL; return NULL;
} else { } else if (!nodatadetectortype){
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes); n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
#ifdef VERBOSE #ifdef VERBOSE