From b2d39d4785b911b9fee1dc18a7fe7387d8486c89 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 9 Aug 2019 17:19:12 +0200 Subject: [PATCH] WIP done --- slsDetectorGui/src/qTabAdvanced.cpp | 2 +- slsDetectorGui/src/qTabDataOutput.cpp | 2 +- slsDetectorGui/src/qTabDebugging.cpp | 2 +- slsDetectorGui/src/qTabDeveloper.cpp | 2 +- slsDetectorSoftware/include/Detector.h | 48 ++++++++++ .../include/multiSlsDetector.h | 6 +- .../include/multiSlsDetectorClient.h | 2 +- slsDetectorSoftware/src/Detector.cpp | 80 ++++++++++++++++- .../src/slsDetectorCommand.cpp | 7 +- slsSupportLib/include/sls_detector_defs.h | 87 ++----------------- 10 files changed, 142 insertions(+), 96 deletions(-) diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 0faad922a..f1924f06e 100755 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -124,7 +124,7 @@ void qTabAdvanced::PopulateDetectors() { SLOT(SetDetector(int))); comboDetector->clear(); - for (int i = 0; i < myDet->size(); ++i) + for (unsigned int i = 0; i < myDet->size(); ++i) comboDetector->addItem(QString(myDet->getHostname(i).c_str())); comboDetector->setCurrentIndex(0); diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index da7b9d55b..afe65f3c3 100755 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -81,7 +81,7 @@ void qTabDataOutput::PopulateDetectors() { comboDetector->clear(); comboDetector->addItem("All"); if (myDet->size() > 1) { - for (int i = 0; i < myDet->size(); ++i) + for (unsigned int i = 0; i < myDet->size(); ++i) comboDetector->addItem(QString(myDet->getHostname(i).c_str())); } } diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index a62373c50..b9666f465 100755 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -55,7 +55,7 @@ void qTabDebugging::PopulateDetectors() { FILE_LOG(logDEBUG) << "Populating detectors"; comboDetector->clear(); - for (int i = 0; i < myDet->size(); ++i) { + for (unsigned int i = 0; i < myDet->size(); ++i) { comboDetector->addItem(QString(myDet->getHostname(i).c_str())); } } diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index 7326740ad..122c4daf0 100755 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -125,7 +125,7 @@ void qTabDeveloper::PopulateDetectors() { comboDetector->clear(); comboDetector->addItem("All"); if (myDet->size() > 1) { - for (int i = 0; i < myDet->size(); ++i) + for (unsigned int i = 0; i < myDet->size(); ++i) comboDetector->addItem(QString(myDet->getHostname(i).c_str())); } comboDetector->setCurrentIndex(0); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 97a2ba2e6..2ec121fed 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -908,6 +908,54 @@ class Detector { void setDAC(int value, defs::dacIndex index, bool mV, Positions pos = {}); + Result getTimingMode(Positions pos = {}) const; + + /** + * (Gotthard, Jungfrau, CTB Options: AUTO_TIMING, TRIGGER_EXPOSURE) + * (Eiger Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER) + */ + void setTimingMode(defs::externalCommunicationMode value, Positions pos = {}); + + /** + * (Gotthard) + */ + Result getExternalSignalFlags(Positions pos = {}) const; + + /** + * (Gotthard Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE) + */ + void setExternalSignalFlags(defs::externalSignalFlag value, Positions pos = {}); + + /** + * (Eiger) + */ + Result getParallelMode(Positions pos = {}) const; + + /** + * (Eiger) + */ + void setParallelMode(bool value, Positions pos = {}); + + /** + * (Eiger) + */ + Result getOverFlowMode(Positions pos = {}) const; + + /** + * (Eiger) + */ + void setOverFlowMode(bool value, Positions pos = {}); + + /** + * (CTB Options: NORMAL_READOUT = 0, DIGITAL_ONLY = 1, ANALOG_AND_DIGITAL = 2) + */ + Result getSignalType(Positions pos = {}) const; + + /** + * (CTB Options: NORMAL_READOUT = 0, DIGITAL_ONLY = 1, ANALOG_AND_DIGITAL = 2) + */ + void setSignalType(int value, Positions pos = {}); + // Erik Result getFramesCaughtByReceiver(Positions pos = {}) const; diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index a5929c2f5..d9b36a25e 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -886,7 +886,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ externalCommunicationMode setExternalCommunicationMode( externalCommunicationMode pol = GET_EXTERNAL_COMMUNICATION_MODE, - int detPos = -1); + int detPos = -1);// /** * Set/get external signal flags (to specify triggerinrising edge etc) @@ -897,7 +897,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ externalSignalFlag setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG, - int detPos = -1); + int detPos = -1);// /** * Set/get readout flags (Eiger, Mythen) @@ -906,7 +906,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * @param detPos -1 for all detectors in list or specific detector position * @returns readout flag */ - int setReadOutFlags(readOutFlags flag = GET_READOUT_FLAGS, int detPos = -1); + int setReadOutFlags(readOutFlags flag = GET_READOUT_FLAGS, int detPos = -1);// /** * Set Interrupt last sub frame (Only for Eiger) diff --git a/slsDetectorSoftware/include/multiSlsDetectorClient.h b/slsDetectorSoftware/include/multiSlsDetectorClient.h index c627d1813..e72e61332 100755 --- a/slsDetectorSoftware/include/multiSlsDetectorClient.h +++ b/slsDetectorSoftware/include/multiSlsDetectorClient.h @@ -101,7 +101,7 @@ class multiSlsDetectorClient { return; } } - if (parser.detector_id() >= detPtr->size()) { + if (parser.detector_id() >= static_cast(detPtr->size())) { os << "position is out of bounds.\n"; return; } diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 4f1ccdd86..c78da583a 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -597,7 +597,7 @@ Result Detector::getTemp(defs::dacIndex index, Positions pos) const { switch (getDetectorType()) { case defs::EIGER: case defs::JUNGFRAU: - for (auto it : pos) { + for (auto &it : res) { it /= 1000; } break; @@ -694,6 +694,82 @@ void Detector::setDAC(int value, defs::dacIndex index, bool mV, Positions pos) { pimpl->Parallel(&slsDetector::setDAC, pos, value, index, mV); } + Result Detector::getTimingMode(Positions pos) const { + return pimpl->Parallel(&slsDetector::setExternalCommunicationMode, pos, defs::GET_EXTERNAL_COMMUNICATION_MODE); + } + + void Detector::setTimingMode(defs::externalCommunicationMode value, Positions pos) { + pimpl->Parallel(&slsDetector::setExternalCommunicationMode, pos, value); + } + + Result Detector::getExternalSignalFlags(Positions pos) const { + return pimpl->Parallel(&slsDetector::setExternalSignalFlags, pos, defs::GET_EXTERNAL_SIGNAL_FLAG); + } + + void Detector::setExternalSignalFlags(defs::externalSignalFlag value, Positions pos) { + pimpl->Parallel(&slsDetector::setExternalSignalFlags, pos, value); + } + + Result Detector::getParallelMode(Positions pos) const { + auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos, defs::GET_READOUT_FLAGS); + Result booleanRes; + for (unsigned int i = 0; i < res.size(); ++i) { + booleanRes[i] = (res[i] & defs::PARALLEL) ? true : false; + } + return booleanRes; + } + + void Detector::setParallelMode(bool value, Positions pos) { + pimpl->Parallel(&slsDetector::setReadOutFlags, pos, value ? defs::PARALLEL : defs::NONPARALLEL); + } + + Result Detector::getOverFlowMode(Positions pos) const { + auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos, defs::GET_READOUT_FLAGS); + Result booleanRes; + for (unsigned int i = 0; i < res.size(); ++i) { + booleanRes[i] = (res[i] & defs::SHOW_OVERFLOW) ? true : false; + } + return booleanRes; + } + + void Detector::setOverFlowMode(bool value, Positions pos) { + pimpl->Parallel(&slsDetector::setReadOutFlags, pos, value ? defs::SHOW_OVERFLOW : defs::NOOVERFLOW); + } + + Result Detector::getSignalType(Positions pos) const { + auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos, defs::GET_READOUT_FLAGS); + for (auto &it : res) { + if (it & defs::ANALOG_AND_DIGITAL) { + it = 2; + } else if (it & defs::DIGITAL_ONLY) { + it = 1; + } else if (it == defs::NORMAL_READOUT) { + it = 0; + } else { + throw RuntimeError("Unknown Signal Type"); + } + } + return res; + } + + void Detector::setSignalType(int value, Positions pos) { + defs::readOutFlags flag; + switch (value) { + case 0: + flag = defs::NORMAL_READOUT; + break; + case 1: + flag = defs::DIGITAL_ONLY; + break; + case 2: + flag = defs::ANALOG_AND_DIGITAL; + break; + default: + throw RuntimeError("Unknown Signal Type"); + } + pimpl->Parallel(&slsDetector::setReadOutFlags, pos, flag); + } + // Erik Result Detector::getFramesCaughtByReceiver(Positions pos) const { return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos); @@ -912,7 +988,7 @@ Result Detector::getAutoCompDisable(Positions pos) const { void Detector::setPowerChip(bool on, Positions pos) { if (on && pimpl->size() > 3) { - for (int i = 0; i != pimpl->size(); ++i) { + for (unsigned int i = 0; i != pimpl->size(); ++i) { pimpl->powerChip(static_cast(on), i); usleep(1000 * 1000); } diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index c2a00202f..5243ef95b 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -378,8 +378,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { ++i; /*! \page config - - extsig [flag] sets/gets the mode of the external signal. Options: \c off, \c trigger_in_rising_edge, \c trigger_in_falling_edge, - \c trigger_out_rising_edge, \c trigger_out_falling_edge\n Used in GOTTHARDonly. \c Returns \c (string) + - extsig [flag] sets/gets the mode of the external signal. Options: \c trigger_in_rising_edge, \c trigger_in_falling_edge. Used in GOTTHARDonly. \c Returns \c (string) */ descrToFuncMap[i].m_pFuncName = "extsig"; /* find command! */ descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced; @@ -4815,7 +4814,7 @@ std::string slsDetectorCommand::helpAdvanced(int action) { std::ostringstream os; if (action == PUT_ACTION || action == HELP_ACTION) { - os << "extsig mode \t sets the mode of the external signal. can be \n \t \t \t off, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge" << std::endl; + os << "extsig mode \t sets the mode of the external signal. can be trigger_out_rising_edge, trigger_out_falling_edge. Gotthard only" << std::endl; os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, digital, analog_digital, overlow, nooverflow, unknown." << std::endl; os << "interruptsubframe flag \t sets the interrupt subframe flag. Setting it to 1 will interrupt the last subframe at the required exposure time. By default, this is disabled and set to 0, ie. it will wait for the last sub frame to finish exposing. Used for EIGER in 32 bit mode only." << std::endl; os << "readnlines f \t sets the number of rows to read out per half module. Options: 1 - 256 (Not all values as it depends on dynamic range and 10GbE enabled). Used for EIGER only. " << std::endl; @@ -4831,7 +4830,7 @@ std::string slsDetectorCommand::helpAdvanced(int action) { } if (action == GET_ACTION || action == HELP_ACTION) { - os << "extsig \t gets the mode of the external signal. can be \n \t \t \t off, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge" << std::endl; + os << "extsig \t gets the mode of the external signal. can be trigger_in_rising_edge, trigger_in_falling_edge. Gotthard only" << std::endl; os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, digital, analog_digital, overflow, nooverflow, unknown" << std::endl; os << "interruptsubframe \t gets the interrupt subframe flag. Setting it to 1 will interrupt the last subframe at the required exposure time. By default, this is disabled and set to 0, ie. it will wait for the last sub frame to finish exposing. Used for EIGER in 32 bit mode only." << std::endl; os << "readnlines \t gets the number of rows to read out per half module. Used for EIGER only. " << std::endl; diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 141ccd768..e224a319f 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -673,108 +673,31 @@ format }; /** returns std::string from external signal type index - \param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, - TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, - RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, - GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, - TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, - RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, - MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG \returns - std::string off, gate_in_active_high, gate_in_active_low, - trigger_in_rising_edge, trigger_in_falling_edge, - ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, - gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, - trigger_out_falling_edge, ro_trigger_out_rising_edge, - ro_trigger_out_falling_edge, gnd, vcc, sync, unknown + \param f can be TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, + \returns std::string trigger_in_rising_edge, trigger_in_falling_edge, unknown */ static std::string externalSignalType(externalSignalFlag f) { switch (f) { - case SIGNAL_OFF: - return std::string("off"); - case GATE_IN_ACTIVE_HIGH: - return std::string("gate_in_active_high"); - case GATE_IN_ACTIVE_LOW: - return std::string("gate_in_active_low"); case TRIGGER_IN_RISING_EDGE: return std::string("trigger_in_rising_edge"); case TRIGGER_IN_FALLING_EDGE: return std::string("trigger_in_falling_edge"); - case RO_TRIGGER_IN_RISING_EDGE: - return std::string("ro_trigger_in_rising_edge"); - case RO_TRIGGER_IN_FALLING_EDGE: - return std::string("ro_trigger_in_falling_edge"); - case GATE_OUT_ACTIVE_HIGH: - return std::string("gate_out_active_high"); - case GATE_OUT_ACTIVE_LOW: - return std::string("gate_out_active_low"); - case TRIGGER_OUT_RISING_EDGE: - return std::string("trigger_out_rising_edge"); - case TRIGGER_OUT_FALLING_EDGE: - return std::string("trigger_out_falling_edge"); - case RO_TRIGGER_OUT_RISING_EDGE: - return std::string("ro_trigger_out_rising_edge"); - case RO_TRIGGER_OUT_FALLING_EDGE: - return std::string("ro_trigger_out_falling_edge"); - case MASTER_SLAVE_SYNCHRONIZATION: - return std::string("sync"); - case OUTPUT_LOW: - return std::string("gnd"); - case OUTPUT_HIGH: - return std::string("vcc"); default: return std::string("unknown"); } }; /** returns external signal type index from std::string - \param sval off, gate_in_active_high, gate_in_active_low, - trigger_in_rising_edge, trigger_in_falling_edge, - ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, - gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, - trigger_out_falling_edge, ro_trigger_out_rising_edge, - ro_trigger_out_falling_edge, gnd, vcc, sync, unknown \returns can be - SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, - TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, - RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, - GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, - TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, - RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, - MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown) + \param sval trigger_in_rising_edge, trigger_in_falling_edge, unknown + \returns can be TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, + GET_EXTERNAL_SIGNAL_FLAG (if unknown) */ static externalSignalFlag externalSignalType(std::string sval) { - if (sval == "off") - return SIGNAL_OFF; - if (sval == "gate_in_active_high") - return GATE_IN_ACTIVE_HIGH; - if (sval == "gate_in_active_low") - return GATE_IN_ACTIVE_LOW; if (sval == "trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE; if (sval == "trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE; - if (sval == "ro_trigger_in_rising_edge") - return RO_TRIGGER_IN_RISING_EDGE; - if (sval == "ro_trigger_in_falling_edge") - return RO_TRIGGER_IN_FALLING_EDGE; - if (sval == "gate_out_active_high") - return GATE_OUT_ACTIVE_HIGH; - if (sval == "gate_out_active_low") - return GATE_OUT_ACTIVE_LOW; - if (sval == "trigger_out_rising_edge") - return TRIGGER_OUT_RISING_EDGE; - if (sval == "trigger_out_falling_edge") - return TRIGGER_OUT_FALLING_EDGE; - if (sval == "ro_trigger_out_rising_edge") - return RO_TRIGGER_OUT_RISING_EDGE; - if (sval == "ro_trigger_out_falling_edge") - return RO_TRIGGER_OUT_FALLING_EDGE; - if (sval == "sync") - return MASTER_SLAVE_SYNCHRONIZATION; - if (sval == "gnd") - return OUTPUT_LOW; - if (sval == "vcc") - return OUTPUT_HIGH; return GET_EXTERNAL_SIGNAL_FLAG; };