From a77964e1dd0d63d85bda39f3a5b87db1e287a90a Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 8 Aug 2019 16:18:04 +0200 Subject: [PATCH 1/2] WIP --- slsDetectorSoftware/include/Detector.h | 46 +++++++++---------- .../include/multiSlsDetector.h | 8 ++-- slsDetectorSoftware/include/slsDetector.h | 2 +- slsDetectorSoftware/src/Detector.cpp | 24 +++++++++- slsDetectorSoftware/src/slsDetector.cpp | 2 +- 5 files changed, 52 insertions(+), 30 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 2270abbe3..341ec91e5 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -295,46 +295,46 @@ class Detector { void setReadNLines(const int value, Positions pos = {}); /** - * Get Receiver TCP port (for client communication with Receiver) + * Get Detector Control TCP port (for client communication with Detector control server) * @param pos detector position - * @returns receiver port + * @returns control TCP port */ - //int getControlort(Positions pos = {}) const; + Result getControlPort(Positions pos = {}) const; /** - * Set TCP Port of the detector (for client communication with Receiver) + * Set Detector Control TCP port (for client communication with Detector control server) * @param value port number * @param pos detector position */ - //void setControlPort(int port_number, Positions pos = {}); + void setControlPort(int value, Positions pos = {}); + + /** + * Get Detector Stop TCP port (for client communication with Detector Stop server) + * @param pos detector position + * @returns Stop TCP port + */ + Result getStopPort(Positions pos = {}) const; + + /** + * Set Detector Stop TCP port (for client communication with Detector Stop server) + * @param value port number + * @param pos detector position + */ + void setStopPort(int value, Positions pos = {}); /** * Get Receiver TCP port (for client communication with Receiver) * @param pos detector position - * @returns receiver port + * @returns Receiver TCP port */ - //int getStopPort(Positions pos = {}) const; + Result getReceiverPort(Positions pos = {}) const; /** - * Set TCP Port of the detector (for client communication with Receiver) + * Set Receiver TCP port (for client communication with Receiver) * @param value port number * @param pos detector position */ - //void setStopPort(int port_number, Positions pos = {}); - - /** - * Get Receiver TCP port (for client communication with Receiver) - * @param pos detector position - * @returns receiver port - */ - //int getReceiverPort(Positions pos = {}) const; - - /** - * Set TCP Port of the detector (for client communication with Receiver) - * @param value port number - * @param pos detector position - */ - //void setReceiverPort(int port_number, Positions pos = {}); + void setReceiverPort(int value, Positions pos = {}); diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 556eb28c0..3e9f3ee43 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -534,7 +534,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns port number */ - int setControlPort(int port_number = -1, int detPos = -1); + int setControlPort(int port_number = -1, int detPos = -1);// /** * Set/Gets TCP STOP Port of the detector @@ -542,7 +542,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns port number */ - int setStopPort(int port_number = -1, int detPos = -1); + int setStopPort(int port_number = -1, int detPos = -1);// /** * Set/Gets TCP Port of the receiver @@ -550,14 +550,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns port number */ - int setReceiverPort(int port_number = -1, int detPos = -1); + int setReceiverPort(int port_number = -1, int detPos = -1);// /** * Get Receiver port * @param detPos -1 for all detectors in list or specific detector position * @returns vector of receiver port */ - int getReceiverPort(int detPos = -1) const; + int getReceiverPort(int detPos = -1) const;// /** * Lock server for this client IP diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index 2a96ce92f..91c8cf684 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -447,7 +447,7 @@ class slsDetector : public virtual slsDetectorDefs { * Set Detector offset in shared memory * @param value offset for detector */ - void setDetectorOffset(slsDetectorDefs::coordinates value); + void setDetectorOffsets(slsDetectorDefs::coordinates value); /** * Set Detector offset in shared memory in dimension d diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 577e7415a..0d39b6b34 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -209,7 +209,7 @@ Result Detector::getDetectorOffsets(Positions pos) const { } void Detector::setDetectorOffsets(defs::coordinates value, Positions pos) { - return pimpl->Parallel(&slsDetector::setDetectorOffset, pos, value); + return pimpl->Parallel(&slsDetector::setDetectorOffsets, pos, value); } Result Detector::getQuad(Positions pos) const { @@ -228,7 +228,29 @@ void Detector::setReadNLines(const int value, Positions pos) { pimpl->Parallel(&slsDetector::setReadNLines, pos, value); } +Result Detector::getControlPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getControlPort, pos); +} +void Detector::setControlPort(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setControlPort, pos, value); +} + +Result Detector::getStopPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getStopPort, pos); +} + +void Detector::setStopPort(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setStopPort, pos, value); +} + +Result Detector::getReceiverPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverPort, pos); +} + +void Detector::setReceiverPort(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverPort, pos, value); +} // Erik Result Detector::getFramesCaughtByReceiver(Positions pos) const { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 7133a4a53..0c942a57d 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -706,7 +706,7 @@ void slsDetector::setDetectorOffset(dimension d, int off) { } } -void slsDetector::setDetectorOffset(slsDetectorDefs::coordinates value) { +void slsDetector::setDetectorOffsets(slsDetectorDefs::coordinates value) { shm()->offset[X] = value.x; shm()->offset[Y] = value.y; } From eaf0d8668b280244d8104f8df571d667999e4d90 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 8 Aug 2019 16:39:25 +0200 Subject: [PATCH 2/2] WIP --- slsDetectorSoftware/include/Detector.h | 1 - .../include/multiSlsDetector.h | 16 --------- slsDetectorSoftware/include/slsDetector.h | 12 ------- slsDetectorSoftware/src/Detector.cpp | 1 + slsDetectorSoftware/src/multiSlsDetector.cpp | 20 ----------- slsDetectorSoftware/src/slsDetector.cpp | 20 ----------- .../src/slsDetectorCommand.cpp | 33 ++----------------- 7 files changed, 3 insertions(+), 100 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 341ec91e5..a8150b7b3 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -337,7 +337,6 @@ class Detector { void setReceiverPort(int value, Positions pos = {}); - // Erik Result getFramesCaughtByReceiver(Positions pos = {}) const; diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 3e9f3ee43..d659987b6 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -520,14 +520,6 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ int getReadNLines(int detPos = -1);// - /** - * Checks if each of the detectors are online/offline - * @param detPos -1 for all detectors in list or specific detector position - * @returns empty string if they are all online, - * else returns concatenation of strings of all detectors that are offline - */ - std::string checkOnline(int detPos = -1); - /** * Set/Gets TCP Port of the detector * @param port_number (-1 gets) @@ -1761,14 +1753,6 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ bool getUseReceiverFlag(int detPos = -1); // - /** - * Checks if the receiver is really online - * @param detPos -1 for all detectors in list or specific detector position - * @returns empty string if all online, else concatenates hostnames of all - * detectors that are offline - */ - std::string checkReceiverOnline(int detPos = -1); //not needed - /** * Locks/Unlocks the connection to the receiver * @param lock sets (1), usets (0), gets (-1) the lock diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index 91c8cf684..300bdec08 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -456,12 +456,6 @@ class slsDetector : public virtual slsDetectorDefs { */ void updateMultiSize(int detx, int dety); - /** - * Checks if each of the detector is online/offline - * @returns empty string if it is online - * else returns hostname if it is offline - */ - std::string checkOnline(); int setControlPort(int port_number); @@ -1474,12 +1468,6 @@ class slsDetector : public virtual slsDetectorDefs { */ bool getUseReceiverFlag() const; - /** - * Checks if the receiver is really online - * @returns empty string if online, else returns receiver hostname - */ - std::string checkReceiverOnline(); - /** * Locks/Unlocks the connection to the receiver * @param lock sets (1), usets (0), gets (-1) the lock diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 216f9aa5c..ea62ba2f7 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -253,6 +253,7 @@ void Detector::setReceiverPort(int value, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverPort, pos, value); } + // Erik Result Detector::getFramesCaughtByReceiver(Positions pos) const { return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos); diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index a13c79a6c..cf772606f 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -788,15 +788,6 @@ int multiSlsDetector::getReadNLines(int detPos) { return sls::minusOneIfDifferent(r); } -std::string multiSlsDetector::checkOnline(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->checkOnline(); - } - - auto r = parallelCall(&slsDetector::checkOnline); - return sls::concatenateNonEmptyStrings(r); -} - int multiSlsDetector::setControlPort(int port_number, int detPos) { if (detPos >= 0) { return detectors[detPos]->setControlPort(port_number); @@ -2995,17 +2986,6 @@ bool multiSlsDetector::getUseReceiverFlag(int detPos) { } } -std::string multiSlsDetector::checkReceiverOnline(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->checkReceiverOnline(); - } - - // multi - auto r = parallelCall(&slsDetector::checkReceiverOnline); - return sls::concatenateNonEmptyStrings(r); -} - int multiSlsDetector::lockReceiver(int lock, int detPos) { // single if (detPos >= 0) { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 0c942a57d..2b608b922 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -716,17 +716,6 @@ void slsDetector::updateMultiSize(int detx, int dety) { shm()->multiSize[1] = dety; } -std::string slsDetector::checkOnline() { - std::string retval; - try { - // Need both control and stop socket to work! - auto client = DetectorSocket(shm()->hostname, shm()->controlPort); - auto stop = DetectorSocket(shm()->hostname, shm()->stopPort); - } catch (...) { - retval = shm()->hostname; - } - return retval; -} int slsDetector::setControlPort(int port_number) { int retval = -1; @@ -2970,15 +2959,6 @@ void slsDetector::printReceiverConfiguration(TLogLevel level) { bool slsDetector::getUseReceiverFlag() const { return shm()->useReceiverFlag; } -std::string slsDetector::checkReceiverOnline() { - try { - getReceiverSoftwareVersion(); - } catch (...) { - return shm()->rxHostname; - } - return std::string(); -} - int slsDetector::lockReceiver(int lock) { FILE_LOG(logDEBUG1) << "Setting receiver server lock to " << lock; int retval = -1; diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index 7ac82ced0..4f1153667 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -287,12 +287,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { commands to configure detector status */ - /*! \page config - - checkonline returns the hostnames of all detectors without connecting to them. \c Returns (string) "All online" or "[list of offline hostnames] : Not online". - */ - descrToFuncMap[i].m_pFuncName = "checkonline"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOnline; - ++i; /*! \page config - activate [b] [p] Activates/Deactivates the detector. \c b is 1 for activate, 0 for deactivate. Deactivated detector does not send data. \c p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Used for EIGER only. \c Returns \c (int) (string) */ @@ -1797,13 +1791,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver; ++i; - /*! \page receiver - - rx_checkonline Checks the receiver if it is online/offline mode. Only get! \c Returns (string) "All online" or "[list of offline hostnames] : Not online". - */ - descrToFuncMap[i].m_pFuncName = "rx_checkonline"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOnline; - ++i; - /*! \page receiver - framescaught gets the number of frames caught by receiver. Average of all for multi-detector command. Only get! \c Returns \c (int) */ @@ -3207,15 +3194,7 @@ std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], i int ival; char ans[1000]; - if (cmd == "checkonline") { - if (action == PUT_ACTION) - return std::string("cannot set"); - strcpy(ans, myDet->checkOnline(detPos).c_str()); - if (!strlen(ans)) - strcpy(ans, "All online"); - else - strcat(ans, " :Not online"); - } else if (cmd == "activate") { + if (cmd == "activate") { if (action == PUT_ACTION) { if (!sscanf(args[1], "%d", &ival)) @@ -3235,13 +3214,7 @@ std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], i int ret = myDet->setDeactivatedRxrPaddingMode(-1, detPos); sprintf(ans, "%d %s", myDet->activate(-1, detPos), ret == 1 ? "padding" : (ret == 0 ? "nopadding" : "unknown")); } else { - if (action == PUT_ACTION) - return std::string("cannot set"); - strcpy(ans, myDet->checkReceiverOnline(detPos).c_str()); - if (!strlen(ans)) - strcpy(ans, "All receiver online"); - else - strcat(ans, " :Not all receiver online"); + return std::string("unknown command"); } return ans; @@ -3254,8 +3227,6 @@ std::string slsDetectorCommand::helpOnline(int action) { os << "activate i [p]\n sets the detector in activated (1) or deactivated (0) mode (does not send data). p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Only for Eiger." << std::endl; } if (action == GET_ACTION || action == HELP_ACTION) { - os << "checkonline \n returns the hostnames of all detectors in offline mode" << std::endl; - os << "rx_checkonline \n returns the hostnames of all receiver in offline mode" << std::endl; os << "activate \n gets the detector activated (1) or deactivated (0) mode. And padding or nonpadding for the deactivated receiver. Only for Eiger." << std::endl; } return os.str();