mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_receiver_software
This commit is contained in:
commit
248848c666
@ -67,6 +67,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
|
||||
//Frame indices and numbers caught
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
uint32_t getStartAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -288,9 +293,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* @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
|
||||
* @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 &fstartind);
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
* @param ithr thread index
|
||||
@ -479,6 +486,13 @@ protected:
|
||||
unsigned char fnum[4];
|
||||
unsigned char header_after[24];
|
||||
} eiger_image_header;
|
||||
/** structure of an eiger image header*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char header_before[35];
|
||||
unsigned char fnum[4];
|
||||
unsigned char header_after[9];
|
||||
} eiger_image_header32;
|
||||
|
||||
|
||||
/** structure of an eiger image header*/
|
||||
|
@ -240,6 +240,11 @@ class UDPInterface {
|
||||
*/
|
||||
virtual int getFramesCaught() = 0;
|
||||
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
virtual uint32_t getStartAcquisitionIndex()=0;
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -328,9 +333,10 @@ class UDPInterface {
|
||||
* @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
|
||||
* @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 &fstartind ) = 0;
|
||||
virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex)=0;
|
||||
|
||||
/** set status to transmitting and
|
||||
* when fifo is empty later, sets status to run_finished
|
||||
|
@ -89,6 +89,11 @@ class UDPRESTImplementation : protected virtual slsReceiverDefs, public UDPBaseI
|
||||
|
||||
|
||||
//Frame indices and numbers caught
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
uint32_t getStartAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -300,8 +305,10 @@ class UDPRESTImplementation : protected virtual slsReceiverDefs, public UDPBaseI
|
||||
* @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 &fstartind);
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
|
@ -68,6 +68,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
|
||||
|
||||
//Frame indices and numbers caught
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
//uint32_t getStartAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -290,8 +295,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
* @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 &fstartind);
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
* @param ithr thread index
|
||||
|
@ -155,6 +155,8 @@ int UDPBaseImplementation::getFramesCaught(){ FILE_LOG(logDEBUG) << __AT__ << "
|
||||
|
||||
int UDPBaseImplementation::getTotalFramesCaught(){ FILE_LOG(logDEBUG) << __AT__ << " starting";return (totalPacketsCaught/packetsPerFrame);}
|
||||
|
||||
uint32_t UDPBaseImplementation::getStartAcquisitionIndex(){ FILE_LOG(logDEBUG) << __AT__ << " starting";return startAcquisitionIndex;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getStartFrameIndex(){ FILE_LOG(logDEBUG) << __AT__ << " starting";return startFrameIndex;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFrameIndex(){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
@ -642,17 +644,19 @@ void UDPBaseImplementation::setupFifoStructure(){ FILE_LOG(logDEBUG) << __AT__ <
|
||||
|
||||
|
||||
/** acquisition functions */
|
||||
void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t& fstartind){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
//point to gui data
|
||||
if (guiData == NULL)
|
||||
if (guiData == NULL){
|
||||
guiData = latestData;
|
||||
}
|
||||
|
||||
//copy data and filename
|
||||
strcpy(c,guiFileName);
|
||||
fnum = guiFrameNumber;
|
||||
fstartind = getStartFrameIndex();
|
||||
startAcquisitionIndex = getStartAcquisitionIndex();
|
||||
startFrameIndex = getStartFrameIndex();
|
||||
|
||||
|
||||
//could not get gui data
|
||||
if(!guiDataReady){
|
||||
@ -662,12 +666,7 @@ void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32
|
||||
else{
|
||||
*raw = guiData;
|
||||
guiData = NULL;
|
||||
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady = 0;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
if((nFrameToGui) && (writerthreads_mask)){
|
||||
/*if(nFrameToGui){*/
|
||||
//release after getting data
|
||||
sem_post(&smp);
|
||||
}
|
||||
@ -688,7 +687,7 @@ void UDPBaseImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
}
|
||||
|
||||
//random read or nth frame read, gui needs data now
|
||||
//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
|
||||
|
@ -200,6 +200,11 @@ int UDPRESTImplementation::getTotalFramesCaught(){
|
||||
return (totalPacketsCaught/packetsPerFrame);
|
||||
}
|
||||
|
||||
uint32_t UDPRESTImplementation::getStartAcquisitionIndex(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
return startAcquisitionIndex;
|
||||
}
|
||||
|
||||
uint32_t UDPRESTImplementation::getStartFrameIndex(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
return startFrameIndex;
|
||||
@ -590,16 +595,19 @@ void UDPRESTImplementation::setupFifoStructure(){
|
||||
|
||||
|
||||
/** acquisition functions */
|
||||
void UDPRESTImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){
|
||||
void UDPRESTImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
//point to gui data
|
||||
if (guiData == NULL)
|
||||
if (guiData == NULL){
|
||||
guiData = latestData;
|
||||
}
|
||||
|
||||
//copy data and filename
|
||||
strcpy(c,guiFileName);
|
||||
fnum = guiFrameNumber;
|
||||
fstartind = getStartFrameIndex();
|
||||
startAcquisitionIndex = getStartAcquisitionIndex();
|
||||
startFrameIndex = getStartFrameIndex();
|
||||
|
||||
|
||||
//could not get gui data
|
||||
if(!guiDataReady){
|
||||
@ -609,12 +617,7 @@ void UDPRESTImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32
|
||||
else{
|
||||
*raw = guiData;
|
||||
guiData = NULL;
|
||||
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady = 0;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
if((nFrameToGui) && (writerthreads_mask)){
|
||||
/*if(nFrameToGui){*/
|
||||
//release after getting data
|
||||
sem_post(&smp);
|
||||
}
|
||||
|
@ -352,6 +352,8 @@ int UDPStandardImplementation::setDetectorType(detectorType det){ FILE_LOG(logD
|
||||
|
||||
//int UDPStandardImplementation::getTotalFramesCaught(){return (totalPacketsCaught/packetsPerFrame);}
|
||||
|
||||
//uint32_t UDPStandardImplementation::getStartAcquisitionIndex(){return startAcquisitionIndex;}
|
||||
|
||||
//uint32_t UDPStandardImplementation::getStartFrameIndex(){return startFrameIndex;}
|
||||
|
||||
/*
|
||||
@ -868,32 +870,34 @@ void UDPStandardImplementation::setupFifoStructure(){
|
||||
|
||||
|
||||
/** acquisition functions */
|
||||
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){
|
||||
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
//point to gui data
|
||||
if (guiData == NULL){
|
||||
guiData = latestData;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout <<"gui data not null anymore" << endl;
|
||||
cout << "gui data not null anymore" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//copy data and filename
|
||||
strcpy(c,guiFileName);
|
||||
fnum = guiFrameNumber;
|
||||
fstartind = getStartFrameIndex();
|
||||
startAcquisitionIndex = getStartAcquisitionIndex();
|
||||
startFrameIndex = getStartFrameIndex();
|
||||
|
||||
|
||||
//could not get gui data
|
||||
if(!guiDataReady){
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"gui data not ready"<<endl;
|
||||
cout << "gui data not ready" << endl;
|
||||
#endif
|
||||
*raw = NULL;
|
||||
}
|
||||
//data ready, set guidata to receive new data
|
||||
else{
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"gui data ready"<<endl;
|
||||
cout << "gui data ready" << endl;
|
||||
#endif
|
||||
*raw = guiData;
|
||||
guiData = NULL;
|
||||
@ -903,14 +907,14 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
||||
pthread_mutex_unlock(&dataReadyMutex);*/
|
||||
if((nFrameToGui) && (writerthreads_mask)){
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"gonna post"<<endl;
|
||||
cout << "gonna post" << endl;
|
||||
#endif
|
||||
/*if(nFrameToGui){*/
|
||||
//release after getting data
|
||||
sem_post(&smp);
|
||||
}
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"done post"<<endl;
|
||||
cout << "done post" << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -921,25 +925,31 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
||||
|
||||
void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "copyframe" << endl;
|
||||
#endif
|
||||
|
||||
//random read when gui not ready , also command line doesnt have nthframetogui
|
||||
//else guidata always null as guidataready is always 1 after 1st frame, and seccond data never gets copied
|
||||
if((!nFrameToGui) && (!guiData)){
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "doing nothing" << endl;
|
||||
#endif
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady=0;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
}
|
||||
|
||||
//random read or nth frame read, gui needs data now
|
||||
//random read or nth frame read, gui needs data now or it is the first frame
|
||||
else{
|
||||
//cout <<"gui needs data now"<<endl;
|
||||
/*
|
||||
//nth frame read, block current process if the guireader hasnt read it yet
|
||||
if(nFrameToGui)
|
||||
sem_wait(&smp);
|
||||
*/
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "gui needs data now or 1st frame" << endl;
|
||||
#endif
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady=0;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "guidataready is 0, copying data" << endl;
|
||||
#endif
|
||||
//eiger
|
||||
if(startbuf != NULL){
|
||||
int offset = 0;
|
||||
@ -954,8 +964,7 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
||||
for(int i=1000;i<1010;i=i+2)
|
||||
//cout<<"startbuf:"<<dec<<i<<hex<<":\t0x"<<htonl((uint32_t)(*((uint32_t*)(startbuf[1] + HEADER_SIZE_NUM_TOT_PACKETS+ EIGER_HEADER_LENGTH+8+ i))))<<endl;
|
||||
cout<<"startbuf:"<<dec<<i<<hex<<":\t0x"<<((uint16_t)(*((uint16_t*)(startbuf[1] + 2+ 48+ j*1040+8+ i))))<<endl;
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
guiFrameNumber = fnum;
|
||||
}else//other detectors
|
||||
@ -965,12 +974,18 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
||||
strcpy(guiFileName,savefilename);
|
||||
guiDataReady=1;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "guidataready = 1" << endl;
|
||||
#endif
|
||||
//nth frame read, block current process if the guireader hasnt read it yet
|
||||
if(nFrameToGui){
|
||||
//cout<<"waiting after copying"<<endl;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"waiting after copying"<<endl;
|
||||
#endif
|
||||
sem_wait(&smp);
|
||||
//cout<<"done waiting"<<endl;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"done waiting"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@ -1693,9 +1708,9 @@ int UDPStandardImplementation::startListening(){
|
||||
expected = maxBufferSize - carryonBufferSize;
|
||||
}
|
||||
|
||||
//#ifdef VERDEBUG
|
||||
#ifdef EIGER_DEBUG
|
||||
cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
//start indices for each start of scan/acquisition - eiger does it before
|
||||
@ -1871,7 +1886,8 @@ int UDPStandardImplementation::startWriting(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//so that the first frame is always copied
|
||||
guiData = latestData;
|
||||
|
||||
|
||||
while((1<<ithread)&writerthreads_mask){
|
||||
@ -1896,15 +1912,15 @@ int UDPStandardImplementation::startWriting(){
|
||||
|
||||
//last dummy packet
|
||||
if(numpackets == 0xFFFF){
|
||||
//#ifdef VERYDEBUG
|
||||
#ifdef VERYDEBUG
|
||||
cout << "**LAST dummy packet" << endl;
|
||||
//#endif
|
||||
#endif
|
||||
stopWriting(ithread,wbuf);
|
||||
continue;
|
||||
}
|
||||
//#ifdef VERYDEBUG
|
||||
#ifdef VERYDEBUG
|
||||
else cout <<"**NOT a dummy packet"<<endl;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -1913,8 +1929,11 @@ int UDPStandardImplementation::startWriting(){
|
||||
tempframenum = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
||||
if(dynamicRange != 32)
|
||||
tempframenum += (startFrameIndex-1); //eiger frame numbers start at 1, so need to -1
|
||||
else
|
||||
else{
|
||||
cout << " 32 bit eiger could be "<< dec << htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum) << endl;
|
||||
cout << " 32 bit eiger32 could be "<< dec << htonl(*(unsigned int*)((eiger_image_header32 *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum) << endl;
|
||||
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
|
||||
@ -1928,10 +1947,10 @@ int UDPStandardImplementation::startWriting(){
|
||||
currframenum = tempframenum;
|
||||
pthread_mutex_unlock(&progress_mutex);
|
||||
}
|
||||
//#ifdef VERYDEBUG
|
||||
#ifdef VERYDEBUG
|
||||
if(myDetectorType == EIGER)
|
||||
cout << endl <<ithread << " tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
|
||||
//without datacompression: write datacall back, or write data, free fifo
|
||||
@ -1969,7 +1988,8 @@ int UDPStandardImplementation::startWriting(){
|
||||
}
|
||||
else{
|
||||
//copy to gui
|
||||
if(numpackets == packetsPerFrame * numJobsPerThread){ //only full frames
|
||||
if(numpackets >= packetsPerFrame){//min 1 frame, but neednt be
|
||||
//if(numpackets == packetsPerFrame * numJobsPerThread){ //only full frames
|
||||
copyFrameToGui(NULL,-1,wbuf[0]+HEADER_SIZE_NUM_TOT_PACKETS);
|
||||
#ifdef VERYVERBOSE
|
||||
cout << ithread << " finished copying" << endl;
|
||||
@ -2108,12 +2128,20 @@ int i;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
//free buffer
|
||||
if(rc <= 0){
|
||||
cout << ithread << "Discarding empty frame" << endl;
|
||||
fifoFree[ithread]->push(buffer[ithread]);
|
||||
#ifdef FIFO_DEBUG
|
||||
cprintf(BLUE,"%d listener empty buffer pushed into fifofree %x\n", ithread, (void*)(buffer[ithread]));
|
||||
#endif
|
||||
}
|
||||
//push the last buffer into fifo
|
||||
if(rc > 0){
|
||||
else{
|
||||
//eiger (incomplete frames) - throw away
|
||||
if((myDetectorType == EIGER) && (rc < (bufferSize * numJobsPerThread)) ){
|
||||
if(rc == 266240)
|
||||
cout << ithread << " Start of detector: Received test frame of 266240 bytes." << endl;
|
||||
cprintf(GREEN, "%d Start of detector: Received test frame of 266240 bytes.\n",ithread);
|
||||
cout << ithread << "Discarding incomplete frame" << endl;
|
||||
fifoFree[ithread]->push(buffer[ithread]);
|
||||
#ifdef FIFO_DEBUG
|
||||
@ -2135,14 +2163,6 @@ int i;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//free buffer
|
||||
else{
|
||||
cout << ithread << "Discarding empty frame" << endl;
|
||||
fifoFree[ithread]->push(buffer[ithread]);
|
||||
#ifdef FIFO_DEBUG
|
||||
cprintf(BLUE,"%d listener empty buffer pushed into fifofree %x\n", ithread, (void*)(buffer[ithread]));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2252,8 +2272,13 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
|
||||
//report
|
||||
|
||||
cprintf(GREEN, "Status: Run Finished\n");
|
||||
if(!totalPacketsCaught){
|
||||
cprintf(RED, "Total Packets Caught:%d\n", totalPacketsCaught);
|
||||
cprintf(RED, "Total Frames Caught:%d\n",(totalPacketsCaught/packetsPerFrame));
|
||||
}else{
|
||||
cprintf(GREEN, "Total Packets Caught:%d\n", totalPacketsCaught);
|
||||
cprintf(GREEN, "Total Frames Caught:%d\n",(totalPacketsCaught/packetsPerFrame));
|
||||
}
|
||||
//acquisition end
|
||||
if (acquisitionFinishedCallBack)
|
||||
acquisitionFinishedCallBack((totalPacketsCaught/packetsPerFrame), pAcquisitionFinished);
|
||||
|
@ -977,7 +977,9 @@ int slsReceiverTCPIPInterface::read_frame(){
|
||||
int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
ret=OK;
|
||||
char fName[MAX_STR_LENGTH]="";
|
||||
int arg = -1,i;
|
||||
int acquisitionIndex = -1;
|
||||
int frameIndex= -1;
|
||||
int i;
|
||||
|
||||
|
||||
int bufferSize = MOENCH_BUFFER_SIZE;
|
||||
@ -990,7 +992,8 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
|
||||
char* raw = new char[bufferSize];
|
||||
|
||||
uint32_t startIndex=0;
|
||||
uint32_t startAcquisitionIndex=0;
|
||||
uint32_t startFrameIndex=0;
|
||||
uint32_t index = 0,bindex = 0, offset=0;
|
||||
|
||||
strcpy(mess,"Could not read frame\n");
|
||||
@ -1001,18 +1004,18 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if(!receiverBase->getFramesCaught()){
|
||||
arg = -1;
|
||||
startAcquisitionIndex = -1;
|
||||
cout<<"haven't caught any frame yet"<<endl;
|
||||
}
|
||||
|
||||
else{
|
||||
ret = OK;
|
||||
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||
receiverBase->readFrame(fName,&raw,index,startIndex);
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
arg = -1;
|
||||
startAcquisitionIndex = -1;
|
||||
#ifdef VERBOSE
|
||||
cout<<"data not ready for gui yet"<<endl;
|
||||
#endif
|
||||
@ -1044,7 +1047,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
bindex = (*((uint32_t*)(((char*)origVal)+packetOffset)));
|
||||
if (bindex == 0xFFFFFFFF){
|
||||
cout << "Missing Packet,Not sending to gui" << endl;
|
||||
index = startIndex - 1;
|
||||
index = startAcquisitionIndex - 1;
|
||||
break;//use continue and change index above if you want to display missing packets with 0 value anyway in gui
|
||||
}
|
||||
|
||||
@ -1088,16 +1091,28 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
//check if same frame number
|
||||
}
|
||||
|
||||
arg = index - startIndex;
|
||||
acquisitionIndex = index-startAcquisitionIndex;
|
||||
if(acquisitionIndex == -1)
|
||||
startFrameIndex = -1;
|
||||
else
|
||||
frameIndex = index-startFrameIndex;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "acquisitionIndex calculated is:" << acquisitionIndex << endl;
|
||||
cout << "frameIndex calculated is:" << frameIndex << endl;
|
||||
cout << "index:" << index << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "\nstartIndex:" << startIndex << endl;
|
||||
cout << "fName:" << fName << endl;
|
||||
cout << "index:" << arg << endl;
|
||||
if(retval==NULL)cout<<"retval is null"<<endl;
|
||||
cout << "acquisitionIndex:" << acquisitionIndex << endl;
|
||||
cout << "frameIndex:" << frameIndex << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1115,7 +1130,8 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
}
|
||||
else{
|
||||
socket->SendDataOnly(fName,MAX_STR_LENGTH);
|
||||
socket->SendDataOnly(&arg,sizeof(arg));
|
||||
socket->SendDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
||||
socket->SendDataOnly(&frameIndex,sizeof(frameIndex));
|
||||
socket->SendDataOnly(retval,MOENCH_DATA_BYTES);
|
||||
}
|
||||
//return ok/fail
|
||||
@ -1135,7 +1151,9 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
ret=OK;
|
||||
char fName[MAX_STR_LENGTH]="";
|
||||
int arg = -1,i;
|
||||
int acquisitionIndex = -1;
|
||||
int frameIndex= -1;
|
||||
int i;
|
||||
|
||||
|
||||
//retval is a full frame
|
||||
@ -1161,7 +1179,8 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
uint32_t index=0,index2=0;
|
||||
uint32_t pindex=0,pindex2=0;
|
||||
uint32_t bindex=0,bindex2=0;
|
||||
uint32_t startIndex=0;
|
||||
uint32_t startAcquisitionIndex=0;
|
||||
uint32_t startFrameIndex=0;
|
||||
|
||||
strcpy(mess,"Could not read frame\n");
|
||||
|
||||
@ -1173,16 +1192,16 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if(!receiverBase->getFramesCaught()){
|
||||
arg=-1;
|
||||
startAcquisitionIndex=-1;
|
||||
cout<<"haven't caught any frame yet"<<endl;
|
||||
}else{
|
||||
ret = OK;
|
||||
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||
receiverBase->readFrame(fName,&raw,index,startIndex);
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
arg = -1;
|
||||
startAcquisitionIndex = -1;
|
||||
#ifdef VERBOSE
|
||||
cout<<"data not ready for gui yet"<<endl;
|
||||
#endif
|
||||
@ -1216,7 +1235,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
if(bindex != 0xFFFFFFFF)
|
||||
memcpy((((char*)retval)+(GOTTHARD_SHORT_DATABYTES*shortFrame)),((char*) origVal)+4, GOTTHARD_SHORT_DATABYTES);
|
||||
else{
|
||||
index = startIndex - 1;
|
||||
index = startAcquisitionIndex - 1;
|
||||
cout << "Missing Packet,Not sending to gui" << endl;
|
||||
}
|
||||
}
|
||||
@ -1247,14 +1266,29 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
}*/
|
||||
}
|
||||
|
||||
arg = (index - startIndex);
|
||||
acquisitionIndex = index-startAcquisitionIndex;
|
||||
if(acquisitionIndex == -1)
|
||||
startFrameIndex = -1;
|
||||
else
|
||||
frameIndex = index-startFrameIndex;
|
||||
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "acquisitionIndex calculated is:" << acquisitionIndex << endl;
|
||||
cout << "frameIndex calculated is:" << frameIndex << endl;
|
||||
cout << "index:" << index << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
if(arg!=-1){
|
||||
if(frameIndex!=-1){
|
||||
cout << "fName:" << fName << endl;
|
||||
cout << "findex:" << arg << endl;
|
||||
cout << "acquisitionIndex:" << acquisitionIndex << endl;
|
||||
cout << "frameIndex:" << frameIndex << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1275,7 +1309,8 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
}
|
||||
else{
|
||||
socket->SendDataOnly(fName,MAX_STR_LENGTH);
|
||||
socket->SendDataOnly(&arg,sizeof(arg));
|
||||
socket->SendDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
||||
socket->SendDataOnly(&frameIndex,sizeof(frameIndex));
|
||||
socket->SendDataOnly(retval,GOTTHARD_DATA_BYTES);
|
||||
}
|
||||
|
||||
@ -1297,7 +1332,9 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
ret=OK;
|
||||
char fName[MAX_STR_LENGTH]="";
|
||||
int arg = -1,i;
|
||||
int acquisitionIndex = -1;
|
||||
int frameIndex= -1;
|
||||
int i;
|
||||
uint32_t index=0;
|
||||
|
||||
int frameSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE * packetsPerFrame;
|
||||
@ -1309,7 +1346,8 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
char* raw = new char[frameSize];
|
||||
char* origVal = new char[frameSize];
|
||||
char* retval = new char[dataSize];
|
||||
uint32_t startIndex=0;
|
||||
uint32_t startAcquisitionIndex=0;
|
||||
uint32_t startFrameIndex=0;
|
||||
strcpy(mess,"Could not read frame\n");
|
||||
|
||||
|
||||
@ -1320,7 +1358,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if(!receiverBase->getFramesCaught()){
|
||||
arg=-1;
|
||||
startAcquisitionIndex=-1;
|
||||
#ifdef VERBOSE
|
||||
cout<<"haven't caught any frame yet"<<endl;
|
||||
#endif
|
||||
@ -1329,13 +1367,13 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
else{
|
||||
ret = OK;
|
||||
/** read a frame */
|
||||
receiverBase->readFrame(fName,&raw,index,startIndex);
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
#ifdef VERBOSE
|
||||
cout << "index:" << dec << index << endl;
|
||||
#endif
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
arg = -1;
|
||||
startAcquisitionIndex = -1;
|
||||
#ifdef VERBOSE
|
||||
cout<<"data not ready for gui yet"<<endl;
|
||||
#endif
|
||||
@ -1463,19 +1501,29 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
(*(((uint64_t*)retval)+i)) = temp;
|
||||
*/
|
||||
}
|
||||
arg = index-startIndex;
|
||||
acquisitionIndex = index-startAcquisitionIndex;
|
||||
if(acquisitionIndex == -1)
|
||||
startFrameIndex = -1;
|
||||
else
|
||||
frameIndex = index-startFrameIndex;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "arg calculated is:"<<arg<<endl;
|
||||
cout <<"index:"<<index<<" startindex:"<<startIndex<<endl;
|
||||
cout << "acquisitionIndex calculated is:" << acquisitionIndex << endl;
|
||||
cout << "frameIndex calculated is:" << frameIndex << endl;
|
||||
cout << "index:" << index << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
//if(arg!=-1){
|
||||
if(frameIndex!=-1){
|
||||
cout << "fName:" << fName << endl;
|
||||
cout << "findex:" << dec << arg << endl;
|
||||
//}
|
||||
cout << "acquisitionIndex:" << acquisitionIndex << endl;
|
||||
cout << "frameIndex:" << frameIndex << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -1495,7 +1543,8 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
}
|
||||
else{
|
||||
socket->SendDataOnly(fName,MAX_STR_LENGTH);
|
||||
socket->SendDataOnly(&arg,sizeof(arg));
|
||||
socket->SendDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
||||
socket->SendDataOnly(&frameIndex,sizeof(frameIndex));
|
||||
socket->SendDataOnly(retval,dataSize);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user