mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
moved statistics to listener
This commit is contained in:
parent
e93f53f459
commit
608f292e4f
@ -189,6 +189,11 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
uint32_t CreateAnImage(char* buf);
|
uint32_t CreateAnImage(char* buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print Fifo Statistics
|
||||||
|
*/
|
||||||
|
void PrintFifoStatistics();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** type of thread */
|
/** type of thread */
|
||||||
@ -281,5 +286,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
|
|
||||||
/** if the udp socket is connected */
|
/** if the udp socket is connected */
|
||||||
bool udpSocketAlive;
|
bool udpSocketAlive;
|
||||||
|
|
||||||
|
uint32_t numPacketsStatistic;
|
||||||
|
|
||||||
|
uint32_t numFramesStatistic;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,11 +45,12 @@ slsReceiverDefs::fileFormat BinaryFile::GetFileType() {
|
|||||||
|
|
||||||
|
|
||||||
int BinaryFile::CreateFile(uint64_t fnum) {
|
int BinaryFile::CreateFile(uint64_t fnum) {
|
||||||
|
/*
|
||||||
//calculate packet loss
|
//calculate packet loss
|
||||||
int64_t loss = -1;
|
int64_t loss = -1;
|
||||||
if (numFramesInFile)
|
if (numFramesInFile)
|
||||||
loss = (numFramesInFile*(*packetsPerFrame)) - numActualPacketsInFile;
|
loss = (numFramesInFile*(*packetsPerFrame)) - numActualPacketsInFile;
|
||||||
|
*/
|
||||||
numFramesInFile = 0;
|
numFramesInFile = 0;
|
||||||
numActualPacketsInFile = 0;
|
numActualPacketsInFile = 0;
|
||||||
|
|
||||||
@ -60,8 +61,11 @@ int BinaryFile::CreateFile(uint64_t fnum) {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
//first file, print entrire path
|
//first file, print entrire path
|
||||||
if (loss == -1)
|
/*if (loss == -1)*/
|
||||||
|
if (!numFramesInFile)
|
||||||
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
|
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
|
||||||
|
|
||||||
|
/*
|
||||||
//other files
|
//other files
|
||||||
else {
|
else {
|
||||||
char c[1000]; strcpy(c, currentFileName.c_str());
|
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",
|
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));
|
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), basename(c));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,9 @@ void Listener::ResetParametersforNewMeasurement() {
|
|||||||
delete [] listeningPacket;
|
delete [] listeningPacket;
|
||||||
listeningPacket = new char[generalData->packetSize];
|
listeningPacket = new char[generalData->packetSize];
|
||||||
memset(listeningPacket,0,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
|
(*((uint64_t*)(buffer + FIFO_HEADER_NUMBYTES ))) = currentFrameIndex; //for those returning earlier
|
||||||
currentFrameIndex++;
|
currentFrameIndex++;
|
||||||
|
|
||||||
|
|
||||||
//push into fifo
|
//push into fifo
|
||||||
fifo->PushAddress(buffer);
|
fifo->PushAddress(buffer);
|
||||||
|
|
||||||
|
//Statistics
|
||||||
|
if (numFramesStatistic >= generalData->maxFramesPerFile)
|
||||||
|
PrintFifoStatistics();
|
||||||
|
numFramesStatistic++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -417,6 +424,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
|
|
||||||
//update parameters
|
//update parameters
|
||||||
numPacketsCaught++; //record immediately to get more time before socket shutdown
|
numPacketsCaught++; //record immediately to get more time before socket shutdown
|
||||||
|
numPacketsStatistic++;
|
||||||
|
|
||||||
// -------------------------- new header ----------------------------------------------------------------------
|
// -------------------------- new header ----------------------------------------------------------------------
|
||||||
if (standardheader) {
|
if (standardheader) {
|
||||||
@ -449,8 +457,6 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
if (!measurementStartedFlag)
|
if (!measurementStartedFlag)
|
||||||
RecordFirstIndices(fnum);
|
RecordFirstIndices(fnum);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//future packet by looking at image number (all other detectors)
|
//future packet by looking at image number (all other detectors)
|
||||||
if (fnum != currentFrameIndex) {
|
if (fnum != currentFrameIndex) {
|
||||||
//bprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets );
|
//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;
|
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);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user