mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
implemented fifo depth configurable from client
This commit is contained in:
parent
003d0255c3
commit
777f04331d
@ -179,6 +179,13 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
bool getTenGigaEnable() const;
|
||||
|
||||
/**
|
||||
* Get Fifo Depth
|
||||
* @return fifo depth
|
||||
*/
|
||||
uint32_t getFifoDepth() const;
|
||||
|
||||
|
||||
//***receiver status***
|
||||
/**
|
||||
* Get Listening Status of Receiver
|
||||
@ -324,6 +331,13 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
int setTenGigaEnable(const bool b);
|
||||
|
||||
/**
|
||||
* Set Fifo Depth
|
||||
* @param i fifo depth value
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setFifoDepth(const uint32_t i);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
@ -460,6 +474,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
uint32_t dynamicRange;
|
||||
/** Ten Giga Enable*/
|
||||
bool tengigaEnable;
|
||||
/** Fifo Depth */
|
||||
uint32_t fifoDepth;
|
||||
/** Bottom Half Module Enable */
|
||||
bool bottomEnable;
|
||||
|
||||
|
@ -235,6 +235,12 @@ class UDPInterface {
|
||||
*/
|
||||
virtual bool getTenGigaEnable() const = 0;
|
||||
|
||||
/**
|
||||
* Get Fifo Depth
|
||||
* @return fifo depth
|
||||
*/
|
||||
virtual uint32_t getFifoDepth() const = 0;
|
||||
|
||||
//***receiver status***
|
||||
/**
|
||||
* Get Listening Status of Receiver
|
||||
@ -378,6 +384,13 @@ class UDPInterface {
|
||||
*/
|
||||
virtual int setTenGigaEnable(const bool b) = 0;
|
||||
|
||||
/**
|
||||
* Set Fifo Depth
|
||||
* @param i fifo depth value
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setFifoDepth(const uint32_t i) = 0;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
|
@ -122,6 +122,13 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
int setTenGigaEnable(const bool b);
|
||||
|
||||
|
||||
/**
|
||||
* Overridden method
|
||||
* Set Fifo Depth
|
||||
* @param i fifo depth value
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setFifoDepth(const uint32_t i);
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
@ -584,8 +591,8 @@ private:
|
||||
/** Number of Jobs Per Buffer */
|
||||
int numberofJobsPerBuffer;
|
||||
|
||||
/** Fifo Depth */
|
||||
uint32_t fifoDepth;
|
||||
/** Total fifo size */
|
||||
uint32_t fifoSize;
|
||||
|
||||
/** Missing Packet identifier value */
|
||||
const static uint16_t missingPacketValue = 0xFFFF;
|
||||
|
@ -207,6 +207,9 @@ private:
|
||||
/** enable 10Gbe */
|
||||
int enable_tengiga();
|
||||
|
||||
/** set fifo depth */
|
||||
int set_fifo_depth();
|
||||
|
||||
//General Functions
|
||||
/** Locks Receiver */
|
||||
int lock_receiver();
|
||||
|
@ -48,7 +48,8 @@ enum {
|
||||
F_ENABLE_RECEIVER_COMPRESSION, /**< enable compression in receiver */
|
||||
F_ENABLE_RECEIVER_OVERWRITE, /**< set overwrite flag in receiver */
|
||||
|
||||
F_ENABLE_RECEIVER_TEN_GIGA /**< enable 10Gbe in receiver */
|
||||
F_ENABLE_RECEIVER_TEN_GIGA, /**< enable 10Gbe in receiver */
|
||||
F_SET_RECEIVER_FIFO_DEPTH /**< set receiver fifo depth */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
};
|
||||
|
@ -44,6 +44,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
numberOfFrames = 0;
|
||||
dynamicRange = 16;
|
||||
tengigaEnable = false;
|
||||
fifoDepth = 0;
|
||||
bottomEnable = false;
|
||||
|
||||
//***receiver parameters***
|
||||
@ -181,6 +182,8 @@ uint32_t UDPBaseImplementation::getDynamicRange() const{ FILE_LOG(logDEBUG) << _
|
||||
|
||||
bool UDPBaseImplementation::getTenGigaEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return tengigaEnable;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFifoDepth() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fifoDepth;}
|
||||
|
||||
/***receiver status***/
|
||||
slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return status;}
|
||||
|
||||
@ -358,6 +361,15 @@ int UDPBaseImplementation::setTenGigaEnable(const bool b){
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setFifoDepth(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
fifoDepth = i;
|
||||
FILE_LOG(logINFO) << "Fifo Depth: " << i;
|
||||
|
||||
//overridden functions might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
|
@ -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:
|
||||
|
@ -252,6 +252,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_ENABLE_RECEIVER_OVERWRITE] = &slsReceiverTCPIPInterface::enable_overwrite;
|
||||
|
||||
flist[F_ENABLE_RECEIVER_TEN_GIGA] = &slsReceiverTCPIPInterface::enable_tengiga;
|
||||
flist[F_SET_RECEIVER_FIFO_DEPTH] = &slsReceiverTCPIPInterface::set_fifo_depth;
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
@ -2484,6 +2485,81 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_fifo_depth() {
|
||||
ret=OK;
|
||||
int value=-1;
|
||||
int retval=-100;
|
||||
strcpy(mess,"Could not set/get fifo depth for receiver\n");
|
||||
|
||||
// receive arguments
|
||||
if(socket->ReceiveDataOnly(&value,sizeof(value)) < 0 ){
|
||||
strcpy(mess,"Error reading from socket\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
if (ret==OK) {
|
||||
if(value >= 0){
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else if (receiverBase == NULL){
|
||||
strcpy(mess,"Receiver not set up\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
else if(receiverBase->getStatus()==RUNNING){
|
||||
strcpy(mess,"Cannot set/get fifo depth while status is running\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
else{
|
||||
if(value >= 0){
|
||||
ret = receiverBase->setFifoDepth(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (receiverBase == NULL){
|
||||
strcpy(mess,"Receiver not set up\n");
|
||||
ret=FAIL;
|
||||
}else{
|
||||
retval = receiverBase->getFifoDepth();
|
||||
if(value >= 0 && retval != value)
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ret==OK && socket->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
// send answer
|
||||
socket->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL){
|
||||
cprintf(RED,"%s\n",mess);
|
||||
socket->SendDataOnly(mess,sizeof(mess));
|
||||
}
|
||||
socket->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
//return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user