From 5cfe7b433832f1510eb6776a172b77caeb2d87bc Mon Sep 17 00:00:00 2001 From: Maliakal Dhanya Date: Tue, 16 Sep 2014 16:29:36 +0200 Subject: [PATCH] 32 bit image, and 32 bit mode frame number for eiger fixed, startframeindex included in readframe for all det in tcpip class --- .../MySocketTCP/genericSocket.h | 12 +++++++++ .../slsReceiver/slsReceiverBase.h | 3 ++- .../slsReceiver/slsReceiverTCPIPInterface.cpp | 27 ++++++++++--------- .../slsReceiver/slsReceiverUDPFunctions.cpp | 27 ++++++++++++++----- .../slsReceiver/slsReceiverUDPFunctions.h | 4 +-- 5 files changed, 51 insertions(+), 22 deletions(-) diff --git a/slsReceiverSoftware/MySocketTCP/genericSocket.h b/slsReceiverSoftware/MySocketTCP/genericSocket.h index bb899f35b..a798a0fef 100644 --- a/slsReceiverSoftware/MySocketTCP/genericSocket.h +++ b/slsReceiverSoftware/MySocketTCP/genericSocket.h @@ -61,6 +61,8 @@ class sockaddr_in; #endif +#include /******exit */ + #include #include #include @@ -558,6 +560,16 @@ enum communicationProtocol{ break; case UDP: if (socketDescriptor<0) return -1; + +/* + cout <<"******listening inside genericsocket"<0){ diff --git a/slsReceiverSoftware/slsReceiver/slsReceiverBase.h b/slsReceiverSoftware/slsReceiver/slsReceiverBase.h index 007bf4a97..97d21bec4 100644 --- a/slsReceiverSoftware/slsReceiver/slsReceiverBase.h +++ b/slsReceiverSoftware/slsReceiver/slsReceiverBase.h @@ -273,8 +273,9 @@ public: * @param c pointer to current file name * @param raw address of pointer, pointing to current frame to send to gui * @param fnum frame number for eiger as it is not in the packet + * @param fstartind is the start index of the acquisition */ - virtual void readFrame(char* c,char** raw, uint32_t &fnum) = 0; + virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind ) = 0; /** set status to transmitting and * when fifo is empty later, sets status to run_finished diff --git a/slsReceiverSoftware/slsReceiver/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/slsReceiver/slsReceiverTCPIPInterface.cpp index cc143efc4..2ebfd3826 100644 --- a/slsReceiverSoftware/slsReceiver/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/slsReceiver/slsReceiverTCPIPInterface.cpp @@ -1000,8 +1000,8 @@ int slsReceiverTCPIPInterface::moench_read_frame(){ else{ ret = OK; - startIndex=receiverBase->getStartFrameIndex(); - receiverBase->readFrame(fName,&raw,index); + /*startIndex=receiverBase->getStartFrameIndex();*/ + receiverBase->readFrame(fName,&raw,index,startIndex); /**send garbage with -1 index to try again*/ if (raw == NULL){ @@ -1170,8 +1170,8 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){ cout<<"haven't caught any frame yet"<getStartFrameIndex(); - receiverBase->readFrame(fName,&raw,index); + /*startIndex=receiverBase->getStartFrameIndex();*/ + receiverBase->readFrame(fName,&raw,index,startIndex); /**send garbage with -1 index to try again*/ if (raw == NULL){ @@ -1302,13 +1302,9 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ char* raw = new char[frameSize]; char* origVal = new char[frameSize]; char* retval = new char[dataSize]; - + uint32_t startIndex=0; strcpy(mess,"Could not read frame\n"); -/* typedef struct{ - unsigned char num1[4]; - unsigned char num2[4]; - } eiger_packet_header;*/ // execute action if the arguments correctly arrived #ifdef SLS_RECEIVER_UDP_FUNCTIONS @@ -1326,7 +1322,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ else{ ret = OK; /** read a frame */ - receiverBase->readFrame(fName,&raw, index); + receiverBase->readFrame(fName,&raw,index,startIndex); #ifdef VERBOSE cout << "index:" << dec << index << endl; #endif @@ -1373,16 +1369,21 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ memcpy(retval+retindex ,origVal+c1 ,numbytesperlineperport); retindex += numbytesperlineperport; c1 += numbytesperlineperport; + if(repeat == 2) c1 += 16; } for(irepeat=0;irepeat using namespace std; +#define EIGER_32BIT_INITIAL_CONSTANT 0x17c + @@ -785,7 +787,7 @@ void slsReceiverUDPFunctions::setupFifoStructure(){ /** acquisition functions */ -void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum){ +void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){ //point to gui data if (guiData == NULL) guiData = latestData; @@ -793,7 +795,7 @@ void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum){ //copy data and filename strcpy(c,guiFileName); fnum = guiFrameNumber; - + fstartind = getStartFrameIndex(); //could not get gui data if(!guiDataReady){ @@ -1506,9 +1508,13 @@ int slsReceiverUDPFunctions::startListening(){ //normal listening else if(!carryonBufferSize){ + /* if(!ithread){*/ rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize); expected = maxBufferSize; - + /*}else{ + while(1) usleep(100000000); + } +*/ } //the remaining packets from previous buffer else{ @@ -1726,7 +1732,10 @@ int loop; //for progress if(myDetectorType == EIGER){ tempframenum = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum); - tempframenum += (startFrameIndex-1); //eiger frame numbers start at 1, so need to -1 + if(dynamicRange != 32) + tempframenum += (startFrameIndex-1); //eiger frame numbers start at 1, so need to -1 + else + tempframenum = ((tempframenum / EIGER_32BIT_INITIAL_CONSTANT) + startFrameIndex)-1;//eiger 32 bit mode is a multiple of 17c. +startframeindex for scans }else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) tempframenum = (((((uint32_t)(*((uint32_t*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset); else @@ -1751,6 +1760,7 @@ int loop; if (cbAction < DO_EVERYTHING){ for(i=0;i 0){ for(i=0;i