mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-09 03:20:42 +02:00
copy first frame to latest data no matter what and also copy only if more than packets per frame
This commit is contained in:
parent
2f82469531
commit
6063c712f7
@ -688,7 +688,7 @@ void UDPBaseImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char
|
|||||||
pthread_mutex_unlock(&dataReadyMutex);
|
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{
|
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
|
||||||
|
@ -874,7 +874,7 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
|||||||
if (guiData == NULL){
|
if (guiData == NULL){
|
||||||
guiData = latestData;
|
guiData = latestData;
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout <<"gui data not null anymore" << endl;
|
cout << "gui data not null anymore" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,14 +886,14 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
|||||||
//could not get gui data
|
//could not get gui data
|
||||||
if(!guiDataReady){
|
if(!guiDataReady){
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout<<"gui data not ready"<<endl;
|
cout << "gui data not ready" << endl;
|
||||||
#endif
|
#endif
|
||||||
*raw = NULL;
|
*raw = NULL;
|
||||||
}
|
}
|
||||||
//data ready, set guidata to receive new data
|
//data ready, set guidata to receive new data
|
||||||
else{
|
else{
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout<<"gui data ready"<<endl;
|
cout << "gui data ready" << endl;
|
||||||
#endif
|
#endif
|
||||||
*raw = guiData;
|
*raw = guiData;
|
||||||
guiData = NULL;
|
guiData = NULL;
|
||||||
@ -903,14 +903,14 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
|||||||
pthread_mutex_unlock(&dataReadyMutex);*/
|
pthread_mutex_unlock(&dataReadyMutex);*/
|
||||||
if((nFrameToGui) && (writerthreads_mask)){
|
if((nFrameToGui) && (writerthreads_mask)){
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout<<"gonna post"<<endl;
|
cout << "gonna post" << endl;
|
||||||
#endif
|
#endif
|
||||||
/*if(nFrameToGui){*/
|
/*if(nFrameToGui){*/
|
||||||
//release after getting data
|
//release after getting data
|
||||||
sem_post(&smp);
|
sem_post(&smp);
|
||||||
}
|
}
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout<<"done post"<<endl;
|
cout << "done post" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -921,25 +921,31 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
|||||||
|
|
||||||
void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){
|
void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
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
|
//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)){
|
if((!nFrameToGui) && (!guiData)){
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "doing nothing" << endl;
|
||||||
|
#endif
|
||||||
pthread_mutex_lock(&dataReadyMutex);
|
pthread_mutex_lock(&dataReadyMutex);
|
||||||
guiDataReady=0;
|
guiDataReady=0;
|
||||||
pthread_mutex_unlock(&dataReadyMutex);
|
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{
|
else{
|
||||||
//cout <<"gui needs data now"<<endl;
|
#ifdef VERY_VERY_DEBUG
|
||||||
/*
|
cout << "gui needs data now or 1st frame" << endl;
|
||||||
//nth frame read, block current process if the guireader hasnt read it yet
|
#endif
|
||||||
if(nFrameToGui)
|
|
||||||
sem_wait(&smp);
|
|
||||||
*/
|
|
||||||
pthread_mutex_lock(&dataReadyMutex);
|
pthread_mutex_lock(&dataReadyMutex);
|
||||||
guiDataReady=0;
|
guiDataReady=0;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "guidataready is 0, copying data" << endl;
|
||||||
|
#endif
|
||||||
//eiger
|
//eiger
|
||||||
if(startbuf != NULL){
|
if(startbuf != NULL){
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -954,8 +960,7 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
|||||||
for(int i=1000;i<1010;i=i+2)
|
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"<<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;
|
cout<<"startbuf:"<<dec<<i<<hex<<":\t0x"<<((uint16_t)(*((uint16_t*)(startbuf[1] + 2+ 48+ j*1040+8+ i))))<<endl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
guiFrameNumber = fnum;
|
guiFrameNumber = fnum;
|
||||||
}else//other detectors
|
}else//other detectors
|
||||||
@ -965,7 +970,9 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
|||||||
strcpy(guiFileName,savefilename);
|
strcpy(guiFileName,savefilename);
|
||||||
guiDataReady=1;
|
guiDataReady=1;
|
||||||
pthread_mutex_unlock(&dataReadyMutex);
|
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
|
//nth frame read, block current process if the guireader hasnt read it yet
|
||||||
if(nFrameToGui){
|
if(nFrameToGui){
|
||||||
//cout<<"waiting after copying"<<endl;
|
//cout<<"waiting after copying"<<endl;
|
||||||
@ -1693,9 +1700,9 @@ int UDPStandardImplementation::startListening(){
|
|||||||
expected = maxBufferSize - carryonBufferSize;
|
expected = maxBufferSize - carryonBufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef VERDEBUG
|
#ifdef EIGER_DEBUG
|
||||||
cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl;
|
cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//start indices for each start of scan/acquisition - eiger does it before
|
//start indices for each start of scan/acquisition - eiger does it before
|
||||||
@ -1871,7 +1878,8 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//so that the first frame is always copied
|
||||||
|
guiData = latestData;
|
||||||
|
|
||||||
|
|
||||||
while((1<<ithread)&writerthreads_mask){
|
while((1<<ithread)&writerthreads_mask){
|
||||||
@ -1896,15 +1904,15 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
//last dummy packet
|
//last dummy packet
|
||||||
if(numpackets == 0xFFFF){
|
if(numpackets == 0xFFFF){
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << "**LAST dummy packet" << endl;
|
cout << "**LAST dummy packet" << endl;
|
||||||
//#endif
|
#endif
|
||||||
stopWriting(ithread,wbuf);
|
stopWriting(ithread,wbuf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
else cout <<"**NOT a dummy packet"<<endl;
|
else cout <<"**NOT a dummy packet"<<endl;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1969,7 +1977,8 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//copy to gui
|
//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);
|
copyFrameToGui(NULL,-1,wbuf[0]+HEADER_SIZE_NUM_TOT_PACKETS);
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cout << ithread << " finished copying" << endl;
|
cout << ithread << " finished copying" << endl;
|
||||||
@ -2108,8 +2117,16 @@ int i;
|
|||||||
exit(-1);
|
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
|
//push the last buffer into fifo
|
||||||
if(rc > 0){
|
else{
|
||||||
//eiger (incomplete frames) - throw away
|
//eiger (incomplete frames) - throw away
|
||||||
if((myDetectorType == EIGER) && (rc < (bufferSize * numJobsPerThread)) ){
|
if((myDetectorType == EIGER) && (rc < (bufferSize * numJobsPerThread)) ){
|
||||||
if(rc == 266240)
|
if(rc == 266240)
|
||||||
@ -2135,14 +2152,6 @@ int i;
|
|||||||
#endif
|
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1252,10 +1252,10 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
if(arg!=-1){
|
//if(arg!=-1){
|
||||||
cout << "fName:" << fName << endl;
|
cout << "fName:" << fName << endl;
|
||||||
cout << "findex:" << arg << endl;
|
cout << "findex:" << arg << endl;
|
||||||
}
|
//}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user