From 6693d0833103670722b0fcbdc54eda0948208168 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 14 Nov 2017 11:53:37 +0100 Subject: [PATCH 1/8] fixed help of acquire doing an actual acquisition --- slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 83960ada2..2888450c7 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -2302,6 +2302,10 @@ 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); From dda86cfe9b83d53b534b227f6e5b8a95afa1e586 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 14 Nov 2017 16:26:17 +0100 Subject: [PATCH 2/8] somewhere in separating zmq rxr and client --- .../commonFiles/sls_detector_defs.h | 3 +- .../multiSlsDetector/multiSlsDetector.cpp | 6 ++-- .../slsDetector/slsDetector.cpp | 29 +++++++++++++++++-- slsDetectorSoftware/slsDetector/slsDetector.h | 15 +++++++--- .../slsDetector/slsDetectorCommand.cpp | 21 ++++++++++++-- 5 files changed, 61 insertions(+), 13 deletions(-) diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index 386255bae..66fc70a2a 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -193,7 +193,8 @@ enum networkParameter { FLOW_CONTROL_10G, /**< flow control for 10GbE */ FLOW_CONTROL_WR_PTR, /**< memory write pointer for flow control */ FLOW_CONTROL_RD_PTR, /**< memory read pointer for flow control */ - RECEIVER_STREAMING_PORT /**< receiever streaming TCP(ZMQ) port */ + RECEIVER_STREAMING_PORT, /**< receiever streaming TCP(ZMQ) port */ + CLIENT_STREAMING_PORT /**< client streaming TCP(ZMQ) port */ }; /** diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 67973eda8..4d698604f 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -3690,7 +3690,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){ // disable data streaming before changing zmq port (but only if they were on) int prev_streaming = 0; - if (p == RECEIVER_STREAMING_PORT) { + if (p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT) { prev_streaming = getStreamingSocketsCreatedInClient(); enableDataStreamingFromReceiver(0); } @@ -3704,7 +3704,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){ string* sret[thisMultiDetector->numberOfDetectors]; for(int idet=0; idetnumberOfDetectors; ++idet){ if(detectors[idet]){ - if (p == RECEIVER_STREAMING_PORT) + if (p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT) s.append("multi\0"); sret[idet]=new string("error"); Task* task = new Task(new func2_t(&slsDetector::setNetworkParameter, @@ -3748,7 +3748,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){ } //enable data streaming if it was on - if (p == RECEIVER_STREAMING_PORT && prev_streaming) + if ((p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT) && prev_streaming) enableDataStreamingFromReceiver(1); return getNetworkParameter(p); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 380223a02..ced0c34e5 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -5930,6 +5930,9 @@ string slsDetector::setNetworkParameter(networkParameter index, string value) { case FLOW_CONTROL_10G: sscanf(value.c_str(),"%d",&i); return setDetectorNetworkParameter(index, i); + case CLIENT_STREAMING_PORT: + setClientStreamingPort(value); + return getClientStreamingPort(); case RECEIVER_STREAMING_PORT: setReceiverStreamingPort(value); return getReceiverStreamingPort(); @@ -6221,6 +6224,28 @@ int slsDetector::setReceiverUDPPort2(int udpport){ } +int slsDetector::setReceiverStreamingPort(string port) { + int defaultport = 0; + int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; + int arg = 0; + + //multi command, calculate individual ports + size_t found = port.find("multi"); + if(found != string::npos) { + port.erase(found,5); + sscanf(port.c_str(),"%d",&defaultport); + arg = defaultport + (posId * numsockets); + } + else + sscanf(port.c_str(),"%d",&arg); + thisDetector->zmqport = arg; + + return thisDetector->zmqport; +} + + + + int slsDetector::setReceiverStreamingPort(string port) { int defaultport = 0; int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; @@ -6249,12 +6274,12 @@ int slsDetector::setReceiverStreamingPort(string port) { disconnectData(); } if(ret!=FAIL) - thisDetector->zmqport = retval; + thisDetector->receiver_zmqport = retval; if(ret==FORCE_UPDATE) updateReceiver(); } - return thisDetector->zmqport; + return thisDetector->receiver_zmqport; } string slsDetector::setDetectorNetworkParameter(networkParameter index, int delay){ diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 97a40e9f2..728041162 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -269,8 +269,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion { bool acquiringFlag; /** flipped data across x or y axis */ int flippedData[2]; - /** tcp port between receiver and gui (only data) */ + /** tcp port from gui/different process to receiver (only data) */ int zmqport; + /** tcp port from receiver to gui/different process (only data) */ + int receiver_zmqport; + } sharedSlsDetector; @@ -1733,8 +1736,10 @@ class slsDetector : public slsDetectorUtils, public energyConversion { string getReceiverUDPPort() {ostringstream ss; ss << thisDetector->receiverUDPPort; string s = ss.str(); return s;}; /** returns the receiver UDP2 for Eiger IP address \sa sharedSlsDetector */ string getReceiverUDPPort2() {ostringstream ss; ss << thisDetector->receiverUDPPort2; string s = ss.str(); return s;}; - /** returns the zmq port \sa sharedSlsDetector */ - string getReceiverStreamingPort() {ostringstream ss; ss << thisDetector->zmqport; string s = ss.str(); return s;}; + /** returns the client zmq port \sa sharedSlsDetector */ + string getClientStreamingPort() {ostringstream ss; ss << thisDetector->zmqport; string s = ss.str(); return s;}; + /** returns the receiver zmq port \sa sharedSlsDetector */ + string getReceiverStreamingPort() {ostringstream ss; ss << thisDetector->receiver_zmqport; string s = ss.str(); return s;}; /** validates the format of detector MAC address and sets it \sa sharedSlsDetector */ string setDetectorMAC(string detectorMAC); @@ -1750,7 +1755,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion { int setReceiverUDPPort(int udpport); /** sets the receiver udp port2 for Eiger \sa sharedSlsDetector */ int setReceiverUDPPort2(int udpport); - /** sets the zmq port in client and receiver (includes "multi" at the end if it should calculate individual ports \sa sharedSlsDetector */ + /** sets the zmq port in client (includes "multi" at the end if it should calculate individual ports \sa sharedSlsDetector */ + int setClientStreamingPort(string port); + /** sets the zmq port in receiver (includes "multi" at the end if it should calculate individual ports \sa sharedSlsDetector */ int setReceiverStreamingPort(string port); /** sets the transmission delay for left or right port or for an entire frame*/ string setDetectorNetworkParameter(networkParameter index, int delay); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 2888450c7..1d91e41d8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -1894,12 +1894,19 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page network - - zmqport [port] 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) + - zmqport [port] sets/gets the 0MQ (TCP) port of the client to where final data is streamed to (eg. for GUI). 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 + - rx_zmqport [port] 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="rx_zmqport"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter; + ++i; + /*! \page network - configuremac [i] 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) */ @@ -3946,6 +3953,12 @@ 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))) @@ -3976,7 +3989,8 @@ 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 << "zmqport port \n sets zmq port (data to client from receiver/different process); setting via multidetector command calculates port for individual detectors"<< std::endl; + os << "rx_zmqport port \n sets zmq port (data from receiver to client/different process); setting via multidetector command calculates port for individual detectors"<< std::endl; } if (action==GET_ACTION || action==HELP_ACTION) { os << "detectormac \n gets detector mac "<< std::endl; @@ -3989,7 +4003,8 @@ 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 << "zmqport \n gets zmq port (data to client from receiver/different process)"<< std::endl; + os << "rx_zmqport \n gets zmq port (data from receiver to client/different process)"<< std::endl; } return os.str(); From 2b0d07387abbad6b33432a6dd8474fae8cbef427 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Wed, 15 Nov 2017 17:16:47 +0100 Subject: [PATCH 3/8] in between separating datastreaming in client and receiver --- .../multiSlsDetector/multiSlsDetector.h | 19 ++++-- .../slsDetector/slsDetector.cpp | 25 ++------ slsDetectorSoftware/slsDetector/slsDetector.h | 7 +- .../slsDetector/slsDetectorCommand.cpp | 64 ++++--------------- .../slsDetector/slsDetectorUtils.h | 6 +- 5 files changed, 40 insertions(+), 81 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 2d0ff72a5..96d35eb28 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -207,6 +207,9 @@ class multiSlsDetector : public slsDetectorUtils { /** receiver online flag - is set if the receiver is connected, unset if socket connection is not possible */ int receiverOnlineFlag; + /** data streaming (up stream) enable in receiver */ + bool receiver_datastream; + } sharedMultiSlsDetector; @@ -1342,17 +1345,19 @@ class multiSlsDetector : public slsDetectorUtils { /** - * Get Streaming sockets created in client from reciever - /returns 1 if sockets created, else 0 + * Enable data streaming to client + * @param enable 0 to disable, 1 to enable, -1 to get the value + * @returns data streaming to client enable */ - int getStreamingSocketsCreatedInClient(); + int enableDataStreamingToClient(int enable=-1); /** Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming + * @param enable 0 to disable 1 to enable -1 to only get the value + * @returns data streaming to receiver enable */ int enableDataStreamingFromReceiver(int enable=-1); + /** updates the multidetector offsets */ void updateOffsets(); @@ -1489,8 +1494,8 @@ private: int getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename); - /** Ensures if sockets created successfully */ - bool dataSocketsStarted; + /** data streaming (down stream) enabled in client (zmq sckets created) */ + bool client_datastream; /** ZMQ Socket - Receiver to Client */ ZmqSocket* zmqSocket[MAXDET]; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index ced0c34e5..a61be6d5e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -777,7 +777,8 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->acquiringFlag = false; thisDetector->flippedData[0] = 0; thisDetector->flippedData[1] = 0; - thisDetector->zmqport = 0; + thisDetector->zmqport = DEFAULT_ZMQ_CL_PORTNO + (posId * (thisDetector->myDetectorType == EIGER) ? 2 : 1); + thisDetector->receiver_zmqport = DEFAULT_ZMQ_RX_PORTNO + (posId * (thisDetector->myDetectorType == EIGER) ? 2 : 1); for (int ia=0; iaactionScript[ia],"none"); @@ -6067,7 +6068,7 @@ string slsDetector::setReceiver(string receiverIP){ std::cout << "dynamic range:" << thisDetector->dynamicRange << endl << endl; std::cout << "flippeddatax:" << thisDetector->flippedData[d] << endl; std::cout << "10GbE:" << thisDetector->tenGigaEnable << endl << endl; - std::cout << "streaming port:" << thisDetector->zmqport << endl; + std::cout << "rx streaming port:" << thisDetector->receiver_zmqport << endl; //std::cout << "dataStreaming:" << enableDataStreamingFromReceiver(-1) << endl << endl; /** enable compresison, */ @@ -6113,19 +6114,7 @@ string slsDetector::setReceiver(string receiverIP){ // data streaming setReceiverStreamingPort(getReceiverStreamingPort()); - int clientSockets = parentDet->getStreamingSocketsCreatedInClient(); - int recSockets = enableDataStreamingFromReceiver(-1); - if(clientSockets != recSockets) { - pthread_mutex_lock(&ms); - if(clientSockets) - printf("Enabling Data Streaming\n"); - else - printf("Disabling Data Streaming\n"); - // push client state to receiver - /*parentDet->enableDataStreamingFromReceiver(clientSockets);*/ - enableDataStreamingFromReceiver(clientSockets); - pthread_mutex_unlock(&ms); - } + enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1)); } } @@ -6224,7 +6213,7 @@ int slsDetector::setReceiverUDPPort2(int udpport){ } -int slsDetector::setReceiverStreamingPort(string port) { +int slsDetector::setClientStreamingPort(string port) { int defaultport = 0; int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; int arg = 0; @@ -8268,9 +8257,9 @@ int slsDetector::updateReceiverNoWait() { parentDet->enableOverwriteMask(ind); pthread_mutex_unlock(&ms); - // streaming port + // receiver streaming port n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->zmqport = ind; + thisDetector->receiver_zmqport = ind; if (!n) printf("n: %d\n", n); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 728041162..0ec9c4a99 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -273,7 +273,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion { int zmqport; /** tcp port from receiver to gui/different process (only data) */ int receiver_zmqport; - + /** data streaming (up stream) enable in receiver */ + bool receiver_datastream; } sharedSlsDetector; @@ -1781,8 +1782,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion { int setReceiverReadTimer(int time_in_ms=500); /** Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming + * @param enable 0 to disable 1 to enable -1 to only get the value + * @returns data streaming to receiver enable */ int enableDataStreamingFromReceiver(int enable=-1); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 1d91e41d8..a45a19363 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -255,13 +255,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { commands to configure detector data structure */ - /*! \page config - - externalgui 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 */ @@ -1907,6 +1900,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter; ++i; + /*! \page network + - rx_datastream enables/disables data streaming from receiver. 1 enables 0MQ data stream from receiver (creates streamer threads), while 0 disables (destroys streamer threads). \c Returns \c (int) + */ + descrToFuncMap[i].m_pFuncName="rx_datastream"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDataStream; + ++i; + /*! \page network - configuremac [i] 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) */ @@ -2316,16 +2316,6 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int 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){ @@ -2490,18 +2480,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); } @@ -2510,9 +2493,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(); } @@ -5899,33 +5882,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); } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index d297cfe27..faa4b473d 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -749,9 +749,9 @@ virtual ROI* getROI(int &n)=0; */ virtual int setReadReceiverFrequency(int getFromReceiver, int freq=-1)=0; -/** Enable or disable streaming of data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming +/** Enable or disable streaming data from receiver to client + * @param enable 0 to disable 1 to enable -1 to only get the value + * @returns data streaming to receiver enable */ virtual int enableDataStreamingFromReceiver(int enable=-1)=0; From fd34bab34b2c94c05edf6f6fb58b246ac5d4be74 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Wed, 15 Nov 2017 17:19:07 +0100 Subject: [PATCH 4/8] in between separating datastreaming in client and receiver --- .../multiSlsDetector/multiSlsDetector.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 4d698604f..6e53af4af 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -3690,8 +3690,13 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){ // disable data streaming before changing zmq port (but only if they were on) int prev_streaming = 0; + switch (p) { + case RECEIVER_STREAMING_PORT: + prev_streaming = enableDataStreamingFromReceiver(); + enableDataStreamingFromReceiver(0); + } if (p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT) { - prev_streaming = getStreamingSocketsCreatedInClient(); + prev_streaming = enableDataStreamingToClient(); enableDataStreamingFromReceiver(0); } @@ -6150,7 +6155,7 @@ int multiSlsDetector::setReceiverReadTimer(int time_in_ms){ return ret; } -int multiSlsDetector::getStreamingSocketsCreatedInClient() { +int multiSlsDetector::enableDataStreamingToClient() { return dataSocketsStarted; } From 7dee07b9c571ad6e33c448dbd8efeb0a4dbb3c75 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 16 Nov 2017 09:12:54 +0100 Subject: [PATCH 5/8] somewhere --- slsDetectorSoftware/commonFiles/error_defs.h | 2 +- .../multiSlsDetector/multiSlsDetector.cpp | 150 +++++++++--------- .../slsDetector/slsDetector.cpp | 19 ++- 3 files changed, 93 insertions(+), 78 deletions(-) diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h index 922d1b08d..272626053 100644 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ b/slsDetectorSoftware/commonFiles/error_defs.h @@ -240,7 +240,7 @@ public: retval.append("Could not activate/deactivate receiver\n"); if(slsErrorMask&DATA_STREAMING) - retval.append("Could not set/reset Data Streaming\n"); + retval.append("Could not enable/disable Data Streaming\n"); if(slsErrorMask&RESET_ERROR) retval.append("Could not reset the FPGA\n"); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 6e53af4af..9c29efcfc 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -209,6 +209,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) thisMultiDetector->receiver_read_freq = 0; thisMultiDetector->acquiringFlag = false; thisMultiDetector->externalgui = false; + thisMultiDetector->receiver_datastream = false; thisMultiDetector->alreadyExisting=1; } @@ -274,7 +275,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) getNMods(); getMaxMods(); - dataSocketsStarted = false; + client_datastream = false; for(int i=0;igetReceiverStreamingPort().c_str(),"%d",&portnum); - if (portnum == 0) { - portnum = DEFAULT_ZMQ_PORTNO + - (i/numSocketsPerDetector)*numSocketsPerDetector + (i%numSocketsPerDetector); // *num and /num is not same cuz its integers - }else{ - portnum += (i%numSocketsPerDetector); - } + uint32_t portnum = 0; + sscanf(detectors[i/numSocketsPerDetector]->getClientStreamingPort().c_str(),"%d",&portnum); + portnum += (i%numSocketsPerDetector); zmqSocket[i] = new ZmqSocket(detectors[i/numSocketsPerDetector]->getReceiver().c_str(), portnum); if (zmqSocket[i]->IsError()) { @@ -5692,7 +5700,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){ printf("Zmq Client[%d] at %s\n",i, zmqSocket[i]->GetZmqServerAddress()); } - dataSocketsStarted = true; + client_datastream = true; cout << "Receiving Data Socket(s) created" << endl; return OK; } @@ -6155,71 +6163,63 @@ int multiSlsDetector::setReceiverReadTimer(int time_in_ms){ return ret; } -int multiSlsDetector::enableDataStreamingToClient() { - return dataSocketsStarted; +int multiSlsDetector::enableDataStreamingToClient(int enable) { + if(enable >= 0){ + + //destroy data threads + if (!enable) + createReceivingDataSockets(true); + + //create data threads + else { + if(createReceivingDataSockets() == FAIL){ + std::cout << "Could not create data threads in client." << std::endl; + //only for the first det as theres no general one + setErrorMask(getErrorMask()|(1<<0)); + detectors[0]->setErrorMask((detectors[0]->getErrorMask())|(DATA_STREAMING)); + } + } + } + return client_datastream; } -int multiSlsDetector::enableDataStreamingFromReceiver(int enable){//cannot parrallize due to serReceiver calling parentdet->enabledatastremain - - //create client sockets only if no external gui - if (!thisMultiDetector->externalgui) { - if(enable >= 0){ - - //destroy data threads - if(dataSocketsStarted) - createReceivingDataSockets(true); - - //create data threads - if(enable > 0){ - if(createReceivingDataSockets() == FAIL){ - std::cout << "Could not create data threads in client. Aborting creating data sockets in receiver" << std::endl; - //only for the first det as theres no general one - setErrorMask(getErrorMask()|(1<<0)); - detectors[0]->setErrorMask((detectors[0]->getErrorMask())|(DATA_STREAMING)); - return -1; +int multiSlsDetector::enableDataStreamingFromReceiver(int enable){ + if(enable >= 0){ + int ret=-100; + if(!threadpool){ + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + }else{ + //return storage values + int* iret[thisMultiDetector->numberOfDetectors]; + for(int idet=0; idetnumberOfDetectors; ++idet){ + if(detectors[idet]){ + iret[idet]= new int(-1); + Task* task = new Task(new func1_t(&slsDetector::enableDataStreamingFromReceiver, + detectors[idet],enable,iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for(int idet=0; idetnumberOfDetectors; ++idet){ + if(detectors[idet]){ + if(iret[idet] != NULL){ + if (ret==-100) + ret=*iret[idet]; + else if (ret!=*iret[idet]) + ret=-1; + delete iret[idet]; + }else ret=-1; + if(detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask()|(1<receiver_datastream = ret; } - - int ret=-100; - if(!threadpool){ - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - }else{ - //return storage values - int* iret[thisMultiDetector->numberOfDetectors]; - for(int idet=0; idetnumberOfDetectors; ++idet){ - if(detectors[idet]){ - iret[idet]= new int(-1); - Task* task = new Task(new func1_t(&slsDetector::enableDataStreamingFromReceiver, - detectors[idet],enable,iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for(int idet=0; idetnumberOfDetectors; ++idet){ - if(detectors[idet]){ - if(iret[idet] != NULL){ - if (ret==-100) - ret=*iret[idet]; - else if (ret!=*iret[idet]) - ret=-1; - delete iret[idet]; - }else ret=-1; - if(detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask()|(1<externalgui) { - if (ret != dataSocketsStarted) - ret = -1; - } - return ret; + return thisMultiDetector->receiver_datastream; } int multiSlsDetector::enableReceiverCompression(int i){ diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index a61be6d5e..543bcbfe3 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -777,8 +777,9 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->acquiringFlag = false; thisDetector->flippedData[0] = 0; thisDetector->flippedData[1] = 0; - thisDetector->zmqport = DEFAULT_ZMQ_CL_PORTNO + (posId * (thisDetector->myDetectorType == EIGER) ? 2 : 1); - thisDetector->receiver_zmqport = DEFAULT_ZMQ_RX_PORTNO + (posId * (thisDetector->myDetectorType == EIGER) ? 2 : 1); + thisDetector->zmqport = 0; + thisDetector->receiver_zmqport = 0; + thisDetector->receiver_datastream = false; for (int ia=0; iaactionScript[ia],"none"); @@ -923,6 +924,14 @@ int slsDetector::initializeDetectorSize(detectorType type) { delete thisReceiver; thisReceiver = new receiverInterface(dataSocket); + // zmq ports + if (posId != -1) { + if (thisDetector->zmqport == 0) + thisDetector->zmqport = DEFAULT_ZMQ_CL_PORTNO + (posId * ((thisDetector->myDetectorType == EIGER) ? 2 : 1)); + if (thisDetector->receiver_zmqport == 0) + thisDetector->receiver_zmqport = DEFAULT_ZMQ_RX_PORTNO + (posId * ((thisDetector->myDetectorType == EIGER) ? 2 : 1)); + } + // setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips); #ifdef VERBOSE @@ -5967,6 +5976,8 @@ string slsDetector::getNetworkParameter(networkParameter index) { case DETECTOR_TXN_DELAY_FRAME: case FLOW_CONTROL_10G: return setDetectorNetworkParameter(index, -1); + case CLIENT_STREAMING_PORT: + return getClientStreamingPort(); case RECEIVER_STREAMING_PORT: return getReceiverStreamingPort(); default: @@ -8261,6 +8272,10 @@ int slsDetector::updateReceiverNoWait() { n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); thisDetector->receiver_zmqport = ind; + // receiver streaming enable + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + thisDetector->receiver_datastream = ind; + if (!n) printf("n: %d\n", n); return OK; From 8e0414d1b9f880ded77893da27ad1d151c8e48d2 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 16 Nov 2017 15:01:22 +0100 Subject: [PATCH 6/8] separating zmqport, enabling in client and receiver works --- slsDetectorSoftware/slsDetector/slsDetector.cpp | 8 ++++---- slsDetectorSoftware/slsDetector/slsDetector.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 543bcbfe3..d57c6fda4 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -6224,7 +6224,7 @@ int slsDetector::setReceiverUDPPort2(int udpport){ } -int slsDetector::setClientStreamingPort(string port) { +string slsDetector::setClientStreamingPort(string port) { int defaultport = 0; int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; int arg = 0; @@ -6240,13 +6240,13 @@ int slsDetector::setClientStreamingPort(string port) { sscanf(port.c_str(),"%d",&arg); thisDetector->zmqport = arg; - return thisDetector->zmqport; + return getClientStreamingPort(); } -int slsDetector::setReceiverStreamingPort(string port) { +string slsDetector::setReceiverStreamingPort(string port) { int defaultport = 0; int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; int arg = 0; @@ -6279,7 +6279,7 @@ int slsDetector::setReceiverStreamingPort(string port) { updateReceiver(); } - return thisDetector->receiver_zmqport; + return getReceiverStreamingPort(); } string slsDetector::setDetectorNetworkParameter(networkParameter index, int delay){ diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 0ec9c4a99..b6e3f7ac0 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1757,9 +1757,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion { /** sets the receiver udp port2 for Eiger \sa sharedSlsDetector */ int setReceiverUDPPort2(int udpport); /** sets the zmq port in client (includes "multi" at the end if it should calculate individual ports \sa sharedSlsDetector */ - int setClientStreamingPort(string port); + string setClientStreamingPort(string port); /** sets the zmq port in receiver (includes "multi" at the end if it should calculate individual ports \sa sharedSlsDetector */ - int setReceiverStreamingPort(string port); + string setReceiverStreamingPort(string port); /** sets the transmission delay for left or right port or for an entire frame*/ string setDetectorNetworkParameter(networkParameter index, int delay); From 4097c37b31eeb6123d6ecfc4e5de5b5818d2e4fc Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 16 Nov 2017 16:01:31 +0100 Subject: [PATCH 7/8] in between --- .../multiSlsDetector/multiSlsDetector.h | 2 +- slsDetectorSoftware/slsDetector/slsDetector.h | 2 +- .../slsDetector/slsDetectorBase.h | 1 - .../slsDetector/slsDetectorUsers.cpp | 12 +++++ .../slsDetector/slsDetectorUsers.h | 35 ++++++++++++--- .../slsDetector/slsDetectorUtils.h | 45 ++++++++++++++++++- 6 files changed, 88 insertions(+), 9 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 96d35eb28..7f82c9642 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1353,7 +1353,7 @@ class multiSlsDetector : public slsDetectorUtils { /** Enable or disable streaming data from receiver to client * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming to receiver enable + * @returns data streaming from receiver enable */ int enableDataStreamingFromReceiver(int enable=-1); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index b6e3f7ac0..06fb35123 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1783,7 +1783,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion { /** Enable or disable streaming data from receiver to client * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming to receiver enable + * @returns data streaming from receiver enable */ int enableDataStreamingFromReceiver(int enable=-1); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index 7d8683fdc..f8a8b4626 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -425,7 +425,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef */ int setHighVoltage(int val){return setDAC(val, HV_NEW, 0, -1);} \ - /** set dacs value \param val value diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 95d9369ec..828c9f65b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -227,6 +227,18 @@ int slsDetectorUsers::enableDataStreamingFromReceiver(int i){ return myDetector->enableDataStreamingFromReceiver(i); } +int slsDetectorUsers::enableDataStreamingToClient(int i){ + return myDetector->enableDataStreamingToClient(i); +} + +int slsDetectorUsers::setReceiverDataStreamingOutPort(int i, int imod){ + return myDetector->setReceiverDataStreamingOutPort(i, imod); +} + +int slsDetectorUsers::setClientDataStreamingInPort(int i, int imod){ + return myDetector->setClientDataStreamingInPort(i, imod); +} + int64_t slsDetectorUsers::getModuleFirmwareVersion(){ return myDetector->getModuleFirmwareVersion(); } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index ea8011326..f0cee1730 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -439,13 +439,38 @@ class slsDetectorUsers virtual void finalizeDataset(double *a, double *v, double *e, int &np); - /** - Enable data streaming from receiver (zmq) - \param i 1 to set, 0 to reset and -1 to get - \returns data streaming enable - */ + /** Enable or disable streaming data from receiver (creates transmitting sockets) + * @param enable 0 to disable 1 to enable -1 to only get the value + * @returns data streaming from receiver enable + */ int enableDataStreamingFromReceiver(int i=-1); + /** + * Enable data streaming to client (creates receiving sockets) + * @param i 0 to disable, 1 to enable, -1 to get the value + * @returns data streaming to client enable + */ + int enableDataStreamingToClient(int i=-1); + + /** + * Set/Get receiver streaming out ZMQ port + * If imod is -1, when setting it calculates and sets the port for all individual detectors + * and when getting it returns only the port of individual detector in first position + * @param i sets, -1 gets + * @param imod module index, -1 for all + * @returns receiver streaming out ZMQ port () + */ + int setReceiverDataStreamingOutPort(int i, int imod=-1); + + /** + * Set/Get client streaming in ZMQ port + * If imod is -1, when setting it calculates and sets the port for all individual detectors + * and when getting it returns only the port of individual detector in first position + * @param i sets, -1 gets + * @param imod module index, -1 for all + * @returns client streaming in ZMQ port + */ + int setClientDataStreamingInPort(int i, int imod=-1); /** get get Module Firmware Version diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index faa4b473d..0a6bdafc8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -30,6 +30,7 @@ extern "C" { #include #include #include +#include using namespace std; @@ -88,6 +89,48 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { int enableFlatFieldCorrection(int i=-1) {if (i>0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();}; int enablePixelMaskCorrection(int i=-1) {if (i>0) setBadChannelCorrection("default"); else if (i==0) setBadChannelCorrection(""); return getBadChannelCorrection();}; int enableCountRateCorrection(int i=-1) {if (i>0) setRateCorrection(i); else if (i==0) setRateCorrection(0); return getRateCorrection();}; + + /** + * Set/Get receiver streaming out ZMQ port + * @param i sets, -1 gets + * @param imod module index, -1 for all + * @returns receiver streaming out ZMQ port + */ + int setReceiverDataStreamingOutPort(int i, int imod) { \ + // single module + if (imod < 0) { \ + if (i >= 0) { \ + ostringstream ss; ss << i; string s = ss.str(); \ + getSlsDetector(imod)->setReceiverStreamingPort(RECEIVER_STREAMING_PORT, s); \ + } \ + return atoi(getSlsDetector(imod)->getReceiverStreamingPort().c_str()); \ + } \ + // multimodule + if (i >= 0) \ + setNetworkParameter(RECEIVER_STREAMING_PORT, s); \ + return atoi(getSlsDetector(0)->getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ + + /** + * Set/Get client streaming in ZMQ port + * @param i sets, -1 gets + * @param imod module index, -1 for all + * @returns client streaming in ZMQ port + */ + int setClientDataStreamingInPort(int i, int imod=-1){ \ + // single module + if (imod < 0) { \ + if (i >= 0) { \ + ostringstream ss; ss << i; string s = ss.str(); \ + getSlsDetector(imod)->setReceiverStreamingPort(CLIENT_STREAMING_PORT, s); \ + } \ + return atoi(getSlsDetector(imod)->getReceiverStreamingPort().c_str()); \ + } \ + // multimodule + if (i >= 0) \ + setNetworkParameter(CLIENT_STREAMING_PORT, s); \ + return atoi(getSlsDetector(0)->getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ + }; + // string getFilePath(){return fileIO::getFilePath();};; // string setFilePath(string s){return fileIO::setFilePath(s);}; @@ -751,7 +794,7 @@ virtual int setReadReceiverFrequency(int getFromReceiver, int freq=-1)=0; /** Enable or disable streaming data from receiver to client * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming to receiver enable + * @returns data streaming from receiver enable */ virtual int enableDataStreamingFromReceiver(int enable=-1)=0; From f647bdaa48f670d072afd7928e2925adf5966c1f Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Fri, 17 Nov 2017 08:46:43 +0100 Subject: [PATCH 8/8] updated users class to reflect zmq changes (separation), fixed warnings --- slsDetectorSoftware/slsDetector/slsDetector.h | 2 +- .../slsDetector/slsDetectorUsers.cpp | 8 ++-- .../slsDetector/slsDetectorUsers.h | 12 ++---- .../slsDetector/slsDetectorUtils.h | 43 ++++++------------- 4 files changed, 22 insertions(+), 43 deletions(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 06fb35123..3e058fad7 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1643,7 +1643,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion { /** gets the number of frames caught by any one receiver (to avoid using threadpool) \returns number of frames caught by any one receiver (master receiver if exists) */ - int getFramesCaughtByAnyReceiver() {getFramesCaughtByReceiver();}; + int getFramesCaughtByAnyReceiver() {return getFramesCaughtByReceiver();}; /** gets the current frame index of receiver \returns current frame index of receiver diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 828c9f65b..c783d349f 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -231,12 +231,12 @@ int slsDetectorUsers::enableDataStreamingToClient(int i){ return myDetector->enableDataStreamingToClient(i); } -int slsDetectorUsers::setReceiverDataStreamingOutPort(int i, int imod){ - return myDetector->setReceiverDataStreamingOutPort(i, imod); +int slsDetectorUsers::setReceiverDataStreamingOutPort(int i){ + return myDetector->setReceiverDataStreamingOutPort(i); } -int slsDetectorUsers::setClientDataStreamingInPort(int i, int imod){ - return myDetector->setClientDataStreamingInPort(i, imod); +int slsDetectorUsers::setClientDataStreamingInPort(int i){ + return myDetector->setClientDataStreamingInPort(i); } int64_t slsDetectorUsers::getModuleFirmwareVersion(){ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index f0cee1730..dbaa75340 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -454,23 +454,19 @@ class slsDetectorUsers /** * Set/Get receiver streaming out ZMQ port - * If imod is -1, when setting it calculates and sets the port for all individual detectors - * and when getting it returns only the port of individual detector in first position + * For multi modules, it calculates (increments) and sets the ports * @param i sets, -1 gets - * @param imod module index, -1 for all * @returns receiver streaming out ZMQ port () */ - int setReceiverDataStreamingOutPort(int i, int imod=-1); + int setReceiverDataStreamingOutPort(int i=-1); /** * Set/Get client streaming in ZMQ port - * If imod is -1, when setting it calculates and sets the port for all individual detectors - * and when getting it returns only the port of individual detector in first position + * For multi modules, it calculates (increments) and sets the ports * @param i sets, -1 gets - * @param imod module index, -1 for all * @returns client streaming in ZMQ port */ - int setClientDataStreamingInPort(int i, int imod=-1); + int setClientDataStreamingInPort(int i=-1); /** get get Module Firmware Version diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 0a6bdafc8..9f47b3080 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -90,48 +90,31 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { int enablePixelMaskCorrection(int i=-1) {if (i>0) setBadChannelCorrection("default"); else if (i==0) setBadChannelCorrection(""); return getBadChannelCorrection();}; int enableCountRateCorrection(int i=-1) {if (i>0) setRateCorrection(i); else if (i==0) setRateCorrection(0); return getRateCorrection();}; + /** * Set/Get receiver streaming out ZMQ port + * For multi modules, it calculates (increments) and sets the ports * @param i sets, -1 gets - * @param imod module index, -1 for all * @returns receiver streaming out ZMQ port */ - int setReceiverDataStreamingOutPort(int i, int imod) { \ - // single module - if (imod < 0) { \ - if (i >= 0) { \ - ostringstream ss; ss << i; string s = ss.str(); \ - getSlsDetector(imod)->setReceiverStreamingPort(RECEIVER_STREAMING_PORT, s); \ - } \ - return atoi(getSlsDetector(imod)->getReceiverStreamingPort().c_str()); \ - } \ - // multimodule - if (i >= 0) \ - setNetworkParameter(RECEIVER_STREAMING_PORT, s); \ - return atoi(getSlsDetector(0)->getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ + int setReceiverDataStreamingOutPort(int i) { \ + if (i >= 0) { ostringstream ss; ss << i; string s = ss.str(); \ + setNetworkParameter(RECEIVER_STREAMING_PORT, s);} \ + return atoi(getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ /** * Set/Get client streaming in ZMQ port + * For multi modules, it calculates (increments) and sets the ports * @param i sets, -1 gets - * @param imod module index, -1 for all * @returns client streaming in ZMQ port */ - int setClientDataStreamingInPort(int i, int imod=-1){ \ - // single module - if (imod < 0) { \ - if (i >= 0) { \ - ostringstream ss; ss << i; string s = ss.str(); \ - getSlsDetector(imod)->setReceiverStreamingPort(CLIENT_STREAMING_PORT, s); \ - } \ - return atoi(getSlsDetector(imod)->getReceiverStreamingPort().c_str()); \ - } \ - // multimodule - if (i >= 0) \ - setNetworkParameter(CLIENT_STREAMING_PORT, s); \ - return atoi(getSlsDetector(0)->getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ - }; + int setClientDataStreamingInPort(int i){ \ + if (i >= 0) { ostringstream ss; ss << i; string s = ss.str(); \ + setNetworkParameter(CLIENT_STREAMING_PORT, s);} \ + return atoi(getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ - // string getFilePath(){return fileIO::getFilePath();};; + +// string getFilePath(){return fileIO::getFilePath();};; // string setFilePath(string s){return fileIO::setFilePath(s);}; // string getFileName(){return fileIO::getFileName();};