From 9b9876e287fcf2e7e5964b7feb51eb770496bde9 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 8 Nov 2016 16:03:44 +0100 Subject: [PATCH] added the print temp losses --- .../include/UDPStandardImplementation.h | 5 +- .../src/UDPStandardImplementation.cpp | 57 ++++++++++++++----- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index 413d98147..c7bf94813 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -624,7 +624,10 @@ private: /** Previous Frame number from buffer to calculate loss */ int64_t frameNumberInPreviousFile[MAX_NUMBER_OF_WRITER_THREADS]; - + /** Previous Frame number from last check to calculate loss */ + int64_t frameNumberInPreviousCheck[MAX_NUMBER_OF_WRITER_THREADS]; + /** total packet count from last check */ + int64_t totalWritingPacketCountFromLastCheck[MAX_NUMBER_OF_WRITER_THREADS]; /* Acquisition started */ diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 4ea310b26..e810cc1ba 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -167,9 +167,11 @@ void UDPStandardImplementation::initializeMembers(){ frameIndex[i] = 0; currentFrameNumber[i] = 0; frameNumberInPreviousFile[i] = 0; + frameNumberInPreviousCheck[i] = 0; lastFrameNumberInFile[i] = -1; totalPacketsInFile[i] = 0; totalWritingPacketCount[i] = 0; + totalWritingPacketCountFromLastCheck[i] = 0; } @@ -947,6 +949,7 @@ int UDPStandardImplementation::startReceiver(char *c){ lastFrameNumberInFile[i] = -1; totalPacketsInFile[i] = 0; totalWritingPacketCount[i] = 0; + totalWritingPacketCountFromLastCheck[i] = 0; if(sfilefd[i]){ fclose(sfilefd[i]); sfilefd[i] = 0; @@ -1582,11 +1585,7 @@ int UDPStandardImplementation::createNewFile(int ithread){ setvbuf(sfilefd[ithread],NULL,_IOFBF,BUF_SIZE); //Print packet loss and filenames - if(!totalWritingPacketCount[ithread]){ - frameNumberInPreviousFile[ithread] = -1; - //printf("Thread:%d File:%s\n",ithread,completeFileName[ithread]); - }else{ - + if(totalWritingPacketCount[ithread]){ printf("\nThread:%d File:%s\n" "Packets Lost:%d" "\t\tPacketsInFile:%lld\tCurrentFrameNumber:%lld\tPreviousFrameNumber:%lld\n", @@ -1610,6 +1609,7 @@ int UDPStandardImplementation::createNewFile(int ithread){ + return OK; } @@ -2738,15 +2738,21 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer){ fwrite((void*)fileHeader[ithread], 1, FILE_HEADER_SIZE, sfilefd[ithread]); } - if(totalWritingPacketCount[ithread]){ - printf("\nThread:%d File:%s\n" - "Packets Lost:%d" - "\t\tPacketsInFile:%lld\tCurrentFrameNumber:%lld\tPreviousFrameNumber:%lld\n", - ithread,completeFileName[ithread], - ( ((int)(currentFrameNumber[ithread]-frameNumberInPreviousFile[ithread])*packetsPerFrame) - totalPacketsInFile[ithread]), - totalPacketsInFile[ithread],currentFrameNumber[ithread],frameNumberInPreviousFile[ithread] - ); + //Print packet loss + if(totalWritingPacketCountFromLastCheck[ithread]){ + printf("\nThread:%d" + "\t\tPackets Lost:%d" + "\tPacketsFromLastCheck:%lld" + "\tCurrentFrameNumber:%lld" + "\tPreviousFrameNumber:%lld\n", + ithread, + ( ((int)(currentFrameNumber[ithread]-frameNumberInPreviousCheck[ithread])*packetsPerFrame) - totalWritingPacketCountFromLastCheck[ithread]), + totalWritingPacketCountFromLastCheck[ithread], + currentFrameNumber[ithread], + frameNumberInPreviousCheck[ithread] + ); } + closeFile(ithread); pthread_mutex_lock(&statusMutex); writerThreadsMask^=(1< 1) pthread_mutex_unlock(&writeMutex); + + //Print packet loss and filenames + if(totalWritingPacketCountFromLastCheck[ithread] && (currentFrameNumber[ithread]%(maxFramesPerFile/10)) == 0){ + printf("\nThread:%d" + "\t\tPackets Lost:%d" + "\tPacketsFromLastCheck:%lld" + "\tCurrentFrameNumber:%lld" + "\tPreviousFrameNumber:%lld\n", + ithread, + ( ((int)(currentFrameNumber[ithread]-frameNumberInPreviousCheck[ithread])*packetsPerFrame) - totalWritingPacketCountFromLastCheck[ithread]), + totalWritingPacketCountFromLastCheck[ithread], + currentFrameNumber[ithread], + frameNumberInPreviousCheck[ithread] + ); + } + + //reset counters for each new file + if(totalWritingPacketCountFromLastCheck[ithread]){ + frameNumberInPreviousCheck[ithread] = currentFrameNumber[ithread]; + totalWritingPacketCountFromLastCheck[ithread] = 0; + }else + frameNumberInPreviousCheck[ithread] = -1; + + + } #ifdef DEBUG4 cprintf(GREEN,"Writing_Thread: Writing done\nGoing to copy frame\n");