Merge branch 'developer' of git.psi.ch:sls_detectors_software/sls_detector_software into developer

This commit is contained in:
2017-11-21 12:10:33 +01:00
18 changed files with 452 additions and 263 deletions

View File

@ -255,13 +255,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
commands to configure detector data structure
*/
/*! \page config
- <b> externalgui </b>sets/gets external gui flag. 1 sets and enables the 0MQ data stream (0MQ threads created) from receiver to client, while 0 unsets and disables. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="externalgui"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDataStream;
++i;
/*! \page config
- \b free Free shared memory on the control PC
*/
@ -1902,19 +1895,39 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
/*! \page network
- <b>zmqport [port]</b> sets/gets the 0MQ (TCP) port of the receiver from where data is streamed to the client. Use single-detector command to set individually or multi-detector command to calculate based on \c port for the rest. \c Returns \c (int)
- <b>zmqport [port]</b> sets/gets the 0MQ (TCP) port of the client to where final data is streamed to (eg. for GUI). The default already connects with rx_zmqport for the GUI. This command to change from default can be used from command line when sockets are not already open as the command line is not aware/create the 0mq sockets in the client side. Use single-detector command to set individually or multi-detector command to calculate based on \c port for the rest. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="zmqport"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>zmqsrcip [ip]</b> sets/gets the 0MQ (TCP) ip of the receiver from where data is streamed to the client. Default is ip of rx_hostname. Use this only with external gui. \c Returns \c (string)
- <b>rx_zmqport [port]</b> sets/gets the 0MQ (TCP) port of the receiver from where data is streamed from (eg. to GUI or another process for further processing). Use single-detector command to set individually or multi-detector command to calculate based on \c port for the rest. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="zmqsrcip"; //
descrToFuncMap[i].m_pFuncName="rx_zmqport"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b> rx_datastream </b>enables/disables data streaming from receiver. 1 enables 0MQ data stream from receiver (creates streamer threads), while 0 disables (destroys streamer threads). Switching to Gui enables data streaming in receiver and switching back to command line acquire will require disabling data streaming in receiver for fast applications \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="rx_datastream"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDataStream;
++i;
/*! \page network
- <b>zmqip [ip]</b> sets/gets the 0MQ (TCP) ip of the client to where final data is streamed to (eg. for GUI). For Experts only! Default is ip of rx_hostname and works for GUI. This command to change from default can be used from command line when sockets are not already open as the command line is not aware/create the 0mq sockets in the client side. This is usually used to stream in from an external process. . If no custom ip, empty until first time connect to receiver. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName="zmqip"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
/*! \page network
- <b>rx_zmqip [ip]</b> sets/gets the 0MQ (TCP) ip of the receiver from where data is streamed from (eg. to GUI or another process for further processing). For Experts only! Default is ip of rx_hostname and works for GUI. This is usually used to stream out to an external process for further processing. . If no custom ip, empty until first time connect to receiver. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName="rx_zmqip"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
/*! \page network
- <b>configuremac [i]</b> configures the MAC of the detector with these parameters: detectorip, detectormac, rx_udpip, rx_udpmac, rx_udpport, rx_udpport2 (if applicable). This command is already included in \c rx_hsotname. Only put!. \c Returns \c (int)
@ -2318,19 +2331,13 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
#endif
if (action==HELP_ACTION) {
return helpAcquire(narg,args,HELP_ACTION);
}
myDet->setOnline(ONLINE_FLAG);
int r_online = myDet->setReceiverOnline(ONLINE_FLAG);
if ((!myDet->getExternalGuiFlag()) && (r_online == ONLINE_FLAG)) {
// command line: must be off, if receiver on or there was -1, then
if (myDet->enableDataStreamingFromReceiver(-1) != 0){
//switch it off, if error
if (myDet->enableDataStreamingFromReceiver(0) != 0) {
return string("could not disable data streaming in receiver\n");
}
}
}
if(myDet->acquire() == FAIL)
return string("acquire unsuccessful");
if(r_online){
@ -2495,18 +2502,11 @@ string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action) {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&ival))
return string ("cannot scan externalgui mode");
myDet->setExternalGuiFlag(ival>0?true:false);
return string ("cannot scan rx_datastream mode");
myDet->enableDataStreamingFromReceiver(ival);
}
int retval = myDet->getExternalGuiFlag();
//if external gui on and datastreaming off
if (retval && !myDet->enableDataStreamingFromReceiver()) {
retval=-1;
printf("Error: data streaming in receiver is switched off while external gui flag in shared memory is off.\n");
}
sprintf(ans,"%d",myDet->getExternalGuiFlag());
sprintf(ans,"%d",myDet->enableDataStreamingFromReceiver());
return string(ans);
}
@ -2515,9 +2515,9 @@ string slsDetectorCommand::helpDataStream(int narg, char *args[], int action) {
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION)
os << string("externalgui \t gets external gui flag. 1/0 means the 0MQ data stream (0MQ threads created) from receiver to client is enabled/disabled. -1 for inconsistency. \n");
os << string("rx_datastream \t enables/disables data streaming from receiver. 1 is 0MQ data stream from receiver enabled, while 0 is 0MQ disabled. -1 for inconsistency between multiple receivers. \n");
if (action==PUT_ACTION || action==HELP_ACTION)
os << string("externalgui i\t sets external gui flag. 1/0 means the 0MQ data stream (0MQ threads created) from receiver to client is enabled/disabled. \n");
os << string("rx_datastream i\t enables/disables data streaming from receiver. i is 1 enables 0MQ data stream from receiver (creates streamer threads), while 0 disables (destroys streamer threads). \n");
return os.str();
}
@ -3958,13 +3958,21 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
return ("cannot parse argument") + string(args[1]);
}
}else if (cmd=="zmqport") {
t=CLIENT_STREAMING_PORT;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
}else if (cmd=="rx_zmqport") {
t=RECEIVER_STREAMING_PORT;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
}else if (cmd=="zmqsrcip") {
t=RECEIVER_STREAMING_SRC_IP;
}else if (cmd=="zmqip") {
t=CLIENT_STREAMING_SRC_IP;
}else if (cmd=="rx_zmqip") {
t=RECEIVER_STREAMING_SRC_IP;
}
else return ("unknown network parameter")+cmd;
@ -3991,8 +3999,16 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "txndelay_right port \n sets detector transmission delay of the right port"<< std::endl;
os << "txndelay_frame port \n sets detector transmission delay of the entire frame"<< std::endl;
os << "flowcontrol_10g port \n sets flow control for 10g for eiger"<< std::endl;
os << "zmqport port \n sets zmq port (data from receiver to client); setting via multidetector command calculates port for individual detectors"<< std::endl;
os << "zmqsrcip ip \n sets/gets the 0MQ (TCP) ip of the receiver from where data is streamed to the client. Default is ip of rx_hostname. Use this only with external gui." << std::endl;
os << "zmqport port \n sets the 0MQ (TCP) port of the client to where final data is streamed to (eg. for GUI). The default already connects with rx_zmqport for the GUI. "
"This command to change from default can be used from command line when sockets are not already open as the command line is not aware/create the 0mq sockets in the client side. "
"Use single-detector command to set individually or multi-detector command to calculate based on port for the rest."<< std::endl;
os << "rx_zmqport port \n sets the 0MQ (TCP) port of the receiver from where data is streamed from (eg. to GUI or another process for further processing). "
"Use single-detector command to set individually or multi-detector command to calculate based on port for the rest."<< std::endl;
os << "zmqip ip \n sets the 0MQ (TCP) ip of the client to where final data is streamed to (eg. for GUI). Default is ip of rx_hostname and works for GUI. "
"This command to change from default can be used from command line when sockets are not already open as the command line is not aware/create the 0mq sockets in the client side. "
"This is usually used to stream in from an external process." << std::endl;
os << "rx_zmqip ip \n sets/gets the 0MQ (TCP) ip of the receiver from where data is streamed from (eg. to GUI or another process for further processing). "
"Default is ip of rx_hostname and works for GUI. This is usually used to stream out to an external process for further processing." << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "detectormac \n gets detector mac "<< std::endl;
@ -4005,8 +4021,10 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "txndelay_right \n gets detector transmission delay of the right port"<< std::endl;
os << "txndelay_frame \n gets detector transmission delay of the entire frame"<< std::endl;
os << "flowcontrol_10g \n gets flow control for 10g for eiger"<< std::endl;
os << "zmqport \n gets zmq port (data from receiver to client)"<< std::endl;
os << "zmqsrcip \n gets zmq source ip (data from receiver to client), none if default setting and no custom ip" << std::endl;
os << "zmqport \n gets the 0MQ (TCP) port of the client to where final data is streamed to"<< std::endl;
os << "rx_zmqport \n gets the 0MQ (TCP) port of the receiver from where data is streamed from"<< std::endl;
os << "zmqip \n gets the 0MQ (TCP) ip of the client to where final data is streamed to.If no custom ip, empty until first time connect to receiver" << std::endl;
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;
}
return os.str();
@ -5916,33 +5934,14 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG);
int receivers = myDet->setReceiverOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
if(cmd=="receiver"){
if (action==PUT_ACTION) {
if(!strcasecmp(args[1],"start")) {
//to ensure data streaming enable is the same across client and receiver
if ((!myDet->getExternalGuiFlag()) && (receivers == ONLINE_FLAG)) {
//if it was not off
if (myDet->enableDataStreamingFromReceiver(-1) != 0){
//switch it off, if error
if (myDet->enableDataStreamingFromReceiver(0) != 0) {
return string("could not disable data streaming in receiver\n");
}
}
}
if(!strcasecmp(args[1],"start"))
myDet->startReceiver();
}
else if(!strcasecmp(args[1],"stop")){
//myDet->stopReceiver();
// myDet->startReceiverReadout();
/*runStatus s = myDet->getReceiverStatus();
while(s != RUN_FINISHED){
usleep(50000);
s = myDet->getReceiverStatus();
}*/
else if(!strcasecmp(args[1],"stop"))
myDet->stopReceiver();
}
else
return helpReceiver(narg, args, action);
}