sorta done without missing packet identifiers

This commit is contained in:
Dhanya Maliakal 2015-07-28 18:15:09 +02:00
parent f970baf1b8
commit fa156f337e
4 changed files with 154 additions and 120 deletions

View File

@ -575,6 +575,9 @@ protected:
/** Pckets currently in current file, starts new file when it reaches max */ /** Pckets currently in current file, starts new file when it reaches max */
int packetsInFile; int packetsInFile;
/** Number of missing packets in file (sometimes packetsinFile is incorrect due to padded packets for eiger)*/
int numTotMissingPacketsInFile;
/** Frame index at start of an entire acquisition (including all scans) */ /** Frame index at start of an entire acquisition (including all scans) */
uint32_t startAcquisitionIndex; uint32_t startAcquisitionIndex;

View File

@ -461,7 +461,7 @@ private:
* When acquisition is over, this is called * When acquisition is over, this is called
* @param ithread listening thread number * @param ithread listening thread number
*/ */
void stopWriting(int ithread); void stopWriting(int ithread, char* wbuffer[]);
/** /**
* updates parameters and writes to file when not a dummy frame * updates parameters and writes to file when not a dummy frame
@ -470,7 +470,7 @@ private:
* @param ithread writing thread number * @param ithread writing thread number
* @param wbuffer writer buffer * @param wbuffer writer buffer
*/ */
void handleWithoutDataCompression(int ithread, char* wbuffer[]); void handleWithoutDataCompression(int ithread, char* wbuffer);
/** /**
* data compression for each fifo output * data compression for each fifo output

View File

@ -19,8 +19,8 @@ typedef int int32_t;
#define MAX_FRAMES_PER_FILE 20000 #define MAX_FRAMES_PER_FILE 20000
#define SHORT_MAX_FRAMES_PER_FILE 100000 #define SHORT_MAX_FRAMES_PER_FILE 100000
#define MOENCH_MAX_FRAMES_PER_FILE 1000 #define MOENCH_MAX_FRAMES_PER_FILE 1000
#define EIGER_MAX_FRAMES_PER_FILE 20 #define EIGER_MAX_FRAMES_PER_FILE 2000
#define JFCTB_MAX_FRAMES_PER_FILE 100000 #define JFCTB_MAX_FRAMES_PER_FILE 100000
/** /**

View File

@ -122,6 +122,7 @@ void UDPStandardImplementation::initializeMembers(){
packetsCaught = 0; packetsCaught = 0;
totalPacketsCaught = 0; totalPacketsCaught = 0;
packetsInFile = 0; packetsInFile = 0;
numTotMissingPacketsInFile = 0;
startAcquisitionIndex = 0; startAcquisitionIndex = 0;
acquisitionIndex = 0; acquisitionIndex = 0;
packetsPerFrame = 0; packetsPerFrame = 0;
@ -1260,6 +1261,7 @@ int UDPStandardImplementation::setupWriter(){
//reset writing thread variables //reset writing thread variables
packetsInFile=0; packetsInFile=0;
numTotMissingPacketsInFile = 0;
packetsCaught=0; packetsCaught=0;
frameIndex=0; frameIndex=0;
if(sfilefd) sfilefd=NULL; if(sfilefd) sfilefd=NULL;
@ -1377,6 +1379,8 @@ int UDPStandardImplementation::createNewFile(){
//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);
else if (myDetectorType == EIGER)
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,currframenum,fileIndex);
else else
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex); sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex);
@ -1411,11 +1415,11 @@ int UDPStandardImplementation::createNewFile(){
cout << savefilename cout << savefilename
<< "\tpacket loss " << "\tpacket loss "
<< setw(4)<<fixed << setprecision(4)<< dec << << setw(4)<<fixed << setprecision(4)<< dec <<
(int)((((currframenum-prevframenum)-(packetsInFile/packetsPerFrame))/(double)(currframenum-prevframenum))*100.000) (int)((((currframenum-prevframenum)-((packetsInFile-numTotMissingPacketsInFile)/packetsPerFrame))/(double)(currframenum-prevframenum))*100.000)
<< "%\tframenum " << "%\tframenum "
<< dec << currframenum //<< "\t\t p " << prevframenum << dec << currframenum //<< "\t\t p " << prevframenum
<< "\tindex " << dec << gt << "\tindex " << dec << gt
<< "\tlost " << dec << (((int)(currframenum-prevframenum))-(packetsInFile/packetsPerFrame)) << endl; << "\tlost " << dec << (((int)(currframenum-prevframenum))-((packetsInFile-numTotMissingPacketsInFile)/packetsPerFrame)) << endl;
} }
} }
@ -1424,6 +1428,7 @@ int UDPStandardImplementation::createNewFile(){
if(packetsCaught){ if(packetsCaught){
prevframenum = currframenum; prevframenum = currframenum;
packetsInFile = 0; packetsInFile = 0;
numTotMissingPacketsInFile = 0;
} }
return OK; return OK;
@ -1898,14 +1903,15 @@ int UDPStandardImplementation::startWriting(){
thread_started = 1; thread_started = 1;
int totalheader = HEADER_SIZE_NUM_TOT_PACKETS + EIGER_HEADER_LENGTH; int numpackets[numListeningThreads], nf;
int numpackets[numListeningThreads], popready[numListeningThreads], nf; bool startdatapacket[numListeningThreads],fullframe[numListeningThreads],popready[numListeningThreads];
bool startdatapacket[numListeningThreads],fullframe[numListeningThreads];
uint32_t tempframenum[numListeningThreads]; uint32_t tempframenum[numListeningThreads];
uint32_t lastpacketheader[numListeningThreads], currentpacketheader[numListeningThreads]; uint32_t lastpacketheader[numListeningThreads], currentpacketheader[numListeningThreads];
int numberofmissingpackets[numListeningThreads]; int numberofmissingpackets[numListeningThreads];
char* tempbuffer = NULL; char* tempbuffer = NULL;
char* blankframe = NULL;
int blankoffset;
int tempoffset[numListeningThreads]; int tempoffset[numListeningThreads];
int LAST_PACKET_VALUE; int LAST_PACKET_VALUE;
@ -1939,35 +1945,50 @@ int UDPStandardImplementation::startWriting(){
//allow them all to be popped initially //allow them all to be popped initially
for(i=0;i<numListeningThreads;++i){ for(i=0;i<numListeningThreads;++i){
numpackets[i] = 0;
popready[i] = 1;
startdatapacket[i] = false;
fullframe[i] = false; fullframe[i] = false;
popready[i] = true;
tempframenum[i] = 0; startdatapacket[i] = false;
tempoffset[i] = (i*(packetsPerFrame/numListeningThreads)*onePacketSize )+ HEADER_SIZE_NUM_TOT_PACKETS;
blankoffset = 0;
lastpacketheader[i] = -1; lastpacketheader[i] = -1;
currentpacketheader[i] = -1; currentpacketheader[i] = -1;
numberofmissingpackets[i] = 0; numberofmissingpackets[i] = 0;
tempoffset[i] = i*(packetsPerFrame/numListeningThreads)*onePacketSize;
numpackets[i] = 0;
tempframenum[i] = 0;
} }
if(tempbuffer) { if(tempbuffer) {
delete [] tempbuffer; delete [] tempbuffer;
tempbuffer = NULL; tempbuffer = NULL;
} }
if(blankframe) {
delete [] blankframe;
blankframe = NULL;
}
if(myDetectorType == EIGER){ if(myDetectorType == EIGER){
tempbuffer = new char[onePacketSize * packetsPerFrame]; tempbuffer = new char[HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize * packetsPerFrame];
currframenum = 0; blankframe = new char[onePacketSize * packetsPerFrame];
//filling blank frames
for(i=0;i<packetsPerFrame * onePacketSize;++i)
(*((uint8_t*)(tempbuffer+i))) = 0xFF;
//last packet numbers for different dynamic ranges
switch(dynamicRange){
case 4: LAST_PACKET_VALUE = 0x40; break;
case 8: LAST_PACKET_VALUE = 0x80; break;
case 16: LAST_PACKET_VALUE = 0xff; break;
case 32: LAST_PACKET_VALUE = 0xff; break;
default: break;
}
} }
switch(dynamicRange){
case 4: LAST_PACKET_VALUE = 0x40; break;
case 8: LAST_PACKET_VALUE = 0x80; break;
case 16: LAST_PACKET_VALUE = 0xff; break;
case 32: LAST_PACKET_VALUE = 0xff; break;
default: break;
}
while((1<<ithread)&writerthreads_mask){ while((1<<ithread)&writerthreads_mask){
@ -1989,7 +2010,7 @@ int UDPStandardImplementation::startWriting(){
#endif #endif
//dont pop again if dummy packet //dont pop again if dummy packet
if(!numpackets[i]) if(!numpackets[i])
popready[i] = 0; popready[i] = false;
} }
} }
@ -2028,18 +2049,21 @@ int UDPStandardImplementation::startWriting(){
if(numpackets[i] && (!fullframe[i])){ if(numpackets[i] && (!fullframe[i])){
//header packet //header packet
if( 0x01 == (*(uint8_t*)(((eiger_image_header *)((char*)(wbuf[i])))->header_confirm))){ if( 0x01 == (*(uint8_t*)(((eiger_image_header *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->header_confirm))){
//new frame (no datapacket received yet), update frame num and corrected for fnum reset for scans //new frame (no datapacket received yet), update frame num and corrected for fnum reset for scans
if(!startdatapacket[i]) if(!startdatapacket[i])
tempframenum[i] = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + woffset[i])))->fnum)+(startFrameIndex-1); tempframenum[i] = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum)+(startFrameIndex-1);
//next frame, leave //next frame, leave
else{ else{
//add missing packets //add missing packets
numberofmissingpackets += (LAST_PACKET_VALUE = lastpacketheader[i]); numberofmissingpackets[i] = (LAST_PACKET_VALUE - lastpacketheader[i]);
//to decrement from packetsInFile to calculate packet loss
numTotMissingPacketsInFile += numberofmissingpackets[i];
for(j=0;j<numberofmissingpackets[i];++j){ for(j=0;j<numberofmissingpackets[i];++j){
tempbuffer[tempoffset[i]] = BLANK_PACKET; tempbuffer[tempoffset[i]] = blankframe[blankoffset];
tempoffset[i] += onePacketSize; tempoffset[i] += onePacketSize;
blankoffset += onePacketSize;
} }
//set fullframe and dont let fifo pop over it until written //set fullframe and dont let fifo pop over it until written
fullframe[i] = true; fullframe[i] = true;
@ -2049,17 +2073,20 @@ int UDPStandardImplementation::startWriting(){
//data packet //data packet
else{ else{
//update current packet //update current packet
currentpacketheader[i] = ((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuf[i] + woffset[i])))->num4))); currentpacketheader[i] = ((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS)))->num4)));
//same frame packet - continue building frame //same frame packet - continue building frame
if(currentpacketheader[i] > lastpacketheader[i]){ if(currentpacketheader[i] > lastpacketheader[i]){
//add missing packets //add missing packets
numberofmissingpackets[i] += (currentpacketheader[i] - lastpacketheader[i] -1); numberofmissingpackets[i] = (currentpacketheader[i] - lastpacketheader[i] -1);
//to decrement from packetsInFile to calculate packet loss
numTotMissingPacketsInFile += numberofmissingpackets[i];
for(j=0;j<numberofmissingpackets[i];++j){ for(j=0;j<numberofmissingpackets[i];++j){
tempbuffer[tempoffset[i]] = BLANK_PACKET; tempbuffer[tempoffset[i]] = blankframe[blankoffset];
tempoffset[i] += onePacketSize; tempoffset[i] += onePacketSize;
blankoffset += onePacketSize;
} }
//add current packet //add current packet
tempbuffer[tempoffset[i]] = wbuf[i]; tempbuffer[tempoffset[i]] = wbuf[i] + HEADER_SIZE_NUM_TOT_PACKETS;
tempoffset[i] += onePacketSize; tempoffset[i] += onePacketSize;
//update last packet //update last packet
lastpacketheader[i] = currentpacketheader[i]; lastpacketheader[i] = currentpacketheader[i];
@ -2072,10 +2099,13 @@ int UDPStandardImplementation::startWriting(){
//next frame packet - leave //next frame packet - leave
else{ else{
//add missing packets //add missing packets
numberofmissingpackets += (LAST_PACKET_VALUE = lastpacketheader[i]); numberofmissingpackets[i] = (LAST_PACKET_VALUE = lastpacketheader[i]);
//to decrement from packetsInFile to calculate packet loss
numTotMissingPacketsInFile += numberofmissingpackets[i];
for(j=0;j<numberofmissingpackets[i];++j){ for(j=0;j<numberofmissingpackets[i];++j){
tempbuffer[tempoffset[i]] = BLANK_PACKET; tempbuffer[tempoffset[i]] = blankframe[blankoffset];
tempoffset[i] += onePacketSize; tempoffset[i] += onePacketSize;
blankoffset += onePacketSize;
} }
//set fullframe and dont let fifo pop over it until written //set fullframe and dont let fifo pop over it until written
fullframe[i] = true; fullframe[i] = true;
@ -2090,29 +2120,32 @@ int UDPStandardImplementation::startWriting(){
//check if a full frame received //check if a full frame received
if(fullframe[0] && fullframe[1]){ if(fullframe[0] && fullframe[1]){
//reset a few stuff
for(int i=0;i<numListeningThreads;i++){ for(int i=0;i<numListeningThreads;i++){
popready[i] = 1; fullframe[i] = false;
startdatapacket[i] = 0; popready[i] = true;
tempoffset[i] = i*(packetsPerFrame/numListeningThreads)*onePacketSize; startdatapacket[i] = false;
tempoffset[i] = (i*(packetsPerFrame/numListeningThreads)*onePacketSize) + HEADER_SIZE_NUM_TOT_PACKETS;
blankoffset = 0;
lastpacketheader[i] = -1; lastpacketheader[i] = -1;
currentpacketheader[i] = -1;
numberofmissingpackets[i] = 0; numberofmissingpackets[i] = 0;
} }
//determine frame number
if(tempframenum[0] != tempframenum[1]) if(tempframenum[0] != tempframenum[1])
cprintf(RED,"Frame numbers mismatch!!! %d %d\n",tempframenum[0],tempframenum[1]); cprintf(RED,"Frame numbers mismatch!!! %d %d\n",tempframenum[0],tempframenum[1]);
currentpacketheader = tempframenum[0]; currframenum = tempframenum[0];
//write
//copy
}
#ifdef EIGER_DEBUG2 #ifdef EIGER_DEBUG2
cout << endl <<ithread << " tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; cout << endl <<ithread << "fnum:" << currframenum << endl;
#endif #endif
//set number of packets to write
(*((uint32_t*)(tempbuffer))) = packetsPerFrame;
//write and copy to gui
handleWithoutDataCompression(ithread,tempbuffer);
}
} }
@ -2151,6 +2184,7 @@ int UDPStandardImplementation::startWriting(){
//wait //wait
sem_wait(&writersmp[ithread]); sem_wait(&writersmp[ithread]);
if(killAllWritingThreads){ if(killAllWritingThreads){
if(tempbuffer) {delete [] tempbuffer; tempbuffer = 0;}
cprintf(GREEN,"%d good bye writing thread\n", ithread); cprintf(GREEN,"%d good bye writing thread\n", ithread);
closeFile(ithread); closeFile(ithread);
pthread_exit(NULL); pthread_exit(NULL);
@ -2188,6 +2222,7 @@ int UDPStandardImplementation::startWriting(){
//wait //wait
sem_wait(&writersmp[ithread]); sem_wait(&writersmp[ithread]);
if(killAllWritingThreads){ if(killAllWritingThreads){
if(tempbuffer) {delete [] tempbuffer; tempbuffer = 0;}
cprintf(GREEN,"%d Goodbye thread\n", ithread); cprintf(GREEN,"%d Goodbye thread\n", ithread);
closeFile(ithread); closeFile(ithread);
pthread_exit(NULL); pthread_exit(NULL);
@ -2199,6 +2234,7 @@ int UDPStandardImplementation::startWriting(){
delete [] d; delete [] d;
if(tempbuffer) {delete [] tempbuffer; tempbuffer = 0;}
return OK; return OK;
} }
@ -2362,16 +2398,26 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
FILE_LOG(logDEBUG) << __AT__ << " called"; FILE_LOG(logDEBUG) << __AT__ << " called";
int i,j; int i,j;
#ifdef VERYDEBUG #ifdef VERBOSE
cprintf(GREEN,"%d popped last dummy frame:0x%x\n",ithread, (void*)wbuffer[0]); cprintf(GREEN,"%d End of Acquisition\n",ithread);
#endif #endif
//free fifo //free fifo
for(i=0;i<numListeningThreads;++i){ for(i=0;i<numListeningThreads;++i){
while(!fifoFree[i]->push(wbuffer[i])); if(myDetectorType == EIGER) {
//push every packet
for(j=0;j<packetsPerFrame/2;++j){
while(!fifoFree[j]->push(wbuffer[i]+j*onePacketSize));
#ifdef FIFO_DEBUG #ifdef FIFO_DEBUG
cprintf(GREEN,"%d writer free dummy pushed into fifofree %x for listener %d\n", ithread,(void*)(wbuffer[i]),i); cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(wbuffer[i]+j*onePacketSize));
#endif #endif
}
}else{
while(!fifoFree[i]->push(wbuffer[i]));
#ifdef FIFO_DEBUG
cprintf(GREEN,"%d writer free dummy pushed into fifofree %x for listener %d\n", ithread,(void*)(wbuffer[i]),i);
#endif
}
} }
@ -2444,7 +2490,6 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num
offset = HEADER_SIZE_NUM_TOT_PACKETS; offset = HEADER_SIZE_NUM_TOT_PACKETS;
if(myDetectorType == EIGER){ if(myDetectorType == EIGER){
offset += EIGER_HEADER_LENGTH;
#ifdef WRITE_HEADERS #ifdef WRITE_HEADERS
#ifdef VERY_DEBUG #ifdef VERY_DEBUG
if(myDetectorType == EIGER){ if(myDetectorType == EIGER){
@ -2531,7 +2576,7 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num
if(packetsInFile >= maxPacketsPerFile){ if(packetsInFile >= maxPacketsPerFile){
//for packet loss //for packet loss
lastpacket = (((packetsToSave - 1) * onePacketSize) + offset); lastpacket = (((packetsToSave - 1) * onePacketSize) + offset);
if(myDetectorType == EIGER); if(myDetectorType == EIGER);//because currframenum is the latest one for eiger
else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
tempframenum = (((((uint32_t)(*((uint32_t*)(buf + lastpacket))))+1)& (frameIndexMask)) >> frameIndexOffset); tempframenum = (((((uint32_t)(*((uint32_t*)(buf + lastpacket))))+1)& (frameIndexMask)) >> frameIndexOffset);
else else
@ -2578,79 +2623,67 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num
void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer[]){ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer){
int totalheader = HEADER_SIZE_NUM_TOT_PACKETS + EIGER_HEADER_LENGTH; int i,npackets;
int i,j,npackets, ntotpackets=0;
if (cbAction < DO_EVERYTHING){ if (cbAction < DO_EVERYTHING){
for(i=0;i<numListeningThreads;++i){ npackets = (uint32_t)(*((uint32_t*)wbuffer));
npackets = (uint16_t)(*((uint16_t*)wbuffer[i])); rawDataReadyCallBack(currframenum, wbuffer + HEADER_SIZE_NUM_TOT_PACKETS, npackets * onePacketSize, sfilefd, guiData,pRawDataReady);
ntotpackets += npackets;
rawDataReadyCallBack(currframenum, wbuffer[i], npackets * onePacketSize, sfilefd, guiData,pRawDataReady);
}
} }
else { else {
for(j=0;j<numListeningThreads;++j){ npackets = (uint32_t)(*((uint32_t*)wbuffer));
//for eiger, if partial frames (only one port) and it is not the smaller framenumber, ignore if (npackets > 0){
if(partialframe && (j!=smaller) ) continue;
npackets = (uint16_t)(*((uint16_t*)wbuffer[j]));
ntotpackets += npackets;
if (npackets > 0){
#ifdef WRITE_HEADERS #ifdef WRITE_HEADERS
if (myDetectorType == EIGER){ if (myDetectorType == EIGER){
for (i = 0; i < packetsPerFrame/2; i++){ for (i = 0; i < packetsPerFrame; i++){
//overwriting frame number in header //overwriting frame number in header
(*(uint32_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num1)) = currframenum; (*(uint32_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num1)) = currframenum;
//overwriting port number and dynamic range //overwriting port number and dynamic range
if (!j) (*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num3)) = (dynamicRange<<2); if (i<(packetsPerFrame/2))
else (*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num3)) = ((dynamicRange<<2)|(0x1)); (*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num3)) = (dynamicRange<<2);
else
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num3)) = ((dynamicRange<<2)|(0x1));
#ifdef VERYDEBUG #ifdef VERYDEBUG
cprintf(GREEN, "%d - 0x%x - %d\n", i, cprintf(GREEN, "%d - 0x%x - %d\n", i,
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num3)), (*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS +i*onePacketSize)))->num3)),
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num4))); (*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS +i*onePacketSize)))->num4)));
#endif #endif
} }
//for 32 bit,port number needs to be changed and packet number reconstructed //for 32 bit,port number needs to be changed and packet number reconstructed
if(dynamicRange == 32){ if(dynamicRange == 32){
for (i = 0; i < packetsPerFrame/4; i++){ for (i = 0; i < packetsPerFrame; i++){
if( (i < (packetsPerFrame/4)) || ((i > (packetsPerFrame/2)) && (i < (3*packetsPerFrame/4))) ){
//new packet number that has space for 16 bit //new packet number that has space for 16 bit
(*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num2)) (*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num2))
= ((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num4))); = ((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num4)));
}else{
#ifdef VERYDEBUG
cprintf(GREEN, "%d - 0x%x - %d - %d\n", i,
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num3)),
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num4)),
(*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num2)));
#endif
}
for (i = packetsPerFrame/4; i < packetsPerFrame/2; i++){
//new packet number that has space for 16 bit //new packet number that has space for 16 bit
(*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num2)) (*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num2))
= ((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader + onePacketSize*i)))->num4))+(packetsPerFrame/4)); = ((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS + onePacketSize*i)))->num4))+(packetsPerFrame/4));
#ifdef VERYDEBUG
cprintf(GREEN, "%d -0x%x - %d - %d\n", i,
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num3)),
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num4)),
(*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer[j] + totalheader +i*onePacketSize)))->num2)));
#endif
} }
#ifdef VERYDEBUG
cprintf(GREEN, "%d - 0x%x - %d - %d\n", i,
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS +i*onePacketSize)))->num3)),
(*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS +i*onePacketSize)))->num4)),
(*(uint16_t*)(((eiger_packet_header *)((char*)(wbuffer + HEADER_SIZE_NUM_TOT_PACKETS +i*onePacketSize)))->num2)));
#endif
} }
} }
}
#endif #endif
writeToFile_withoutCompression(wbuffer[j], npackets,currframenum); writeToFile_withoutCompression(wbuffer, npackets,currframenum);
}
} }
#ifdef VERYDEBUG #ifdef VERYDEBUG
cprintf(GREEN,"written everyting\n"); cprintf(GREEN,"written everyting\n");
#endif #endif
@ -2658,25 +2691,23 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
if(myDetectorType == EIGER) { if(myDetectorType == EIGER) {
if(ntotpackets >= packetsPerFrame ) {
#ifdef VERYDEBUG #ifdef VERYDEBUG
cprintf(GREEN,"gonna copy frame\n"); cprintf(GREEN,"gonna copy frame\n");
#endif #endif
copyFrameToGui(wbuffer,currframenum); copyFrameToGui(wbuffer,currframenum);
//#ifdef VERYDEBUG //#ifdef VERYDEBUG
cprintf(GREEN,"copied frame\n"); cprintf(GREEN,"copied frame\n");
//#endif //#endif
}
for(i=0;i<numListeningThreads;++i){ for(i=0;i<packetsPerFrame;++i){
//for eiger, if partial frames (only one port) and it is not the smaller framenumber, ignore //free those not blank packets
if(partialframe && (i!=smaller) ) continue; if((*(uint8_t*)(((eiger_packet_header *)((char*)(wbuffer + onePacketSize*i)))->num3)) != 0xFF)
while(!fifoFree[i]->push(wbuffer[i])); while(!fifoFree[i]->push(wbuffer+i*onePacketSize));
#ifdef FIFO_DEBUG #ifdef FIFO_DEBUG
cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(wbuffer[i]),i); cprintf(GREEN,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(wbuffer+i*onePacketSize));
#endif #endif
} }
} }
else{ else{
//copy to gui //copy to gui