mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
got rid of warnings
This commit is contained in:
@ -79,7 +79,7 @@ template<typename Element>
|
|||||||
bool CircularFifo<Element>::push(Element*& item_)
|
bool CircularFifo<Element>::push(Element*& item_)
|
||||||
{
|
{
|
||||||
|
|
||||||
int nextTail = increment(tail);
|
unsigned int nextTail = increment(tail);
|
||||||
if(nextTail != head)
|
if(nextTail != head)
|
||||||
{
|
{
|
||||||
array[tail] = item_;
|
array[tail] = item_;
|
||||||
|
@ -1399,12 +1399,6 @@ int UDPBaseImplementation::startListening(){ FILE_LOG(logDEBUG) << __AT__ << " s
|
|||||||
|
|
||||||
|
|
||||||
int UDPBaseImplementation::startWriting(){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
int UDPBaseImplementation::startWriting(){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||||
int ithread = currentWriterThreadIndex;
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
cout << ithread << "In startWriting()" <<endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -1568,94 +1562,6 @@ void UDPBaseImplementation::stopWriting(int ithread, char* wbuffer[]){ FILE_LOG(
|
|||||||
void UDPBaseImplementation::writeToFile_withoutCompression(char* buf,int numpackets, uint32_t framenum){
|
void UDPBaseImplementation::writeToFile_withoutCompression(char* buf,int numpackets, uint32_t framenum){
|
||||||
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int packetsToSave, offset,lastpacket;
|
|
||||||
uint32_t tempframenum = framenum;
|
|
||||||
|
|
||||||
//file write
|
|
||||||
if((enableFileWrite) && (sfilefd)){
|
|
||||||
|
|
||||||
offset = HEADER_SIZE_NUM_TOT_PACKETS;
|
|
||||||
if(myDetectorType == EIGER)
|
|
||||||
offset += EIGER_HEADER_LENGTH;
|
|
||||||
while(numpackets > 0){
|
|
||||||
|
|
||||||
//for progress and packet loss calculation(new files)
|
|
||||||
if(myDetectorType == EIGER);
|
|
||||||
else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
|
||||||
tempframenum = (((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset);
|
|
||||||
else
|
|
||||||
tempframenum = ((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))& (frameIndexMask)) >> frameIndexOffset);
|
|
||||||
|
|
||||||
if(numWriterThreads == 1)
|
|
||||||
currframenum = tempframenum;
|
|
||||||
else{
|
|
||||||
if(tempframenum > currframenum)
|
|
||||||
currframenum = tempframenum;
|
|
||||||
}
|
|
||||||
#ifdef VERYDEBUG
|
|
||||||
cout << "tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//lock
|
|
||||||
if(numWriterThreads > 1)
|
|
||||||
pthread_mutex_lock(&write_mutex);
|
|
||||||
|
|
||||||
|
|
||||||
//to create new file when max reached
|
|
||||||
packetsToSave = maxPacketsPerFile - packetsInFile;
|
|
||||||
if(packetsToSave > numpackets)
|
|
||||||
packetsToSave = numpackets;
|
|
||||||
/**next time offset is still plus header length*/
|
|
||||||
fwrite(buf+offset, 1, packetsToSave * onePacketSize, sfilefd);
|
|
||||||
packetsInFile += packetsToSave;
|
|
||||||
packetsCaught += packetsToSave;
|
|
||||||
totalPacketsCaught += packetsToSave;
|
|
||||||
|
|
||||||
|
|
||||||
//new file
|
|
||||||
if(packetsInFile >= maxPacketsPerFile){
|
|
||||||
//for packet loss
|
|
||||||
lastpacket = (((packetsToSave - 1) * onePacketSize) + offset);
|
|
||||||
if(myDetectorType == EIGER);
|
|
||||||
else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
|
||||||
tempframenum = (((((uint32_t)(*((uint32_t*)(buf + lastpacket))))+1)& (frameIndexMask)) >> frameIndexOffset);
|
|
||||||
else
|
|
||||||
tempframenum = ((((uint32_t)(*((uint32_t*)(buf + lastpacket))))& (frameIndexMask)) >> frameIndexOffset);
|
|
||||||
|
|
||||||
if(numWriterThreads == 1)
|
|
||||||
currframenum = tempframenum;
|
|
||||||
else{
|
|
||||||
if(tempframenum > currframenum)
|
|
||||||
currframenum = tempframenum;
|
|
||||||
}
|
|
||||||
#ifdef VERYDEBUG
|
|
||||||
cout << "tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl;
|
|
||||||
#endif
|
|
||||||
//create
|
|
||||||
createNewFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
//unlock
|
|
||||||
if(numWriterThreads > 1)
|
|
||||||
pthread_mutex_unlock(&write_mutex);
|
|
||||||
|
|
||||||
|
|
||||||
offset += (packetsToSave * onePacketSize);
|
|
||||||
numpackets -= packetsToSave;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(numWriterThreads > 1)
|
|
||||||
pthread_mutex_lock(&write_mutex);
|
|
||||||
packetsInFile += numpackets;
|
|
||||||
packetsCaught += numpackets;
|
|
||||||
totalPacketsCaught += numpackets;
|
|
||||||
if(numWriterThreads > 1)
|
|
||||||
pthread_mutex_unlock(&write_mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1675,97 +1581,6 @@ void UDPBaseImplementation::handleDataCompression(int ithread, char* wbuffer[],
|
|||||||
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
||||||
|
|
||||||
|
|
||||||
#if defined(MYROOT1) && defined(ALLFILE_DEBUG)
|
|
||||||
writeToFile_withoutCompression(wbuf[0], numpackets,currframenum);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
eventType thisEvent = PEDESTAL;
|
|
||||||
int ndata;
|
|
||||||
char* buff = 0;
|
|
||||||
int npackets = (uint16_t)(*((uint16_t*)wbuffer[0]));
|
|
||||||
data = wbuffer[0]+ HEADER_SIZE_NUM_TOT_PACKETS;
|
|
||||||
int remainingsize = npackets * onePacketSize;
|
|
||||||
int np;
|
|
||||||
int once = 0;
|
|
||||||
double tot, tl, tr, bl, br;
|
|
||||||
int xmin = 1, ymin = 1, ix, iy;
|
|
||||||
|
|
||||||
|
|
||||||
while(buff = receiverdata[ithread]->findNextFrame(data,ndata,remainingsize)){
|
|
||||||
np = ndata/onePacketSize;
|
|
||||||
|
|
||||||
//cout<<"buff framnum:"<<ithread <<":"<< ((((uint32_t)(*((uint32_t*)buff)))& (frameIndexMask)) >> frameIndexOffset)<<endl;
|
|
||||||
|
|
||||||
if ((np == packetsPerFrame) && (buff!=NULL)){
|
|
||||||
if(nf == 1000) cout << "Thread " << ithread << ": pedestal done " << endl;
|
|
||||||
|
|
||||||
|
|
||||||
singlePhotonDet[ithread]->newFrame();
|
|
||||||
|
|
||||||
//only for moench
|
|
||||||
if(commonModeSubtractionEnable){
|
|
||||||
for(ix = xmin - 1; ix < xmax+1; ix++){
|
|
||||||
for(iy = ymin - 1; iy < ymax+1; iy++){
|
|
||||||
thisEvent = singlePhotonDet[ithread]->getEventType(buff, ix, iy, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(ix = xmin - 1; ix < xmax+1; ix++)
|
|
||||||
for(iy = ymin - 1; iy < ymax+1; iy++){
|
|
||||||
thisEvent=singlePhotonDet[ithread]->getEventType(buff, ix, iy, commonModeSubtractionEnable);
|
|
||||||
if (nf>1000) {
|
|
||||||
tot=0;
|
|
||||||
tl=0;
|
|
||||||
tr=0;
|
|
||||||
bl=0;
|
|
||||||
br=0;
|
|
||||||
if (thisEvent==PHOTON_MAX) {
|
|
||||||
receiverdata[ithread]->getFrameNumber(buff);
|
|
||||||
//iFrame=receiverdata[ithread]->getFrameNumber(buff);
|
|
||||||
#ifdef MYROOT1
|
|
||||||
myTree[ithread]->Fill();
|
|
||||||
//cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl;
|
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&write_mutex);
|
|
||||||
if((enableFileWrite) && (sfilefd))
|
|
||||||
singlePhotonDet[ithread]->writeCluster(sfilefd);
|
|
||||||
pthread_mutex_unlock(&write_mutex);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nf++;
|
|
||||||
#ifndef ALLFILE
|
|
||||||
pthread_mutex_lock(&progress_mutex);
|
|
||||||
packetsInFile += packetsPerFrame;
|
|
||||||
packetsCaught += packetsPerFrame;
|
|
||||||
totalPacketsCaught += packetsPerFrame;
|
|
||||||
if(packetsInFile >= maxPacketsPerFile)
|
|
||||||
createNewFile();
|
|
||||||
pthread_mutex_unlock(&progress_mutex);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
if(!once){
|
|
||||||
copyFrameToGui(NULL,buff);
|
|
||||||
once = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
remainingsize -= ((buff + ndata) - data);
|
|
||||||
data = buff + ndata;
|
|
||||||
if(data > (wbuffer[0] + HEADER_SIZE_NUM_TOT_PACKETS + npackets * onePacketSize) )
|
|
||||||
cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<<endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!fifoFree[0]->push(wbuffer[0]));
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
cout<<"buf freed:"<<(void*)wbuffer[0]<<endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,7 +1111,6 @@ int UDPStandardImplementation::shutDownUDPSockets(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: add a destroyListeningThreads
|
|
||||||
int UDPStandardImplementation::createListeningThreads(bool destroy){
|
int UDPStandardImplementation::createListeningThreads(bool destroy){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
@ -1656,7 +1655,7 @@ void UDPStandardImplementation::startReadout(){
|
|||||||
/********************************************/
|
/********************************************/
|
||||||
//usleep(10000000);
|
//usleep(10000000);
|
||||||
//usleep(2000000);
|
//usleep(2000000);
|
||||||
int prev = totalPacketsCaught;
|
uint32_t prev = totalPacketsCaught;
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
while(prev!=totalPacketsCaught){
|
while(prev!=totalPacketsCaught){
|
||||||
prev=totalPacketsCaught;
|
prev=totalPacketsCaught;
|
||||||
@ -1709,9 +1708,6 @@ int UDPStandardImplementation::startListening(){
|
|||||||
uint32_t lastframeheader;// for moench to check for all the packets in last frame
|
uint32_t lastframeheader;// for moench to check for all the packets in last frame
|
||||||
char* tempchar = NULL;
|
char* tempchar = NULL;
|
||||||
|
|
||||||
uint32_t prenum=0;
|
|
||||||
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
//variables that need to be checked/set before each acquisition
|
//variables that need to be checked/set before each acquisition
|
||||||
carryonBufferSize = 0;
|
carryonBufferSize = 0;
|
||||||
@ -1964,9 +1960,8 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LAST_PACKET_VALUE;
|
uint32_t LAST_PACKET_VALUE;
|
||||||
|
|
||||||
eiger_packet_header_t* wbuf_header=0;
|
|
||||||
eiger_packet_footer_t* wbuf_footer=0;
|
eiger_packet_footer_t* wbuf_footer=0;
|
||||||
|
|
||||||
eiger_packet_header_t* tempframe_header=0;
|
eiger_packet_header_t* tempframe_header=0;
|
||||||
@ -1974,7 +1969,6 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
|
|
||||||
eiger_packet_header_t* blankframe_header=0;
|
eiger_packet_header_t* blankframe_header=0;
|
||||||
unsigned char* blankframe_data=0;
|
unsigned char* blankframe_data=0;
|
||||||
eiger_packet_footer_t* blankframe_footer=0;
|
|
||||||
|
|
||||||
//last packet numbers for different dynamic ranges
|
//last packet numbers for different dynamic ranges
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
@ -2252,7 +2246,7 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
||||||
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
||||||
cprintf(BG_RED, "wrong blank mismatch num4 earlier2! "
|
cprintf(BG_RED, "wrong blank mismatch num4 earlier2! "
|
||||||
"i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%x\n",
|
"i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%p\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
*( (uint16_t*) tempframe_header->missingpacket),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
*( (uint16_t*) blankframe_header->missingpacket),
|
*( (uint16_t*) blankframe_header->missingpacket),
|
||||||
@ -2303,7 +2297,7 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
blankframe_header = (eiger_packet_header_t*) blankframe[blankoffset];
|
||||||
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
if (*( (uint16_t*) tempframe_header->missingpacket)!= missingPacketValue){
|
||||||
cprintf(BG_RED, "correct blank mismatch num4 earlier2! "
|
cprintf(BG_RED, "correct blank mismatch num4 earlier2! "
|
||||||
"i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%x\n",
|
"i:%d pnum:%d fnum:%d missingpacket:0x%x actual missingpacket:0x%x add:0x%p\n",
|
||||||
i,tempoffset[i],tempframenum[i],
|
i,tempoffset[i],tempframenum[i],
|
||||||
*( (uint16_t*) tempframe_header->missingpacket),
|
*( (uint16_t*) tempframe_header->missingpacket),
|
||||||
*( (uint16_t*) blankframe_header->missingpacket),
|
*( (uint16_t*) blankframe_header->missingpacket),
|
||||||
@ -2320,7 +2314,7 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
blankoffset ++;
|
blankoffset ++;
|
||||||
}
|
}
|
||||||
//add current packet
|
//add current packet
|
||||||
if(currentpacketheader[i] != (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){
|
if(currentpacketheader[i] != (uint32_t)(tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){
|
||||||
cprintf(BG_RED, "correct pnum mismatch earlier! tempoffset[%d]:%d pnum:%d fnum:%d rfnum:%d\n",
|
cprintf(BG_RED, "correct pnum mismatch earlier! tempoffset[%d]:%d pnum:%d fnum:%d rfnum:%d\n",
|
||||||
i,tempoffset[i],currentpacketheader[i],
|
i,tempoffset[i],currentpacketheader[i],
|
||||||
tempframenum[i],(uint32_t)(*( (uint64_t*) wbuf_footer)));
|
tempframenum[i],(uint32_t)(*( (uint64_t*) wbuf_footer)));
|
||||||
@ -2335,7 +2329,7 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
i,*( (uint16_t*) tempframe_footer->packetnum),tempoffset[i]);
|
i,*( (uint16_t*) tempframe_footer->packetnum),tempoffset[i]);
|
||||||
#endif
|
#endif
|
||||||
if(*( (uint16_t*) tempframe_footer->packetnum)!= (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){
|
if(*( (uint16_t*) tempframe_footer->packetnum)!= (tempoffset[i]-(i*packetsPerFrame/numListeningThreads))+1){
|
||||||
cprintf(BG_RED, "pnum mismatch num4 earlier! i:%d pnum:%d pnum orig:%d fnum:%d add:0x%x\n",
|
cprintf(BG_RED, "pnum mismatch num4 earlier! i:%d pnum:%d pnum orig:%d fnum:%d add:0x%p\n",
|
||||||
i,*( (uint16_t*) tempframe_footer->packetnum),*( (uint16_t*) wbuf_footer->packetnum),
|
i,*( (uint16_t*) tempframe_footer->packetnum),*( (uint16_t*) wbuf_footer->packetnum),
|
||||||
tempframenum[i],(void*)(tempbuffer[tempoffset[i]]));
|
tempframenum[i],(void*)(tempbuffer[tempoffset[i]]));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -2815,7 +2809,7 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf[],int n
|
|||||||
cprintf(GREEN,"totalPacketsCaught:%d\n", totalPacketsCaught);
|
cprintf(GREEN,"totalPacketsCaught:%d\n", totalPacketsCaught);
|
||||||
#endif
|
#endif
|
||||||
//new file
|
//new file
|
||||||
if(packetsInFile >= maxPacketsPerFile){
|
if(packetsInFile >= (uint32_t)maxPacketsPerFile){
|
||||||
|
|
||||||
//for packet loss, because currframenum is the latest one for eiger
|
//for packet loss, because currframenum is the latest one for eiger
|
||||||
if(myDetectorType != EIGER){
|
if(myDetectorType != EIGER){
|
||||||
@ -2870,7 +2864,7 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf[],int n
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer[],int npackets){
|
void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer[],int npackets){
|
||||||
int i,j, missingpacket,port = 0, pnuminc;
|
int i, missingpacket,port = 0;
|
||||||
|
|
||||||
|
|
||||||
if (cbAction < DO_EVERYTHING){
|
if (cbAction < DO_EVERYTHING){
|
||||||
@ -3069,7 +3063,7 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer
|
|||||||
packetsInFile += packetsPerFrame;
|
packetsInFile += packetsPerFrame;
|
||||||
packetsCaught += packetsPerFrame;
|
packetsCaught += packetsPerFrame;
|
||||||
totalPacketsCaught += packetsPerFrame;
|
totalPacketsCaught += packetsPerFrame;
|
||||||
if(packetsInFile >= maxPacketsPerFile)
|
if(packetsInFile >= (uint32_t)maxPacketsPerFile)
|
||||||
createNewFile();
|
createNewFile();
|
||||||
pthread_mutex_unlock(&progress_mutex);
|
pthread_mutex_unlock(&progress_mutex);
|
||||||
|
|
||||||
|
@ -39,10 +39,11 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
|
|||||||
shortFrame(-1),
|
shortFrame(-1),
|
||||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
||||||
dynamicrange(16),
|
dynamicrange(16),
|
||||||
socket(NULL),
|
|
||||||
killTCPServerThread(0),
|
killTCPServerThread(0),
|
||||||
tenGigaEnable(0), portNumber(DEFAULT_PORTNO+2),
|
tenGigaEnable(0),
|
||||||
bottom(bot){
|
portNumber(DEFAULT_PORTNO+2),
|
||||||
|
bottom(bot),
|
||||||
|
socket(NULL){
|
||||||
|
|
||||||
int port_no=portNumber;
|
int port_no=portNumber;
|
||||||
if(receiverBase == NULL) receiverBase = 0;
|
if(receiverBase == NULL) receiverBase = 0;
|
||||||
|
Reference in New Issue
Block a user