diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 4a52610d6..3483ca37f 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -65,25 +65,9 @@ class Detector { // Bits and registers - /** - * Clears (sets to 0) bit number bitnr in register at addr. - * @param addr address of the register - * @param bitnr bit number to clear - * @param pos detector position - */ - void clearBit(uint32_t addr, int bitnr, Positions pos = {}); - - /** - * Sets bit number bitnr in register at addr to 1 - * @param addr address of the register - * @param bitnr bit number to clear - * @param pos detector position - */ - void setBit(uint32_t addr, int bitnr, Positions pos = {}); - Result readRegister(uint32_t addr, Positions pos = {}) const; - void writeRegister(uint32_t addr, uint32_t val, Positions pos = {}); + /************************************************** * * @@ -955,6 +939,273 @@ class Detector { // Erik + /** [Eiger] */ + Result getInterruptSubframe(Positions pos = {}) const; + + /** [Eiger] when set, the last subframe is interrupted at end of acq */ + void setInterruptSubframe(const bool enable, Positions pos = {}); + + Result readRegister(uint32_t addr, Positions pos = {}) const; + + void writeRegister(uint32_t addr, uint32_t val, Positions pos = {}); + + void setBit(uint32_t addr, int bitnr, Positions pos = {}); + + void clearBit(uint32_t addr, int bitnr, Positions pos = {}); + + Result getDetectorMAC(Positions pos = {}) const; + + void setDetectorMAC(const std::string &detectorMAC, Positions pos = {}); + + /** [Jungfrau] bottom half */ + Result getDetectorMAC2(Positions pos = {}) const; + + /** [Jungfrau] bottom half */ + void setDetectorMAC2(const std::string &detectorMAC, Positions pos = {}); + + Result getDetectorIP(Positions pos = {}) const; + + void setDetectorIP(const std::string &detectorIP, Positions pos = {}); + + /** [Jungfrau] bottom half */ + Result getDetectorIP2(Positions pos = {}) const; + + /** [Jungfrau] bottom half */ + void setDetectorIP2(const std::string &detectorIP, Positions pos = {}); + + Result getReceiverHostname(Positions pos = {}) const; + + /** + * Validates and sets the receiver. + * Updates local receiver cache parameters + * Configures the detector to the receiver as UDP destination + * @param receiver receiver hostname or IP address + */ + void setReceiverHostname(const std::string &receiver, Positions pos = {}); + + Result getReceiverUDPIP(Positions pos = {}) const; + void setReceiverUDPIP(const std::string &udpip, Positions pos = {}); + + /** [Jungfrau bottom half] */ + Result getReceiverUDPIP2(Positions pos = {}) const; + + /** [Jungfrau bottom half] */ + void setReceiverUDPIP2(const std::string &udpip, Positions pos = {}); + + Result getReceiverUDPMAC(Positions pos = {}) const; + void setReceiverUDPMAC(const std::string &udpmac, Positions pos = {}); + + /** [Jungfrau bottom half] */ + Result getReceiverUDPMAC2(Positions pos = {}) const; + /** [Jungfrau bottom half] */ + void setReceiverUDPMAC2(const std::string &udpmac, Positions pos = {}); + + Result getReceiverUDPPort(Positions pos = {}) const; + void setReceiverUDPPort(int udpport, Positions pos = {}); + + /** [Eiger right port][Jungfrau bottom half] */ + Result getReceiverUDPPort2(Positions pos = {}) const; + /** [Eiger right port][Jungfrau bottom half] */ + void setReceiverUDPPort2(int udpport, Positions pos = {}); + + /** [Jungfrau] */ + Result getNumberofUDPInterfaces(Positions pos = {}) const; + /** [Jungfrau] Also restarts client and receiver sockets */ + void setNumberofUDPInterfaces(int n, Positions pos = {}); + + /** [Jungfrau] */ + Result getSelectedUDPInterface(Positions pos = {}) const; + /** + * [Jungfrau: + * Effective only when number of interfaces is 1. + * Options: 0 (outer, default), 1(inner)] + */ + void selectUDPInterface(int interface, Positions pos = {}); + + Result getClientStreamingPort(Positions pos = {}) const; + /** + * pos can be for a single module or all modules, not a subset + * If pos for all modules, ports for each module is calculated (increments) + * Restarts client zmq sockets + */ + void setClientDataStreamingInPort(int port, Positions pos = {}); + + Result getReceiverStreamingPort(Positions pos = {}) const; + /** + * pos can be for a single module or all modules, not a subset + * If pos for all modules, ports for each module is calculated (increments) + * Restarts receiver zmq sockets + */ + void setReceiverDataStreamingOutPort(int port, Positions pos = {}); + + Result getClientStreamingIP(Positions pos = {}) const; + // TODO these should probably be the same ?? same as what? + void setClientDataStreamingInIP(const std::string &ip, Positions pos = {}); + + Result getReceiverStreamingIP(Positions pos = {}) const; + void setReceiverDataStreamingOutIP(const std::string &ip, + Positions pos = {}); + + /** [Eiger, Jungfrau] */ + Result getFlowControl10G(Positions pos = {}) const; + /** [Eiger, Jungfrau] */ + void setFlowControl10G(bool enable, Positions pos = {}); + + /** [Eiger, Jungfrau] */ + Result getTransmissionDelayFrame(Positions pos = {}) const; + /** + * [Jungfrau: Sets the transmission delay of the first UDP packet being streamed out of the module + * Options: 0 - 31, each value represenets 1 ms ] + * [Eiger: Sets the transmission delay of entire frame streamed out for both left and right UDP ports] + */ + void setTransmissionDelayFrame(int value, Positions pos = {}); + + /** [Eiger] */ + Result getTransmissionDelayLeft(Positions pos = {}) const; + /** + * [Eiger] + * Sets the transmission delay of first packet streamed ut of the left UDP port + */ + void setTransmissionDelayLeft(int value, Positions pos = {}); + + /** [Eiger] */ + Result getTransmissionDelayRight(Positions pos = {}) const; + /** + * [Eiger] + * Sets the transmission delay of first packet streamed ut of the right UDP port + */ + void setTransmissionDelayRight(int value, Positions pos = {}); + + /** [Moench] */ + Result getAdditionalJsonHeader(Positions pos = {}) const; + /** [Moench] */ + void setAdditionalJsonHeader(const std::string &jsonheader, + Positions pos = {}); + + /** [Moench] */ + Result getAdditionalJsonParameter(const std::string &key, + Positions pos = {}) const; + /** + * [Moench] + * Sets the value for additional json header parameter if found, + * else appends the parameter key and value + * The value cannot be empty + */ + void setAdditionalJsonParameter(const std::string &key, + const std::string &value, + Positions pos = {}); + + /** [Moench] TODO! How do we do this best??? Can be refactored to something + * else? Use a generic zmq message passing system... + * For now limiting to all detectors working the same*/ + /** [Moench: -1 if not found or cannot convert to int] */ + Result getDetectorMinMaxEnergyThreshold(const bool isEmax, Positions pos = {}) const; + /** [Moench] */ + void setDetectorMinMaxEnergyThreshold(const bool isEmax, const int value, Positions pos = {}); + /** [Moench: -1 if unknown mode] */ + Result getFrameMode(Positions pos = {}) const; + /** [Moench] */ + void setFrameMode(defs::frameModeType value, Positions pos = {}); + /** [Moench: -1 if unknown mode] */ + Result getDetectorMode(Positions pos = {}) const; + /** [Moench] */ + void setDetectorMode(defs::detectorModeType value, Positions pos = {}); + + /** [Gotthard] */ + Result getDigitalTestBit(Positions pos = {}); + /** [Gotthard] */ + Result setDigitalTestBit(const int value, Positions pos = {}); + /** [Gotthard, Jungfrau, CTB] */ + Result executeFirmwareTest(Positions pos = {}); + /** [Gotthard, Jungfrau, CTB] */ + Result executeBusTest(Positions pos = {}); + /** [Gotthard] subset modules not allowed */ + void loadDarkImage(const std::string &fname, Positions pos = {}); + /** [Gotthard] subset modules not allowed */ + void loadGainImage(const std::string &fname, Positions pos = {}); + /** + * [Gotthard] subset modules not allowed + * @param startACQ if start acq after reading counter + */ + void getCounterMemoryBlock(const std::string &fname, bool startACQ, Positions pos = {}); + /** + * [Gotthard] + * @param startACQ if start acq after resetting counter + * TODO! does it make sense to call one detector? + */ + void resetCounterBlock(bool startACQ, Positions pos = {}); + + /** [Eiger] */ + Result getCounterBit(Positions pos = {}) const; + /** [Eiger] If it is set, it resets chips completely (else partially) before an acquisition TODO: if it makes sense */ + void setCounterBit(bool value, Positions pos = {}); + + /** [Gotthard, CTB] subset modules not allowed */ + Result> getROI(Positions pos = {}) const; + /** + * [Gotthard Options: Only a single chip or all chips, only 1 ROI allowed] + * [CTB: multiple ROIs allowed] + * subset modules not allowed + */ + void setROI(std::vector value, Positions pos = {}); + + /** [CTB]*/ + Result getADCEnableMask(Positions pos = {}) const; + + /** [CTB]*/ + void setADCEnableMask(uint32_t mask, Positions pos = {}); + + /** [CTB] */ + Result getADCInvert(Positions pos = {}) const; + + /** [CTB]*/ + void setADCInvert(uint32_t value, Positions pos = {}); + + /** [CTB] */ + Result getExternalSamplingSource(Positions pos = {}) const; + + /** [CTB] Value between 0-63 */ + void setExternalSamplingSource(int value, Positions pos = {}); + + /** [CTB] */ + Result getExternalSampling(Positions pos = {}) const; + + /** [CTB] */ + void setExternalSampling(bool value, Positions pos = {}); + + /** [CTB] */ + Result> getReceiverDbitList(Positions pos = {}) const; + + /** [CTB] list contains the set of bits (0-63) to save */ + void setReceiverDbitList(std::vector list, Positions pos = {}); + + /** [CTB] */ + Result getReceiverDbitOffset(Positions pos = {}) const; + + /** [CTB] Set number of bytes of digital data to skip in the Receiver */ + void setReceiverDbitOffset(int value, Positions pos = {}); + + /** [Gotthard][Jungfrau][CTB] not possible to read back*/ + void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {}); + + + + + + + + Result getReceiverUDPSocketBufferSize(Positions pos = {}) const; + void setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, + Positions pos = {}); + Result + getReceiverRealUDPSocketBufferSize(Positions pos = {}) const; + + + + + + + Result getFramesCaughtByReceiver(Positions pos = {}) const; Result getReceiverCurrentFrameIndex(Positions pos = {}) const; @@ -979,9 +1230,11 @@ class Detector { /** [All] */ Result getReceiverStreamingTimer(Positions pos = {}) const; - // TODO! - // int enableDataStreamingToClient(int enable = -1); - void enableDataStreamingFromReceiver(bool enable, Positions pos = {}); + bool getDataStreamingToClient() const; + void setDataStreamingToClient(bool value); + + Result getDataStreamingFromReceiver(Positions pos = {}) const; + void setDataStreamingFromReceiver(bool value, Positions pos = {}); /** [TODO! All?] */ void setTenGigaEnabled(bool value, Positions pos = {}); @@ -1272,203 +1525,8 @@ class Detector { Result getActive(Positions pos = {}) const; - /** [Gotthard][Jungfrau][CTB] not possible to read back*/ - void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {}); - /** [CTB] How much digital data in bytes is skipped */ - Result getReceiverDbitOffset(Positions pos = {}) const; - - /** [CTB] Set how many bytes of digital data to skip */ - void setReceiverDbitOffset(int value, Positions pos = {}); - - /** [CTB] Which of the bits 0-63 to save*/ - Result> getReceiverDbitList(Positions pos = {}) const; - - /** [CTB] Which of the bits 0-63 to save*/ - void setReceiverDbitList(std::vector list, Positions pos = {}); - - /** [CTB] */ - Result getExternalSampling(Positions pos = {}) const; - - /** [CTB] */ - void setExternalSampling(bool value, Positions pos = {}); - - /** [CTB] */ - Result getExternalSamplingSource(Positions pos = {}) const; - - /** [CTB] Value between 0-63 */ - void setExternalSamplingSource(int value, Positions pos = {}); - - // TODO! does any of them need the option to take positions - /** [CTB] */ - uint32_t getADCInvert() const; - - /** [CTB]*/ - void setADCInvert(uint32_t value); - - /** [CTB]*/ - uint32_t getADCEnableMask() const; - - /** [CTB]*/ - void setADCEnableMask(uint32_t mask); - - /** [Gotthard] */ - Result getCounterBit(Positions pos = {}) const; - - /** [Gotthard] possible values? */ - void setCounterBit(int i, Positions pos = {}); - - /** - * [Gotthard] startACQ = 1 to start acq after resetting counter - * TODO! does it make sense to call one detector? - * - */ - void resetCounterBlock(int startACQ = 0, Positions pos = {}); - - // TODO getROI, setROI, verifyMinMaxROI - - // writeCounterBlockFile - - void loadImageToDetector(defs::imageType index, const std::string &fname, - Positions pos = {}); - - /** [Gotthard] - * @param value 1 to set or 0 to clear the digital test bit -1? - */ - Result digitalTest(defs::digitalTestMode mode, int ival = -1, - Positions pos = {}); - - /** [Eiger] */ - void setFlowControl10G(bool enable, Positions pos = {}); - - /** [Eiger] */ - Result getFlowControl10G(Positions pos = {}) const; - - Result - getReceiverRealUDPSocketBufferSize(Positions pos = {}) const; - - Result getReceiverUDPSocketBufferSize(Positions pos = {}) const; - - void setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, - Positions pos = {}); - - /** [Moench] TODO! How do we do this best??? Can be refactored to something - * else? Use a generic zmq message passing system... - * For now limiting to all detectors working the same*/ - int setDetectorMode(defs::detectorModeType value); - int setFrameMode(defs::frameModeType value); - int setDetectorMinMaxEnergyThreshold(const int index, int value); - - void setAdditionalJsonHeader(const std::string &jsonheader, - 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; - - /** 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 = {}); - - /** [Jungfrau] */ - Result getReceiverUDPMAC2(Positions pos = {}) const; - - /** [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 = {}); - - /** [Eiger] */ - Result getInterruptSubframe(Positions pos = {}) const; - - /** [Eiger] when set the last subframe is interrupted at end of acq*/ - void setInterruptSubframe(const bool enable, Positions pos = {}); + }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index b209f1d2b..fb7395a2c 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -1387,7 +1387,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { void resetCounterBlock(int startACQ = 0, int detPos = -1); // /** - * Set/get counter bit in detector (Gotthard) + * Set/get counter bit in detector (Eiger) * @param i is -1 to get, 0 to reset and any other value to set the counter * bit * @param detPos -1 for all detectors in list or specific detector position @@ -1395,13 +1395,6 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ int setCounterBit(int i = -1, int detPos = -1); // - /** - * Ensures that min is less than max in both dimensions (Gotthard) - * @param n number of rois - * @param r array of rois - */ - void verifyMinMaxROI(int n, ROI r[]); - /** * Set ROI (Gotthard) * At the moment only one set allowed @@ -1976,7 +1969,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param enable 0 to disable, 1 to enable, -1 to get the value * @returns data streaming to client enable */ - int enableDataStreamingToClient(int enable = -1); + bool enableDataStreamingToClient(int enable = -1); /** * Enable or disable streaming data from receiver to client @@ -2283,6 +2276,13 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ void addSlsDetector(const std::string &hostname); + /** + * Ensures that min is less than max in both dimensions (Gotthard) + * @param n number of rois + * @param r array of rois + */ + void verifyMinMaxROI(int n, ROI r[]); + /** * add gap pixels to the image (only for Eiger in 4 bit mode) * @param image pointer to image without gap pixels diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 316ebf718..61e276d89 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -41,19 +41,9 @@ void Detector::setConfig(const std::string &fname) { pimpl->readConfigurationFile(fname); } -void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) { - pimpl->Parallel(&slsDetector::clearBit, pos, addr, bitnr); -} -void Detector::setBit(uint32_t addr, int bitnr, Positions pos) { - pimpl->Parallel(&slsDetector::setBit, pos, addr, bitnr); -} -void Detector::writeRegister(uint32_t addr, uint32_t val, Positions pos) { - pimpl->Parallel(&slsDetector::writeRegister, pos, addr, val); -} -Result Detector::readRegister(uint32_t addr, Positions pos) const { - return pimpl->Parallel(&slsDetector::readRegister, pos, addr); -} + + Result Detector::getStartingFrameNumber(Positions pos) const { return pimpl->Parallel(&slsDetector::getStartingFrameNumber, pos); @@ -156,7 +146,7 @@ defs::coordinates Detector::getNumberOfDetectors() const { } Result Detector::getNumberOfChannels(Positions pos) const { - if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { + if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) {// TODO: also check condition that pos.size == pimpl->size()?? for other occurences as well return {pimpl->getNumberOfChannels()}; } return pimpl->Parallel(&slsDetector::getNumberOfChannels, pos); @@ -775,6 +765,470 @@ void Detector::setDAC(int value, defs::dacIndex index, bool mV, Positions pos) { } // Erik +Result Detector::getInterruptSubframe(Positions pos) const { + return pimpl->Parallel(&slsDetector::getInterruptSubframe, pos); +} + +void Detector::setInterruptSubframe(const bool enable, Positions pos){ + pimpl->Parallel(&slsDetector::setInterruptSubframe, pos, enable); +} + +void Detector::writeRegister(uint32_t addr, uint32_t val, Positions pos) { + pimpl->Parallel(&slsDetector::writeRegister, pos, addr, val); +} + +Result Detector::readRegister(uint32_t addr, Positions pos) const { + return pimpl->Parallel(&slsDetector::readRegister, pos, addr); +} + +void Detector::setBit(uint32_t addr, int bitnr, Positions pos) { + pimpl->Parallel(&slsDetector::setBit, pos, addr, bitnr); +} + +void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) { + pimpl->Parallel(&slsDetector::clearBit, pos, addr, bitnr); +} + +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); +} + +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::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::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::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::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::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::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); +} + +Result Detector::getReceiverUDPPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPPort, pos); +} + +void Detector::setReceiverUDPPort(int udpport, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPPort, pos, udpport); +} + +Result Detector::getReceiverUDPPort2(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); +} + +void Detector::setReceiverUDPPort2(int udpport, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); +} + +Result Detector::getNumberofUDPInterfaces(Positions pos) const { + return pimpl->Parallel(&slsDetector::getNumberofUDPInterfaces, pos); +} + +void Detector::setNumberofUDPInterfaces(int n, Positions pos) { + bool previouslyClientStreaming = getDataStreamingToClient(); + bool previouslyReceiverStreaming = getDataStreamingFromReceiver(pos).squash(false); + pimpl->Parallel(&slsDetector::setNumberofUDPInterfaces, pos, n); + // redo the zmq sockets if enabled + if (previouslyClientStreaming) { + setDataStreamingToClient(false); + setDataStreamingToClient(true); + } + if (previouslyReceiverStreaming) { + setDataStreamingFromReceiver(false, pos); + setDataStreamingFromReceiver(true, pos); + } +} + +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::getClientStreamingPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getClientStreamingPort, pos); +} + +void Detector::setClientDataStreamingInPort(int port, Positions pos) { + if (pos.size() > 1 && pos.size() < pimpl->size()) { + throw RuntimeError("Cannot set client streaming port to a subset of modules"); + } + pimpl->setClientDataStreamingInPort(port, pos.empty() ? -1 : pos[0]); +} + +Result Detector::getReceiverStreamingPort(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverStreamingPort, pos); +} + +void Detector::setReceiverDataStreamingOutPort(int port, Positions pos) { + if (pos.size() > 1 && pos.size() < pimpl->size()) { + throw RuntimeError("Cannot set receiver streaming port to a subset of modules"); + } + pimpl->setReceiverDataStreamingOutPort(port, pos.empty() ? -1 : pos[0]); +} + +Result Detector::getClientStreamingIP(Positions pos) const { + return pimpl->Parallel(&slsDetector::getClientStreamingIP, pos); +} + +void Detector::setClientDataStreamingInIP(const std::string &ip, + Positions pos) { + bool previouslyClientStreaming = getDataStreamingToClient(); + // TODO! probably in one call ?? + pimpl->Parallel(&slsDetector::setClientStreamingIP, pos, ip); + if (previouslyClientStreaming) { + setDataStreamingToClient(false); + setDataStreamingToClient(true); + } +} + +Result Detector::getReceiverStreamingIP(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverStreamingIP, pos); +} + +void Detector::setReceiverDataStreamingOutIP(const std::string &ip, + Positions pos) { + bool previouslyReceiverStreaming = getDataStreamingFromReceiver(pos).squash(false); + // TODO! probably in one call + pimpl->Parallel(&slsDetector::setReceiverStreamingIP, pos, ip); + if (previouslyReceiverStreaming) { + setDataStreamingFromReceiver(false, pos); + setDataStreamingFromReceiver(true, pos); + } +} + +Result Detector::getFlowControl10G(Positions pos) const { + return pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::FLOW_CONTROL_10G, -1); +} + +void Detector::setFlowControl10G(bool enable, Positions pos) { + pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::FLOW_CONTROL_10G, static_cast(enable)); +} + +Result Detector::getTransmissionDelayFrame(Positions pos) const { + return pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::DETECTOR_TXN_DELAY_FRAME, -1); +} + +void Detector::setTransmissionDelayFrame(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::DETECTOR_TXN_DELAY_FRAME, value); +} + +Result Detector::getTransmissionDelayLeft(Positions pos) const { + return pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::DETECTOR_TXN_DELAY_LEFT, -1); +} + +void Detector::setTransmissionDelayLeft(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::DETECTOR_TXN_DELAY_LEFT, value); +} + +Result Detector::getTransmissionDelayRight(Positions pos) const { + return pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::DETECTOR_TXN_DELAY_RIGHT, -1); +} + +void Detector::setTransmissionDelayRight(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, + defs::DETECTOR_TXN_DELAY_RIGHT, value); +} + +void Detector::setAdditionalJsonHeader(const std::string &jsonheader, + Positions pos) { + pimpl->Parallel(&slsDetector::setAdditionalJsonHeader, pos, jsonheader); +} + +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::getDetectorMinMaxEnergyThreshold(const bool isEmax, Positions pos) const { + auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos, isEmax ? "emax" : "emin"); + Result intResult; + try{ + for (unsigned int i = 0; i < res.size(); ++i) { + intResult[i] = stoi(res[i]); + } + } catch(...) { + throw RuntimeError("Cannot find or convert emin/emax string to integer"); + } + return intResult; +} + +void Detector::setDetectorMinMaxEnergyThreshold(const bool isEmax, const int value, Positions pos) { + pimpl->Parallel(&slsDetector::setAdditionalJsonParameter, pos, isEmax ? "emax" : "emin", std::to_string(value)); +} + +Result Detector::getFrameMode(Positions pos) const { + auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos, "frameMode"); + Result intResult; + try{ + for (unsigned int i = 0; i < res.size(); ++i) { + intResult[i] = defs::getFrameModeType(res[i]); + } + } catch(...) { + throw RuntimeError("Cannot find or convert frameMode string to integer"); + } + return intResult; +} + +void Detector::setFrameMode(defs::frameModeType value, Positions pos) { + pimpl->Parallel(&slsDetector::setAdditionalJsonParameter, pos, "frameMode", defs::getFrameModeType(value)); +} + +Result Detector::getDetectorMode(Positions pos) const { + auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos, "detectorMode"); + Result intResult; + try{ + for (unsigned int i = 0; i < res.size(); ++i) { + intResult[i] = defs::getDetectorModeType(res[i]); + } + } catch(...) { + throw RuntimeError("Cannot find or convert detectorMode string to integer"); + } + return intResult; +} + +void Detector::setDetectorMode(defs::detectorModeType value, Positions pos) { + pimpl->Parallel(&slsDetector::setAdditionalJsonParameter, pos, "detectorMode", defs::getDetectorModeType(value)); +} + +Result Detector::getDigitalTestBit(Positions pos) { + return pimpl->Parallel(&slsDetector::digitalTest, pos, defs::DIGITAL_BIT_TEST, -1); +} + +Result Detector::setDigitalTestBit(int value, Positions pos) { + return pimpl->Parallel(&slsDetector::digitalTest, pos, defs::DIGITAL_BIT_TEST, value); +} + +Result Detector::executeFirmwareTest(Positions pos) { + return pimpl->Parallel(&slsDetector::digitalTest, pos, defs::DETECTOR_FIRMWARE_TEST, -1); +} + +Result Detector::executeBusTest(Positions pos) { + return pimpl->Parallel(&slsDetector::digitalTest, pos, defs::DETECTOR_BUS_TEST, -1); +} + +void Detector::loadDarkImage(const std::string &fname, Positions pos) { + // TODO! optimize away multiple loads in multi + if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { + pimpl->loadImageToDetector(defs::DARK_IMAGE, fname, -1); + } + if (pos.size() > 1) { + throw RuntimeError("Cannot load dark image on a subset of modules"); + } + pimpl->Parallel(&slsDetector::loadImageToDetector, pos, defs::DARK_IMAGE, fname); +} + +void Detector::loadGainImage(const std::string &fname, Positions pos) { + // TODO! optimize away multiple loadsin multi + if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { + pimpl->loadImageToDetector(defs::GAIN_IMAGE, fname, -1); + } + if (pos.size() > 1) { + throw RuntimeError("Cannot load gain image on a subset of modules"); + } + pimpl->Parallel(&slsDetector::loadImageToDetector, pos, defs::GAIN_IMAGE, fname); +} + +void Detector::getCounterMemoryBlock(const std::string &fname, bool startACQ, Positions pos) { + if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { + pimpl->writeCounterBlockFile(fname, static_cast(startACQ), -1); + } + if (pos.size() > 1) { + throw RuntimeError("Cannot load get counter memory block on a subset of modules"); + } + pimpl->Parallel(&slsDetector::writeCounterBlockFile, pos, fname, static_cast(startACQ)); +} + +void Detector::resetCounterBlock(bool startACQ, Positions pos) { + pimpl->Parallel(&slsDetector::resetCounterBlock, pos, static_cast(startACQ)); +} + +Result Detector::getCounterBit(Positions pos) const { + return pimpl->Parallel(&slsDetector::setCounterBit, pos, -1); +} + +void Detector::setCounterBit(bool value, Positions pos) { + pimpl->Parallel(&slsDetector::setCounterBit, pos, value); +} + +Result> Detector::getROI(Positions pos) const { + int n = 0; + if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { + auto res = pimpl->getROI(n, -1); + std::vector arrayRes(n); + std::copy_n(res, n * sizeof(defs::ROI), arrayRes.begin()); + return arrayRes; + } else if (pos.size() > 1) { + throw RuntimeError("Cannot get roi from a subset of modules"); + } else { + auto res = pimpl->Parallel(&slsDetector::getROI, pos, n); + std::vector arrayRes(n); + std::copy_n(res, n * sizeof(defs::ROI), arrayRes.begin()); + return arrayRes; + } +} + +void Detector::setROI(std::vector value, Positions pos) { + if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { + pimpl->setROI(static_cast(value.size()), value.data(), -1); + } else if (pos.size() > 1) { + throw RuntimeError("Cannot set roi to a subset of modules"); + } else { + pimpl->Parallel(&slsDetector::setROI, pos, static_cast(value.size()), value.data()); + } +} + +Result Detector::getADCEnableMask(Positions pos) const { + return pimpl->Parallel(&slsDetector::getADCEnableMask, pos); +} + +void Detector::setADCEnableMask(uint32_t mask, Positions pos) { + pimpl->Parallel(&slsDetector::setADCEnableMask, pos, mask); +} + +Result Detector::getADCInvert(Positions pos) const { + return pimpl->Parallel(&slsDetector::getADCInvert, pos); +} + +void Detector::setADCInvert(uint32_t value, Positions pos) { + pimpl->Parallel(&slsDetector::setADCInvert, pos, value); +} + +Result Detector::getExternalSamplingSource(Positions pos) const { + return pimpl->Parallel(&slsDetector::getExternalSamplingSource, pos); +} + +void Detector::setExternalSamplingSource(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setExternalSamplingSource, pos, value); +} + +Result Detector::getExternalSampling(Positions pos) const { + return pimpl->Parallel(&slsDetector::getExternalSampling, pos); +} + +void Detector::setExternalSampling(bool value, Positions pos) { + pimpl->Parallel(&slsDetector::setExternalSampling, pos, value); +} + +Result> Detector::getReceiverDbitList(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverDbitList, pos); +} + +void Detector::setReceiverDbitList(std::vector list, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverDbitList, pos, list); +} + +Result Detector::getReceiverDbitOffset(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverDbitOffset, pos); +} + +void Detector::setReceiverDbitOffset(int value, Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverDbitOffset, pos, value); +} + +void Detector::writeAdcRegister(uint32_t addr, uint32_t value, Positions pos) { + pimpl->Parallel(&slsDetector::writeAdcRegister, pos, addr, value); +} + + + + + + + +Result Detector::getReceiverUDPSocketBufferSize(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverUDPSocketBufferSize, pos); +} + +void Detector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, + Positions pos) { + pimpl->Parallel(&slsDetector::setReceiverUDPSocketBufferSize, pos, + udpsockbufsize); +} + +Result +Detector::getReceiverRealUDPSocketBufferSize(Positions pos) const { + return pimpl->Parallel(&slsDetector::getReceiverRealUDPSocketBufferSize, + pos); +} + + + + Result Detector::getFramesCaughtByReceiver(Positions pos) const { return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos); } @@ -803,7 +1257,19 @@ Result Detector::getReceiverStreamingTimer(Positions pos) const { return pimpl->Parallel(&slsDetector::setReceiverStreamingTimer, pos, -1); } -void Detector::enableDataStreamingFromReceiver(bool enable, Positions pos) { +bool Detector::getDataStreamingToClient() const { + return pimpl->enableDataStreamingToClient(-1); +} + +void Detector::setDataStreamingToClient(bool enable) { + pimpl->enableDataStreamingToClient(static_cast(enable)); +} + +Result Detector::getDataStreamingFromReceiver(Positions pos) const { + return pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, -1); +} + +void Detector::setDataStreamingFromReceiver(bool enable, Positions pos) { pimpl->Parallel(&slsDetector::enableDataStreamingFromReceiver, pos, static_cast(enable)); } @@ -1123,292 +1589,11 @@ Result Detector::getActive(Positions pos) const { return pimpl->Parallel(&slsDetector::activate, pos, -1); } -void Detector::writeAdcRegister(uint32_t addr, uint32_t value, Positions pos) { - pimpl->Parallel(&slsDetector::writeAdcRegister, pos, addr, value); -} -Result Detector::getReceiverDbitOffset(Positions pos) const { - return pimpl->Parallel(&slsDetector::getReceiverDbitOffset, pos); -} -void Detector::setReceiverDbitOffset(int value, Positions pos) { - pimpl->Parallel(&slsDetector::setReceiverDbitOffset, pos, value); -} -Result> Detector::getReceiverDbitList(Positions pos) const { - return pimpl->Parallel(&slsDetector::getReceiverDbitList, pos); -} -void Detector::setReceiverDbitList(std::vector list, Positions pos) { - pimpl->Parallel(&slsDetector::setReceiverDbitList, pos, list); -} -Result Detector::getExternalSampling(Positions pos) const { - return pimpl->Parallel(&slsDetector::getExternalSampling, pos); -} -void Detector::setExternalSampling(bool value, Positions pos) { - pimpl->Parallel(&slsDetector::setExternalSampling, pos, value); -} - -Result Detector::getExternalSamplingSource(Positions pos) const { - return pimpl->Parallel(&slsDetector::getExternalSamplingSource, pos); -} - -void Detector::setExternalSamplingSource(int value, Positions pos) { - pimpl->Parallel(&slsDetector::setExternalSamplingSource, pos, value); -} - -uint32_t Detector::getADCInvert() const { - return pimpl->Parallel(&slsDetector::getADCInvert, {}) - .tsquash("Different Values for function getADCInvert"); -} - -void Detector::setADCInvert(uint32_t value) { - pimpl->Parallel(&slsDetector::setADCInvert, {}, value); -} - -uint32_t Detector::getADCEnableMask() const { - return pimpl->Parallel(&slsDetector::getADCEnableMask, {}) - .tsquash("Values of ADC enable mask cannot be different"); -} - -void Detector::setADCEnableMask(uint32_t mask) { - pimpl->Parallel(&slsDetector::setADCEnableMask, {}, mask); -} - -Result Detector::getCounterBit(Positions pos) const { - return pimpl->Parallel(&slsDetector::setCounterBit, pos, -1); -} - -void Detector::setCounterBit(int i, Positions pos) { - pimpl->Parallel(&slsDetector::setCounterBit, pos, i); -} - -void Detector::resetCounterBlock(int startACQ, Positions pos) { - pimpl->Parallel(&slsDetector::resetCounterBlock, pos, startACQ); -} - -void Detector::loadImageToDetector(defs::imageType index, - const std::string &fname, Positions pos) { - // TODO! optimize away multiple loads - pimpl->Parallel(&slsDetector::loadImageToDetector, pos, index, fname); -} - -Result Detector::digitalTest(defs::digitalTestMode mode, int ival, - Positions pos) { - return pimpl->Parallel(&slsDetector::digitalTest, pos, mode, ival); -} - -void Detector::setFlowControl10G(bool enable, Positions pos) { - pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, - defs::FLOW_CONTROL_10G, static_cast(enable)); -} - -Result Detector::getFlowControl10G(Positions pos) const { - return pimpl->Parallel(&slsDetector::setDetectorNetworkParameter, pos, - defs::FLOW_CONTROL_10G, -1); -} - -Result -Detector::getReceiverRealUDPSocketBufferSize(Positions pos) const { - return pimpl->Parallel(&slsDetector::getReceiverRealUDPSocketBufferSize, - pos); -} - -Result Detector::getReceiverUDPSocketBufferSize(Positions pos) const { - return pimpl->Parallel(&slsDetector::getReceiverUDPSocketBufferSize, pos); -} - -void Detector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, - Positions pos) { - pimpl->Parallel(&slsDetector::setReceiverUDPSocketBufferSize, pos, - udpsockbufsize); -} - -int Detector::setDetectorMode(defs::detectorModeType value) { - return pimpl->setDetectorMode(value); -} -int Detector::setFrameMode(defs::frameModeType value) { - return pimpl->setFrameMode(value); -} -int Detector::setDetectorMinMaxEnergyThreshold(const int index, int value) { - return pimpl->setDetectorMinMaxEnergyThreshold(index, value); -} - -void Detector::setAdditionalJsonHeader(const std::string &jsonheader, - Positions pos) { - pimpl->Parallel(&slsDetector::setAdditionalJsonHeader, pos, jsonheader); -} - -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); - enableDataStreamingFromReceiver(false, pos); - enableDataStreamingFromReceiver(true, pos); -} - -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); -} - -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 { - return pimpl->Parallel(&slsDetector::getReceiverUDPPort2, pos); -} - -void Detector::setReceiverUDPPort2(int udpport, Positions pos) { - pimpl->Parallel(&slsDetector::setReceiverUDPPort2, pos, udpport); -} - -Result Detector::getReceiverUDPPort(Positions pos) const { - return pimpl->Parallel(&slsDetector::getReceiverUDPPort, pos); -} - -void Detector::setReceiverUDPPort(int udpport, Positions pos) { - pimpl->Parallel(&slsDetector::setReceiverUDPPort, 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); -} - -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); -} - -Result Detector::getInterruptSubframe(Positions pos) const { - return pimpl->Parallel(&slsDetector::getInterruptSubframe, pos); -} - -void Detector::setInterruptSubframe(const bool enable, Positions pos){ - pimpl->Parallel(&slsDetector::setInterruptSubframe, pos, enable); -} } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 7ef451e85..c5492c1ec 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -1726,7 +1726,7 @@ int multiSlsDetector::getReceiverUDPPort2(int detPos) const { int multiSlsDetector::setNumberofUDPInterfaces(int n, int detPos) { - int previouslyClientStreaming = enableDataStreamingToClient(); + bool previouslyClientStreaming = enableDataStreamingToClient(); int previouslyReceiverStreaming = enableDataStreamingFromReceiver(); // single @@ -1739,7 +1739,7 @@ int multiSlsDetector::setNumberofUDPInterfaces(int n, int detPos) { auto r = parallelCall(&slsDetector::setNumberofUDPInterfaces, n); // redo the zmq sockets - if (previouslyClientStreaming != 0) { + if (previouslyClientStreaming) { enableDataStreamingToClient(0); enableDataStreamingToClient(1); } @@ -1791,7 +1791,7 @@ int multiSlsDetector::getSelectedUDPInterface(int detPos) const { void multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) { if (i >= 0) { - int prev_streaming = enableDataStreamingToClient(); + bool prev_streaming = enableDataStreamingToClient(); // single if (detPos >= 0) { @@ -1811,7 +1811,7 @@ void multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) { } } - if (prev_streaming != 0) { + if (prev_streaming) { enableDataStreamingToClient(0); enableDataStreamingToClient(1); } @@ -1872,7 +1872,7 @@ int multiSlsDetector::getReceiverStreamingPort(int detPos) { void multiSlsDetector::setClientDataStreamingInIP(const std::string &ip, int detPos) { if (ip.length() != 0u) { - int prev_streaming = enableDataStreamingToClient(-1); + bool prev_streaming = enableDataStreamingToClient(-1); // single if (detPos >= 0) { @@ -1885,7 +1885,7 @@ void multiSlsDetector::setClientDataStreamingInIP(const std::string &ip, } } - if (prev_streaming != 0) { + if (prev_streaming) { enableDataStreamingToClient(0); enableDataStreamingToClient(1); } @@ -2142,6 +2142,13 @@ void multiSlsDetector::writeCounterBlockFile(const std::string &fname, imageVals + idet * detectors[idet]->getTotalNumberOfChannels(), startACQ); } + + if (writeDataFile(fname, nch, imageVals) < nch * (int)sizeof(short int)) { + throw RuntimeError( + "Could not open file to write or did not write enough data" + " in file to write counter block file from detector."); + } + } void multiSlsDetector::resetCounterBlock(int startACQ, int detPos) { @@ -3693,7 +3700,7 @@ int multiSlsDetector::setReceiverStreamingTimer(int time_in_ms, int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::enableDataStreamingToClient(int enable) { +bool multiSlsDetector::enableDataStreamingToClient(int enable) { if (enable >= 0) { // destroy data threads if (enable == 0) { @@ -3705,7 +3712,7 @@ int multiSlsDetector::enableDataStreamingToClient(int enable) { } } } - return static_cast(client_downstream); + return client_downstream; } int multiSlsDetector::enableDataStreamingFromReceiver(int enable, int detPos) { diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index 5243ef95b..7cd414911 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -235,7 +235,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { ++i; /*! \page acquisition - - resmat i sets/resets counter bit in detector.gets the counter bit in detector ???? + - resmat i sets/resets counter bit in detector.gets the counter bit in Eiger */ descrToFuncMap[i].m_pFuncName = "resmat"; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdCounter;