diff --git a/python/sls_detector/detector.py b/python/sls_detector/detector.py index 4e9a7ed58..f6481e32f 100755 --- a/python/sls_detector/detector.py +++ b/python/sls_detector/detector.py @@ -40,12 +40,6 @@ class Detector: self._api.setFlippedDataY, self._api.getNumberOfDetectors, 'flippeddatay') - try: - self.online = True - self.receiver_online = True - except DetectorError: - print('WARNING: Cannot connect to detector') - def __len__(self): return self._api.getNumberOfDetectors() @@ -728,27 +722,6 @@ class Detector: """ return self._api.getNumberOfDetectors() - @property - def online(self): - """Online flag for the detector - - Examples - ---------- - - :: - - d.online - >> False - - d.online = True - - """ - return self._api.getOnline() - - @online.setter - def online(self, value): - self._api.setOnline(value) - @property def last_client_ip(self): @@ -794,9 +767,6 @@ class Detector: """ return self._api.getReceiverOnline() - @receiver_online.setter - def receiver_online(self, value): - self._api.setReceiverOnline(value) @property def receiver_version(self): diff --git a/python/src/Detector.h b/python/src/Detector.h index 1b1545d2e..1c9451236 100755 --- a/python/src/Detector.h +++ b/python/src/Detector.h @@ -115,12 +115,6 @@ class Detector { std::string checkOnline() { return det.checkOnline(); } - bool getReceiverOnline() { return det.setReceiverOnline(); } - void setReceiverOnline(const bool status) { det.setReceiverOnline(status); } - - bool getOnline() { return det.setOnline(); } - void setOnline(const bool status) { det.setOnline(status); } - bool isChipPowered() { return det.powerChip(); } void powerChip(const bool value) { det.powerChip(value); } @@ -355,19 +349,11 @@ class Detector { return mp; } - bool isClientAndDetectorCompatible() { - auto r = det.checkDetectorVersionCompatibility(); - if (r == 0) - return true; - else - return false; + void checkDetectorVersionCompatibility() { + det.checkDetectorVersionCompatibility(); } - bool isClientAndReceiverCompatible() { - auto r = det.checkReceiverVersionCompatibility(); - if (r == 0) - return true; - else - return false; + bool checkReceiverVersionCompatibility() { + det.checkReceiverVersionCompatibility(); } /*** END Frame and file settings ***/ diff --git a/python/src/main.cpp b/python/src/main.cpp index fd91c9cfb..6e5fcb72e 100755 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -32,11 +32,8 @@ PYBIND11_MODULE(_sls_detector, m) { d = Eiger() d._api.getThresholdEnergy() - #creating a DetectorApi object (remember to set online flags) from _sls_detector import DetectorApi api = DetectorApi(0) - api.setOnline(True) - api.setReceiverOnline(True) api.getNumberOfFrames() #But the Pythonic way is almost alway simpler @@ -97,11 +94,6 @@ PYBIND11_MODULE(_sls_detector, m) { .def("getHostname", &Detector::getHostname) .def("setHostname", &Detector::setHostname) - .def("getOnline", &Detector::getOnline) - .def("setOnline", &Detector::setOnline) - .def("getReceiverOnline", &Detector::getReceiverOnline) - .def("setReceiverOnline", &Detector::setReceiverOnline) - .def("getReceiverPort", &Detector::getReceiverPort) .def("setReceiverPort", &Detector::setReceiverPort) @@ -224,10 +216,10 @@ PYBIND11_MODULE(_sls_detector, m) { .def("getPartialFramesPadding", &Detector::getPartialFramesPadding) .def("getUserDetails", &Detector::getUserDetails) - .def("isClientAndDetectorCompatible", - &Detector::isClientAndDetectorCompatible) - .def("isClientAndReceiverCompatible", - &Detector::isClientAndReceiverCompatible) + .def("checkDetectorVersionCompatibility", + &Detector::checkDetectorVersionCompatibility) + .def("checkReceiverVersionCompatibility", + &Detector::checkReceiverVersionCompatibility) .def("getMeasuredPeriod", &Detector::getMeasuredPeriod) .def("getMeasuredSubPeriod", &Detector::getMeasuredSubPeriod) @@ -310,11 +302,6 @@ PYBIND11_MODULE(_sls_detector, m) { multiDetectorApi.def(py::init()) .def("acquire", &multiSlsDetector::acquire) - .def_property("online", - py::cpp_function(&multiSlsDetector::setOnline, py::arg(), - py::arg() = -1, py::arg("det_id") = -1), - py::cpp_function(&multiSlsDetector::setOnline, py::arg(), - py::arg("flag"), py::arg("det_id") = -1)) .def_property("exptime", py::cpp_function(&multiSlsDetector::setExposureTime, py::arg(), py::arg() = -1, py::arg() = 0, diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui index 29bed92cd..b6545fd4a 100755 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -298,49 +298,7 @@ Network - - - - - 0 - 0 - - - - - 180 - 20 - - - - - 16777215 - 28 - - - - Sets the Receiver Hostname, connects to it and gets the receiver mac address and eth. Sets some receiver parameters like file name, file dir, file index in receiver. -#rx_hostname# - - - none - - - - - - - - 0 - 0 - - - - Receiver UDP IP: - - - - + @@ -390,7 +348,62 @@ - + + + + + 0 + 0 + + + + + 180 + 20 + + + + + 16777215 + 28 + + + + Sets the Receiver Hostname, connects to it and gets the receiver mac address and eth. Sets some receiver parameters like file name, file dir, file index in receiver. +#rx_hostname# + + + none + + + + + + + + 0 + 0 + + + + Receiver UDP IP: + + + + + + + + 0 + 0 + + + + Detector Control Port: + + + + @@ -419,7 +432,7 @@ - + @@ -448,26 +461,7 @@ - - - - - 0 - 0 - - - - - 108 - 0 - - - - Detector Online Status: - - - - + @@ -496,7 +490,7 @@ - + @@ -546,39 +540,7 @@ - - - - - 0 - 0 - - - - - 180 - 20 - - - - - 16777215 - 28 - - - - Gets the detector online status -#online# - - - Offline - - - true - - - - + @@ -628,7 +590,7 @@ - + @@ -641,20 +603,7 @@ - - - - - 0 - 0 - - - - Receiver Online Status: - - - - + @@ -683,7 +632,7 @@ - + @@ -733,7 +682,7 @@ - + @@ -746,7 +695,7 @@ - + @@ -759,7 +708,7 @@ - + @@ -809,7 +758,7 @@ - + @@ -822,7 +771,7 @@ - + @@ -872,7 +821,7 @@ - + @@ -901,7 +850,7 @@ - + @@ -930,51 +879,6 @@ - - - - - 0 - 0 - - - - - 180 - 20 - - - - - 16777215 - 28 - - - - Gets the receiver online status -#r_online# - - - Offline - - - true - - - - - - - - 0 - 0 - - - - Detector Control Port: - - - @@ -997,7 +901,7 @@ - + @@ -1029,7 +933,7 @@ - + @@ -1042,7 +946,7 @@ - + @@ -1055,7 +959,7 @@ - + @@ -1068,7 +972,7 @@ - + @@ -1081,7 +985,7 @@ - + @@ -1504,7 +1408,6 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode btnClearRoi scrollArea comboDetector - dispOnline spinControlPort spinStopPort dispDetectorUDPIP @@ -1512,7 +1415,6 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode spinZMQPort dispZMQIP dispRxrHostname - dispRxrOnline spinRxrTCPPort spinRxrUDPPort dispRxrUDPIP diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h index 76414eb70..921232914 100755 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -43,7 +43,6 @@ private: void Initialization(); void PopulateDetectors(); - void GetOnline(); void GetControlPort(); void GetStopPort(); void GetDetectorUDPIP(); @@ -51,7 +50,6 @@ private: void GetCltZMQPort(); void GetCltZMQIP(); void GetRxrHostname(); - void GetReceiverOnline(); void GetRxrTCPPort(); void GetRxrUDPPort(); void GetRxrUDPIP(); @@ -65,11 +63,6 @@ private: void GetSubDeadTime(); multiSlsDetector *myDet; - /** Tool Tip */ - QString errOnlineTip; - QString detOnlineTip; - QString rxrOnlineTip; - QPalette red; /** ROI */ std::vector lblFromX; std::vector spinFromX; diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 002c8c2f1..9efa24faf 100755 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -24,14 +24,6 @@ qTabAdvanced::~qTabAdvanced() { } void qTabAdvanced::SetupWidgetWindow() { - // palette - red = QPalette(); - red.setColor(QPalette::Active, QPalette::WindowText, Qt::red); - detOnlineTip = dispOnline->toolTip(); - rxrOnlineTip = dispRxrOnline->toolTip(); - errOnlineTip = QString( - "

It is offline!"); - // enabling according to det type switch (myDet->getDetectorTypeAsEnum()) { case slsDetectorDefs::EIGER: @@ -140,44 +132,6 @@ void qTabAdvanced::PopulateDetectors() { SLOT(SetDetector(int))); } -void qTabAdvanced::GetOnline() { - FILE_LOG(logDEBUG) << "Getting detector online status"; - - int moduleId = comboDetector->currentIndex(); - try { - myDet->checkOnline(moduleId); - - int ret = myDet->getOnlineFlag(moduleId); - switch (ret) { - case 1: - dispOnline->setText("Online"); - lblOnline->setText("Detector Online Status: "); - dispOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - dispOnline->setPalette(lblHostname->palette()); - lblOnline->setPalette(lblHostname->palette()); - break; - default: - dispOnline->setText("Offline"); - lblOnline->setText("Detector Online Status:* "); - dispOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - dispOnline->setPalette(red); - lblOnline->setPalette(red); - break; - } - } - // ignore if checkonline throws socket exception, else display it - catch (const sls::SocketError &e) { - ; // do nothing as it might just be offline - } - // display any other exception - catch (const std::exception &e) { - qDefs::ExceptionMessage("Could not get detector online status", - e.what(), "qTabAdvanced::GetOnline"); - } -} - void qTabAdvanced::GetControlPort() { FILE_LOG(logDEBUG) << "Getting control port "; disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, @@ -276,44 +230,6 @@ void qTabAdvanced::GetRxrHostname() { SLOT(SetRxrHostname())); } -void qTabAdvanced::GetReceiverOnline() { - FILE_LOG(logDEBUG) << "Getting Receiver online status"; - - int moduleId = comboDetector->currentIndex(); - try { - myDet->checkReceiverOnline(moduleId); - - int ret = myDet->getReceiverOnlineFlag(moduleId); - switch (ret) { - case 1: - dispRxrOnline->setText("Online"); - lblRxrOnline->setText("Receiver Online Status: "); - dispRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - dispRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setPalette(lblHostname->palette()); - break; - default: - dispRxrOnline->setText("Offline"); - lblRxrOnline->setText("Receiver Online Status:* "); - dispRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - dispRxrOnline->setPalette(red); - lblRxrOnline->setPalette(red); - break; - } - } - // ignore if checkReceiverOnline throws socket exception - catch (const sls::SocketError &e) { - ; - } - // display any other exception - catch (const std::exception &e) { - qDefs::ExceptionMessage("Could not check receiver online status", - e.what(), "qTabAdvanced::GetReceiverOnline"); - } -} - void qTabAdvanced::GetRxrTCPPort() { FILE_LOG(logDEBUG) << "Getting Receiver TCP port"; disconnect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, @@ -402,7 +318,6 @@ void qTabAdvanced::SetDetector(int index) { FILE_LOG(logDEBUG) << "Set Detector: " << comboDetector->currentText().toAscii().data(); - GetOnline(); GetControlPort(); GetStopPort(); GetDetectorUDPIP(); @@ -410,7 +325,6 @@ void qTabAdvanced::SetDetector(int index) { GetCltZMQPort(); GetCltZMQIP(); GetRxrHostname(); - GetReceiverOnline(); GetRxrTCPPort(); GetRxrUDPPort(); GetRxrUDPIP(); diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 9b94d70af..2d00b42b2 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -16,7 +16,7 @@ class detectorData; #include #include -#define MULTI_SHMVERSION 0x190724 +#define MULTI_SHMVERSION 0x190726 #define SHORT_STRING_LENGTH 50 #define DATE_LENGTH 30 @@ -50,10 +50,6 @@ struct sharedMultiSlsDetector { /** Number of detectors operated at once */ int numberOfDetector[2]; - /** online flag - is set if the detector is connected, unset if socket - * connection is not possible */ - int onlineFlag; - /** stopped flag - is set if an acquisition error occurs or the detector * is stopped manually. Is reset to 0 at the start of the acquisition */ int stoppedFlag; @@ -199,17 +195,16 @@ class multiSlsDetector : public virtual slsDetectorDefs { * (if hostname/rx_hostname has been set/ sockets created) * @param p port type control port or receiver port * @param detPos -1 for all detectors in list or specific detector position - * @returns FAIL for incompatibility, OK for compatibility */ - int checkDetectorVersionCompatibility(int detPos = -1); + void checkDetectorVersionCompatibility(int detPos = -1); + /** * Check version compatibility with receiver software * (if hostname/rx_hostname has been set/ sockets created) * @param p port type control port or receiver port * @param detPos -1 for all detectors in list or specific detector position - * @returns FAIL for incompatibility, OK for compatibility */ - int checkReceiverVersionCompatibility(int detPos = -1); + void checkReceiverVersionCompatibility(int detPos = -1); /** * Get ID or version numbers @@ -261,7 +256,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Sets the hostname of all sls detectors in shared memory - * Connects to them to set up online flag + * Connects to them * @param name concatenated hostname of all the sls detectors * @param detPos -1 for all detectors in list or specific detector position */ @@ -278,7 +273,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Appends detectors to the end of the list in shared memory - * Connects to them to set up online flag + * Connects to them * @param name concatenated hostname of the sls detectors to be appended to * the list */ @@ -406,25 +401,6 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ void updateOffsets(); - /** - * Checks if the multi detectors are online and sets the online flag - * @param online if GET_ONLINE_FLAG, only returns shared memory online flag, - * else sets the detector in online/offline state - * if OFFLINE_FLAG, (i.e. no communication to the detector - using only - * local structure - no data acquisition possible!); if ONLINE_FLAG, - * detector in online state (i.e. communication to the detector updating the - * local structure) - * @param detPos -1 for all detectors in list or specific detector position - * @returns online/offline status - */ - int setOnline(int value = GET_ONLINE_FLAG, int detPos = -1); - - /** - * Get detector online status - * @param detPos -1 for all detectors in list or specific detector position - */ - int getOnlineFlag(int detPos = -1); - /** * Checks if each of the detectors are online/offline * @param detPos -1 for all detectors in list or specific detector position @@ -482,17 +458,15 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Exit detector server * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int exitServer(int detPos = -1); + void exitServer(int detPos = -1); /** * Execute a command on the detector server * @param cmd command * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int execCommand(const std::string &cmd, int detPos); + void execCommand(const std::string &cmd, int detPos); /** * Load configuration from a configuration File @@ -562,18 +536,16 @@ class multiSlsDetector : public virtual slsDetectorDefs { * file name extension is automatically generated. * @param fname specific settings/trimbits file * @param detPos -1 for all detectors in list or specific detector position - * returns OK or FAIL */ - int loadSettingsFile(const std::string &fname, int detPos = -1); + void loadSettingsFile(const std::string &fname, int detPos = -1); /** * Saves the modules settings/trimbits to a specific file * file name extension is automatically generated. * @param fname specific settings/trimbits file * @param detPos -1 for all detectors in list or specific detector position - * returns OK or FAIL */ - int saveSettingsFile(const std::string &fname, int detPos = -1); + void saveSettingsFile(const std::string &fname, int detPos = -1); /** * Get Detector run status @@ -585,60 +557,52 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Prepares detector for acquisition (Eiger) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK if all detectors are ready for acquisition, FAIL otherwise */ - int prepareAcquisition(int detPos = -1); + void prepareAcquisition(int detPos = -1); /** * Start detector acquisition (Non blocking) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL if even one does not start properly */ - int startAcquisition(int detPos = -1); + void startAcquisition(int detPos = -1); /** * Stop detector acquisition * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int stopAcquisition(int detPos = -1); + void stopAcquisition(int detPos = -1); /** * Give an internal software trigger to the detector (Eiger only) * @param detPos -1 for all detectors in list or specific detector position - * @return OK or FAIL */ - int sendSoftwareTrigger(int detPos = -1); + void sendSoftwareTrigger(int detPos = -1); /** * Start detector acquisition and read all data (Blocking until end of * acquisition) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int startAndReadAll(int detPos = -1); + void startAndReadAll(int detPos = -1); /** * Start readout (without exposure or interrupting exposure) (Eiger store in * ram) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int startReadOut(int detPos = -1); + void startReadOut(int detPos = -1); /** * Requests and receives all data from the detector (Eiger store in ram) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int readAll(int detPos = -1); + void readAll(int detPos = -1); /** * Configures in detector the destination for UDP packets * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int configureMAC(int detPos = -1); + void configureMAC(int detPos = -1); /** * Set starting frame number for the next acquisition @@ -1275,9 +1239,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param index image type * @param fname file name from which to load image * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int loadImageToDetector(imageType index, const std::string &fname, + void loadImageToDetector(imageType index, const std::string &fname, int detPos = -1); /** @@ -1285,18 +1248,16 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param fname file name to load data from * @param startACQ is 1 to start acquisition after reading counter * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int writeCounterBlockFile(const std::string &fname, int startACQ = 0, + void writeCounterBlockFile(const std::string &fname, int startACQ = 0, int detPos = -1); /** * Resets counter in detector (Gotthard) * @param startACQ is 1 to start acquisition after resetting counter * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int resetCounterBlock(int startACQ = 0, int detPos = -1); + void resetCounterBlock(int startACQ = 0, int detPos = -1); /** * Set/get counter bit in detector (Gotthard) @@ -1320,9 +1281,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param n number of rois * @param roiLimits array of roi * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int setROI(int n = -1, ROI roiLimits[] = nullptr, int detPos = -1); + void setROI(int n = -1, ROI roiLimits[] = nullptr, int detPos = -1); /** * Get ROI from each detector and convert it to the multi detector scale @@ -1423,9 +1383,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param addr address of adc register * @param val value * @param detPos -1 for all detectors in list or specific detector position - * @returns return value (mostly -1 as it can't read adc register) */ - int writeAdcRegister(uint32_t addr, uint32_t val, int detPos = -1); + void writeAdcRegister(uint32_t addr, uint32_t val, int detPos = -1); /** * Activates/Deactivates the detector (Eiger only) @@ -1503,9 +1462,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param x is x coordinate * @param y is y coordinate * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int pulsePixel(int n = 0, int x = 0, int y = 0, int detPos = -1); + void pulsePixel(int n = 0, int x = 0, int y = 0, int detPos = -1); /** * Pulse Pixel and move by a relative value (Eiger) @@ -1513,17 +1471,15 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param x is relative x value * @param y is relative y value * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int pulsePixelNMove(int n = 0, int x = 0, int y = 0, int detPos = -1); + void pulsePixelNMove(int n = 0, int x = 0, int y = 0, int detPos = -1); /** * Pulse Chip (Eiger) * @param n is number of times to pulse * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int pulseChip(int n = 0, int detPos = -1); + void pulseChip(int n = 0, int detPos = -1); /** * Set/gets threshold temperature (Jungfrau) @@ -1561,32 +1517,28 @@ class multiSlsDetector : public virtual slsDetectorDefs { * Programs FPGA with pof file (Not Eiger) * @param fname file name * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int 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 - * @returns OK or FAIL */ - int resetFPGA(int detPos = -1); + void resetFPGA(int detPos = -1); /** * Copies detector server from tftp and changes respawn server (Not Eiger) * @param fname name of detector server binary * @param hostname name of pc to tftp from * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos = -1); + void copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos = -1); /** * Reboot detector controller (Not Eiger) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int rebootController(int detPos = -1); + void rebootController(int detPos = -1); /** * Updates the firmware, detector server and then reboots detector controller blackfin. (Not Eiger) @@ -1594,9 +1546,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param hostname name of pc to tftp from * @param fname programming file name * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos = -1); + void update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos = -1); /** * Power on/off Chip (Jungfrau) @@ -1621,9 +1572,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * if >0 set dead time to t, if < 0 set deadtime to default dead time * for current settings * @param detPos -1 for all detectors in list or specific detector position - * @returns 0 if rate correction disabled, >0 otherwise */ - int setRateCorrection(int64_t t = 0, int detPos = -1); + void setRateCorrection(int64_t t = 0, int detPos = -1); /** * Get rate correction ( Eiger) @@ -1639,19 +1589,12 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ void printReceiverConfiguration(TLogLevel level = logINFO, int detPos = -1); - /** - * Sets up receiver socket if online and sets the flag - * @param online online/offline flag (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns online/offline flag - */ - int setReceiverOnline(int value = GET_ONLINE_FLAG, int detPos = -1); - /** * Get receiver online status * @param detPos -1 for all detectors in list or specific detector position + * @returns use receiver flag */ - int getReceiverOnlineFlag(int detPos = -1); + bool getUseReceiverFlag(int detPos = -1); /** * Checks if the receiver is really online @@ -1679,18 +1622,16 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Turns off the receiver server! * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int exitReceiver(int detPos = -1); + void exitReceiver(int detPos = -1); /** * Executes a system command on the receiver server * e.g. mount an nfs disk, reboot and returns answer etc. * @param cmd command to be executed * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int execReceiverCommand(const std::string &cmd, int detPos = -1); + void execReceiverCommand(const std::string &cmd, int detPos = -1); /** * Returns output file directory @@ -1796,16 +1737,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** * Receiver starts listening to packets * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int startReceiver(int detPos = -1); + void startReceiver(int detPos = -1); /** * Stops the listening mode of receiver * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int stopReceiver(int detPos = -1); + void stopReceiver(int detPos = -1); /** * Gets the status of the listening mode of receiver @@ -1832,9 +1771,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * Resets framescaught in receiver * Use this when using startAcquisition instead of acquire * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int resetFramesCaught(int detPos = -1); + void resetFramesCaught(int detPos = -1); /** * Create Receiving Data Sockets @@ -2026,9 +1964,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * Sets the mask applied to every pattern (CTB/ Moench) * @param mask mask to be applied * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int setPatternMask(uint64_t mask, int detPos = -1); + void setPatternMask(uint64_t mask, int detPos = -1); /** * Gets the mask applied to every pattern (CTB/ Moench) @@ -2041,9 +1978,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * Selects the bits that the mask will be applied to for every pattern (CTB/ Moench) * @param mask mask to select bits * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int setPatternBitMask(uint64_t mask, int detPos = -1); + void setPatternBitMask(uint64_t mask, int detPos = -1); /** * Gets the bits that the mask will be applied to for every pattern (CTB/ Moench) @@ -2065,9 +2001,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param digital IO mask to select the pins * @param delay delay in ps(1 bit=25ps, max of 775 ps) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int setDigitalIODelay(uint64_t pinMask, int delay, int detPos = -1); + void setDigitalIODelay(uint64_t pinMask, int delay, int detPos = -1); /** * Loads the detector setup from file diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index 0009adbb0..fa6c1f4a9 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -12,7 +12,7 @@ class ServerInterface; -#define SLS_SHMVERSION 0x190515 +#define SLS_SHMVERSION 0x190726 /** * @short structure allocated in shared memory to store detector settings for IPC and cache @@ -24,9 +24,8 @@ struct sharedSlsDetector { /** shared memory version */ int shmversion; - /** online flag - is set if the detector is connected, unset if socket - * connection is not possible */ - int onlineFlag; + /** is the port used for control functions */ + int controlPort; /** stopped flag - is set if an acquisition error occurs or the detector * is stopped manually. Is reset to 0 at the start of the acquisition */ @@ -41,15 +40,13 @@ struct sharedSlsDetector { /** END OF FIXED PATTERN -----------------------------------------------*/ + /** Detector offset in the X & Y direction in the multi detector structure */ int offset[2]; /** Number of detectors in multi list in x dir and y dir */ int multiSize[2]; - /** is the port used for control functions */ - int controlPort; - /** is the port used to stop the acquisition */ int stopPort; @@ -147,9 +144,9 @@ struct sharedSlsDetector { /** selected udp interface */ int selectedUDPInterface; - /** online flag - is set if the receiver is connected, + /** is set if the receiver hostname given and is connected, * unset if socket connection is not possible */ - int rxOnlineFlag; + bool useReceiverFlag; /** 10 Gbe enable*/ int tenGigaEnable; @@ -187,15 +184,6 @@ struct sharedSlsDetector { /** additional json header */ char rxAdditionalJsonHeader[MAX_STR_LENGTH]; - /** detector control server software API version */ - int64_t detectorControlAPIVersion; - - /** detector stop server software API version */ - int64_t detectorStopAPIVersion; - - /** receiver server software API version */ - int64_t receiverAPIVersion; - /** receiver frames discard policy */ slsDetectorDefs::frameDiscardPolicy rxFrameDiscardMode; @@ -273,17 +261,13 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Check version compatibility with receiver software - * (if hostname/rx_hostname has been set/ sockets created) - * @param p port type control port or receiver port - * @returns FAIL for incompatibility, OK for compatibility */ - int checkReceiverVersionCompatibility(); + void checkReceiverVersionCompatibility(); /** * Check version compatibility with detector software - * @returns FAIL for incompatibility, OK for compatibility */ - int checkDetectorVersionCompatibility(); + void checkDetectorVersionCompatibility(); /** * Get ID or version numbers @@ -304,18 +288,17 @@ class slsDetector : public virtual slsDetectorDefs{ * @param args_size size of argument * @param retval return pointers * @param retval_size size of return value - * @returns success or failure */ - int sendToDetector(int fnum, const void *args, size_t args_size, + void sendToDetector(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size); template - int sendToDetector(int fnum, const Arg &args, Ret &retval); + void sendToDetector(int fnum, const Arg &args, Ret &retval); template - int sendToDetector(int fnum, const Arg &args, std::nullptr_t); + void sendToDetector(int fnum, const Arg &args, std::nullptr_t); template - int sendToDetector(int fnum, std::nullptr_t, Ret & retval); - int sendToDetector(int fnum); + void sendToDetector(int fnum, std::nullptr_t, Ret & retval); + void sendToDetector(int fnum); /** * Send function parameters to detector (stop server) @@ -324,19 +307,18 @@ class slsDetector : public virtual slsDetectorDefs{ * @param args_size size of argument * @param retval return pointers * @param retval_size size of return value - * @returns success or failure */ - int sendToDetectorStop(int fnum, const void *args, size_t args_size, + void sendToDetectorStop(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size); template - int sendToDetectorStop(int fnum, const Arg &args, Ret &retval); + void sendToDetectorStop(int fnum, const Arg &args, Ret &retval); template - int sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t); + void sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t); template - int sendToDetectorStop(int fnum, std::nullptr_t, Ret & retval); + void sendToDetectorStop(int fnum, std::nullptr_t, Ret & retval); - int sendToDetectorStop(int fnum); + void sendToDetectorStop(int fnum); /** * Send function parameters to receiver @@ -345,18 +327,17 @@ class slsDetector : public virtual slsDetectorDefs{ * @param args_size size of argument * @param retval return pointers * @param retval_size size of return value - * @returns success or failure */ - int sendToReceiver(int fnum, const void *args, size_t args_size, + void sendToReceiver(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size); template - int sendToReceiver(int fnum, const Arg& args, Ret& retval); + void sendToReceiver(int fnum, const Arg& args, Ret& retval); template - int sendToReceiver(int fnum, const Arg& args, std::nullptr_t); + void sendToReceiver(int fnum, const Arg& args, std::nullptr_t); template - int sendToReceiver(int fnum, std::nullptr_t, Ret& retval); + void sendToReceiver(int fnum, std::nullptr_t, Ret& retval); - int sendToReceiver(int fnum); + void sendToReceiver(int fnum); /** * Free shared memory and delete shared memory structure @@ -490,21 +471,6 @@ class slsDetector : public virtual slsDetectorDefs{ */ void updateMultiSize(int detx, int dety); - /** - * Checks if the detector is online and sets the online flag - * @param online if GET_ONLINE_FLAG, only returns shared memory online flag, - * else sets the detector in online/offline state - * if OFFLINE_FLAG, (i.e. no communication to the detector - using only local structure - no data acquisition possible!); - * if ONLINE_FLAG, detector in online state (i.e. communication to the detector updating the local structure) - * @returns online/offline status - */ - int setOnline(int value = GET_ONLINE_FLAG); - - /** - * Returns the online flag - */ - int getOnlineFlag() const; - /** * Checks if each of the detector is online/offline * @returns empty string if it is online @@ -551,30 +517,20 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Exit detector server - * @returns OK or FAIL */ - int exitServer(); + void exitServer(); /** * Executes a system command on the detector server * e.g. mount an nfs disk, reboot and returns answer etc. * @param cmd command to be executed - * @returns OK or FAIL */ - int execCommand(const std::string &cmd); + void execCommand(const std::string &cmd); /** * Updates some of the shared memory receiving the data from the detector - * @returns OK */ - int updateDetectorNoWait(sls::ClientSocket &client); - - /** - * Updates some of the shared memory receiving the data from the detector - * calls updateDetectorNoWait - * @returns OK or FAIL or FORCE_RET - */ - int updateDetector(); + void updateCachedDetectorVariables(); /** * Get detector specific commands to write into config file @@ -628,9 +584,8 @@ class slsDetector : public virtual slsDetectorDefs{ * @param e_eV threshold in eV * @param isettings ev. change settings * @param tb 1 to include trimbits, 0 to exclude - * @returns OK if successful, else FAIL */ - int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb = 1); + void setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb = 1); /** * Returns the detector trimbit/settings directory \sa sharedSlsDetector @@ -649,17 +604,15 @@ class slsDetector : public virtual slsDetectorDefs{ * Loads the modules settings/trimbits reading from a specific file * file name extension is automatically generated. * @param fname specific settings/trimbits file - * returns OK or FAIL */ - int loadSettingsFile(const std::string &fname); + void loadSettingsFile(const std::string &fname); /** * Saves the modules settings/trimbits to a specific file * file name extension is automatically generated. * @param fname specific settings/trimbits file - * returns OK or FAIL */ - int saveSettingsFile(const std::string &fname); + void saveSettingsFile(const std::string &fname); /** * Get run status of the detector @@ -669,51 +622,43 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Prepares detector for acquisition (Eiger) - * @returns OK or FAIL */ - int prepareAcquisition(); + void prepareAcquisition(); /** * Start detector acquisition (Non blocking) - * @returns OK or FAIL if even one does not start properly */ - int startAcquisition(); + void startAcquisition(); /** * Stop detector acquisition - * @returns OK or FAIL */ - int stopAcquisition(); + void stopAcquisition(); /** * Give an internal software trigger to the detector (Eiger only) - * @return OK or FAIL */ - int sendSoftwareTrigger(); + void sendSoftwareTrigger(); /** * Start detector acquisition and read all data (Blocking until end of acquisition) - * @returns OK or FAIL */ - int startAndReadAll(); + void startAndReadAll(); /** * Start readout (without exposure or interrupting exposure) (Eiger store in ram) - * @returns OK or FAIL */ - int startReadOut(); + void startReadOut(); /** * Requests and receives all data from the detector (Eiger store in ram) - * @returns OK or FAIL */ - int readAll(); + void readAll(); /** * Configures in detector the destination for UDP packets - * @returns OK or FAIL */ - int configureMAC(); + void configureMAC(); /** * Set starting frame number for the next acquisition @@ -1131,40 +1076,35 @@ class slsDetector : public virtual slsDetectorDefs{ * Load dark or gain image to detector (Gotthard) * @param index image type, 0 for dark image and 1 for gain image * @param fname file name from which to load image - * @returns OK or FAIL */ - int loadImageToDetector(imageType index, const std::string &fname); + void loadImageToDetector(imageType index, const std::string &fname); /** * Called from loadImageToDetector to send the image to detector * @param index image type, 0 for dark image and 1 for gain image * @param imageVals image - * @returns OK or FAIL */ - int sendImageToDetector(imageType index, int16_t imageVals[]); + void sendImageToDetector(imageType index, int16_t imageVals[]); /** * Writes the counter memory block from the detector (Gotthard) * @param fname file name to load data from * @param startACQ is 1 to start acquisition after reading counter - * @returns OK or FAIL */ - int writeCounterBlockFile(const std::string &fname, int startACQ = 0); + void writeCounterBlockFile(const std::string &fname, int startACQ = 0); /** * Gets counter memory block in detector (Gotthard) * @param image counter memory block from detector * @param startACQ 1 to start acquisition afterwards, else 0 - * @returns OK or FAIL */ - int getCounterBlock(int16_t image[], int startACQ = 0); + void getCounterBlock(int16_t image[], int startACQ = 0); /** * Resets counter in detector * @param startACQ is 1 to start acquisition after resetting counter - * @returns OK or FAIL */ - int resetCounterBlock(int startACQ = 0); + void resetCounterBlock(int startACQ = 0); /** * Set/get counter bit in detector (Gotthard) @@ -1178,9 +1118,8 @@ class slsDetector : public virtual slsDetectorDefs{ * At the moment only one set allowed * @param n number of rois * @param roiLimits array of roi - * @returns OK or FAIL */ - int setROI(int n = -1, ROI roiLimits[] = nullptr); + void setROI(int n = -1, ROI roiLimits[] = nullptr); /** * Get ROI from each detector and convert it to the multi detector scale (Gotthard) @@ -1200,9 +1139,8 @@ class slsDetector : public virtual slsDetectorDefs{ * from setROI * @param n number of ROIs (-1 to get) * @param roiLimits ROI - * @returns OK or FAIL */ - int sendROI(int n = -1, ROI roiLimits[] = nullptr); + void sendROI(int n = -1, ROI roiLimits[] = nullptr); /** * Set ADC Enable Mask (CTB, Moench) @@ -1291,9 +1229,8 @@ class slsDetector : public virtual slsDetectorDefs{ * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users * @param addr address of adc register * @param val value - * @returns return value (mostly -1 as it can't read adc register) */ - int writeAdcRegister(uint32_t addr, uint32_t val); + void writeAdcRegister(uint32_t addr, uint32_t val); /** * Activates/Deactivates the detector (Eiger only) @@ -1361,25 +1298,22 @@ class slsDetector : public virtual slsDetectorDefs{ * @param n is number of times to pulse * @param x is x coordinate * @param y is y coordinate - * @returns OK or FAIL */ - int pulsePixel(int n = 0, int x = 0, int y = 0); + void pulsePixel(int n = 0, int x = 0, int y = 0); /** * Pulse Pixel and move by a relative value (Eiger) * @param n is number of times to pulse * @param x is relative x value * @param y is relative y value - * @returns OK or FAIL */ - int pulsePixelNMove(int n = 0, int x = 0, int y = 0); + void pulsePixelNMove(int n = 0, int x = 0, int y = 0); /** * Pulse Chip (Eiger) * @param n is number of times to pulse - * @returns OK or FAIL */ - int pulseChip(int n_pulses = 0); + void pulseChip(int n_pulses = 0); /** * Set/gets threshold temperature (Jungfrau) @@ -1412,29 +1346,25 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Programs FPGA with pof file (Jungfrau, CTB, Moench) * @param buffer programming file in memory - * @returns OK or FAIL */ - int programFPGA(std::vector buffer); + void programFPGA(std::vector buffer); /** * Resets FPGA (Jungfrau) - * @returns OK or FAIL */ - int resetFPGA(); + void resetFPGA(); /** * Copies detector server from tftp and changes respawn server (Not Eiger) * @param fname name of detector server binary * @param hostname name of pc to tftp from - * @returns OK or FAIL */ - int copyDetectorServer(const std::string &fname, const std::string &hostname); + void copyDetectorServer(const std::string &fname, const std::string &hostname); /** * Reboot detector controller (blackfin/ powerpc) - * @returns OK or FAIL */ - int rebootController(); + void rebootController(); /** * Power on/off Chip (Jungfrau) @@ -1463,10 +1393,9 @@ class slsDetector : public virtual slsDetectorDefs{ * @param module module to be set - must contain correct module number and * also channel and chip registers * @param tb 1 to include trimbits, 0 to exclude (used for eiger) - * @returns ok or fail * \sa ::sls_detector_module */ - int setModule(sls_detector_module& module, int tb = 1); + void setModule(sls_detector_module& module, int tb = 1); /** * Get module structure from detector (all detectors) @@ -1479,9 +1408,8 @@ class slsDetector : public virtual slsDetectorDefs{ * @param t dead time in ns - if 0 disable correction, * if >0 set dead time to t, if < 0 set deadtime to default dead time * for current settings - * @returns 0 if rate correction disabled, >0 otherwise */ - int setRateCorrection(int64_t t = 0); + void setRateCorrection(int64_t t = 0); /** * Get rate correction (Eiger) @@ -1502,15 +1430,10 @@ class slsDetector : public virtual slsDetectorDefs{ */ void printReceiverConfiguration(TLogLevel level = logINFO); - /** - * Checks if receiver is online and set flag - * Also initializes the data socekt - * @param online 1 to set online, 0 to set offline, -1 gets - * @returns online, offline (from shared memory) + /** + * Gets the use receiver flag from shared memory */ - int setReceiverOnline(int value = GET_ONLINE_FLAG); - - int getReceiverOnlineFlag() const; + bool getUseReceiverFlag() const; /** * Checks if the receiver is really online @@ -1533,29 +1456,20 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Exits the receiver TCP server - * @retutns OK or FAIL */ - int exitReceiver(); + void exitReceiver(); /** * Executes a system command on the receiver server * e.g. mount an nfs disk, reboot and returns answer etc. * @param cmd command to be executed - * @returns OK or FAIL */ - int execReceiverCommand(const std::string &cmd); - - /** - updates the shared memory receiving the data from the detector (without asking and closing the connection - /returns OK - */ - // int updateReceiverNoWait(sls::ClientSocket &receiver); + void execReceiverCommand(const std::string &cmd); /** * Updates the shared memory receiving the data from the detector - * @returns OK or FAIL */ - int updateCachedReceiverVariables() const; + void updateCachedReceiverVariables() const; /** * Send the multi detector size to the detector @@ -1660,15 +1574,13 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Receiver starts listening to packets - * @returns OK or FAIL */ - int startReceiver(); + void startReceiver(); /** * Stops the listening mode of receiver - * @returns OK or FAIL */ - int stopReceiver(); + void stopReceiver(); /** * Gets the status of the listening mode of receiver @@ -1691,9 +1603,8 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Resets framescaught in receiver * Use this when using startAcquisition instead of acquire - * @returns OK or FAIL */ - int resetFramesCaught(); + void resetFramesCaught(); /** * Sets/Gets receiver file write enable @@ -1786,9 +1697,8 @@ class slsDetector : public virtual slsDetectorDefs{ * restream the stop dummy packet from receiver * Used usually for Moench, * in case it is lost in network due to high data rate - * @returns OK if success else FAIL */ - int restreamStopFromReceiver(); + void restreamStopFromReceiver(); /** * Opens pattern file and sends pattern to CTB @@ -1848,9 +1758,8 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Sets the mask applied to every pattern (CTB/ Moench) * @param mask mask to be applied - * @returns OK or FAIL */ - int setPatternMask(uint64_t mask); + void setPatternMask(uint64_t mask); /** * Gets the mask applied to every pattern (CTB/ Moench) @@ -1861,9 +1770,8 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Selects the bits that the mask will be applied to for every pattern (CTB/ Moench) * @param mask mask to select bits - * @returns OK or FAIL */ - int setPatternBitMask(uint64_t mask); + void setPatternBitMask(uint64_t mask); /** * Gets the bits that the mask will be applied to for every pattern (CTB/ Moench) @@ -1882,9 +1790,8 @@ class slsDetector : public virtual slsDetectorDefs{ * Set Digital IO Delay (Moench, CTB only) * @param digital IO mask to select the pins * @param delay delay in ps(1 bit=25ps, max of 775 ps) - * @returns OK or FAIL */ - int setDigitalIODelay(uint64_t pinMask, int delay); + void setDigitalIODelay(uint64_t pinMask, int delay); private: /** @@ -1929,9 +1836,8 @@ class slsDetector : public virtual slsDetectorDefs{ /** * Get MAC from the receiver using udpip and * set up UDP connection in detector - * @returns Ok or FAIL */ - int setUDPConnection(); + void setUDPConnection(); /* * Template function to do linear interpolation between two points (Eiger only) @@ -1973,9 +1879,8 @@ class slsDetector : public virtual slsDetectorDefs{ * writes a trim/settings file * @param fname name of the file to be written * @param mod module structure which has to be written to file - * @returns OK or FAIL if the file could not be written */ - int writeSettingsFile(const std::string &fname, sls_detector_module& mod); + void writeSettingsFile(const std::string &fname, sls_detector_module& mod); /** * Get Names of dacs in settings file diff --git a/slsDetectorSoftware/include/slsDetectorUsers.h b/slsDetectorSoftware/include/slsDetectorUsers.h index e29f44ce6..d05c0f96c 100755 --- a/slsDetectorSoftware/include/slsDetectorUsers.h +++ b/slsDetectorSoftware/include/slsDetectorUsers.h @@ -129,24 +129,6 @@ public: */ std::string getDetectorType(int detPos = -1); - /** - * Sets/Checks the detectors in multi detector list to online/offline - * Must be called before communicating with detector - * @param online 1 to set detector online, 0 to set it offline, -1 to get - * @param detPos -1 for all detectors in list or specific detector position - * @returns (1)online/(0)offline status - */ - int setOnline(int const online = -1, int detPos = -1); - - /** - * Sets/Checks the receivers in multi detector list to online/offline - * Must be called before communicating with receiver - * @param online 1 to set receiver online, 0 to set it receiver, -1 to get - * @param detPos -1 for all detectors in list or specific detector position - * @returns (1)online/(0)offline status - */ - int setReceiverOnline(int const online = -1, int detPos = -1); - /** * Load configuration from a configuration File (for one time detector setup) * @param fname configuration file name @@ -213,16 +195,14 @@ public: /** * Check Detector Version Compatibility * @param detPos -1 for all detectors in list or specific detector position - * @returns true if compatible, else false */ - bool isDetectorVersionCompatible(int detPos = -1); + void isDetectorVersionCompatible(int detPos = -1); /** * Check Receiver Version Compatibility * @param detPos -1 for all detectors in list or specific detector position - * @returns true if compatible, else false */ - bool isReceiverVersionCompatible(int detPos = -1); + void isReceiverVersionCompatible(int detPos = -1); /** * Performs a complete acquisition @@ -236,9 +216,8 @@ public: /** * Stop detector acquisition * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int stopMeasurement(int detPos = -1); + void stopMeasurement(int detPos = -1); /** * Get Detector run status @@ -251,24 +230,21 @@ public: * (Advanced user, included in startMeasurement) * Start detector acquisition (Non blocking) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL if even one does not start properly */ - int startAcquisition(int detPos = -1); + void startAcquisition(int detPos = -1); /** * Stop detector acquisition (Same as stopMeasurement) * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int stopAcquisition(int detPos = -1); + void stopAcquisition(int detPos = -1); /** * (Only in non blocking acquire mode) * Give an internal software trigger to the detector (Eiger) * @param detPos -1 for all detectors in list or specific detector position - * @return OK or FAIL */ - int sendSoftwareTrigger(int detPos = -1); + void sendSoftwareTrigger(int detPos = -1); /** * Set Rate correction ( Eiger) @@ -534,9 +510,8 @@ public: * @param n number of rois * @param roiLimits array of roi * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int setROI(int n=-1, slsDetectorDefs::ROI roiLimits[]=NULL, int detPos = -1); + void setROI(int n=-1, slsDetectorDefs::ROI roiLimits[]=NULL, int detPos = -1); /** * Get ROI from each detector and convert it to the multi detector scale (Gotthard) @@ -559,17 +534,15 @@ public: * (Advanced user, included in startMeasurement) * Receiver starts listening to packets * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int startReceiver(int detPos = -1); + void startReceiver(int detPos = -1); /** * (Advanced user, included in startMeasurement) * Stops the listening mode of receiver * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int stopReceiver(int detPos = -1); + void stopReceiver(int detPos = -1); /** * Set/get receiver silent mode @@ -584,9 +557,8 @@ public: * Resets framescaught in receiver * Use this when using startAcquisition instead of acquire * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int resetFramesCaughtInReceiver(int detPos = -1); + void resetFramesCaughtInReceiver(int detPos = -1); /** * (Advanced user) diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index e123db611..ccfb75f22 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -182,22 +182,20 @@ bool multiSlsDetector::isAcquireReady() { return OK != 0u; } -int multiSlsDetector::checkDetectorVersionCompatibility(int detPos) { +void multiSlsDetector::checkDetectorVersionCompatibility(int detPos) { if (detPos >= 0) { - return detectors[detPos]->checkDetectorVersionCompatibility(); + detectors[detPos]->checkDetectorVersionCompatibility(); } - auto r = parallelCall(&slsDetector::checkDetectorVersionCompatibility); - return sls::minusOneIfDifferent(r); + parallelCall(&slsDetector::checkDetectorVersionCompatibility); } -int multiSlsDetector::checkReceiverVersionCompatibility(int detPos) { +void multiSlsDetector::checkReceiverVersionCompatibility(int detPos) { if (detPos >= 0) { - return detectors[detPos]->checkReceiverVersionCompatibility(); + detectors[detPos]->checkReceiverVersionCompatibility(); } - auto r = parallelCall(&slsDetector::checkReceiverVersionCompatibility); - return sls::minusOneIfDifferent(r); + parallelCall(&slsDetector::checkReceiverVersionCompatibility); } int64_t multiSlsDetector::getId(idMode mode, int detPos) { @@ -312,7 +310,6 @@ void multiSlsDetector::initializeDetectorStructure() { multi_shm()->numberOfDetectors = 0; multi_shm()->numberOfDetector[X] = 0; multi_shm()->numberOfDetector[Y] = 0; - multi_shm()->onlineFlag = 1; multi_shm()->stoppedFlag = 0; multi_shm()->dataBytes = 0; multi_shm()->dataBytesInclGapPixels = 0; @@ -421,7 +418,6 @@ void multiSlsDetector::addMultipleDetectors(const char *name) { addSlsDetector(hostname); } - setOnline(); updateOffsets(); } @@ -451,7 +447,6 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) { multi_shm()->numberOfChannels += detectors[pos]->getTotalNumberOfChannels(); detectors[pos]->setHostname(hostname); - detectors[pos]->setOnline(1); } void multiSlsDetector::addSlsDetector(std::unique_ptr det) { @@ -725,29 +720,6 @@ void multiSlsDetector::updateOffsets() { } } -int multiSlsDetector::setOnline(int value, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setOnline(value); - } - - // multi - if (value != GET_ONLINE_FLAG) { - auto r = parallelCall(&slsDetector::setOnline, value); - multi_shm()->onlineFlag = sls::minusOneIfDifferent(r); - } - return multi_shm()->onlineFlag; -} - -int multiSlsDetector::getOnlineFlag(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getOnlineFlag(); - } - - auto r = serialCall(&slsDetector::getOnlineFlag); - return sls::minusOneIfDifferent(r); -} - std::string multiSlsDetector::checkOnline(int detPos) { if (detPos >= 0) { return detectors[detPos]->checkOnline(); @@ -809,20 +781,18 @@ std::string multiSlsDetector::getLastClientIP(int detPos) { return sls::concatenateIfDifferent(r); } -int multiSlsDetector::exitServer(int detPos) { +void multiSlsDetector::exitServer(int detPos) { if (detPos >= 0) { - return detectors[detPos]->exitServer(); + detectors[detPos]->exitServer(); } - auto r = parallelCall(&slsDetector::exitServer); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::exitServer); } -int multiSlsDetector::execCommand(const std::string &cmd, int detPos) { +void multiSlsDetector::execCommand(const std::string &cmd, int detPos) { if (detPos >= 0) { - return detectors[detPos]->execCommand(cmd); + detectors[detPos]->execCommand(cmd); } - auto r = parallelCall(&slsDetector::execCommand, cmd); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::execCommand, cmd); } void multiSlsDetector::readConfigurationFile(const std::string &fname) { @@ -949,26 +919,24 @@ std::string multiSlsDetector::setSettingsDir(const std::string &directory, return sls::concatenateIfDifferent(r); } -int multiSlsDetector::loadSettingsFile(const std::string &fname, int detPos) { +void multiSlsDetector::loadSettingsFile(const std::string &fname, int detPos) { // single if (detPos >= 0) { return detectors[detPos]->loadSettingsFile(fname); } // multi - auto r = parallelCall(&slsDetector::loadSettingsFile, fname); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::loadSettingsFile, fname); } -int multiSlsDetector::saveSettingsFile(const std::string &fname, int detPos) { +void multiSlsDetector::saveSettingsFile(const std::string &fname, int detPos) { // single if (detPos >= 0) { return detectors[detPos]->saveSettingsFile(fname); } // multi - auto r = parallelCall(&slsDetector::saveSettingsFile, fname); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::saveSettingsFile, fname); } slsDetectorDefs::runStatus multiSlsDetector::getRunStatus(int detPos) { @@ -993,39 +961,33 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus(int detPos) { return IDLE; } -int multiSlsDetector::prepareAcquisition(int detPos) { +void multiSlsDetector::prepareAcquisition(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->prepareAcquisition(); + detectors[detPos]->prepareAcquisition(); } // multi - auto r = parallelCall(&slsDetector::prepareAcquisition); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::prepareAcquisition); } -int multiSlsDetector::startAcquisition(int detPos) { +void multiSlsDetector::startAcquisition(int detPos) { // single if (detPos >= 0) { if (detectors[detPos]->getDetectorTypeAsEnum() == EIGER) { - if (detectors[detPos]->prepareAcquisition() == FAIL) { - return FAIL; - } + detectors[detPos]->prepareAcquisition(); } - return detectors[detPos]->startAcquisition(); + detectors[detPos]->startAcquisition(); } // multi if (getDetectorTypeAsEnum() == EIGER) { - if (prepareAcquisition() == FAIL) { - return FAIL; - } + prepareAcquisition(); } - auto r = parallelCall(&slsDetector::startAcquisition); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::startAcquisition); } -int multiSlsDetector::stopAcquisition(int detPos) { +void multiSlsDetector::stopAcquisition(int detPos) { // locks to synchronize using client->receiver simultaneously (processing // thread) std::lock_guard lock(mg); @@ -1035,77 +997,67 @@ int multiSlsDetector::stopAcquisition(int detPos) { multi_shm()->stoppedFlag = 1; } - return detectors[detPos]->stopAcquisition(); + detectors[detPos]->stopAcquisition(); } else { multi_shm()->stoppedFlag = 1; - auto r = parallelCall(&slsDetector::stopAcquisition); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::stopAcquisition); } } -int multiSlsDetector::sendSoftwareTrigger(int detPos) { +void multiSlsDetector::sendSoftwareTrigger(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->sendSoftwareTrigger(); + detectors[detPos]->sendSoftwareTrigger(); } // multi - auto r = parallelCall(&slsDetector::sendSoftwareTrigger); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::sendSoftwareTrigger); } -int multiSlsDetector::startAndReadAll(int detPos) { +void multiSlsDetector::startAndReadAll(int detPos) { // single if (detPos >= 0) { if (detectors[detPos]->getDetectorTypeAsEnum() == EIGER) { - if (detectors[detPos]->prepareAcquisition() == FAIL) { - return FAIL; - } + detectors[detPos]->prepareAcquisition(); } - return detectors[detPos]->startAndReadAll(); + detectors[detPos]->startAndReadAll(); } // multi if (getDetectorTypeAsEnum() == EIGER) { - if (prepareAcquisition() == FAIL) { - return FAIL; - } + prepareAcquisition(); } - auto r = parallelCall(&slsDetector::startAndReadAll); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::startAndReadAll); } -int multiSlsDetector::startReadOut(int detPos) { +void multiSlsDetector::startReadOut(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->startReadOut(); + detectors[detPos]->startReadOut(); } // multi - auto r = parallelCall(&slsDetector::startReadOut); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::startReadOut); } -int multiSlsDetector::readAll(int detPos) { +void multiSlsDetector::readAll(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->readAll(); + detectors[detPos]->readAll(); } // multi - auto r = parallelCall(&slsDetector::readAll); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::readAll); } -int multiSlsDetector::configureMAC(int detPos) { +void multiSlsDetector::configureMAC(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->configureMAC(); + detectors[detPos]->configureMAC(); } // multi - auto r = parallelCall(&slsDetector::configureMAC); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::configureMAC); } void multiSlsDetector::setStartingFrameNumber(const uint64_t value, @@ -2134,12 +2086,12 @@ int multiSlsDetector::digitalTest(digitalTestMode mode, int ival, int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::loadImageToDetector(imageType index, +void multiSlsDetector::loadImageToDetector(imageType index, const std::string &fname, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->loadImageToDetector(index, fname); + detectors[detPos]->loadImageToDetector(index, fname); } // multi @@ -2153,56 +2105,36 @@ int multiSlsDetector::loadImageToDetector(imageType index, } // send image to all - std::vector r; for (size_t idet = 0; idet < detectors.size(); ++idet) { - r.push_back(detectors[idet]->sendImageToDetector( - index, - imageVals + idet * detectors[idet]->getTotalNumberOfChannels())); + detectors[idet]->sendImageToDetector(index, imageVals + idet * detectors[idet]->getTotalNumberOfChannels()); } - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; } -int multiSlsDetector::writeCounterBlockFile(const std::string &fname, +void multiSlsDetector::writeCounterBlockFile(const std::string &fname, int startACQ, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->writeCounterBlockFile(fname, startACQ); + detectors[detPos]->writeCounterBlockFile(fname, startACQ); } // multi - - // get image from all int nch = multi_shm()->numberOfChannels; short int imageVals[nch]; - std::vector r; for (size_t idet = 0; idet < detectors.size(); ++idet) { - r.push_back(detectors[idet]->getCounterBlock( + detectors[idet]->getCounterBlock( imageVals + idet * detectors[idet]->getTotalNumberOfChannels(), - startACQ)); + startACQ); } - - // write image if all ok - if (sls::allEqualTo(r, static_cast(OK))) { - 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."); - } - return OK; - } - return FAIL; } -int multiSlsDetector::resetCounterBlock(int startACQ, int detPos) { +void multiSlsDetector::resetCounterBlock(int startACQ, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->resetCounterBlock(startACQ); + detectors[detPos]->resetCounterBlock(startACQ); } // multi - auto r = parallelCall(&slsDetector::resetCounterBlock, startACQ); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::resetCounterBlock, startACQ); } int multiSlsDetector::setCounterBit(int i, int detPos) { @@ -2232,10 +2164,10 @@ void multiSlsDetector::verifyMinMaxROI(int n, ROI r[]) { } } -int multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) { +void multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setROI(n, roiLimits); + detectors[detPos]->setROI(n, roiLimits); } // multi @@ -2252,7 +2184,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) { } if ((n < 0) || (roiLimits == nullptr)) { - return FAIL; + throw RuntimeError("Cannot set ROI due to Invalid ROI"); } // ensures min < max @@ -2371,12 +2303,9 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) { } // settings the rois for each detector - std::vector r; - r.reserve(detectors.size()); for (size_t i = 0; i != detectors.size(); ++i) { - r.push_back(detectors[i]->setROI(nroi[i], allroi[i])); + detectors[i]->setROI(nroi[i], allroi[i]); } - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; } const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) { @@ -2645,16 +2574,15 @@ int multiSlsDetector::getReceiverDbitOffset(int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::writeAdcRegister(uint32_t addr, uint32_t val, +void multiSlsDetector::writeAdcRegister(uint32_t addr, uint32_t val, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->writeAdcRegister(addr, val); + detectors[detPos]->writeAdcRegister(addr, val); } // multi - auto r = parallelCall(&slsDetector::writeAdcRegister, addr, val); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::writeAdcRegister, addr, val); } int multiSlsDetector::activate(int const enable, int detPos) { @@ -2762,37 +2690,34 @@ std::vector multiSlsDetector::getTrimEn(int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::pulsePixel(int n, int x, int y, int detPos) { +void multiSlsDetector::pulsePixel(int n, int x, int y, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->pulsePixel(n, x, y); + detectors[detPos]->pulsePixel(n, x, y); } // multi - auto r = parallelCall(&slsDetector::pulsePixel, n, x, y); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::pulsePixel, n, x, y); } -int multiSlsDetector::pulsePixelNMove(int n, int x, int y, int detPos) { +void multiSlsDetector::pulsePixelNMove(int n, int x, int y, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->pulsePixelNMove(n, x, y); + detectors[detPos]->pulsePixelNMove(n, x, y); } // multi - auto r = parallelCall(&slsDetector::pulsePixelNMove, n, x, y); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::pulsePixelNMove, n, x, y); } -int multiSlsDetector::pulseChip(int n, int detPos) { +void multiSlsDetector::pulseChip(int n, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->pulseChip(n); + detectors[detPos]->pulseChip(n); } // multi - auto r = parallelCall(&slsDetector::pulseChip, n); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::pulseChip, n); } int multiSlsDetector::setThresholdTemperature(int val, int detPos) { @@ -2839,61 +2764,57 @@ int multiSlsDetector::setStoragecellStart(int pos, int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::programFPGA(const std::string &fname, int detPos) { +void multiSlsDetector::programFPGA(const std::string &fname, int detPos) { FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; // read pof file std::vector buffer = readPofFile(fname); // single if (detPos >= 0) { - return detectors[detPos]->programFPGA(buffer); + detectors[detPos]->programFPGA(buffer); } // multi - auto r = parallelCall(&slsDetector::programFPGA, buffer); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::programFPGA, buffer); } -int multiSlsDetector::resetFPGA(int detPos) { +void multiSlsDetector::resetFPGA(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->resetFPGA(); + detectors[detPos]->resetFPGA(); } // multi - auto r = parallelCall(&slsDetector::resetFPGA); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::resetFPGA); } -int multiSlsDetector::copyDetectorServer(const std::string &fname, +void multiSlsDetector::copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos) { // single if (detPos >= 0) { detectors[detPos]->copyDetectorServer(fname, hostname); - return detectors[detPos] - ->rebootController(); // reboot and copy should be independant for + detectors[detPos]->rebootController(); + // reboot and copy should be independant for // update command } // multi parallelCall(&slsDetector::copyDetectorServer, fname, hostname); - auto r = parallelCall(&slsDetector::rebootController); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::rebootController); } -int multiSlsDetector::rebootController(int detPos) { +void multiSlsDetector::rebootController(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->rebootController(); + detectors[detPos]->rebootController(); } // multi - auto r = parallelCall(&slsDetector::rebootController); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::rebootController); } -int multiSlsDetector::update(const std::string &sname, +void multiSlsDetector::update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos) { FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; @@ -2903,13 +2824,12 @@ int multiSlsDetector::update(const std::string &sname, // single if (detPos >= 0) { detectors[detPos]->copyDetectorServer(sname, hostname); - return detectors[detPos]->programFPGA(buffer); + detectors[detPos]->programFPGA(buffer); } // multi parallelCall(&slsDetector::copyDetectorServer, sname, hostname); - auto r = parallelCall(&slsDetector::programFPGA, buffer); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::programFPGA, buffer); } int multiSlsDetector::powerChip(int ival, int detPos) { @@ -2944,15 +2864,14 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::setRateCorrection(int64_t t, int detPos) { +void multiSlsDetector::setRateCorrection(int64_t t, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setRateCorrection(t); + detectors[detPos]->setRateCorrection(t); } // multi - auto r = parallelCall(&slsDetector::setRateCorrection, t); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::setRateCorrection, t); } int64_t multiSlsDetector::getRateCorrection(int detPos) { @@ -2978,26 +2897,19 @@ void multiSlsDetector::printReceiverConfiguration(TLogLevel level, int detPos) { } } -int multiSlsDetector::setReceiverOnline(int value, int detPos) { +bool multiSlsDetector::getUseReceiverFlag(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setReceiverOnline(value); + return detectors[detPos]->getUseReceiverFlag(); } // multi - auto r = parallelCall(&slsDetector::setReceiverOnline, value); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getReceiverOnlineFlag(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getReceiverOnlineFlag(); + auto r = parallelCall(&slsDetector::getUseReceiverFlag); + if (sls::allEqual(r)) { + return r.front(); + } else { + throw RuntimeError("Inconsistent Use receiver flags"); } - - // multi - auto r = parallelCall(&slsDetector::getReceiverOnlineFlag); - return sls::minusOneIfDifferent(r); } std::string multiSlsDetector::checkReceiverOnline(int detPos) { @@ -3033,26 +2945,24 @@ std::string multiSlsDetector::getReceiverLastClientIP(int detPos) { return sls::concatenateIfDifferent(r); } -int multiSlsDetector::exitReceiver(int detPos) { +void multiSlsDetector::exitReceiver(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->exitReceiver(); + detectors[detPos]->exitReceiver(); } // multi - auto r = parallelCall(&slsDetector::exitReceiver); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::exitReceiver); } -int multiSlsDetector::execReceiverCommand(const std::string &cmd, int detPos) { +void multiSlsDetector::execReceiverCommand(const std::string &cmd, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->execReceiverCommand(cmd); + detectors[detPos]->execReceiverCommand(cmd); } // multi - auto r = parallelCall(&slsDetector::execReceiverCommand, cmd); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::execReceiverCommand, cmd); } std::string multiSlsDetector::getFilePath(int detPos) { @@ -3204,26 +3114,24 @@ int multiSlsDetector::getFileIndex(int detPos) const { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::startReceiver(int detPos) { +void multiSlsDetector::startReceiver(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->startReceiver(); + detectors[detPos]->startReceiver(); } // multi - auto r = parallelCall(&slsDetector::startReceiver); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::startReceiver); } -int multiSlsDetector::stopReceiver(int detPos) { +void multiSlsDetector::stopReceiver(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->stopReceiver(); + detectors[detPos]->stopReceiver(); } // multi - auto r = parallelCall(&slsDetector::stopReceiver); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::stopReceiver); } slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(int detPos) { @@ -3285,15 +3193,14 @@ uint64_t multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) { return ((sls::sum(r)) / (int)detectors.size()); } -int multiSlsDetector::resetFramesCaught(int detPos) { +void multiSlsDetector::resetFramesCaught(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->resetFramesCaught(); + detectors[detPos]->resetFramesCaught(); } // multi - auto r = parallelCall(&slsDetector::resetFramesCaught); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::resetFramesCaught); } int multiSlsDetector::createReceivingDataSockets(const bool destroy) { @@ -3938,15 +3845,14 @@ uint64_t multiSlsDetector::setPatternWaitTime(int level, uint64_t t, return sls::minusOneIfDifferent(r); } -int multiSlsDetector::setPatternMask(uint64_t mask, int detPos) { +void multiSlsDetector::setPatternMask(uint64_t mask, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setPatternMask(mask); + detectors[detPos]->setPatternMask(mask); } // multi - auto r = parallelCall(&slsDetector::setPatternMask, mask); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::setPatternMask, mask); } uint64_t multiSlsDetector::getPatternMask(int detPos) { @@ -3962,12 +3868,11 @@ uint64_t multiSlsDetector::getPatternMask(int detPos) { } } -int multiSlsDetector::setPatternBitMask(uint64_t mask, int detPos) { +void multiSlsDetector::setPatternBitMask(uint64_t mask, int detPos) { if (detPos >= 0) { - return detectors[detPos]->setPatternBitMask(mask); + detectors[detPos]->setPatternBitMask(mask); } - auto r = parallelCall(&slsDetector::setPatternBitMask, mask); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::setPatternBitMask, mask); } uint64_t multiSlsDetector::getPatternBitMask(int detPos) { @@ -3995,16 +3900,15 @@ int multiSlsDetector::setLEDEnable(int enable, int detPos) { return sls::minusOneIfDifferent(r); } -int multiSlsDetector::setDigitalIODelay(uint64_t pinMask, int delay, +void multiSlsDetector::setDigitalIODelay(uint64_t pinMask, int delay, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setDigitalIODelay(pinMask, delay); + detectors[detPos]->setDigitalIODelay(pinMask, delay); } // multi - auto r = parallelCall(&slsDetector::setDigitalIODelay, pinMask, delay); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::setDigitalIODelay, pinMask, delay); } int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1, @@ -4209,7 +4113,7 @@ void multiSlsDetector::registerDataCallback( void *pArg) { dataReady = userCallback; pCallbackArg = pArg; - if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { + if (getUseReceiverFlag()) { if (dataReady == nullptr) { enableDataStreamingToClient(0); enableDataStreamingFromReceiver(0); @@ -4282,7 +4186,7 @@ int multiSlsDetector::acquire() { // process) sem_init(&sem_endRTAcquisition, 1, 0); - bool receiver = (setReceiverOnline() == ONLINE_FLAG); + bool receiver = getUseReceiverFlag(); progressIndex = 0; multi_shm()->stoppedFlag = 0; setJoinThreadFlag(false); @@ -4291,9 +4195,7 @@ int multiSlsDetector::acquire() { if (receiver) { std::lock_guard lock(mg); if (getReceiverStatus() != IDLE) { - if (stopReceiver() == FAIL) { - multi_shm()->stoppedFlag = 1; - } + stopReceiver(); } } @@ -4302,19 +4204,13 @@ int multiSlsDetector::acquire() { // resets frames caught in receiver if (receiver && multi_shm()->stoppedFlag == 0) { std::lock_guard lock(mg); - if (resetFramesCaught() == FAIL) { - multi_shm()->stoppedFlag = 1; - } + resetFramesCaught(); } // start receiver if (receiver && multi_shm()->stoppedFlag == 0) { std::lock_guard lock(mg); - if (startReceiver() == FAIL) { - FILE_LOG(logERROR) << "Start receiver failed "; - stopReceiver(); - multi_shm()->stoppedFlag = 1; - } + startReceiver(); // let processing thread listen to these packets if (multi_shm()->stoppedFlag == 0) sem_post(&sem_newRTAcquisition); @@ -4326,15 +4222,13 @@ int multiSlsDetector::acquire() { // stop receiver if (receiver) { std::lock_guard lock(mg); - if (stopReceiver() == FAIL) { - multi_shm()->stoppedFlag = 1; - } else { + stopReceiver(); if (dataReady != nullptr) { sem_wait(&sem_endRTAcquisition); // waits for receiver's } // external process to be // done sending data to gui - } + incrementFileIndex(); } @@ -4372,9 +4266,7 @@ void multiSlsDetector::startProcessingThread() { } void multiSlsDetector::processData() { - if (setReceiverOnline() == OFFLINE_FLAG) { - return; - } else { + if (getUseReceiverFlag()) { if (dataReady != nullptr) { readFrameFromReceiver(); } @@ -4391,7 +4283,7 @@ void multiSlsDetector::processData() { } } // get progress - if (setReceiverOnline() == ONLINE_FLAG) { + { std::lock_guard lock(mg); caught = getFramesCaughtByReceiver(0); } diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index d1ae54317..769cdb6b7 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -54,10 +54,8 @@ slsDetector::slsDetector(int multi_id, int det_id, bool verify) slsDetector::~slsDetector() = default; -int slsDetector::checkDetectorVersionCompatibility() { - // TODO! Verify that this works as intended when version don't match +void slsDetector::checkDetectorVersionCompatibility() { int fnum = F_CHECK_VERSION; - int ret = FAIL; int64_t arg = 0; // get api version number for detector server @@ -85,42 +83,17 @@ int slsDetector::checkDetectorVersionCompatibility() { << "Checking version compatibility with detector with value " << std::hex << arg << std::dec; - // control server - if (shm()->onlineFlag == ONLINE_FLAG) { - // in case it throws - shm()->detectorControlAPIVersion = 0; - shm()->detectorStopAPIVersion = 0; - shm()->onlineFlag = OFFLINE_FLAG; - - sendToDetector(fnum, arg, nullptr); - ret = sendToDetectorStop(fnum, arg, nullptr); - - // success - shm()->detectorControlAPIVersion = arg; - shm()->detectorStopAPIVersion = arg; - shm()->onlineFlag = ONLINE_FLAG; - } - return ret; + sendToDetector(fnum, arg, nullptr); + sendToDetectorStop(fnum, arg, nullptr); } -int slsDetector::checkReceiverVersionCompatibility() { +void slsDetector::checkReceiverVersionCompatibility() { // TODO! Verify that this works as intended when version don't match - int ret = FAIL; int64_t arg = APIRECEIVER; FILE_LOG(logDEBUG1) << "Checking version compatibility with receiver with value " << std::hex << arg << std::dec; - - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - // in case it throws - shm()->receiverAPIVersion = 0; - shm()->rxOnlineFlag = OFFLINE_FLAG; - - ret = sendToReceiver(F_RECEIVER_CHECK_VERSION, arg, nullptr); - shm()->receiverAPIVersion = arg; - shm()->rxOnlineFlag = ONLINE_FLAG; - } - return ret; + sendToReceiver(F_RECEIVER_CHECK_VERSION, arg, nullptr); } int64_t slsDetector::getId(idMode mode) { @@ -133,86 +106,80 @@ int64_t slsDetector::getId(idMode mode) { int arg = static_cast(mode); int64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting id type " << mode; - if (shm()->onlineFlag == ONLINE_FLAG) { - sendToDetector(F_GET_ID, arg, retval); - FILE_LOG(logDEBUG1) - << "Id (" << mode << "): 0x" << std::hex << retval << std::dec; - } + sendToDetector(F_GET_ID, arg, retval); + FILE_LOG(logDEBUG1) + << "Id (" << mode << "): 0x" << std::hex << retval << std::dec; return retval; } int64_t slsDetector::getReceiverSoftwareVersion() { FILE_LOG(logDEBUG1) << "Getting receiver software version"; int64_t retval = -1; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_GET_RECEIVER_ID, nullptr, retval); } return retval; } -int slsDetector::sendToDetector(int fnum, const void *args, size_t args_size, +void slsDetector::sendToDetector(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto ret = client.sendCommandThenRead(fnum, args, args_size, retval, retval_size); client.close(); if (ret == FORCE_UPDATE) { - ret = updateDetector(); + updateCachedDetectorVariables(); } - return ret; } template -int slsDetector::sendToDetector(int fnum, const Arg &args, Ret &retval) { - return sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval)); +void slsDetector::sendToDetector(int fnum, const Arg &args, Ret &retval) { + sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval)); } template -int slsDetector::sendToDetector(int fnum, const Arg &args, std::nullptr_t) { - return sendToDetector(fnum, &args, sizeof(args), nullptr, 0); +void slsDetector::sendToDetector(int fnum, const Arg &args, std::nullptr_t) { + sendToDetector(fnum, &args, sizeof(args), nullptr, 0); } template -int slsDetector::sendToDetector(int fnum, std::nullptr_t, Ret &retval) { - return sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval)); +void slsDetector::sendToDetector(int fnum, std::nullptr_t, Ret &retval) { + sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval)); } -int slsDetector::sendToDetector(int fnum) { - return sendToDetector(fnum, nullptr, 0, nullptr, 0); +void slsDetector::sendToDetector(int fnum) { + sendToDetector(fnum, nullptr, 0, nullptr, 0); } -int slsDetector::sendToDetectorStop(int fnum, const void *args, +void slsDetector::sendToDetectorStop(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size) { auto stop = DetectorSocket(shm()->hostname, shm()->stopPort); - auto ret = - stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size); + stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size); stop.close(); - // no update on stop port - return ret; } template -int slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) { - return sendToDetectorStop(fnum, &args, sizeof(args), &retval, +void slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) { + sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval)); } template -int slsDetector::sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t) { - return sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0); +void slsDetector::sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t) { + sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0); } template -int slsDetector::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) { - return sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval)); +void slsDetector::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) { + sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval)); } -int slsDetector::sendToDetectorStop(int fnum) { - return sendToDetectorStop(fnum, nullptr, 0, nullptr, 0); +void slsDetector::sendToDetectorStop(int fnum) { + sendToDetectorStop(fnum, nullptr, 0, nullptr, 0); } -int slsDetector::sendToReceiver(int fnum, const void *args, size_t args_size, +void slsDetector::sendToReceiver(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size) { auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); @@ -220,28 +187,27 @@ int slsDetector::sendToReceiver(int fnum, const void *args, size_t args_size, retval_size); receiver.close(); if (ret == FORCE_UPDATE) { - ret = updateCachedReceiverVariables(); + updateCachedReceiverVariables(); } - return ret; } template -int slsDetector::sendToReceiver(int fnum, const Arg &args, Ret &retval) { - return sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval)); +void slsDetector::sendToReceiver(int fnum, const Arg &args, Ret &retval) { + sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval)); } template -int slsDetector::sendToReceiver(int fnum, const Arg &args, std::nullptr_t) { - return sendToReceiver(fnum, &args, sizeof(args), nullptr, 0); +void slsDetector::sendToReceiver(int fnum, const Arg &args, std::nullptr_t) { + sendToReceiver(fnum, &args, sizeof(args), nullptr, 0); } template -int slsDetector::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) { - return sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval)); +void slsDetector::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) { + sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval)); } -int slsDetector::sendToReceiver(int fnum) { - return sendToReceiver(fnum, nullptr, 0, nullptr, 0); +void slsDetector::sendToReceiver(int fnum) { + sendToReceiver(fnum, nullptr, 0, nullptr, 0); } void slsDetector::freeSharedMemory() { @@ -252,7 +218,14 @@ void slsDetector::freeSharedMemory() { void slsDetector::setHostname(const std::string &hostname) { sls::strcpy_safe(shm()->hostname, hostname.c_str()); - updateDetector(); + auto client = DetectorSocket(shm()->hostname, shm()->controlPort); + client.close(); + + FILE_LOG(logINFO) << "Checking Detector Version Compatibility"; + checkDetectorVersionCompatibility(); + + FILE_LOG(logINFO) << "Detector connecting - updating!"; + updateCachedDetectorVariables(); } std::string slsDetector::getHostname() const { return shm()->hostname; } @@ -278,7 +251,7 @@ void slsDetector::initSharedMemory(detectorType type, int multi_id, void slsDetector::initializeDetectorStructure(detectorType type) { shm()->shmversion = SLS_SHMVERSION; - shm()->onlineFlag = OFFLINE_FLAG; + shm()->controlPort = DEFAULT_PORTNO; shm()->stoppedFlag = 0; sls::strcpy_safe(shm()->hostname, DEFAULT_HOSTNAME); shm()->myDetectorType = type; @@ -286,7 +259,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) { shm()->offset[Y] = 0; shm()->multiSize[X] = 0; shm()->multiSize[Y] = 0; - shm()->controlPort = DEFAULT_PORTNO; + shm()->stopPort = DEFAULT_PORTNO + 1; sls::strcpy_safe(shm()->settingsDir, getenv("HOME")); shm()->nROI = 0; @@ -329,7 +302,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) { shm()->numUDPInterfaces = 1; shm()->selectedUDPInterface = 0; - shm()->rxOnlineFlag = OFFLINE_FLAG; + shm()->useReceiverFlag = false; shm()->tenGigaEnable = 0; shm()->flippedData[X] = 0; shm()->flippedData[Y] = 0; @@ -343,9 +316,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) { shm()->rxZmqip = 0u; shm()->gappixels = 0u; memset(shm()->rxAdditionalJsonHeader, 0, MAX_STR_LENGTH); - shm()->detectorControlAPIVersion = 0; - shm()->detectorStopAPIVersion = 0; - shm()->receiverAPIVersion = 0; shm()->rxFrameDiscardMode = NO_DISCARD; shm()->rxFramePadding = true; shm()->activated = true; @@ -527,21 +497,16 @@ slsDetector::getTypeFromDetector(const std::string &hostname, int cport) { int slsDetector::setDetectorType(detectorType const type) { int fnum = F_GET_DETECTOR_TYPE; - int ret = FAIL; detectorType retval = GENERIC; FILE_LOG(logDEBUG1) << "Setting detector type to " << type; // if unspecified, then get from detector if (type == GET_DETECTOR_TYPE) { - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(fnum, nullptr, retval); + sendToDetector(fnum, nullptr, retval); shm()->myDetectorType = static_cast(retval); FILE_LOG(logDEBUG1) << "Detector Type: " << retval; - } - } else { - ret = OK; - } - if ((shm()->rxOnlineFlag == ONLINE_FLAG) && ret == OK) { + } + if (shm()->useReceiverFlag) { auto arg = static_cast(shm()->myDetectorType); retval = GENERIC; FILE_LOG(logDEBUG1) << "Sending detector type to Receiver: " << arg; @@ -624,21 +589,17 @@ int slsDetector::getNChips(dimension d) const { return shm()->nChip[d]; } int slsDetector::getQuad() { int retval = -1; FILE_LOG(logDEBUG1) << "Getting Quad Type"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_QUAD, nullptr, retval); FILE_LOG(logDEBUG1) << "Quad Type :" << retval; - } return retval; } void slsDetector::setQuad(const bool enable) { int value = enable ? 1 : 0; FILE_LOG(logDEBUG1) << "Setting Quad type to " << value; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_QUAD, value, nullptr); - } FILE_LOG(logDEBUG1) << "Setting Quad type to " << value << " in Receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr); } } @@ -658,43 +619,13 @@ void slsDetector::updateMultiSize(int detx, int dety) { shm()->multiSize[1] = dety; } -int slsDetector::setOnline(int value) { - if (value != GET_ONLINE_FLAG) { - int old_flag = shm()->onlineFlag; - shm()->onlineFlag = OFFLINE_FLAG; - - if (value == ONLINE_FLAG) { - auto client = DetectorSocket(shm()->hostname, shm()->controlPort); - client.close(); - shm()->onlineFlag = ONLINE_FLAG; - - if (old_flag == OFFLINE_FLAG) { - - // check version compatibility (first time) - if ((shm()->detectorControlAPIVersion == 0) || - (shm()->detectorStopAPIVersion == 0)) { - checkDetectorVersionCompatibility(); - } - - FILE_LOG(logINFO) << "Detector connecting - updating!"; - updateDetector(); - } - } - } - return shm()->onlineFlag; -} - -int slsDetector::getOnlineFlag() const { return shm()->onlineFlag; } - std::string slsDetector::checkOnline() { std::string retval; try { // Need both control and stop socket to work! auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto stop = DetectorSocket(shm()->hostname, shm()->stopPort); - shm()->onlineFlag = ONLINE_FLAG; } catch (...) { - shm()->onlineFlag = OFFLINE_FLAG; retval = shm()->hostname; } return retval; @@ -704,13 +635,9 @@ int slsDetector::setControlPort(int port_number) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting control port to " << port_number; if (port_number >= 0 && port_number != shm()->controlPort) { - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_PORT, port_number, retval); shm()->controlPort = retval; FILE_LOG(logDEBUG1) << "Control port: " << retval; - } else { - shm()->controlPort = port_number; - } } return shm()->controlPort; } @@ -719,13 +646,9 @@ int slsDetector::setStopPort(int port_number) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting stop port to " << port_number; if (port_number >= 0 && port_number != shm()->stopPort) { - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetectorStop(F_SET_PORT, port_number, retval); shm()->stopPort = retval; FILE_LOG(logDEBUG1) << "Stop port: " << retval; - } else { - shm()->stopPort = port_number; - } } return shm()->stopPort; } @@ -733,7 +656,7 @@ int slsDetector::setStopPort(int port_number) { int slsDetector::setReceiverPort(int port_number) { FILE_LOG(logDEBUG1) << "Setting reciever port to " << port_number; if (port_number >= 0 && port_number != shm()->rxTCPPort) { - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int retval = -1; sendToReceiver(F_SET_RECEIVER_PORT, port_number, retval); shm()->rxTCPPort = retval; @@ -755,191 +678,167 @@ int slsDetector::getStopPort() const { return shm()->stopPort; } int slsDetector::lockServer(int lock) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting detector server lock to " << lock; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_LOCK_SERVER, lock, retval); FILE_LOG(logDEBUG1) << "Lock: " << retval; - } return retval; } std::string slsDetector::getLastClientIP() { char retval[INET_ADDRSTRLEN]{}; FILE_LOG(logDEBUG1) << "Getting last client ip to detector server"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_LAST_CLIENT_IP, nullptr, retval); FILE_LOG(logDEBUG1) << "Last client IP to detector: " << retval; - } return retval; } -int slsDetector::exitServer() { - int ret = FAIL; +void slsDetector::exitServer() { FILE_LOG(logDEBUG1) << "Sending exit command to detector server"; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_EXIT_SERVER); + sendToDetector(F_EXIT_SERVER); FILE_LOG(logINFO) << "Shutting down the Detector server"; - } - return ret; } -int slsDetector::execCommand(const std::string &cmd) { - int ret = FAIL; +void slsDetector::execCommand(const std::string &cmd) { char arg[MAX_STR_LENGTH]{}; char retval[MAX_STR_LENGTH]{}; sls::strcpy_safe(arg, cmd.c_str()); FILE_LOG(logDEBUG1) << "Sending command to detector " << arg; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_EXEC_COMMAND, arg, retval); + sendToDetector(F_EXEC_COMMAND, arg, retval); if (strlen(retval) != 0u) { FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; } - } - return ret; } -int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) { - int n = 0, i32 = 0; - int64_t i64 = 0; - char lastClientIP[INET_ADDRSTRLEN] = {0}; - n += client.Receive(lastClientIP, sizeof(lastClientIP)); - FILE_LOG(logDEBUG1) << "Updating detector last modified by " - << lastClientIP; - - // dr - n += client.Receive(&i32, sizeof(i32)); - shm()->dynamicRange = i32; - - // databytes - n += client.Receive(&i32, sizeof(i32)); - shm()->dataBytes = i32; - - // settings - if ((shm()->myDetectorType != CHIPTESTBOARD) && - (shm()->myDetectorType != MOENCH)) { - n += client.Receive(&i32, sizeof(i32)); - shm()->currentSettings = static_cast(i32); - } - - // threshold - if (shm()->myDetectorType == EIGER) { - n += client.Receive(&i32, sizeof(i32)); - shm()->currentThresholdEV = i32; - } - - // frame number - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[FRAME_NUMBER] = i64; - - // exptime - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[ACQUISITION_TIME] = i64; - - // subexptime, subdeadtime - if (shm()->myDetectorType == EIGER) { - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = i64; - - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[SUBFRAME_DEADTIME] = i64; - } - - // period - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[FRAME_PERIOD] = i64; - - // delay - if (shm()->myDetectorType != EIGER) { - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[DELAY_AFTER_TRIGGER] = i64; - } - - if (shm()->myDetectorType == JUNGFRAU) { - // storage cell - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[STORAGE_CELL_NUMBER] = i64; - - // storage cell delay - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[STORAGE_CELL_DELAY] = i64; - } - - // cycles - n += client.Receive(&i64, sizeof(i64)); - shm()->timerValue[CYCLES_NUMBER] = i64; - - // readout flags - if (shm()->myDetectorType == EIGER || - shm()->myDetectorType == CHIPTESTBOARD) { - n += client.Receive(&i32, sizeof(i32)); - shm()->roFlags = static_cast(i32); - } - - // roi - if (shm()->myDetectorType == GOTTHARD) { - n += client.Receive(&i32, sizeof(i32)); - shm()->nROI = i32; - for (int i = 0; i < shm()->nROI; ++i) { - n += client.Receive(&i32, sizeof(i32)); - shm()->roiLimits[i].xmin = i32; - n += client.Receive(&i32, sizeof(i32)); - shm()->roiLimits[i].xmax = i32; - n += client.Receive(&i32, sizeof(i32)); - shm()->roiLimits[i].ymin = i32; - n += client.Receive(&i32, sizeof(i32)); - shm()->roiLimits[i].xmax = i32; - } - } - - if (shm()->myDetectorType == CHIPTESTBOARD || - shm()->myDetectorType == MOENCH) { - // analog samples - n += client.Receive(&i64, sizeof(i64)); - if (i64 >= 0) { - shm()->timerValue[ANALOG_SAMPLES] = i64; - } - - // digital samples - n += client.Receive(&i64, sizeof(i64)); - if (i64 >= 0) { - shm()->timerValue[DIGITAL_SAMPLES] = i64; - } - - // adcmask - uint32_t u32 = 0; - n += client.Receive(&u32, sizeof(u32)); - shm()->adcEnableMask = u32; - if (shm()->myDetectorType == MOENCH) - setAdditionalJsonParameter("adcmask", std::to_string(u32)); - - // update #nchans and databytes, as it depends on #samples, adcmask, - // readoutflags - updateTotalNumberOfChannels(); - } - - if (n == 0) { - FILE_LOG(logERROR) << "Could not update detector, received 0 bytes"; - } - - return OK; -} - -int slsDetector::updateDetector() { +void slsDetector::updateCachedDetectorVariables() { int fnum = F_UPDATE_CLIENT; - int ret = FAIL; FILE_LOG(logDEBUG1) << "Sending update client to detector server"; + auto client = DetectorSocket(shm()->hostname, shm()->controlPort); + if (client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0) == FORCE_UPDATE) { + int n = 0, i32 = 0; + int64_t i64 = 0; + char lastClientIP[INET_ADDRSTRLEN] = {0}; + n += client.Receive(lastClientIP, sizeof(lastClientIP)); + FILE_LOG(logDEBUG1) << "Updating detector last modified by " + << lastClientIP; - if (shm()->onlineFlag == ONLINE_FLAG) { - auto client = DetectorSocket(shm()->hostname, shm()->controlPort); - ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); - // if it returns ok (jungfrau in programming mode), dont update - if (ret == FORCE_UPDATE) { - ret = updateDetectorNoWait(client); + // dr + n += client.Receive(&i32, sizeof(i32)); + shm()->dynamicRange = i32; + + // databytes + n += client.Receive(&i32, sizeof(i32)); + shm()->dataBytes = i32; + + // settings + if ((shm()->myDetectorType != CHIPTESTBOARD) && + (shm()->myDetectorType != MOENCH)) { + n += client.Receive(&i32, sizeof(i32)); + shm()->currentSettings = static_cast(i32); + } + + // threshold + if (shm()->myDetectorType == EIGER) { + n += client.Receive(&i32, sizeof(i32)); + shm()->currentThresholdEV = i32; + } + + // frame number + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[FRAME_NUMBER] = i64; + + // exptime + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[ACQUISITION_TIME] = i64; + + // subexptime, subdeadtime + if (shm()->myDetectorType == EIGER) { + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = i64; + + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[SUBFRAME_DEADTIME] = i64; + } + + // period + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[FRAME_PERIOD] = i64; + + // delay + if (shm()->myDetectorType != EIGER) { + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[DELAY_AFTER_TRIGGER] = i64; + } + + if (shm()->myDetectorType == JUNGFRAU) { + // storage cell + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[STORAGE_CELL_NUMBER] = i64; + + // storage cell delay + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[STORAGE_CELL_DELAY] = i64; + } + + // cycles + n += client.Receive(&i64, sizeof(i64)); + shm()->timerValue[CYCLES_NUMBER] = i64; + + // readout flags + if (shm()->myDetectorType == EIGER || + shm()->myDetectorType == CHIPTESTBOARD) { + n += client.Receive(&i32, sizeof(i32)); + shm()->roFlags = static_cast(i32); + } + + // roi + if (shm()->myDetectorType == GOTTHARD) { + n += client.Receive(&i32, sizeof(i32)); + shm()->nROI = i32; + for (int i = 0; i < shm()->nROI; ++i) { + n += client.Receive(&i32, sizeof(i32)); + shm()->roiLimits[i].xmin = i32; + n += client.Receive(&i32, sizeof(i32)); + shm()->roiLimits[i].xmax = i32; + n += client.Receive(&i32, sizeof(i32)); + shm()->roiLimits[i].ymin = i32; + n += client.Receive(&i32, sizeof(i32)); + shm()->roiLimits[i].xmax = i32; + } + } + + if (shm()->myDetectorType == CHIPTESTBOARD || + shm()->myDetectorType == MOENCH) { + // analog samples + n += client.Receive(&i64, sizeof(i64)); + if (i64 >= 0) { + shm()->timerValue[ANALOG_SAMPLES] = i64; + } + + // digital samples + n += client.Receive(&i64, sizeof(i64)); + if (i64 >= 0) { + shm()->timerValue[DIGITAL_SAMPLES] = i64; + } + + // adcmask + uint32_t u32 = 0; + n += client.Receive(&u32, sizeof(u32)); + shm()->adcEnableMask = u32; + if (shm()->myDetectorType == MOENCH) + setAdditionalJsonParameter("adcmask", std::to_string(u32)); + + // update #nchans and databytes, as it depends on #samples, adcmask, + // readoutflags + updateTotalNumberOfChannels(); + } + + if (n == 0) { + FILE_LOG(logERROR) << "Could not update detector, received 0 bytes"; } } - return ret; } + std::vector slsDetector::getConfigFileCommands() { std::vector base{"hostname", "port", "stopport", "settingsdir", "fpath", "lock", @@ -1054,12 +953,9 @@ slsDetector::sendSettingsOnly(detectorSettings isettings) { int arg = static_cast(isettings); int retval = -1; FILE_LOG(logDEBUG1) << "Setting settings to " << arg; - - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_SETTINGS, arg, retval); FILE_LOG(logDEBUG1) << "Settings: " << retval; shm()->currentSettings = static_cast(retval); - } return shm()->currentSettings; } @@ -1083,12 +979,10 @@ int slsDetector::getThresholdEnergy() { } FILE_LOG(logDEBUG1) << "Getting threshold energy"; - if (shm()->onlineFlag == ONLINE_FLAG) { int retval = -1; sendToDetector(F_GET_THRESHOLD_ENERGY, nullptr, retval); FILE_LOG(logDEBUG1) << "Threshold: " << retval; shm()->currentThresholdEV = retval; - } return shm()->currentThresholdEV; } @@ -1116,7 +1010,7 @@ int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, "Set threshold energy not implemented for this detector"); } -int slsDetector::setThresholdEnergyAndSettings(int e_eV, +void slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb) { @@ -1175,7 +1069,6 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, throw RuntimeError("setThresholdEnergyAndSettings: Could not set " "settings in detector"); } - return OK; } std::string slsDetector::getTrimbitFilename(detectorSettings s, int e_eV) { @@ -1218,7 +1111,7 @@ std::string slsDetector::setSettingsDir(const std::string &dir) { return shm()->settingsDir; } -int slsDetector::loadSettingsFile(const std::string &fname) { +void slsDetector::loadSettingsFile(const std::string &fname) { std::string fn = fname; std::ostringstream ostfn; ostfn << fname; @@ -1234,11 +1127,10 @@ int slsDetector::loadSettingsFile(const std::string &fname) { } fn = ostfn.str(); auto myMod = readSettingsFile(fn); - int ret = setModule(myMod); - return ret; + setModule(myMod); } -int slsDetector::saveSettingsFile(const std::string &fname) { +void slsDetector::saveSettingsFile(const std::string &fname) { std::string fn = fname; std::ostringstream ostfn; ostfn << fname; @@ -1250,112 +1142,76 @@ int slsDetector::saveSettingsFile(const std::string &fname) { } fn = ostfn.str(); sls_detector_module myMod = getModule(); - int ret = writeSettingsFile(fn, myMod); - return ret; + writeSettingsFile(fn, myMod); } slsDetectorDefs::runStatus slsDetector::getRunStatus() { runStatus retval = ERROR; FILE_LOG(logDEBUG1) << "Getting status"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetectorStop(F_GET_RUN_STATUS, nullptr, retval); FILE_LOG(logDEBUG1) << "Detector status: " << runStatusType(retval); - } return retval; } -int slsDetector::prepareAcquisition() { - int ret = FAIL; +void slsDetector::prepareAcquisition() { FILE_LOG(logDEBUG1) << "Preparing Detector for Acquisition"; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_PREPARE_ACQUISITION); + sendToDetector(F_PREPARE_ACQUISITION); FILE_LOG(logDEBUG1) << "Prepare Acquisition successful"; - } - return ret; } -int slsDetector::startAcquisition() { - int ret = FAIL; +void slsDetector::startAcquisition() { FILE_LOG(logDEBUG1) << "Starting Acquisition"; shm()->stoppedFlag = 0; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_START_ACQUISITION); + sendToDetector(F_START_ACQUISITION); FILE_LOG(logDEBUG1) << "Starting Acquisition successful"; - } - return ret; } -int slsDetector::stopAcquisition() { +void slsDetector::stopAcquisition() { // get status before stopping acquisition runStatus s = ERROR, r = ERROR; - int ret = FAIL; if (shm()->rxUpstream) { s = getRunStatus(); r = getReceiverStatus(); } FILE_LOG(logDEBUG1) << "Stopping Acquisition"; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetectorStop(F_STOP_ACQUISITION); + sendToDetectorStop(F_STOP_ACQUISITION); FILE_LOG(logDEBUG1) << "Stopping Acquisition successful"; - } shm()->stoppedFlag = 1; // if rxr streaming and acquisition finished, restream dummy stop packet if ((shm()->rxUpstream) && (s == IDLE) && (r == IDLE)) { restreamStopFromReceiver(); } - return ret; } -int slsDetector::sendSoftwareTrigger() { - int ret = FAIL; +void slsDetector::sendSoftwareTrigger() { FILE_LOG(logDEBUG1) << "Sending software trigger"; shm()->stoppedFlag = 0; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SOFTWARE_TRIGGER); + sendToDetector(F_SOFTWARE_TRIGGER); FILE_LOG(logDEBUG1) << "Sending software trigger successful"; - } - return ret; } -int slsDetector::startAndReadAll() { - int ret = FAIL; +void slsDetector::startAndReadAll() { FILE_LOG(logDEBUG1) << "Starting and reading all frames"; shm()->stoppedFlag = 0; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_START_AND_READ_ALL); - // TODO! how to we hande this? ret == FAIL --> - // shm()->stoppedFlag = 1; + sendToDetector(F_START_AND_READ_ALL); FILE_LOG(logDEBUG1) << "Detector successfully finished acquisition"; - } - return ret; } -int slsDetector::startReadOut() { - int ret = FAIL; +void slsDetector::startReadOut() { FILE_LOG(logDEBUG1) << "Starting readout"; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_START_READOUT); + sendToDetector(F_START_READOUT); FILE_LOG(logDEBUG1) << "Starting detector readout successful"; - } - return ret; } -int slsDetector::readAll() { - int ret = FAIL; +void slsDetector::readAll() { FILE_LOG(logDEBUG1) << "Reading all frames"; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_READ_ALL); - // TODO! how to we hande this? ret == FAIL --> - // shm()->stoppedFlag = 1; + sendToDetector(F_READ_ALL); FILE_LOG(logDEBUG1) << "Detector successfully finished reading all frames"; - } - return ret; } -int slsDetector::configureMAC() { +void slsDetector::configureMAC() { int fnum = F_CONFIGURE_MAC; - int ret = FAIL; const size_t array_size = 50; const size_t n_args = 14; const size_t n_retvals = 2; @@ -1435,9 +1291,8 @@ int slsDetector::configureMAC() { FILE_LOG(logDEBUG1) << "col:" << args[13] << "-"; // send to server - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); - ret = client.sendCommandThenRead(fnum, args, sizeof(args), retvals, + int ret = client.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals)); // TODO!(Erik) Send as int already from detector @@ -1458,32 +1313,25 @@ int slsDetector::configureMAC() { FILE_LOG(logINFO) << detId << ": Detector IP updated to " << getDetectorIP(); } - } if (ret == FORCE_UPDATE) { - ret = updateDetector(); + updateCachedDetectorVariables(); } - return ret; } void slsDetector::setStartingFrameNumber(const uint64_t value) { FILE_LOG(logDEBUG1) << "Setting starting frame number to " << value; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_STARTING_FRAME_NUMBER, value, nullptr); - } } uint64_t slsDetector::getStartingFrameNumber() { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting starting frame number"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_STARTING_FRAME_NUMBER, nullptr, retval); FILE_LOG(logDEBUG1) << "Starting frame number :" << retval; - } return retval; } int64_t slsDetector::setTimer(timerIndex index, int64_t t) { - int ret = FAIL; int64_t args[]{static_cast(index), t}; int64_t retval = -1; FILE_LOG(logDEBUG1) << "Setting " << getTimerType(index) << " to " << t @@ -1491,8 +1339,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { // send to detector int64_t oldtimer = shm()->timerValue[index]; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SET_TIMER, args, retval); + sendToDetector(F_SET_TIMER, args, retval); FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval; shm()->timerValue[index] = retval; // update #nchans and databytes, as it depends on #samples, adcmask, @@ -1500,7 +1347,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { if (index == ANALOG_SAMPLES || index == DIGITAL_SAMPLES) { updateTotalNumberOfChannels(); } - } // setting timers consequences (eiger (ratecorr) ) // (a get can also change timer value, hence check difference) @@ -1519,7 +1365,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { } // send to reciever - if (shm()->rxOnlineFlag == ONLINE_FLAG && ret != FAIL) { + if (shm()->useReceiverFlag) { timerIndex rt[]{FRAME_NUMBER, FRAME_PERIOD, CYCLES_NUMBER, @@ -1564,10 +1410,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { int64_t slsDetector::getTimeLeft(timerIndex index) { int64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting " << getTimerType(index) << " left"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetectorStop(F_GET_TIME_LEFT, index, retval); FILE_LOG(logDEBUG1) << getTimerType(index) << " left: " << retval; - } return retval; } @@ -1576,24 +1420,19 @@ int slsDetector::setSpeed(speedVariable sp, int value, int mode) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting speed index " << sp << " to " << value << " mode: " << mode; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_SPEED, args, retval); FILE_LOG(logDEBUG1) << "Speed index " << sp << ": " << retval; - } return retval; } int slsDetector::setDynamicRange(int n) { // TODO! Properly handle fail - int ret = FAIL; int retval = -1; FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n; int olddr = shm()->dynamicRange; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SET_DYNAMIC_RANGE, n, retval); + sendToDetector(F_SET_DYNAMIC_RANGE, n, retval); FILE_LOG(logDEBUG1) << "Dynamic Range: " << retval; shm()->dynamicRange = retval; - } // only for eiger // setting dr consequences on databytes shm @@ -1611,7 +1450,7 @@ int slsDetector::setDynamicRange(int n) { << shm()->dataBytesInclGapPixels; } - if (shm()->rxOnlineFlag == ONLINE_FLAG && ret != FAIL) { + if (shm()->useReceiverFlag) { n = shm()->dynamicRange; retval = -1; FILE_LOG(logDEBUG1) << "Sending dynamic range to receiver: " << n; @@ -1632,22 +1471,17 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val << (mV != 0 ? "mV" : "dac units"); - - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_DAC, args, retval); FILE_LOG(logDEBUG1) << "Dac index " << index << ": " << retval << (mV != 0 ? "mV" : "dac units"); - } return retval; } int slsDetector::getADC(dacIndex index) { int retval = -1; FILE_LOG(logDEBUG1) << "Getting ADC " << index; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_ADC, static_cast(index), retval); FILE_LOG(logDEBUG1) << "ADC (" << index << "): " << retval; - } return retval; } @@ -1657,11 +1491,8 @@ slsDetector::setExternalCommunicationMode(externalCommunicationMode pol) { auto arg = static_cast(pol); externalCommunicationMode retval = GET_EXTERNAL_COMMUNICATION_MODE; FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol; - - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(fnum, arg, retval); FILE_LOG(logDEBUG1) << "Timing Mode: " << retval; - } return retval; } @@ -1670,21 +1501,16 @@ slsDetector::setExternalSignalFlags(externalSignalFlag pol) { int fnum = F_SET_EXTERNAL_SIGNAL_FLAG; auto retval = GET_EXTERNAL_SIGNAL_FLAG; FILE_LOG(logDEBUG1) << "Setting signal flag to " << pol; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(fnum, pol, retval); FILE_LOG(logDEBUG1) << "Ext Signal: " << retval; - } return retval; } int slsDetector::setReadOutFlags(readOutFlags flag) { - int ret = FAIL; auto arg = static_cast(flag); readOutFlags retval = GET_READOUT_FLAGS; FILE_LOG(logDEBUG1) << "Setting readout flags to " << flag; - - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SET_READOUT_FLAGS, arg, retval); + sendToDetector(F_SET_READOUT_FLAGS, arg, retval); FILE_LOG(logDEBUG1) << "Readout flag: " << retval; shm()->roFlags = retval; // update #nchans and databytes, as it depends on #samples, adcmask, @@ -1692,18 +1518,14 @@ int slsDetector::setReadOutFlags(readOutFlags flag) { if (shm()->myDetectorType == CHIPTESTBOARD) { updateTotalNumberOfChannels(); } - } - if (ret != FAIL) { FILE_LOG(logDEBUG1) << "Setting receiver readout flags to " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int fnum = F_RECEIVER_SET_READOUT_FLAGS; - ret = FAIL; arg = shm()->roFlags; retval = static_cast(-1); sendToReceiver(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Receiver readout flag: " << retval; } - } return shm()->roFlags; } @@ -1712,22 +1534,18 @@ uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) { uint32_t retval = -1; FILE_LOG(logDEBUG1) << "Writing to reg 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_WRITE_REGISTER, args, retval); FILE_LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex << retval << std::dec; - } return retval; } uint32_t slsDetector::readRegister(uint32_t addr) { uint32_t retval = -1; FILE_LOG(logDEBUG1) << "Reading reg 0x" << std::hex << addr << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_READ_REGISTER, addr, retval); FILE_LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex << retval << std::dec; - } return retval; } @@ -1758,8 +1576,8 @@ std::string slsDetector::setDetectorMAC(const std::string &detectorMAC) { shm()->detectorMAC = addr; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return getDetectorMAC().str(); @@ -1776,8 +1594,8 @@ std::string slsDetector::setDetectorMAC2(const std::string &detectorMAC) { shm()->detectorMAC2 = addr; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return getDetectorMAC2().str(); } @@ -1793,8 +1611,8 @@ std::string slsDetector::setDetectorIP(const std::string &ip) { shm()->detectorIP = ip; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return getDetectorIP().str(); } @@ -1810,8 +1628,8 @@ std::string slsDetector::setDetectorIP2(const std::string &ip) { shm()->detectorIP2 = ip; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return getDetectorIP().str(); } @@ -1824,21 +1642,25 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) { if (receiverIP == "none") { memset(shm()->rxHostname, 0, MAX_STR_LENGTH); sls::strcpy_safe(shm()->rxHostname, "none"); - shm()->rxOnlineFlag = OFFLINE_FLAG; + shm()->useReceiverFlag = false; return std::string(shm()->rxHostname); } + // stop acquisition if running if (getRunStatus() == RUNNING) { FILE_LOG(logWARNING) << "Acquisition already running, Stopping it."; stopAcquisition(); } // update detector before receiver - updateDetector(); + updateCachedDetectorVariables(); // start updating sls::strcpy_safe(shm()->rxHostname, receiverIP.c_str()); + shm()->useReceiverFlag = true; + checkReceiverVersionCompatibility(); + + - if (setReceiverOnline(ONLINE_FLAG) == ONLINE_FLAG) { FILE_LOG(logDEBUG) << "detector type:" << (slsDetectorDefs::detectorTypeToString(shm()->myDetectorType)) @@ -1955,7 +1777,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) { enableDataStreamingFromReceiver( static_cast(enableDataStreamingFromReceiver(-1))); } - } + return std::string(shm()->rxHostname); } @@ -1972,8 +1794,8 @@ std::string slsDetector::setReceiverUDPIP(const std::string &udpip) { shm()->rxUDPIP = ip; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return getReceiverUDPIP().str(); } @@ -1989,8 +1811,8 @@ std::string slsDetector::setReceiverUDPIP2(const std::string &udpip) { shm()->rxUDPIP2 = ip; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return getReceiverUDPIP2().str(); } @@ -2023,8 +1845,8 @@ int slsDetector::setReceiverUDPPort(int udpport) { shm()->rxUDPPort = udpport; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return shm()->rxUDPPort; } @@ -2035,8 +1857,8 @@ int slsDetector::setReceiverUDPPort2(int udpport) { shm()->rxUDPPort2 = udpport; if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return shm()->rxUDPPort2; } @@ -2051,8 +1873,8 @@ int slsDetector::setNumberofUDPInterfaces(int n) { shm()->numUDPInterfaces = (n > 1 ? 2 : 1); if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return shm()->numUDPInterfaces; } @@ -2068,8 +1890,8 @@ int slsDetector::selectUDPInterface(int n) { shm()->selectedUDPInterface = (n == 0 ? 0 : 1); if (strcmp(shm()->rxHostname, "none") == 0) { FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) { - FILE_LOG(logWARNING) << "UDP connection set up failed"; + } else { + setUDPConnection(); } return shm()->selectedUDPInterface; } @@ -2089,7 +1911,7 @@ void slsDetector::setReceiverStreamingPort(int port) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending receiver streaming port to receiver: " << port; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(fnum, &port, sizeof(port), &retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Receiver streaming port: " << retval; shm()->rxZmqport = retval; @@ -2129,7 +1951,7 @@ void slsDetector::setReceiverStreamingIP(std::string sourceIP) { } // send to receiver - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { char retvals[MAX_STR_LENGTH]{}; char args[MAX_STR_LENGTH]{}; sls::strcpy_safe(args, shm()->rxZmqip.str()); //TODO send int @@ -2151,11 +1973,9 @@ int slsDetector::setDetectorNetworkParameter(networkParameter index, int retval = -1; FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to " << delay; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_NETWORK_PARAMETER, args, retval); FILE_LOG(logDEBUG1) << "Network Parameter (" << index << "): " << retval; - } return retval; } @@ -2167,7 +1987,7 @@ slsDetector::setAdditionalJsonHeader(const std::string &jsonheader) { sls::strcpy_safe(args, jsonheader.c_str()); FILE_LOG(logDEBUG1) << "Sending additional json header " << args; - if (shm()->rxOnlineFlag != ONLINE_FLAG) { + if (!shm()->useReceiverFlag) { sls::strcpy_safe(shm()->rxAdditionalJsonHeader, jsonheader.c_str()); } else { sendToReceiver(fnum, args, sizeof(args), retvals, sizeof(retvals)); @@ -2182,7 +2002,7 @@ std::string slsDetector::getAdditionalJsonHeader() { int fnum = F_GET_ADDITIONAL_JSON_HEADER; char retvals[MAX_STR_LENGTH]{}; FILE_LOG(logDEBUG1) << "Getting additional json header "; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(fnum, nullptr, 0, retvals, sizeof(retvals)); FILE_LOG(logDEBUG1) << "Additional json header: " << retvals; memset(shm()->rxAdditionalJsonHeader, 0, MAX_STR_LENGTH); @@ -2278,7 +2098,7 @@ int64_t slsDetector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize) { FILE_LOG(logDEBUG1) << "Sending UDP Socket Buffer size to receiver: " << udpsockbufsize; int64_t retval = -1; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_UDP_SOCK_BUF_SIZE, udpsockbufsize, retval); FILE_LOG(logDEBUG1) << "Receiver UDP Socket Buffer size: " << retval; } @@ -2292,7 +2112,7 @@ int64_t slsDetector::getReceiverUDPSocketBufferSize() { int64_t slsDetector::getReceiverRealUDPSocketBufferSize() { int64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size from receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, nullptr, retval); FILE_LOG(logDEBUG1) << "Real Receiver UDP Socket Buffer size: " << retval; @@ -2300,16 +2120,14 @@ int64_t slsDetector::getReceiverRealUDPSocketBufferSize() { return retval; } -int slsDetector::setUDPConnection() { - int ret = FAIL; +void slsDetector::setUDPConnection() { char args[5][MAX_STR_LENGTH]{}; char retvals[2][MAX_STR_LENGTH]{}; FILE_LOG(logDEBUG1) << "Setting UDP Connection"; // called before set up if (strcmp(shm()->rxHostname, "none") == 0) { - FILE_LOG(logDEBUG1) << "Receiver hostname not set yet."; - return FAIL; + throw RuntimeError("Cannot set udp connection. Receiver hostname not set yet."); } if (shm()->rxUDPIP == 0) { @@ -2339,8 +2157,8 @@ int slsDetector::setUDPConnection() { FILE_LOG(logDEBUG1) << "Receiver udp port: " << shm()->rxUDPPort; FILE_LOG(logDEBUG1) << "Receiver udp port2: " << shm()->rxUDPPort2; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - ret = sendToReceiver(F_SETUP_RECEIVER_UDP, args, retvals); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SETUP_RECEIVER_UDP, args, retvals); if (strlen(retvals[0]) != 0u) { FILE_LOG(logDEBUG1) << "Receiver UDP MAC returned : " << retvals[0]; shm()->rxUDPMAC = retvals[0]; @@ -2350,15 +2168,11 @@ int slsDetector::setUDPConnection() { << "Receiver UDP MAC2 returned : " << retvals[1]; shm()->rxUDPMAC2 = retvals[1]; } - // configure detector with udp details - if (configureMAC() == FAIL) { - setReceiverOnline(OFFLINE_FLAG); - } + configureMAC(); } else { throw ReceiverError("setUDPConnection: Receiver is OFFLINE"); } printReceiverConfiguration(logDEBUG1); - return ret; } int slsDetector::digitalTest(digitalTestMode mode, int ival) { @@ -2366,14 +2180,12 @@ int slsDetector::digitalTest(digitalTestMode mode, int ival) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending digital test of mode " << mode << ", ival " << ival; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_DIGITAL_TEST, args, retval); FILE_LOG(logDEBUG1) << "Digital Test returned: " << retval; - } return retval; } -int slsDetector::loadImageToDetector(imageType index, +void slsDetector::loadImageToDetector(imageType index, const std::string &fname) { int nChan = getTotalNumberOfChannels(); int16_t args[nChan]; @@ -2381,95 +2193,70 @@ int slsDetector::loadImageToDetector(imageType index, << "image from file " << fname; if (readDataFile(fname, args, nChan) != 0) { - return sendImageToDetector(index, args); + sendImageToDetector(index, args); } else { throw RuntimeError( "slsDetector::loadImageToDetector: Could not open file: " + fname); } } -int slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) { +void slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) { int fnum = F_LOAD_IMAGE; - int ret = FAIL; int nChan = getTotalNumberOfChannels(); int args[]{static_cast(index), nChan}; FILE_LOG(logDEBUG1) << "Sending image to detector"; - - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.Send(&fnum, sizeof(fnum)); client.Send(args, sizeof(args)); client.Send(imageVals, nChan * sizeof(int16_t)); + int ret = FAIL; client.Receive(&ret, sizeof(ret)); - if (ret == FAIL) { char mess[MAX_STR_LENGTH]{}; client.Receive(mess, MAX_STR_LENGTH); throw DetectorError("Detector " + std::to_string(detId) + " returned error: " + std::string(mess)); - } - } if (ret == FORCE_UPDATE) { - ret = updateDetector(); + updateCachedDetectorVariables(); } - return ret; } -int slsDetector::writeCounterBlockFile(const std::string &fname, int startACQ) { - int ret = FAIL; +void slsDetector::writeCounterBlockFile(const std::string &fname, int startACQ) { int nChan = getTotalNumberOfChannels(); int16_t retvals[nChan]; FILE_LOG(logDEBUG1) << "Reading Counter to " << fname << (startACQ != 0 ? " and Restarting Acquisition" : "\n"); - - ret = getCounterBlock(retvals, startACQ); - if (ret != FAIL) { - return writeDataFile(fname, nChan, retvals); - } else { - throw RuntimeError( - "slsDetector::writeCounterBlockFile: getCounterBlock failed"); - } + getCounterBlock(retvals, startACQ); + writeDataFile(fname, nChan, retvals); } -int slsDetector::getCounterBlock(int16_t image[], int startACQ) { +void slsDetector::getCounterBlock(int16_t image[], int startACQ) { int fnum = F_READ_COUNTER_BLOCK; - int ret = FAIL; int nChan = getTotalNumberOfChannels(); int args[] = {startACQ, nChan}; FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ; - - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(fnum, args, sizeof(args), image, + sendToDetector(fnum, args, sizeof(args), image, nChan * sizeof(int16_t)); - } - return ret; } -int slsDetector::resetCounterBlock(int startACQ) { - int ret = FAIL; +void slsDetector::resetCounterBlock(int startACQ) { FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_RESET_COUNTER_BLOCK, startACQ, nullptr); - } - return ret; + sendToDetector(F_RESET_COUNTER_BLOCK, startACQ, nullptr); } int slsDetector::setCounterBit(int cb) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending counter bit " << cb; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_COUNTER_BIT, cb, retval); FILE_LOG(logDEBUG1) << "Counter bit: " << retval; - } return retval; } -int slsDetector::setROI(int n, ROI roiLimits[]) { +void slsDetector::setROI(int n, ROI roiLimits[]) { std::sort(roiLimits, roiLimits + n, [](ROI a, ROI b) { return a.xmin < b.xmin; }); - int ret = sendROI(n, roiLimits); - return ret; + sendROI(n, roiLimits); } const slsDetectorDefs::ROI *slsDetector::getROI(int &n) { @@ -2480,7 +2267,7 @@ const slsDetectorDefs::ROI *slsDetector::getROI(int &n) { int slsDetector::getNRoi() { return shm()->nROI; } -int slsDetector::sendROI(int n, ROI roiLimits[]) { +void slsDetector::sendROI(int n, ROI roiLimits[]) { int fnum = F_SET_ROI; int ret = FAIL; int narg = n; @@ -2490,7 +2277,6 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { ROI retval[MAX_ROIS]; FILE_LOG(logDEBUG1) << "Sending ROI to detector" << narg; - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.Send(&fnum, sizeof(fnum)); client.Send(&narg, sizeof(narg)); @@ -2530,25 +2316,16 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { << shm()->roiLimits[i].ymax << ")"; } } - } else { - // detector is offline lets just update SHM - if (n != -1) { - shm()->nROI = n; - for (int i = 0; i != n; ++i) { - shm()->roiLimits[i] = roiLimits[i]; - } - } - } if (ret == FORCE_UPDATE) { - ret = updateDetector(); + updateCachedDetectorVariables(); } // old firmware requires configuremac after setting roi if (shm()->myDetectorType == GOTTHARD && n != -1) { - ret = configureMAC(); + configureMAC(); } // update roi in receiver - if (ret == OK && shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { fnum = F_RECEIVER_SET_ROI; ret = FAIL; narg = shm()->nROI; @@ -2575,20 +2352,17 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { " returned error: " + std::string(mess)); } if (ret == FORCE_UPDATE) { - ret = updateCachedReceiverVariables(); + updateCachedReceiverVariables(); } } - return ret; } void slsDetector::setADCEnableMask(uint32_t mask) { uint32_t arg = mask; FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0); shm()->adcEnableMask = mask; - } // update #nchans and databytes, as it depends on #samples, adcmask, // readoutflags @@ -2599,7 +2373,7 @@ void slsDetector::setADCEnableMask(uint32_t mask) { setAdditionalJsonParameter("adcmask", std::to_string(shm()->adcEnableMask)); - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int fnum = F_RECEIVER_SET_ADC_MASK; int retval = -1; mask = shm()->adcEnableMask; @@ -2612,32 +2386,26 @@ void slsDetector::setADCEnableMask(uint32_t mask) { uint32_t slsDetector::getADCEnableMask() { uint32_t retval = -1; FILE_LOG(logDEBUG1) << "Getting ADC Enable mask"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sizeof(retval)); shm()->adcEnableMask = retval; FILE_LOG(logDEBUG1) << "ADC Enable Mask: 0x" << std::hex << retval << std::dec; - } return shm()->adcEnableMask; } void slsDetector::setADCInvert(uint32_t value) { FILE_LOG(logDEBUG1) << "Setting ADC Invert to 0x" << std::hex << value << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_ADC_INVERT, value, nullptr); - } } uint32_t slsDetector::getADCInvert() { uint32_t retval = -1; FILE_LOG(logDEBUG1) << "Getting ADC Invert"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_ADC_INVERT, nullptr, retval); FILE_LOG(logDEBUG1) << "ADC Invert: 0x" << std::hex << retval << std::dec; - } return retval; } @@ -2645,10 +2413,8 @@ int slsDetector::setExternalSamplingSource(int value) { int arg = value; int retval = -1; FILE_LOG(logDEBUG1) << "Setting External Sampling Source to " << arg; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_EXTERNAL_SAMPLING_SOURCE, arg, retval); FILE_LOG(logDEBUG1) << "External Sampling source: " << retval; - } return retval; } @@ -2660,10 +2426,8 @@ int slsDetector::setExternalSampling(int value) { int arg = value; int retval = -1; FILE_LOG(logDEBUG1) << "Setting External Sampling to " << arg; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_EXTERNAL_SAMPLING, arg, retval); FILE_LOG(logDEBUG1) << "External Sampling: " << retval; - } return retval; } @@ -2682,7 +2446,7 @@ void slsDetector::setReceiverDbitList(std::vector list) { } } shm()->rxDbitList = list; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_DBIT_LIST, shm()->rxDbitList, nullptr); } } @@ -2690,7 +2454,7 @@ void slsDetector::setReceiverDbitList(std::vector list) { std::vector slsDetector::getReceiverDbitList() { sls::FixedCapacityContainer retval; FILE_LOG(logDEBUG1) << "Getting Receiver Dbit List"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_GET_RECEIVER_DBIT_LIST, nullptr, retval); shm()->rxDbitList = retval; } @@ -2703,7 +2467,7 @@ int slsDetector::setReceiverDbitOffset(int value) { shm()->rxDbitOffset = value; FILE_LOG(logDEBUG1) << "Setting digital bit offset in receiver to " << value; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_DBIT_OFFSET, value, retval); FILE_LOG(logDEBUG1) << "Receiver digital bit offset: " << retval; } @@ -2712,26 +2476,20 @@ int slsDetector::setReceiverDbitOffset(int value) { int slsDetector::getReceiverDbitOffset() { return shm()->rxDbitOffset; } -int slsDetector::writeAdcRegister(uint32_t addr, uint32_t val) { +void slsDetector::writeAdcRegister(uint32_t addr, uint32_t val) { uint32_t args[]{addr, val}; FILE_LOG(logDEBUG1) << "Writing to ADC register 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { - return sendToDetector(F_WRITE_ADC_REG, args, nullptr); - } - return FAIL; + sendToDetector(F_WRITE_ADC_REG, args, nullptr); } int slsDetector::activate(int enable) { - int ret = FAIL; int retval = -1; FILE_LOG(logDEBUG1) << "Setting activate flag to " << enable; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_ACTIVATE, enable, retval); + sendToDetector(F_ACTIVATE, enable, retval); FILE_LOG(logDEBUG1) << "Activate: " << retval; shm()->activated = static_cast(retval); - } - if (shm()->rxOnlineFlag == ONLINE_FLAG && ret == OK) { + if (shm()->useReceiverFlag) { int fnum = F_RECEIVER_ACTIVATE; enable = static_cast(shm()->activated); retval = -1; @@ -2746,7 +2504,7 @@ bool slsDetector::setDeactivatedRxrPaddingMode(int padding) { int fnum = F_RECEIVER_DEACTIVATED_PADDING_ENABLE; int retval = -1; FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable: " << padding; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(fnum, &padding, sizeof(padding), &retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable:" << retval; @@ -2773,7 +2531,7 @@ int slsDetector::setFlippedData(dimension d, int value) { args[1] = shm()->flippedData[d]; FILE_LOG(logDEBUG1) << "Setting flipped data across axis " << d << " with value: " << value; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, args, retval); FILE_LOG(logDEBUG1) << "Flipped data:" << retval; } @@ -2783,10 +2541,8 @@ int slsDetector::setFlippedData(dimension d, int value) { int slsDetector::setAllTrimbits(int val) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting all trimbits to " << val; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_ALL_TRIMBITS, val, retval); FILE_LOG(logDEBUG1) << "All trimbit value: " << retval; - } return retval; } @@ -2795,7 +2551,7 @@ int slsDetector::enableGapPixels(int val) { int fnum = F_ENABLE_GAPPIXELS_IN_RECEIVER; int retval = -1; FILE_LOG(logDEBUG1) << "Sending gap pixels enable to receiver: " << val; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(fnum, &val, sizeof(val), &retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Gap pixels enable to receiver:" << retval; shm()->gappixels = retval; @@ -2831,76 +2587,59 @@ std::vector slsDetector::getTrimEn() { shm()->trimEnergies.end()); } -int slsDetector::pulsePixel(int n, int x, int y) { +void slsDetector::pulsePixel(int n, int x, int y) { int args[]{n, x, y}; FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times at (" << x << "," << y << ")"; - if (shm()->onlineFlag == ONLINE_FLAG) { - return sendToDetector(F_PULSE_PIXEL, args, nullptr); - } - return FAIL; + sendToDetector(F_PULSE_PIXEL, args, nullptr); } -int slsDetector::pulsePixelNMove(int n, int x, int y) { +void slsDetector::pulsePixelNMove(int n, int x, int y) { int args[]{n, x, y}; FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times and move by delta (" << x << "," << y << ")"; - if (shm()->onlineFlag == ONLINE_FLAG) { - return sendToDetector(F_PULSE_PIXEL_AND_MOVE, args, nullptr); - } - return FAIL; + sendToDetector(F_PULSE_PIXEL_AND_MOVE, args, nullptr); } -int slsDetector::pulseChip(int n_pulses) { +void slsDetector::pulseChip(int n_pulses) { FILE_LOG(logDEBUG1) << "Pulsing chip " << n_pulses << " number of times"; - if (shm()->onlineFlag == ONLINE_FLAG) { - return sendToDetector(F_PULSE_CHIP, n_pulses, nullptr); - } - return FAIL; + sendToDetector(F_PULSE_CHIP, n_pulses, nullptr); } int slsDetector::setThresholdTemperature(int val) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting threshold temperature to " << val; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetectorStop(F_THRESHOLD_TEMP, val, retval); FILE_LOG(logDEBUG1) << "Threshold temperature: " << retval; - } return retval; } int slsDetector::setTemperatureControl(int val) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting temperature control to " << val; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetectorStop(F_TEMP_CONTROL, val, retval); FILE_LOG(logDEBUG1) << "Temperature control: " << retval; - } return retval; } int slsDetector::setTemperatureEvent(int val) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting temperature event to " << val; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetectorStop(F_TEMP_EVENT, val, retval); FILE_LOG(logDEBUG1) << "Temperature event: " << retval; - } return retval; } int slsDetector::setStoragecellStart(int pos) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting storage cell start to " << pos; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_STORAGE_CELL_START, pos, retval); FILE_LOG(logDEBUG1) << "Storage cell start: " << retval; - } return retval; } -int slsDetector::programFPGA(std::vector buffer) { +void slsDetector::programFPGA(std::vector buffer) { // validate type switch (shm()->myDetectorType) { case JUNGFRAU: @@ -2920,7 +2659,6 @@ int slsDetector::programFPGA(std::vector buffer) { FILE_LOG(logINFO) << "Sending programming binary to detector " << detId << " (" << shm()->hostname << ")"; - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.Send(&fnum, sizeof(fnum)); client.Send(&filesize, sizeof(filesize)); @@ -2964,7 +2702,7 @@ int slsDetector::programFPGA(std::vector buffer) { size_t unitprogramsize = 0; int currentPointer = 0; size_t totalsize = filesize; - while (ret != FAIL && (filesize > 0)) { + while (filesize > 0) { unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb if (unitprogramsize > filesize) { // less than 2mb unitprogramsize = filesize; @@ -2974,7 +2712,14 @@ int slsDetector::programFPGA(std::vector buffer) { client.Send(&buffer[currentPointer], unitprogramsize); client.Receive(&ret, sizeof(ret)); - if (ret != FAIL) { + if (ret == FAIL) { + printf("\n"); + client.Receive(mess, sizeof(mess)); + std::ostringstream os; + os << "Detector " << detId << " (" << shm()->hostname << ")" + << " returned error: " << mess; + throw RuntimeError(os.str()); + } else { filesize -= unitprogramsize; currentPointer += unitprogramsize; @@ -2984,82 +2729,56 @@ int slsDetector::programFPGA(std::vector buffer) { totalsize) * 100)); std::cout << std::flush; - } else { - printf("\n"); - client.Receive(mess, sizeof(mess)); - std::ostringstream os; - os << "Detector " << detId << " (" << shm()->hostname << ")" - << " returned error: " << mess; - throw RuntimeError(os.str()); - } + } } printf("\n"); - } - if (ret != FAIL) { - ret = rebootController(); - } - return ret; + rebootController(); } -int slsDetector::resetFPGA() { +void slsDetector::resetFPGA() { FILE_LOG(logDEBUG1) << "Sending reset FPGA"; - if (shm()->onlineFlag == ONLINE_FLAG) { - return sendToDetector(F_RESET_FPGA); - } - return FAIL; + return sendToDetector(F_RESET_FPGA); } -int slsDetector::copyDetectorServer(const std::string &fname, +void slsDetector::copyDetectorServer(const std::string &fname, const std::string &hostname) { char args[2][MAX_STR_LENGTH]{}; sls::strcpy_safe(args[0], fname.c_str()); sls::strcpy_safe(args[1], hostname.c_str()); FILE_LOG(logINFO) << "Sending detector server " << args[0] << " from host " << args[1]; - if (shm()->onlineFlag == ONLINE_FLAG) { - return sendToDetector(F_COPY_DET_SERVER, args, nullptr); - } - return FAIL; + sendToDetector(F_COPY_DET_SERVER, args, nullptr); } -int slsDetector::rebootController() { +void slsDetector::rebootController() { if (shm()->myDetectorType == EIGER) { throw RuntimeError( "Reboot controller not implemented for this detector"); } int fnum = F_REBOOT_CONTROLLER; - int ret = FAIL; FILE_LOG(logINFO) << "Sending reboot controller to detector " << detId << " (" << shm()->hostname << ")"; - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.Send(&fnum, sizeof(fnum)); - ret = OK; - } - return ret; } int slsDetector::powerChip(int ival) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting power chip to " << ival; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_POWER_CHIP, ival, retval); FILE_LOG(logDEBUG1) << "Power chip: " << retval; - } return retval; } int slsDetector::setAutoComparatorDisableMode(int ival) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting auto comp disable mode to " << ival; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_AUTO_COMP_DISABLE, ival, retval); FILE_LOG(logDEBUG1) << "Auto comp disable: " << retval; - } return retval; } -int slsDetector::setModule(sls_detector_module &module, int tb) { +void slsDetector::setModule(sls_detector_module &module, int tb) { int fnum = F_SET_MODULE; int ret = FAIL; int retval = -1; @@ -3069,7 +2788,6 @@ int slsDetector::setModule(sls_detector_module &module, int tb) { module.nchan = 0; module.nchip = 0; } - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.Send(&fnum, sizeof(fnum)); sendModule(&module, client); @@ -3082,17 +2800,13 @@ int slsDetector::setModule(sls_detector_module &module, int tb) { } client.Receive(&retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Set Module returned: " << retval; - } if (ret == FORCE_UPDATE) { - ret = updateDetector(); + updateCachedDetectorVariables(); } // update client structure - if (ret == OK) { if (module.eV != -1) { shm()->currentThresholdEV = module.eV; } - } - return ret; } sls_detector_module slsDetector::getModule() { @@ -3100,40 +2814,30 @@ sls_detector_module slsDetector::getModule() { int ret = FAIL; FILE_LOG(logDEBUG1) << "Getting module"; sls_detector_module myMod{shm()->myDetectorType}; - if (shm()->onlineFlag == ONLINE_FLAG) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); receiveModule(&myMod, client); - } if (ret == FORCE_UPDATE) { - ret = updateDetector(); + updateCachedDetectorVariables(); } - if (ret == OK) { if (myMod.eV != -1) { shm()->currentThresholdEV = myMod.eV; } - } return myMod; } -int slsDetector::setRateCorrection(int64_t t) { - int ret = FAIL; +void slsDetector::setRateCorrection(int64_t t) { FILE_LOG(logDEBUG1) << "Setting Rate Correction to " << t; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SET_RATE_CORRECT, t, nullptr); + sendToDetector(F_SET_RATE_CORRECT, t, nullptr); shm()->deadTime = t; - } - return ret; } int64_t slsDetector::getRateCorrection() { int64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting rate correction"; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_RATE_CORRECT, nullptr, retval); shm()->deadTime = retval; FILE_LOG(logDEBUG1) << "Rate correction: " << retval; - } return retval; } @@ -3167,31 +2871,13 @@ void slsDetector::printReceiverConfiguration(TLogLevel level) { << "\nReceiver UDP Port2:\t" << getReceiverUDPPort2(); } -int slsDetector::setReceiverOnline(int value) { - if (value != GET_ONLINE_FLAG) { - if (strcmp(shm()->rxHostname, "none") == 0) { - shm()->rxOnlineFlag = OFFLINE_FLAG; - } else { - shm()->rxOnlineFlag = OFFLINE_FLAG; - if (value == ONLINE_FLAG) { - shm()->rxOnlineFlag = ONLINE_FLAG; - if (shm()->receiverAPIVersion == 0) { - checkReceiverVersionCompatibility(); - } - } - } - } - return shm()->rxOnlineFlag; -} -int slsDetector::getReceiverOnlineFlag() const { return shm()->rxOnlineFlag; } +bool slsDetector::getUseReceiverFlag() const { return shm()->useReceiverFlag; } std::string slsDetector::checkReceiverOnline() { try { getReceiverSoftwareVersion(); - shm()->rxOnlineFlag = ONLINE_FLAG; } catch (...) { - shm()->rxOnlineFlag = OFFLINE_FLAG; return shm()->rxHostname; } return std::string(); @@ -3200,7 +2886,7 @@ std::string slsDetector::checkReceiverOnline() { int slsDetector::lockReceiver(int lock) { FILE_LOG(logDEBUG1) << "Setting receiver server lock to " << lock; int retval = -1; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_LOCK_RECEIVER, lock, retval); FILE_LOG(logDEBUG1) << "Receiver Lock: " << retval; } @@ -3210,48 +2896,39 @@ int slsDetector::lockReceiver(int lock) { std::string slsDetector::getReceiverLastClientIP() { char retval[INET_ADDRSTRLEN]{}; FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_GET_LAST_RECEIVER_CLIENT_IP, nullptr, retval); FILE_LOG(logDEBUG1) << "Last client IP from receiver: " << retval; } return retval; } -int slsDetector::exitReceiver() { +void slsDetector::exitReceiver() { FILE_LOG(logDEBUG1) << "Sending exit command to receiver server"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - return sendToReceiver(F_EXIT_RECEIVER); + if (shm()->useReceiverFlag) { + sendToReceiver(F_EXIT_RECEIVER); } - return FAIL; } -int slsDetector::execReceiverCommand(const std::string &cmd) { - int ret = FAIL; +void slsDetector::execReceiverCommand(const std::string &cmd) { char arg[MAX_STR_LENGTH]{}; char retval[MAX_STR_LENGTH]{}; sls::strcpy_safe(arg, cmd.c_str()); FILE_LOG(logDEBUG1) << "Sending command to receiver: " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - ret = sendToReceiver(F_EXEC_RECEIVER_COMMAND, arg, retval); + if (shm()->useReceiverFlag) { + sendToReceiver(F_EXEC_RECEIVER_COMMAND, arg, retval); FILE_LOG(logINFO) << "Receiver " << detId << " returned:\n" << retval; } - return ret; } -int slsDetector::updateCachedReceiverVariables() const { +void slsDetector::updateCachedReceiverVariables() const { int fnum = F_UPDATE_RECEIVER_CLIENT; - int ret = FAIL; FILE_LOG(logDEBUG1) << "Sending update client to receiver server"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { auto receiver = sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort); - ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); - if (ret == FAIL) { - std::string msg = - "Could not update receiver: " + std::string(shm()->rxHostname); - throw RuntimeError(msg); - } else { + receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); int n = 0, i32 = 0; char cstring[MAX_STR_LENGTH]{}; char lastClientIP[INET_ADDRSTRLEN]{}; @@ -3352,10 +3029,7 @@ int slsDetector::updateCachedReceiverVariables() const { std::string(shm()->rxHostname) + ", received 0 bytes\n"); } - return OK; - } } - return ret; } void slsDetector::sendMultiDetectorSize() { @@ -3364,7 +3038,7 @@ void slsDetector::sendMultiDetectorSize() { FILE_LOG(logDEBUG1) << "Sending multi detector size to receiver: (" << shm()->multiSize[0] << "," << shm()->multiSize[1] << ")"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SEND_RECEIVER_MULTIDETSIZE, args, retval); FILE_LOG(logDEBUG1) << "Receiver multi size returned: " << retval; } @@ -3372,7 +3046,7 @@ void slsDetector::sendMultiDetectorSize() { void slsDetector::setDetectorId() { FILE_LOG(logDEBUG1) << "Sending detector pos id to receiver: " << detId; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int retval = -1; sendToReceiver(F_SEND_RECEIVER_DETPOSID, detId, retval); FILE_LOG(logDEBUG1) << "Receiver Position Id returned: " << retval; @@ -3384,7 +3058,7 @@ void slsDetector::setDetectorHostname() { char retvals[MAX_STR_LENGTH]{}; sls::strcpy_safe(args, shm()->hostname); FILE_LOG(logDEBUG1) << "Sending detector hostname to receiver: " << args; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SEND_RECEIVER_DETHOSTNAME, args, retvals); FILE_LOG(logDEBUG1) << "Receiver set detector hostname: " << retvals; } @@ -3398,7 +3072,7 @@ std::string slsDetector::setFilePath(const std::string &path) { char retvals[MAX_STR_LENGTH]{}; sls::strcpy_safe(args, path.c_str()); FILE_LOG(logDEBUG1) << "Sending file path to receiver: " << args; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, retvals); FILE_LOG(logDEBUG1) << "Receiver file path: " << retvals; sls::strcpy_safe(shm()->rxFilePath, retvals); @@ -3415,7 +3089,7 @@ std::string slsDetector::setFileName(const std::string &fname) { char retvals[MAX_STR_LENGTH]{}; sls::strcpy_safe(args, fname.c_str()); FILE_LOG(logDEBUG1) << "Sending file name to receiver: " << args; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, retvals); FILE_LOG(logDEBUG1) << "Receiver file name: " << retvals; sls::strcpy_safe(shm()->rxFileName, retvals); @@ -3428,7 +3102,7 @@ int slsDetector::setFramesPerFile(int n_frames) { if (n_frames >= 0) { FILE_LOG(logDEBUG1) << "Setting receiver frames per file to " << n_frames; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int retval = -1; sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, retval); FILE_LOG(logDEBUG1) << "Receiver frames per file: " << retval; @@ -3444,7 +3118,7 @@ slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) { int arg = static_cast(f); FILE_LOG(logDEBUG1) << "Setting receiver frames discard policy to " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { auto retval = static_cast(-1); sendToReceiver(F_RECEIVER_DISCARD_POLICY, arg, retval); FILE_LOG(logDEBUG1) << "Receiver frames discard policy: " << retval; @@ -3457,7 +3131,7 @@ bool slsDetector::setPartialFramesPadding(bool padding) { int arg = static_cast(padding); int retval = static_cast(padding); FILE_LOG(logDEBUG1) << "Setting receiver partial frames enable to " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_PADDING_ENABLE, arg, retval); FILE_LOG(logDEBUG1) << "Receiver partial frames enable: " << retval; } @@ -3474,7 +3148,7 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { auto arg = static_cast(f); auto retval = static_cast(-1); FILE_LOG(logDEBUG1) << "Setting receiver file format to " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_FILE_FORMAT, arg, retval); FILE_LOG(logDEBUG1) << "Receiver file format: " << retval; shm()->rxFileFormat = retval; @@ -3491,7 +3165,7 @@ int slsDetector::setFileIndex(int file_index) { if (F_SET_RECEIVER_FILE_INDEX >= 0) { int retval = -1; FILE_LOG(logDEBUG1) << "Setting file index to " << file_index; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, retval); FILE_LOG(logDEBUG1) << "Receiver file index: " << retval; shm()->rxFileIndex = retval; @@ -3509,26 +3183,24 @@ int slsDetector::incrementFileIndex() { return shm()->rxFileIndex; } -int slsDetector::startReceiver() { +void slsDetector::startReceiver() { FILE_LOG(logDEBUG1) << "Starting Receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - return sendToReceiver(F_START_RECEIVER); + if (shm()->useReceiverFlag) { + sendToReceiver(F_START_RECEIVER); } - return FAIL; } -int slsDetector::stopReceiver() { +void slsDetector::stopReceiver() { FILE_LOG(logDEBUG1) << "Stopping Receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - return sendToReceiver(F_STOP_RECEIVER); + if (shm()->useReceiverFlag) { + sendToReceiver(F_STOP_RECEIVER); } - return FAIL; } slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { runStatus retval = ERROR; FILE_LOG(logDEBUG1) << "Getting Receiver Status"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_GET_RECEIVER_STATUS, nullptr, retval); FILE_LOG(logDEBUG1) << "Receiver Status: " << runStatusType(retval); } @@ -3538,7 +3210,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { int slsDetector::getFramesCaughtByReceiver() { int retval = -1; FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_GET_RECEIVER_FRAMES_CAUGHT, nullptr, retval); FILE_LOG(logDEBUG1) << "Frames Caught by Receiver: " << retval; } @@ -3548,26 +3220,25 @@ int slsDetector::getFramesCaughtByReceiver() { uint64_t slsDetector::getReceiverCurrentFrameIndex() { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_GET_RECEIVER_FRAME_INDEX, nullptr, retval); FILE_LOG(logDEBUG1) << "Current Frame Index of Receiver: " << retval; } return retval; } -int slsDetector::resetFramesCaught() { +void slsDetector::resetFramesCaught() { FILE_LOG(logDEBUG1) << "Reset Frames Caught by Receiver"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - return sendToReceiver(F_RESET_RECEIVER_FRAMES_CAUGHT); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RESET_RECEIVER_FRAMES_CAUGHT); } - return FAIL; } bool slsDetector::setFileWrite(bool value) { int arg = static_cast(value); int retval = -1; FILE_LOG(logDEBUG1) << "Sending enable file write to receiver: " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_ENABLE_RECEIVER_FILE_WRITE, arg, retval); FILE_LOG(logDEBUG1) << "Receiver file write enable: " << retval; shm()->rxFileWrite = static_cast(retval); @@ -3582,7 +3253,7 @@ bool slsDetector::setMasterFileWrite(bool value) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending enable master file write to receiver: " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_ENABLE_RECEIVER_MASTER_FILE_WRITE, arg, retval); FILE_LOG(logDEBUG1) << "Receiver master file write enable: " << retval; shm()->rxMasterFileWrite = static_cast(retval); @@ -3598,7 +3269,7 @@ bool slsDetector::setFileOverWrite(bool value) { int arg = static_cast(value); int retval = -1; FILE_LOG(logDEBUG1) << "Sending enable file overwrite to receiver: " << arg; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_ENABLE_RECEIVER_OVERWRITE, arg, retval); FILE_LOG(logDEBUG1) << "Receiver file overwrite enable: " << retval; shm()->rxFileOverWrite = static_cast(retval); @@ -3611,7 +3282,7 @@ bool slsDetector::getFileOverWrite() const { return shm()->rxFileOverWrite; } int slsDetector::setReceiverStreamingFrequency(int freq) { if (freq >= 0) { FILE_LOG(logDEBUG1) << "Sending read frequency to receiver: " << freq; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int retval = -1; sendToReceiver(F_RECEIVER_STREAMING_FREQUENCY, freq, retval); FILE_LOG(logDEBUG1) << "Receiver read frequency: " << retval; @@ -3624,7 +3295,7 @@ int slsDetector::setReceiverStreamingFrequency(int freq) { int slsDetector::setReceiverStreamingTimer(int time_in_ms) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending read timer to receiver: " << time_in_ms; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_RECEIVER_STREAMING_TIMER, time_in_ms, retval); FILE_LOG(logDEBUG1) << "Receiver read timer: " << retval; } @@ -3634,7 +3305,7 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) { bool slsDetector::enableDataStreamingFromReceiver(int enable) { if (enable >= 0) { FILE_LOG(logDEBUG1) << "Sending Data Streaming to receiver: " << enable; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int retval = -1; sendToReceiver(F_STREAM_DATA_FROM_RECEIVER, enable, retval); FILE_LOG(logDEBUG1) << "Receiver Data Streaming: " << retval; @@ -3645,16 +3316,13 @@ bool slsDetector::enableDataStreamingFromReceiver(int enable) { } int slsDetector::enableTenGigabitEthernet(int value) { - int ret = FAIL; int retval = -1; FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << value; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_ENABLE_TEN_GIGA, value, retval); FILE_LOG(logDEBUG1) << "10Gbe: " << retval; shm()->tenGigaEnable = retval; - ret = configureMAC(); - } - if ((shm()->rxOnlineFlag == ONLINE_FLAG) && ret == OK) { + configureMAC(); + if (shm()->useReceiverFlag) { retval = -1; value = shm()->tenGigaEnable; FILE_LOG(logDEBUG1) << "Sending 10Gbe enable to receiver: " << value; @@ -3667,7 +3335,7 @@ int slsDetector::enableTenGigabitEthernet(int value) { int slsDetector::setReceiverFifoDepth(int n_frames) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending Receiver Fifo Depth: " << n_frames; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_FIFO_DEPTH, n_frames, retval); FILE_LOG(logDEBUG1) << "Receiver Fifo Depth: " << retval; } @@ -3676,7 +3344,7 @@ int slsDetector::setReceiverFifoDepth(int n_frames) { bool slsDetector::setReceiverSilentMode(int value) { FILE_LOG(logDEBUG1) << "Sending Receiver Silent Mode: " << value; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { + if (shm()->useReceiverFlag) { int retval = -1; sendToReceiver(F_SET_RECEIVER_SILENT_MODE, value, retval); FILE_LOG(logDEBUG1) << "Receiver Data Streaming: " << retval; @@ -3685,12 +3353,11 @@ bool slsDetector::setReceiverSilentMode(int value) { return shm()->rxSilentMode; } -int slsDetector::restreamStopFromReceiver() { +void slsDetector::restreamStopFromReceiver() { FILE_LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq"; - if (shm()->rxOnlineFlag == ONLINE_FLAG) { - return sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER); } - return FAIL; } int slsDetector::setPattern(const std::string &fname) { @@ -3714,10 +3381,8 @@ uint64_t slsDetector::setPatternIOControl(uint64_t word) { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Setting Pattern IO Control, word: 0x" << std::hex << word << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { - sendToDetector(F_SET_PATTERN_IO_CONTROL, word, retval); - FILE_LOG(logDEBUG1) << "Set Pattern IO Control: " << retval; - } + sendToDetector(F_SET_PATTERN_IO_CONTROL, word, retval); + FILE_LOG(logDEBUG1) << "Set Pattern IO Control: " << retval; return retval; } @@ -3725,10 +3390,8 @@ uint64_t slsDetector::setPatternClockControl(uint64_t word) { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Setting Pattern Clock Control, word: 0x" << std::hex << word << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_PATTERN_CLOCK_CONTROL, word, retval); FILE_LOG(logDEBUG1) << "Set Pattern Clock Control: " << retval; - } return retval; } @@ -3737,10 +3400,8 @@ uint64_t slsDetector::setPatternWord(int addr, uint64_t word) { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Setting Pattern word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_PATTERN_WORD, args, retval); FILE_LOG(logDEBUG1) << "Set Pattern word: " << retval; - } return retval; } @@ -3751,11 +3412,9 @@ std::array slsDetector::setPatternLoops(int level, int start, int stop, FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level << ", start: " << start << ", stop: " << stop << ", nloops: " << n; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_PATTERN_LOOP, args, retvals); FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", " << retvals[1] << ", " << retvals[2]; - } return retvals; } @@ -3764,10 +3423,8 @@ int slsDetector::setPatternWaitAddr(int level, int addr) { int args[]{level, addr}; FILE_LOG(logDEBUG1) << "Setting Pat Wait Addr, level: " << level << ", addr: 0x" << std::hex << addr << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_PATTERN_WAIT_ADDR, args, retval); FILE_LOG(logDEBUG1) << "Set Pat Wait Addr: " << retval; - } return retval; } @@ -3776,76 +3433,57 @@ uint64_t slsDetector::setPatternWaitTime(int level, uint64_t t) { uint64_t args[]{static_cast(level), t}; FILE_LOG(logDEBUG1) << "Setting Pat Wait Time, level: " << level << ", t: " << t; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_SET_PATTERN_WAIT_TIME, args, retval); FILE_LOG(logDEBUG1) << "Set Pat Wait Time: " << retval; - } return retval; } -int slsDetector::setPatternMask(uint64_t mask) { - int ret = FAIL; +void slsDetector::setPatternMask(uint64_t mask) { FILE_LOG(logDEBUG1) << "Setting Pattern Mask " << std::hex << mask << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SET_PATTERN_MASK, mask, nullptr); + sendToDetector(F_SET_PATTERN_MASK, mask, nullptr); FILE_LOG(logDEBUG1) << "Pattern Mask successful"; - } - return ret; } uint64_t slsDetector::getPatternMask() { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting Pattern Mask "; - if (shm()->onlineFlag == ONLINE_FLAG) { + sendToDetector(F_GET_PATTERN_MASK, nullptr, retval); FILE_LOG(logDEBUG1) << "Pattern Mask:" << retval; - } return retval; } -int slsDetector::setPatternBitMask(uint64_t mask) { - int ret = FAIL; +void slsDetector::setPatternBitMask(uint64_t mask) { FILE_LOG(logDEBUG1) << "Setting Pattern Bit Mask " << std::hex << mask << std::dec; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_SET_PATTERN_BIT_MASK, mask, nullptr); + sendToDetector(F_SET_PATTERN_BIT_MASK, mask, nullptr); FILE_LOG(logDEBUG1) << "Pattern Bit Mask successful"; - } - return ret; } uint64_t slsDetector::getPatternBitMask() { uint64_t retval = -1; FILE_LOG(logDEBUG1) << "Getting Pattern Bit Mask "; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_GET_PATTERN_BIT_MASK, nullptr, retval); FILE_LOG(logDEBUG1) << "Pattern Bit Mask:" << retval; - } return retval; } int slsDetector::setLEDEnable(int enable) { int retval = -1; FILE_LOG(logDEBUG1) << "Sending LED Enable: " << enable; - if (shm()->onlineFlag == ONLINE_FLAG) { sendToDetector(F_LED, enable, retval); FILE_LOG(logDEBUG1) << "LED Enable: " << retval; - } return retval; } -int slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) { - int ret = FAIL; +void slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) { uint64_t args[]{pinMask, static_cast(delay)}; FILE_LOG(logDEBUG1) << "Sending Digital IO Delay, pin mask: " << std::hex << args[0] << ", delay: " << std::dec << args[1] << " ps"; - if (shm()->onlineFlag == ONLINE_FLAG) { - ret = sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr); + sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr); FILE_LOG(logDEBUG1) << "Digital IO Delay successful"; - } - return ret; } sls_detector_module slsDetector::interpolateTrim(sls_detector_module *a, @@ -4013,7 +3651,7 @@ sls_detector_module slsDetector::readSettingsFile(const std::string &fname, return myMod; } -int slsDetector::writeSettingsFile(const std::string &fname, +void slsDetector::writeSettingsFile(const std::string &fname, sls_detector_module &mod) { FILE_LOG(logDEBUG1) << "Write settings file " << fname; auto names = getSettingsFileDacNames(); @@ -4050,7 +3688,6 @@ int slsDetector::writeSettingsFile(const std::string &fname, } } outfile.close(); - return OK; } std::vector slsDetector::getSettingsFileDacNames() { diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index b4ead49b7..8c4831cd8 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -301,13 +301,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { commands to configure detector status */ - /*! \page config - - online [i] sets the detector in online (1) or offline (0) mode. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName = "online"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOnline; - ++i; - /*! \page config - checkonline returns the hostnames of all detectors without connecting to them. \c Returns (string) "All online" or "[list of offline hostnames] : Not online". */ @@ -1804,13 +1797,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver; ++i; - /*! \page receiver - - rx_online [i] sets/gets the receiver in online/offline mode. 1 is online, 0 is offline. Get is from shared memory. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName = "rx_online"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOnline; - ++i; - /*! \page receiver - rx_checkonline Checks the receiver if it is online/offline mode. Only get! \c Returns (string) "All online" or "[list of offline hostnames] : Not online". */ @@ -2219,13 +2205,9 @@ std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[], return std::string("acquire failed"); } - int rx_online = myDet->setReceiverOnline(-1, detPos); - - - if (myDet->acquire() == FAIL) return std::string("acquire failed"); - if (rx_online) { + if (myDet->getUseReceiverFlag(detPos)) { char answer[100]; sprintf(answer, "\nAcquired %d", myDet->getFramesCaughtByReceiver(detPos)); return std::string(answer); @@ -2261,7 +2243,7 @@ std::string slsDetectorCommand::cmdData(int narg, const char * const args[], int // myDet->setThreadedProcessing(0); // myDet->readAll(detPos); // //processdata in receiver is useful only for gui purposes - // if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG) + // if(myDet->getUseReceiverFlag(detPos)==OFFLINE_FLAG) // myDet->processData(); // myDet->setThreadedProcessing(b); return std::string(""); @@ -2489,28 +2471,20 @@ std::string slsDetectorCommand::cmdExitServer(int narg, const char * const args[ if (action == PUT_ACTION) { if (cmd == "exitserver") { - if (myDet->exitServer(detPos) == OK) - return std::string("Server shut down."); - else - return std::string("Error closing server\n"); + myDet->exitServer(detPos); + return std::string("Server shut down."); } else if (cmd == "rx_exit") { - if (myDet->exitReceiver(detPos) == OK) - return std::string("Receiver shut down\n"); - else - return std::string("Error closing receiver\n"); + myDet->exitReceiver(detPos); + return std::string("Receiver shut down\n"); } else if (cmd == "execcommand") { - if (myDet->execCommand(std::string(args[1]), detPos) == OK) - return std::string("Command executed successfully\n"); - else - return std::string("Command failed\n"); + myDet->execCommand(std::string(args[1]), detPos); + return std::string("Command executed successfully\n"); } else if (cmd == "rx_execcommand") { - if (myDet->execReceiverCommand(std::string(args[1]), detPos) == OK) - return std::string("Command executed successfully\n"); - else - return std::string("Command failed\n"); - } else + myDet->execReceiverCommand(std::string(args[1]), detPos); + return std::string("Command executed successfully\n"); + } else return ("cannot decode command\n"); } else return ("cannot get"); @@ -2781,7 +2755,6 @@ std::string slsDetectorCommand::helpThreaded(int action) { std::string slsDetectorCommand::cmdImage(int narg, const char * const args[], int action, int detPos) { std::string sval; - int retval = FAIL; if (action == HELP_ACTION) return helpImage(HELP_ACTION); else if (action == GET_ACTION) @@ -2790,14 +2763,11 @@ std::string slsDetectorCommand::cmdImage(int narg, const char * const args[], in sval = std::string(args[1]); if (std::string(args[0]) == std::string("darkimage")) - retval = myDet->loadImageToDetector(DARK_IMAGE, sval, detPos); + myDet->loadImageToDetector(DARK_IMAGE, sval, detPos); else if (std::string(args[0]) == std::string("gainimage")) - retval = myDet->loadImageToDetector(GAIN_IMAGE, sval, detPos); + myDet->loadImageToDetector(GAIN_IMAGE, sval, detPos); - if (retval == OK) - return std::string("Image loaded succesfully"); - else - return std::string("Image load failed"); + return std::string("Image loaded succesfully"); } std::string slsDetectorCommand::helpImage(int action) { @@ -2831,13 +2801,16 @@ std::string slsDetectorCommand::cmdCounter(int narg, const char * const args[], if (narg < 3) return std::string("should specify I/O file"); sval = std::string(args[2]); - retval = myDet->writeCounterBlockFile(sval, ival, detPos); + myDet->writeCounterBlockFile(sval, ival, detPos); + return std::string("Counter read succesfully"); } } else if (std::string(args[0]) == std::string("resetctr")) { if (action == GET_ACTION) return std::string("Cannot get"); - else - retval = myDet->resetCounterBlock(ival, detPos); + else { + myDet->resetCounterBlock(ival, detPos); + return std::string("successful"); + } } else if (std::string(args[0]) == std::string("resmat")) { @@ -2852,7 +2825,7 @@ std::string slsDetectorCommand::cmdCounter(int narg, const char * const args[], } if (retval == OK) - return std::string("Counter read/reset succesfully"); + return std::string("Counter set/reset succesfully"); else return std::string("Counter read/reset failed"); } @@ -3254,15 +3227,7 @@ std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], i int ival; char ans[1000]; - if (cmd == "online") { - if (action == PUT_ACTION) { - if (sscanf(args[1], "%d", &ival)) - myDet->setOnline(ival, detPos); - else - return std::string("Could not scan online mode ") + std::string(args[1]); - } - sprintf(ans, "%d", myDet->setOnline(-1, detPos)); - } else if (cmd == "checkonline") { + if (cmd == "checkonline") { if (action == PUT_ACTION) return std::string("cannot set"); strcpy(ans, myDet->checkOnline(detPos).c_str()); @@ -3289,14 +3254,6 @@ std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], i } int ret = myDet->setDeactivatedRxrPaddingMode(-1, detPos); sprintf(ans, "%d %s", myDet->activate(-1, detPos), ret == 1 ? "padding" : (ret == 0 ? "nopadding" : "unknown")); - } else if (cmd == "rx_online") { - if (action == PUT_ACTION) { - if (sscanf(args[1], "%d", &ival)) - myDet->setReceiverOnline(ival, detPos); - else - return std::string("Could not scan online mode ") + std::string(args[1]); - } - sprintf(ans, "%d", myDet->setReceiverOnline(-1, detPos)); } else { if (action == PUT_ACTION) return std::string("cannot set"); @@ -3314,14 +3271,10 @@ std::string slsDetectorCommand::helpOnline(int action) { std::ostringstream os; if (action == PUT_ACTION || action == HELP_ACTION) { - os << "online i \n sets the detector in online (1) or offline (0) mode" << std::endl; - os << "rx_online i \n sets the receiver in online (1) or offline (0) mode" << std::endl; os << "activate i [p]\n sets the detector in activated (1) or deactivated (0) mode (does not send data). p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Only for Eiger." << std::endl; } if (action == GET_ACTION || action == HELP_ACTION) { - os << "online \n gets the detector online (1) or offline (0) mode" << std::endl; os << "checkonline \n returns the hostnames of all detectors in offline mode" << std::endl; - os << "rx_online \n gets the receiver online (1) or offline (0) mode" << std::endl; os << "rx_checkonline \n returns the hostnames of all receiver in offline mode" << std::endl; os << "activate \n gets the detector activated (1) or deactivated (0) mode. And padding or nonpadding for the deactivated receiver. Only for Eiger." << std::endl; } @@ -3333,17 +3286,12 @@ std::string slsDetectorCommand::cmdConfigureMac(int narg, const char * const arg if (action == HELP_ACTION) { return helpConfigureMac(action); } - int ret; - char ans[1000]; - if (action == PUT_ACTION) { - - ret = myDet->configureMAC(detPos); + myDet->configureMAC(detPos); } else return std::string("Cannot get ") + cmd; - sprintf(ans, "%d", ret); - return ans; + return std::string("successful"); } std::string slsDetectorCommand::helpConfigureMac(int action) { @@ -3547,17 +3495,13 @@ std::string slsDetectorCommand::cmdSettings(int narg, const char * const args[], #ifdef VERBOSE std::cout << " trimfile " << sval << std::endl; #endif - int ret = OK; if (action == GET_ACTION) { //create file names - ret = myDet->saveSettingsFile(sval, detPos); + myDet->saveSettingsFile(sval, detPos); } else if (action == PUT_ACTION) { - ret = myDet->loadSettingsFile(sval, detPos); + myDet->loadSettingsFile(sval, detPos); } - if (ret == OK) - return sval; - else - return std::string("failed"); + return sval; } return std::string("Specify file name for geting settings file"); } else if (cmd == "trimval") { @@ -3652,19 +3596,13 @@ std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int a } if (cmd == "checkdetversion") { - int retval = myDet->checkDetectorVersionCompatibility(detPos); - if (retval < 0) - sprintf(answer, "%d", -1); - sprintf(answer, "%s", retval == OK ? "compatible" : "incompatible"); - return std::string(answer); + myDet->checkDetectorVersionCompatibility(detPos); + return std::string("compatible"); } if (cmd == "rx_checkversion") { - int retval = myDet->checkReceiverVersionCompatibility(detPos); - if (retval < 0) - sprintf(answer, "%d", -1); - sprintf(answer, "%s", retval == OK ? "compatible" : "incompatible"); - return std::string(answer); + myDet->checkReceiverVersionCompatibility(detPos); + return std::string("compatible"); } return std::string("unknown id mode ") + cmd; @@ -3779,7 +3717,8 @@ std::string slsDetectorCommand::cmdRegister(int narg, const char * const args[], ; else return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[2]); - sprintf(answer, "%s", (myDet->writeAdcRegister(addr, val, detPos) == OK) ? "successful" : "failed"); + myDet->writeAdcRegister(addr, val, detPos); + sprintf(answer, "%s","successful"); } else { if (sscanf(args[2], "%d", &n)) @@ -4815,17 +4754,15 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], if (strstr(args[1], ".pof") == nullptr) return std::string("wrong usage: programming file should have .pof extension"); std::string sval = std::string(args[1]); - if (myDet->programFPGA(sval, detPos) == OK) - return std::string("successful"); - return std::string("failed"); + myDet->programFPGA(sval, detPos); + return std::string("successful"); } else if (cmd == "resetfpga") { if (action == GET_ACTION) return std::string("cannot get"); - if (myDet->resetFPGA(detPos) == OK) - return std::string("successful"); - return std::string("failed"); + myDet->resetFPGA(detPos); + return std::string("successful"); } else if (cmd == "copydetectorserver") { @@ -4835,17 +4772,15 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], return ("wrong usage." + helpAdvanced(PUT_ACTION)); std::string sval = std::string(args[1]); std::string pval = std::string(args[2]); - if (myDet->copyDetectorServer(sval, pval, detPos) == OK) - return std::string("successful"); - return std::string("failed"); + myDet->copyDetectorServer(sval, pval, detPos); + return std::string("successful"); } else if (cmd == "rebootcontroller") { if (action == GET_ACTION) return std::string("cannot get"); - if (myDet->rebootController(detPos) == OK) - return std::string("successful"); - return std::string("failed"); + myDet->rebootController(detPos); + return std::string("successful"); } else if (cmd == "update") { @@ -4859,9 +4794,8 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], std::string sval = std::string(args[1]); std::string pval = std::string(args[2]); std::string fval = std::string(args[3]); - if (myDet->update(sval, pval, fval, detPos) == OK) - return std::string("successful"); - return std::string("failed"); + myDet->update(sval, pval, fval, detPos); + return std::string("successful"); } else if (cmd == "powerchip") { @@ -4899,10 +4833,8 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], if (!sscanf(args[2], "%d", &delay)) return std::string("could not scan diodelay delay " + std::string(args[2])); - int retval = myDet->setDigitalIODelay(pinMask, delay, detPos); - if (retval == -1) - return std::to_string(-1); - return std::string((retval == OK) ? "successful" : "failed"); + myDet->setDigitalIODelay(pinMask, delay, detPos); + return std::string("successful"); } else if (cmd == "auto_comp_disable") { @@ -5048,11 +4980,8 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[], if (action == GET_ACTION) return std::string("cannot get"); else { - if (myDet->resetFramesCaught(detPos) == OK) - strcpy(answer, "successful"); - else - strcpy(answer, "failed"); - return std::string(answer); + myDet->resetFramesCaught(detPos); + return std::string("successful"); } } @@ -5102,7 +5031,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[], else if (cmd == "rx_silent") { if (action == PUT_ACTION) { if (!sscanf(args[1], "%d", &ival)) - return std::string("Could not scan rx_online input ") + std::string(args[1]); + return std::string("Could not scan rx_silent input ") + std::string(args[1]); if (ival >= 0) sprintf(answer, "%d", myDet->setReceiverSilentMode(ival, detPos)); } else @@ -5729,7 +5658,6 @@ std::string slsDetectorCommand::helpPulse(int action) { } std::string slsDetectorCommand::cmdPulse(int narg, const char * const args[], int action, int detPos) { - int retval = FAIL; if (action == HELP_ACTION) return helpPulse(action); @@ -5742,7 +5670,7 @@ std::string slsDetectorCommand::cmdPulse(int narg, const char * const args[], in return std::string("Could not scan 1st argument ") + std::string(args[1]); if (std::string(args[0]) == std::string("pulsechip")) - retval = myDet->pulseChip(ival1, detPos); + myDet->pulseChip(ival1, detPos); else { //next commands requires 3 addnl. arguments @@ -5755,19 +5683,16 @@ std::string slsDetectorCommand::cmdPulse(int narg, const char * const args[], in return std::string("Could not scan 3rd argument ") + std::string(args[3]); if (std::string(args[0]) == std::string("pulse")) - retval = myDet->pulsePixel(ival1, ival2, ival3, detPos); + myDet->pulsePixel(ival1, ival2, ival3, detPos); else if (std::string(args[0]) == std::string("pulsenmove")) - retval = myDet->pulsePixelNMove(ival1, ival2, ival3, detPos); + myDet->pulsePixelNMove(ival1, ival2, ival3, detPos); else - return std::string("could not decode command") + cmd; + std::string("could not decode command") + cmd; } - if (retval == OK) - return std::string(" successful"); - else - return std::string(" failed"); + return std::string(" successful"); } diff --git a/slsDetectorSoftware/src/slsDetectorUsers.cpp b/slsDetectorSoftware/src/slsDetectorUsers.cpp index 390329c6a..5aa1aeabe 100755 --- a/slsDetectorSoftware/src/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/src/slsDetectorUsers.cpp @@ -30,13 +30,6 @@ int slsDetectorUsers::getDetectorSize(int &x, int &y, int &nx, int &ny, int detP std::string slsDetectorUsers::getDetectorType(int detPos){ return detector.getDetectorTypeAsString(detPos); } -int slsDetectorUsers::setOnline(int const online, int detPos){ - return detector.setOnline(online, detPos); -} - -int slsDetectorUsers::setReceiverOnline(int const online, int detPos){ - return detector.setReceiverOnline(online, detPos); -} int slsDetectorUsers::readConfigurationFile(const std::string& fname){ try{ @@ -79,36 +72,36 @@ int64_t slsDetectorUsers::getReceiverSoftwareVersion(int detPos){ return detector.getId(slsDetectorDefs::RECEIVER_VERSION, detPos); } -bool slsDetectorUsers::isDetectorVersionCompatible(int detPos) { - return (detector.checkDetectorVersionCompatibility(detPos) == slsDetectorDefs::OK); +void slsDetectorUsers::isDetectorVersionCompatible(int detPos) { + detector.checkDetectorVersionCompatibility(detPos); } -bool slsDetectorUsers::isReceiverVersionCompatible(int detPos) { - return (detector.checkReceiverVersionCompatibility(detPos) == slsDetectorDefs::OK); +void slsDetectorUsers::isReceiverVersionCompatible(int detPos) { + detector.checkReceiverVersionCompatibility(detPos); } int slsDetectorUsers::startMeasurement(){ return detector.acquire(); } -int slsDetectorUsers::stopMeasurement(int detPos){ - return detector.stopAcquisition(detPos); +void slsDetectorUsers::stopMeasurement(int detPos){ + detector.stopAcquisition(detPos); } int slsDetectorUsers::getDetectorStatus(int detPos){ return (int)detector.getRunStatus(detPos); } -int slsDetectorUsers::startAcquisition(int detPos) { - return detector.startAcquisition(detPos); +void slsDetectorUsers::startAcquisition(int detPos) { + detector.startAcquisition(detPos); } -int slsDetectorUsers::stopAcquisition(int detPos) { - return detector.stopAcquisition(detPos); +void slsDetectorUsers::stopAcquisition(int detPos) { + detector.stopAcquisition(detPos); } -int slsDetectorUsers::sendSoftwareTrigger(int detPos) { - return detector.sendSoftwareTrigger(detPos); +void slsDetectorUsers::sendSoftwareTrigger(int detPos) { + detector.sendSoftwareTrigger(detPos); } int slsDetectorUsers::enableCountRateCorrection(int i, int detPos){ @@ -237,8 +230,8 @@ int slsDetectorUsers::setFlowControl10G(int i, int detPos) { return detector.setFlowControl10G(i, detPos); } -int slsDetectorUsers::setROI(int n, slsDetectorDefs::ROI roiLimits[], int detPos) { - return detector.setROI(n, roiLimits, detPos); +void slsDetectorUsers::setROI(int n, slsDetectorDefs::ROI roiLimits[], int detPos) { + detector.setROI(n, roiLimits, detPos); } const slsDetectorDefs::ROI* slsDetectorUsers::getROI(int &n, int detPos) { @@ -252,20 +245,20 @@ const slsDetectorDefs::ROI* slsDetectorUsers::getROI(int &n, int detPos) { *********************************************************************/ -int slsDetectorUsers::startReceiver(int detPos) { - return detector.startReceiver(detPos); +void slsDetectorUsers::startReceiver(int detPos) { + detector.startReceiver(detPos); } -int slsDetectorUsers::stopReceiver(int detPos) { - return detector.stopReceiver(detPos); +void slsDetectorUsers::stopReceiver(int detPos) { + detector.stopReceiver(detPos); } int slsDetectorUsers::setReceiverSilentMode(int i, int detPos) { return detector.setReceiverSilentMode(i, detPos); } -int slsDetectorUsers::resetFramesCaughtInReceiver(int detPos) { - return detector.resetFramesCaught(detPos); +void slsDetectorUsers::resetFramesCaughtInReceiver(int detPos) { + detector.resetFramesCaught(detPos); } int slsDetectorUsers::setReceiverFifoDepth(int i, int detPos) { diff --git a/slsSupportLib/include/genericSocket.h b/slsSupportLib/include/genericSocket.h index 431dcf604..220aa5e8f 100755 --- a/slsSupportLib/include/genericSocket.h +++ b/slsSupportLib/include/genericSocket.h @@ -243,9 +243,9 @@ public: if(bind(sockfd.fd,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){ - FILE_LOG(logERROR) << "Can not bind socket"; + FILE_LOG(logERROR) << "Can not bind socket. Please check if another process is running."; sockfd.fd =-1; - throw SocketError("Can not bind socket"); + throw SocketError("Can not bind socket. Please check if another process is running."); } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index a66a02f6c..63f474901 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -262,17 +262,6 @@ format */ enum { GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION }; - /** online flags enum \sa setOnline*/ - enum { - GET_ONLINE_FLAG = -1, /**< returns wether the detector is in online or - offline state */ - OFFLINE_FLAG = 0, /**< detector in offline state (i.e. no communication - to the detector - using only local structure - no - data acquisition possible!) */ - ONLINE_FLAG = 1 /**< detector in online state (i.e. communication to the - detector updating the local structure) */ - }; - /** flags to get (or set) the size of the detector */ diff --git a/slsSupportLib/src/ServerSocket.cpp b/slsSupportLib/src/ServerSocket.cpp index 8e8bcca8d..ea7c831f1 100755 --- a/slsSupportLib/src/ServerSocket.cpp +++ b/slsSupportLib/src/ServerSocket.cpp @@ -29,7 +29,7 @@ ServerSocket::ServerSocket(int port) if (bind(getSocketId(), (struct sockaddr *)&serverAddr, sizeof(serverAddr)) != 0) { close(); - throw sls::SocketError("Server ERROR: cannot bind socket"); + throw sls::SocketError("Server ERROR: cannot bind socket. Please check if another instance is running."); } if (listen(getSocketId(), DEFAULT_BACKLOG) != 0) { close();