moved statistics to listener

This commit is contained in:
Dhanya Maliakal 2017-08-18 16:50:19 +02:00
parent e93f53f459
commit 608f292e4f
3 changed files with 41 additions and 5 deletions

View File

@ -189,6 +189,11 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
*/
uint32_t CreateAnImage(char* buf);
/**
* Print Fifo Statistics
*/
void PrintFifoStatistics();
/** type of thread */
@ -281,5 +286,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** if the udp socket is connected */
bool udpSocketAlive;
uint32_t numPacketsStatistic;
uint32_t numFramesStatistic;
};

View File

@ -45,11 +45,12 @@ slsReceiverDefs::fileFormat BinaryFile::GetFileType() {
int BinaryFile::CreateFile(uint64_t fnum) {
/*
//calculate packet loss
int64_t loss = -1;
if (numFramesInFile)
loss = (numFramesInFile*(*packetsPerFrame)) - numActualPacketsInFile;
*/
numFramesInFile = 0;
numActualPacketsInFile = 0;
@ -60,8 +61,11 @@ int BinaryFile::CreateFile(uint64_t fnum) {
return FAIL;
//first file, print entrire path
if (loss == -1)
/*if (loss == -1)*/
if (!numFramesInFile)
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
/*
//other files
else {
char c[1000]; strcpy(c, currentFileName.c_str());
@ -72,6 +76,7 @@ int BinaryFile::CreateFile(uint64_t fnum) {
bprintf(GREEN,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tNew_File:%s\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), basename(c));
}
*/
return OK;
}

View File

@ -161,6 +161,9 @@ void Listener::ResetParametersforNewMeasurement() {
delete [] listeningPacket;
listeningPacket = new char[generalData->packetSize];
memset(listeningPacket,0,generalData->packetSize);
numPacketsStatistic = 0;
numFramesStatistic = 0;
}
@ -289,10 +292,14 @@ void Listener::ThreadExecution() {
(*((uint64_t*)(buffer + FIFO_HEADER_NUMBYTES ))) = currentFrameIndex; //for those returning earlier
currentFrameIndex++;
//push into fifo
fifo->PushAddress(buffer);
//Statistics
if (numFramesStatistic >= generalData->maxFramesPerFile)
PrintFifoStatistics();
numFramesStatistic++;
}
@ -417,6 +424,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//update parameters
numPacketsCaught++; //record immediately to get more time before socket shutdown
numPacketsStatistic++;
// -------------------------- new header ----------------------------------------------------------------------
if (standardheader) {
@ -449,8 +457,6 @@ uint32_t Listener::ListenToAnImage(char* buf) {
if (!measurementStartedFlag)
RecordFirstIndices(fnum);
//future packet by looking at image number (all other detectors)
if (fnum != currentFrameIndex) {
//bprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets );
@ -516,3 +522,19 @@ uint32_t Listener::CreateAnImage(char* buf) {
return generalData->imageSize;
}
void Listener::PrintFifoStatistics() {
//calculate packet loss
int64_t loss = -1;
loss = (numFramesStatistic*(generalData->packetsPerFrame)) - numPacketsStatistic;
numPacketsStatistic = 0;
numFramesStatistic = 0;
if (loss)
bprintf(RED,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , fifo->GetMinLevelForFifoFree(), currentFrameIndex);
else
bprintf(GREEN,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), currentFrameIndex);
}