mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
esrf changes: rx_udpsocksize sets/gets udp socket buffer size to be set, rx_realudpsocksize gets the real udp sock size buffer. At receiver config and at rx_udpsocksize command, dummy udp sockets created to know if set udp sock size fails (if fail, set to previous value), and also to get the real udp sock buffer size
This commit is contained in:
@ -6257,6 +6257,10 @@ string slsDetector::setNetworkParameter(networkParameter index, string value) {
|
||||
return setReceiverStreamingIP(value);
|
||||
case ADDITIONAL_JSON_HEADER:
|
||||
return setAdditionalJsonHeader(value);
|
||||
case RECEIVER_UDP_SCKT_BUF_SIZE:
|
||||
sscanf(value.c_str(),"%d",&i);
|
||||
setReceiverUDPSocketBufferSize(i);
|
||||
return getReceiverUDPSocketBufferSize();
|
||||
|
||||
default:
|
||||
return (char*)("unknown network parameter");
|
||||
@ -6298,6 +6302,11 @@ string slsDetector::getNetworkParameter(networkParameter index) {
|
||||
return getReceiverStreamingIP();
|
||||
case ADDITIONAL_JSON_HEADER:
|
||||
return getAdditionalJsonHeader();
|
||||
case RECEIVER_UDP_SCKT_BUF_SIZE:
|
||||
return getReceiverUDPSocketBufferSize();
|
||||
case RECEIVER_REAL_UDP_SCKT_BUF_SIZE:
|
||||
return getReceiverRealUDPSocketBufferSize();
|
||||
|
||||
default:
|
||||
return (char*)("unknown network parameter");
|
||||
}
|
||||
@ -6724,6 +6733,64 @@ string slsDetector::setAdditionalJsonHeader(string jsonheader) {
|
||||
}
|
||||
|
||||
|
||||
string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) {
|
||||
|
||||
int fnum=F_RECEIVER_UDP_SOCK_BUF_SIZE;
|
||||
int ret = FAIL;
|
||||
int retval = -1;
|
||||
int arg = udpsockbufsize;
|
||||
|
||||
if(thisDetector->receiverOnlineFlag == ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending UDP Socket Buffer size to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL) {
|
||||
setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER));
|
||||
std::cout << "Warning: Could not set udp socket buffer size" << std::endl;
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
ostringstream ss;
|
||||
ss << retval;
|
||||
string s = ss.str();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
string slsDetector::getReceiverRealUDPSocketBufferSize() {
|
||||
|
||||
int fnum=F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE;
|
||||
int ret = FAIL;
|
||||
int retval = -1;
|
||||
|
||||
if(thisDetector->receiverOnlineFlag == ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Getting real UDP Socket Buffer size to receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getInt(fnum,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL) {
|
||||
setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER));
|
||||
std::cout << "Warning: Could not get real socket buffer size" << std::endl;
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
ostringstream ss;
|
||||
ss << retval;
|
||||
string s = ss.str();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
string slsDetector::setDetectorNetworkParameter(networkParameter index, int delay){
|
||||
int fnum = F_SET_NETWORK_PARAMETER;
|
||||
|
@ -1833,6 +1833,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
string getReceiverStreamingIP(){return string(thisDetector->receiver_zmqip);};
|
||||
/** gets the additional json header, returns "none" if default setting and no custom set*/
|
||||
string getAdditionalJsonHeader(){return string(thisDetector->receiver_additionalJsonHeader);};
|
||||
/** returns the receiver UDP socket buffer size */
|
||||
string getReceiverUDPSocketBufferSize() {return setReceiverUDPSocketBufferSize();};
|
||||
/** returns the real receiver UDP socket buffer size */
|
||||
string getReceiverRealUDPSocketBufferSize();
|
||||
|
||||
|
||||
/** validates the format of detector MAC address and sets it \sa sharedSlsDetector */
|
||||
string setDetectorMAC(string detectorMAC);
|
||||
@ -1858,6 +1863,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
string setReceiverStreamingIP(string sourceIP);
|
||||
/** additional json header, returns "none" if default setting and no custom set */
|
||||
string setAdditionalJsonHeader(string jsonheader);
|
||||
/** sets the receiver UDP socket buffer size */
|
||||
string setReceiverUDPSocketBufferSize(int udpsockbufsize=-1);
|
||||
|
||||
/** sets the transmission delay for left or right port or for an entire frame*/
|
||||
string setDetectorNetworkParameter(networkParameter index, int delay);
|
||||
|
@ -1978,6 +1978,21 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
++i;
|
||||
|
||||
/*! \page network
|
||||
- <b>rx_udpsocksize [size]</b> sets/gets the UDP socket buffer size. Already trying to set by default to 100mb, 2gb for Jungfrau. Does not remember in client shared memory, so must be initialized each time after setting receiver hostname in config file.\c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="rx_udpsocksize"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
++i;
|
||||
|
||||
/*! \page network
|
||||
- <b>rx_realudpsocksize [size]</b> gets the actual UDP socket buffer size. Usually double the set udp socket buffer size due to kernel bookkeeping. Get only. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="rx_realudpsocksize"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
++i;
|
||||
|
||||
|
||||
/*! \page network
|
||||
- <b>detectormac [mac]</b> sets/gets the mac address of the detector UDP interface from where the detector will stream data. Use single-detector command. Normally unused. \c Returns \c (string)
|
||||
*/
|
||||
@ -4071,7 +4086,18 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
|
||||
if (!(sscanf(args[1],"%d",&i)))
|
||||
return ("cannot parse argument") + string(args[1]);
|
||||
}
|
||||
} else if (cmd=="txndelay_left") {
|
||||
} else if (cmd=="rx_udpsocksize") {
|
||||
t=RECEIVER_UDP_SCKT_BUF_SIZE;
|
||||
if (action==PUT_ACTION){
|
||||
if (!(sscanf(args[1],"%d",&i)))
|
||||
return ("cannot parse argument") + string(args[1]);
|
||||
}
|
||||
} else if (cmd=="rx_realudpsocksize") {
|
||||
t=RECEIVER_REAL_UDP_SCKT_BUF_SIZE;
|
||||
if (action==PUT_ACTION){
|
||||
return ("cannot put!");
|
||||
}
|
||||
} else if (cmd=="txndelay_left") {
|
||||
t=DETECTOR_TXN_DELAY_LEFT;
|
||||
if (action==PUT_ACTION){
|
||||
if (!(sscanf(args[1],"%d",&i)))
|
||||
@ -4165,6 +4191,10 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
|
||||
os << "rx_jsonaddheader [t]\n sets additional json header to be streamed "
|
||||
"out with the zmq from receiver. Default is empty. t must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||
"Use only if it needs to be processed by an intermediate process." << std::endl;
|
||||
os << "rx_udpsocksize [t]\n sets the UDP socket buffer size. Different defaults for Jungfrau. "
|
||||
"Does not remember in client shared memory, "
|
||||
"so must be initialized each time after setting receiver "
|
||||
"hostname in config file." << std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
os << "detectormac \n gets detector mac "<< std::endl;
|
||||
@ -4183,6 +4213,9 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
|
||||
os << "rx_zmqip \n gets/gets the 0MQ (TCP) ip of the receiver from where data is streamed from. If no custom ip, empty until first time connect to receiver" << std::endl;
|
||||
os << "rx_jsonaddheader \n gets additional json header to be streamed "
|
||||
"out with the zmq from receiver." << std::endl;
|
||||
os << "rx_udpsocksize \n gets the UDP socket buffer size." << std::endl;
|
||||
os << "rx_realudpsocksize \n gets the actual UDP socket buffer size. Usually double the set udp socket buffer size due to kernel bookkeeping." << std::endl;
|
||||
|
||||
}
|
||||
return os.str();
|
||||
|
||||
|
Reference in New Issue
Block a user