From 6b363a16feceefcb41d0600e625aa0e1ab60963b Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 9 Aug 2019 14:45:07 +0200 Subject: [PATCH 1/4] WIP --- python/src/DetectorPythonInterface.h | 24 ++++---- slsDetectorSoftware/include/Detector.h | 24 +++++++- .../include/multiSlsDetector.h | 16 ++--- slsDetectorSoftware/src/Detector.cpp | 61 ++++++++++++++++--- slsDetectorSoftware/src/multiSlsDetector.cpp | 3 +- 5 files changed, 97 insertions(+), 31 deletions(-) diff --git a/python/src/DetectorPythonInterface.h b/python/src/DetectorPythonInterface.h index a91f2ec96..9f8b3efc0 100755 --- a/python/src/DetectorPythonInterface.h +++ b/python/src/DetectorPythonInterface.h @@ -156,7 +156,7 @@ class DetectorPythonInterface { return g; } - int getNumberOfDetectors() { return det.getNumberOfDetectors(); } + int getNumberOfDetectors() { return det.size(); } std::string getRunStatus() { auto s = det.getRunStatus(); @@ -234,7 +234,7 @@ class DetectorPythonInterface { } void setRateCorrection(std::vector tau) { - for (int i = 0; i < det.getNumberOfDetectors(); ++i) + for (size_t i = 0; i < det.size(); ++i) det.setRateCorrection(tau[i], i); } @@ -334,7 +334,7 @@ class DetectorPythonInterface { std::vector getMeasuredPeriod() { std::vector mp; - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + for (size_t i = 0; i < det.size(); ++i) { auto t = det.getTimeLeft(slsDetectorDefs::MEASURED_PERIOD, i); mp.push_back(static_cast(t) * 1E-9); } @@ -342,7 +342,7 @@ class DetectorPythonInterface { } std::vector getMeasuredSubPeriod() { std::vector mp; - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + for (size_t i = 0; i < det.size(); ++i) { auto t = det.getTimeLeft(slsDetectorDefs::MEASURED_SUBPERIOD, i); mp.push_back(static_cast(t) * 1E-9); } @@ -550,7 +550,7 @@ class DetectorPythonInterface { std::vector getDetectorType() { std::vector detector_type; - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + for (size_t i = 0; i < det.size(); ++i) { detector_type.push_back(det.getDetectorTypeAsString(i)); } return detector_type; @@ -577,8 +577,8 @@ class DetectorPythonInterface { // detectors return a vector of strings std::vector getReceiverStreamingPort() { std::vector vec; - vec.reserve(det.getNumberOfDetectors()); - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + vec.reserve(det.size()); + for (size_t i = 0; i < det.size(); ++i) { vec.push_back(det.getReceiverStreamingPort(i)); } return vec; @@ -590,8 +590,8 @@ class DetectorPythonInterface { std::vector getReceiverUDPPort() { std::vector vec; - vec.reserve(det.getNumberOfDetectors()); - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + vec.reserve(det.size()); + for (size_t i = 0; i < det.size(); ++i) { vec.push_back(det.getReceiverUDPPort(i)); } return vec; @@ -599,8 +599,8 @@ class DetectorPythonInterface { std::vector getReceiverUDPPort2() { std::vector vec; - vec.reserve(det.getNumberOfDetectors()); - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + vec.reserve(det.size()); + for (size_t i = 0; i < det.size(); ++i) { vec.push_back(det.getReceiverUDPPort2(i)); } return vec; @@ -990,7 +990,7 @@ void DetectorPythonInterface::setReadoutFlag(const std::string flag_name) { std::vector DetectorPythonInterface::getRateCorrection() { std::vector rate_corr; - for (int i = 0; i < det.getNumberOfDetectors(); ++i) { + for (size_t i = 0; i < det.size(); ++i) { rate_corr.push_back(det.getRateCorrection(i)); } return rate_corr; diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index a964543f2..da29ee2e1 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1113,9 +1113,31 @@ class Detector { int setDetectorMinMaxEnergyThreshold(const int index, int value); void setAdditionalJsonHeader(const std::string &jsonheader, - Positions pos = {}); + Positions pos = {}); Result getAdditionalJsonHeader(Positions pos = {}) const; + + Result getAdditionalJsonParameter(const std::string &key, + Positions pos = {}) const; + + void setAdditionalJsonParameter(const std::string &key, + const std::string &value, + Positions pos = {}); + + // TODO these should probably be the same + Result getReceiverStreamingIP(Positions pos = {}) const; + + void setReceiverDataStreamingOutIP(const std::string &ip, + Positions pos = {}); + + Result getClientStreamingIP(Positions pos = {}) const; + + // TODO these should probably be the same + void setClientDataStreamingInIP(const std::string &ip, Positions pos = {}); + + Result getReceiverStreamingPort(Positions pos = {}) const; + + // void setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 8e73c61fd..91dfd1a16 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -381,7 +381,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * Returns the number of detectors in the multidetector structure * @returns number of detectors */ - int size() const;// + size_t size() const;// /** * Returns number of detectors in dimension d @@ -1225,7 +1225,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position */ void setClientDataStreamingInIP(const std::string &ip = "", - int detPos = -1); + int detPos = -1); // /** * Returns the client zmq ip @@ -1234,7 +1234,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the client zmq ip */ - std::string getClientStreamingIP(int detPos = -1); + std::string getClientStreamingIP(int detPos = -1); // /** * (advanced users) @@ -1244,7 +1244,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position */ void setReceiverDataStreamingOutIP(const std::string &ip = "", - int detPos = -1); + int detPos = -1); // /** * Returns the receiver zmq ip @@ -1253,7 +1253,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver zmq ip */ - std::string getReceiverStreamingIP(int detPos = -1); + std::string getReceiverStreamingIP(int detPos = -1); // /** * Sets the transmission delay for left, right or entire frame @@ -1264,7 +1264,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @returns transmission delay */ int setDetectorNetworkParameter(networkParameter index, int delay, - int detPos = -1); + int detPos = -1); //maybe not needed in API /** * Sets the additional json header @@ -1273,14 +1273,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @returns additional json header, default is empty */ std::string setAdditionalJsonHeader(const std::string &jsonheader, - int detPos = -1); + int detPos = -1); // /** * Returns the additional json header * @param detPos -1 for all detectors in list or specific detector position * @returns the additional json header, default is empty */ - std::string getAdditionalJsonHeader(int detPos = -1); + std::string getAdditionalJsonHeader(int detPos = -1); // /** * Sets the value for the additional json header parameter if found, else diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 2f13d1bd4..962fceb47 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -142,9 +142,7 @@ Result Detector::getDetectorTypeAsString(Positions pos) const { return pimpl->Parallel(&slsDetector::getDetectorTypeAsString, pos); } -int Detector::size() const { - return pimpl->size(); -} +int Detector::size() const { return pimpl->size(); } defs::coordinates Detector::getNumberOfDetectors() const { defs::coordinates coord; @@ -432,7 +430,8 @@ Result Detector::getNumberOfCyclesLeft(Positions pos) const { } Result Detector::getExptimeLeft(Positions pos) const { - return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::ACQUISITION_TIME); + return pimpl->Parallel(&slsDetector::getTimeLeft, pos, + defs::ACQUISITION_TIME); } Result Detector::getPeriodLeft(Positions pos) const { @@ -440,11 +439,13 @@ Result Detector::getPeriodLeft(Positions pos) const { } Result Detector::getDelayAfterTriggerLeft(Positions pos) const { - return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::DELAY_AFTER_TRIGGER); + return pimpl->Parallel(&slsDetector::getTimeLeft, pos, + defs::DELAY_AFTER_TRIGGER); } Result Detector::getNumberOfFramesFromStart(Positions pos) const { - return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::FRAMES_FROM_START); + return pimpl->Parallel(&slsDetector::getTimeLeft, pos, + defs::FRAMES_FROM_START); } Result Detector::getActualTime(Positions pos) const { @@ -452,15 +453,18 @@ Result Detector::getActualTime(Positions pos) const { } Result Detector::getMeasurementTime(Positions pos) const { - return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::MEASUREMENT_TIME); + return pimpl->Parallel(&slsDetector::getTimeLeft, pos, + defs::MEASUREMENT_TIME); } Result Detector::getMeasuredPeriod(Positions pos) const { - return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::MEASURED_PERIOD); + return pimpl->Parallel(&slsDetector::getTimeLeft, pos, + defs::MEASURED_PERIOD); }; Result Detector::getMeasuredSubFramePeriod(Positions pos) const { - return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::MEASURED_SUBPERIOD); + return pimpl->Parallel(&slsDetector::getTimeLeft, pos, + defs::MEASURED_SUBPERIOD); }; // Erik @@ -929,4 +933,43 @@ Result Detector::getAdditionalJsonHeader(Positions pos) const { return pimpl->Parallel(&slsDetector::getAdditionalJsonHeader, pos); } +Result Detector::getAdditionalJsonParameter(const std::string &key, + Positions pos) const { + return pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos, key); +} + +void Detector::setAdditionalJsonParameter(const std::string &key, + const std::string &value, + Positions pos) { + pimpl->Parallel(&slsDetector::setAdditionalJsonParameter, pos, key, value); +} + +Result Detector::getReceiverStreamingIP(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverStreamingIP, pos); +} + +void Detector::setReceiverDataStreamingOutIP(const std::string &ip, + Positions pos) { + // TODO! probably in one call + pimpl->Parallel(&slsDetector::setReceiverStreamingIP, pos, ip); + pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, 0); + pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, 1); +} + +Result Detector::getClientStreamingIP(Positions pos) const { + return pimpl->Parallel(&slsDetector::getClientStreamingIP, pos); +} + +void Detector::setClientDataStreamingInIP(const std::string &ip, + Positions pos) { + // TODO! probably in one call + pimpl->Parallel(&slsDetector::setClientStreamingIP, pos, ip); + pimpl->enableDataStreamingToClient(0); + pimpl->enableDataStreamingToClient(1); +} + +Result Detector::getReceiverStreamingPort(Positions pos) const{ + return pimpl->Parallel(&slsDetector::getReceiverStreamingPort, pos); +} + } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 843fb1f41..7b1f4c2c3 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -660,7 +660,7 @@ std::string multiSlsDetector::getDetectorTypeAsString(int detPos) { return sls::concatenateIfDifferent(r); } -int multiSlsDetector::size() const { return detectors.size(); } +size_t multiSlsDetector::size() const { return detectors.size(); } int multiSlsDetector::getNumberOfDetectors(dimension d) const { return multi_shm()->numberOfDetector[d]; @@ -1946,6 +1946,7 @@ void multiSlsDetector::setReceiverDataStreamingOutIP(const std::string &ip, } } + std::string multiSlsDetector::getReceiverStreamingIP(int detPos) { // single if (detPos >= 0) { From 56703c48867089c3045c3c40781b754ac4c1b519 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 9 Aug 2019 15:20:53 +0200 Subject: [PATCH 2/4] WIP --- slsDetectorSoftware/include/Detector.h | 35 ++++++- .../include/multiSlsDetector.h | 20 ++-- slsDetectorSoftware/src/Detector.cpp | 93 ++++++++++++++++--- 3 files changed, 122 insertions(+), 26 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 88bf5162f..beed21c63 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -854,7 +854,7 @@ class Detector { // TODO! // int enableDataStreamingToClient(int enable = -1); - // int enableDataStreamingFromReceiver(int enable = -1, int detPos = -1) + void enableDataStreamingFromReceiver(bool enable, Positions pos = {}); /** [TODO! All?] */ void setTenGigaEnabled(bool value, Positions pos = {}); @@ -1257,7 +1257,38 @@ class Detector { Result getReceiverStreamingPort(Positions pos = {}) const; - // void setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); + /** Single detector or all since ports are calculated*/ + void setReceiverDataStreamingOutPort(int port, int module_id = -1); + + Result getClientStreamingPort(Positions pos = {}) const; + + /** Single detector or all since ports are calculated*/ + void setClientDataStreamingInPort(int port, int module_id = -1); + + /** [Jungfrau] */ + Result getSelectedUDPInterface(Positions pos = {}) const; + + /** + * [Jungfrau] + * @param interface interface to select, either 1 or 2 + * */ + void selectUDPInterface(int interface, Positions pos = {}); + + Result getNumberofUDPInterfaces(Positions pos = {}) const; + + void setNumberofUDPInterfaces(int n, Positions pos = {}); + + /** [Eiger][Jungfrau] */ + Result getReceiverUDPPort2(Positions pos = {}) const; + + /** [Eiger][Jungfrau] */ + void setReceiverUDPPort2(int udpport, Positions pos = {}); + + /** [Eiger][Jungfrau] */ + Result getReceiverUDPPort(Positions pos = {}) const; + + /** [Eiger][Jungfrau] */ + void setReceiverUDPPort(int udpport, Positions pos = {}); }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index a74ba2862..73195e606 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -1120,14 +1120,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP port */ - int setReceiverUDPPort(int udpport, int detPos = -1); + int setReceiverUDPPort(int udpport, int detPos = -1); // /** * Returns the receiver UDP port * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP port */ - int getReceiverUDPPort(int detPos = -1) const; + int getReceiverUDPPort(int detPos = -1) const; // /** * Sets the receiver UDP port 2 (Eiger and Jungfrau only) @@ -1135,7 +1135,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP port 2 */ - int setReceiverUDPPort2(int udpport, int detPos = -1); + int setReceiverUDPPort2(int udpport, int detPos = -1); // /** * Returns the receiver UDP port 2 of same interface (Eiger and Jungfrau @@ -1143,7 +1143,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP port 2 of same interface */ - int getReceiverUDPPort2(int detPos = -1) const; + int getReceiverUDPPort2(int detPos = -1) const; // /** * Sets the number of UDP interfaces to stream data from detector (Jungfrau @@ -1152,7 +1152,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the number of interfaces */ - int setNumberofUDPInterfaces(int n, int detPos = -1); + int setNumberofUDPInterfaces(int n, int detPos = -1); // /** * Returns the number of UDP interfaces to stream data from detector @@ -1160,7 +1160,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the number of interfaces */ - int getNumberofUDPInterfaces(int detPos = -1) const; + int getNumberofUDPInterfaces(int detPos = -1) const; // /** * Selects the UDP interfaces to stream data from detector. Effective only @@ -1177,7 +1177,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the interface selected */ - int getSelectedUDPInterface(int detPos = -1) const; + int getSelectedUDPInterface(int detPos = -1) const; // /** * (advanced users) @@ -1196,7 +1196,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the client zmq port */ - int getClientStreamingPort(int detPos = -1); + int getClientStreamingPort(int detPos = -1); // /** * (advanced users) @@ -1206,7 +1206,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * individual detectors using i * @param detPos -1 for all detectors in list or specific detector position */ - void setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); + void setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); // /** * Returns the receiver zmq port @@ -1215,7 +1215,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver zmq port */ - int getReceiverStreamingPort(int detPos = -1); + int getReceiverStreamingPort(int detPos = -1); // /** * (advanced users) diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 80e6f40d7..9825a9a14 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -468,7 +468,8 @@ Result Detector::getMeasuredSubFramePeriod(Positions pos) const { } Result Detector::getSpeed(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1, + 0); } void Detector::setSpeed(int value, Positions pos) { @@ -476,7 +477,8 @@ void Detector::setSpeed(int value, Positions pos) { } Result Detector::getADCPhase(bool inDeg, Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, -1, inDeg); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, -1, + inDeg); } void Detector::setADCPhase(int value, bool inDeg, Positions pos) { @@ -484,19 +486,23 @@ void Detector::setADCPhase(int value, bool inDeg, Positions pos) { } Result Detector::getMaxADCPhaseShift(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::MAX_ADC_PHASE_SHIFT, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, + defs::MAX_ADC_PHASE_SHIFT, -1, 0); } Result Detector::getDBITPhase(bool inDeg, Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, -1, inDeg); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, -1, + inDeg); } void Detector::setDBITPhase(int value, bool inDeg, Positions pos) { - pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, value, inDeg); + pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, value, + inDeg); } Result Detector::getMaxDBITPhaseShift(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::MAX_DBIT_PHASE_SHIFT, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, + defs::MAX_DBIT_PHASE_SHIFT, -1, 0); } Result Detector::getADCClock(Positions pos) const { @@ -508,7 +514,8 @@ void Detector::setADCClock(int value, Positions pos) { } Result Detector::getDBITClock(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_CLOCK, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_CLOCK, -1, + 0); } void Detector::setDBITClock(int value, Positions pos) { @@ -516,7 +523,8 @@ void Detector::setDBITClock(int value, Positions pos) { } Result Detector::getRUNClock(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1, + 0); } void Detector::setRUNClock(int value, Positions pos) { @@ -524,11 +532,13 @@ void Detector::setRUNClock(int value, Positions pos) { } Result Detector::getSYNCClock(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::SYNC_CLOCK, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::SYNC_CLOCK, -1, + 0); } Result Detector::getADCPipeline(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PIPELINE, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PIPELINE, -1, + 0); } void Detector::setADCPipeline(int value, Positions pos) { @@ -536,7 +546,8 @@ void Detector::setADCPipeline(int value, Positions pos) { } Result Detector::getDBITPipeline(Positions pos) const { - return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, -1, 0); + return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, -1, + 0); } void Detector::setDBITPipeline(int value, Positions pos) { @@ -572,6 +583,11 @@ Result Detector::getReceiverStreamingTimer(Positions pos) const { return pimpl->Parallel(&slsDetector::setReceiverStreamingTimer, pos, -1); } +void Detector::enableDataStreamingFromReceiver(bool enable, Positions pos) { + pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, + static_cast(enable)); +} + void Detector::setTenGigaEnabled(bool value, Positions pos) { pimpl->Parallel(&slsDetector::enableTenGigabitEthernet, pos, static_cast(value)); @@ -1028,8 +1044,8 @@ void Detector::setReceiverDataStreamingOutIP(const std::string &ip, Positions pos) { // TODO! probably in one call pimpl->Parallel(&slsDetector::setReceiverStreamingIP, pos, ip); - pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, 0); - pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, 1); + enableDataStreamingFromReceiver(false, pos); + enableDataStreamingFromReceiver(true, pos); } Result Detector::getClientStreamingIP(Positions pos) const { @@ -1044,8 +1060,57 @@ void Detector::setClientDataStreamingInIP(const std::string &ip, pimpl->enableDataStreamingToClient(1); } -Result Detector::getReceiverStreamingPort(Positions pos) const{ +Result Detector::getReceiverStreamingPort(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverStreamingPort, pos); } +void Detector::setReceiverDataStreamingOutPort(int port, int module_id) { + pimpl->setReceiverDataStreamingOutPort(port, module_id); +} + +Result Detector::getClientStreamingPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getClientStreamingPort, pos); +} + +void Detector::setClientDataStreamingInPort(int port, int module_id) { + pimpl->setClientDataStreamingInPort(port, module_id); +} + +Result Detector::getSelectedUDPInterface(Positions pos) const { + return pimpl->Parallel(&slsDetector::getSelectedUDPInterface, pos); +} + +void Detector::selectUDPInterface(int interface, Positions pos) { + pimpl->Parallel(&slsDetector::selectUDPInterface, pos, interface); +} + +Result Detector::getNumberofUDPInterfaces(Positions pos) const { + return pimpl->Parallel(&slsDetector::getNumberofUDPInterfaces, pos); +} + +void Detector::setNumberofUDPInterfaces(int n, Positions pos) { + pimpl->Parallel(&slsDetector::setNumberofUDPInterfaces, pos, n); + + pimpl->enableDataStreamingToClient(0); + pimpl->enableDataStreamingToClient(1); + enableDataStreamingFromReceiver(false, pos); + enableDataStreamingFromReceiver(true, pos); +} + +Result Detector::getReceiverUDPPort2(Positions pos) const{ + pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); +} + +void Detector::setReceiverUDPPort2(int udpport, Positions pos){ + pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); +} + +Result Detector::getReceiverUDPPort(Positions pos) const{ + pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); +} + +void Detector::setReceiverUDPPort(int udpport, Positions pos){ + pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); +} + } // namespace sls \ No newline at end of file From 206740efd6fc3c96fc09362b31c7f19816a57909 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 9 Aug 2019 15:35:33 +0200 Subject: [PATCH 3/4] WIP --- slsDetectorSoftware/include/Detector.h | 9 +++++++-- slsDetectorSoftware/src/Detector.cpp | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index beed21c63..01210f044 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -8,8 +8,7 @@ class multiSlsDetector; namespace sls { using ns = std::chrono::nanoseconds; -using Positions = const std::vector &; -using defs = slsDetectorDefs; +class MacAddr; /** * \class Detector @@ -1289,6 +1288,12 @@ class Detector { /** [Eiger][Jungfrau] */ void setReceiverUDPPort(int udpport, Positions pos = {}); + + /** [Jungfrau] */ + Result getReceiverUDPMAC2(Positions pos = {}) const; + + /** [Jungfrau] */ + void setReceiverUDPMAC2(const std::string &udpmac, Positions pos = {}); }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 9825a9a14..b8de96c73 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1113,4 +1113,11 @@ void Detector::setReceiverUDPPort(int udpport, Positions pos){ pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); } +Result Detector::getReceiverUDPMAC2(Positions pos) const{ + return pimpl->Parallel(&slsDetector::getReceiverUDPMAC2, pos); +} + +void Detector::setReceiverUDPMAC2(const std::string &udpmac, Positions pos){ + pimpl->Parallel(&slsDetector::setReceiverUDPMAC2, pos, udpmac); +} } // namespace sls \ No newline at end of file From dea402a7e718fe8055362f860b483eacd7f87842 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 9 Aug 2019 16:12:26 +0200 Subject: [PATCH 4/4] WIP --- slsDetectorSoftware/include/Detector.h | 44 +++++++++- .../include/multiSlsDetector.h | 32 ++++---- slsDetectorSoftware/src/Detector.cpp | 81 ++++++++++++++++--- 3 files changed, 130 insertions(+), 27 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 01210f044..1c2b92da9 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -9,6 +9,7 @@ class multiSlsDetector; namespace sls { using ns = std::chrono::nanoseconds; class MacAddr; +class IpAddr; /** * \class Detector @@ -1274,7 +1275,6 @@ class Detector { void selectUDPInterface(int interface, Positions pos = {}); Result getNumberofUDPInterfaces(Positions pos = {}) const; - void setNumberofUDPInterfaces(int n, Positions pos = {}); /** [Eiger][Jungfrau] */ @@ -1292,8 +1292,48 @@ class Detector { /** [Jungfrau] */ Result getReceiverUDPMAC2(Positions pos = {}) const; - /** [Jungfrau] */ + /** [Jungfrau] */ void setReceiverUDPMAC2(const std::string &udpmac, Positions pos = {}); + + Result getReceiverUDPMAC(Positions pos = {}) const; + void setReceiverUDPMAC(const std::string &udpmac, Positions pos = {}); + + /** [Jungfrau] */ + Result getReceiverUDPIP2(Positions pos = {}) const; + + /** [Jungfrau] */ + void setReceiverUDPIP2(const std::string &udpip, Positions pos = {}); + + Result getReceiverUDPIP(Positions pos = {}) const; + void setReceiverUDPIP(const std::string &udpip, Positions pos = {}); + + Result getReceiverHostname(Positions pos = {}) const; + + /** + * Validates and sets the receiver. + * Also updates the receiver with all the shared memory parameters + * significant for the receiver Also configures the detector to the receiver + * as UDP destination + * @param receiver receiver hostname or IP address */ + void setReceiverHostname(const std::string &receiver, Positions pos = {}); + + /** [Jungfrau] */ + Result getDetectorIP2(Positions pos = {}) const; + + /** [Jungfrau] */ + void setDetectorIP2(const std::string &detectorIP, Positions pos = {}); + + Result getDetectorIP(Positions pos = {}) const; + void setDetectorIP(const std::string &detectorIP, Positions pos = {}); + + Result getDetectorMAC(Positions pos = {}) const; + void setDetectorMAC(const std::string &detectorMAC, Positions pos = {}); + + /** [Jungfrau] */ + Result getDetectorMAC2(Positions pos = {}) const; + + /** [Jungfrau] */ + void setDetectorMAC2(const std::string &detectorMAC, Positions pos = {}); }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 73195e606..14cd4b1f8 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -976,14 +976,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the detector MAC address */ - std::string setDetectorMAC(const std::string &detectorMAC, int detPos = -1); + std::string setDetectorMAC(const std::string &detectorMAC, int detPos = -1); // /** * Returns the detector MAC address * @param detPos -1 for all detectors in list or specific detector position * @returns the detector MAC address */ - std::string getDetectorMAC(int detPos = -1); + std::string getDetectorMAC(int detPos = -1); // /** * Validates the format of the detector MAC address (bottom half) and sets @@ -993,14 +993,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @returns the detector MAC address (bottom half) */ std::string setDetectorMAC2(const std::string &detectorMAC, - int detPos = -1); + int detPos = -1); // /** * Returns the detector MAC address (bottom half) Jungfrau only * @param detPos -1 for all detectors in list or specific detector position * @returns the detector MAC address (bottom half) */ - std::string getDetectorMAC2(int detPos = -1); + std::string getDetectorMAC2(int detPos = -1); // /** * Validates the format of the detector IP address and sets it @@ -1008,14 +1008,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the detector IP address */ - std::string setDetectorIP(const std::string &detectorIP, int detPos = -1); + std::string setDetectorIP(const std::string &detectorIP, int detPos = -1); // /** * Returns the detector IP address * @param detPos -1 for all detectors in list or specific detector position * @returns the detector IP address */ - std::string getDetectorIP(int detPos = -1) const; + std::string getDetectorIP(int detPos = -1) const; // /** * Validates the format of the detector IP address (bottom half) and sets it @@ -1024,14 +1024,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the detector IP address (bottom half) */ - std::string setDetectorIP2(const std::string &detectorIP, int detPos = -1); + std::string setDetectorIP2(const std::string &detectorIP, int detPos = -1); // /** * Returns the detector IP address (bottom half) Jungfrau only * @param detPos -1 for all detectors in list or specific detector position * @returns the detector IP address (bottom half) */ - std::string getDetectorIP2(int detPos = -1) const; + std::string getDetectorIP2(int detPos = -1) const; // /** * Validates and sets the receiver. @@ -1043,14 +1043,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @returns the receiver IP address from shared memory */ std::string setReceiverHostname(const std::string &receiver, - int detPos = -1); + int detPos = -1); // /** * Returns the receiver IP address * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver IP address */ - std::string getReceiverHostname(int detPos = -1) const; + std::string getReceiverHostname(int detPos = -1) const; // /** * Validates the format of the receiver UDP IP address and sets it @@ -1058,14 +1058,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP IP address */ - std::string setReceiverUDPIP(const std::string &udpip, int detPos = -1); + std::string setReceiverUDPIP(const std::string &udpip, int detPos = -1); // /** * Returns the receiver UDP IP address * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP IP address */ - std::string getReceiverUDPIP(int detPos = -1) const; + std::string getReceiverUDPIP(int detPos = -1) const; // /** * Validates the format of the receiver UDP IP address (bottom half) and @@ -1074,14 +1074,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP IP address (bottom half) */ - std::string setReceiverUDPIP2(const std::string &udpip, int detPos = -1); + std::string setReceiverUDPIP2(const std::string &udpip, int detPos = -1); // /** * Returns the receiver UDP IP address (bottom half) Jungfrau only * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP IP address (bottom half) */ - std::string getReceiverUDPIP2(int detPos = -1) const; + std::string getReceiverUDPIP2(int detPos = -1) const; // /** * Validates the format of the receiver UDP MAC address and sets it @@ -1089,14 +1089,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP MAC address */ - std::string setReceiverUDPMAC(const std::string &udpmac, int detPos = -1); + std::string setReceiverUDPMAC(const std::string &udpmac, int detPos = -1);// /** * Returns the receiver UDP MAC address * @param detPos -1 for all detectors in list or specific detector position * @returns the receiver UDP MAC address */ - std::string getReceiverUDPMAC(int detPos = -1) const; + std::string getReceiverUDPMAC(int detPos = -1) const; // /** * Validates the format of the receiver UDP MAC address (bottom half) and diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index b8de96c73..ceea070c4 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1097,27 +1097,90 @@ void Detector::setNumberofUDPInterfaces(int n, Positions pos) { enableDataStreamingFromReceiver(true, pos); } -Result Detector::getReceiverUDPPort2(Positions pos) const{ - pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); +Result Detector::getReceiverUDPPort2(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); } -void Detector::setReceiverUDPPort2(int udpport, Positions pos){ +void Detector::setReceiverUDPPort2(int udpport, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); } -Result Detector::getReceiverUDPPort(Positions pos) const{ - pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); +Result Detector::getReceiverUDPPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPPort, pos); } -void Detector::setReceiverUDPPort(int udpport, Positions pos){ - pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); +void Detector::setReceiverUDPPort(int udpport, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPPort, pos, udpport); } -Result Detector::getReceiverUDPMAC2(Positions pos) const{ +Result Detector::getReceiverUDPMAC2(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverUDPMAC2, pos); } -void Detector::setReceiverUDPMAC2(const std::string &udpmac, Positions pos){ +void Detector::setReceiverUDPMAC2(const std::string &udpmac, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverUDPMAC2, pos, udpmac); } + +Result Detector::getReceiverUDPMAC(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPMAC, pos); +} + +void Detector::setReceiverUDPMAC(const std::string &udpmac, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPMAC, pos, udpmac); +} + +Result Detector::getReceiverUDPIP2(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPIP2, pos); +} + +void Detector::setReceiverUDPIP2(const std::string &udpip, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPIP2, pos, udpip); +} + +Result Detector::getReceiverUDPIP(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPIP, pos); +} + +void Detector::setReceiverUDPIP(const std::string &udpip, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPIP, pos, udpip); +} + +Result Detector::getReceiverHostname(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverHostname, pos); +} + +void Detector::setReceiverHostname(const std::string &receiver, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverHostname, pos, receiver); +} + +Result Detector::getDetectorIP2(Positions pos) const{ + return pimpl->Parallel(&slsDetector::getDetectorIP2, pos); +} + +void Detector::setDetectorIP2(const std::string &detectorIP, Positions pos){ + pimpl->Parallel(&slsDetector::setDetectorIP2, pos, detectorIP); +} + +Result Detector::getDetectorIP(Positions pos) const{ + return pimpl->Parallel(&slsDetector::getDetectorIP, pos); +} + +void Detector::setDetectorIP(const std::string &detectorIP, Positions pos){ + pimpl->Parallel(&slsDetector::setDetectorIP, pos, detectorIP); +} + +Result Detector::getDetectorMAC(Positions pos) const{ + return pimpl->Parallel(&slsDetector::getDetectorMAC, pos); +} +void Detector::setDetectorMAC(const std::string &detectorMAC, Positions pos){ + pimpl->Parallel(&slsDetector::setDetectorMAC, pos, detectorMAC); +} + +Result Detector::getDetectorMAC2(Positions pos) const{ + return pimpl->Parallel(&slsDetector::getDetectorMAC2, pos); +} +void Detector::setDetectorMAC2(const std::string &detectorMAC, Positions pos){ + pimpl->Parallel(&slsDetector::setDetectorMAC2, pos, detectorMAC); +} + } // namespace sls \ No newline at end of file