#include "sls/Detector.h" #include "sls/detectorData.h" #include "CmdParser.h" #include "CmdProxy.h" #include "DetectorImpl.h" #include "Module.h" #include "sls/container_utils.h" #include "sls/logger.h" #include "sls/sls_detector_defs.h" #include "sls/versionAPI.h" #include #include #include namespace sls { void freeSharedMemory(int multiId, int detPos) { // single if (detPos >= 0) { SharedMemory temp_shm(multiId, detPos); if (temp_shm.IsExisting()) { temp_shm.RemoveSharedMemory(); } return; } // multi - get number of detectors from shm SharedMemory multiShm(multiId, -1); int numDetectors = 0; if (multiShm.IsExisting()) { multiShm.OpenSharedMemory(); numDetectors = multiShm()->numberOfDetectors; multiShm.RemoveSharedMemory(); } for (int i = 0; i < numDetectors; ++i) { SharedMemory shm(multiId, i); shm.RemoveSharedMemory(); } } using defs = slsDetectorDefs; Detector::Detector(int shm_id) : pimpl(sls::make_unique(shm_id)) {} Detector::~Detector() = default; // Configuration void Detector::freeSharedMemory() { pimpl->freeSharedMemory(); } void Detector::loadConfig(const std::string &fname) { int shm_id = getShmId(); freeSharedMemory(); pimpl = sls::make_unique(shm_id); LOG(logINFO) << "Loading configuration file: " << fname; loadParameters(fname); } void Detector::loadParameters(const std::string &fname) { std::ifstream input_file(fname); if (!input_file) { throw RuntimeError("Could not open configuration file " + fname + " for reading"); } std::vector parameters; for (std::string line; std::getline(input_file, line);) { if (line.find('#') != std::string::npos) { line.erase(line.find('#')); } if (line.length() > 1) { parameters.push_back(line); } } loadParameters(parameters); } void Detector::loadParameters(const std::vector ¶meters) { CmdProxy proxy(this); CmdParser parser; for (const auto ¤t_line : parameters) { parser.Parse(current_line); proxy.Call(parser.command(), parser.arguments(), parser.detector_id(), defs::PUT_ACTION); } } Result Detector::getHostname(Positions pos) const { return pimpl->Parallel(&Module::getHostname, pos); } void Detector::setHostname(const std::vector &hostname) { pimpl->setHostname(hostname); } void Detector::setVirtualDetectorServers(int numServers, int startingPort) { pimpl->setVirtualDetectorServers(numServers, startingPort); } int Detector::getShmId() const { return pimpl->getMultiId(); } std::string Detector::getPackageVersion() const { return GITBRANCH; } int64_t Detector::getClientVersion() const { return APILIB; } Result Detector::getFirmwareVersion(Positions pos) const { return pimpl->Parallel(&Module::getFirmwareVersion, pos); } Result Detector::getDetectorServerVersion(Positions pos) const { return pimpl->Parallel(&Module::getDetectorServerVersion, pos); } Result Detector::getSerialNumber(Positions pos) const { return pimpl->Parallel(&Module::getSerialNumber, pos); } Result Detector::getReceiverVersion(Positions pos) const { return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos); } Result Detector::getDetectorType(Positions pos) const { return pimpl->Parallel(&Module::getDetectorType, pos); } int Detector::size() const { return pimpl->size(); } bool Detector::empty() const { return pimpl->size() == 0; } defs::xy Detector::getModuleGeometry() const { return pimpl->getNumberOfDetectors(); } Result Detector::getModuleSize(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfChannels, pos); } defs::xy Detector::getDetectorSize() const { return pimpl->getNumberOfChannels(); } void Detector::setDetectorSize(const defs::xy value) { pimpl->setNumberOfChannels(value); } std::vector Detector::getSettingsList() const { switch (getDetectorType().squash()) { case defs::EIGER: return std::vector{ defs::STANDARD, defs::HIGHGAIN, defs::LOWGAIN, defs::VERYHIGHGAIN, defs::VERYLOWGAIN}; case defs::GOTTHARD: return std::vector{ defs::HIGHGAIN, defs::DYNAMICGAIN, defs::LOWGAIN, defs::MEDIUMGAIN, defs::VERYHIGHGAIN}; case defs::JUNGFRAU: return std::vector{ defs::DYNAMICGAIN, defs::DYNAMICHG0, defs::FIXGAIN1, defs::FIXGAIN2, defs::FORCESWITCHG1, defs::FORCESWITCHG2}; case defs::GOTTHARD2: return std::vector{ defs::DYNAMICGAIN, defs::DYNAMICHG0, defs::FIXGAIN1, defs::FIXGAIN2}; case defs::MOENCH: return std::vector{ defs::G1_HIGHGAIN, defs::G1_LOWGAIN, defs::G2_HIGHCAP_HIGHGAIN, defs::G2_HIGHCAP_LOWGAIN, defs::G2_LOWCAP_HIGHGAIN, defs::G2_LOWCAP_LOWGAIN, defs::G4_HIGHGAIN, defs::G4_LOWGAIN}; case defs::CHIPTESTBOARD: case defs::MYTHEN3: throw RuntimeError("Settings not implemented for this detector"); default: throw RuntimeError("Unknown detector type"); } } Result Detector::getSettings(Positions pos) const { return pimpl->Parallel(&Module::getSettings, pos); } void Detector::setSettings(const defs::detectorSettings value, Positions pos) { pimpl->Parallel(&Module::setSettings, pos, value); } void Detector::loadTrimbits(const std::string &fname, Positions pos) { pimpl->Parallel(&Module::loadSettingsFile, pos, fname); } Result Detector::getAllTrimbits(Positions pos) const { return pimpl->Parallel(&Module::getAllTrimbits, pos); } void Detector::setAllTrimbits(int value, Positions pos) { pimpl->Parallel(&Module::setAllTrimbits, pos, value); } bool Detector::getGapPixelsinCallback() const { return pimpl->getGapPixelsinCallback(); } void Detector::setGapPixelsinCallback(bool enable) { pimpl->setGapPixelsinCallback(enable); } Result Detector::isVirtualDetectorServer(Positions pos) const { return pimpl->Parallel(&Module::isVirtualDetectorServer, pos); } // Callback void Detector::registerAcquisitionFinishedCallback(void (*func)(double, int, void *), void *pArg) { pimpl->registerAcquisitionFinishedCallback(func, pArg); } void Detector::registerDataCallback(void (*func)(detectorData *, uint64_t, uint32_t, void *), void *pArg) { pimpl->registerDataCallback(func, pArg); } // Acquisition Parameters Result Detector::getNumberOfFrames(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfFrames, pos); } void Detector::setNumberOfFrames(int64_t value) { pimpl->Parallel(&Module::setNumberOfFrames, {}, value); } Result Detector::getNumberOfTriggers(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfTriggers, pos); } void Detector::setNumberOfTriggers(int64_t value) { pimpl->Parallel(&Module::setNumberOfTriggers, {}, value); } Result Detector::getExptime(Positions pos) const { return pimpl->Parallel(&Module::getExptime, pos, -1); } void Detector::setExptime(ns t, Positions pos) { pimpl->Parallel(&Module::setExptime, pos, -1, t.count()); updateRxRateCorrections(); } Result Detector::getPeriod(Positions pos) const { return pimpl->Parallel(&Module::getPeriod, pos); } void Detector::setPeriod(ns t, Positions pos) { pimpl->Parallel(&Module::setPeriod, pos, t.count()); } Result Detector::getDelayAfterTrigger(Positions pos) const { return pimpl->Parallel(&Module::getDelayAfterTrigger, pos); } void Detector::setDelayAfterTrigger(ns value, Positions pos) { pimpl->Parallel(&Module::setDelayAfterTrigger, pos, value.count()); } Result Detector::getNumberOfFramesLeft(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfFramesLeft, pos); } Result Detector::getNumberOfTriggersLeft(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfTriggersLeft, pos); } Result Detector::getDelayAfterTriggerLeft(Positions pos) const { return pimpl->Parallel(&Module::getDelayAfterTriggerLeft, pos); } Result Detector::getPeriodLeft(Positions pos) const { return pimpl->Parallel(&Module::getPeriodLeft, pos); } Result Detector::getDynamicRange(Positions pos) const { return pimpl->Parallel(&Module::getDynamicRange, pos); } void Detector::setDynamicRange(int value) { pimpl->Parallel(&Module::setDynamicRange, {}, value); updateRxRateCorrections(); } std::vector Detector::getDynamicRangeList() const { switch (getDetectorType().squash()) { case defs::EIGER: return std::vector{4, 8, 16, 32}; case defs::MYTHEN3: return std::vector{8, 16, 32}; default: return std::vector{16}; } } Result Detector::getTimingMode(Positions pos) const { return pimpl->Parallel(&Module::getTimingMode, pos); } void Detector::setTimingMode(defs::timingMode value, Positions pos) { pimpl->Parallel(&Module::setTimingMode, pos, value); } std::vector Detector::getTimingModeList() const { switch (getDetectorType().squash()) { case defs::EIGER: return std::vector{defs::AUTO_TIMING, defs::TRIGGER_EXPOSURE, defs::GATED, defs::BURST_TRIGGER}; case defs::MYTHEN3: return std::vector{defs::AUTO_TIMING, defs::TRIGGER_EXPOSURE, defs::GATED, defs::TRIGGER_GATED}; default: return std::vector{defs::AUTO_TIMING, defs::TRIGGER_EXPOSURE}; } } Result Detector::getSpeed(Positions pos) const { auto res = pimpl->Parallel(&Module::getClockDivider, pos, defs::RUN_CLOCK); Result speedResult(res.size()); for (unsigned int i = 0; i < res.size(); ++i) { speedResult[i] = static_cast(res[i]); } return speedResult; } void Detector::setSpeed(defs::speedLevel value, Positions pos) { pimpl->Parallel(&Module::setClockDivider, pos, defs::RUN_CLOCK, static_cast(value)); } Result Detector::getADCPhase(Positions pos) const { return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, false); } void Detector::setADCPhase(int value, Positions pos) { pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value, false); } Result Detector::getMaxADCPhaseShift(Positions pos) const { return pimpl->Parallel(&Module::getMaxClockPhaseShift, pos, defs::ADC_CLOCK); } Result Detector::getADCPhaseInDegrees(Positions pos) const { return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, true); } void Detector::setADCPhaseInDegrees(int value, Positions pos) { pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value, true); } Result Detector::getDBITPhase(Positions pos) const { return pimpl->Parallel(&Module::getClockPhase, pos, defs::DBIT_CLOCK, false); } void Detector::setDBITPhase(int value, Positions pos) { pimpl->Parallel(&Module::setClockPhase, pos, defs::DBIT_CLOCK, value, false); } Result Detector::getMaxDBITPhaseShift(Positions pos) const { return pimpl->Parallel(&Module::getMaxClockPhaseShift, pos, defs::DBIT_CLOCK); } Result Detector::getDBITPhaseInDegrees(Positions pos) const { return pimpl->Parallel(&Module::getClockPhase, pos, defs::DBIT_CLOCK, true); } void Detector::setDBITPhaseInDegrees(int value, Positions pos) { pimpl->Parallel(&Module::setClockPhase, pos, defs::DBIT_CLOCK, value, true); } Result Detector::getClockFrequency(int clkIndex, Positions pos) { return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex); } Result Detector::getClockPhase(int clkIndex, Positions pos) { return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false); } void Detector::setClockPhase(int clkIndex, int value, Positions pos) { pimpl->Parallel(&Module::setClockPhase, pos, clkIndex, value, false); } Result Detector::getMaxClockPhaseShift(int clkIndex, Positions pos) { return pimpl->Parallel(&Module::getMaxClockPhaseShift, pos, clkIndex); } Result Detector::getClockPhaseinDegrees(int clkIndex, Positions pos) { return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, true); } void Detector::setClockPhaseinDegrees(int clkIndex, int value, Positions pos) { pimpl->Parallel(&Module::setClockPhase, pos, clkIndex, value, true); } Result Detector::getClockDivider(int clkIndex, Positions pos) { return pimpl->Parallel(&Module::getClockDivider, pos, clkIndex); } void Detector::setClockDivider(int clkIndex, int value, Positions pos) { pimpl->Parallel(&Module::setClockDivider, pos, clkIndex, value); } Result Detector::getHighVoltage(Positions pos) const { return pimpl->Parallel(&Module::getDAC, pos, defs::HIGH_VOLTAGE, false); } void Detector::setHighVoltage(int value, Positions pos) { pimpl->Parallel(&Module::setDAC, pos, value, defs::HIGH_VOLTAGE, false); } Result Detector::getPowerChip(Positions pos) const { return pimpl->Parallel(&Module::getPowerChip, pos); } void Detector::setPowerChip(bool on, Positions pos) { if ((pos.empty() || pos[0] == -1) && on && pimpl->size() > 3) { for (int i = 0; i != pimpl->size(); ++i) { pimpl->Parallel(&Module::setPowerChip, {i}, on); std::this_thread::sleep_for(std::chrono::seconds(1)); } } else { pimpl->Parallel(&Module::setPowerChip, pos, on); } } Result Detector::getImageTestMode(Positions pos) { return pimpl->Parallel(&Module::getImageTestMode, pos); } void Detector::setImageTestMode(int value, Positions pos) { pimpl->Parallel(&Module::setImageTestMode, pos, value); } std::vector Detector::getTemperatureList() const { std::vector retval; switch (getDetectorType().squash()) { case defs::CHIPTESTBOARD: return std::vector{defs::SLOW_ADC_TEMP}; case defs::JUNGFRAU: case defs::GOTTHARD: return std::vector{defs::TEMPERATURE_ADC, defs::TEMPERATURE_FPGA}; case defs::EIGER: return std::vector{ defs::TEMPERATURE_FPGA, defs::TEMPERATURE_FPGAEXT, defs::TEMPERATURE_10GE, defs::TEMPERATURE_DCDC, defs::TEMPERATURE_SODL, defs::TEMPERATURE_SODR, defs::TEMPERATURE_FPGA2, defs::TEMPERATURE_FPGA3}; default: return std::vector{}; } } Result Detector::getTemperature(defs::dacIndex index, Positions pos) const { switch (index) { case defs::TEMPERATURE_ADC: case defs::TEMPERATURE_FPGA: case defs::TEMPERATURE_FPGAEXT: case defs::TEMPERATURE_10GE: case defs::TEMPERATURE_DCDC: case defs::TEMPERATURE_SODL: case defs::TEMPERATURE_SODR: case defs::TEMPERATURE_FPGA2: case defs::TEMPERATURE_FPGA3: case defs::SLOW_ADC_TEMP: break; default: throw RuntimeError("Unknown Temperature Index"); } auto res = pimpl->Parallel(&Module::getADC, pos, index); switch (getDetectorType().squash()) { case defs::EIGER: case defs::JUNGFRAU: for (auto &it : res) { it /= 1000; } break; default: break; } return res; } std::vector Detector::getDacList() const { std::vector retval; switch (getDetectorType().squash()) { case defs::EIGER: return std::vector{ defs::VSVP, defs::VTRIM, defs::VRPREAMP, defs::VRSHAPER, defs::VSVN, defs::VTGSTV, defs::VCMP_LL, defs::VCMP_LR, defs::VCAL, defs::VCMP_RL, defs::RXB_RB, defs::RXB_LB, defs::VCMP_RR, defs::VCP, defs::VCN, defs::VISHAPER, defs::VTHRESHOLD}; case defs::GOTTHARD: return std::vector{ defs::VREF_DS, defs::VCASCN_PB, defs::VCASCP_PB, defs::VOUT_CM, defs::VCASC_OUT, defs::VIN_CM, defs::VREF_COMP, defs::IB_TESTC}; case defs::JUNGFRAU: return std::vector{ defs::VB_COMP, defs::VDD_PROT, defs::VIN_COM, defs::VREF_PRECH, defs::VB_PIXBUF, defs::VB_DS, defs::VREF_DS, defs::VREF_COMP}; case defs::GOTTHARD2: return std::vector{ defs::VREF_H_ADC, defs::VB_COMP_FE, defs::VB_COMP_ADC, defs::VCOM_CDS, defs::VREF_RSTORE, defs::VB_OPA_1ST, defs::VREF_COMP_FE, defs::VCOM_ADC1, defs::VREF_PRECH, defs::VREF_L_ADC, defs::VREF_CDS, defs::VB_CS, defs::VB_OPA_FD, defs::VCOM_ADC2}; case defs::MYTHEN3: return std::vector{ defs::VCASSH, defs::VTH2, defs::VRSHAPER, defs::VRSHAPER_N, defs::VIPRE_OUT, defs::VTH3, defs::VTH1, defs::VICIN, defs::VCAS, defs::VRPREAMP, defs::VCAL_N, defs::VIPRE, defs::VISHAPER, defs::VCAL_P, defs::VTRIM, defs::VDCSH, defs::VTHRESHOLD}; case defs::MOENCH: return std::vector{ defs::VBP_COLBUF, defs::VIPRE, defs::VIN_CM, defs::VB_SDA, defs::VCASC_SFP, defs::VOUT_CM, defs::VIPRE_CDS, defs::IBIAS_SFP}; case defs::CHIPTESTBOARD: for (int i = 0; i != 18; ++i) { retval.push_back(static_cast(i)); } break; default: throw RuntimeError("Unknown detector type"); } return retval; } void Detector::setDefaultDacs(Positions pos) { pimpl->Parallel(&Module::setDefaultDacs, pos); } Result Detector::getDAC(defs::dacIndex index, bool mV, Positions pos) const { return pimpl->Parallel(&Module::getDAC, pos, index, mV); } void Detector::setDAC(defs::dacIndex index, int value, bool mV, Positions pos) { pimpl->Parallel(&Module::setDAC, pos, value, index, mV); } Result Detector::getOnChipDAC(defs::dacIndex index, int chipIndex, Positions pos) const { return pimpl->Parallel(&Module::getOnChipDAC, pos, index, chipIndex); } void Detector::setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos) { 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); } Result Detector::getParallelMode(Positions pos) const { return pimpl->Parallel(&Module::getParallelMode, pos); } void Detector::setParallelMode(bool value, Positions pos) { pimpl->Parallel(&Module::setParallelMode, pos, value); } // Acquisition void Detector::acquire() { pimpl->acquire(); } void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); } void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); } void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); } void Detector::startDetector() { pimpl->Parallel(&Module::startAcquisition, {}); } void Detector::startDetectorReadout() { pimpl->Parallel(&Module::startReadout, {}); } void Detector::stopDetector() { pimpl->Parallel(&Module::stopAcquisition, {}); } Result Detector::getDetectorStatus(Positions pos) const { return pimpl->Parallel(&Module::getRunStatus, pos); } Result Detector::getReceiverStatus(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStatus, pos); } Result Detector::getFramesCaught(Positions pos) const { return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos); } Result> Detector::getNumMissingPackets(Positions pos) const { return pimpl->Parallel(&Module::getNumMissingPackets, pos); } Result Detector::getNextFrameNumber(Positions pos) const { return pimpl->Parallel(&Module::getNextFrameNumber, pos); } void Detector::setNextFrameNumber(uint64_t value, Positions pos) { pimpl->Parallel(&Module::setNextFrameNumber, pos, value); } void Detector::sendSoftwareTrigger(Positions pos) { pimpl->Parallel(&Module::sendSoftwareTrigger, pos); } Result Detector::getScan(Positions pos) const { return pimpl->Parallel(&Module::getScan, pos); } void Detector::setScan(const defs::scanParameters t) { pimpl->Parallel(&Module::setScan, {}, t); } Result Detector::getScanErrorMessage(Positions pos) const { return pimpl->Parallel(&Module::getScanErrorMessage, pos); } // Network Configuration (Detector<->Receiver) Result Detector::getNumberofUDPInterfaces(Positions pos) const { return pimpl->Parallel(&Module::getNumberofUDPInterfaces, pos); } void Detector::setNumberofUDPInterfaces(int n, Positions pos) { bool previouslyClientStreaming = pimpl->getDataStreamingToClient(); bool useReceiver = getUseReceiverFlag().squash(false); bool previouslyReceiverStreaming = false; if (useReceiver) { previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true); } pimpl->Parallel(&Module::setNumberofUDPInterfaces, pos, n); // ensure receiver zmq socket ports are multiplied by 2 (2 interfaces) if (getUseReceiverFlag().squash(false) && size()) { int startingPort = getRxZmqPort({0}).squash(0); setRxZmqPort(startingPort, -1); } // redo the zmq sockets if enabled if (previouslyClientStreaming) { pimpl->setDataStreamingToClient(false); pimpl->setDataStreamingToClient(true); } if (previouslyReceiverStreaming) { setRxZmqDataStream(false, pos); setRxZmqDataStream(true, pos); } } Result Detector::getSelectedUDPInterface(Positions pos) const { return pimpl->Parallel(&Module::getSelectedUDPInterface, pos); } void Detector::selectUDPInterface(int interface, Positions pos) { pimpl->Parallel(&Module::selectUDPInterface, pos, interface); } Result Detector::getSourceUDPIP(Positions pos) const { return pimpl->Parallel(&Module::getSourceUDPIP, pos); } void Detector::setSourceUDPIP(const IpAddr ip, Positions pos) { pimpl->Parallel(&Module::setSourceUDPIP, pos, ip); } Result Detector::getSourceUDPIP2(Positions pos) const { return pimpl->Parallel(&Module::getSourceUDPIP2, pos); } void Detector::setSourceUDPIP2(const IpAddr ip, Positions pos) { pimpl->Parallel(&Module::setSourceUDPIP2, pos, ip); } Result Detector::getSourceUDPMAC(Positions pos) const { return pimpl->Parallel(&Module::getSourceUDPMAC, pos); } void Detector::setSourceUDPMAC(const MacAddr mac, Positions pos) { pimpl->Parallel(&Module::setSourceUDPMAC, pos, mac); } Result Detector::getSourceUDPMAC2(Positions pos) const { return pimpl->Parallel(&Module::getSourceUDPMAC2, pos); } void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) { pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac); } Result Detector::getDestinationUDPIP(Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPIP, pos); } void Detector::setDestinationUDPIP(const IpAddr ip, Positions pos) { pimpl->Parallel(&Module::setDestinationUDPIP, pos, ip); } Result Detector::getDestinationUDPIP2(Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPIP2, pos); } void Detector::setDestinationUDPIP2(const IpAddr ip, Positions pos) { pimpl->Parallel(&Module::setDestinationUDPIP2, pos, ip); } Result Detector::getDestinationUDPMAC(Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPMAC, pos); } void Detector::setDestinationUDPMAC(const MacAddr mac, Positions pos) { pimpl->Parallel(&Module::setDestinationUDPMAC, pos, mac); } Result Detector::getDestinationUDPMAC2(Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPMAC2, pos); } void Detector::setDestinationUDPMAC2(const MacAddr mac, Positions pos) { pimpl->Parallel(&Module::setDestinationUDPMAC2, pos, mac); } Result Detector::getDestinationUDPPort(Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPPort, pos); } void Detector::setDestinationUDPPort(int port, int module_id) { if (module_id == -1) { std::vector port_list = getPortNumbers(port); for (int idet = 0; idet < size(); ++idet) { pimpl->Parallel(&Module::setDestinationUDPPort, {idet}, port_list[idet]); } } else { pimpl->Parallel(&Module::setDestinationUDPPort, {module_id}, port); } } Result Detector::getDestinationUDPPort2(Positions pos) const { return pimpl->Parallel(&Module::getDestinationUDPPort2, pos); } void Detector::setDestinationUDPPort2(int port, int module_id) { if (module_id == -1) { std::vector port_list = getPortNumbers(port); for (int idet = 0; idet < size(); ++idet) { pimpl->Parallel(&Module::setDestinationUDPPort2, {idet}, port_list[idet]); } } else { pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port); } } void Detector::reconfigureUDPDestination(Positions pos) { pimpl->Parallel(&Module::reconfigureUDPDestination, pos); } void Detector::validateUDPConfiguration(Positions pos) { pimpl->Parallel(&Module::validateUDPConfiguration, pos); } Result Detector::printRxConfiguration(Positions pos) const { return pimpl->Parallel(&Module::printReceiverConfiguration, pos); } Result Detector::getTenGiga(Positions pos) const { return pimpl->Parallel(&Module::getTenGiga, pos); } void Detector::setTenGiga(bool value, Positions pos) { pimpl->Parallel(&Module::setTenGiga, pos, value); } Result Detector::getTenGigaFlowControl(Positions pos) const { return pimpl->Parallel(&Module::getTenGigaFlowControl, pos); } void Detector::setTenGigaFlowControl(bool enable, Positions pos) { pimpl->Parallel(&Module::setTenGigaFlowControl, pos, enable); } Result Detector::getTransmissionDelayFrame(Positions pos) const { return pimpl->Parallel(&Module::getTransmissionDelayFrame, pos); } void Detector::setTransmissionDelayFrame(int value, Positions pos) { pimpl->Parallel(&Module::setTransmissionDelayFrame, pos, value); } Result Detector::getTransmissionDelayLeft(Positions pos) const { return pimpl->Parallel(&Module::getTransmissionDelayLeft, pos); } void Detector::setTransmissionDelayLeft(int value, Positions pos) { pimpl->Parallel(&Module::setTransmissionDelayLeft, pos, value); } Result Detector::getTransmissionDelayRight(Positions pos) const { return pimpl->Parallel(&Module::getTransmissionDelayRight, pos); } void Detector::setTransmissionDelayRight(int value, Positions pos) { pimpl->Parallel(&Module::setTransmissionDelayRight, pos, value); } // Receiver Result Detector::getUseReceiverFlag(Positions pos) const { return pimpl->Parallel(&Module::getUseReceiverFlag, pos); } Result Detector::getRxHostname(Positions pos) const { return pimpl->Parallel(&Module::getReceiverHostname, pos); } void Detector::setRxHostname(const std::string &receiver, Positions pos) { pimpl->Parallel(&Module::setReceiverHostname, pos, receiver); updateRxRateCorrections(); } void Detector::setRxHostname(const std::vector &name) { // set all to same rx_hostname if (name.size() == 1) { pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]); } else { if ((int)name.size() != size()) { throw RuntimeError( "Receiver hostnames size " + std::to_string(name.size()) + " does not match detector size " + std::to_string(size())); } // set each rx_hostname for (int idet = 0; idet < size(); ++idet) { pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]); } } updateRxRateCorrections(); } Result Detector::getRxPort(Positions pos) const { return pimpl->Parallel(&Module::getReceiverPort, pos); } void Detector::setRxPort(int port, int module_id) { if (module_id == -1) { std::vector port_list(size()); for (auto &it : port_list) { it = port++; } for (int idet = 0; idet < size(); ++idet) { pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]); } } else { pimpl->Parallel(&Module::setReceiverPort, {module_id}, port); } } Result Detector::getRxFifoDepth(Positions pos) const { return pimpl->Parallel(&Module::getReceiverFifoDepth, pos); } void Detector::setRxFifoDepth(int nframes, Positions pos) { pimpl->Parallel(&Module::setReceiverFifoDepth, pos, nframes); } Result Detector::getRxSilentMode(Positions pos) const { return pimpl->Parallel(&Module::getReceiverSilentMode, pos); } void Detector::setRxSilentMode(bool value, Positions pos) { pimpl->Parallel(&Module::setReceiverSilentMode, pos, value); } Result Detector::getRxFrameDiscardPolicy(Positions pos) const { return pimpl->Parallel(&Module::getReceiverFramesDiscardPolicy, pos); } void Detector::setRxFrameDiscardPolicy(defs::frameDiscardPolicy f, Positions pos) { pimpl->Parallel(&Module::setReceiverFramesDiscardPolicy, pos, f); } Result Detector::getPartialFramesPadding(Positions pos) const { return pimpl->Parallel(&Module::getPartialFramesPadding, pos); } void Detector::setPartialFramesPadding(bool value, Positions pos) { pimpl->Parallel(&Module::setPartialFramesPadding, pos, value); } Result Detector::getRxUDPSocketBufferSize(Positions pos) const { return pimpl->Parallel(&Module::getReceiverUDPSocketBufferSize, pos); } void Detector::setRxUDPSocketBufferSize(int udpsockbufsize, Positions pos) { pimpl->Parallel(&Module::setReceiverUDPSocketBufferSize, pos, udpsockbufsize); } Result Detector::getRxRealUDPSocketBufferSize(Positions pos) const { return pimpl->Parallel(&Module::getReceiverRealUDPSocketBufferSize, pos); } Result Detector::getRxLock(Positions pos) { return pimpl->Parallel(&Module::getReceiverLock, pos); } void Detector::setRxLock(bool value, Positions pos) { pimpl->Parallel(&Module::setReceiverLock, pos, value); } Result Detector::getRxLastClientIP(Positions pos) const { return pimpl->Parallel(&Module::getReceiverLastClientIP, pos); } Result> Detector::getRxThreadIds(Positions pos) const { return pimpl->Parallel(&Module::getReceiverThreadIds, pos); } // File Result Detector::getFileFormat(Positions pos) const { return pimpl->Parallel(&Module::getFileFormat, pos); } void Detector::setFileFormat(defs::fileFormat f, Positions pos) { pimpl->Parallel(&Module::setFileFormat, pos, f); } Result Detector::getFilePath(Positions pos) const { return pimpl->Parallel(&Module::getFilePath, pos); } void Detector::setFilePath(const std::string &fpath, Positions pos) { pimpl->Parallel(&Module::setFilePath, pos, fpath); } Result Detector::getFileNamePrefix(Positions pos) const { return pimpl->Parallel(&Module::getFileName, pos); } void Detector::setFileNamePrefix(const std::string &fname, Positions pos) { pimpl->Parallel(&Module::setFileName, pos, fname); } Result Detector::getAcquisitionIndex(Positions pos) const { return pimpl->Parallel(&Module::getFileIndex, pos); } void Detector::setAcquisitionIndex(int64_t i, Positions pos) { pimpl->Parallel(&Module::setFileIndex, pos, i); } Result Detector::getFileWrite(Positions pos) const { return pimpl->Parallel(&Module::getFileWrite, pos); } void Detector::setFileWrite(bool value, Positions pos) { pimpl->Parallel(&Module::setFileWrite, pos, value); } void Detector::setMasterFileWrite(bool value) { pimpl->Parallel(&Module::setMasterFileWrite, {0}, value); } bool Detector::getMasterFileWrite() const { return pimpl->Parallel(&Module::getMasterFileWrite, {0})[0]; } Result Detector::getFileOverWrite(Positions pos) const { return pimpl->Parallel(&Module::getFileOverWrite, pos); } void Detector::setFileOverWrite(bool value, Positions pos) { pimpl->Parallel(&Module::setFileOverWrite, pos, value); } Result Detector::getFramesPerFile(Positions pos) const { return pimpl->Parallel(&Module::getFramesPerFile, pos); } void Detector::setFramesPerFile(int n, Positions pos) { pimpl->Parallel(&Module::setFramesPerFile, pos, n); } // Zmq Streaming (Receiver<->Client) Result Detector::getRxZmqDataStream(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreaming, pos); } void Detector::setRxZmqDataStream(bool value, Positions pos) { pimpl->Parallel(&Module::setReceiverStreaming, pos, value); } Result Detector::getRxZmqFrequency(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreamingFrequency, pos); } void Detector::setRxZmqFrequency(int freq, Positions pos) { pimpl->Parallel(&Module::setReceiverStreamingFrequency, pos, freq); } Result Detector::getRxZmqTimer(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreamingTimer, pos); } void Detector::setRxZmqTimer(int time_in_ms, Positions pos) { pimpl->Parallel(&Module::setReceiverStreamingTimer, pos, time_in_ms); } Result Detector::getRxZmqStartingFrame(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreamingStartingFrame, pos); } void Detector::setRxZmqStartingFrame(int fnum, Positions pos) { pimpl->Parallel(&Module::setReceiverStreamingStartingFrame, pos, fnum); } Result Detector::getRxZmqPort(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreamingPort, pos); } void Detector::setRxZmqPort(int port, int module_id) { bool previouslyReceiverStreaming = getRxZmqDataStream(std::vector{module_id}).squash(false); if (module_id == -1) { std::vector port_list = getPortNumbers(port); for (int idet = 0; idet < size(); ++idet) { pimpl->Parallel(&Module::setReceiverStreamingPort, {idet}, port_list[idet]); } } else { pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port); } if (previouslyReceiverStreaming) { setRxZmqDataStream(false, std::vector{module_id}); setRxZmqDataStream(true, std::vector{module_id}); } } Result Detector::getRxZmqIP(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreamingIP, pos); } void Detector::setRxZmqIP(const IpAddr ip, Positions pos) { bool previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(false); pimpl->Parallel(&Module::setReceiverStreamingIP, pos, ip); if (previouslyReceiverStreaming) { setRxZmqDataStream(false, pos); setRxZmqDataStream(true, pos); } } Result Detector::getClientZmqPort(Positions pos) const { return pimpl->Parallel(&Module::getClientStreamingPort, pos); } void Detector::setClientZmqPort(int port, int module_id) { bool previouslyClientStreaming = pimpl->getDataStreamingToClient(); if (module_id == -1) { std::vector port_list = getPortNumbers(port); for (int idet = 0; idet < size(); ++idet) { pimpl->Parallel(&Module::setClientStreamingPort, {idet}, port_list[idet]); } } else { pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port); } if (previouslyClientStreaming) { pimpl->setDataStreamingToClient(false); pimpl->setDataStreamingToClient(true); } } Result Detector::getClientZmqIp(Positions pos) const { return pimpl->Parallel(&Module::getClientStreamingIP, pos); } void Detector::setClientZmqIp(const IpAddr ip, Positions pos) { bool previouslyClientStreaming = pimpl->getDataStreamingToClient(); pimpl->Parallel(&Module::setClientStreamingIP, pos, ip); if (previouslyClientStreaming) { pimpl->setDataStreamingToClient(false); pimpl->setDataStreamingToClient(true); } } int Detector::getClientZmqHwm() const { return pimpl->getClientStreamingHwm(); } void Detector::setClientZmqHwm(const int limit) { pimpl->setClientStreamingHwm(limit); } Result Detector::getRxZmqHwm(Positions pos) const { return pimpl->Parallel(&Module::getReceiverStreamingHwm, pos); } void Detector::setRxZmqHwm(const int limit) { bool previouslyReceiverStreaming = getRxZmqDataStream().squash(false); pimpl->Parallel(&Module::setReceiverStreamingHwm, {}, limit); if (previouslyReceiverStreaming) { setRxZmqDataStream(false, {}); setRxZmqDataStream(true, {}); } } // Eiger Specific Result Detector::getSubExptime(Positions pos) const { return pimpl->Parallel(&Module::getSubExptime, pos); } void Detector::setSubExptime(ns t, Positions pos) { pimpl->Parallel(&Module::setSubExptime, pos, t.count()); updateRxRateCorrections(); } Result Detector::getSubDeadTime(Positions pos) const { return pimpl->Parallel(&Module::getSubDeadTime, pos); } void Detector::setSubDeadTime(ns value, Positions pos) { pimpl->Parallel(&Module::setSubDeadTime, pos, value.count()); } Result Detector::getThresholdEnergy(Positions pos) const { return pimpl->Parallel(&Module::getThresholdEnergy, pos); } void Detector::setThresholdEnergy(int threshold_ev, defs::detectorSettings settings, bool trimbits, Positions pos) { pimpl->Parallel(&Module::setThresholdEnergy, pos, threshold_ev, settings, static_cast(trimbits)); } Result Detector::getSettingsPath(Positions pos) const { return pimpl->Parallel(&Module::getSettingsDir, pos); } void Detector::setSettingsPath(const std::string &value, Positions pos) { pimpl->Parallel(&Module::setSettingsDir, pos, value); } Result Detector::getOverFlowMode(Positions pos) const { return pimpl->Parallel(&Module::getOverFlowMode, pos); } void Detector::setOverFlowMode(bool value, Positions pos) { pimpl->Parallel(&Module::setOverFlowMode, pos, value); } Result Detector::getBottom(Positions pos) const { return pimpl->Parallel(&Module::getFlippedDataX, pos); } void Detector::setBottom(bool value, Positions pos) { pimpl->Parallel(&Module::setFlippedDataX, pos, value); } Result> Detector::getTrimEnergies(Positions pos) const { return pimpl->Parallel(&Module::getTrimEn, pos); } void Detector::setTrimEnergies(std::vector energies, Positions pos) { pimpl->Parallel(&Module::setTrimEn, pos, energies); } Result Detector::getRateCorrection(Positions pos) const { return pimpl->Parallel(&Module::getRateCorrection, pos); } void Detector::setDefaultRateCorrection(Positions pos) { pimpl->Parallel(&Module::setDefaultRateCorrection, pos); updateRxRateCorrections(); } void Detector::setRateCorrection(ns dead_time, Positions pos) { pimpl->Parallel(&Module::setRateCorrection, pos, dead_time.count()); updateRxRateCorrections(); } void Detector::updateRxRateCorrections() { // get tau from all modules and send to Rx index 0 if (getDetectorType().squash() == defs::EIGER) { if (getUseReceiverFlag().squash(false)) { std::vector dead_times; for (auto item : getRateCorrection()) dead_times.push_back(item.count()); pimpl->Parallel(&Module::sendReceiverRateCorrections, {0}, dead_times); } } } Result Detector::getPartialReadout(Positions pos) const { return pimpl->Parallel(&Module::getReadNLines, pos); } void Detector::setPartialReadout(const int lines, Positions pos) { pimpl->Parallel(&Module::setReadNLines, pos, lines); } Result Detector::getInterruptSubframe(Positions pos) const { return pimpl->Parallel(&Module::getInterruptSubframe, pos); } void Detector::setInterruptSubframe(const bool enable, Positions pos) { pimpl->Parallel(&Module::setInterruptSubframe, pos, enable); } Result Detector::getMeasuredPeriod(Positions pos) const { return pimpl->Parallel(&Module::getMeasuredPeriod, pos); } Result Detector::getMeasuredSubFramePeriod(Positions pos) const { return pimpl->Parallel(&Module::getMeasuredSubFramePeriod, pos); } Result Detector::getActive(Positions pos) const { return pimpl->Parallel(&Module::getActivate, pos); } void Detector::setActive(const bool active, Positions pos) { pimpl->Parallel(&Module::setActivate, pos, active); } Result Detector::getRxPadDeactivatedMode(Positions pos) const { return pimpl->Parallel(&Module::getDeactivatedRxrPaddingMode, pos); } void Detector::setRxPadDeactivatedMode(bool pad, Positions pos) { pimpl->Parallel(&Module::setDeactivatedRxrPaddingMode, pos, pad); } Result Detector::getPartialReset(Positions pos) const { return pimpl->Parallel(&Module::getCounterBit, pos); } void Detector::setPartialReset(bool value, Positions pos) { pimpl->Parallel(&Module::setCounterBit, pos, value); } void Detector::pulsePixel(int n, defs::xy pixel, Positions pos) { pimpl->Parallel(&Module::pulsePixel, pos, n, pixel.x, pixel.y); } void Detector::pulsePixelNMove(int n, defs::xy pixel, Positions pos) { pimpl->Parallel(&Module::pulsePixelNMove, pos, n, pixel.x, pixel.y); } void Detector::pulseChip(int n, Positions pos) { pimpl->Parallel(&Module::pulseChip, pos, n); } Result Detector::getQuad(Positions pos) const { return pimpl->Parallel(&Module::getQuad, pos); } void Detector::setQuad(const bool enable) { if (enable && size() > 1) { throw RuntimeError("Cannot set Quad type as it is available only for 1 " "Eiger Quad Half module."); } pimpl->Parallel(&Module::setQuad, {}, enable); } // Jungfrau Specific Result Detector::getThresholdTemperature(Positions pos) const { return pimpl->Parallel(&Module::getThresholdTemperature, pos); } void Detector::setThresholdTemperature(int temp, Positions pos) { pimpl->Parallel(&Module::setThresholdTemperature, pos, temp); } Result Detector::getTemperatureControl(Positions pos) const { return pimpl->Parallel(&Module::getTemperatureControl, pos); } void Detector::setTemperatureControl(bool enable, Positions pos) { pimpl->Parallel(&Module::setTemperatureControl, pos, enable); } Result Detector::getTemperatureEvent(Positions pos) const { return pimpl->Parallel(&Module::getTemperatureEvent, pos); } void Detector::resetTemperatureEvent(Positions pos) { pimpl->Parallel(&Module::resetTemperatureEvent, pos); } Result Detector::getAutoCompDisable(Positions pos) const { return pimpl->Parallel(&Module::getAutoComparatorDisableMode, pos); } void Detector::setAutoCompDisable(bool value, Positions pos) { pimpl->Parallel(&Module::setAutoComparatorDisableMode, pos, value); } Result Detector::getNumberOfAdditionalStorageCells(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfAdditionalStorageCells, pos); } void Detector::setNumberOfAdditionalStorageCells(int value) { pimpl->Parallel(&Module::setNumberOfAdditionalStorageCells, {}, value); } Result Detector::getStorageCellStart(Positions pos) const { return pimpl->Parallel(&Module::getStorageCellStart, pos); } void Detector::setStorageCellStart(int cell, Positions pos) { pimpl->Parallel(&Module::setStorageCellStart, pos, cell); } Result Detector::getStorageCellDelay(Positions pos) const { return pimpl->Parallel(&Module::getStorageCellDelay, pos); } void Detector::setStorageCellDelay(ns value, Positions pos) { pimpl->Parallel(&Module::setStorageCellDelay, pos, value.count()); } // Gotthard Specific Result Detector::getROI(Positions pos) const { return pimpl->Parallel(&Module::getROI, pos); } void Detector::setROI(defs::ROI value, int module_id) { if (module_id < 0 && size() > 1) { throw RuntimeError("Cannot set ROI for all modules simultaneously"); } pimpl->Parallel(&Module::setROI, {module_id}, value); } void Detector::clearROI(Positions pos) { pimpl->Parallel(&Module::clearROI, pos); } Result Detector::getExptimeLeft(Positions pos) const { return pimpl->Parallel(&Module::getExptimeLeft, pos); } // Gotthard2 Specific Result Detector::getNumberOfBursts(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfBursts, pos); } void Detector::setNumberOfBursts(int64_t value) { pimpl->Parallel(&Module::setNumberOfBursts, {}, value); } Result Detector::getBurstPeriod(Positions pos) const { return pimpl->Parallel(&Module::getBurstPeriod, pos); } void Detector::setBurstPeriod(ns value, Positions pos) { pimpl->Parallel(&Module::setBurstPeriod, pos, value.count()); } Result Detector::getNumberOfBurstsLeft(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfBurstsLeft, pos); } Result> Detector::getInjectChannel(Positions pos) { return pimpl->Parallel(&Module::getInjectChannel, pos); } void Detector::setInjectChannel(const int offsetChannel, const int incrementChannel, Positions pos) { pimpl->Parallel(&Module::setInjectChannel, pos, offsetChannel, incrementChannel); } void Detector::getVetoPhoton(const int chipIndex, const std::string &fname, Positions pos) { pimpl->Parallel(&Module::getVetoPhoton, pos, chipIndex, fname); } void Detector::setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string &fname, Positions pos) { pimpl->Parallel(&Module::setVetoPhoton, pos, chipIndex, numPhotons, energy, fname); } void Detector::setVetoReference(const int gainIndex, const int value, Positions pos) { pimpl->Parallel(&Module::setVetoReference, pos, gainIndex, value); } void Detector::setVetoFile(const int chipIndex, const std::string &fname, Positions pos) { pimpl->Parallel(&Module::setVetoFile, pos, chipIndex, fname); } Result Detector::getBurstMode(Positions pos) { return pimpl->Parallel(&Module::getBurstMode, pos); } void Detector::setBurstMode(defs::burstMode value, Positions pos) { pimpl->Parallel(&Module::setBurstMode, pos, value); } Result Detector::getCDSGain(Positions pos) const { return pimpl->Parallel(&Module::getCDSGain, pos); } void Detector::setCDSGain(bool value, Positions pos) { pimpl->Parallel(&Module::setCDSGain, pos, value); } Result Detector::getFilter(Positions pos) const { return pimpl->Parallel(&Module::getFilter, pos); } void Detector::setFilter(int value, Positions pos) { pimpl->Parallel(&Module::setFilter, pos, value); } Result Detector::getCurrentSource(Positions pos) const { return pimpl->Parallel(&Module::getCurrentSource, pos); } void Detector::setCurrentSource(bool value, Positions pos) { pimpl->Parallel(&Module::setCurrentSource, pos, value); } Result Detector::getTimingSource(Positions pos) const { return pimpl->Parallel(&Module::getTimingSource, pos); } void Detector::setTimingSource(defs::timingSourceType value, Positions pos) { pimpl->Parallel(&Module::setTimingSource, pos, value); } Result Detector::getVeto(Positions pos) const { return pimpl->Parallel(&Module::getVeto, pos); } void Detector::setVeto(bool enable, Positions pos) { pimpl->Parallel(&Module::setVeto, pos, enable); } Result Detector::getADCConfiguration(const int chipIndex, const int adcIndex, Positions pos) const { return pimpl->Parallel(&Module::getADCConfiguration, pos, chipIndex, adcIndex); } void Detector::setADCConfiguration(const int chipIndex, const int adcIndex, const int value, Positions pos) { pimpl->Parallel(&Module::setADCConfiguration, pos, chipIndex, adcIndex, value); } void Detector::getBadChannels(const std::string &fname, Positions pos) const { pimpl->Parallel(&Module::getBadChannels, pos, fname); } void Detector::setBadChannels(const std::string &fname, Positions pos) { pimpl->Parallel(&Module::setBadChannels, pos, fname); } // Mythen3 Specific Result Detector::getCounterMask(Positions pos) const { return pimpl->Parallel(&Module::getCounterMask, pos); } void Detector::setCounterMask(uint32_t countermask, Positions pos) { pimpl->Parallel(&Module::setCounterMask, pos, countermask); } Result Detector::getNumberOfGates(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfGates, pos); } void Detector::setNumberOfGates(int value, Positions pos) { pimpl->Parallel(&Module::setNumberOfGates, pos, value); } Result Detector::getExptime(int gateIndex, Positions pos) const { return pimpl->Parallel(&Module::getExptime, pos, gateIndex); } void Detector::setExptime(int gateIndex, ns t, Positions pos) { pimpl->Parallel(&Module::setExptime, pos, gateIndex, t.count()); } Result> Detector::getExptimeForAllGates(Positions pos) const { return pimpl->Parallel(&Module::getExptimeForAllGates, pos); } Result Detector::getGateDelay(int gateIndex, Positions pos) const { return pimpl->Parallel(&Module::getGateDelay, pos, gateIndex); } void Detector::setGateDelay(int gateIndex, ns t, Positions pos) { pimpl->Parallel(&Module::setGateDelay, pos, gateIndex, t.count()); } Result> Detector::getGateDelayForAllGates(Positions pos) const { return pimpl->Parallel(&Module::getGateDelayForAllGates, pos); } // CTB/ Moench Specific Result Detector::getNumberOfAnalogSamples(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfAnalogSamples, pos); } void Detector::setNumberOfAnalogSamples(int value, Positions pos) { pimpl->Parallel(&Module::setNumberOfAnalogSamples, pos, value); } Result Detector::getADCClock(Positions pos) const { return pimpl->Parallel(&Module::getClockFrequency, pos, defs::ADC_CLOCK); } void Detector::setADCClock(int value_in_MHz, Positions pos) { pimpl->Parallel(&Module::setClockFrequency, pos, defs::ADC_CLOCK, value_in_MHz); } Result Detector::getRUNClock(Positions pos) const { return pimpl->Parallel(&Module::getClockFrequency, pos, defs::RUN_CLOCK); } void Detector::setRUNClock(int value_in_MHz, Positions pos) { pimpl->Parallel(&Module::setClockFrequency, pos, defs::RUN_CLOCK, value_in_MHz); } Result Detector::getSYNCClock(Positions pos) const { return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK); } Result Detector::getADCPipeline(Positions pos) const { return pimpl->Parallel(&Module::getPipeline, pos, defs::ADC_CLOCK); } void Detector::setADCPipeline(int value, Positions pos) { pimpl->Parallel(&Module::setPipeline, pos, defs::ADC_CLOCK, value); } Result Detector::getDBITPipeline(Positions pos) const { return pimpl->Parallel(&Module::getPipeline, pos, defs::DBIT_CLOCK); } Result Detector::getVoltage(defs::dacIndex index, Positions pos) const { switch (index) { case defs::V_LIMIT: case defs::V_POWER_A: case defs::V_POWER_B: case defs::V_POWER_C: case defs::V_POWER_D: case defs::V_POWER_IO: case defs::V_POWER_CHIP: break; default: throw RuntimeError("Unknown Voltage Index"); } return pimpl->Parallel(&Module::getDAC, pos, index, true); } void Detector::setVoltage(defs::dacIndex index, int value, Positions pos) { switch (index) { case defs::V_LIMIT: case defs::V_POWER_A: case defs::V_POWER_B: case defs::V_POWER_C: case defs::V_POWER_D: case defs::V_POWER_IO: case defs::V_POWER_CHIP: break; default: throw RuntimeError("Unknown Voltage Index"); } pimpl->Parallel(&Module::setDAC, pos, value, index, true); } Result Detector::getADCEnableMask(Positions pos) const { return pimpl->Parallel(&Module::getADCEnableMask, pos); } void Detector::setADCEnableMask(uint32_t mask, Positions pos) { pimpl->Parallel(&Module::setADCEnableMask, pos, mask); } Result Detector::getTenGigaADCEnableMask(Positions pos) const { return pimpl->Parallel(&Module::getTenGigaADCEnableMask, pos); } void Detector::setTenGigaADCEnableMask(uint32_t mask, Positions pos) { pimpl->Parallel(&Module::setTenGigaADCEnableMask, pos, mask); } // CTB Specific Result Detector::getNumberOfDigitalSamples(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfDigitalSamples, pos); } void Detector::setNumberOfDigitalSamples(int value, Positions pos) { pimpl->Parallel(&Module::setNumberOfDigitalSamples, pos, value); } Result Detector::getReadoutMode(Positions pos) const { return pimpl->Parallel(&Module::getReadoutMode, pos); } /** Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL \n * Default: ANALOG_ONLY */ void Detector::setReadoutMode(defs::readoutMode value, Positions pos) { pimpl->Parallel(&Module::setReadoutMode, pos, value); } Result Detector::getDBITClock(Positions pos) const { return pimpl->Parallel(&Module::getClockFrequency, pos, defs::DBIT_CLOCK); } void Detector::setDBITClock(int value_in_MHz, Positions pos) { pimpl->Parallel(&Module::setClockFrequency, pos, defs::DBIT_CLOCK, value_in_MHz); } void Detector::setDBITPipeline(int value, Positions pos) { pimpl->Parallel(&Module::setPipeline, pos, defs::DBIT_CLOCK, value); } Result Detector::getMeasuredVoltage(defs::dacIndex index, Positions pos) const { switch (index) { case defs::V_POWER_A: case defs::V_POWER_B: case defs::V_POWER_C: case defs::V_POWER_D: case defs::V_POWER_IO: case defs::V_POWER_CHIP: break; default: throw RuntimeError("Unknown Voltage Index"); } return pimpl->Parallel(&Module::getADC, pos, index); } Result Detector::getMeasuredCurrent(defs::dacIndex index, Positions pos) const { switch (index) { case defs::I_POWER_A: case defs::I_POWER_B: case defs::I_POWER_C: case defs::I_POWER_D: case defs::I_POWER_IO: break; default: throw RuntimeError("Unknown Current Index"); } return pimpl->Parallel(&Module::getADC, pos, index); } Result Detector::getSlowADC(defs::dacIndex index, Positions pos) const { if (index < defs::SLOW_ADC0 || index > defs::SLOW_ADC7) { throw RuntimeError("Unknown Slow ADC Index"); } return pimpl->Parallel(&Module::getADC, pos, index); } Result Detector::getExternalSamplingSource(Positions pos) const { return pimpl->Parallel(&Module::getExternalSamplingSource, pos); } void Detector::setExternalSamplingSource(int value, Positions pos) { pimpl->Parallel(&Module::setExternalSamplingSource, pos, value); } Result Detector::getExternalSampling(Positions pos) const { return pimpl->Parallel(&Module::getExternalSampling, pos); } void Detector::setExternalSampling(bool value, Positions pos) { pimpl->Parallel(&Module::setExternalSampling, pos, value); } Result> Detector::getRxDbitList(Positions pos) const { return pimpl->Parallel(&Module::getReceiverDbitList, pos); } void Detector::setRxDbitList(const std::vector &list, Positions pos) { pimpl->Parallel(&Module::setReceiverDbitList, pos, list); } Result Detector::getRxDbitOffset(Positions pos) const { return pimpl->Parallel(&Module::getReceiverDbitOffset, pos); } void Detector::setRxDbitOffset(int value, Positions pos) { pimpl->Parallel(&Module::setReceiverDbitOffset, pos, value); } void Detector::setDigitalIODelay(uint64_t pinMask, int delay, Positions pos) { pimpl->Parallel(&Module::setDigitalIODelay, pos, pinMask, delay); } Result Detector::getLEDEnable(Positions pos) const { return pimpl->Parallel(&Module::getLEDEnable, pos); } void Detector::setLEDEnable(bool enable, Positions pos) { pimpl->Parallel(&Module::setLEDEnable, pos, enable); } // Pattern void Detector::savePattern(const std::string &fname) { auto t = pimpl->Parallel(&Module::getPattern, {}); // auto pat = t.tsquash("Inconsistent pattern parameters between modules"); auto pat = std::move(t[0]); // pat->save(fname); } // namespace sls void Detector::setPattern(const std::string &fname, Positions pos) { auto pat = sls::make_unique(); pat->load(fname); pimpl->Parallel(&Module::setPattern, pos, pat.get()); } void Detector::setPattern(const defs::patternParameters *pat, Positions pos) { pimpl->Parallel(&Module::setPattern, pos, pat); } Result Detector::getPatternIOControl(Positions pos) const { return pimpl->Parallel(&Module::getPatternIOControl, pos); } void Detector::setPatternIOControl(uint64_t word, Positions pos) { pimpl->Parallel(&Module::setPatternIOControl, pos, word); } Result Detector::getPatternWord(int addr, Positions pos) { return pimpl->Parallel(&Module::getPatternWord, pos, addr); } void Detector::setPatternWord(int addr, uint64_t word, Positions pos) { pimpl->Parallel(&Module::setPatternWord, pos, addr, word); } Result> Detector::getPatternLoopAddresses(int level, Positions pos) const { return pimpl->Parallel(&Module::getPatternLoopAddresses, pos, level); } void Detector::setPatternLoopAddresses(int level, int start, int stop, Positions pos) { pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, start, stop); } Result Detector::getPatternLoopCycles(int level, Positions pos) const { return pimpl->Parallel(&Module::getPatternLoopCycles, pos, level); } void Detector::setPatternLoopCycles(int level, int n, Positions pos) { pimpl->Parallel(&Module::setPatternLoopCycles, pos, level, n); } Result Detector::getPatternWaitAddr(int level, Positions pos) const { return pimpl->Parallel(&Module::getPatternWaitAddr, pos, level); } void Detector::setPatternWaitAddr(int level, int addr, Positions pos) { pimpl->Parallel(&Module::setPatternWaitAddr, pos, level, addr); } Result Detector::getPatternWaitTime(int level, Positions pos) const { return pimpl->Parallel(&Module::getPatternWaitTime, pos, level); } void Detector::setPatternWaitTime(int level, uint64_t t, Positions pos) { pimpl->Parallel(&Module::setPatternWaitTime, pos, level, t); } Result Detector::getPatternMask(Positions pos) { return pimpl->Parallel(&Module::getPatternMask, pos); } void Detector::setPatternMask(uint64_t mask, Positions pos) { pimpl->Parallel(&Module::setPatternMask, pos, mask); } Result Detector::getPatternBitMask(Positions pos) const { return pimpl->Parallel(&Module::getPatternBitMask, pos); } void Detector::setPatternBitMask(uint64_t mask, Positions pos) { pimpl->Parallel(&Module::setPatternBitMask, pos, mask); } void Detector::startPattern(Positions pos) { pimpl->Parallel(&Module::startPattern, pos); } // Moench Result> Detector::getAdditionalJsonHeader(Positions pos) const { return pimpl->Parallel(&Module::getAdditionalJsonHeader, pos); } void Detector::setAdditionalJsonHeader( const std::map &jsonHeader, Positions pos) { pimpl->Parallel(&Module::setAdditionalJsonHeader, pos, jsonHeader); } Result Detector::getAdditionalJsonParameter(const std::string &key, Positions pos) const { return pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, key); } void Detector::setAdditionalJsonParameter(const std::string &key, const std::string &value, Positions pos) { pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, key, value); } // Advanced void Detector::programFPGA(const std::string &fname, Positions pos) { std::vector buffer = pimpl->readProgrammingFile(fname); pimpl->Parallel(&Module::programFPGA, pos, buffer); } void Detector::resetFPGA(Positions pos) { pimpl->Parallel(&Module::resetFPGA, pos); } void Detector::copyDetectorServer(const std::string &fname, const std::string &hostname, Positions pos) { pimpl->Parallel(&Module::copyDetectorServer, pos, fname, hostname); rebootController(pos); } void Detector::rebootController(Positions pos) { pimpl->Parallel(&Module::rebootController, pos); } void Detector::updateFirmwareAndServer(const std::string &sname, const std::string &hostname, const std::string &fname, Positions pos) { pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname); programFPGA(fname, pos); rebootController(pos); } Result Detector::readRegister(uint32_t addr, Positions pos) const { return pimpl->Parallel(&Module::readRegister, pos, addr); } void Detector::writeRegister(uint32_t addr, uint32_t val, Positions pos) { pimpl->Parallel(&Module::writeRegister, pos, addr, val); } void Detector::setBit(uint32_t addr, int bitnr, Positions pos) { pimpl->Parallel(&Module::setBit, pos, addr, bitnr); } void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) { pimpl->Parallel(&Module::clearBit, pos, addr, bitnr); } Result Detector::getBit(uint32_t addr, int bitnr, Positions pos) { return pimpl->Parallel(&Module::getBit, pos, addr, bitnr); } void Detector::executeFirmwareTest(Positions pos) { pimpl->Parallel(&Module::executeFirmwareTest, pos); } void Detector::executeBusTest(Positions pos) { pimpl->Parallel(&Module::executeBusTest, pos); } void Detector::writeAdcRegister(uint32_t addr, uint32_t value, Positions pos) { pimpl->Parallel(&Module::writeAdcRegister, pos, addr, value); } bool Detector::getInitialChecks() const { return pimpl->getInitialChecks(); } void Detector::setInitialChecks(const bool value) { pimpl->setInitialChecks(value); } Result Detector::getADCInvert(Positions pos) const { return pimpl->Parallel(&Module::getADCInvert, pos); } void Detector::setADCInvert(uint32_t value, Positions pos) { pimpl->Parallel(&Module::setADCInvert, pos, value); } // Insignificant Result Detector::getControlPort(Positions pos) const { return pimpl->Parallel(&Module::getControlPort, pos); } void Detector::setControlPort(int value, Positions pos) { pimpl->Parallel(&Module::setControlPort, pos, value); } Result Detector::getStopPort(Positions pos) const { return pimpl->Parallel(&Module::getStopPort, pos); } void Detector::setStopPort(int value, Positions pos) { pimpl->Parallel(&Module::setStopPort, pos, value); } Result Detector::getDetectorLock(Positions pos) const { return pimpl->Parallel(&Module::getLockDetector, pos); } void Detector::setDetectorLock(bool lock, Positions pos) { pimpl->Parallel(&Module::setLockDetector, pos, lock); } Result Detector::getLastClientIP(Positions pos) const { return pimpl->Parallel(&Module::getLastClientIP, pos); } Result Detector::executeCommand(const std::string &value, Positions pos) { return pimpl->Parallel(&Module::execCommand, pos, value); } Result Detector::getNumberOfFramesFromStart(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfFramesFromStart, pos); } Result Detector::getActualTime(Positions pos) const { return pimpl->Parallel(&Module::getActualTime, pos); } Result Detector::getMeasurementTime(Positions pos) const { return pimpl->Parallel(&Module::getMeasurementTime, pos); } std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); } Result Detector::getRxCurrentFrameIndex(Positions pos) const { return pimpl->Parallel(&Module::getReceiverCurrentFrameIndex, pos); } std::vector Detector::getPortNumbers(int start_port) { int num_sockets_per_detector = 1; switch (getDetectorType().squash()) { case defs::EIGER: num_sockets_per_detector *= 2; break; case defs::JUNGFRAU: if (getNumberofUDPInterfaces().squash() == 2) { num_sockets_per_detector *= 2; } break; default: break; } std::vector res; res.reserve(size()); for (int idet = 0; idet < size(); ++idet) { res.push_back(start_port + (idet * num_sockets_per_detector)); } return res; } } // namespace sls