From 40bc498e9a5d779839a3173052699f057099a553 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 8 Aug 2019 16:44:52 +0200 Subject: [PATCH] WIP --- slsDetectorSoftware/include/Detector.h | 64 +++++++++++++++---- .../include/multiSlsDetector.h | 34 +++++----- slsDetectorSoftware/src/Detector.cpp | 57 ++++++++++++++++- 3 files changed, 125 insertions(+), 30 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 2270abbe3..5d1e45b9c 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -299,44 +299,42 @@ class Detector { * @param pos detector position * @returns receiver port */ - //int getControlort(Positions pos = {}) const; + // int getControlort(Positions pos = {}) const; /** * Set TCP Port of the detector (for client communication with Receiver) * @param value port number * @param pos detector position */ - //void setControlPort(int port_number, Positions pos = {}); + // void setControlPort(int port_number, Positions pos = {}); /** * Get Receiver TCP port (for client communication with Receiver) * @param pos detector position * @returns receiver port */ - //int getStopPort(Positions pos = {}) const; + // int getStopPort(Positions pos = {}) const; /** * Set TCP Port of the detector (for client communication with Receiver) * @param value port number * @param pos detector position */ - //void setStopPort(int port_number, Positions pos = {}); + // void setStopPort(int port_number, Positions pos = {}); - /** + /** * Get Receiver TCP port (for client communication with Receiver) * @param pos detector position * @returns receiver port */ - //int getReceiverPort(Positions pos = {}) const; + // int getReceiverPort(Positions pos = {}) const; /** * Set TCP Port of the detector (for client communication with Receiver) * @param value port number * @param pos detector position */ - //void setReceiverPort(int port_number, Positions pos = {}); - - + // void setReceiverPort(int port_number, Positions pos = {}); // Erik @@ -525,17 +523,61 @@ 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 = {}); + + /** [Jungfrau] TODO??? fix docs */ + void setAutoCompDisable(bool value, Positions pos = {}); + + Result getAutoCompDisable(Positions pos = {}) const; + + void setPowerChip(bool on, Positions pos = {}); + + Result getPowerChip(Positions pos = {}) const; + + /** + * Updates the firmware, detector server and then reboots detector + * controller blackfin. (Not Eiger) + * @param sname name of detector server binary + * @param hostname name of pc to tftp from + * @param fname programming file name + * @param pos detector positions + */ + void updateFirmwareAndServer(const std::string &sname, + const std::string &hostname, + const std::string &fname, Positions pos = {}); + + /** [not Eiger] TODO! is this needed?*/ + void rebootController(Positions pos = {}); + + /** Copy detector server to detector */ + void copyDetectorServer(const std::string &fname, + const std::string &hostname, Positions pos = {}); + + + /** [not Eiger] */ + void resetFPGA(Positions pos = {}); + + /** [not Eiger] */ + void programFPGA(const std::string &fname, Positions pos = {}); + + /** + * [Jungfrau] Set first storage cell of the series (Jungfrau) + * @param value storage cell index. Value can be 0 to 15. + */ + void setStoragecellStart(int cell, Positions pos = {}); + + Result getStorageCellStart(Positions pos = {}) const; + + }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 556eb28c0..8a6dd006b 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -1681,13 +1681,13 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param fname file name * @param detPos -1 for all detectors in list or specific detector position */ - void programFPGA(const std::string &fname, int detPos = -1); + void programFPGA(const std::string &fname, int detPos = -1); // /** * Resets FPGA (Not Eiger) * @param detPos -1 for all detectors in list or specific detector position */ - void resetFPGA(int detPos = -1); + void resetFPGA(int detPos = -1); // /** * Copies detector server from tftp and changes respawn server (Not Eiger) @@ -1696,13 +1696,13 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position */ void copyDetectorServer(const std::string &fname, - const std::string &hostname, int detPos = -1); + const std::string &hostname, int detPos = -1); // /** * Reboot detector controller (Not Eiger) * @param detPos -1 for all detectors in list or specific detector position */ - void rebootController(int detPos = -1); + void rebootController(int detPos = -1); // /** * Updates the firmware, detector server and then reboots detector @@ -1713,7 +1713,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position */ void update(const std::string &sname, const std::string &hostname, - const std::string &fname, int detPos = -1); + const std::string &fname, int detPos = -1); // /** * Power on/off Chip (Jungfrau) @@ -1721,7 +1721,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns OK or FAIL */ - int powerChip(int ival = -1, int detPos = -1); + int powerChip(int ival = -1, int detPos = -1); // /** * Automatic comparator disable (Jungfrau) @@ -1729,7 +1729,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns OK or FAIL */ - int setAutoComparatorDisableMode(int ival = -1, int detPos = -1); + int setAutoComparatorDisableMode(int ival = -1, int detPos = -1); // /** * Set Rate correction ( Eiger) @@ -1738,14 +1738,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { * for current settings * @param detPos -1 for all detectors in list or specific detector position */ - void setRateCorrection(int64_t t = 0, int detPos = -1); + void setRateCorrection(int64_t t = 0, int detPos = -1); // /** * Get rate correction ( Eiger) * @param detPos -1 for all detectors in list or specific detector position * @returns 0 if rate correction disabled, > 0 otherwise (ns) */ - int64_t getRateCorrection(int detPos = -1); + int64_t getRateCorrection(int detPos = -1); // /** * Prints receiver configuration @@ -2230,6 +2230,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ void processData(); + /** + * Convert raw file + * @param fname name of pof file + * @param fpgasrc pointer in memory to read pof to + * @returns file size + */ + std::vector readPofFile(const std::string &fname); + private: /** * increments file index @@ -2370,13 +2378,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ int kbhit(); - /** - * Convert raw file - * @param fname name of pof file - * @param fpgasrc pointer in memory to read pof to - * @returns file size - */ - std::vector readPofFile(const std::string &fname); + /** * Convert a double holding time in seconds to an int64_t with nano seconds diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index d77c13647..01adb635b 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -209,7 +209,8 @@ Result Detector::getDetectorOffsets(Positions pos) const { } void Detector::setDetectorOffsets(defs::coordinates value, Positions pos) { - pimpl->Parallel(&slsDetector::setDetectorOffset, pos, value); + pimpl->Parallel(&slsDetector::setDetectorOffset, pos, + value); } Result Detector::getQuad(Positions pos) const { @@ -228,8 +229,6 @@ void Detector::setReadNLines(const int value, Positions pos) { pimpl->Parallel(&slsDetector::setReadNLines, pos, value); } - - // Erik Result Detector::getFramesCaughtByReceiver(Positions pos) const { return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos); @@ -432,4 +431,56 @@ void Detector::setRateCorrection(int64_t dead_time_ns, Positions pos) { pimpl->Parallel(&slsDetector::setRateCorrection, pos, dead_time_ns); } +void Detector::setAutoCompDisable(bool value, Positions pos) { + pimpl->Parallel(&slsDetector::setAutoComparatorDisableMode, pos, + static_cast(value)); +} + +Result Detector::getAutoCompDisable(Positions pos) const { + return pimpl->Parallel(&slsDetector::setAutoComparatorDisableMode, pos, -1); +} + +void Detector::setPowerChip(bool on, Positions pos) { + pimpl->Parallel(&slsDetector::powerChip, pos, static_cast(on)); +} + +Result Detector::getPowerChip(Positions pos) const { + return pimpl->Parallel(&slsDetector::powerChip, pos, -1); +} + +void Detector::updateFirmwareAndServer(const std::string &sname, + const std::string &hostname, + const std::string &fname, + Positions pos) { + copyDetectorServer(fname, hostname, pos); + programFPGA(fname, pos); +} + +void Detector::rebootController(Positions pos) { + pimpl->Parallel(&slsDetector::rebootController, pos); +} + +void Detector::copyDetectorServer(const std::string &fname, + const std::string &hostname, Positions pos) { + pimpl->Parallel(&slsDetector::copyDetectorServer, pos, fname, hostname); +} + +void Detector::resetFPGA(Positions pos) { + pimpl->Parallel(&slsDetector::resetFPGA, pos); +} + +void Detector::programFPGA(const std::string &fname, Positions pos) { + FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; + std::vector buffer = pimpl->readPofFile(fname); + pimpl->Parallel(&slsDetector::programFPGA, pos, buffer); +} + +void Detector::setStoragecellStart(int cell, Positions pos) { + pimpl->Parallel(&slsDetector::setStoragecellStart, pos, cell); +} + +Result Detector::getStorageCellStart(Positions pos) const { + return pimpl->Parallel(&slsDetector::setStoragecellStart, pos, -1); +} + } // namespace sls \ No newline at end of file