From 79d5a24af40d0292bb1cdfcdeb6eac074cd4a60c Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Fri, 4 Nov 2016 12:02:37 +0100 Subject: [PATCH] debugging --- .../multiSlsDetector/multiSlsDetector.cpp | 62 ++++++++++++++----- .../multiSlsDetector/multiSlsDetector.h | 2 +- slsDetectorSoftware/slsDetector/slsDetector.h | 2 +- .../slsDetectorAnalysis/detectorData.h | 4 +- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 89fbf951a..4a5e87ce3 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2231,17 +2231,18 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){ double* multiSlsDetector::decodeData(int *datain, double *fdata) { double *dataout; + cprintf(GREEN,"numchanensl:%d\n",thisMultiDetector->numberOfChannels); + if (fdata) dataout=fdata; else dataout=new double[thisMultiDetector->numberOfChannels]; - + // int ich=0; double *detp=dataout; int *datap=datain; - for (int i=0; inumberOfDetectors; i++) { if (detectors[i]) { detectors[i]->decodeData(datap, detp); @@ -5100,8 +5101,24 @@ void multiSlsDetector::startReceivingDataThread(){ int ithread = currentThreadIndex; //set current thread value index + char hostname[100] = "tcp://"; + + char rx_hostname[100]; + strcpy(rx_hostname, detectors[ithread]->getReceiver()); + cout<<"rx_hostname:"<h_addr)); + } + strcat(hostname,":"); //server details - char hostname[100] = "tcp://127.0.0.1:"; + //char hostname[100] = "tcp://127.0.0.1:"; int portno = DEFAULT_ZMQ_PORTNO + ithread; sprintf(hostname,"%s%d",hostname,portno); @@ -5113,7 +5130,7 @@ void multiSlsDetector::startReceivingDataThread(){ zmqsocket = zmq_socket(context, ZMQ_PULL); //int hwmval = 10; //zmq_setsockopt(zmqsocket,ZMQ_RCVHWM,&hwmval,sizeof(hwmval)); //set receive HIGH WATER MARK (8-9ms slower//should not drop last packets) - zmq_connect(zmqsocket, hostname); + cprintf(RED,"connect ret:%d\n",zmq_connect(zmqsocket, hostname)); cout << "ZMQ Client of " << ithread << " at " << hostname << endl; cprintf(BLUE,"%d Created socket\n",ithread); @@ -5124,6 +5141,7 @@ void multiSlsDetector::startReceivingDataThread(){ int expectedsize = 1024*256;/**shouldnt work for other bit modes or anythign*/ if(getDetectorsType() == EIGER){ numReadoutPerDetector = 2; + expectedsize = 1024*256; }else if(getDetectorsType() == JUNGFRAU){ jungfrau = true; expectedsize = 8192*128; @@ -5149,6 +5167,7 @@ void multiSlsDetector::startReceivingDataThread(){ //scan header------------------------------------------------------------------- zmq_msg_init (&message); + cprintf(BLUE,"waiting to listen to header\n"); len = zmq_msg_recv(&message, zmqsocket, 0); if (len == -1) { cprintf(BG_RED,"Could not read header for socket %d\n",ithread); @@ -5160,7 +5179,7 @@ void multiSlsDetector::startReceivingDataThread(){ // error if you print it // cout << ithread << " header len:"<numberOfDetectors; //initializing variables - strcpy(currentFileName,""); + currentFileName=""; currentAcquisitionIndex = -1; currentFrameIndex = -1; currentSubFrameIndex = -1; @@ -5362,7 +5381,20 @@ void multiSlsDetector::readFrameFromReceiver(){ //send data to callback fdata = decodeData(multiframe); if ((fdata) && (dataReady)){ - thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName,nx,ny); + //cprintf(BLUE,"progress:%d\n",getCurrentProgress()); + //cprintf(BLUE,"f:%d\n",currentFrameIndex); + //cprintf(BLUE,"progress:%d\n",getCurrentProgress()); + + // cprintf(BLUE,"filename:%s\n",currentFileName); + + //cprintf(BLUE,"progress:%d\n",getCurrentProgress()); + //cprintf(BLUE,"f:%d\n",currentFrameIndex); + currentFileName = "/external_pool/jungfrau_data/softwaretest/dhanya/run_f000000000000_0.raw"; + thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny); + //cprintf(BLUE,"progress:%d\n",getCurrentProgress()); + // cprintf(BLUE,"f:%d\n",currentFrameIndex); + //cprintf(BLUE,"progress:%d\n",getCurrentProgress()); + //cprintf(BLUE,"filenameeeeeeeeeee:%s\n",thisData->fileName); dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);//should be fnum and subfnum from json header delete thisData; fdata = NULL; diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 7e0a7e362..7d1204198 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1404,7 +1404,7 @@ private: int currentAcquisitionIndex; int currentFrameIndex; int currentSubFrameIndex; - char currentFileName[MAX_STR_LENGTH]; + string currentFileName; pthread_t receivingDataThreads[MAXDET]; /** Ensures if threads created successfully */ diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index a3c6ff126..da6168ba8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1590,7 +1590,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion { * @param destroy is true to destroy all the threads * @return OK or FAIL */ - int createReceivingDataThreads(bool destroy = false){}; + int createReceivingDataThreads(bool destroy = false){return 0;}; /** Reads frames from receiver through a constant socket diff --git a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h index 79c37d93b..888993fa0 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h @@ -17,7 +17,9 @@ class detectorData { \param np number of points in x coordinate defaults to the number of detector channels (1D detector) \param ny dimension in y (1D detector) */ - detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny){strcpy(fileName,fname);}; + detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny){ + strcpy(fileName,fname); + }; /** @short The destructor deletes also the arrays pointing to data/errors/angles if not NULL