From a57f7943ee3a75238c45cb7f6ed24b5be18cfbd2 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 17 Jun 2020 18:30:25 +0200 Subject: [PATCH] WIP --- slsDetectorSoftware/include/Detector.h | 30 +- slsDetectorSoftware/src/Detector.cpp | 61 +- slsDetectorSoftware/src/Module.cpp | 1193 ++++++++++++------------ slsDetectorSoftware/src/Module.h | 554 +++-------- 4 files changed, 784 insertions(+), 1054 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 6ea27deae..b7b4540d2 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -327,6 +327,21 @@ class Detector { void setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos = {}); + /** [Gotthard] signal index is 0 + * [Mythen3] signal index 0-3 for master input, 4-7 master output signals */ + Result + getExternalSignalFlags(int signalIndex, Positions pos = {}) const; + + /** [Gotthard] signal index is 0 + * Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE + * [Mythen3] signal index 0 is master input trigger signal, 1-3 for master + * input gate signals, 4 is busy out signal, 5-7 is master output gate + * signals. + * Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE (for + * master input trigger only), INVERSION_ON, INVERSION_OFF */ + void setExternalSignalFlags(int signalIndex, defs::externalSignalFlag value, + Positions pos = {}); + /************************************************** * * * Acquisition * @@ -925,21 +940,6 @@ class Detector { /** [Gotthard] */ Result getExptimeLeft(Positions pos = {}) const; - /** [Gotthard] signal index is 0 - * [Mythen3] signal index 0-3 for master input, 4-7 master output signals */ - Result - getExternalSignalFlags(int signalIndex, Positions pos = {}) const; - - /** [Gotthard] signal index is 0 - * Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE - * [Mythen3] signal index 0 is master input trigger signal, 1-3 for master - * input gate signals, 4 is busy out signal, 5-7 is master output gate - * signals. - * Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE (for - * master input trigger only), INVERSION_ON, INVERSION_OFF */ - void setExternalSignalFlags(int signalIndex, defs::externalSignalFlag value, - Positions pos = {}); - /************************************************** * * * Gotthard2 Specific * diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index cf91efb03..1d53c48be 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -503,6 +503,17 @@ void Detector::setOnChipDAC(defs::dacIndex index, int chipIndex, int value, pimpl->Parallel(&Module::setOnChipDAC, pos, index, chipIndex, value); } +Result +Detector::getExternalSignalFlags(int signalIndex, Positions pos) const { + return pimpl->Parallel(&Module::getExternalSignalFlags, pos, signalIndex); +} + +void Detector::setExternalSignalFlags(int signalIndex, + defs::externalSignalFlag value, + Positions pos) { + pimpl->Parallel(&Module::setExternalSignalFlags, pos, signalIndex, value); +} + // Acquisition void Detector::acquire() { pimpl->acquire(); } @@ -826,11 +837,11 @@ Result Detector::getRxRealUDPSocketBufferSize(Positions pos) const { } Result Detector::getRxLock(Positions pos) { - return pimpl->Parallel(&Module::lockReceiver, pos, -1); + return pimpl->Parallel(&Module::getReceiverLock, pos); } void Detector::setRxLock(bool value, Positions pos) { - pimpl->Parallel(&Module::lockReceiver, pos, static_cast(value)); + pimpl->Parallel(&Module::setReceiverLock, pos, value); } Result Detector::getRxLastClientIP(Positions pos) const { @@ -927,7 +938,7 @@ void Detector::setRxZmqFrequency(int freq, Positions pos) { } Result Detector::getRxZmqTimer(Positions pos) const { - return pimpl->Parallel(&Module::setReceiverStreamingTimer, pos, -1); + return pimpl->Parallel(&Module::getReceiverStreamingTimer, pos); } void Detector::setRxZmqTimer(int time_in_ms, Positions pos) { @@ -1130,16 +1141,11 @@ void Detector::setRxPadDeactivatedMode(bool pad, Positions pos) { } Result Detector::getPartialReset(Positions pos) const { - auto res = pimpl->Parallel(&Module::setCounterBit, pos, -1); - Result t(res.size()); - for (unsigned int i = 0; i < res.size(); ++i) { - t[i] = !res[i]; - } - return t; + return pimpl->Parallel(&Module::getCounterBit, pos); } void Detector::setPartialReset(bool value, Positions pos) { - pimpl->Parallel(&Module::setCounterBit, pos, !value); + pimpl->Parallel(&Module::setCounterBit, pos, value); } void Detector::pulsePixel(int n, defs::xy pixel, Positions pos) { @@ -1169,41 +1175,35 @@ void Detector::setQuad(const bool enable) { // Jungfrau Specific Result Detector::getThresholdTemperature(Positions pos) const { - auto res = pimpl->Parallel(&Module::setThresholdTemperature, pos, -1); - for (auto &it : res) { - it /= 1000; - } - return res; + return pimpl->Parallel(&Module::getThresholdTemperature, pos); } void Detector::setThresholdTemperature(int temp, Positions pos) { - pimpl->Parallel(&Module::setThresholdTemperature, pos, temp * 1000); + pimpl->Parallel(&Module::setThresholdTemperature, pos, temp); } Result Detector::getTemperatureControl(Positions pos) const { - return pimpl->Parallel(&Module::setTemperatureControl, pos, -1); + return pimpl->Parallel(&Module::getTemperatureControl, pos); } void Detector::setTemperatureControl(bool enable, Positions pos) { - pimpl->Parallel(&Module::setTemperatureControl, pos, - static_cast(enable)); + pimpl->Parallel(&Module::setTemperatureControl, pos, enable); } Result Detector::getTemperatureEvent(Positions pos) const { - return pimpl->Parallel(&Module::setTemperatureEvent, pos, -1); + return pimpl->Parallel(&Module::getTemperatureEvent, pos); } void Detector::resetTemperatureEvent(Positions pos) { - pimpl->Parallel(&Module::setTemperatureEvent, pos, 0); + pimpl->Parallel(&Module::resetTemperatureEvent, pos); } Result Detector::getAutoCompDisable(Positions pos) const { - return pimpl->Parallel(&Module::setAutoComparatorDisableMode, pos, -1); + return pimpl->Parallel(&Module::getAutoComparatorDisableMode, pos); } void Detector::setAutoCompDisable(bool value, Positions pos) { - pimpl->Parallel(&Module::setAutoComparatorDisableMode, pos, - static_cast(value)); + pimpl->Parallel(&Module::setAutoComparatorDisableMode, pos, value); } Result Detector::getNumberOfAdditionalStorageCells(Positions pos) const { @@ -1215,7 +1215,7 @@ void Detector::setNumberOfAdditionalStorageCells(int value) { } Result Detector::getStorageCellStart(Positions pos) const { - return pimpl->Parallel(&Module::setStorageCellStart, pos, -1); + return pimpl->Parallel(&Module::getStorageCellStart, pos); } void Detector::setStorageCellStart(int cell, Positions pos) { @@ -1251,17 +1251,6 @@ Result Detector::getExptimeLeft(Positions pos) const { return pimpl->Parallel(&Module::getExptimeLeft, pos); } -Result -Detector::getExternalSignalFlags(int signalIndex, Positions pos) const { - return pimpl->Parallel(&Module::getExternalSignalFlags, pos, signalIndex); -} - -void Detector::setExternalSignalFlags(int signalIndex, - defs::externalSignalFlag value, - Positions pos) { - pimpl->Parallel(&Module::setExternalSignalFlags, pos, signalIndex, value); -} - // Gotthard2 Specific Result Detector::getNumberOfBursts(Positions pos) const { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index bcf01e5be..2ac00bddc 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -332,6 +332,19 @@ void Module::setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, sendToDetector(F_SET_ON_CHIP_DAC, args, nullptr); } +slsDetectorDefs::externalSignalFlag +Module::getExternalSignalFlags(int signalIndex) { + return sendToDetector( + F_GET_EXTERNAL_SIGNAL_FLAG, signalIndex); +} + +void Module::setExternalSignalFlags(int signalIndex, externalSignalFlag type) { + int args[]{signalIndex, static_cast(type)}; + sendToDetector(F_SET_EXTERNAL_SIGNAL_FLAG, args, nullptr); +} + +// Acquisition + void Module::startReceiver() { shm()->stoppedFlag = false; sendToReceiver(F_START_RECEIVER, nullptr, nullptr); @@ -417,6 +430,8 @@ void Module::setStartingFrameNumber(uint64_t value) { void Module::sendSoftwareTrigger() { sendToDetectorStop(F_SOFTWARE_TRIGGER); } +// Network Configuration (Detector<->Receiver) + int Module::getNumberofUDPInterfacesFromShm() { return shm()->numUDPInterfaces; } @@ -645,6 +660,8 @@ void Module::setTransmissionDelayRight(int value) { sendToDetector(F_SET_TRANSMISSION_DELAY_RIGHT, value, nullptr); } +// Receiver Config + bool Module::getUseReceiverFlag() const { return shm()->useReceiverFlag; } std::string Module::getReceiverHostname() const { @@ -752,6 +769,576 @@ void Module::setReceiverSilentMode(bool enable) { nullptr); } +slsDetectorDefs::frameDiscardPolicy Module::getReceiverFramesDiscardPolicy() { + return static_cast( + sendToReceiver(F_GET_RECEIVER_DISCARD_POLICY)); +} + +void Module::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) { + sendToReceiver(F_SET_RECEIVER_DISCARD_POLICY, static_cast(f), nullptr); +} + +bool Module::getPartialFramesPadding() { + return sendToReceiver(F_GET_RECEIVER_PADDING); +} + +void Module::setPartialFramesPadding(bool padding) { + sendToReceiver(F_SET_RECEIVER_PADDING, static_cast(padding), nullptr); +} + +int64_t Module::getReceiverUDPSocketBufferSize() const { + int arg = -1; + return sendToReceiver(F_RECEIVER_UDP_SOCK_BUF_SIZE, arg); +} + +int64_t Module::getReceiverRealUDPSocketBufferSize() const { + return sendToReceiver(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE); +} + +void Module::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize) { + sendToReceiver(F_RECEIVER_UDP_SOCK_BUF_SIZE, udpsockbufsize); +} + +bool Module::getReceiverLock() { + int arg = -1; + return static_cast(sendToReceiver(F_LOCK_RECEIVER, arg)); +} + +void Module::setReceiverLock(bool lock) { + sendToReceiver(F_LOCK_RECEIVER, static_cast(lock)); +} + +sls::IpAddr Module::getReceiverLastClientIP() const { + return sendToReceiver(F_GET_LAST_RECEIVER_CLIENT_IP); +} + +std::array Module::getReceiverThreadIds() const { + return sendToReceiver>( + F_GET_RECEIVER_THREAD_IDS); +} + +// File + +slsDetectorDefs::fileFormat Module::getFileFormat() { + return static_cast( + sendToReceiver(F_GET_RECEIVER_FILE_FORMAT)); +} + +void Module::setFileFormat(fileFormat f) { + sendToReceiver(F_SET_RECEIVER_FILE_FORMAT, static_cast(f), nullptr); +} + +std::string Module::getFilePath() { + char ret[MAX_STR_LENGTH]{}; + sendToReceiver(F_GET_RECEIVER_FILE_PATH, nullptr, ret); + return ret; +} + +void Module::setFilePath(const std::string &path) { + if (path.empty()) { + throw RuntimeError("Cannot set empty file path"); + } + char args[MAX_STR_LENGTH]{}; + sls::strcpy_safe(args, path.c_str()); + sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr); +} + +std::string Module::getFileName() { + char retvals[MAX_STR_LENGTH]{}; + sendToReceiver(F_GET_RECEIVER_FILE_NAME, nullptr, retvals); + return std::string(retvals); +} + +void Module::setFileName(const std::string &fname) { + if (fname.empty()) { + throw RuntimeError("Cannot set empty file name prefix"); + } + char args[MAX_STR_LENGTH]{}; + sls::strcpy_safe(args, fname.c_str()); + sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr); +} + +int64_t Module::getFileIndex() { + return sendToReceiver(F_GET_RECEIVER_FILE_INDEX); +} + +void Module::setFileIndex(int64_t file_index) { + sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr); +} + +void Module::incrementFileIndex() { + sendToReceiver(F_INCREMENT_FILE_INDEX, nullptr, nullptr); +} + +bool Module::getFileWrite() { + return sendToReceiver(F_GET_RECEIVER_FILE_WRITE); +} + +void Module::setFileWrite(bool value) { + sendToReceiver(F_SET_RECEIVER_FILE_WRITE, static_cast(value), nullptr); +} + +bool Module::getMasterFileWrite() { + return sendToReceiver(F_GET_RECEIVER_MASTER_FILE_WRITE); +} + +void Module::setMasterFileWrite(bool value) { + sendToReceiver(F_SET_RECEIVER_MASTER_FILE_WRITE, static_cast(value), + nullptr); +} + +bool Module::getFileOverWrite() { + return sendToReceiver(F_GET_RECEIVER_OVERWRITE); +} + +void Module::setFileOverWrite(bool value) { + sendToReceiver(F_SET_RECEIVER_OVERWRITE, static_cast(value), nullptr); +} + +int Module::getFramesPerFile() { + return sendToReceiver(F_GET_RECEIVER_FRAMES_PER_FILE); +} + +void Module::setFramesPerFile(int n_frames) { + sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, nullptr); +} + +// ZMQ Streaming Parameters (Receiver<->Client) + +bool Module::getReceiverStreaming() { + return sendToReceiver(F_GET_RECEIVER_STREAMING); +} + +void Module::setReceiverStreaming(bool enable) { + sendToReceiver(F_SET_RECEIVER_STREAMING, static_cast(enable), nullptr); +} + +int Module::getReceiverStreamingFrequency() { + return sendToReceiver(F_GET_RECEIVER_STREAMING_FREQUENCY); +} + +void Module::setReceiverStreamingFrequency(int freq) { + if (freq < 0) { + throw RuntimeError("Invalid streaming frequency " + + std::to_string(freq)); + } + sendToReceiver(F_SET_RECEIVER_STREAMING_FREQUENCY, freq, nullptr); +} + +int Module::getReceiverStreamingTimer() { + int arg = -1; + return sendToReceiver(F_RECEIVER_STREAMING_TIMER, arg); +} + +void Module::setReceiverStreamingTimer(int time_in_ms) { + sendToReceiver(F_RECEIVER_STREAMING_TIMER, time_in_ms); +} + +int Module::getReceiverStreamingPort() { + return sendToReceiver(F_GET_RECEIVER_STREAMING_PORT); +} + +void Module::setReceiverStreamingPort(int port) { + sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr); +} + +sls::IpAddr Module::getReceiverStreamingIP() { + return sendToReceiver(F_GET_RECEIVER_STREAMING_SRC_IP); +} + +void Module::setReceiverStreamingIP(const sls::IpAddr ip) { + if (ip == 0) { + throw RuntimeError("Invalid receiver zmq ip address"); + } + // if client zmqip is empty, update it + if (shm()->zmqip == 0) { + shm()->zmqip = ip; + } + sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr); +} + +int Module::getClientStreamingPort() { return shm()->zmqport; } + +void Module::setClientStreamingPort(int port) { shm()->zmqport = port; } + +sls::IpAddr Module::getClientStreamingIP() { return shm()->zmqip; } + +void Module::setClientStreamingIP(const sls::IpAddr ip) { + if (ip == 0) { + throw RuntimeError("Invalid client zmq ip address"); + } + shm()->zmqip = ip; +} + +// Eiger Specific + +int Module::getDynamicRange() { + return sendToDetector(F_SET_DYNAMIC_RANGE, -1); +} + +void Module::setDynamicRange(int n) { + int prev_val = n; + if (shm()->myDetectorType == EIGER) { + prev_val = getDynamicRange(); + } + + auto retval = sendToDetector(F_SET_DYNAMIC_RANGE, n); + if (shm()->useReceiverFlag) { + int arg = retval; + sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, arg); + } + + // changes in dr + if (n != prev_val) { + // update speed for usability + if (n == 32) { + LOG(logINFO) << "Setting Clock to Quarter Speed to cope with " + "Dynamic Range of 32"; + setClockDivider(RUN_CLOCK, 2); + } else if (prev_val == 32) { + LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of " + << n; + setClockDivider(RUN_CLOCK, 0); + } + updateRateCorrection(); + } +} + +int64_t Module::getSubExptime() { + return sendToDetector(F_GET_SUB_EXPTIME); +} + +void Module::setSubExptime(int64_t value) { + int64_t prevVal = value; + if (shm()->myDetectorType == EIGER) { + prevVal = getSubExptime(); + } + sendToDetector(F_SET_SUB_EXPTIME, value, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_SUB_EXPTIME, value, nullptr); + } + if (prevVal != value) { + updateRateCorrection(); + } +} + +int64_t Module::getSubDeadTime() { + return sendToDetector(F_GET_SUB_DEADTIME); +} + +void Module::setSubDeadTime(int64_t value) { + sendToDetector(F_SET_SUB_DEADTIME, value, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_SUB_DEADTIME, value, nullptr); + } +} + +int Module::getThresholdEnergy() { + // moench - get threshold energy from json header + if (shm()->myDetectorType == MOENCH) { + getAdditionalJsonHeader(); + std::string result = getAdditionalJsonParameter("threshold"); + // convert to integer + try { + return std::stoi(result); + } + // not found or cannot scan integer + catch (...) { + return -1; + } + } + return sendToDetector(F_GET_THRESHOLD_ENERGY); +} + +void Module::setThresholdEnergy(int e_eV, detectorSettings isettings, + bool trimbits) { + // check as there is client processing + if (shm()->myDetectorType == EIGER) { + setThresholdEnergyAndSettings(e_eV, isettings, trimbits); + } + // moench - send threshold energy to processor + else if (shm()->myDetectorType == MOENCH) { + setAdditionalJsonParameter("threshold", std::to_string(e_eV)); + } else { + throw RuntimeError( + "Set threshold energy not implemented for this detector"); + } +} + +std::string Module::getSettingsDir() { return std::string(shm()->settingsDir); } + +std::string Module::setSettingsDir(const std::string &dir) { + sls::strcpy_safe(shm()->settingsDir, dir.c_str()); + return shm()->settingsDir; +} + +bool Module::getParallelMode() { + auto r = sendToDetector(F_GET_PARALLEL_MODE); + return static_cast(r); +} + +void Module::setParallelMode(const bool enable) { + sendToDetector(F_SET_PARALLEL_MODE, static_cast(enable), nullptr); +} + +bool Module::getOverFlowMode() { + auto r = sendToDetector(F_GET_OVERFLOW_MODE); + return static_cast(r); +} + +void Module::setOverFlowMode(const bool enable) { + int arg = static_cast(enable); + sendToDetector(F_SET_OVERFLOW_MODE, arg, nullptr); +} + +bool Module::getStoreInRamMode() { + auto r = sendToDetector(F_GET_STOREINRAM_MODE); + return static_cast(r); +} + +void Module::setStoreInRamMode(const bool enable) { + int arg = static_cast(enable); + sendToDetector(F_SET_STOREINRAM_MODE, arg, nullptr); +} + +bool Module::getFlippedDataX() { + return sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, -1); +} + +void Module::setFlippedDataX(bool value) { + sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, static_cast(value)); +} + +std::vector Module::getTrimEn() { + if (shm()->myDetectorType != EIGER) { + throw RuntimeError("getTrimEn not implemented for this detector."); + } + return std::vector(shm()->trimEnergies.begin(), + shm()->trimEnergies.end()); +} + +int Module::setTrimEn(const std::vector &energies) { + if (shm()->myDetectorType != EIGER) { + throw RuntimeError("setTrimEn not implemented for this detector."); + } + if (energies.size() > MAX_TRIMEN) { + std::ostringstream os; + os << "Size of trim energies: " << energies.size() + << " exceeds what can be stored in shared memory: " << MAX_TRIMEN + << "\n"; + throw RuntimeError(os.str()); + } + shm()->trimEnergies = energies; + return shm()->trimEnergies.size(); +} + +int64_t Module::getRateCorrection() { + return sendToDetector(F_GET_RATE_CORRECT); +} + +void Module::setDefaultRateCorrection() { + int64_t arg = -1; + sendToDetector(F_SET_RATE_CORRECT, arg, nullptr); +} + +void Module::setRateCorrection(int64_t t) { + sendToDetector(F_SET_RATE_CORRECT, t, nullptr); +} + +int Module::getReadNLines() { return sendToDetector(F_GET_READ_N_LINES); } + +void Module::setReadNLines(const int value) { + sendToDetector(F_SET_READ_N_LINES, value, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SET_RECEIVER_READ_N_LINES, value, nullptr); + } +} + +bool Module::getInterruptSubframe() { + auto r = sendToDetector(F_GET_INTERRUPT_SUBFRAME); + return static_cast(r); +} + +void Module::setInterruptSubframe(const bool enable) { + int arg = static_cast(enable); + sendToDetector(F_SET_INTERRUPT_SUBFRAME, arg, nullptr); +} + +int64_t Module::getMeasuredPeriod() const { + return sendToDetectorStop(F_GET_MEASURED_PERIOD); +} + +int64_t Module::getMeasuredSubFramePeriod() const { + return sendToDetectorStop(F_GET_MEASURED_SUBPERIOD); +} + +bool Module::getActivate() { + int arg = -1; + auto retval = sendToDetector(F_ACTIVATE, arg); + auto retval2 = sendToDetectorStop(F_ACTIVATE, arg); + if (retval != retval2) { + std::ostringstream oss; + oss << "Inconsistent activate state. Control Server: " << retval + << ". Stop Server: " << retval2; + throw RuntimeError(oss.str()); + } + return retval; +} + +void Module::setActivate(const bool enable) { + int arg = static_cast(enable); + auto retval = sendToDetector(F_ACTIVATE, arg); + sendToDetectorStop(F_ACTIVATE, arg); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_ACTIVATE, retval, nullptr); + } +} + +bool Module::getDeactivatedRxrPaddingMode() { + return sendToReceiver(F_GET_RECEIVER_DEACTIVATED_PADDING); +} + +void Module::setDeactivatedRxrPaddingMode(bool padding) { + sendToReceiver(F_SET_RECEIVER_DEACTIVATED_PADDING, + static_cast(padding), nullptr); +} + +bool Module::getCounterBit() { + int arg = -1; + return (!static_cast(sendToDetector(F_SET_COUNTER_BIT, arg))); +} + +void Module::setCounterBit(bool cb) { + sendToDetector(F_SET_COUNTER_BIT, static_cast(!cb)); +} + +void Module::pulsePixel(int n, int x, int y) { + int args[]{n, x, y}; + sendToDetector(F_PULSE_PIXEL, args, nullptr); +} + +void Module::pulsePixelNMove(int n, int x, int y) { + int args[]{n, x, y}; + sendToDetector(F_PULSE_PIXEL_AND_MOVE, args, nullptr); +} + +void Module::pulseChip(int n_pulses) { + sendToDetector(F_PULSE_CHIP, n_pulses, nullptr); +} + +bool Module::getQuad() { return sendToDetector(F_GET_QUAD) != 0; } + +void Module::setQuad(const bool enable) { + int value = enable ? 1 : 0; + sendToDetector(F_SET_QUAD, value, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr); + } +} + +// Jungfrau Specific + +int Module::getThresholdTemperature() { + int arg = -1; + auto retval = sendToDetectorStop(F_THRESHOLD_TEMP, arg); + if (retval != 0) { + retval /= 1000; + } + return retval; +} + +void Module::setThresholdTemperature(int val) { + if (val <= 0) { + throw RuntimeError("Invalid threshold temperature " + + std::to_string(val)); + } + val *= 1000; + sendToDetectorStop(F_THRESHOLD_TEMP, val); +} + +bool Module::getTemperatureControl() { + int arg = -1; + return static_cast(sendToDetectorStop(F_TEMP_CONTROL, arg)); +} + +void Module::setTemperatureControl(bool val) { + sendToDetectorStop(F_TEMP_CONTROL, static_cast(val)); +} + +int Module::getTemperatureEvent() { + int arg = -1; + return sendToDetectorStop(F_TEMP_EVENT, arg); +} + +void Module::resetTemperatureEvent() { + int arg = 0; + sendToDetectorStop(F_TEMP_EVENT, arg); +} + +bool Module::getAutoComparatorDisableMode() { + int arg = -1; + return static_cast(sendToDetector(F_AUTO_COMP_DISABLE, arg)); +} + +void Module::setAutoComparatorDisableMode(bool val) { + sendToDetector(F_AUTO_COMP_DISABLE, static_cast(val)); +} + +int Module::getNumberOfAdditionalStorageCells() { + return sendToDetector(F_GET_NUM_ADDITIONAL_STORAGE_CELLS); +} + +void Module::setNumberOfAdditionalStorageCells(int value) { + sendToDetector(F_SET_NUM_ADDITIONAL_STORAGE_CELLS, value, nullptr); +} + +int Module::getStorageCellStart() { + int arg = -1; + return sendToDetector(F_STORAGE_CELL_START, arg); +} + +void Module::setStorageCellStart(int pos) { + sendToDetector(F_STORAGE_CELL_START, pos); +} + +int64_t Module::getStorageCellDelay() { + return sendToDetector(F_GET_STORAGE_CELL_DELAY); +} + +void Module::setStorageCellDelay(int64_t value) { + sendToDetector(F_SET_STORAGE_CELL_DELAY, value, nullptr); +} + +// Gotthard Specific + +slsDetectorDefs::ROI Module::getROI() { + return sendToDetector(F_GET_ROI); +} + +void Module::setROI(slsDetectorDefs::ROI arg) { + if (arg.xmin < 0 || arg.xmax >= getNumberOfChannels().x) { + arg.xmin = -1; + arg.xmax = -1; + } + sendToDetector(F_SET_ROI, arg, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_ROI, arg, nullptr); + } +} + +void Module::clearROI() { setROI(slsDetectorDefs::ROI{}); } + +int64_t Module::getExptimeLeft() const { + int64_t retval = -1; + sendToDetectorStop(F_GET_EXPTIME_LEFT, nullptr, retval); + LOG(logDEBUG1) << "exptime left :" << retval << "ns"; + return retval; +} + +// Gotthard2 Specific + +// private + void Module::sendToDetector(int fnum, const void *args, size_t args_size, void *retval, size_t retval_size) { auto client = DetectorSocket(shm()->hostname, shm()->controlPort); @@ -1250,29 +1837,6 @@ int Module::receiveModule(sls_detector_module *myMod, return ts; } -bool Module::getQuad() { return sendToDetector(F_GET_QUAD) != 0; } - -void Module::setQuad(const bool enable) { - int value = enable ? 1 : 0; - LOG(logDEBUG1) << "Setting Quad type to " << value; - sendToDetector(F_SET_QUAD, value, nullptr); - LOG(logDEBUG1) << "Setting Quad type to " << value << " in Receiver"; - if (shm()->useReceiverFlag) { - sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr); - } -} - -void Module::setReadNLines(const int value) { - LOG(logDEBUG1) << "Setting read n lines to " << value; - sendToDetector(F_SET_READ_N_LINES, value, nullptr); - LOG(logDEBUG1) << "Setting read n lines to " << value << " in Receiver"; - if (shm()->useReceiverFlag) { - sendToReceiver(F_SET_RECEIVER_READ_N_LINES, value, nullptr); - } -} - -int Module::getReadNLines() { return sendToDetector(F_GET_READ_N_LINES); } - int Module::setControlPort(int port_number) { int retval = -1; LOG(logDEBUG1) << "Setting control port to " << port_number; @@ -1402,44 +1966,8 @@ std::vector Module::getConfigFileCommands() { return commands; } -int Module::getThresholdEnergy() { - // moench - get threshold energy from processor (due to different clients, - // diff shm) - if (shm()->myDetectorType == MOENCH) { - // get json from rxr, parse for threshold and update shm - getAdditionalJsonHeader(); - std::string result = getAdditionalJsonParameter("threshold"); - // convert to integer - try { - return std::stoi(result); - } - // not found or cannot scan integer - catch (...) { - return -1; - } - } - return sendToDetector(F_GET_THRESHOLD_ENERGY); -} - -void Module::setThresholdEnergy(int e_eV, detectorSettings isettings, int tb) { - // check as there is client processing - if (shm()->myDetectorType == EIGER) { - setThresholdEnergyAndSettings(e_eV, isettings, tb); - } - - // moench - send threshold energy to processor - else if (shm()->myDetectorType == MOENCH) { - setAdditionalJsonParameter("threshold", std::to_string(e_eV)); - } - - else { - throw RuntimeError( - "Set threshold energy not implemented for this detector"); - } -} - void Module::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, - int tb) { + bool trimbits) { // if settings provided, use that, else use the shared memory variable detectorSettings is = @@ -1461,7 +1989,7 @@ void Module::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, if (!interpolate) { std::string settingsfname = getTrimbitFilename(is, e_eV); LOG(logDEBUG1) << "Settings File is " << settingsfname; - myMod = readSettingsFile(settingsfname, tb); + myMod = readSettingsFile(settingsfname, trimbits); } else { // find the trim values int trim1 = -1, trim2 = -1; @@ -1476,13 +2004,13 @@ void Module::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, std::string settingsfname2 = getTrimbitFilename(is, trim2); LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and " << settingsfname2; - auto myMod1 = readSettingsFile(settingsfname1, tb); - auto myMod2 = readSettingsFile(settingsfname2, tb); + auto myMod1 = readSettingsFile(settingsfname1, trimbits); + auto myMod2 = readSettingsFile(settingsfname2, trimbits); if (myMod1.iodelay != myMod2.iodelay) { throw RuntimeError("setThresholdEnergyAndSettings: Iodelays do not " "match between files"); } - myMod = interpolateTrim(&myMod1, &myMod2, e_eV, trim1, trim2, tb); + myMod = interpolateTrim(&myMod1, &myMod2, e_eV, trim1, trim2, trimbits); myMod.iodelay = myMod1.iodelay; myMod.tau = linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau); @@ -1490,7 +2018,7 @@ void Module::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, myMod.reg = is; myMod.eV = e_eV; - setModule(myMod, tb); + setModule(myMod, trimbits); if (getSettings() != is) { throw RuntimeError("setThresholdEnergyAndSettings: Could not set " "settings in detector"); @@ -1527,13 +2055,6 @@ std::string Module::getTrimbitFilename(detectorSettings s, int e_eV) { return ostfn.str(); } -std::string Module::getSettingsDir() { return std::string(shm()->settingsDir); } - -std::string Module::setSettingsDir(const std::string &dir) { - sls::strcpy_safe(shm()->settingsDir, dir.c_str()); - return shm()->settingsDir; -} - void Module::startAndReadAll() { shm()->stoppedFlag = false; sendToDetector(F_START_AND_READ_ALL); @@ -1556,15 +2077,6 @@ void Module::setNumberOfBursts(int64_t value) { } } -int Module::getNumberOfAdditionalStorageCells() { - return sendToDetector(F_GET_NUM_ADDITIONAL_STORAGE_CELLS); -} - -void Module::setNumberOfAdditionalStorageCells(int value) { - LOG(logDEBUG1) << "Setting number of storage cells to " << value; - sendToDetector(F_SET_NUM_ADDITIONAL_STORAGE_CELLS, value, nullptr); -} - int Module::getNumberOfAnalogSamples() { return sendToDetector(F_GET_NUM_ANALOG_SAMPLES); } @@ -1664,68 +2176,7 @@ void Module::setBurstPeriod(int64_t value) { sendToDetector(F_SET_BURST_PERIOD, value, nullptr); } -int64_t Module::getSubExptime() { - return sendToDetector(F_GET_SUB_EXPTIME); -} - -void Module::setSubExptime(int64_t value) { - int64_t prevVal = value; - if (shm()->myDetectorType == EIGER) { - prevVal = getSubExptime(); - } - LOG(logDEBUG1) << "Setting sub exptime to " << value << "ns"; - sendToDetector(F_SET_SUB_EXPTIME, value, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending sub exptime to Receiver: " << value; - sendToReceiver(F_RECEIVER_SET_SUB_EXPTIME, value, nullptr); - } - if (prevVal != value) { - updateRateCorrection(); - } -} - -int64_t Module::getSubDeadTime() { - return sendToDetector(F_GET_SUB_DEADTIME); -} - -void Module::setSubDeadTime(int64_t value) { - LOG(logDEBUG1) << "Setting sub deadtime to " << value << "ns"; - sendToDetector(F_SET_SUB_DEADTIME, value, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending sub deadtime to Receiver: " << value; - sendToReceiver(F_RECEIVER_SET_SUB_DEADTIME, value, nullptr); - } -} - -int64_t Module::getStorageCellDelay() { - return sendToDetector(F_GET_STORAGE_CELL_DELAY); -} - -void Module::setStorageCellDelay(int64_t value) { - LOG(logDEBUG1) << "Setting storage cell delay to " << value << "ns"; - sendToDetector(F_SET_STORAGE_CELL_DELAY, value, nullptr); -} - -int64_t Module::getExptimeLeft() const { - int64_t retval = -1; - sendToDetectorStop(F_GET_EXPTIME_LEFT, nullptr, retval); - LOG(logDEBUG1) << "exptime left :" << retval << "ns"; - return retval; -} - -int64_t Module::getMeasuredPeriod() const { - int64_t retval = -1; - sendToDetectorStop(F_GET_MEASURED_PERIOD, nullptr, retval); - LOG(logDEBUG1) << "measured period :" << retval << "ns"; - return retval; -} - -int64_t Module::getMeasuredSubFramePeriod() const { - int64_t retval = -1; - sendToDetectorStop(F_GET_MEASURED_SUBPERIOD, nullptr, retval); - LOG(logDEBUG1) << "exptime :" << retval << "ns"; - return retval; -} +// Acquisition Parameters int64_t Module::getNumberOfFramesFromStart() const { int64_t retval = -1; @@ -1748,89 +2199,6 @@ int64_t Module::getMeasurementTime() const { return retval; } -int Module::getDynamicRange() { - return sendToDetector(F_SET_DYNAMIC_RANGE, -1); -} - -void Module::setDynamicRange(int n) { - int prev_val = n; - if (shm()->myDetectorType == EIGER) { - prev_val = getDynamicRange(); - } - - int retval = -1; - LOG(logDEBUG1) << "Setting dynamic range to " << n; - sendToDetector(F_SET_DYNAMIC_RANGE, n, retval); - LOG(logDEBUG1) << "Dynamic Range: " << retval; - - if (shm()->useReceiverFlag) { - int arg = retval; - retval = -1; - LOG(logDEBUG1) << "Sending dynamic range to receiver: " << arg; - sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, arg, retval); - LOG(logDEBUG1) << "Receiver Dynamic range: " << retval; - } - - // changes in dr - if (n != prev_val) { - // update speed for usability - if (n == 32) { - LOG(logINFO) << "Setting Clock to Quarter Speed to cope with " - "Dynamic Range of 32"; - setClockDivider(RUN_CLOCK, 2); - } else if (prev_val == 32) { - LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of " - << n; - setClockDivider(RUN_CLOCK, 0); - } - updateRateCorrection(); - } -} - -slsDetectorDefs::externalSignalFlag -Module::getExternalSignalFlags(int signalIndex) { - return sendToDetector( - F_GET_EXTERNAL_SIGNAL_FLAG, signalIndex); -} - -void Module::setExternalSignalFlags(int signalIndex, externalSignalFlag type) { - LOG(logDEBUG1) << "Setting signal flag (" << signalIndex << ") to " << type; - int args[]{signalIndex, static_cast(type)}; - sendToDetector(F_SET_EXTERNAL_SIGNAL_FLAG, args, nullptr); -} - -void Module::setParallelMode(const bool enable) { - LOG(logDEBUG1) << "Setting parallel mode to " << enable; - sendToDetector(F_SET_PARALLEL_MODE, static_cast(enable), nullptr); -} - -bool Module::getParallelMode() { - auto r = sendToDetector(F_GET_PARALLEL_MODE); - return static_cast(r); -} - -void Module::setOverFlowMode(const bool enable) { - int arg = static_cast(enable); - LOG(logDEBUG1) << "Setting overflow mode to " << arg; - sendToDetector(F_SET_OVERFLOW_MODE, arg, nullptr); -} - -bool Module::getOverFlowMode() { - auto r = sendToDetector(F_GET_OVERFLOW_MODE); - return static_cast(r); -} - -void Module::setStoreInRamMode(const bool enable) { - int arg = static_cast(enable); - LOG(logDEBUG1) << "Setting store in ram mode to " << arg; - sendToDetector(F_SET_STOREINRAM_MODE, arg, nullptr); -} - -bool Module::getStoreInRamMode() { - auto r = sendToDetector(F_GET_STOREINRAM_MODE); - return static_cast(r); -} - void Module::setReadoutMode(const slsDetectorDefs::readoutMode mode) { auto arg = static_cast(mode); LOG(logDEBUG1) << "Setting readout mode to " << arg; @@ -1849,17 +2217,6 @@ slsDetectorDefs::readoutMode Module::getReadoutMode() { return static_cast(r); } -void Module::setInterruptSubframe(const bool enable) { - int arg = static_cast(enable); - LOG(logDEBUG1) << "Setting Interrupt subframe to " << arg; - sendToDetector(F_SET_INTERRUPT_SUBFRAME, arg, nullptr); -} - -bool Module::getInterruptSubframe() { - auto r = sendToDetector(F_GET_INTERRUPT_SUBFRAME); - return static_cast(r); -} - uint32_t Module::writeRegister(uint32_t addr, uint32_t val) { uint32_t args[]{addr, val}; uint32_t retval = -1; @@ -1891,43 +2248,6 @@ uint32_t Module::clearBit(uint32_t addr, int n) { } } -void Module::setClientStreamingPort(int port) { shm()->zmqport = port; } - -int Module::getClientStreamingPort() { return shm()->zmqport; } - -void Module::setReceiverStreamingPort(int port) { - sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr); -} - -int Module::getReceiverStreamingPort() { - return sendToReceiver(F_GET_RECEIVER_STREAMING_PORT); -} - -void Module::setClientStreamingIP(const sls::IpAddr ip) { - LOG(logDEBUG1) << "Setting client zmq ip to " << ip; - if (ip == 0) { - throw RuntimeError("Invalid client zmq ip address"); - } - shm()->zmqip = ip; -} - -sls::IpAddr Module::getClientStreamingIP() { return shm()->zmqip; } - -void Module::setReceiverStreamingIP(const sls::IpAddr ip) { - if (ip == 0) { - throw RuntimeError("Invalid receiver zmq ip address"); - } - // if client zmqip is empty, update it - if (shm()->zmqip == 0) { - shm()->zmqip = ip; - } - sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr); -} - -sls::IpAddr Module::getReceiverStreamingIP() { - return sendToReceiver(F_GET_RECEIVER_STREAMING_SRC_IP); -} - void Module::updateReceiverStreamingIP() { auto ip = getReceiverStreamingIP(); if (ip == 0) { @@ -2040,19 +2360,6 @@ std::string Module::getAdditionalJsonParameter(const std::string &key) { return retval; } -int64_t Module::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize) { - return sendToReceiver(F_RECEIVER_UDP_SOCK_BUF_SIZE, - udpsockbufsize); -} - -int64_t Module::getReceiverUDPSocketBufferSize() { - return setReceiverUDPSocketBufferSize(); -} - -int64_t Module::getReceiverRealUDPSocketBufferSize() const { - return sendToReceiver(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE); -} - void Module::executeFirmwareTest() { LOG(logDEBUG1) << "Executing firmware test"; sendToDetector(F_SET_FIRMWARE_TEST); @@ -2252,33 +2559,6 @@ void Module::setVeto(bool enable) { sendToDetector(F_SET_VETO, static_cast(enable), nullptr); } -int Module::setCounterBit(int cb) { - return sendToDetector(F_SET_COUNTER_BIT, cb); -} - -void Module::clearROI() { - LOG(logDEBUG1) << "Clearing ROI"; - setROI(slsDetectorDefs::ROI{}); -} - -void Module::setROI(slsDetectorDefs::ROI arg) { - if (arg.xmin < 0 || arg.xmax >= getNumberOfChannels().x) { - arg.xmin = -1; - arg.xmax = -1; - } - LOG(logDEBUG) << "Sending ROI to detector [" << arg.xmin << ", " << arg.xmax - << "]"; - sendToDetector(F_SET_ROI, arg, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending ROI to receiver"; - sendToReceiver(F_RECEIVER_SET_ROI, arg, nullptr); - } -} - -slsDetectorDefs::ROI Module::getROI() { - return sendToDetector(F_GET_ROI); -} - void Module::setADCEnableMask(uint32_t mask) { uint32_t arg = mask; LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg @@ -2393,119 +2673,6 @@ void Module::writeAdcRegister(uint32_t addr, uint32_t val) { sendToDetector(F_WRITE_ADC_REG, args, nullptr); } -bool Module::getActivate() { - int retval = -1, retval2 = -1; - int arg = -1; - sendToDetector(F_ACTIVATE, arg, retval); - sendToDetectorStop(F_ACTIVATE, arg, retval2); - if (retval != retval2) { - std::ostringstream oss; - oss << "Inconsistent activate state. Control Server: " << retval - << ". Stop Server: " << retval2; - throw RuntimeError(oss.str()); - } - return retval; -} - -void Module::setActivate(const bool enable) { - int retval = -1; - int arg = static_cast(enable); - LOG(logDEBUG1) << "Setting activate flag to " << enable; - sendToDetector(F_ACTIVATE, arg, retval); - sendToDetectorStop(F_ACTIVATE, arg, retval); - if (shm()->useReceiverFlag) { - sendToReceiver(F_RECEIVER_ACTIVATE, retval, nullptr); - } -} - -bool Module::getDeactivatedRxrPaddingMode() { - return sendToReceiver(F_GET_RECEIVER_DEACTIVATED_PADDING); -} - -void Module::setDeactivatedRxrPaddingMode(bool padding) { - sendToReceiver(F_SET_RECEIVER_DEACTIVATED_PADDING, - static_cast(padding), nullptr); -} - -bool Module::getFlippedDataX() { - return sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, -1); -} - -void Module::setFlippedDataX(bool value) { - sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, static_cast(value)); -} - -int Module::setTrimEn(const std::vector &energies) { - if (shm()->myDetectorType != EIGER) { - throw RuntimeError("setTrimEn not implemented for this detector."); - } - if (energies.size() > MAX_TRIMEN) { - std::ostringstream os; - os << "Size of trim energies: " << energies.size() - << " exceeds what can be stored in shared memory: " << MAX_TRIMEN - << "\n"; - throw RuntimeError(os.str()); - } - shm()->trimEnergies = energies; - return shm()->trimEnergies.size(); -} - -std::vector Module::getTrimEn() { - if (shm()->myDetectorType != EIGER) { - throw RuntimeError("getTrimEn not implemented for this detector."); - } - return std::vector(shm()->trimEnergies.begin(), - shm()->trimEnergies.end()); -} - -void Module::pulsePixel(int n, int x, int y) { - int args[]{n, x, y}; - LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times at (" << x - << "," << y << ")"; - sendToDetector(F_PULSE_PIXEL, args, nullptr); -} - -void Module::pulsePixelNMove(int n, int x, int y) { - int args[]{n, x, y}; - LOG(logDEBUG1) << "Pulsing pixel " << n - << " number of times and move by delta (" << x << "," << y - << ")"; - sendToDetector(F_PULSE_PIXEL_AND_MOVE, args, nullptr); -} - -void Module::pulseChip(int n_pulses) { - LOG(logDEBUG1) << "Pulsing chip " << n_pulses << " number of times"; - sendToDetector(F_PULSE_CHIP, n_pulses, nullptr); -} - -int Module::setThresholdTemperature(int val) { - int retval = -1; - LOG(logDEBUG1) << "Setting threshold temperature to " << val; - sendToDetectorStop(F_THRESHOLD_TEMP, val, retval); - LOG(logDEBUG1) << "Threshold temperature: " << retval; - return retval; -} - -int Module::setTemperatureControl(int val) { - int retval = -1; - LOG(logDEBUG1) << "Setting temperature control to " << val; - sendToDetectorStop(F_TEMP_CONTROL, val, retval); - LOG(logDEBUG1) << "Temperature control: " << retval; - return retval; -} - -int Module::setTemperatureEvent(int val) { - int retval = -1; - LOG(logDEBUG1) << "Setting temperature event to " << val; - sendToDetectorStop(F_TEMP_EVENT, val, retval); - LOG(logDEBUG1) << "Temperature event: " << retval; - return retval; -} - -int Module::setStorageCellStart(int pos) { - return sendToDetector(F_STORAGE_CELL_START, pos); -} - void Module::programFPGA(std::vector buffer) { switch (shm()->myDetectorType) { case JUNGFRAU: @@ -2658,16 +2825,12 @@ void Module::rebootController() { LOG(logINFO) << "Controller rebooted successfully!"; } -int Module::setAutoComparatorDisableMode(int ival) { - return sendToDetector(F_AUTO_COMP_DISABLE, ival); -} - -void Module::setModule(sls_detector_module &module, int tb) { +void Module::setModule(sls_detector_module &module, bool trimbits) { int fnum = F_SET_MODULE; int ret = FAIL; - LOG(logDEBUG1) << "Setting module with tb:" << tb; + LOG(logDEBUG1) << "Setting module with trimbits:" << trimbits; // to exclude trimbits - if (tb == 0) { + if (!trimbits) { module.nchan = 0; module.nchip = 0; } @@ -2693,119 +2856,15 @@ sls_detector_module Module::getModule() { return myMod; } -void Module::setDefaultRateCorrection() { - LOG(logDEBUG1) << "Setting Default Rate Correction"; - int64_t arg = -1; - sendToDetector(F_SET_RATE_CORRECT, arg, nullptr); -} - -void Module::setRateCorrection(int64_t t) { - LOG(logDEBUG1) << "Setting Rate Correction to " << t; - sendToDetector(F_SET_RATE_CORRECT, t, nullptr); -} - -int64_t Module::getRateCorrection() { - return sendToDetector(F_GET_RATE_CORRECT); -} - void Module::updateRateCorrection() { sendToDetector(F_UPDATE_RATE_CORRECTION); } -int Module::lockReceiver(int lock) { - return sendToReceiver(F_LOCK_RECEIVER, lock); -} - -sls::IpAddr Module::getReceiverLastClientIP() const { - return sendToReceiver(F_GET_LAST_RECEIVER_CLIENT_IP); -} - -std::array Module::getReceiverThreadIds() const { - return sendToReceiver>( - F_GET_RECEIVER_THREAD_IDS); -} - void Module::exitReceiver() { LOG(logDEBUG1) << "Sending exit command to receiver server"; sendToReceiver(F_EXIT_RECEIVER, nullptr, nullptr); } -std::string Module::getFilePath() { - char ret[MAX_STR_LENGTH]{}; - sendToReceiver(F_GET_RECEIVER_FILE_PATH, nullptr, ret); - return ret; -} - -void Module::setFilePath(const std::string &path) { - if (path.empty()) { - throw RuntimeError("Cannot set empty file path"); - } - char args[MAX_STR_LENGTH]{}; - sls::strcpy_safe(args, path.c_str()); - sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr); -} - -std::string Module::getFileName() { - char retvals[MAX_STR_LENGTH]{}; - sendToReceiver(F_GET_RECEIVER_FILE_NAME, nullptr, retvals); - return std::string(retvals); -} - -void Module::setFileName(const std::string &fname) { - if (fname.empty()) { - throw RuntimeError("Cannot set empty file name prefix"); - } - char args[MAX_STR_LENGTH]{}; - sls::strcpy_safe(args, fname.c_str()); - sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr); -} - -int64_t Module::getFileIndex() { - return sendToReceiver(F_GET_RECEIVER_FILE_INDEX); -} - -void Module::setFileIndex(int64_t file_index) { - sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr); -} - -void Module::incrementFileIndex() { - sendToReceiver(F_INCREMENT_FILE_INDEX, nullptr, nullptr); -} - -slsDetectorDefs::fileFormat Module::getFileFormat() { - return static_cast( - sendToReceiver(F_GET_RECEIVER_FILE_FORMAT)); -} - -void Module::setFileFormat(fileFormat f) { - sendToReceiver(F_SET_RECEIVER_FILE_FORMAT, static_cast(f), nullptr); -} - -int Module::getFramesPerFile() { - return sendToReceiver(F_GET_RECEIVER_FRAMES_PER_FILE); -} - -void Module::setFramesPerFile(int n_frames) { - sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, nullptr); -} - -slsDetectorDefs::frameDiscardPolicy Module::getReceiverFramesDiscardPolicy() { - return static_cast( - sendToReceiver(F_GET_RECEIVER_DISCARD_POLICY)); -} - -void Module::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) { - sendToReceiver(F_SET_RECEIVER_DISCARD_POLICY, static_cast(f), nullptr); -} - -bool Module::getPartialFramesPadding() { - return sendToReceiver(F_GET_RECEIVER_PADDING); -} - -void Module::setPartialFramesPadding(bool padding) { - sendToReceiver(F_SET_RECEIVER_PADDING, static_cast(padding), nullptr); -} - uint64_t Module::getReceiverCurrentFrameIndex() const { return sendToReceiver(F_GET_RECEIVER_FRAME_INDEX); } @@ -2814,55 +2873,6 @@ int Module::getReceiverProgress() const { return sendToReceiver(F_GET_RECEIVER_PROGRESS); } -void Module::setFileWrite(bool value) { - sendToReceiver(F_SET_RECEIVER_FILE_WRITE, static_cast(value), nullptr); -} - -bool Module::getFileWrite() { - return sendToReceiver(F_GET_RECEIVER_FILE_WRITE); -} - -void Module::setMasterFileWrite(bool value) { - sendToReceiver(F_SET_RECEIVER_MASTER_FILE_WRITE, static_cast(value), - nullptr); -} - -bool Module::getMasterFileWrite() { - return sendToReceiver(F_GET_RECEIVER_MASTER_FILE_WRITE); -} - -void Module::setFileOverWrite(bool value) { - sendToReceiver(F_SET_RECEIVER_OVERWRITE, static_cast(value), nullptr); -} - -bool Module::getFileOverWrite() { - return sendToReceiver(F_GET_RECEIVER_OVERWRITE); -} - -int Module::getReceiverStreamingFrequency() { - return sendToReceiver(F_GET_RECEIVER_STREAMING_FREQUENCY); -} - -void Module::setReceiverStreamingFrequency(int freq) { - if (freq < 0) { - throw RuntimeError("Invalid streaming frequency " + - std::to_string(freq)); - } - sendToReceiver(F_SET_RECEIVER_STREAMING_FREQUENCY, freq, nullptr); -} - -int Module::setReceiverStreamingTimer(int time_in_ms) { - return sendToReceiver(F_RECEIVER_STREAMING_TIMER, time_in_ms); -} - -bool Module::getReceiverStreaming() { - return sendToReceiver(F_GET_RECEIVER_STREAMING); -} - -void Module::setReceiverStreaming(bool enable) { - sendToReceiver(F_SET_RECEIVER_STREAMING, static_cast(enable), nullptr); -} - void Module::restreamStopFromReceiver() { LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq"; if (shm()->useReceiverFlag) { @@ -2998,7 +3008,7 @@ uint32_t Module::getCounterMask() { sls_detector_module Module::interpolateTrim(sls_detector_module *a, sls_detector_module *b, const int energy, const int e1, - const int e2, int tb) { + const int e2, bool trimbits) { // only implemented for eiger currently (in terms of which dacs) if (shm()->myDetectorType != EIGER) { @@ -3056,7 +3066,7 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a, b->dacs[dacs_to_interpolate[i]]); } // Interpolate all trimbits - if (tb != 0) { + if (trimbits) { for (int i = 0; i < myMod.nchan; ++i) { myMod.chanregs[i] = linearInterpolation( energy, e1, e2, a->chanregs[i], b->chanregs[i]); @@ -3065,7 +3075,8 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a, return myMod; } -sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) { +sls_detector_module Module::readSettingsFile(const std::string &fname, + bool trimbits) { LOG(logDEBUG1) << "Read settings file " << fname; sls_detector_module myMod(shm()->myDetectorType); // open file @@ -3086,7 +3097,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) { infile.read(reinterpret_cast(&myMod.iodelay), sizeof(myMod.iodelay)); infile.read(reinterpret_cast(&myMod.tau), sizeof(myMod.tau)); - if (tb != 0) { + if (trimbits) { infile.read(reinterpret_cast(myMod.chanregs), sizeof(int) * (myMod.nchan)); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index c95527704..5c0e7b224 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -145,6 +145,8 @@ class Module : public virtual slsDetectorDefs { int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex); void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value); + externalSignalFlag getExternalSignalFlags(int signalIndex); + void setExternalSignalFlags(int signalIndex, externalSignalFlag type); /************************************************** * * @@ -220,30 +222,145 @@ class Module : public virtual slsDetectorDefs { void setReceiverFifoDepth(int n_frames); bool getReceiverSilentMode(); void setReceiverSilentMode(bool enable); + frameDiscardPolicy getReceiverFramesDiscardPolicy(); + void setReceiverFramesDiscardPolicy(frameDiscardPolicy f); + bool getPartialFramesPadding(); + void setPartialFramesPadding(bool padding); + int64_t getReceiverUDPSocketBufferSize() const; + int64_t getReceiverRealUDPSocketBufferSize() const; + void setReceiverUDPSocketBufferSize(int64_t udpsockbufsize); + bool getReceiverLock(); + void setReceiverLock(bool lock); + sls::IpAddr getReceiverLastClientIP() const; + std::array getReceiverThreadIds() const; - /** - * Get Quad Type (Only for Eiger Quad detector hardware) - * @returns quad type - */ + /************************************************** + * * + * File * + * * + * ************************************************/ + fileFormat getFileFormat(); + void setFileFormat(fileFormat f); + std::string getFilePath(); + void setFilePath(const std::string &path); + std::string getFileName(); + void setFileName(const std::string &fname); + int64_t getFileIndex(); + void setFileIndex(int64_t file_index); + void incrementFileIndex(); + bool getFileWrite(); + void setFileWrite(bool value); + bool getMasterFileWrite(); + void setMasterFileWrite(bool value); + bool getFileOverWrite(); + void setFileOverWrite(bool value); + int getFramesPerFile(); + /** 0 will set frames per file to unlimited */ + void setFramesPerFile(int n_frames); + + /************************************************** + * * + * ZMQ Streaming Parameters (Receiver<->Client)* + * * + * ************************************************/ + bool getReceiverStreaming(); + void setReceiverStreaming(bool enable); + int getReceiverStreamingFrequency(); + /** Option: nth frame streamed out, if 0, streamed out at a timer of 200 */ + void setReceiverStreamingFrequency(int freq); + int getReceiverStreamingTimer(); + void setReceiverStreamingTimer(int time_in_ms = 200); + int getReceiverStreamingPort(); + void setReceiverStreamingPort(int port); + sls::IpAddr getReceiverStreamingIP(); + void setReceiverStreamingIP(const sls::IpAddr ip); + int getClientStreamingPort(); + void setClientStreamingPort(int port); + sls::IpAddr getClientStreamingIP(); + void setClientStreamingIP(const sls::IpAddr ip); + + /************************************************** + * * + * Eiger Specific * + * * + * ************************************************/ + int getDynamicRange(); + void setDynamicRange(int n); + int64_t getSubExptime(); + void setSubExptime(int64_t value); + int64_t getSubDeadTime(); + void setSubDeadTime(int64_t value); + int getThresholdEnergy(); + void setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS, + bool trimbits = true); + std::string getSettingsDir(); + std::string setSettingsDir(const std::string &dir); + bool getParallelMode(); + void setParallelMode(const bool enable); + bool getOverFlowMode(); + void setOverFlowMode(const bool enable); + bool getStoreInRamMode(); + void setStoreInRamMode(const bool enable); + bool getFlippedDataX(); + void setFlippedDataX(bool value); + std::vector getTrimEn(); + int setTrimEn(const std::vector &energies = {}); + int64_t getRateCorrection(); + void setDefaultRateCorrection(); + void setRateCorrection(int64_t t = 0); + int getReadNLines(); + void setReadNLines(const int value); + bool getInterruptSubframe(); + void setInterruptSubframe(const bool enable); + int64_t getMeasuredPeriod() const; + int64_t getMeasuredSubFramePeriod() const; + bool getActivate(); + void setActivate(const bool enable); + bool getDeactivatedRxrPaddingMode(); + void setDeactivatedRxrPaddingMode(bool padding); + bool getCounterBit(); + void setCounterBit(bool cb); + void pulsePixel(int n = 0, int x = 0, int y = 0); + void pulsePixelNMove(int n = 0, int x = 0, int y = 0); + void pulseChip(int n_pulses = 0); bool getQuad(); - - /** - * Set Quad Type (Only for Eiger Quad detector hardware) - * @param enable true if quad type set, else false - */ void setQuad(const bool enable); - /** - * Set number of rows to read out (Only for Eiger) - * @param value number of lines - */ - void setReadNLines(const int value); + /************************************************** + * * + * Jungfrau Specific * + * * + * ************************************************/ + int getThresholdTemperature(); + void setThresholdTemperature(int val); + bool getTemperatureControl(); + void setTemperatureControl(bool val); + int getTemperatureEvent(); + void resetTemperatureEvent(); + bool getAutoComparatorDisableMode(); + void setAutoComparatorDisableMode(bool val); + int getNumberOfAdditionalStorageCells(); + void setNumberOfAdditionalStorageCells(int value); + int getStorageCellStart(); + void setStorageCellStart(int pos); + int64_t getStorageCellDelay(); + void setStorageCellDelay(int64_t value); - /** - * Get number of rows to read out (Only for Eiger) - * @returns number of lines - */ - int getReadNLines(); + /************************************************** + * * + * Gotthard Specific * + * * + * ************************************************/ + slsDetectorDefs::ROI getROI(); + void setROI(slsDetectorDefs::ROI arg); + void clearROI(); + int64_t getExptimeLeft() const; + + /************************************************** + * * + * Gotthard2 Specific * + * * + * ************************************************/ /** * Set Detector offset in shared memory in dimension d @@ -297,22 +414,6 @@ class Module : public virtual slsDetectorDefs { */ std::vector getConfigFileCommands(); - /** - * Get threshold energy (Mythen and Eiger) - * @returns current threshold value in ev (-1 failed) - */ - int getThresholdEnergy(); - - /** - * Set threshold energy (Mythen and Eiger) - * For Eiger, calls setThresholdEneryAndSettings - * @param e_eV threshold in eV - * @param isettings ev. change settings - * @param tb 1 to include trimbits, 0 to exclude - */ - void setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS, - int tb = 1); - /** * Set threshold energy and settings (Eiger only) * @param e_eV threshold in eV @@ -320,20 +421,7 @@ class Module : public virtual slsDetectorDefs { * @param tb 1 to include trimbits, 0 to exclude */ void setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, - int tb = 1); - - /** - * Returns the detector trimbit/settings directory \sa sharedSlsDetector - * @returns the trimbit/settings directory - */ - std::string getSettingsDir(); - - /** - * Sets the detector trimbit/settings directory \sa sharedSlsDetector - * @param s trimbits/settings directory - * @returns the trimbit/settings directory - */ - std::string setSettingsDir(const std::string &dir); + bool trimbits = true); /** * Start detector acquisition and read all data (Blocking until end of @@ -363,12 +451,6 @@ class Module : public virtual slsDetectorDefs { /** [Gotthard2] only in burst mode and in auto timing mode */ void setNumberOfBursts(int64_t value); - /** [Jungfrau] Advanced */ - int getNumberOfAdditionalStorageCells(); - - /** [Jungfrau] Advanced */ - void setNumberOfAdditionalStorageCells(int value); - /** [CTB][Moench] */ int getNumberOfAnalogSamples(); @@ -405,34 +487,6 @@ class Module : public virtual slsDetectorDefs { /** [Gotthard2] only in burst mode and in auto timing mode */ void setBurstPeriod(int64_t value); - /** [Eiger] in 32 bit mode */ - int64_t getSubExptime(); - - /** [Eiger] in 32 bit mode */ - void setSubExptime(int64_t value); - - /** [Eiger] in 32 bit mode */ - int64_t getSubDeadTime(); - - /** [Eiger] in 32 bit mode */ - void setSubDeadTime(int64_t value); - - /** [Jungfrau] Advanced*/ - int64_t getStorageCellDelay(); - - /** [Jungfrau] Advanced - * Options: (0-1638375 ns (resolution of 25ns) */ - void setStorageCellDelay(int64_t value); - - /** [Gotthard] */ - int64_t getExptimeLeft() const; - - /** [Eiger] minimum two frames */ - int64_t getMeasuredPeriod() const; - - /** [Eiger] */ - int64_t getMeasuredSubFramePeriod() const; - /** [Jungfrau][CTB][Moench][Mythen3] * [Gotthard2] only in continuous mode */ int64_t getNumberOfFramesFromStart() const; @@ -445,53 +499,6 @@ class Module : public virtual slsDetectorDefs { * [Gotthard2] only in continuous mode */ int64_t getMeasurementTime() const; - int getDynamicRange(); - /** - * Set/get dynamic range - * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to - * 1) - */ - void setDynamicRange(int n); - - externalSignalFlag getExternalSignalFlags(int signalIndex); - void setExternalSignalFlags(int signalIndex, externalSignalFlag type); - - /** - * Set Parallel readout mode (Only for Eiger) - * @param enable true if parallel, else false for non parallel - */ - void setParallelMode(const bool enable); - - /** - * Get parallel mode (Only for Eiger) - * @returns parallel mode - */ - bool getParallelMode(); - - /** - * Set overflow readout mode in 32 bit mode (Only for Eiger) - * @param enable true if overflow, else false - */ - void setOverFlowMode(const bool enable); - - /** - * Get overflow mode in 32 bit mode (Only for Eiger) - * @returns overflow mode - */ - bool getOverFlowMode(); - - /** - * Set store in ram readout mode (Only for Eiger) - * @param enable true if store in ram, else false - */ - void setStoreInRamMode(const bool enable); - - /** - * Get store in ram mode (Only for Eiger) - * @returns store in ram mode - */ - bool getStoreInRamMode(); - /** * [Ctb] * @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY, @@ -505,18 +512,6 @@ class Module : public virtual slsDetectorDefs { */ readoutMode getReadoutMode(); - /** - * Set Interrupt last sub frame (Only for Eiger) - * @param enable true if interrupt last subframe set, else false - */ - void setInterruptSubframe(const bool enable); - - /** - * Get Interrupt last sub frame (Only for Eiger) - * @returns true if interrupt last subframe set, else false - */ - bool getInterruptSubframe(); - /** * Write in a register. For Advanced users * @param addr address of register @@ -550,53 +545,7 @@ class Module : public virtual slsDetectorDefs { void test(); - /** - * Sets the client zmq port\sa sharedSlsDetector - * @param port client zmq port - */ - void setClientStreamingPort(int port); - - /** - * Returns the client zmq port \sa sharedSlsDetector - * @returns the client zmq port - */ - int getClientStreamingPort(); - - /** - * Sets the receiver zmq port\sa sharedSlsDetector - * @param port receiver zmq port - */ - void setReceiverStreamingPort(int port); - - /** - * Returns the receiver zmq port \sa sharedSlsDetector - * @returns the receiver zmq port - */ - int getReceiverStreamingPort(); - - /** - * Sets the client zmq ip\sa sharedSlsDetector - * @param ip client zmq ip - */ - void setClientStreamingIP(const sls::IpAddr ip); - - /** - * Returns the client zmq ip \sa sharedSlsDetector - * @returns the client zmq ip - */ - sls::IpAddr getClientStreamingIP(); - - /** - * Sets the receiver zmq ip\sa sharedSlsDetector - * @param ip receiver zmq ip - */ - void setReceiverStreamingIP(const sls::IpAddr ip); - - /** - * Returns the receiver zmq ip \sa sharedSlsDetector - * @returns the receiver zmq ip - */ - sls::IpAddr getReceiverStreamingIP(); + int getReceiverProgress() const; /** update receiver stremaing ip from shm to receiver * if empty, use rx_hostname ip @@ -615,25 +564,6 @@ class Module : public virtual slsDetectorDefs { const std::string &value); std::string getAdditionalJsonParameter(const std::string &key); - /** - * Sets the receiver UDP socket buffer size - * @param udpsockbufsize additional json header - * @returns receiver udp socket buffer size - */ - int64_t setReceiverUDPSocketBufferSize(int64_t udpsockbufsize = -1); - - /** - * Returns the receiver UDP socket buffer size\sa sharedSlsDetector - * @returns the receiver UDP socket buffer size - */ - int64_t getReceiverUDPSocketBufferSize(); - - /** - * Returns the receiver real UDP socket buffer size\sa sharedSlsDetector - * @returns the receiver real UDP socket buffer size - */ - int64_t getReceiverRealUDPSocketBufferSize() const; - /** [Gotthard][Jungfrau][CTB][Moench] */ void executeFirmwareTest(); @@ -681,33 +611,6 @@ class Module : public virtual slsDetectorDefs { /** default disabled */ void setVeto(bool enable); - /** - * Set/get counter bit in detector (Gotthard) - * @param i is -1 to get, 0 to reset and any other value to set the counter - * bit - * @returns the counter bit in detector - */ - int setCounterBit(int cb = -1); - - /** - * Clear ROI (Gotthard) - */ - void clearROI(); - - /** - * Set ROI (Gotthard) - * Also calls configuremac - * @param arg roi - */ - void setROI(slsDetectorDefs::ROI arg); - - /** - * Get ROI (Gotthard) - * Update receiver if different from shm - * @returns roi - */ - slsDetectorDefs::ROI getROI(); - /** * Set ADC Enable Mask (CTB, Moench) * @param mask ADC Enable mask @@ -781,94 +684,11 @@ class Module : public virtual slsDetectorDefs { */ void writeAdcRegister(uint32_t addr, uint32_t val); - bool getActivate(); - void setActivate(const bool enable); - - bool getDeactivatedRxrPaddingMode(); - - /** - * Set deactivated Receiver padding mode (Eiger only) - */ - void setDeactivatedRxrPaddingMode(bool padding); - - /** - * Returns the enable if data will be flipped across x axis (Eiger) - * @returns if flipped across x axis - */ - bool getFlippedDataX(); - - /** - * Sets the enable which determines if - * data will be flipped across x axis (Eiger) - * @param value 0 or 1 to reset/set - */ - void setFlippedDataX(bool value); - - /** - * Sets the number of trim energies and their value (Eiger) - * \sa sharedSlsDetector - * @param nen number of energies - * @param vector os trimmed energies - * @returns number of trim energies - */ - int setTrimEn(const std::vector &energies = {}); - - /** - * Returns a vector with the trimmed energies (Eiger) - * \sa sharedSlsDetector - * @returns vector with the trimmed energies - */ - std::vector getTrimEn(); - - /** - * Pulse Pixel (Eiger) - * @param n is number of times to pulse - * @param x is x coordinate - * @param y is y coordinate - */ - 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 - */ - void pulsePixelNMove(int n = 0, int x = 0, int y = 0); - - /** - * Pulse Chip (Eiger) - * @param n is number of times to pulse - */ - void pulseChip(int n_pulses = 0); - - /** - * Set/gets threshold temperature (Jungfrau) - * @param val value in millidegrees, -1 gets - * @returns threshold temperature in millidegrees - */ - int setThresholdTemperature(int val = -1); - - /** - * Enables/disables temperature control (Jungfrau) - * @param val value, -1 gets - * @returns temperature control enable - */ - int setTemperatureControl(int val = -1); - - /** - * Resets/ gets over-temperature event (Jungfrau) - * @param val value, -1 gets - * @returns over-temperature event - */ - int setTemperatureEvent(int val = -1); - /** * Set storage cell that stores first acquisition of the series (Jungfrau) * @param value storage cell index. Value can be 0 to 15. (-1 gets) * @returns the storage cell that stores the first acquisition of the series */ - int setStorageCellStart(int pos = -1); /** * [Jungfau][Ctb] Programs FPGA with raw file from pof file @@ -901,13 +721,6 @@ class Module : public virtual slsDetectorDefs { */ void rebootController(); - /** - * Automatic comparator disable (Jungfrau) - * @param ival on is 1, off is 0, -1 to get - * @returns OK or FAIL - */ - int setAutoComparatorDisableMode(int ival = -1); - /** * Get trimbit filename with path for settings and energy * @@ -922,7 +735,7 @@ class Module : public virtual slsDetectorDefs { * @param tb 1 to include trimbits, 0 to exclude (used for eiger) * \sa ::sls_detector_module */ - void setModule(sls_detector_module &module, int tb = 1); + void setModule(sls_detector_module &module, bool trimbits = true); /** * Get module structure from detector (all detectors) @@ -931,25 +744,6 @@ class Module : public virtual slsDetectorDefs { */ sls_detector_module getModule(); - /** - * Set Default Rate correction from trimbit file(Eiger) - */ - void setDefaultRateCorrection(); - - /** - * Set Rate correction (Eiger) - * @param t dead time in ns - if 0 disable correction, - * if >0 set dead time to t, cannot be < 0 - * for current settings - */ - void setRateCorrection(int64_t t = 0); - - /** - * Get rate correction (Eiger) - * @returns 0 if rate correction disabled, > 0 otherwise - */ - int64_t getRateCorrection(); - /** * Update rate correction according to dynamic range (Eiger) * If rate correction enabled and dr is 8 or 16, it will throw @@ -957,81 +751,16 @@ class Module : public virtual slsDetectorDefs { */ void updateRateCorrection(); - /** - * Locks/Unlocks the connection to the receiver - * @param lock sets (1), usets (0), gets (-1) the lock - * @returns lock status of the receiver - */ - int lockReceiver(int lock = -1); - - /** - * Returns the IP of the last client connecting to the receiver - * @returns the IP of the last client connecting to the receiver - */ - sls::IpAddr getReceiverLastClientIP() const; - - std::array getReceiverThreadIds() const; - /** * Exits the receiver TCP server */ void exitReceiver(); - std::string getFilePath(); - void setFilePath(const std::string &path); - std::string getFileName(); - void setFileName(const std::string &fname); - int64_t getFileIndex(); - void setFileIndex(int64_t file_index); - void incrementFileIndex(); - fileFormat getFileFormat(); - void setFileFormat(fileFormat f); - int getFramesPerFile(); - /** 0 will set frames per file to unlimited */ - void setFramesPerFile(int n_frames); - frameDiscardPolicy getReceiverFramesDiscardPolicy(); - void setReceiverFramesDiscardPolicy(frameDiscardPolicy f); - bool getPartialFramesPadding(); - void setPartialFramesPadding(bool padding); - /** * Gets the current frame index of receiver * @returns current frame index of receiver */ uint64_t getReceiverCurrentFrameIndex() const; - int getReceiverProgress() const; - - void setFileWrite(bool value); - bool getFileWrite(); - void setMasterFileWrite(bool value); - bool getMasterFileWrite(); - void setFileOverWrite(bool value); - bool getFileOverWrite(); - - int getReceiverStreamingFrequency(); - - /** - * (previously setReadReceiverFrequency) - * Sets the receiver streaming frequency - * @param freq nth frame streamed out, if 0, streamed out at a timer of 200 - * ms - * @param detPos -1 for all detectors in list or specific detector position - */ - void setReceiverStreamingFrequency(int freq); - - /** - * (previously setReceiverReadTimer) - * Sets the receiver streaming timer - * If receiver streaming frequency is 0, then this timer between each - * data stream is set. Default is 200 ms. - * @param time_in_ms timer between frames - * @returns receiver streaming timer in ms - */ - int setReceiverStreamingTimer(int time_in_ms = 200); - - bool getReceiverStreaming(); - - void setReceiverStreaming(bool enable); /** * If data streaming in receiver is enabled, @@ -1331,7 +1060,7 @@ class Module : public virtual slsDetectorDefs { sls_detector_module interpolateTrim(sls_detector_module *a, sls_detector_module *b, const int energy, const int e1, - const int e2, int tb = 1); + const int e2, bool trimbits = true); /** * reads a trim/settings file @@ -1342,7 +1071,8 @@ class Module : public virtual slsDetectorDefs { * @returns the pointer to myMod or NULL if reading the file failed */ - sls_detector_module readSettingsFile(const std::string &fname, int tb = 1); + sls_detector_module readSettingsFile(const std::string &fname, + bool trimbits = true); /** Module Id or position in the detectors list */ const int moduleId;