diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index d69e00b93..cbc4f386c 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -297,11 +297,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter * Returns the buffer-current frame read by receiver * @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 startAcquisitionIndex is the start index of the acquisition * @param startFrameIndex is the start index of the scan */ - void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex); + void readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex); /** * Closes all files @@ -359,7 +358,7 @@ protected: * Copy frames to gui * uses semaphore for nth frame mode */ - void copyFrameToGui(char* startbuf[], uint32_t fnum=-1, char* buf=NULL); + void copyFrameToGui(char* startbuf[], char* buf=NULL); /** * creates udp sockets @@ -483,6 +482,7 @@ protected: //// Could be done more fine-grained... TODO // private: protected: + /** structure of an eiger packet*/ typedef struct { @@ -643,9 +643,6 @@ protected: /** points to the filename to send to gui */ char* guiFileName; - /** temporary number for eiger frame number as its not included in the packet */ - uint32_t guiFrameNumber; - /** send every nth frame to gui or only upon gui request*/ int nFrameToGui; diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 8952396f3..c1d30ec0b 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -338,11 +338,10 @@ class UDPInterface { * Returns the buffer-current frame read by receiver * @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 startAcquisitionIndex is the start index of the acquisition * @param startFrameIndex is the start index of the scan */ - virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex)=0; + virtual void readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex)=0; /** set status to transmitting and * when fifo is empty later, sets status to run_finished diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index 92092bead..2916ee6b9 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -294,11 +294,10 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase * Returns the buffer-current frame read by receiver * @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 startAcquisitionIndex is the start index of the acquisition * @param startFrameIndex is the start index of the scan */ - void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex); + void readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex); /** * Closes all files @@ -356,7 +355,7 @@ private: * Copy frames to gui * uses semaphore for nth frame mode */ - void copyFrameToGui(char* startbuf[], uint32_t fnum=-1, char* buf=NULL); + void copyFrameToGui(char* startbuf[], char* buf=NULL); /** * creates udp sockets diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index fb10ae106..20326bafd 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -567,7 +567,7 @@ void UDPBaseImplementation::setupFifoStructure(){ FILE_LOG(logDEBUG) << __AT__ < /** acquisition functions */ -void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){ +void UDPBaseImplementation::readFrame(char* c,char** raw,uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){ FILE_LOG(logDEBUG) << __AT__ << " called"; //point to gui data if (guiData == NULL){ @@ -576,7 +576,6 @@ void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32 //copy data and filename strcpy(c,guiFileName); - fnum = guiFrameNumber; startAcquisitionIndex = getStartAcquisitionIndex(); startFrameIndex = getStartFrameIndex(); @@ -601,55 +600,8 @@ void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32 -void UDPBaseImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){ FILE_LOG(logDEBUG) << __AT__ << " starting"; +void UDPBaseImplementation::copyFrameToGui(char* startbuf[], char* buf){ FILE_LOG(logDEBUG) << __AT__ << " starting"; - //random read when gui not ready - if((!nFrameToGui) && (!guiData)){ - pthread_mutex_lock(&dataReadyMutex); - guiDataReady=0; - pthread_mutex_unlock(&dataReadyMutex); - } - - //random read or nth frame read, gui needs data now or it is the first frame - else{ - /* - //nth frame read, block current process if the guireader hasnt read it yet - if(nFrameToGui) - sem_wait(&smp); -*/ - pthread_mutex_lock(&dataReadyMutex); - guiDataReady=0; - //eiger - if(startbuf != NULL){ - int offset = 0; - int size = frameSize/EIGER_MAX_PORTS; - for(int j=0;j= packetsPerFrame){//min 1 frame, but neednt be //if(npackets == packetsPerFrame * numJobsPerThread){ //only full frames - copyFrameToGui(NULL,-1,wbuffer[0]+HEADER_SIZE_NUM_TOT_PACKETS); + copyFrameToGui(NULL,wbuffer[0]+HEADER_SIZE_NUM_TOT_PACKETS); #ifdef VERYVERBOSE cout << ithread << " finished copying" << endl; #endif @@ -3087,7 +3075,7 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer #endif if(!once){ - copyFrameToGui(NULL,-1,buff); + copyFrameToGui(NULL,buff); once = 1; } } diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 17ff75764..ffa3f5d8c 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -1068,7 +1068,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){ uint32_t startAcquisitionIndex=0; uint32_t startFrameIndex=0; - uint32_t index = 0,bindex = 0, offset=0; + uint32_t index = -1,bindex = 0, offset=0; strcpy(mess,"Could not read frame\n"); @@ -1088,7 +1088,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){ else{ ret = OK; /*startIndex=receiverBase->getStartFrameIndex();*/ - receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex); + receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex); /**send garbage with -1 index to try again*/ if (raw == NULL){ @@ -1253,7 +1253,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){ char* raw = new char[bufferSize]; - uint32_t index=0,index2=0; + uint32_t index=-1,index2=0; uint32_t pindex=0,pindex2=0; uint32_t bindex=0,bindex2=0; uint32_t startAcquisitionIndex=0; @@ -1277,7 +1277,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){ }else{ ret = OK; /*startIndex=receiverBase->getStartFrameIndex();*/ - receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex); + receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex); /**send garbage with -1 index to try again*/ if (raw == NULL){ @@ -1429,7 +1429,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){ for(i=0;igetStartFrameIndex();*/ - receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex); + receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex); /**send garbage with -1 index to try again*/ if (raw == NULL){ @@ -1567,16 +1567,36 @@ int slsReceiverTCPIPInterface::propix_read_frame(){ int slsReceiverTCPIPInterface::eiger_read_frame(){ ret=OK; + + /** structure of an eiger packet*/ + typedef struct + { + unsigned char subframenum[4]; + unsigned char missingpacket[2]; + unsigned char portnum[1]; + unsigned char dynamicrange[1]; + } eiger_packet_header_t; + + typedef struct + { + unsigned char framenum[6]; + unsigned char packetnum[2]; + } eiger_packet_footer_t; + + char fName[MAX_STR_LENGTH]=""; int acquisitionIndex = -1; int frameIndex= -1; uint32_t index=0; + uint32_t subframenumber=-1; int frameSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE * packetsPerFrame; int dataSize = EIGER_ONE_GIGA_ONE_DATA_SIZE * packetsPerFrame; + int oneDataSize = EIGER_ONE_GIGA_ONE_DATA_SIZE; if(tenGigaEnable){ frameSize = EIGER_TEN_GIGA_ONE_PACKET_SIZE * packetsPerFrame; dataSize = EIGER_TEN_GIGA_ONE_DATA_SIZE * packetsPerFrame; + oneDataSize = EIGER_TEN_GIGA_ONE_DATA_SIZE; } char* raw = new char[frameSize]; char* origVal = new char[frameSize]; @@ -1605,10 +1625,8 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ else{ ret = OK; /** read a frame */ - receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex); -#ifdef VERBOSE - cout << "index:" << dec << index << endl; -#endif + receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex); + /**send garbage with -1 index to try again*/ if (raw == NULL){ startAcquisitionIndex = -1; @@ -1620,6 +1638,21 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ /**proper frame*/ else{//cout<<"**** got proper frame ******"<subframenum); + } + +#ifdef VERBOSE + cout << "index:" << dec << index << endl; + cout << "subframenumber:" << dec << subframenumber << endl; +#endif + memcpy(origVal,raw,frameSize); raw=NULL; @@ -1740,6 +1773,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ cout << "index:" << index << endl; cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl; cout << "startFrameIndex:" << startFrameIndex << endl; + cout << "subframenumber:" << subframenumber << endl; #endif } } @@ -1751,6 +1785,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ cout << "frameIndex:" << frameIndex << endl; cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl; cout << "startFrameIndex:" << startFrameIndex << endl; + cout << "subframenumber:" << subframenumber << endl; } #endif @@ -1773,6 +1808,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){ socket->SendDataOnly(fName,MAX_STR_LENGTH); socket->SendDataOnly(&acquisitionIndex,sizeof(acquisitionIndex)); socket->SendDataOnly(&frameIndex,sizeof(frameIndex)); + socket->SendDataOnly(&subframenumber,sizeof(subframenumber)); socket->SendDataOnly(retval,dataSize); }