mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
changes for min fifo level
This commit is contained in:
parent
efad86335f
commit
e93f53f459
@ -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<char>* fifoStream;
|
||||
|
||||
/** Fifo depth set */
|
||||
int fifoDepth;
|
||||
|
||||
volatile int status_fifoBound;
|
||||
volatile int status_fifoFree;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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<char>(fifoDepth);
|
||||
fifoFree = new CircularFifo<char>(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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user