diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index f69184230..d2d43e005 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -183,8 +183,8 @@ int main(int argc, char *argv[]) { gainfname = args["gainfile"]; etafname = args["etafilefile"]; - if (atoi(args["nuninterfaces"].c_str())>1){ - cprintf(RED, "Sorry, at the moment only a single interface is supported instead of %d\n",atoi(args["nuninterfaces"].c_str())); + if (atoi(args["numinterfaces"].c_str())>1){ + cprintf(RED, "Sorry, at the moment only a single interface is supported instead of %d\n",atoi(args["numinterfaces"].c_str())); return EXIT_FAILURE; } @@ -272,54 +272,34 @@ int main(int argc, char *argv[]) { sls::ZmqSocket *zmqsocket = NULL; -#ifdef NEWZMQ // receive socket try { -#endif - zmqsocket = new sls::ZmqSocket(socketip.c_str(), portnum); - -#ifdef NEWZMQ } catch (...) { cprintf(RED, - "Error: Could not create Zmq socket on port %d with ip %s\n", + "Error: Could not create Zmq receiving socket on port %d with ip %s\n", portnum, socketip.c_str()); delete zmqsocket; return EXIT_FAILURE; } -#endif - -#ifndef NEWZMQ - if (zmqsocket->IsError()) { - cprintf(RED, - "Error: Could not create Zmq socket on port %d with ip %s\n", - portnum, socketip.c_str()); - delete zmqsocket; - return EXIT_FAILURE; - } -#endif if (zmqsocket->Connect()) { - cprintf(RED, "Error: Could not connect to socket %s\n", + cprintf(RED, "Error: Could not connect to Zmq receiving socket %s\n", (zmqsocket->GetZmqServerAddress()).c_str()); delete zmqsocket; return EXIT_FAILURE; } else - printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress().c_str()); + printf("Zmq receiving socket at %s\n", zmqsocket->GetZmqServerAddress().c_str()); // send socket sls::ZmqSocket *zmqsocket2 = 0; // cout << "zmq2 " << endl; if (send) { -#ifdef NEWZMQ // receive socket try { -#endif - zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2.c_str()); - -#ifdef NEWZMQ + zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2.c_str()); } catch (...) { cprintf(RED, - "Error: Could not create Zmq socket server on port %d and " + "Error: Could not create Zmq sending socket on port %d and " "ip %s\n", portnum2, socketip2.c_str()); // delete zmqsocket2; @@ -328,28 +308,7 @@ int main(int argc, char *argv[]) { // return EXIT_FAILURE; send = false; } -#endif - -#ifndef NEWZMQ - if (zmqsocket2->IsError()) { - cprintf(RED, - "AAA Error: Could not create Zmq socket server on port %d " - "and ip %s\n", - portnum2, socketip2.c_str()); - // delete zmqsocket2; - // delete zmqsocket; - // return EXIT_FAILURE; - send = false; - } -#endif - if (zmqsocket2->Connect()) { - cprintf(RED, "BBB Error: Could not connect to socket %s\n", - zmqsocket2->GetZmqServerAddress().c_str()); - // delete zmqsocket2; - send = false; - // return EXIT_FAILURE; - } else - printf("Zmq Client at %s\n", + printf("Zmq sending socket at %s\n", zmqsocket2->GetZmqServerAddress().c_str()); } diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index e97f31bb9..e61084330 100755 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -82,10 +82,11 @@ if(SLS_USE_TEXTCLIENT) set(det_bin_names "sls_detector_put" "sls_detector_get" "sls_detector_acquire" + "sls_detector_acquire_zmq" "sls_detector_help" "sls_detector" ) - set(det_cmd_name "PUT" "GET" "READOUT" "HELP" "INFER") + set(det_cmd_name "PUT" "GET" "READOUT" "READOUTZMQ" "HELP" "INFER") list(LENGTH det_bin_names len1) math(EXPR len2 "${len1} - 1") diff --git a/slsDetectorSoftware/generator/Caller.in.h b/slsDetectorSoftware/generator/Caller.in.h index 21c4ac098..0344605c6 100644 --- a/slsDetectorSoftware/generator/Caller.in.h +++ b/slsDetectorSoftware/generator/Caller.in.h @@ -71,6 +71,8 @@ class Caller { using StringMap = std::map; Detector *ptr; // pointer to the detector that executes the command + static void EmptyDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer); + FunctionMap functions{ {"list", &Caller::list}, diff --git a/slsDetectorSoftware/src/Caller.h b/slsDetectorSoftware/src/Caller.h index b3ec879b4..55aba7968 100644 --- a/slsDetectorSoftware/src/Caller.h +++ b/slsDetectorSoftware/src/Caller.h @@ -397,6 +397,9 @@ class Caller { using StringMap = std::map; Detector *ptr; // pointer to the detector that executes the command + static void EmptyDataCallBack(detectorData *data, uint64_t frameIndex, + uint32_t subFrameIndex, void *this_pointer); + FunctionMap functions{ {"list", &Caller::list}, diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index c760a9c4f..ec42a0368 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -212,6 +212,12 @@ std::string Caller::hostname(int action) { } return os.str(); } + +void Caller::EmptyDataCallBack(detectorData *data, uint64_t frameIndex, + uint32_t subFrameIndex, void *this_pointer) { + LOG(logDEBUG) << "EmptyDataCallBack to start up zmq sockets"; +} + std::string Caller::acquire(int action) { std::ostringstream os; if (action == defs::HELP_ACTION) { @@ -232,6 +238,9 @@ std::string Caller::acquire(int action) { if (det_id >= 0) { throw RuntimeError("Individual detectors not allowed for readout."); } + if (action == defs::READOUT_ZMQ_ACTION) { + det->registerDataCallback(&(EmptyDataCallBack), this); + } det->acquire(); if (det->getUseReceiverFlag().squash(false)) { diff --git a/slsDetectorSoftware/src/CmdApp.cpp b/slsDetectorSoftware/src/CmdApp.cpp index 9a616e19b..5f6c98628 100644 --- a/slsDetectorSoftware/src/CmdApp.cpp +++ b/slsDetectorSoftware/src/CmdApp.cpp @@ -20,6 +20,10 @@ int main(int argc, char *argv[]) { int action = slsDetectorDefs::READOUT_ACTION; #endif +#ifdef READOUTZMQ + int action = slsDetectorDefs::READOUT_ZMQ_ACTION; +#endif + #ifdef HELP int action = slsDetectorDefs::HELP_ACTION; #endif @@ -38,7 +42,7 @@ int main(int argc, char *argv[]) { sls::CmdParser parser; parser.Parse(argc, argv); - if (action == slsDetectorDefs::READOUT_ACTION) + if (action == slsDetectorDefs::READOUT_ACTION || action == slsDetectorDefs::READOUT_ZMQ_ACTION) parser.setCommand("acquire"); if (parser.isHelp()) diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index d7eafd5fd..e56032dd1 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -216,7 +216,7 @@ typedef struct { /** type of action performed (for text client) */ - enum { GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION }; + enum { GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION, READOUT_ZMQ_ACTION }; /** dimension indexes