moved start of frame to after stoplistening, for eiger to ignore incomplete frames

This commit is contained in:
Dhanya Maliakal
2015-02-24 16:19:33 +01:00
parent 651a13f811
commit 3ee146a2ca
3 changed files with 45 additions and 29 deletions

View File

@ -171,6 +171,7 @@ uint32_t UDPBaseImplementation::getAcquisitionIndex(){ FILE_LOG(logDEBUG) << __A
acquisitionIndex=-1; acquisitionIndex=-1;
else else
acquisitionIndex = currframenum - startAcquisitionIndex; acquisitionIndex = currframenum - startAcquisitionIndex;
//cout<<"acquisitionIndex:"<<acquisitionIndex <<" currframenum:"<<currframenum <<" startAcquisitionIndex:" <<startAcquisitionIndex<<endl;
return acquisitionIndex; return acquisitionIndex;
} }

View File

@ -1691,11 +1691,11 @@ int UDPStandardImplementation::startListening(){
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
if((!measurementStarted) && (rc > 0) && (!ithread)) if((!measurementStarted) && (rc > 0) && (!ithread))
startFrameIndices(ithread); startFrameIndices(ithread);
*/
//problem in receiving or end of acquisition //problem in receiving or end of acquisition
if((rc < expected)||(rc <= 0)){ if((rc < expected)||(rc <= 0)){
@ -1703,11 +1703,11 @@ int UDPStandardImplementation::startListening(){
continue; continue;
} }
/* ///*
//start indices for each start of scan/acquisition - eiger does it before //start indices for each start of scan/acquisition - this should be done after to ignore first incomplete frames
if((!measurementStarted) && (rc > 0) && (!ithread)) if((!measurementStarted) && (rc > 0) && (!ithread))
startFrameIndices(ithread); startFrameIndices(ithread);
*/ //*/
//reset //reset
packetcount = (packetsPerFrame/numListeningThreads) * numJobsPerThread; packetcount = (packetsPerFrame/numListeningThreads) * numJobsPerThread;
@ -1884,17 +1884,16 @@ int UDPStandardImplementation::startWriting(){
cout << ithread << " *** writer popped from fifo " << (void*) wbuf[1]<< endl; cout << ithread << " *** writer popped from fifo " << (void*) wbuf[1]<< endl;
#endif #endif
//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
@ -1919,10 +1918,10 @@ int UDPStandardImplementation::startWriting(){
currframenum = tempframenum; currframenum = tempframenum;
pthread_mutex_unlock(&progress_mutex); pthread_mutex_unlock(&progress_mutex);
} }
#ifdef VERYDEBUG //#ifdef VERYDEBUG
if(myDetectorType == EIGER) if(myDetectorType == EIGER)
cout << endl <<ithread << " tempframenum:" << hex << tempframenum << " curframenum:" << currframenum << endl; cout << endl <<ithread << " tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl;
#endif //#endif
//without datacompression: write datacall back, or write data, free fifo //without datacompression: write datacall back, or write data, free fifo
@ -2095,22 +2094,37 @@ int i;
fifoFree[ithread]->push(buffer[ithread]); fifoFree[ithread]->push(buffer[ithread]);
exit(-1); exit(-1);
} }
//push the last buffer into fifo //push the last buffer into fifo
if((myDetectorType == EIGER) && (rc < 266240) )//for eiger throw away incomplete frames if(rc > 0){
fifoFree[ithread]->push(buffer[ithread]); //eiger (incomplete frames) - throw away
else if(rc > 0){ if((myDetectorType == EIGER) && (rc < (bufferSize * numJobsPerThread)) ){
pc = (rc/onePacketSize); if(rc == 266240)
cout << ithread << " Start of detector: Received test frame of 266240 bytes." << endl;
cout << ithread << "Discarding incomplete frame" << endl;
fifoFree[ithread]->push(buffer[ithread]);
}
//eiger (complete frames) + other detectors
else{
pc = (rc/onePacketSize);
#ifdef VERYDEBUG #ifdef VERYDEBUG
cout << ithread << " last rc:"<<rc<<endl; cout << ithread << " last rc:"<<rc<<endl;
cout << ithread << " *** last packetcount:" << pc << endl; cout << ithread << " *** last packetcount:" << pc << endl;
#endif #endif
(*((uint16_t*)(buffer[ithread]))) = pc; (*((uint16_t*)(buffer[ithread]))) = pc;
totalListeningFrameCount[ithread] += pc; totalListeningFrameCount[ithread] += pc;
while(!fifo[ithread]->push(buffer[ithread])); while(!fifo[ithread]->push(buffer[ithread]));
#ifdef VERYDEBUG #ifdef VERYDEBUG
cout << ithread << " *** last lbuf1:" << (void*)buffer[ithread] << endl; cout << ithread << " *** last lbuf1:" << (void*)buffer[ithread] << endl;
#endif #endif
}
} }
//free buffer
else{
cout << ithread << "Discarding empty frame" << endl;
fifoFree[ithread]->push(buffer[ithread]);
}
//push dummy buffer to all writer threads //push dummy buffer to all writer threads
@ -2279,8 +2293,9 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num
packetsInFile += packetsToSave; packetsInFile += packetsToSave;
packetsCaught += packetsToSave; packetsCaught += packetsToSave;
totalPacketsCaught += packetsToSave; totalPacketsCaught += packetsToSave;
#ifdef VERYDEBUG
cout << "/totalPacketsCaught:" << dec << totalPacketsCaught <<endl;
#endif
//new file //new file
if(packetsInFile >= maxPacketsPerFile){ if(packetsInFile >= maxPacketsPerFile){
//for packet loss //for packet loss

View File

@ -1336,9 +1336,9 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
/**send garbage with -1 index to try again*/ /**send garbage with -1 index to try again*/
if (raw == NULL){ if (raw == NULL){
arg = -1; arg = -1;
//#ifdef VERBOSE #ifdef VERBOSE
cout<<"data not ready for gui yet"<<endl; cout<<"data not ready for gui yet"<<endl;
//#endif #endif
} }
/**proper frame*/ /**proper frame*/
@ -1464,19 +1464,19 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
*/ */
} }
arg = index-startIndex; arg = index-startIndex;
//#ifdef VERY_VERY_DEBUG #ifdef VERY_VERY_DEBUG
cout << "arg calculated is:"<<arg<<endl; cout << "arg calculated is:"<<arg<<endl;
cout <<"index:"<<index<<" startindex:"<<startIndex<<endl; cout <<"index:"<<index<<" startindex:"<<startIndex<<endl;
//#endif #endif
} }
} }
//#ifdef VERBOSE #ifdef VERBOSE
//if(arg!=-1){ //if(arg!=-1){
cout << "fName:" << fName << endl; cout << "fName:" << fName << endl;
cout << "findex:" << dec << arg << endl; cout << "findex:" << dec << arg << endl;
//} //}
//#endif #endif