diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 1d53c48be..54920668b 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1569,11 +1569,11 @@ void Detector::setDigitalIODelay(uint64_t pinMask, int delay, Positions pos) { } Result Detector::getLEDEnable(Positions pos) const { - return pimpl->Parallel(&Module::setLEDEnable, pos, -1); + return pimpl->Parallel(&Module::getLEDEnable, pos); } void Detector::setLEDEnable(bool enable, Positions pos) { - pimpl->Parallel(&Module::setLEDEnable, pos, static_cast(enable)); + pimpl->Parallel(&Module::setLEDEnable, pos, enable); } // Pattern @@ -1585,7 +1585,7 @@ void Detector::savePattern(const std::string &fname) { throw RuntimeError("Could not create file to save pattern"); } // get pattern limits - auto r = pimpl->Parallel(&Module::setPatternLoopAddresses, {}, -1, -1, -1) + auto r = pimpl->Parallel(&Module::getPatternLoopAddresses, {}, -1) .tsquash("Inconsistent pattern limits"); CmdProxy proxy(this); @@ -1617,7 +1617,7 @@ void Detector::setPattern(const std::string &fname, Positions pos) { } Result Detector::getPatternIOControl(Positions pos) const { - return pimpl->Parallel(&Module::setPatternIOControl, pos, -1); + return pimpl->Parallel(&Module::getPatternIOControl, pos); } void Detector::setPatternIOControl(uint64_t word, Positions pos) { @@ -1625,7 +1625,7 @@ void Detector::setPatternIOControl(uint64_t word, Positions pos) { } Result Detector::getPatternClockControl(Positions pos) const { - return pimpl->Parallel(&Module::setPatternClockControl, pos, -1); + return pimpl->Parallel(&Module::getPatternClockControl, pos); } void Detector::setPatternClockControl(uint64_t word, Positions pos) { @@ -1633,7 +1633,7 @@ void Detector::setPatternClockControl(uint64_t word, Positions pos) { } Result Detector::getPatternWord(int addr, Positions pos) { - return pimpl->Parallel(&Module::setPatternWord, pos, addr, -1); + return pimpl->Parallel(&Module::getPatternWord, pos, addr); } void Detector::setPatternWord(int addr, uint64_t word, Positions pos) { @@ -1642,8 +1642,7 @@ void Detector::setPatternWord(int addr, uint64_t word, Positions pos) { Result> Detector::getPatternLoopAddresses(int level, Positions pos) const { - return pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, -1, - -1); + return pimpl->Parallel(&Module::getPatternLoopAddresses, pos, level); } void Detector::setPatternLoopAddresses(int level, int start, int stop, @@ -1652,7 +1651,7 @@ void Detector::setPatternLoopAddresses(int level, int start, int stop, } Result Detector::getPatternLoopCycles(int level, Positions pos) const { - return pimpl->Parallel(&Module::setPatternLoopCycles, pos, level, -1); + return pimpl->Parallel(&Module::getPatternLoopCycles, pos, level); } void Detector::setPatternLoopCycles(int level, int n, Positions pos) { @@ -1660,7 +1659,7 @@ void Detector::setPatternLoopCycles(int level, int n, Positions pos) { } Result Detector::getPatternWaitAddr(int level, Positions pos) const { - return pimpl->Parallel(&Module::setPatternWaitAddr, pos, level, -1); + return pimpl->Parallel(&Module::getPatternWaitAddr, pos, level); } void Detector::setPatternWaitAddr(int level, int addr, Positions pos) { @@ -1668,7 +1667,7 @@ void Detector::setPatternWaitAddr(int level, int addr, Positions pos) { } Result Detector::getPatternWaitTime(int level, Positions pos) const { - return pimpl->Parallel(&Module::setPatternWaitTime, pos, level, -1); + return pimpl->Parallel(&Module::getPatternWaitTime, pos, level); } void Detector::setPatternWaitTime(int level, uint64_t t, Positions pos) { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 2ac00bddc..34732a4c8 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -205,6 +205,25 @@ void Module::setNumberOfTriggers(int64_t value) { } } +int64_t Module::getExptime(int gateIndex) { + return sendToDetector(F_GET_EXPTIME, gateIndex); +} + +void Module::setExptime(int gateIndex, int64_t value) { + int64_t prevVal = value; + if (shm()->myDetectorType == EIGER) { + prevVal = getExptime(-1); + } + int64_t args[]{static_cast(gateIndex), value}; + sendToDetector(F_SET_EXPTIME, args, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_EXPTIME, args, nullptr); + } + if (prevVal != value) { + updateRateCorrection(); + } +} + int64_t Module::getPeriod() { return sendToDetector(F_GET_PERIOD); } void Module::setPeriod(int64_t value) { @@ -1329,14 +1348,522 @@ void Module::setROI(slsDetectorDefs::ROI arg) { 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; + return sendToDetectorStop(F_GET_EXPTIME_LEFT); } // Gotthard2 Specific +int64_t Module::getNumberOfBursts() { + return sendToDetector(F_GET_NUM_BURSTS); +} + +void Module::setNumberOfBursts(int64_t value) { + sendToDetector(F_SET_NUM_BURSTS, value, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SET_RECEIVER_NUM_BURSTS, value, nullptr); + } +} + +int64_t Module::getBurstPeriod() { + return sendToDetector(F_GET_BURST_PERIOD); +} + +void Module::setBurstPeriod(int64_t value) { + sendToDetector(F_SET_BURST_PERIOD, value, nullptr); +} + +std::array Module::getInjectChannel() { + std::array retvals{}; + sendToDetector(F_GET_INJECT_CHANNEL, nullptr, retvals); + return retvals; +} + +void Module::setInjectChannel(const int offsetChannel, + const int incrementChannel) { + int args[]{offsetChannel, incrementChannel}; + sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr); +} + +std::vector Module::getVetoPhoton(const int chipIndex) { + int fnum = F_GET_VETO_PHOTON; + int ret = FAIL; + auto client = DetectorSocket(shm()->hostname, shm()->controlPort); + client.Send(&fnum, sizeof(fnum)); + client.Send(&chipIndex, sizeof(chipIndex)); + client.Receive(&ret, sizeof(ret)); + if (ret == FAIL) { + char mess[MAX_STR_LENGTH]{}; + client.Receive(mess, MAX_STR_LENGTH); + throw RuntimeError("Detector " + std::to_string(moduleId) + + " returned error: " + std::string(mess)); + } else { + int nch = -1; + client.Receive(&nch, sizeof(nch)); + + int adus[nch]; + memset(adus, 0, sizeof(adus)); + client.Receive(adus, sizeof(adus)); + std::vector retvals(adus, adus + nch); + LOG(logDEBUG1) << "Getting veto photon [" << chipIndex << "]: " << nch + << " channels\n"; + return retvals; + } +} + +void Module::setVetoPhoton(const int chipIndex, const int numPhotons, + const int energy, const std::string &fname) { + if (shm()->myDetectorType != GOTTHARD2) { + throw RuntimeError( + "Set Veto reference is not implemented for this detector"); + } + if (chipIndex < -1 || chipIndex >= shm()->nChip.x) { + throw RuntimeError("Could not set veto photon. Invalid chip index: " + + std::to_string(chipIndex)); + } + if (numPhotons < 1) { + throw RuntimeError( + "Could not set veto photon. Invalid number of photons: " + + std::to_string(numPhotons)); + } + if (energy < 1) { + throw RuntimeError("Could not set veto photon. Invalid energy: " + + std::to_string(energy)); + } + std::ifstream infile(fname.c_str()); + if (!infile.is_open()) { + throw RuntimeError("Could not set veto photon. Could not open file: " + + fname); + } + + int totalEnergy = numPhotons * energy; + int ch = shm()->nChan.x; + int gainIndex = 2; + int nRead = 0; + int value[ch]; + memset(value, 0, sizeof(value)); + bool firstLine = true; + + while (infile.good()) { + std::string line; + getline(infile, line); + if (line.find('#') != std::string::npos) { + line.erase(line.find('#')); + } + if (line.length() < 1) { + continue; + } + std::istringstream ss(line); + // first line: caluclate gain index from gain thresholds from file + if (firstLine) { + int g0 = -1, g1 = -1; + if (!(ss >> g0 >> g1)) { + throw RuntimeError( + "Could not set veto photon. Invalid gain thresholds"); + } + // set gain index and gain bit values + if (totalEnergy < g0) { + gainIndex = 0; + } else if (totalEnergy < g1) { + gainIndex = 1; + } + LOG(logINFO) << "Setting veto photon. Reading Gain " << gainIndex + << " values"; + firstLine = false; + } + // read pedestal and gain values + else { + double p[3] = {-1, -1, -1}, g[3] = {-1, -1, -1}; + if (!(ss >> p[0] >> p[1] >> p[2] >> g[0] >> g[1] >> g[2])) { + throw RuntimeError("Could not set veto photon. Invalid " + "pedestal or gain values for channel " + + std::to_string(nRead)); + } + value[nRead] = + p[gainIndex] + + (g[gainIndex] * + totalEnergy); // ADU value = pedestal + gain * total energy + ++nRead; + if (nRead >= ch) { + break; + } + } + } + if (nRead != ch) { + throw RuntimeError("Could not set veto photon. Insufficient pedestal " + "pr gain values: " + + std::to_string(nRead)); + } + + int fnum = F_SET_VETO_PHOTON; + int ret = FAIL; + int args[]{chipIndex, gainIndex, ch}; + LOG(logDEBUG) << "Sending veto photon value to detector [chip:" << chipIndex + << ", G" << gainIndex << "]: " << args; + auto client = DetectorSocket(shm()->hostname, shm()->controlPort); + client.Send(&fnum, sizeof(fnum)); + client.Send(args, sizeof(args)); + client.Send(value, sizeof(value)); + client.Receive(&ret, sizeof(ret)); + if (ret == FAIL) { + char mess[MAX_STR_LENGTH]{}; + client.Receive(mess, MAX_STR_LENGTH); + throw RuntimeError("Detector " + std::to_string(moduleId) + + " returned error: " + std::string(mess)); + } +} + +void Module::setVetoReference(const int gainIndex, const int value) { + int args[]{gainIndex, value}; + sendToDetector(F_SET_VETO_REFERENCE, args, nullptr); +} + +slsDetectorDefs::burstMode Module::getBurstMode() { + auto r = sendToDetector(F_GET_BURST_MODE); + return static_cast(r); +} + +void Module::setBurstMode(slsDetectorDefs::burstMode value) { + int arg = static_cast(value); + sendToDetector(F_SET_BURST_MODE, arg, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SET_RECEIVER_BURST_MODE, value, nullptr); + } +} + +bool Module::getCurrentSource() { + return sendToDetector(F_GET_CURRENT_SOURCE); +} + +void Module::setCurrentSource(bool value) { + sendToDetector(F_SET_CURRENT_SOURCE, static_cast(value), nullptr); +} + +slsDetectorDefs::timingSourceType Module::getTimingSource() { + auto r = sendToDetector(F_GET_TIMING_SOURCE); + return static_cast(r); +} + +void Module::setTimingSource(slsDetectorDefs::timingSourceType value) { + sendToDetector(F_SET_TIMING_SOURCE, static_cast(value), nullptr); +} + +bool Module::getVeto() { return sendToDetector(F_GET_VETO); } + +void Module::setVeto(bool enable) { + sendToDetector(F_SET_VETO, static_cast(enable), nullptr); +} + +// Mythen3 Specific + +uint32_t Module::getCounterMask() { + return sendToDetector(F_GET_COUNTER_MASK); +} + +void Module::setCounterMask(uint32_t countermask) { + LOG(logDEBUG1) << "Setting Counter mask to " << countermask; + sendToDetector(F_SET_COUNTER_MASK, countermask, nullptr); + if (shm()->useReceiverFlag) { + int ncounters = __builtin_popcount(countermask); + LOG(logDEBUG1) << "Sending Reciver #counters: " << ncounters; + sendToReceiver(F_RECEIVER_SET_NUM_COUNTERS, ncounters, nullptr); + } +} + +int Module::getNumberOfGates() { return sendToDetector(F_GET_NUM_GATES); } + +void Module::setNumberOfGates(int value) { + sendToDetector(F_SET_NUM_GATES, value, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SET_RECEIVER_NUM_GATES, value, nullptr); + } +} + +std::array Module::getExptimeForAllGates() { + static_assert(sizeof(time::ns) == 8, "ns needs to be 64bit"); + return sendToDetector>(F_GET_EXPTIME_ALL_GATES); +} + +int64_t Module::getGateDelay(int gateIndex) { + return sendToDetector(F_GET_GATE_DELAY, gateIndex); +} + +void Module::setGateDelay(int gateIndex, int64_t value) { + int64_t args[]{static_cast(gateIndex), value}; + sendToDetector(F_SET_GATE_DELAY, args, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_SET_RECEIVER_GATE_DELAY, args, nullptr); + } +} + +std::array Module::getGateDelayForAllGates() { + static_assert(sizeof(time::ns) == 8, "ns needs to be 64bit"); + return sendToDetector>(F_GET_GATE_DELAY_ALL_GATES); +} + +// CTB / Moench Specific + +int Module::getNumberOfAnalogSamples() { + return sendToDetector(F_GET_NUM_ANALOG_SAMPLES); +} + +void Module::setNumberOfAnalogSamples(int value) { + sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr); + // update #nchan, as it depends on #samples, adcmask + updateNumberOfChannels(); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value, nullptr); + } +} + +int Module::getPipeline(int clkIndex) { + return sendToDetector(F_GET_PIPELINE, clkIndex); +} + +void Module::setPipeline(int clkIndex, int value) { + int args[]{clkIndex, value}; + sendToDetector(F_SET_PIPELINE, args, nullptr); +} + +uint32_t Module::getADCEnableMask() { + return sendToDetector(F_GET_ADC_ENABLE_MASK); +} + +void Module::setADCEnableMask(uint32_t mask) { + sendToDetector(F_SET_ADC_ENABLE_MASK, mask, nullptr); + // update #nchan, as it depends on #samples, adcmask, + updateNumberOfChannels(); + + // send to processor + if (shm()->myDetectorType == MOENCH) + setAdditionalJsonParameter("adcmask_1g", std::to_string(mask)); + + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_ADC_MASK, mask); + } +} + +uint32_t Module::getTenGigaADCEnableMask() { + return sendToDetector(F_GET_ADC_ENABLE_MASK_10G); +} + +void Module::setTenGigaADCEnableMask(uint32_t mask) { + sendToDetector(F_SET_ADC_ENABLE_MASK_10G, mask, nullptr); + // update #nchan, as it depends on #samples, adcmask, + updateNumberOfChannels(); + + // send to processor + if (shm()->myDetectorType == MOENCH) + setAdditionalJsonParameter("adcmask_10g", std::to_string(mask)); + + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_ADC_MASK_10G, mask); + } +} + +// CTB Specific + +int Module::getNumberOfDigitalSamples() { + return sendToDetector(F_GET_NUM_DIGITAL_SAMPLES); +} + +void Module::setNumberOfDigitalSamples(int value) { + LOG(logDEBUG1) << "Setting number of digital samples to " << value; + sendToDetector(F_SET_NUM_DIGITAL_SAMPLES, value, nullptr); + // update #nchan, as it depends on #samples, adcmask + updateNumberOfChannels(); + if (shm()->useReceiverFlag) { + LOG(logDEBUG1) << "Sending number of digital samples to Receiver: " + << value; + sendToReceiver(F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, value, nullptr); + } +} + +slsDetectorDefs::readoutMode Module::getReadoutMode() { + auto r = sendToDetector(F_GET_READOUT_MODE); + return static_cast(r); +} + +void Module::setReadoutMode(const slsDetectorDefs::readoutMode mode) { + auto arg = static_cast(mode); + LOG(logDEBUG1) << "Setting readout mode to " << arg; + sendToDetector(F_SET_READOUT_MODE, arg, nullptr); + // update #nchan, as it depends on #samples, adcmask, + if (shm()->myDetectorType == CHIPTESTBOARD) { + updateNumberOfChannels(); + } + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_READOUT_MODE, mode, nullptr); + } +} + +int Module::getExternalSamplingSource() { + return setExternalSamplingSource(-1); +} + +int Module::setExternalSamplingSource(int value) { + return sendToDetector(F_EXTERNAL_SAMPLING_SOURCE, value); +} + +bool Module::getExternalSampling() { + int arg = -1; + return sendToDetector(F_EXTERNAL_SAMPLING, arg); +} + +void Module::setExternalSampling(bool value) { + sendToDetector(F_EXTERNAL_SAMPLING, static_cast(value)); +} + +std::vector Module::getReceiverDbitList() const { + return sendToReceiver>( + F_GET_RECEIVER_DBIT_LIST); +} + +void Module::setReceiverDbitList(const std::vector &list) { + LOG(logDEBUG1) << "Setting Receiver Dbit List"; + if (list.size() > 64) { + throw sls::RuntimeError("Dbit list size cannot be greater than 64\n"); + } + for (auto &it : list) { + if (it < 0 || it > 63) { + throw sls::RuntimeError( + "Dbit list value must be between 0 and 63\n"); + } + } + sls::StaticVector arg = list; + sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr); +} + +int Module::getReceiverDbitOffset() { + return sendToReceiver(F_GET_RECEIVER_DBIT_OFFSET); +} + +void Module::setReceiverDbitOffset(int value) { + sendToReceiver(F_SET_RECEIVER_DBIT_OFFSET, value, nullptr); +} + +void Module::setDigitalIODelay(uint64_t pinMask, int delay) { + uint64_t args[]{pinMask, static_cast(delay)}; + sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr); +} + +bool Module::getLEDEnable() { + int arg = -1; + return static_cast(sendToDetector(F_LED, arg)); +} + +void Module::setLEDEnable(bool enable) { + sendToDetector(F_LED, static_cast(enable)); +} + +// Pattern + +void Module::setPattern(const std::string &fname) { + uint64_t word; + uint64_t addr = 0; + FILE *fd = fopen(fname.c_str(), "r"); + if (fd != nullptr) { + while (fread(&word, sizeof(word), 1, fd) != 0U) { + setPatternWord(addr, word); // TODO! (Erik) do we need to send + // pattern in 64bit chunks? + ++addr; + } + fclose(fd); + } else { + throw RuntimeError("Could not open file to set pattern"); + } +} + +uint64_t Module::getPatternIOControl() { + int64_t arg = -1; + return sendToDetector(F_SET_PATTERN_IO_CONTROL, arg); +} + +void Module::setPatternIOControl(uint64_t word) { + sendToDetector(F_SET_PATTERN_IO_CONTROL, word); +} + +uint64_t Module::getPatternClockControl() { + int64_t arg = -1; + return sendToDetector(F_SET_PATTERN_CLOCK_CONTROL, arg); +} + +void Module::setPatternClockControl(uint64_t word) { + sendToDetector(F_SET_PATTERN_CLOCK_CONTROL, word); +} + +uint64_t Module::getPatternWord(int addr) { + uint64_t args[]{static_cast(addr), static_cast(-1)}; + return sendToDetector(F_SET_PATTERN_WORD, args); +} + +void Module::setPatternWord(int addr, uint64_t word) { + uint64_t args[]{static_cast(addr), word}; + sendToDetector(F_SET_PATTERN_WORD, args); +} + +std::array Module::getPatternLoopAddresses(int level) { + int args[]{level, -1, -1}; + std::array retvals{}; + sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals); + return retvals; +} + +void Module::setPatternLoopAddresses(int level, int start, int stop) { + int args[]{level, start, stop}; + std::array retvals{}; + sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals); +} + +int Module::getPatternLoopCycles(int level) { + int args[]{level, -1}; + return sendToDetector(F_SET_PATTERN_LOOP_CYCLES, args); +} + +void Module::setPatternLoopCycles(int level, int n) { + int args[]{level, n}; + sendToDetector(F_SET_PATTERN_LOOP_CYCLES, args); +} + +int Module::getPatternWaitAddr(int level) { + int args[]{level, -1}; + return sendToDetector(F_SET_PATTERN_WAIT_ADDR, args); +} + +void Module::setPatternWaitAddr(int level, int addr) { + int args[]{level, addr}; + sendToDetector(F_SET_PATTERN_WAIT_ADDR, args); +} + +uint64_t Module::getPatternWaitTime(int level) { + uint64_t args[]{static_cast(level), static_cast(-1)}; + return sendToDetector(F_SET_PATTERN_WAIT_TIME, args); +} + +void Module::setPatternWaitTime(int level, uint64_t t) { + uint64_t args[]{static_cast(level), t}; + sendToDetector(F_SET_PATTERN_WAIT_TIME, args); +} + +uint64_t Module::getPatternMask() { + return sendToDetector(F_GET_PATTERN_MASK); +} + +void Module::setPatternMask(uint64_t mask) { + sendToDetector(F_SET_PATTERN_MASK, mask, nullptr); +} + +uint64_t Module::getPatternBitMask() { + return sendToDetector(F_GET_PATTERN_BIT_MASK); +} + +void Module::setPatternBitMask(uint64_t mask) { + sendToDetector(F_SET_PATTERN_BIT_MASK, mask, nullptr); +} + +void Module::startPattern() { sendToDetector(F_START_PATTERN); } + +// Moench + // private void Module::sendToDetector(int fnum, const void *args, size_t args_size, @@ -2064,120 +2591,6 @@ void Module::startReadOut() { sendToDetector(F_START_READOUT); } void Module::readAll() { sendToDetector(F_READ_ALL); } -int64_t Module::getNumberOfBursts() { - return sendToDetector(F_GET_NUM_BURSTS); -} - -void Module::setNumberOfBursts(int64_t value) { - LOG(logDEBUG1) << "Setting number of bursts to " << value; - sendToDetector(F_SET_NUM_BURSTS, value, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending number of bursts to Receiver: " << value; - sendToReceiver(F_SET_RECEIVER_NUM_BURSTS, value, nullptr); - } -} - -int Module::getNumberOfAnalogSamples() { - return sendToDetector(F_GET_NUM_ANALOG_SAMPLES); -} - -void Module::setNumberOfAnalogSamples(int value) { - LOG(logDEBUG1) << "Setting number of analog samples to " << value; - sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr); - // update #nchan, as it depends on #samples, adcmask - updateNumberOfChannels(); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending number of analog samples to Receiver: " - << value; - sendToReceiver(F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value, nullptr); - } -} - -int Module::getNumberOfDigitalSamples() { - return sendToDetector(F_GET_NUM_DIGITAL_SAMPLES); -} - -void Module::setNumberOfDigitalSamples(int value) { - LOG(logDEBUG1) << "Setting number of digital samples to " << value; - sendToDetector(F_SET_NUM_DIGITAL_SAMPLES, value, nullptr); - // update #nchan, as it depends on #samples, adcmask - updateNumberOfChannels(); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending number of digital samples to Receiver: " - << value; - sendToReceiver(F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, value, nullptr); - } -} - -int Module::getNumberOfGates() { return sendToDetector(F_GET_NUM_GATES); } - -void Module::setNumberOfGates(int value) { - LOG(logDEBUG1) << "Setting number of gates to " << value; - sendToDetector(F_SET_NUM_GATES, value, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending number of gates to Receiver: " << value; - sendToReceiver(F_SET_RECEIVER_NUM_GATES, value, nullptr); - } -} - -int64_t Module::getExptime(int gateIndex) { - return sendToDetector(F_GET_EXPTIME, gateIndex); -} - -void Module::setExptime(int gateIndex, int64_t value) { - int64_t prevVal = value; - if (shm()->myDetectorType == EIGER) { - prevVal = getExptime(-1); - } - LOG(logDEBUG1) << "Setting exptime to " << value - << "ns (gateindex: " << gateIndex << ")"; - int64_t args[]{static_cast(gateIndex), value}; - sendToDetector(F_SET_EXPTIME, args, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending exptime to Receiver: " << value; - sendToReceiver(F_RECEIVER_SET_EXPTIME, args, nullptr); - } - if (prevVal != value) { - updateRateCorrection(); - } -} - -std::array Module::getExptimeForAllGates() { - static_assert(sizeof(time::ns) == 8, "ns needs to be 64bit"); - return sendToDetector>(F_GET_EXPTIME_ALL_GATES); -} - -int64_t Module::getGateDelay(int gateIndex) { - return sendToDetector(F_GET_GATE_DELAY, gateIndex); -} - -void Module::setGateDelay(int gateIndex, int64_t value) { - LOG(logDEBUG1) << "Setting gate delay to " << value - << "ns (gateindex: " << gateIndex << ")"; - int64_t args[]{static_cast(gateIndex), value}; - sendToDetector(F_SET_GATE_DELAY, args, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending gate delay to Receiver: " << value; - sendToReceiver(F_SET_RECEIVER_GATE_DELAY, args, nullptr); - } -} - -std::array Module::getGateDelayForAllGates() { - static_assert(sizeof(time::ns) == 8, "ns needs to be 64bit"); - return sendToDetector>(F_GET_GATE_DELAY_ALL_GATES); -} - -int64_t Module::getBurstPeriod() { - return sendToDetector(F_GET_BURST_PERIOD); -} - -void Module::setBurstPeriod(int64_t value) { - LOG(logDEBUG1) << "Setting burst period to " << value << "ns"; - sendToDetector(F_SET_BURST_PERIOD, value, nullptr); -} - -// Acquisition Parameters - int64_t Module::getNumberOfFramesFromStart() const { int64_t retval = -1; sendToDetectorStop(F_GET_FRAMES_FROM_START, nullptr, retval); @@ -2199,24 +2612,6 @@ int64_t Module::getMeasurementTime() const { return retval; } -void Module::setReadoutMode(const slsDetectorDefs::readoutMode mode) { - auto arg = static_cast(mode); - LOG(logDEBUG1) << "Setting readout mode to " << arg; - sendToDetector(F_SET_READOUT_MODE, arg, nullptr); - // update #nchan, as it depends on #samples, adcmask, - if (shm()->myDetectorType == CHIPTESTBOARD) { - updateNumberOfChannels(); - } - if (shm()->useReceiverFlag) { - sendToReceiver(F_RECEIVER_SET_READOUT_MODE, mode, nullptr); - } -} - -slsDetectorDefs::readoutMode Module::getReadoutMode() { - auto r = sendToDetector(F_GET_READOUT_MODE); - return static_cast(r); -} - uint32_t Module::writeRegister(uint32_t addr, uint32_t val) { uint32_t args[]{addr, val}; uint32_t retval = -1; @@ -2370,247 +2765,6 @@ void Module::executeBusTest() { sendToDetector(F_SET_BUS_TEST); } -std::array Module::getInjectChannel() { - std::array retvals{}; - sendToDetector(F_GET_INJECT_CHANNEL, nullptr, retvals); - LOG(logDEBUG1) << "Inject Channel: [offset: " << retvals[0] - << ", increment: " << retvals[1] << ']'; - return retvals; -} - -void Module::setInjectChannel(const int offsetChannel, - const int incrementChannel) { - int args[]{offsetChannel, incrementChannel}; - LOG(logDEBUG1) << "Setting inject channels [offset: " << offsetChannel - << ", increment: " << incrementChannel << ']'; - sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr); -} - -std::vector Module::getVetoPhoton(const int chipIndex) { - int fnum = F_GET_VETO_PHOTON; - int ret = FAIL; - auto client = DetectorSocket(shm()->hostname, shm()->controlPort); - client.Send(&fnum, sizeof(fnum)); - client.Send(&chipIndex, sizeof(chipIndex)); - client.Receive(&ret, sizeof(ret)); - if (ret == FAIL) { - char mess[MAX_STR_LENGTH]{}; - client.Receive(mess, MAX_STR_LENGTH); - throw RuntimeError("Detector " + std::to_string(moduleId) + - " returned error: " + std::string(mess)); - } else { - int nch = -1; - client.Receive(&nch, sizeof(nch)); - - int adus[nch]; - memset(adus, 0, sizeof(adus)); - client.Receive(adus, sizeof(adus)); - std::vector retvals(adus, adus + nch); - LOG(logDEBUG1) << "Getting veto photon [" << chipIndex << "]: " << nch - << " channels\n"; - return retvals; - } -} - -void Module::setVetoPhoton(const int chipIndex, const int numPhotons, - const int energy, const std::string &fname) { - if (shm()->myDetectorType != GOTTHARD2) { - throw RuntimeError( - "Set Veto reference is not implemented for this detector"); - } - if (chipIndex < -1 || chipIndex >= shm()->nChip.x) { - throw RuntimeError("Could not set veto photon. Invalid chip index: " + - std::to_string(chipIndex)); - } - if (numPhotons < 1) { - throw RuntimeError( - "Could not set veto photon. Invalid number of photons: " + - std::to_string(numPhotons)); - } - if (energy < 1) { - throw RuntimeError("Could not set veto photon. Invalid energy: " + - std::to_string(energy)); - } - std::ifstream infile(fname.c_str()); - if (!infile.is_open()) { - throw RuntimeError("Could not set veto photon. Could not open file: " + - fname); - } - - int totalEnergy = numPhotons * energy; - int ch = shm()->nChan.x; - int gainIndex = 2; - int nRead = 0; - int value[ch]; - memset(value, 0, sizeof(value)); - bool firstLine = true; - - while (infile.good()) { - std::string line; - getline(infile, line); - if (line.find('#') != std::string::npos) { - line.erase(line.find('#')); - } - if (line.length() < 1) { - continue; - } - std::istringstream ss(line); - // first line: caluclate gain index from gain thresholds from file - if (firstLine) { - int g0 = -1, g1 = -1; - if (!(ss >> g0 >> g1)) { - throw RuntimeError( - "Could not set veto photon. Invalid gain thresholds"); - } - // set gain index and gain bit values - if (totalEnergy < g0) { - gainIndex = 0; - } else if (totalEnergy < g1) { - gainIndex = 1; - } - LOG(logINFO) << "Setting veto photon. Reading Gain " << gainIndex - << " values"; - firstLine = false; - } - // read pedestal and gain values - else { - double p[3] = {-1, -1, -1}, g[3] = {-1, -1, -1}; - if (!(ss >> p[0] >> p[1] >> p[2] >> g[0] >> g[1] >> g[2])) { - throw RuntimeError("Could not set veto photon. Invalid " - "pedestal or gain values for channel " + - std::to_string(nRead)); - } - value[nRead] = - p[gainIndex] + - (g[gainIndex] * - totalEnergy); // ADU value = pedestal + gain * total energy - ++nRead; - if (nRead >= ch) { - break; - } - } - } - if (nRead != ch) { - throw RuntimeError("Could not set veto photon. Insufficient pedestal " - "pr gain values: " + - std::to_string(nRead)); - } - - int fnum = F_SET_VETO_PHOTON; - int ret = FAIL; - int args[]{chipIndex, gainIndex, ch}; - LOG(logDEBUG) << "Sending veto photon value to detector [chip:" << chipIndex - << ", G" << gainIndex << "]: " << args; - auto client = DetectorSocket(shm()->hostname, shm()->controlPort); - client.Send(&fnum, sizeof(fnum)); - client.Send(args, sizeof(args)); - client.Send(value, sizeof(value)); - client.Receive(&ret, sizeof(ret)); - if (ret == FAIL) { - char mess[MAX_STR_LENGTH]{}; - client.Receive(mess, MAX_STR_LENGTH); - throw RuntimeError("Detector " + std::to_string(moduleId) + - " returned error: " + std::string(mess)); - } -} - -void Module::setVetoReference(const int gainIndex, const int value) { - int args[]{gainIndex, value}; - LOG(logDEBUG1) << "Setting veto reference [gainIndex: " << gainIndex - << ", value: 0x" << std::hex << value << std::dec << ']'; - sendToDetector(F_SET_VETO_REFERENCE, args, nullptr); -} - -slsDetectorDefs::burstMode Module::getBurstMode() { - auto r = sendToDetector(F_GET_BURST_MODE); - return static_cast(r); -} - -void Module::setBurstMode(slsDetectorDefs::burstMode value) { - int arg = static_cast(value); - LOG(logDEBUG1) << "Setting burst mode to " << arg; - sendToDetector(F_SET_BURST_MODE, arg, nullptr); - if (shm()->useReceiverFlag) { - LOG(logDEBUG1) << "Sending burst mode to Receiver: " << value; - sendToReceiver(F_SET_RECEIVER_BURST_MODE, value, nullptr); - } -} - -bool Module::getCurrentSource() { - return sendToDetector(F_GET_CURRENT_SOURCE); -} - -void Module::setCurrentSource(bool value) { - sendToDetector(F_SET_CURRENT_SOURCE, static_cast(value), nullptr); -} - -slsDetectorDefs::timingSourceType Module::getTimingSource() { - auto r = sendToDetector(F_GET_TIMING_SOURCE); - return static_cast(r); -} - -void Module::setTimingSource(slsDetectorDefs::timingSourceType value) { - sendToDetector(F_SET_TIMING_SOURCE, static_cast(value), nullptr); -} - -bool Module::getVeto() { return sendToDetector(F_GET_VETO); } - -void Module::setVeto(bool enable) { - sendToDetector(F_SET_VETO, static_cast(enable), nullptr); -} - -void Module::setADCEnableMask(uint32_t mask) { - uint32_t arg = mask; - LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg - << std::dec; - sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0); - - // update #nchan, as it depends on #samples, adcmask, - updateNumberOfChannels(); - - // send to processor - if (shm()->myDetectorType == MOENCH) - setAdditionalJsonParameter("adcmask_1g", std::to_string(mask)); - - if (shm()->useReceiverFlag) { - int fnum = F_RECEIVER_SET_ADC_MASK; - int retval = -1; - LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << mask - << std::dec << " in receiver"; - sendToReceiver(fnum, mask, retval); - } -} - -uint32_t Module::getADCEnableMask() { - return sendToDetector(F_GET_ADC_ENABLE_MASK); -} - -void Module::setTenGigaADCEnableMask(uint32_t mask) { - uint32_t arg = mask; - LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex << arg - << std::dec; - sendToDetector(F_SET_ADC_ENABLE_MASK_10G, &arg, sizeof(arg), nullptr, 0); - - // update #nchan, as it depends on #samples, adcmask, - updateNumberOfChannels(); - - // send to processor - if (shm()->myDetectorType == MOENCH) - setAdditionalJsonParameter("adcmask_10g", std::to_string(mask)); - - if (shm()->useReceiverFlag) { - int fnum = F_RECEIVER_SET_ADC_MASK_10G; - int retval = -1; - LOG(logDEBUG1) << "Setting 10Gb ADC Enable mask to 0x" << std::hex - << mask << std::dec << " in receiver"; - sendToReceiver(fnum, mask, retval); - } -} - -uint32_t Module::getTenGigaADCEnableMask() { - return sendToDetector(F_GET_ADC_ENABLE_MASK_10G); -} - void Module::setADCInvert(uint32_t value) { LOG(logDEBUG1) << "Setting ADC Invert to 0x" << std::hex << value << std::dec; @@ -2621,51 +2775,6 @@ uint32_t Module::getADCInvert() { return sendToDetector(F_GET_ADC_INVERT); } -int Module::setExternalSamplingSource(int value) { - return sendToDetector(F_EXTERNAL_SAMPLING_SOURCE, value); -} - -int Module::getExternalSamplingSource() { - return setExternalSamplingSource(-1); -} - -void Module::setExternalSampling(bool value) { - sendToDetector(F_EXTERNAL_SAMPLING, static_cast(value)); -} - -bool Module::getExternalSampling() { - int arg = -1; - return sendToDetector(F_EXTERNAL_SAMPLING, arg); -} - -void Module::setReceiverDbitList(const std::vector &list) { - LOG(logDEBUG1) << "Setting Receiver Dbit List"; - if (list.size() > 64) { - throw sls::RuntimeError("Dbit list size cannot be greater than 64\n"); - } - for (auto &it : list) { - if (it < 0 || it > 63) { - throw sls::RuntimeError( - "Dbit list value must be between 0 and 63\n"); - } - } - sls::StaticVector arg = list; - sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr); -} - -std::vector Module::getReceiverDbitList() const { - return sendToReceiver>( - F_GET_RECEIVER_DBIT_LIST); -} - -void Module::setReceiverDbitOffset(int value) { - sendToReceiver(F_SET_RECEIVER_DBIT_OFFSET, value, nullptr); -} - -int Module::getReceiverDbitOffset() { - return sendToReceiver(F_GET_RECEIVER_DBIT_OFFSET); -} - void Module::writeAdcRegister(uint32_t addr, uint32_t val) { uint32_t args[]{addr, val}; LOG(logDEBUG1) << "Writing to ADC register 0x" << std::hex << addr @@ -2880,131 +2989,6 @@ void Module::restreamStopFromReceiver() { } } -void Module::setPattern(const std::string &fname) { - uint64_t word; - uint64_t addr = 0; - FILE *fd = fopen(fname.c_str(), "r"); - if (fd != nullptr) { - while (fread(&word, sizeof(word), 1, fd) != 0U) { - setPatternWord(addr, word); // TODO! (Erik) do we need to send - // pattern in 64bit chunks? - ++addr; - } - fclose(fd); - } else { - throw RuntimeError("Could not open file to set pattern"); - } -} - -uint64_t Module::setPatternIOControl(uint64_t word) { - LOG(logDEBUG1) << "Setting Pattern IO Control, word: 0x" << std::hex << word - << std::dec; - return sendToDetector(F_SET_PATTERN_IO_CONTROL, word); -} - -uint64_t Module::setPatternClockControl(uint64_t word) { - LOG(logDEBUG1) << "Setting Pattern Clock Control, word: 0x" << std::hex - << word << std::dec; - return sendToDetector(F_SET_PATTERN_CLOCK_CONTROL, word); -} - -uint64_t Module::setPatternWord(int addr, uint64_t word) { - uint64_t args[]{static_cast(addr), word}; - - LOG(logDEBUG1) << "Setting Pattern word, addr: 0x" << std::hex << addr - << ", word: 0x" << word << std::dec; - return sendToDetector(F_SET_PATTERN_WORD, args); -} - -std::array Module::setPatternLoopAddresses(int level, int start, - int stop) { - int args[]{level, start, stop}; - std::array retvals{}; - LOG(logDEBUG1) << "Setting Pat Loop Addresses, level: " << level - << ", start: " << start << ", stop: " << stop; - sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals); - LOG(logDEBUG1) << "Set Pat Loop Addresses: " << retvals[0] << ", " - << retvals[1]; - return retvals; -} - -int Module::setPatternLoopCycles(int level, int n) { - int args[]{level, n}; - LOG(logDEBUG1) << "Setting Pat Loop cycles, level: " << level - << ",nloops: " << n; - return sendToDetector(F_SET_PATTERN_LOOP_CYCLES, args); -} - -int Module::setPatternWaitAddr(int level, int addr) { - int args[]{level, addr}; - LOG(logDEBUG1) << "Setting Pat Wait Addr, level: " << level << ", addr: 0x" - << std::hex << addr << std::dec; - return sendToDetector(F_SET_PATTERN_WAIT_ADDR, args); -} - -uint64_t Module::setPatternWaitTime(int level, uint64_t t) { - uint64_t args[]{static_cast(level), t}; - return sendToDetector(F_SET_PATTERN_WAIT_TIME, args); -} - -void Module::setPatternMask(uint64_t mask) { - LOG(logDEBUG1) << "Setting Pattern Mask " << std::hex << mask << std::dec; - sendToDetector(F_SET_PATTERN_MASK, mask, nullptr); -} - -uint64_t Module::getPatternMask() { - return sendToDetector(F_GET_PATTERN_MASK); -} - -void Module::setPatternBitMask(uint64_t mask) { - LOG(logDEBUG1) << "Setting Pattern Bit Mask " << std::hex << mask - << std::dec; - sendToDetector(F_SET_PATTERN_BIT_MASK, mask, nullptr); - LOG(logDEBUG1) << "Pattern Bit Mask successful"; -} - -uint64_t Module::getPatternBitMask() { - return sendToDetector(F_GET_PATTERN_BIT_MASK); -} - -void Module::startPattern() { sendToDetector(F_START_PATTERN); } - -int Module::setLEDEnable(int enable) { - return sendToDetector(F_LED, enable); -} - -void Module::setDigitalIODelay(uint64_t pinMask, int delay) { - uint64_t args[]{pinMask, static_cast(delay)}; - LOG(logDEBUG1) << "Sending Digital IO Delay, pin mask: " << std::hex - << args[0] << ", delay: " << std::dec << args[1] << " ps"; - sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr); - LOG(logDEBUG1) << "Digital IO Delay successful"; -} - -int Module::getPipeline(int clkIndex) { - return sendToDetector(F_GET_PIPELINE, clkIndex); -} - -void Module::setPipeline(int clkIndex, int value) { - int args[]{clkIndex, value}; - LOG(logDEBUG1) << "Setting Clock " << clkIndex << " pipeline to " << value; - sendToDetector(F_SET_PIPELINE, args, nullptr); -} - -void Module::setCounterMask(uint32_t countermask) { - LOG(logDEBUG1) << "Setting Counter mask to " << countermask; - sendToDetector(F_SET_COUNTER_MASK, countermask, nullptr); - if (shm()->useReceiverFlag) { - int ncounters = __builtin_popcount(countermask); - LOG(logDEBUG1) << "Sending Reciver #counters: " << ncounters; - sendToReceiver(F_RECEIVER_SET_NUM_COUNTERS, ncounters, nullptr); - } -} - -uint32_t Module::getCounterMask() { - return sendToDetector(F_GET_COUNTER_MASK); -} - sls_detector_module Module::interpolateTrim(sls_detector_module *a, sls_detector_module *b, const int energy, const int e1, diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 5c0e7b224..8d106e726 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -361,6 +361,105 @@ class Module : public virtual slsDetectorDefs { * Gotthard2 Specific * * * * ************************************************/ + int64_t getNumberOfBursts(); + void setNumberOfBursts(int64_t value); + int64_t getBurstPeriod(); + void setBurstPeriod(int64_t value); + std::array getInjectChannel(); + void setInjectChannel(const int offsetChannel, const int incrementChannel); + std::vector getVetoPhoton(const int chipIndex); + void setVetoPhoton(const int chipIndex, const int numPhotons, + const int energy, const std::string &fname); + void setVetoReference(const int gainIndex, const int value); + burstMode getBurstMode(); + void setBurstMode(burstMode value); + bool getCurrentSource(); + void setCurrentSource(bool value); + slsDetectorDefs::timingSourceType getTimingSource(); + void setTimingSource(slsDetectorDefs::timingSourceType value); + bool getVeto(); + void setVeto(bool enable); + + /************************************************** + * * + * Mythen3 Specific * + * * + * ************************************************/ + uint32_t getCounterMask(); + void setCounterMask(uint32_t countermask); + int getNumberOfGates(); + void setNumberOfGates(int value); + std::array getExptimeForAllGates(); + int64_t getGateDelay(int gateIndex); + void setGateDelay(int gateIndex, int64_t value); + std::array getGateDelayForAllGates(); + + /************************************************** + * * + * CTB / Moench Specific * + * * + * ************************************************/ + int getNumberOfAnalogSamples(); + void setNumberOfAnalogSamples(int value); + int getPipeline(int clkIndex); + void setPipeline(int clkIndex, int value); + uint32_t getADCEnableMask(); + void setADCEnableMask(uint32_t mask); + uint32_t getTenGigaADCEnableMask(); + void setTenGigaADCEnableMask(uint32_t mask); + + /************************************************** + * * + * CTB Specific * + * * + * ************************************************/ + int getNumberOfDigitalSamples(); + void setNumberOfDigitalSamples(int value); + readoutMode getReadoutMode(); + void setReadoutMode(const readoutMode mode); + int getExternalSamplingSource(); + int setExternalSamplingSource(int value); + bool getExternalSampling(); + void setExternalSampling(bool value); + std::vector getReceiverDbitList() const; + void setReceiverDbitList(const std::vector &list); + int getReceiverDbitOffset(); + void setReceiverDbitOffset(int value); + void setDigitalIODelay(uint64_t pinMask, int delay); + bool getLEDEnable(); + void setLEDEnable(bool enable); + + /************************************************** + * * + * Pattern * + * * + * ************************************************/ + void setPattern(const std::string &fname); + uint64_t getPatternIOControl(); + void setPatternIOControl(uint64_t word); + uint64_t getPatternClockControl(); + void setPatternClockControl(uint64_t word); + uint64_t getPatternWord(int addr); + void setPatternWord(int addr, uint64_t word); + std::array getPatternLoopAddresses(int level); + void setPatternLoopAddresses(int level, int start, int stop); + int getPatternLoopCycles(int level); + void setPatternLoopCycles(int level, int n); + int getPatternWaitAddr(int level); + void setPatternWaitAddr(int level, int addr); + uint64_t getPatternWaitTime(int level); + void setPatternWaitTime(int level, uint64_t t); + uint64_t getPatternMask(); + void setPatternMask(uint64_t mask); + uint64_t getPatternBitMask(); + void setPatternBitMask(uint64_t mask); + void startPattern(); + + /************************************************** + * * + * Moench * + * * + * ************************************************/ /** * Set Detector offset in shared memory in dimension d @@ -445,48 +544,6 @@ class Module : public virtual slsDetectorDefs { */ void configureMAC(); - /** [Gotthard2] only in burst mode and in auto timing mode */ - int64_t getNumberOfBursts(); - - /** [Gotthard2] only in burst mode and in auto timing mode */ - void setNumberOfBursts(int64_t value); - - /** [CTB][Moench] */ - int getNumberOfAnalogSamples(); - - /** [CTB][Moench] */ - void setNumberOfAnalogSamples(int value); - - /** [CTB] */ - int getNumberOfDigitalSamples(); - - /** [CTB] */ - void setNumberOfDigitalSamples(int value); - - /** [Mythen3] */ - int getNumberOfGates(); - - /** [Mythen3] */ - void setNumberOfGates(int value); - - /** [Mythen3] for all gates */ - std::array getExptimeForAllGates(); - - /** [Mythen3] gatIndex: 0-2 */ - int64_t getGateDelay(int gateIndex); - - /** [Mythen3] gatIndex: -1 for all, 0-2 */ - void setGateDelay(int gateIndex, int64_t value); - - /** [Mythen3] for all gates */ - std::array getGateDelayForAllGates(); - - /** [Gotthard2] only in burst mode and in auto timing mode */ - int64_t getBurstPeriod(); - - /** [Gotthard2] only in burst mode and in auto timing mode */ - void setBurstPeriod(int64_t value); - /** [Jungfrau][CTB][Moench][Mythen3] * [Gotthard2] only in continuous mode */ int64_t getNumberOfFramesFromStart() const; @@ -499,19 +556,6 @@ class Module : public virtual slsDetectorDefs { * [Gotthard2] only in continuous mode */ int64_t getMeasurementTime() const; - /** - * [Ctb] - * @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY, - * ANALOG_AND_DIGITAL - */ - void setReadoutMode(const readoutMode mode); - - /** - * [Ctb] - * @returns readout mode - */ - readoutMode getReadoutMode(); - /** * Write in a register. For Advanced users * @param addr address of register @@ -570,71 +614,6 @@ class Module : public virtual slsDetectorDefs { /** [Gotthard][Jungfrau][CTB][Moench] */ void executeBusTest(); - /** [Gotthard2] */ - std::array getInjectChannel(); - - /** [Gotthard2] - * @param offsetChannel starting channel to be injected - * @param incrementChannel determines succeeding channels to be injected */ - void setInjectChannel(const int offsetChannel, const int incrementChannel); - - /** [Gotthard2] asic input */ - std::vector getVetoPhoton(const int chipIndex); - - /** [Gotthard2] energy in keV */ - void setVetoPhoton(const int chipIndex, const int numPhotons, - const int energy, const std::string &fname); - - void setVetoReference(const int gainIndex, const int value); - - /** [Gotthard2] */ - burstMode getBurstMode(); - - /** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */ - void setBurstMode(burstMode value); - - /** [Gotthard2] */ - bool getCurrentSource(); - - /** default disabled */ - void setCurrentSource(bool value); - - /** [Gotthard2] */ - slsDetectorDefs::timingSourceType getTimingSource(); - - /** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */ - void setTimingSource(slsDetectorDefs::timingSourceType value); - - /** [Gotthard2] */ - bool getVeto(); - - /** default disabled */ - void setVeto(bool enable); - - /** - * Set ADC Enable Mask (CTB, Moench) - * @param mask ADC Enable mask - */ - void setADCEnableMask(uint32_t mask); - - /** - * Get ADC Enable Mask (CTB, Moench) - * @returns ADC Enable mask - */ - uint32_t getADCEnableMask(); - - /** - * Set 10Gb ADC Enable Mask (CTB, Moench) - * @param mask ADC Enable mask - */ - void setTenGigaADCEnableMask(uint32_t mask); - - /** - * Get 10Gb ADC Enable Mask (CTB, Moench) - * @returns ADC Enable mask - */ - uint32_t getTenGigaADCEnableMask(); - /** * Set ADC invert register (CTB, Moench, Jungfrau) * @param value ADC invert value @@ -649,33 +628,6 @@ class Module : public virtual slsDetectorDefs { */ uint32_t getADCInvert(); - /** - * Set external sampling source (CTB only) - * @param value external sampling source (Option: 0-63) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling source - */ - int setExternalSamplingSource(int value); - - /** - * Get external sampling source (CTB only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling source - */ - int getExternalSamplingSource(); - - void setExternalSampling(bool value); - - bool getExternalSampling(); - - /** digital data bits enable (CTB only) */ - void setReceiverDbitList(const std::vector &list); - std::vector getReceiverDbitList() const; - - /** Set digital data offset in bytes (CTB only) */ - void setReceiverDbitOffset(int value); - int getReceiverDbitOffset(); - /** * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert * users @@ -770,124 +722,6 @@ class Module : public virtual slsDetectorDefs { */ void restreamStopFromReceiver(); - /** - * Opens pattern file and sends pattern to CTB - * @param fname pattern file to open - */ - void setPattern(const std::string &fname); - - /** - * Sets pattern IO control (CTB/ Moench) - * @param word 64bit word to be written, -1 gets - * @returns actual value - */ - uint64_t setPatternIOControl(uint64_t word = -1); - - /** - * Sets pattern clock control (CTB/ Moench) - * @param word 64bit word to be written, -1 gets - * @returns actual value - */ - uint64_t setPatternClockControl(uint64_t word = -1); - - /** - * Writes a pattern word (CTB/ Moench/ Mythen3) - * @param addr address of the word - * @param word 64bit word to be written, -1 reads the addr (same as - * executing the pattern for ctb) - * @returns actual value - */ - uint64_t setPatternWord(int addr, uint64_t word); - - /** - * Sets the pattern or loop limits (CTB/ Moench/ Mythen3) - * @param level -1 complete pattern, 0,1,2, loop level - * @param start start address for level 0-2, -1 gets - * @param stop stop address for level 0-2, -1 gets - * @returns array of start addr and stop addr - */ - std::array setPatternLoopAddresses(int level = -1, int start = -1, - int stop = -1); - - /** - * Sets the pattern or loop limits (CTB/ Moench/ Mythen3) - * @param level -1 complete pattern, 0,1,2, loop level - * @param n number of loops for level 0-2, -1 gets - * @returns number of loops - */ - int setPatternLoopCycles(int level = -1, int n = -1); - - /** - * Sets the wait address (CTB/ Moench/ Mythen3) - * @param level 0,1,2, wait level - * @param addr wait address, -1 gets - * @returns actual value - */ - int setPatternWaitAddr(int level, int addr = -1); - - /** - * Sets the wait time (CTB/ Moench/ Mythen3) - * @param level 0,1,2, wait level - * @param t wait time, -1 gets - * @returns actual value - */ - uint64_t setPatternWaitTime(int level, uint64_t t = -1); - - /** - * Sets the mask applied to every pattern (CTB/ Moench/ Mythen3) - * @param mask mask to be applied - */ - void setPatternMask(uint64_t mask); - - /** - * Gets the mask applied to every pattern (CTB/ Moench/ Mythen3) - * @returns mask set - */ - uint64_t getPatternMask(); - - /** - * Selects the bits that the mask will be applied to for every pattern (CTB/ - * Moench/ Mythen3) - * @param mask mask to select bits - */ - void setPatternBitMask(uint64_t mask); - - /** - * Gets the bits that the mask will be applied to for every pattern (CTB/ - * Moench/ Mythen3) - * @returns mask of bits selected - */ - uint64_t getPatternBitMask(); - - /** [Mythen3] */ - void startPattern(); - - /** - * Set LED Enable (Moench, CTB only) - * @param enable 1 to switch on, 0 to switch off, -1 gets - * @returns LED enable - */ - int setLEDEnable(int enable = -1); - - /** - * 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) - */ - void setDigitalIODelay(uint64_t pinMask, int delay); - - /** [Ctb][Moench] */ - int getPipeline(int clkIndex); - - /** [Ctb][Moench] */ - void setPipeline(int clkIndex, int value); - - /** [Mythen3] */ - void setCounterMask(uint32_t countermask); - - /** [Mythen3] */ - uint32_t getCounterMask(); - private: /** * Send function parameters to detector (control server)