diff --git a/slsReceiverSoftware/include/Fifo.h b/slsReceiverSoftware/include/Fifo.h index f91493976..df02c2d04 100644 --- a/slsReceiverSoftware/include/Fifo.h +++ b/slsReceiverSoftware/include/Fifo.h @@ -21,10 +21,10 @@ class Fifo : private virtual slsReceiverDefs { * Constructor * Calls CreateFifos that creates fifos and allocates memory * @param fifoItemSize size of each fifo item - * @param fifoDepth fifo depth + * @param depth fifo depth * @param success true if successful, else false */ - Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success); + Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success); /** * Destructor @@ -67,15 +67,20 @@ class Fifo : private virtual slsReceiverDefs { */ int GetMaxLevelForFifoBound(); + /** + * Get Minimum Level filled in Fifo Free + * and reset this value to max for next intake + */ + int GetMinLevelForFifoFree(); + private: /** * Create Fifos, allocate memory & push addresses into fifo * @param fifoItemSize size of each fifo item - * @param fifoDepth fifo depth * @return OK if successful, else FAIL */ - int CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth); + int CreateFifos(uint32_t fifoItemSize); /** * Destroy Fifos and deallocate memory @@ -101,5 +106,9 @@ class Fifo : private virtual slsReceiverDefs { /** Circular Fifo pointing to addresses of to be streamed data in memory */ CircularFifo* fifoStream; + /** Fifo depth set */ + int fifoDepth; + volatile int status_fifoBound; + volatile int status_fifoFree; }; diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp index 70abdca43..f8316672f 100644 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ b/slsReceiverSoftware/src/BinaryFile.cpp @@ -66,11 +66,11 @@ int BinaryFile::CreateFile(uint64_t fnum) { else { char c[1000]; strcpy(c, currentFileName.c_str()); if (loss) - bprintf(RED,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n", - *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , basename(c)); + bprintf(RED,"[%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)); else - bprintf(GREEN,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n", - *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), basename(c)); + 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; diff --git a/slsReceiverSoftware/src/Fifo.cpp b/slsReceiverSoftware/src/Fifo.cpp index 1850954aa..9f46788e0 100644 --- a/slsReceiverSoftware/src/Fifo.cpp +++ b/slsReceiverSoftware/src/Fifo.cpp @@ -14,16 +14,18 @@ using namespace std; int Fifo::NumberofFifoClassObjects(0); -Fifo::Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success): +Fifo::Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success): index(NumberofFifoClassObjects), memory(0), fifoBound(0), fifoFree(0), fifoStream(0), - status_fifoBound(0){ + fifoDepth(depth), + status_fifoBound(0), + status_fifoFree(depth){ FILE_LOG (logDEBUG) << __AT__ << " called"; NumberofFifoClassObjects++; - if(CreateFifos(fifoItemSize, fifoDepth) == FAIL) + if(CreateFifos(fifoItemSize) == FAIL) success = false; } @@ -37,11 +39,12 @@ Fifo::~Fifo() { -int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) { +int Fifo::CreateFifos(uint32_t fifoItemSize) { FILE_LOG (logDEBUG) << __AT__ << " called"; //destroy if not already DestroyFifos(); + //create fifos fifoBound = new CircularFifo(fifoDepth); fifoFree = new CircularFifo(fifoDepth); @@ -67,6 +70,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) { buffer += fifoItemSize; } } + FILE_LOG (logDEBUG) << "Fifo Reconstructed Depth " << index << ": " << fifoDepth; return OK; } @@ -100,6 +104,9 @@ void Fifo::FreeAddress(char*& address) { } void Fifo::GetNewAddress(char*& address) { + int temp = fifoFree->getSemValue(); + if (temp < status_fifoFree) + status_fifoFree = temp; fifoFree->pop(address); } @@ -128,3 +135,10 @@ int Fifo::GetMaxLevelForFifoBound() { return temp; } + +int Fifo::GetMinLevelForFifoFree() { + int temp = status_fifoFree; + status_fifoFree = fifoDepth; + return temp; +} +