mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-08 19:10:42 +02:00
receiver nth frame and acquisition indices for eiger
This commit is contained in:
parent
91c0a083b3
commit
3e36b603f9
@ -1318,7 +1318,9 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
/**send garbage with -1 index to try again*/
|
/**send garbage with -1 index to try again*/
|
||||||
if(!receiverBase->getFramesCaught()){
|
if(!receiverBase->getFramesCaught()){
|
||||||
arg=-1;
|
arg=-1;
|
||||||
|
#ifdef VERBOSE
|
||||||
cout<<"haven't caught any frame yet"<<endl;
|
cout<<"haven't caught any frame yet"<<endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/** acq started */
|
/** acq started */
|
||||||
else{
|
else{
|
||||||
@ -1338,6 +1340,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
|
|
||||||
/**proper frame*/
|
/**proper frame*/
|
||||||
else{
|
else{
|
||||||
|
|
||||||
memcpy(origVal,raw,frameSize);
|
memcpy(origVal,raw,frameSize);
|
||||||
raw=NULL;
|
raw=NULL;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||||
/********************************************//**
|
/********************************************//**
|
||||||
* @file slsReceiverUDPFunctions.cpp
|
* @file slsReceiverUDPFunctions.cpp
|
||||||
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
||||||
@ -318,7 +318,7 @@ uint32_t slsReceiverUDPFunctions::getStartFrameIndex(){return startFrameIndex;}
|
|||||||
|
|
||||||
uint32_t slsReceiverUDPFunctions::getFrameIndex(){
|
uint32_t slsReceiverUDPFunctions::getFrameIndex(){
|
||||||
if(!packetsCaught)
|
if(!packetsCaught)
|
||||||
frameIndex=0;
|
frameIndex=-1;
|
||||||
else
|
else
|
||||||
frameIndex = currframenum - startFrameIndex;
|
frameIndex = currframenum - startFrameIndex;
|
||||||
return frameIndex;
|
return frameIndex;
|
||||||
@ -326,7 +326,7 @@ uint32_t slsReceiverUDPFunctions::getFrameIndex(){
|
|||||||
|
|
||||||
uint32_t slsReceiverUDPFunctions::getAcquisitionIndex(){
|
uint32_t slsReceiverUDPFunctions::getAcquisitionIndex(){
|
||||||
if(!totalPacketsCaught)
|
if(!totalPacketsCaught)
|
||||||
acquisitionIndex=0;
|
acquisitionIndex=-1;
|
||||||
else
|
else
|
||||||
acquisitionIndex = currframenum - startAcquisitionIndex;
|
acquisitionIndex = currframenum - startAcquisitionIndex;
|
||||||
return acquisitionIndex;
|
return acquisitionIndex;
|
||||||
@ -808,6 +808,7 @@ void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum){
|
|||||||
guiDataReady = 0;
|
guiDataReady = 0;
|
||||||
pthread_mutex_unlock(&dataReadyMutex);
|
pthread_mutex_unlock(&dataReadyMutex);
|
||||||
if((nFrameToGui) && (writerthreads_mask)){
|
if((nFrameToGui) && (writerthreads_mask)){
|
||||||
|
/*if(nFrameToGui){*/
|
||||||
//release after getting data
|
//release after getting data
|
||||||
sem_post(&smp);
|
sem_post(&smp);
|
||||||
}
|
}
|
||||||
@ -829,10 +830,11 @@ void slsReceiverUDPFunctions::copyFrameToGui(char* startbuf[], uint32_t fnum, ch
|
|||||||
|
|
||||||
//random read or nth frame read, gui needs data now
|
//random read or nth frame read, gui needs data now
|
||||||
else{
|
else{
|
||||||
|
/*
|
||||||
//nth frame read, block current process if the guireader hasnt read it yet
|
//nth frame read, block current process if the guireader hasnt read it yet
|
||||||
if(nFrameToGui)
|
if(nFrameToGui)
|
||||||
sem_wait(&smp);
|
sem_wait(&smp);
|
||||||
|
*/
|
||||||
pthread_mutex_lock(&dataReadyMutex);
|
pthread_mutex_lock(&dataReadyMutex);
|
||||||
guiDataReady=0;
|
guiDataReady=0;
|
||||||
//eiger
|
//eiger
|
||||||
@ -860,6 +862,11 @@ void slsReceiverUDPFunctions::copyFrameToGui(char* startbuf[], uint32_t fnum, ch
|
|||||||
strcpy(guiFileName,savefilename);
|
strcpy(guiFileName,savefilename);
|
||||||
guiDataReady=1;
|
guiDataReady=1;
|
||||||
pthread_mutex_unlock(&dataReadyMutex);
|
pthread_mutex_unlock(&dataReadyMutex);
|
||||||
|
|
||||||
|
//nth frame read, block current process if the guireader hasnt read it yet
|
||||||
|
if(nFrameToGui)
|
||||||
|
sem_wait(&smp);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,7 +1199,8 @@ int slsReceiverUDPFunctions::createCompressionFile(int ithr, int iframe){
|
|||||||
|
|
||||||
|
|
||||||
int slsReceiverUDPFunctions::createNewFile(){
|
int slsReceiverUDPFunctions::createNewFile(){
|
||||||
|
int gt = getFrameIndex();
|
||||||
|
if(gt==-1) gt=0;
|
||||||
//create file name
|
//create file name
|
||||||
if(frameIndexNeeded==-1)
|
if(frameIndexNeeded==-1)
|
||||||
sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||||
@ -1229,7 +1237,7 @@ int slsReceiverUDPFunctions::createNewFile(){
|
|||||||
(int)((((currframenum-prevframenum)-(packetsInFile/packetsPerFrame))/(double)(currframenum-prevframenum))*100.000)
|
(int)((((currframenum-prevframenum)-(packetsInFile/packetsPerFrame))/(double)(currframenum-prevframenum))*100.000)
|
||||||
<< "%\tframenum "
|
<< "%\tframenum "
|
||||||
<< dec << currframenum //<< "\t\t p " << prevframenum
|
<< dec << currframenum //<< "\t\t p " << prevframenum
|
||||||
<< "\tindex " << dec << getFrameIndex()
|
<< "\tindex " << dec << gt
|
||||||
<< "\tlost " << dec << (((int)(currframenum-prevframenum))-(packetsInFile/packetsPerFrame)) << endl;
|
<< "\tlost " << dec << (((int)(currframenum-prevframenum))-(packetsInFile/packetsPerFrame)) << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1319,7 +1327,10 @@ int slsReceiverUDPFunctions::startReceiver(char message[]){
|
|||||||
|
|
||||||
//reset listening thread variables
|
//reset listening thread variables
|
||||||
measurementStarted = false;
|
measurementStarted = false;
|
||||||
|
//should be set to zero as its added to get next start frame indices for scans for eiger
|
||||||
|
if(!acqStarted) currframenum = 0;
|
||||||
startFrameIndex = 0;
|
startFrameIndex = 0;
|
||||||
|
|
||||||
for(int i = 0; i < numListeningThreads; ++i)
|
for(int i = 0; i < numListeningThreads; ++i)
|
||||||
totalListeningFrameCount[i] = 0;
|
totalListeningFrameCount[i] = 0;
|
||||||
|
|
||||||
@ -1715,6 +1726,7 @@ int loop;
|
|||||||
//for progress
|
//for progress
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
tempframenum = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
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
|
||||||
}else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
}else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
||||||
tempframenum = (((((uint32_t)(*((uint32_t*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset);
|
tempframenum = (((((uint32_t)(*((uint32_t*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset);
|
||||||
else
|
else
|
||||||
@ -1840,6 +1852,7 @@ int loop;
|
|||||||
void slsReceiverUDPFunctions::startFrameIndices(int ithread){
|
void slsReceiverUDPFunctions::startFrameIndices(int ithread){
|
||||||
|
|
||||||
if (myDetectorType == EIGER)
|
if (myDetectorType == EIGER)
|
||||||
|
//add currframenum later in this method for scans
|
||||||
startFrameIndex = htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
startFrameIndex = htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
||||||
//gotthard has +1 for frame number and not a short frame
|
//gotthard has +1 for frame number and not a short frame
|
||||||
else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
||||||
@ -1850,9 +1863,6 @@ void slsReceiverUDPFunctions::startFrameIndices(int ithread){
|
|||||||
& (frameIndexMask)) >> frameIndexOffset);
|
& (frameIndexMask)) >> frameIndexOffset);
|
||||||
|
|
||||||
|
|
||||||
cout << "startFrameIndex:" << startFrameIndex<<endl;
|
|
||||||
prevframenum=startFrameIndex;
|
|
||||||
measurementStarted = true;
|
|
||||||
//start of acquisition
|
//start of acquisition
|
||||||
if(!acqStarted){
|
if(!acqStarted){
|
||||||
startAcquisitionIndex=startFrameIndex;
|
startAcquisitionIndex=startFrameIndex;
|
||||||
@ -1860,6 +1870,15 @@ void slsReceiverUDPFunctions::startFrameIndices(int ithread){
|
|||||||
acqStarted = true;
|
acqStarted = true;
|
||||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
||||||
}
|
}
|
||||||
|
//for scans, cuz currfraenum resets
|
||||||
|
else if (myDetectorType == EIGER)
|
||||||
|
startFrameIndex += currframenum;
|
||||||
|
|
||||||
|
|
||||||
|
cout << "startFrameIndex:" << startFrameIndex<<endl;
|
||||||
|
prevframenum=startFrameIndex;
|
||||||
|
measurementStarted = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1867,9 +1886,9 @@ void slsReceiverUDPFunctions::startFrameIndices(int ithread){
|
|||||||
void slsReceiverUDPFunctions::stopListening(int ithread, int rc, int &pc, int &t){
|
void slsReceiverUDPFunctions::stopListening(int ithread, int rc, int &pc, int &t){
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cerr << ithread << " recvfrom() failed:"<<endl;
|
cerr << ithread << " recvfrom() failed:"<<endl;
|
||||||
//#endif
|
#endif
|
||||||
if(status != TRANSMITTING){
|
if(status != TRANSMITTING){
|
||||||
cout << ithread << " *** shoule never be here********* status not transmitting***********************"<<endl;/**/
|
cout << ithread << " *** shoule never be here********* status not transmitting***********************"<<endl;/**/
|
||||||
fifoFree[ithread]->push(buffer[ithread]);
|
fifoFree[ithread]->push(buffer[ithread]);
|
||||||
@ -1898,37 +1917,37 @@ int i;
|
|||||||
cout << ithread << " going to push in dummy buffer:" << (void*)buffer[ithread] << " with num packets:"<< (*((uint16_t*)(buffer[ithread]))) << endl;
|
cout << ithread << " going to push in dummy buffer:" << (void*)buffer[ithread] << " with num packets:"<< (*((uint16_t*)(buffer[ithread]))) << endl;
|
||||||
#endif
|
#endif
|
||||||
while(!fifo[ithread]->push(buffer[ithread]));
|
while(!fifo[ithread]->push(buffer[ithread]));
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " pushed in dummy buffer:" << (void*)buffer[ithread] << endl;
|
cout << ithread << " pushed in dummy buffer:" << (void*)buffer[ithread] << endl;
|
||||||
//#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//reset mask and exit loop
|
//reset mask and exit loop
|
||||||
pthread_mutex_lock(&status_mutex);
|
pthread_mutex_lock(&status_mutex);
|
||||||
listeningthreads_mask^=(1<<ithread);
|
listeningthreads_mask^=(1<<ithread);
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " Resetting mask of current listening thread. New Mask: " << listeningthreads_mask << endl;
|
cout << ithread << " Resetting mask of current listening thread. New Mask: " << listeningthreads_mask << endl;
|
||||||
//#endif
|
#endif
|
||||||
pthread_mutex_unlock(&(status_mutex));
|
pthread_mutex_unlock(&(status_mutex));
|
||||||
|
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << ": Frames listened to " << dec << ((totalListeningFrameCount[ithread]*numListeningThreads)/packetsPerFrame) << endl;
|
cout << ithread << ": Frames listened to " << dec << ((totalListeningFrameCount[ithread]*numListeningThreads)/packetsPerFrame) << endl;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
//waiting for all listening threads to be done, to print final count of frames listened to
|
//waiting for all listening threads to be done, to print final count of frames listened to
|
||||||
if(ithread == 0){
|
if(ithread == 0){
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
if(numListeningThreads > 1)
|
if(numListeningThreads > 1)
|
||||||
cout << "Waiting for listening to be done.. current mask:" << hex << listeningthreads_mask << endl;
|
cout << "Waiting for listening to be done.. current mask:" << hex << listeningthreads_mask << endl;
|
||||||
//#endif
|
#endif
|
||||||
while(listeningthreads_mask)
|
while(listeningthreads_mask)
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
t = 0;
|
t = 0;
|
||||||
for(i=0;i<numListeningThreads;++i)
|
for(i=0;i<numListeningThreads;++i)
|
||||||
t += totalListeningFrameCount[i];
|
t += totalListeningFrameCount[i];
|
||||||
cout << "Total frames listened to " << dec <<(t/packetsPerFrame) << endl;
|
cout << "Total frames listened to " << dec <<(t/packetsPerFrame) << endl;
|
||||||
//#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2292,4 +2311,4 @@ int slsReceiverUDPFunctions::enableTenGiga(int enable){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||||
#ifndef SLS_RECEIVER_UDP_FUNCTIONS_H
|
#ifndef SLS_RECEIVER_UDP_FUNCTIONS_H
|
||||||
#define SLS_RECEIVER_UDP_FUNCTIONS_H
|
#define SLS_RECEIVER_UDP_FUNCTIONS_H
|
||||||
/********************************************//**
|
/********************************************//**
|
||||||
@ -801,4 +801,4 @@ public:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user