diff --git a/slsDetectorSoftware/gitInfo.txt b/slsDetectorSoftware/gitInfo.txt index 304d57e84..0040aef5b 100644 --- a/slsDetectorSoftware/gitInfo.txt +++ b/slsDetectorSoftware/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorSoftware URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git -Repsitory UUID: c79a7cdd6f5f936a90bb31038389b587745a3088 -Revision: 1672 -Branch: developer +Repsitory UUID: ea284699983c3811852b1bcea3708d952803020d +Revision: 1611 +Branch: zmqchange Last Changed Author: Dhanya_Maliakal -Last Changed Rev: 1680 -Last Changed Date: 2017-11-22 11:36:57.000000002 +0100 ./multiSlsDetector/multiSlsDetector.cpp +Last Changed Rev: 1619 +Last Changed Date: 2017-11-27 14:45:39.000000002 +0100 ./slsDetector/slsDetectorBase.h diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 11794d101..8ca9548e5 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -215,7 +215,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) thisMultiDetector->acquiringFlag = false; thisMultiDetector->externalgui = false; - thisMultiDetector->receiver_datastream = false; + thisMultiDetector->receiver_upstream = false; thisMultiDetector->alreadyExisting=1; } @@ -281,7 +281,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) getNMods(); getMaxMods(); - client_datastream = false; + client_downstream = false; for(int i=0;igetClientStreamingPort().c_str(),"%d",&portnum); portnum += (i%numSocketsPerDetector); - + cout<<"ip to be set to :"<getClientStreamingIP().c_str()<getClientStreamingIP().c_str(), portnum); if (zmqSocket[i]->IsError()) { cprintf(RED, "Error: Could not create Zmq socket on port %d\n", portnum); @@ -5781,7 +5752,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){ printf("Zmq Client[%d] at %s\n",i, zmqSocket[i]->GetZmqServerAddress()); } - client_datastream = true; + client_downstream = true; cout << "Receiving Data Socket(s) created" << endl; return OK; } @@ -5898,6 +5869,8 @@ void multiSlsDetector::readFrameFromReceiver(){ multiframegain = new char[multidatabytes](); bool runningList[numSockets]; + bool connectList[numSockets]; + int numRunning = 0; //wait for real time acquisition to start @@ -5906,8 +5879,17 @@ void multiSlsDetector::readFrameFromReceiver(){ if(checkJoinThread()) running = false; - for(int i = 0; i < numSockets; ++i) - runningList[i] = true; + for(int i = 0; i < numSockets; ++i) { + if(!zmqSocket[i]->Connect()) { + connectList[i] = true; + runningList[i] = true; + } else { + connectList[i] = false; + cprintf(RED,"Error: Could not connect to socket %s\n",zmqSocket[i]->GetZmqServerAddress()); + runningList[i] = false; + } + } + numRunning = numSockets; @@ -5996,6 +5978,11 @@ void multiSlsDetector::readFrameFromReceiver(){ running = true; } + // Disconnect resources + for (int i = 0; i < numSockets; ++i) + if (connectList[i]) + zmqSocket[i]->Disconnect(); + //free resources delete [] image; delete[] multiframe; @@ -6371,7 +6358,7 @@ int multiSlsDetector::enableDataStreamingToClient(int enable) { } } } - return client_datastream; + return client_downstream; } int multiSlsDetector::enableDataStreamingFromReceiver(int enable){ @@ -6407,10 +6394,10 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable){ } } } - thisMultiDetector->receiver_datastream = ret; + thisMultiDetector->receiver_upstream = ret; } - return thisMultiDetector->receiver_datastream; + return thisMultiDetector->receiver_upstream; } int multiSlsDetector::enableReceiverCompression(int i){ diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 9443e44cd..bf776825a 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -217,7 +217,7 @@ class multiSlsDetector : public slsDetectorUtils { int receiverOnlineFlag; /** data streaming (up stream) enable in receiver */ - bool receiver_datastream; + bool receiver_upstream; } sharedMultiSlsDetector; @@ -1025,6 +1025,15 @@ class multiSlsDetector : public slsDetectorUtils { string getNetworkParameter(networkParameter); + + /** + sets the network parameters + must restart streaming in client/receiver if to do with zmq after calling this function + \param i network parameter type + \param s value to be set + \returns parameter + + */ string setNetworkParameter(networkParameter, std::string); int setPort(portType, int); int lockServer(int); @@ -1524,7 +1533,7 @@ private: /** data streaming (down stream) enabled in client (zmq sckets created) */ - bool client_datastream; + bool client_downstream; /** ZMQ Socket - Receiver to Client */ ZmqSocket* zmqSocket[MAXDET]; diff --git a/slsDetectorSoftware/slsDetector/gitInfoLib.h b/slsDetectorSoftware/slsDetector/gitInfoLib.h index c6fab4f68..634e08943 100644 --- a/slsDetectorSoftware/slsDetector/gitInfoLib.h +++ b/slsDetectorSoftware/slsDetector/gitInfoLib.h @@ -1,11 +1,11 @@ //#define SVNPATH "" #define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git" //#define SVNREPPATH "" -#define SVNREPUUIDLIB "c79a7cdd6f5f936a90bb31038389b587745a3088" -//#define SVNREV 0x1680 +#define SVNREPUUIDLIB "ea284699983c3811852b1bcea3708d952803020d" +//#define SVNREV 0x1619 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTHLIB "Dhanya_Maliakal" -#define SVNREVLIB 0x1680 -#define SVNDATELIB 0x20171122 +#define SVNREVLIB 0x1619 +#define SVNDATELIB 0x20171127 // diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 969889137..2ed184889 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -797,7 +797,7 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->flippedData[1] = 0; thisDetector->zmqport = 0; thisDetector->receiver_zmqport = 0; - thisDetector->receiver_datastream = false; + thisDetector->receiver_upstream = false; thisDetector->receiver_read_freq = 0; for (int ia=0; iacurrentSettings; } @@ -3771,7 +3773,8 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise if (isettings != thisDetector->currentSettings) { - std::cout<< "Unknown settings for this detector!" << std::endl; + printf("Unknown settings %s for this detector!\n", getDetectorSettings(isettings).c_str()); + setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); }else{ if (imod<0) { modmi=0; @@ -6452,9 +6455,11 @@ string slsDetector::setReceiverStreamingIP(string sourceIP) { // set it anyway, else it is lost memset(thisDetector->receiver_zmqip, 0, MAX_STR_LENGTH); strcpy(thisDetector->receiver_zmqip, arg); + + // if zmqip is empty, update it if (! strlen(thisDetector->zmqip)) - strcpy(thisDetector->zmqip, retval); + strcpy(thisDetector->zmqip, arg); if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ @@ -8519,7 +8524,7 @@ int slsDetector::updateReceiverNoWait() { // receiver streaming enable n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_datastream = ind; + thisDetector->receiver_upstream = ind; // streaming source ip n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); @@ -8809,14 +8814,14 @@ int slsDetector::enableDataStreamingFromReceiver(int enable){ cout << "could not set data streaming in receiver to " << enable <<" Returned:" << retval << endl; setErrorMask((getErrorMask())|(DATA_STREAMING)); } else { - thisDetector->receiver_datastream = retval; + thisDetector->receiver_upstream = retval; if(ret==FORCE_UPDATE) updateReceiver(); } } } - return thisDetector->receiver_datastream; + return thisDetector->receiver_upstream; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 8b5a3bbf3..d162dc2c9 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -274,7 +274,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion { /** tcp port from receiver to gui/different process (only data) */ int receiver_zmqport; /** data streaming (up stream) enable in receiver */ - bool receiver_datastream; + bool receiver_upstream; /* Receiver read frequency */ int receiver_read_freq; /** zmq tcp src ip address in client (only data) **/ @@ -463,7 +463,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion { /** sets the network parameters - \param i network parameter type can be RECEIVER_IP, RECEIVER_MAC, SERVER_MAC + must restart streaming in client/receiver if to do with zmq after calling this function + \param i network parameter type \param s value to be set \returns parameter @@ -1817,6 +1818,16 @@ class slsDetector : public slsDetectorUtils, public energyConversion { */ int setReceiverReadTimer(int time_in_ms=500); + /** + * 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 enableDataStreamingToClient(int enable=-1) { + cprintf(RED,"ERROR: Must be called from the multi Detector level\n"); + return 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 from receiver enable diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index b31ccabeb..219353535 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -574,9 +574,15 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef /** Reads frames from receiver through a constant socket */ - // virtual int* readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex)=0; virtual void readFrameFromReceiver()=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 + */ +virtual int enableDataStreamingToClient(int enable=-1)=0; + /** Sets the read receiver frequency if data required from receiver randomly readRxrFrequency=0, else every nth frame to be sent to gui diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index f86772d53..7ffe9bcd5 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -1895,14 +1895,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page network - - zmqport [port] 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) + - zmqport [port] 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. Use single-detector command to set individually or multi-detector command to calculate based on \c port for the rest. Must restart zmq client streaming in gui/external gui \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) + - 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. put restarts streaming in receiver with new port. \c Returns \c (int) */ descrToFuncMap[i].m_pFuncName="rx_zmqport"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter; @@ -2338,15 +2338,6 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) { myDet->setOnline(ONLINE_FLAG); int r_online = myDet->setReceiverOnline(ONLINE_FLAG); - // switch off data streaming to prevent extra images in zmq gui buffer - /*if (r_online == ONLINE_FLAG) { - if (myDet->enableDataStreamingFromReceiver() != 0) { - if (myDet->enableDataStreamingFromReceiver(0) != 0) { - std::cout << "Error: Unable to switch off data streaming in receiver. If GUI on, extra image(s) in zmq GUI buffer" << std::endl; - } - } - }*/ - if(myDet->acquire() == FAIL) return string("acquire unsuccessful"); if(r_online){ @@ -3914,6 +3905,7 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio networkParameter t; int i; + int prev_streaming = 0; if (action==HELP_ACTION) return helpNetworkParameter(narg,args,action); @@ -3977,6 +3969,9 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio if (action==PUT_ACTION){ if (!(sscanf(args[1],"%d",&i))) return ("cannot parse argument") + string(args[1]); + // if streaming, switch it off + prev_streaming = myDet->enableDataStreamingFromReceiver(); + if (prev_streaming) myDet->enableDataStreamingFromReceiver(0); } }else if (cmd=="zmqip") { t=CLIENT_STREAMING_SRC_IP; @@ -3985,8 +3980,13 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio } else return ("unknown network parameter")+cmd; - if (action==PUT_ACTION) + if (action==PUT_ACTION) { myDet->setNetworkParameter(t, args[1]); + // switch it back on, if it had been switched on + if (prev_streaming && t == RECEIVER_STREAMING_PORT) + myDet->enableDataStreamingFromReceiver(1); + + } return myDet->getNetworkParameter(t); } @@ -4009,15 +4009,17 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti 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 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; + "Use single-detector command to set individually or multi-detector command to calculate based on port for the rest." + "Must restart streaming in client with new port from gui/external gui"<< 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; + "Use single-detector command to set individually or multi-detector command to calculate based on port for the rest." + "Restarts streaming in receiver with new port"<< 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; + "This is usually used to stream in from an external process." + "Must restart streaming in client with new port from gui/external gui. " << 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; + "Default is ip of rx_hostname and works for GUI. This is usually used to stream out to an external process for further processing." + "restarts streaming in receiver with new port" << std::endl; } if (action==GET_ACTION || action==HELP_ACTION) { os << "detectormac \n gets detector mac "<< std::endl; @@ -5943,21 +5945,12 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { myDet->setOnline(ONLINE_FLAG); - int r_online = myDet->setReceiverOnline(ONLINE_FLAG); + myDet->setReceiverOnline(ONLINE_FLAG); if(cmd=="receiver"){ if (action==PUT_ACTION) { - if(!strcasecmp(args[1],"start")) { - /*// switch off data streaming to prevent extra images in zmq gui buffer - if (r_online == ONLINE_FLAG) { - if (myDet->enableDataStreamingFromReceiver() != 0) { - if (myDet->enableDataStreamingFromReceiver(0) != 0) { - std::cout << "Error: Unable to switch off data streaming in receiver. If GUI on, extra image(s) in zmq GUI buffer" << std::endl; - } - } - }*/ + if(!strcasecmp(args[1],"start")) myDet->startReceiver(); - } else if(!strcasecmp(args[1],"stop")) myDet->stopReceiver(); else diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 39e5a8d81..8c26c964c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -211,8 +211,9 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { virtual string getNetworkParameter(networkParameter i)=0; /** - sets the network parameters (implemented for gotthard) - \param i network parameter type can be RECEIVER_IP, RECEIVER_MAC, SERVER_MAC + sets the network parameters + must restart streaming in client/receiver if to do with zmq after calling this function + \param i network parameter type \param s value to be set \returns parameter @@ -784,6 +785,13 @@ virtual ROI* getROI(int &n)=0; */ virtual int setReadReceiverFrequency(int freq=-1)=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 + */ +virtual int enableDataStreamingToClient(int enable=-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 from receiver enable diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 4911a8991..1cc761757 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -509,11 +509,9 @@ void* postProcessing::processData(int delflag) { pthread_mutex_unlock(&mg); //cprintf(RED,"In post processing threads\n"); - - if(dataReady){ + if(dataReady) { readFrameFromReceiver(); - } - + } //only update progress else{ int caught = -1; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h index d2e87722c..97017e060 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -238,7 +238,7 @@ s void ResetPositionIndex(){pthread_mutex_lock(&mp); resetPositionIndex(); pthread_mutex_unlock(&mp);}; - void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;}; + void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;enableDataStreamingToClient(1);}; void registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg) {rawDataReady = userCallback; pRawDataArg = pArg;};