From ca2c284017b38faf082df21d69ff57d90bc0e829 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 8 Aug 2019 16:55:37 +0200 Subject: [PATCH] WIP --- slsDetectorSoftware/include/Detector.h | 48 ++++++++++++++++--- .../include/multiSlsDetector.h | 8 ++-- slsDetectorSoftware/include/slsDetector.h | 4 +- slsDetectorSoftware/src/Detector.cpp | 22 ++++++++- slsDetectorSoftware/src/slsDetector.cpp | 4 +- 5 files changed, 71 insertions(+), 15 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index a8150b7b3..4fc40c7b4 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -295,28 +295,32 @@ class Detector { void setReadNLines(const int value, Positions pos = {}); /** - * Get Detector Control TCP port (for client communication with Detector control server) + * Get Detector Control TCP port (for client communication with Detector + * control server) * @param pos detector position * @returns control TCP port */ Result getControlPort(Positions pos = {}) const; /** - * Set Detector Control TCP port (for client communication with Detector control server) + * Set Detector Control TCP port (for client communication with Detector + * control server) * @param value port number * @param pos detector position */ void setControlPort(int value, Positions pos = {}); /** - * Get Detector Stop TCP port (for client communication with Detector Stop server) + * 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) + * Set Detector Stop TCP port (for client communication with Detector Stop + * server) * @param value port number * @param pos detector position */ @@ -336,6 +340,39 @@ class Detector { */ void setReceiverPort(int value, Positions pos = {}); + /** + * Gets Lock for detector control server to this client IP + * @param pos detector position + * @returns lock + */ + Result getLockServer(Positions pos = {}); + + /** + * Sets Lock for detector control server to this client IP + * @param value lock + * @param pos detector position + */ + void setLockServer(bool value, Positions pos = {}); + + /** + * Get last client IP saved on detector server + * @param pos detector position + * @returns last client IP saved on detector server + */ + Result getLastClientIP(Positions pos = {}); + + /** + * Exit detector server + * @param pos detector position + */ + void exitServer(Positions pos = {}); + + /** + * Execute a command on the detector server + * @param value command + * @param pos detector position + */ + void execCommand(const std::string &value, Positions pos = {}); // Erik @@ -524,14 +561,13 @@ class Detector { void printReceiverConfiguration(Positions pos = {}) const; - /** [Eiger] * @returns deadtime in ns, 0 = disabled */ Result getRateCorrection(Positions pos = {}) const; /** - * [Eiger] Set Rate correction + * [Eiger] Set Rate correction * 0 disable correction, <0 set to default, >0 deadtime in ns */ void setRateCorrection(int64_t dead_time_ns, Positions pos = {}); diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index d659987b6..446c0d62b 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -557,27 +557,27 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns 1 for locked or 0 for unlocked */ - int lockServer(int p = -1, int detPos = -1); + int lockServer(int p = -1, int detPos = -1);// /** * Get last client IP saved on detector server * @param detPos -1 for all detectors in list or specific detector position * @returns last client IP saved on detector server */ - std::string getLastClientIP(int detPos = -1); + std::string getLastClientIP(int detPos = -1);// /** * Exit detector server * @param detPos -1 for all detectors in list or specific detector position */ - void exitServer(int detPos = -1); + void exitServer(int detPos = -1);// /** * Execute a command on the detector server * @param cmd command * @param detPos -1 for all detectors in list or specific detector position */ - void execCommand(const std::string &cmd, int detPos); + void execCommand(const std::string &cmd, int detPos);// /** * Load configuration from a configuration File diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index 300bdec08..516f43eab 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -484,9 +484,9 @@ class slsDetector : public virtual slsDetectorDefs { /** * Lock server for this client IP * @param p 0 to unlock, 1 to lock (-1 gets) - * @returns 1 for locked or 0 for unlocked + * @returns true for locked or false for unlocked */ - int lockServer(int lock = -1); + bool lockServer(int lock = -1); /** * Get last client IP saved on detector server diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index ea62ba2f7..99e7d8fd3 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -210,7 +210,8 @@ Result Detector::getDetectorOffsets(Positions pos) const { void Detector::setDetectorOffsets(defs::coordinates value, Positions pos) { pimpl->Parallel(&slsDetector::setDetectorOffsets, pos, value); - //pimpl->Parallel(&slsDetector::setDetectorOffset, pos, value); + // pimpl->Parallel(&slsDetector::setDetectorOffset, pos, + // value); } Result Detector::getQuad(Positions pos) const { @@ -253,6 +254,25 @@ void Detector::setReceiverPort(int value, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverPort, pos, value); } +Result Detector::getLockServer(Positions pos) { + return pimpl->Parallel(&slsDetector::lockServer, pos, -1); +} + +void Detector::setLockServer(bool value, Positions pos) { + pimpl->Parallel(&slsDetector::lockServer, pos, static_cast(value)); +} + +Result Detector::getLastClientIP(Positions pos) { + return pimpl->Parallel(&slsDetector::getLastClientIP, pos); +} + +void Detector::exitServer(Positions pos) { + pimpl->Parallel(&slsDetector::exitServer, pos); +} + +void Detector::execCommand(const std::string &value, Positions pos) { + pimpl->Parallel(&slsDetector::execCommand, pos, value); +} // Erik Result Detector::getFramesCaughtByReceiver(Positions pos) const { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 2b608b922..e79284da3 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -761,12 +761,12 @@ int slsDetector::getControlPort() const { return shm()->controlPort; } int slsDetector::getStopPort() const { return shm()->stopPort; } -int slsDetector::lockServer(int lock) { +bool slsDetector::lockServer(int lock) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting detector server lock to " << lock; sendToDetector(F_LOCK_SERVER, lock, retval); FILE_LOG(logDEBUG1) << "Lock: " << retval; - return retval; + return (retval == 1 ? true : false); } std::string slsDetector::getLastClientIP() {