mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-16 06:47:14 +02:00
implemented fifo depth configurable from client
This commit is contained in:
@ -170,7 +170,7 @@ void UDPStandardImplementation::initializeMembers(){
|
||||
}
|
||||
sfilefd = NULL;
|
||||
numberofJobsPerBuffer = -1;
|
||||
fifoDepth = 0;
|
||||
fifoSize = 0;
|
||||
|
||||
//***receiver to GUI parameters***
|
||||
latestData = NULL;
|
||||
@ -251,16 +251,15 @@ void UDPStandardImplementation::initializeFilter(){
|
||||
int UDPStandardImplementation::setupFifoStructure(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
|
||||
|
||||
//number of jobs per buffer
|
||||
int64_t i;
|
||||
int oldNumberofJobsPerBuffer = numberofJobsPerBuffer;
|
||||
uint32_t oldFifoSize = fifoDepth;
|
||||
|
||||
//eiger always listens to 1 packet at a time
|
||||
if(myDetectorType == EIGER){
|
||||
numberofJobsPerBuffer = 1;
|
||||
FILE_LOG(logDEBUG) << "Info: 1 packet per buffer";
|
||||
}
|
||||
|
||||
//else calculate best possible number of frames to listen to at a time (for fast readouts like gotthard)
|
||||
else{
|
||||
//if frequency to gui is not random (every nth frame), then listen to only n frames per buffer
|
||||
@ -284,29 +283,41 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
FILE_LOG(logINFO) << "Number of Frames per buffer:" << numberofJobsPerBuffer << endl;
|
||||
}
|
||||
|
||||
//set fifo depth
|
||||
//eiger listens to 1 packet at a time and size changes depending on packets per frame
|
||||
if(myDetectorType == EIGER)
|
||||
fifoDepth = EIGER_FIFO_SIZE * packetsPerFrame;
|
||||
else{
|
||||
fifoDepth = GOTTHARD_FIFO_SIZE;
|
||||
if(myDetectorType == MOENCH)
|
||||
fifoDepth = MOENCH_FIFO_SIZE;
|
||||
else if(myDetectorType == PROPIX)
|
||||
fifoDepth = PROPIX_FIFO_SIZE;
|
||||
//reduce fifo depth if more frames listened to at a time
|
||||
if(fifoDepth % numberofJobsPerBuffer)
|
||||
fifoDepth = (fifoDepth/numberofJobsPerBuffer)+1;
|
||||
else
|
||||
fifoDepth = fifoDepth/numberofJobsPerBuffer;
|
||||
|
||||
|
||||
// fifo depth
|
||||
uint32_t oldFifoSize = fifoSize;
|
||||
//default
|
||||
if(!fifoDepth){
|
||||
switch(myDetectorType){
|
||||
case GOTTHARD: fifoSize = GOTTHARD_FIFO_SIZE; break;
|
||||
case MOENCH: fifoSize = MOENCH_FIFO_SIZE; break;
|
||||
case PROPIX: fifoSize = PROPIX_FIFO_SIZE; break;
|
||||
case EIGER: fifoSize = EIGER_FIFO_SIZE * packetsPerFrame; break;//listens to 1 packet at a time and size depends on packetsperframe
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Info: Fifo Depth:" << fifoDepth;
|
||||
|
||||
//change by user
|
||||
else{
|
||||
if(myDetectorType == EIGER)
|
||||
fifoSize = fifoDepth * packetsPerFrame;
|
||||
else fifoSize = fifoDepth;
|
||||
}
|
||||
|
||||
//reduce fifo depth if > 1 numberofJobsPerBuffer
|
||||
if(fifoSize % numberofJobsPerBuffer)
|
||||
fifoSize = (fifoSize/numberofJobsPerBuffer)+1;
|
||||
else
|
||||
fifoSize = fifoSize/numberofJobsPerBuffer;
|
||||
|
||||
//do not rebuild fifo structure if it is the same
|
||||
if((oldNumberofJobsPerBuffer == numberofJobsPerBuffer) && (oldFifoSize == fifoDepth))
|
||||
//do not rebuild fifo structure if it is the same (oldfifosize differs only for different packetsperframe)
|
||||
if((oldNumberofJobsPerBuffer == numberofJobsPerBuffer) && (oldFifoSize == fifoSize))
|
||||
return OK;
|
||||
FILE_LOG(logINFO) << "Info: Total Fifo Size:" << fifoSize;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//set up fifo structure
|
||||
@ -329,13 +340,11 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
if(mem0[i]) free(mem0[i]);
|
||||
|
||||
//creating
|
||||
fifoFree[i] = new CircularFifo<char>(fifoDepth);
|
||||
fifo[i] = new CircularFifo<char>(fifoDepth);
|
||||
|
||||
//cout<<"buffersize:"<<bufferSize<<endl;
|
||||
fifoFree[i] = new CircularFifo<char>(fifoSize);
|
||||
fifo[i] = new CircularFifo<char>(fifoSize);
|
||||
|
||||
//allocate memory
|
||||
mem0[i] = (char*)malloc((bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * fifoDepth);
|
||||
mem0[i] = (char*)malloc((bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * fifoSize);
|
||||
if (mem0[i] == NULL){
|
||||
cprintf(BG_RED,"Error: Could not allocate memory for listening \n");
|
||||
return FAIL;
|
||||
@ -343,7 +352,7 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
|
||||
//push free address into fifoFree
|
||||
buffer[i]=mem0[i];
|
||||
while (buffer[i] < (mem0[i]+(bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * (fifoDepth-1))) {
|
||||
while (buffer[i] < (mem0[i]+(bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * (fifoSize-1))) {
|
||||
fifoFree[i]->push(buffer[i]);
|
||||
sprintf(buffer[i],"mem%d",i);
|
||||
#ifdef DEBUG5
|
||||
@ -352,7 +361,7 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
buffer[i] += (bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Info: Fifo structure(s) reconstructed";
|
||||
cout << "Fifo structure(s) reconstructed" << endl;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -612,7 +621,16 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
|
||||
}
|
||||
|
||||
|
||||
int UDPStandardImplementation::setFifoDepth(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
|
||||
if(i != fifoDepth){
|
||||
FILE_LOG(logINFO) << "Fifo Depth: " << i << endl;
|
||||
fifoDepth = i;
|
||||
return setupFifoStructure();
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -641,7 +659,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
case EIGER:
|
||||
case JUNGFRAUCTB:
|
||||
case JUNGFRAU:
|
||||
FILE_LOG(logINFO) << " ***** This is a " << getDetectorType(d) << " Receiver *****";
|
||||
FILE_LOG(logINFO) << " ***** " << getDetectorType(d) << " Receiver *****";
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR) << "This is an unknown receiver type " << (int)d;
|
||||
@ -660,7 +678,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
frameIndexOffset = GOTTHARD_FRAME_INDEX_OFFSET;
|
||||
packetIndexMask = GOTTHARD_PACKET_INDEX_MASK;
|
||||
maxPacketsPerFile = MAX_FRAMES_PER_FILE * GOTTHARD_PACKETS_PER_FRAME;
|
||||
fifoDepth = GOTTHARD_FIFO_SIZE;
|
||||
fifoSize = GOTTHARD_FIFO_SIZE;
|
||||
//footerOffset = Not applicable;
|
||||
break;
|
||||
case PROPIX:
|
||||
@ -673,7 +691,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
frameIndexOffset = PROPIX_FRAME_INDEX_OFFSET;
|
||||
packetIndexMask = PROPIX_PACKET_INDEX_MASK;
|
||||
maxPacketsPerFile = MAX_FRAMES_PER_FILE * PROPIX_PACKETS_PER_FRAME;
|
||||
fifoDepth = PROPIX_FIFO_SIZE;
|
||||
fifoSize = PROPIX_FIFO_SIZE;
|
||||
//footerOffset = Not applicable;
|
||||
break;
|
||||
case MOENCH:
|
||||
@ -686,7 +704,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET;
|
||||
packetIndexMask = MOENCH_PACKET_INDEX_MASK;
|
||||
maxPacketsPerFile = MOENCH_MAX_FRAMES_PER_FILE * MOENCH_PACKETS_PER_FRAME;
|
||||
fifoDepth = MOENCH_FIFO_SIZE;
|
||||
fifoSize = MOENCH_FIFO_SIZE;
|
||||
//footerOffset = Not applicable;
|
||||
break;
|
||||
case EIGER:
|
||||
@ -700,7 +718,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
frameIndexOffset = EIGER_FRAME_INDEX_OFFSET;
|
||||
packetIndexMask = EIGER_PACKET_INDEX_MASK;
|
||||
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
|
||||
fifoDepth = EIGER_FIFO_SIZE;
|
||||
fifoSize = EIGER_FIFO_SIZE;
|
||||
footerOffset = EIGER_PACKET_HEADER_SIZE + oneDataSize;
|
||||
break;
|
||||
case JUNGFRAUCTB:
|
||||
@ -714,7 +732,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
frameIndexOffset = JCTB_FRAME_INDEX_OFFSET;
|
||||
packetIndexMask = JCTB_PACKET_INDEX_MASK;
|
||||
maxPacketsPerFile = JFCTB_MAX_FRAMES_PER_FILE * JCTB_PACKETS_PER_FRAME;
|
||||
fifoDepth = JCTB_FIFO_SIZE;
|
||||
fifoSize = JCTB_FIFO_SIZE;
|
||||
//footerOffset = Not applicable;
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user