double* changed to char* in gui data call back, decoding to be done by caller. enablegappixels skeleton created

This commit is contained in:
Dhanya Maliakal 2017-09-29 16:43:19 +02:00
parent 1a8b0692fe
commit afc08f8c30
4 changed files with 17 additions and 72 deletions

View File

@ -282,8 +282,6 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
threadpool = 0;
if(createThreadPool() == FAIL)
exit(-1);
gainDataEnable = false;
}
multiSlsDetector::~multiSlsDetector() {
@ -5711,7 +5709,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
int multiSlsDetector::getData(const int isocket, int* image, const int size,
int multiSlsDetector::getData(const int isocket, char* image, const int size,
uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) {
//fail is on parse error or end of acquisition
@ -5786,18 +5784,6 @@ void multiSlsDetector::readFrameFromReceiver(){
}
int expectedslssize = slsdatabytes/numSocketsPerSLSDetector;
/*int* image = new int[(expectedslssize/sizeof(int))]();
int nel=(thisMultiDetector->dataBytes)/sizeof(int);
if(nel <= 0){
cprintf(RED,"Error: Multislsdetector databytes not valid : %d\n", thisMultiDetector->dataBytes);
return;
}
int* multiframe=new int[nel]();
int* multiframegain=NULL;
if (jungfrau)
multiframegain = new int[nel]();
*/
char* image = new char[expectedslssize]();
char* multiframe = new char[thisMultiDetector->dataBytes]();
char* multiframegain = NULL;
@ -5822,7 +5808,7 @@ void multiSlsDetector::readFrameFromReceiver(){
//exit when last message for each socket received
while(running){
memset(multiframe,0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors);/*memset(((char*)multiframe),0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors);*/ //reset frame memory
memset(multiframe,0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors); //reset frame memory
//get each frame
for(int isocket=0; isocket<numSockets; ++isocket){
@ -5830,7 +5816,7 @@ void multiSlsDetector::readFrameFromReceiver(){
//if running
if (runningList[isocket]) {
//get individual images
if(FAIL == getData(isocket, (int*)image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
if(FAIL == getData(isocket, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
runningList[isocket] = false;
--numRunning;
continue;
@ -5884,37 +5870,11 @@ void multiSlsDetector::readFrameFromReceiver(){
//send data to callback
if(running){
/*
if (jungfrau) {
// with gain data
if (gainDataEnable) {
memcpy(multiframegain, multiframe, nel * sizeof(int));
for(unsigned int i=0;i<nel;++i){
multiframegain[i] = ((multiframe[i] & 0xC0000000) >> 14) | ((multiframe[i] & 0x0000C000) >> 14) ;
multiframe[i] = (multiframe[i] & 0x3FFF3FFF);
}
gdata = decodeData(multiframegain,nch);
}
// without gain data
else {
for(unsigned int i=0;i<nel;++i)
multiframe[i] = (multiframe[i] & 0x3FFF3FFF);
}
}
fdata = decodeData(multiframe,nch);
if ((fdata) && (dataReady)){
thisData = new detectorData(fdata, NULL,NULL,getCurrentProgress(),currentFileName.c_str(),maxX,maxY, gdata);
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
delete thisData;
fdata = NULL;
gdata = NULL;
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
}
*/
if(dataReady) {
thisData = new detectorData(multiframe, thisMultiDetector->dataBytes, NULL,NULL,getCurrentProgress(),currentFileName.c_str(),maxX,maxY);
thisData = new detectorData(NULL,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),maxX,maxY,multiframe, thisMultiDetector->dataBytes);
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
delete thisData;
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
}
setCurrentProgress(currentAcquisitionIndex+1);
@ -6542,7 +6502,3 @@ bool multiSlsDetector::getExternalGuiFlag(){
return thisMultiDetector->externalgui;
}
void multiSlsDetector::setGainDataEnableinDataCallback(bool e) {
gainDataEnable = e;
}

View File

@ -1477,13 +1477,6 @@ class multiSlsDetector : public slsDetectorUtils {
*/
bool getExternalGuiFlag();
/**
* Set Gain Data enable for gain plot
* in data call back
* @param e enable
*/
void setGainDataEnableinDataCallback(bool e);
private:
@ -1498,7 +1491,7 @@ private:
* @param subframeIndex address of subframe index
* @param filename address of file name
*/
int getData(const int isocket, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename);
int getData(const int isocket, char* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename);
/** Ensures if sockets created successfully */
@ -1522,9 +1515,6 @@ private:
private:
ThreadPool* threadpool;
/** Gain Data enabled in data call back */
bool gainDataEnable;
};

View File

@ -18,28 +18,27 @@ class detectorData {
\param ny dimension in y (1D detector)
\param gval pointer to gain data (for jungfrau)
*/
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, double* gval=NULL) : cvalues(NULL), databytes(-1), values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), gvalues(gval){
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), cvalues(cval), databytes(dbytes), dgainvalues(NULL) {
strcpy(fileName,fname);
};
detectorData(char *val=NULL, int db=0, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, double* gval=NULL) : cvalues(val), databytes(db), values(NULL), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), gvalues(gval){
strcpy(fileName,fname);
};
/**
/**
@short The destructor
deletes also the arrays pointing to data/errors/angles if not NULL
*/
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if (gvalues) delete [] gvalues;};
cvalues are deleted by caller
*/
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if(dgainvalues) delete [] dgainvalues;};
//private:
char* cvalues;
int databytes;
double *values; /**< @short pointer to the data */
double *values; /**< @short pointer to the data as double array */
double *errors; /**< @short pointer to the errors */
double *angles;/**< @short pointer to the angles (NULL if no angular conversion) */
double progressIndex;/**< @short file index */
char fileName[1000];/**< @short file name */
int npoints;/**< @short number of points */
int npy;/**< @short dimensions in y coordinate*/
double *gvalues; /**< @short pointer to the gain data */
char* cvalues; /**< @short pointer to the data as char arary */
int databytes; /**< @short number of bytes of data. Used with cvalues */
double* dgainvalues; /**< @short pointer to gain data as double array */
};

View File

@ -332,7 +332,7 @@ s
double *fdata;
int (*dataReady)(detectorData*,int, int,void*);
int (*dataReady)(detectorData*,int, int, void*);
void *pCallbackArg;
detectorData *thisData;