From 947252c852b826ecd5071091be90d6af78fe3625 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 16 Aug 2019 09:45:49 +0200 Subject: [PATCH] WIP --- slsDetectorGui/src/qDrawPlot.cpp | 5 +- .../slsDetectorServer_funcs.c | 5 - slsDetectorSoftware/include/Detector.h | 1495 +++++++++-------- .../include/multiSlsDetector.h | 86 +- slsDetectorSoftware/include/slsDetector.h | 82 +- slsDetectorSoftware/src/Detector.cpp | 148 +- slsDetectorSoftware/src/multiSlsDetector.cpp | 154 +- slsDetectorSoftware/src/slsDetector.cpp | 127 +- .../src/slsDetectorCommand.cpp | 21 +- slsDetectorSoftware/src/slsDetectorUsers.cpp | 10 +- slsSupportLib/include/sls_detector_defs.h | 2 +- 11 files changed, 934 insertions(+), 1201 deletions(-) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index b242c8711..61972327c 100755 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -80,8 +80,9 @@ void qDrawPlot::SetupPlots() { setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); // default image size - nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); - nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); + slsDetectorDefs::xy res = myDet->getNumberOfChannels(); + nPixelsX = res.x; + nPixelsY = res.y; switch(detType) { case slsDetectorDefs::MOENCH: npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, -1) * 2)/25;// for moench 03 diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 542af9d48..16aacb94e 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -2181,11 +2181,6 @@ int send_update(int file_des) { n = sendData(file_des,&i32,sizeof(i32),INT32); if (n < 0) return printSocketReadError(); - // databytes - i32 = calculateDataBytes(); - n = sendData(file_des,&i32,sizeof(i32),INT32); - if (n < 0) return printSocketReadError(); - // settings #if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD) i32 = (int)getSettings(); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 167a114a5..0972d85a6 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -19,14 +19,17 @@ class Detector { public: /** - * @param multi_id multi detector shared memory id + * @param shm_id detector shared memory id + * Default value is 0. Can be set to more values for + * multiple detectors.It is important only if you + * are controlling multiple detectors from the same pc. */ - Detector(int multi_id = 0); + Detector(int shm_id = 0); ~Detector(); /************************************************** * * - * CONFIGURATIOn * + * CONFIGURATION * * * * ************************************************/ @@ -34,176 +37,66 @@ class Detector { * belonging to it.*/ void freeSharedMemory(); - void setConfig(const std::string &fname); + void loadConfig(const std::string &fname); Result getHostname(Positions pos = {}) const; /* Frees shared memory, adds detectors to the list * and updates local detector cache */ - void setHostname(const std::vector &value); + void setHostname(const std::vector &hostname); - int getMultiId() const; + /** Gets shared memory ID */ + int getShmId() const; - void checkDetectorVersionCompatibility(Positions pos = {}) const; - - void checkReceiverVersionCompatibility(Positions pos = {}) const; - - Result getDetectorFirmwareVersion(Positions pos = {}) const; + Result getFirmwareVersion(Positions pos = {}) const; Result getDetectorServerVersion(Positions pos = {}) const; - Result getDetectorSerialNumber(Positions pos = {}) const; + Result getSerialNumber(Positions pos = {}) const; - int64_t getClientSoftwareVersion() const; + int64_t getClientVersion() const; - Result getReceiverSoftwareVersion(Positions pos = {}) const; - - std::string getUserDetailsFromSharedMemory() const; + Result getReceiverVersion(Positions pos = {}) const; Result getDetectorType(Positions pos = {}) const; - Result getDetectorTypeAsString(Positions pos = {}) const; - - /** @returns the total number of detectors */ + /** Gets the total number of detectors */ int size() const; - defs::coordinates getNumberOfDetectors() const; + defs::xy getModuleGeometry() const; - Result getNumberOfChannels(Positions pos = {}) const; + Result getModuleSize(Positions pos = {}) const; - Result - getNumberOfChannelsInclGapPixels(Positions pos = {}) const; - - defs::coordinates getMaxNumberOfChannels() const; + /** Gets the actual full detector size. It is the same even if ROI changes */ + defs::xy getDetectorSize() const; /** - * Sets the maximum number of channels of complete detector in both - * dimensions. -1 means no limit in this dimension. This value is used to - * calculate row and column channels for each module. + * Sets the detector size in both dimensions. + * This value is used to calculate row and column positions for each module. */ - void setMaxNumberOfChannels(const defs::coordinates value); + void setDetectorSize(const defs::xy value); - /** [Eiger] with specific quad hardware */ - Result getQuad(Positions pos = {}) const; - - /** [Eiger] with specific quad hardware */ - void setQuad(const bool enable, Positions pos = {}); - - /** [Eiger] */ - Result getReadNLines(Positions pos = {}) const; - - /** [Eiger] Number of lines to read out per half module - * Options: 0 - 256. Depending on dynamic range and - * 10 GbE enabled, only specific values are accepted - */ - void setReadNLines(const int value, Positions pos = {}); - - Result getControlPort(Positions pos = {}) const; - - /** Detector Control TCP port (for client communication with Detector - * control server) */ - void setControlPort(int value, Positions pos = {}); - - Result getStopPort(Positions pos = {}) const; - - /** Detector Stop TCP port (for client communication with Detector Stop - * server) */ - void setStopPort(int value, Positions pos = {}); - - Result getLockServer(Positions pos = {}) const; - - /** Lock for detector control server to this client IP */ - void setLockServer(bool value, Positions pos = {}); - - /** Get last client IP saved on detector server */ - Result getLastClientIP(Positions pos = {}) const; - - void exitServer(Positions pos = {}); - - /** Execute a command on the detector server */ - void execCommand(const std::string &value, Positions pos = {}); - - void writeConfigurationFile(const std::string &value); - - /** [Not CTB] */ + /** [Jungfrau][Gotthard] */ Result getSettings(Positions pos = {}) const; - /** - * [Not CTB] - * Load detector settings from the settings file picked from the - * trimdir/settingsdir - * Eiger only stores in shared memory ( a get will - * overwrite this) For Eiger, one must use setThresholdEnergy - */ + /** [Jungfrau][Gotthard] */ void setSettings(defs::detectorSettings value, Positions pos = {}); - /** [Eiger] */ - Result getThresholdEnergy(Positions pos = {}) const; - /** - * [Eiger] - * Set threshold energy - * @param value threshold in eV - * @param sett ev. change settings - * @param tb 1 to include trimbits, 0 to exclude - */ - void setThresholdEnergy(int value, - defs::detectorSettings sett = defs::GET_SETTINGS, - int tb = 1, Positions pos = {}); - Result getSettingsDir(Positions pos = {}) const; - - /** [Not CTB] Sets the detector trimbit/settings directory */ - void setSettingsDir(const std::string &value, Positions pos = {}); - - /** [Not CTB] Loads the modules settings/trimbits reading from a specific - * file - * file name extension is automatically generated from detector serial - * number */ - void loadSettingsFile(const std::string &value, Positions pos = {}); - - /** [Not CTB] Saves the modules settings/trimbits to a specific file - * file name extension is automatically generated from detector serial - * number */ - void saveSettingsFile(const std::string &value, Positions pos = {}); - - /** Configures in detector the destination for UDP packets */ - void configureMAC(Positions pos = {}); + /************************************************** + * * + * Acquisition Parameters * + * * + * ************************************************/ Result getNumberOfFrames() const; void setNumberOfFrames(int64_t value); - Result getNumberOfCycles() const; + Result getNumberOfTriggers() const; - void setNumberOfCycles(int64_t value); - - /** [Jungfrau] */ - Result getNumberOfAdditionalStorageCells() const; - - /** [Jungfrau] */ - void setNumberOfStorageCells(int64_t value); - - /** [Jungfrau] */ - Result getStorageCellStart(Positions pos = {}) const; - - /** - * [Jungfrau] Sets the storage cell storing the first acquisition of the - * series Options: 0-15 - */ - void setStoragecellStart(int cell, Positions pos = {}); - - /** [CTB] */ - Result getNumberOfAnalogSamples(Positions pos = {}) const; - - /** [CTB] */ - void setNumberOfAnalogSamples(int64_t value, Positions pos = {}); - - /** [CTB] */ - Result getNumberOfDigitalSamples(Positions pos = {}) const; - - /** [CTB] */ - void setNumberOfDigitalSamples(int64_t value, Positions pos = {}); + void setNumberOfTriggers(int64_t value); Result getExptime(Positions pos = {}) const; @@ -219,60 +112,20 @@ class Detector { /** [Gotthard][Jungfrau] */ void setDelayAfterTrigger(ns value, Positions pos = {}); - /** [Eiger] in 32 bit mode */ - Result getSubExptime(Positions pos = {}) const; - - /** [Eiger] in 32 bit mode */ - void setSubExptime(ns t, Positions pos = {}); - - /** [Eiger] in 32 bit mode */ - Result getSubDeadTime(Positions pos = {}) const; - - /** [Eiger] in 32 bit mode */ - void setSubDeadTime(ns value, Positions pos = {}); - - /** [Jungfrau] */ - Result getStorageCellDelay(Positions pos = {}) const; - - /** [Jungfrau] - * Options: (0-1638375 ns (resolution of 25ns) */ - void setStorageCellDelay(ns value, Positions pos = {}); - /** [Gotthard][Jungfrau][CTB] */ Result getNumberOfFramesLeft(Positions pos = {}) const; /** [Gotthard][Jungfrau][CTB] */ Result getNumberOfCyclesLeft(Positions pos = {}) const; - /** [Gotthard] */ - Result getExptimeLeft(Positions pos = {}) const; - - /** [Gotthard] */ - Result getPeriodLeft(Positions pos = {}) const; - /** [Gotthard][Jungfrau][CTB] */ Result getDelayAfterTriggerLeft(Positions pos = {}) const; - /** [Gotthard][Jungfrau][CTB] */ - Result getNumberOfFramesFromStart(Positions pos = {}) const; - - /** [Jungfrau][CTB] Get time from detector start */ - Result getActualTime(Positions pos = {}) const; - - /** [Jungfrau][CTB] Get timestamp at a frame start */ - Result getMeasurementTime(Positions pos = {}) const; - - /** [Eiger] Get measured period between previous two frames */ - Result getMeasuredPeriod(Positions pos = {}) const; - - /** [Eiger] Get measured sub frame period between previous two frames */ - Result getMeasuredSubFramePeriod(Positions pos = {}) const; - /** [Eiger][Jungfrau] */ Result getSpeed(Positions pos = {}) const; - /** [Eiger][Jungfrau] - * @param value speed (0 full speed, 1 half speed, 2 quarter speed) + /** [Eiger][Jungfrau] // TODO: create enum for speed + * Options: (0 full speed, 1 half speed, 2 quarter speed) */ void setSpeed(int value, Positions pos = {}); @@ -285,57 +138,6 @@ class Detector { /** [Jungfrau][CTB] */ Result getMaxADCPhaseShift(Positions pos = {}) const; - /** [CTB] */ - Result getDBITPhase(bool inDeg, Positions pos = {}) const; - - /** [CTB] */ - void setDBITPhase(int value, bool inDeg, Positions pos = {}); - - /** [CTB] */ - Result getMaxDBITPhaseShift(Positions pos = {}) const; - - /** [CTB] */ - Result getADCClock(Positions pos = {}) const; - - /** [CTB] */ - void setADCClock(int value_in_MHz, Positions pos = {}); - - /** [CTB] */ - Result getDBITClock(Positions pos = {}) const; - - /** [CTB] */ - void setDBITClock(int value_in_MHz, Positions pos = {}); - - /** [CTB] */ - Result getRUNClock(Positions pos = {}) const; - - /** [CTB] */ - void setRUNClock(int value_in_MHz, Positions pos = {}); - - /** [CTB] */ - Result getSYNCClock(Positions pos = {}) const; - - /** [CTB] */ - Result getADCPipeline(Positions pos = {}) const; - - /** [CTB] */ - void setADCPipeline(int value, Positions pos = {}); - - /** [CTB] */ - Result getDBITPipeline(Positions pos = {}) const; - - /** [CTB] */ - void setDBITPipeline(int value, Positions pos = {}); - - Result getDynamicRange(Positions pos = {}) const; - - /** - * [Eiger] - * Options: 4, 8, 16, 32 - * If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1 - */ - void setDynamicRange(int value); - Result getHighVoltage(Positions pos = {}) const; /** @@ -345,60 +147,22 @@ class Detector { */ void setHighVoltage(int value, Positions pos = {}); - /** [Eiger] */ - Result getIODelay(Positions pos = {}) const; - - /** [Eiger] */ - void setIODelay(int value, Positions pos = {}); - /** * (Degrees) - * [Gotthard Options: TEMPERATURE_ADC, TEMPERATURE_FPGA] - * [Jungfrau Options: TEMPERATURE_ADC, TEMPERATURE_FPGA] - * [Eiger Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, + * [Gotthard] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA + * [Jungfrau] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA + * [Eiger] Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, * TEMPERATURE_DCDC, TEMPERATURE_SODL, TEMPERATURE_SODR, TEMPERATURE_FPGA2, - * TEMPERATURE_FPGA3) (CTB Options: SLOW_ADC_TEMP] + * TEMPERATURE_FPGA3 + * [CTB] Options: SLOW_ADC_TEMP */ Result getTemp(defs::dacIndex index, Positions pos = {}) const; - /** [CTB] */ - Result getVrefVoltage(bool mV, Positions pos = {}) const; - - /** [CTB] */ - void setVrefVoltage(int value, bool mV, Positions pos = {}); - - /** [CTB] */ - Result getVoltage(defs::dacIndex index, Positions pos = {}) const; - - /** - * [CTB] mV - * Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C, - * V_POWER_D, V_POWER_IO, V_POWER_CHIP - */ - void setVoltage(int value, defs::dacIndex index, Positions pos = {}); - - /** - * [CTB] mV - * Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO, - * V_POWER_CHIP - */ - Result getMeasuredVoltage(defs::dacIndex index, - Positions pos = {}) const; - - /** - * [CTB] mA - * Options: I_POWER_A, I_POWER_B, I_POWER_C, I_POWER_D, I_POWER_IO - */ - Result getMeasuredCurrent(defs::dacIndex index, - Positions pos = {}) const; - - /** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 */ - Result getSlowADC(defs::dacIndex index, Positions pos = {}) const; - Result getDAC(defs::dacIndex index, bool mV, Positions pos = {}) const; void setDAC(int value, defs::dacIndex index, bool mV, Positions pos = {}); + //TODO: rename externalCommunicationMode: timingMode Result getTimingMode(Positions pos = {}) const; @@ -409,96 +173,91 @@ class Detector { void setTimingMode(defs::externalCommunicationMode value, Positions pos = {}); - /** [Gotthard] */ - Result - getExternalSignalFlags(Positions pos = {}) const; - /** [Gotthard] Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE */ - void setExternalSignalFlags(defs::externalSignalFlag value, - Positions pos = {}); + /************************************************** + * * + * ACQUISITION * + * * + * ************************************************/ + /** + * Blocking call, starts the receiver and detector. + * Increments file index if file write enabled. + * Acquired the number of frames set. + */ + void acquire(); - /** [Eiger] */ - Result getParallelMode(Positions pos = {}) const; - - /** [Eiger] */ - void setParallelMode(bool value, Positions pos = {}); - - /** [Eiger] */ - Result getOverFlowMode(Positions pos = {}) const; - - /** [Eiger] */ - void setOverFlowMode(bool value, Positions pos = {}); - - /** [CTB] */ - Result getSignalType(Positions pos = {}) const; - - /** [CTB] Options: NORMAL_READOUT = 0, DIGITAL_ONLY = 1, ANALOG_AND_DIGITAL - * = 2 */ - void setSignalType(int value, Positions pos = {}); - - /** [Eiger] */ - Result getInterruptSubframe(Positions pos = {}) const; - - /** [Eiger] when set, the last subframe is interrupted at end of acq */ - void setInterruptSubframe(const bool enable, Positions pos = {}); - - Result readRegister(uint32_t addr, Positions pos = {}) const; - - void writeRegister(uint32_t addr, uint32_t val, Positions pos = {}); - - void setBit(uint32_t addr, int bitnr, Positions pos = {}); - - void clearBit(uint32_t addr, int bitnr, Positions pos = {}); - - Result getDetectorMAC(Positions pos = {}) const; - - void setDetectorMAC(const std::string &detectorMAC, Positions pos = {}); - - /** [Jungfrau] bottom half */ - Result getDetectorMAC2(Positions pos = {}) const; - - /** [Jungfrau] bottom half */ - void setDetectorMAC2(const std::string &detectorMAC, Positions pos = {}); - - Result getDetectorIP(Positions pos = {}) const; - - void setDetectorIP(const std::string &detectorIP, Positions pos = {}); - - /** [Jungfrau] bottom half */ - Result getDetectorIP2(Positions pos = {}) const; - - /** [Jungfrau] bottom half */ - void setDetectorIP2(const std::string &detectorIP, Positions pos = {}); - - Result getReceiverHostname(Positions pos = {}) const; + /** Non blocking + * Starts the reciever (if enabled) and then the detector + * You have to check detector status until it is idle before you call stopACquisition + * + */ + void startAcquisition(); /** - * Validates and sets the receiver. - * Updates local receiver cache parameters - * Configures the detector to the receiver as UDP destination - * @param receiver receiver hostname or IP address + * Stops detector acquisition and then receiver (if enabled) + * If no receiver enabled, you can skip this for normal acquisition (no abort) */ - void setReceiverHostname(const std::string &receiver, Positions pos = {}); + void stopAcquisition();//TODO: cannot do this. for acquire, to stop acquisition, must not also do stop receiver(mutex) - Result getReceiverUDPIP(Positions pos = {}) const; + /** + * Clears the acquiring flag. This has to be done manually + * after an acquisition was aborted. + */ + void clearAcquiringFlag(); - void setReceiverUDPIP(const std::string &udpip, Positions pos = {}); + Result getDetectorStatus(Positions pos = {}) const; - /** [Jungfrau bottom half] */ - Result getReceiverUDPIP2(Positions pos = {}) const; + Result getReceiverStatus(Positions pos = {}) const; - /** [Jungfrau bottom half] */ - void setReceiverUDPIP2(const std::string &udpip, Positions pos = {}); + Result getFramesCaught(Positions pos = {}) const; - Result getReceiverUDPMAC(Positions pos = {}) const; + /** [Eiger][Jungfrau] */ + Result getStartingFrameNumber(Positions pos = {}) const; - void setReceiverUDPMAC(const std::string &udpmac, Positions pos = {}); + /** [Eiger][Jungfrau] */ + void setStartingFrameNumber(uint64_t value, Positions pos); - /** [Jungfrau bottom half] */ - Result getReceiverUDPMAC2(Positions pos = {}) const; +//TODO: remove resetframescaught in receiver + + + /************************************************** + * * + * Network Configuration (Detector<->Receiver) * + * * + * ************************************************/ + + /** Configures the destination for UDP packets in the detector */ + void configureMAC(Positions pos = {});//TODO: find a reasonable name + + Result getSourceUDPMAC(Positions pos = {}) const; + + /* For Eiger 1G, the detector will replace with its own DHCP MAC + * For Eiger 10G, the detector will replace with its own DHCP MAC + 1 + * Others can be anything (beware of certain bits) + */ + + void setSourceUDPMAC(const std::string &detectorMAC, Positions pos = {}); + + Result getSourceUDPIP(Positions pos = {}) const; + + /* For Eiger 1G, the detector will replace with its own DHCP IP + * 10G Eiger and other detectors, the source UDP IP must be in the + * same subnet of the destination UDP IP + */ + void setSourceUDPIP(const std::string &detectorIP, Positions pos = {}); + + Result getDestinationUDPIP(Positions pos = {}) const; + + /** IP of the interface in receiver that the detector sends data to */ + void setDestinationUDPIP(const std::string &udpip, Positions pos = {}); + + Result getDestinationUDPMAC(Positions pos = {}) const; + + /** MAC of the interface in receiver that the detector sends data to + * Only needed if you use a custom receiver (not slsReceiver) + */ + void setDestinationUDPMAC(const std::string &udpmac, Positions pos = {}); - /** [Jungfrau bottom half] */ - void setReceiverUDPMAC2(const std::string &udpmac, Positions pos = {}); Result getReceiverUDPPort(Positions pos = {}) const; @@ -510,6 +269,25 @@ class Detector { /** [Eiger right port][Jungfrau bottom half] */ void setReceiverUDPPort2(int udpport, Positions pos = {}); + Result printReceiverConfiguration(Positions pos = {}) const; + + /** [Eiger, Jungfrau] */ + Result getFlowControl10G(Positions pos = {}) const; + + /** [Eiger, Jungfrau] */ + void setFlowControl10G(bool enable, Positions pos = {}); + + /** [Eiger, Jungfrau] */ + Result getTransmissionDelayFrame(Positions pos = {}) const; + + /** + * [Jungfrau]: Sets the transmission delay of the first UDP packet being + * streamed out of the module Options: 0 - 31, each value represenets 1 ms + * [Eiger]: Sets the transmission delay of entire frame streamed out for both + * left and right UDP ports + */ + void setTransmissionDelayFrame(int value, Positions pos = {}); + /** [Jungfrau] */ Result getNumberofUDPInterfaces(Positions pos = {}) const; @@ -526,54 +304,35 @@ class Detector { */ void selectUDPInterface(int interface, Positions pos = {}); - Result getClientStreamingPort(Positions pos = {}) const; - /** - * pos can be for a single module or all modules, not a subset - * If pos for all modules, ports for each module is calculated (increments) - * Restarts client zmq sockets - */ - void setClientDataStreamingInPort(int port, Positions pos = {}); + /** [Jungfrau] bottom half */ + Result getDetectorMAC2(Positions pos = {}) const; - Result getReceiverStreamingPort(Positions pos = {}) const; - /** - * pos can be for a single module or all modules, not a subset - * If pos for all modules, ports for each module is calculated (increments) - * Restarts receiver zmq sockets - */ - void setReceiverDataStreamingOutPort(int port, Positions pos = {}); + /** [Jungfrau] bottom half */ + void setDetectorMAC2(const std::string &detectorMAC, Positions pos = {}); - Result getClientStreamingIP(Positions pos = {}) const; + /** [Jungfrau] bottom half */ + Result getDetectorIP2(Positions pos = {}) const; - // TODO these should probably be the same ?? same as what? - void setClientDataStreamingInIP(const std::string &ip, Positions pos = {}); + /** [Jungfrau] bottom half */ + void setDetectorIP2(const std::string &detectorIP, Positions pos = {}); - Result getReceiverStreamingIP(Positions pos = {}) const; + /** [Jungfrau bottom half] */ + Result getReceiverUDPIP2(Positions pos = {}) const; - void setReceiverDataStreamingOutIP(const std::string &ip, - Positions pos = {}); + /** [Jungfrau bottom half] */ + void setReceiverUDPIP2(const std::string &udpip, Positions pos = {}); + + /** [Jungfrau bottom half] */ + Result getReceiverUDPMAC2(Positions pos = {}) const; - /** [Eiger, Jungfrau] */ - Result getFlowControl10G(Positions pos = {}) const; - - /** [Eiger, Jungfrau] */ - void setFlowControl10G(bool enable, Positions pos = {}); - - /** [Eiger, Jungfrau] */ - Result getTransmissionDelayFrame(Positions pos = {}) const; - - /** - * [Jungfrau: Sets the transmission delay of the first UDP packet being - * streamed out of the module Options: 0 - 31, each value represenets 1 ms ] - * [Eiger: Sets the transmission delay of entire frame streamed out for both - * left and right UDP ports] - */ - void setTransmissionDelayFrame(int value, Positions pos = {}); + /** [Jungfrau bottom half] */ + void setReceiverUDPMAC2(const std::string &udpmac, Positions pos = {}); /** [Eiger] */ Result getTransmissionDelayLeft(Positions pos = {}) const; /** * [Eiger] - * Sets the transmission delay of first packet streamed ut of the left UDP + * Sets the transmission delay of first packet streamed out of the left UDP * port */ void setTransmissionDelayLeft(int value, Positions pos = {}); @@ -588,289 +347,68 @@ class Detector { */ void setTransmissionDelayRight(int value, Positions pos = {}); - /** [Moench] */ - Result getAdditionalJsonHeader(Positions pos = {}) const; - /** [Moench] */ - void setAdditionalJsonHeader(const std::string &jsonheader, - Positions pos = {}); - /** [Moench] */ - Result getAdditionalJsonParameter(const std::string &key, - Positions pos = {}) const; - /** - * [Moench] - * Sets the value for additional json header parameter if found, - * else appends the parameter key and value - * The value cannot be empty - */ - void setAdditionalJsonParameter(const std::string &key, - const std::string &value, - Positions pos = {}); + /************************************************** + * * + * RECEIVER CONFIG * + * * + * ************************************************/ - /** [Moench] TODO! How do we do this best??? Can be refactored to something - * else? Use a generic zmq message passing system... - * For now limiting to all detectors working the same*/ - /** [Moench: -1 if not found or cannot convert to int] */ - Result getDetectorMinMaxEnergyThreshold(const bool isEmax, - Positions pos = {}) const; + /** true when slsReceiver is used */ + Result getUseReceiverFlag(Positions pos = {}) const; - /** [Moench] */ - void setDetectorMinMaxEnergyThreshold(const bool isEmax, const int value, - Positions pos = {}); - - /** [Moench: -1 if unknown mode] */ - Result getFrameMode(Positions pos = {}) const; - - /** [Moench] */ - void setFrameMode(defs::frameModeType value, Positions pos = {}); - - /** [Moench: -1 if unknown mode] */ - Result getDetectorMode(Positions pos = {}) const; - - /** [Moench] */ - void setDetectorMode(defs::detectorModeType value, Positions pos = {}); - - /** [Gotthard] */ - Result getDigitalTestBit(Positions pos = {}); - - /** [Gotthard] */ - Result setDigitalTestBit(const int value, Positions pos = {}); - - /** [Gotthard][Jungfrau][CTB] */ - Result executeFirmwareTest(Positions pos = {}); - - /** [Gotthard][Jungfrau][CTB] */ - Result executeBusTest(Positions pos = {}); - - /** [Gotthard] subset modules not allowed */ - void loadDarkImage(const std::string &fname, Positions pos = {}); - - /** [Gotthard] subset modules not allowed */ - void loadGainImage(const std::string &fname, Positions pos = {}); + Result getReceiverHostname(Positions pos = {}) const; /** - * [Gotthard] subset modules not allowed - * @param startACQ if start acq after reading counter + * Validates and sets the receiver. + * Updates local receiver cache parameters + * Configures the detector to the receiver as UDP destination + * @param receiver receiver hostname or IP address */ - void getCounterMemoryBlock(const std::string &fname, bool startACQ, - Positions pos = {}); + void setReceiverHostname(const std::string &receiver, Positions pos = {}); + + Result getReceiverPort(Positions pos = {}) const; + + /** Receiver TCP port (for client communication with Receiver) */ + void setReceiverPort(int value, Positions pos = {}); + + Result getReceiverFifoDepth(Positions pos = {}) const; + + void setReceiverFifoDepth(int nframes, Positions pos = {}); + + Result getReceiverSilentMode(Positions pos = {}) const; + + void setReceiverSilentMode(bool value, Positions pos = {}); + + Result + getReceiverFrameDiscardPolicy(Positions pos = {}) const; /** - * [Gotthard] - * @param startACQ if start acq after resetting counter - * TODO! does it make sense to call one detector? + * default NO_DISCARD + * Options: NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES */ - void resetCounterBlock(bool startACQ, Positions pos = {}); + void setReceiverFrameDiscardPolicy(defs::frameDiscardPolicy f, + Positions pos = {}); + + Result getPartialFramesPadding(Positions pos = {}) const; - /** [Eiger] */ - Result getCounterBit(Positions pos = {}) const; + /** padding enabled */ + void setPartialFramesPadding(bool value, Positions pos = {}); - /** [Eiger] If it is set, it resets chips completely (else partially) before - * an acquisition TODO: if it makes sense */ - void setCounterBit(bool value, Positions pos = {}); + Result getReceiverUDPSocketBufferSize(Positions pos = {}) const; - /** [Gotthard]*/ - Result getROI(Positions pos = {}) const; + void setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, + Positions pos = {}); + Result + getReceiverRealUDPSocketBufferSize(Positions pos = {}) const; - /** - * [Gotthard] - * Options: Only a single ROI per module - * Can set only a single ROI at a time - * @param module position index - */ - void setROI(defs::ROI value, int moduleId); + Result getReceiverLock(Positions pos = {}); - /** [CTB]*/ - Result getADCEnableMask(Positions pos = {}) const; + /** locks receiver server to client IP */ + void setReceiverLock(bool value, Positions pos = {}); - /** [CTB]*/ - void setADCEnableMask(uint32_t mask, Positions pos = {}); - - /** [CTB] */ - Result getADCInvert(Positions pos = {}) const; - - /** [CTB]*/ - void setADCInvert(uint32_t value, Positions pos = {}); - - /** [CTB] */ - Result getExternalSamplingSource(Positions pos = {}) const; - - /** [CTB] Value between 0-63 */ - void setExternalSamplingSource(int value, Positions pos = {}); - - /** [CTB] */ - Result getExternalSampling(Positions pos = {}) const; - - /** [CTB] */ - void setExternalSampling(bool value, Positions pos = {}); - - /** [CTB] */ - Result> getReceiverDbitList(Positions pos = {}) const; - - /** [CTB] list contains the set of bits (0-63) to save */ - void setReceiverDbitList(std::vector list, Positions pos = {}); - - /** [CTB] */ - Result getReceiverDbitOffset(Positions pos = {}) const; - - /** [CTB] Set number of bytes of digital data to skip in the Receiver */ - void setReceiverDbitOffset(int value, Positions pos = {}); - - /** [Gotthard][Jungfrau][CTB] not possible to read back*/ - void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {}); - - /** [Eiger] */ - Result getActive(Positions pos = {}) const; - - /** [Eiger] */ - void setActive(bool active, Positions pos = {}); - - /** [Eiger] */ - Result getBottom(Positions pos = {}) const; - - /** [Eiger] for gui purposes */ - void setBottom(bool value, Positions pos = {}); - - /** [Eiger] - * @returns -1 if they are all different - */ - Result getAllTrimbits(Positions pos = {}) const; - - /**[Eiger] */ - void setAllTrimbits(int value, Positions pos = {}); - - /**[Eiger] */ - Result getGapPixelsEnable(Positions pos = {}) const; - - /** - * [Eiger] - * 4 bit mode not implemented in Receiver, but in client data call back - * Fills in gap pixels in data - */ - void setGapPixelsEnable(bool enable); - - /**[Eiger] Returns energies in eV where the module is trimmed */ - Result> getTrimEnergies(Positions pos = {}) const; - - /** [Eiger] Set the energies where the detector is trimmed */ - void setTrimEnergies(std::vector energies, Positions pos = {}); - - /** - * [Eiger] Pulse Pixel n times at x and y coordinates - */ - void pulsePixel(int n, int x, int y, Positions pos = {}); - - /** [Eiger] Pulse Pixel n times and move by a relative value of x and y - * coordinates */ - void pulsePixelNMove(int n, int x, int y, Positions pos = {}); - - /** [Eiger] Pulse chip n times */ - void pulseChip(int n, Positions pos = {}); - - /** [Jungfrau] */ - Result getThresholdTemperature(Positions pos = {}) const; - - /** - * [Jungfrau]Set threshold temperature - * If temperature crosses threshold temperature - * and temperature control is enabled, - * power to chip will be switched off and - * temperature event will be set - * @param val value in millidegrees TODO! Verify - */ - void setThresholdTemperature(int temp, Positions pos = {}); - - /** [Jungfrau] */ - Result getTemperatureControl(Positions pos = {}) const; - - /** [Jungfrau] */ - void setTemperatureControl(bool enable, Positions pos = {}); - - /** [Jungfrau] */ - Result getTemperatureEvent(Positions pos = {}) const; - - /** [Jungfrau] */ - void ResetTemperatureEvent(Positions pos = {}); - - /** [Jungfrau][CTB] */ - void programFPGA(const std::string &fname, Positions pos = {}); - - /** [Jungfrau][CTB] */ - void resetFPGA(Positions pos = {}); - - /** - * Copy detector server fname from tftp folder of hostname to detector - * Also changes respawn server, which is effective after a reboot. - */ - void copyDetectorServer(const std::string &fname, - const std::string &hostname, Positions pos = {}); - - /** [Jungfrau][Gotthard][CTB] */ - void rebootController(Positions pos = {}); - - /** - * [Jungfrau][Gotthard][CTB] - * Updates the firmware, detector server and then reboots detector - * controller blackfin. - * @param sname name of detector server binary found on tftp folder of host - * pc - * @param hostname name of pc to tftp from - * @param fname programming file name - * @param pos detector positions - */ - void updateFirmwareAndServer(const std::string &sname, - const std::string &hostname, - const std::string &fname, Positions pos = {}); - - /** [Jungfrau] */ - Result getPowerChip(Positions pos = {}) const; - - /** [Jungfrau] */ - void setPowerChip(bool on, Positions pos = {}); - - /** [Jungfrau] */ - Result getAutoCompDisable(Positions pos = {}) const; - - /** [Jungfrau] TODO??? fix docs ? */ - void setAutoCompDisable(bool value, Positions pos = {}); - - /** [Eiger] - * @returns deadtime in ns, 0 = disabled - */ - Result getRateCorrection(Positions pos = {}) const; - - /** - * [Eiger] Set Rate correction - * 0 disable correction, <0 set to default, >0 deadtime in ns - */ - void setRateCorrection(int64_t dead_time_ns, Positions pos = {}); - - /** [Eiger][Jungfrau] */ - Result getStartingFrameNumber(Positions pos = {}) const; - - /** [Eiger][Jungfrau] */ - void setStartingFrameNumber(uint64_t value, Positions pos); - - /** [Eiger] */ - Result getTenGigaEnabled(Positions pos = {}) const; - - /** [Eiger] */ - void setTenGigaEnabled(bool value, Positions pos = {}); - - /** [CTB] */ - Result getLEDEnable(Positions pos = {}) const; - - /** [CTB] */ - void setLEDEnable(bool enable, Positions pos = {}); - - /** - * [CTB] Set Digital IO Delay - * cannot get - * @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, Positions pos = {}); + Result getReceiverLastClientIP(Positions pos = {}) const; /************************************************** * * @@ -915,31 +453,20 @@ class Detector { void setFramesPerFile(int n, Positions pos = {}); + /************************************************** * * - * RECEIVER CONFIG * + * ZMQ Streaming Parameters * * * * ************************************************/ - /** true when slsReceiver is used */ - Result getUseReceiverFlag(Positions pos = {}) const; - Result printReceiverConfiguration(Positions pos = {}) const; + Result getDataStreamingFromReceiver(Positions pos = {}) const; - Result getReceiverPort(Positions pos = {}) const; + void setDataStreamingFromReceiver(bool value, Positions pos = {}); - /** Receiver TCP port (for client communication with Receiver) */ - void setReceiverPort(int value, Positions pos = {}); + bool getDataStreamingToClient() const; - Result getReceiverLock(Positions pos = {}); - - /** locks receiver server to client IP */ - void setReceiverLock(bool value, Positions pos = {}); - - Result getReceiverLastClientIP(Positions pos = {}) const; - - void exitReceiver(Positions pos = {}); - - void execReceiverCommand(const std::string &cmd, Positions pos = {}); + void setDataStreamingToClient(bool value); Result getReceiverStreamingFrequency(Positions pos = {}) const; @@ -958,36 +485,227 @@ class Detector { */ void setReceiverStreamingTimer(int time_in_ms, Positions pos = {}); - bool getDataStreamingToClient() const; + Result getClientStreamingPort(Positions pos = {}) const; + /** + * pos can be for a single module or all modules, not a subset + * If pos for all modules, ports for each module is calculated (increments) + * Restarts client zmq sockets + */ + void setClientDataStreamingInPort(int port, Positions pos = {}); - void setDataStreamingToClient(bool value); + Result getReceiverStreamingPort(Positions pos = {}) const; + /** + * pos can be for a single module or all modules, not a subset + * If pos for all modules, ports for each module is calculated (increments) + * Restarts receiver zmq sockets + */ + void setReceiverDataStreamingOutPort(int port, Positions pos = {}); - Result getDataStreamingFromReceiver(Positions pos = {}) const; + Result getClientStreamingIP(Positions pos = {}) const; - void setDataStreamingFromReceiver(bool value, Positions pos = {}); + // TODO these should probably be the same ?? same as what? + void setClientDataStreamingInIP(const std::string &ip, Positions pos = {}); - Result getReceiverFifoDepth(Positions pos = {}) const; + Result getReceiverStreamingIP(Positions pos = {}) const; - void setReceiverFifoDepth(int nframes, Positions pos = {}); + void setReceiverDataStreamingOutIP(const std::string &ip, + Positions pos = {}); - Result getReceiverSilentMode(Positions pos = {}) const; + /** [Moench] */ + Result getAdditionalJsonHeader(Positions pos = {}) const; - void setReceiverSilentMode(bool value, Positions pos = {}); + /** [Moench] */ + void setAdditionalJsonHeader(const std::string &jsonheader, + Positions pos = {}); - Result - getReceiverFrameDiscardPolicy(Positions pos = {}) const; + /** [Moench] */ + Result getAdditionalJsonParameter(const std::string &key, + Positions pos = {}) const; + /** + * [Moench] + * Sets the value for additional json header parameter if found, + * else appends the parameter key and value + * The value cannot be empty + */ + void setAdditionalJsonParameter(const std::string &key, + const std::string &value, + Positions pos = {}); + + /** [Moench] TODO! How do we do this best??? Can be refactored to something + * else? Use a generic zmq message passing system... + * For now limiting to all detectors working the same*/ + /** [Moench: -1 if not found or cannot convert to int] */ + Result getDetectorMinMaxEnergyThreshold(const bool isEmax, + Positions pos = {}) const; + + /** [Moench] */ + void setDetectorMinMaxEnergyThreshold(const bool isEmax, const int value, + Positions pos = {}); + + /** [Moench: -1 if unknown mode] */ + Result getFrameMode(Positions pos = {}) const; + + /** [Moench] */ + void setFrameMode(defs::frameModeType value, Positions pos = {}); + + /** [Moench: -1 if unknown mode] */ + Result getDetectorMode(Positions pos = {}) const; + + /** [Moench] */ + void setDetectorMode(defs::detectorModeType value, Positions pos = {}); + + + /************************************************** + * * + * Eiger Specific * + * * + * ************************************************/ + + Result getDynamicRange(Positions pos = {}) const; + + /** [Eiger] */ + Result getTenGigaEnabled(Positions pos = {}) const; + + /** [Eiger] */ + void setTenGigaEnabled(bool value, Positions pos = {}); /** - * default NO_DISCARD - * Options: NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES + * [Eiger] + * Options: 4, 8, 16, 32 + * If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1 */ - void setReceiverFrameDiscardPolicy(defs::frameDiscardPolicy f, - Positions pos = {}); - - Result getPartialFramesPadding(Positions pos = {}) const; + void setDynamicRange(int value); - /** padding enabled */ - void setPartialFramesPadding(bool value, Positions pos = {}); + /** [Eiger] in 32 bit mode */ + Result getSubExptime(Positions pos = {}) const; + + /** [Eiger] in 32 bit mode */ + void setSubExptime(ns t, Positions pos = {}); + + /** [Eiger] in 32 bit mode */ + Result getSubDeadTime(Positions pos = {}) const; + + /** [Eiger] in 32 bit mode */ + void setSubDeadTime(ns value, Positions pos = {}); + + /** [Eiger] */ + Result getThresholdEnergy(Positions pos = {}) const; + + /** [Eiger] */ + void setThresholdEnergy(int threshold_ev, + defs::detectorSettings settings = defs::STANDARD, + bool trimbits = true, Positions pos = {}); + + /** [Eiger] */ + Result getSettingsDir(Positions pos = {}) const; + + /** [Eiger] */ + void setSettingsDir(const std::string &value, Positions pos = {}); + + /** [Eiger] */ + void loadTrimbits(const std::string &fname, Positions pos = {}); + + /**[Eiger] */ + Result getGapPixelsEnable(Positions pos = {}) const; + + /** + * [Eiger] + * 4 bit mode not implemented in Receiver, but in client data call back + * Fills in gap pixels in data + */ + void setGapPixelsEnable(bool enable); + + /** [Eiger] */ + Result getParallelMode(Positions pos = {}) const; + + /** [Eiger] */ + void setParallelMode(bool value, Positions pos = {}); + + /** [Eiger] */ + Result getOverFlowMode(Positions pos = {}) const; + + /** [Eiger] */ + void setOverFlowMode(bool value, Positions pos = {}); + + /** [Eiger] */ + Result getBottom(Positions pos = {}) const; + + /** [Eiger] for gui purposes */ + void setBottom(bool value, Positions pos = {}); + + /** [Eiger] + * @returns -1 if they are all different + */ + Result getAllTrimbits(Positions pos = {}) const; + + /**[Eiger] */ + void setAllTrimbits(int value, Positions pos = {}); + + /**[Eiger] Returns energies in eV where the module is trimmed */ + Result> getTrimEnergies(Positions pos = {}) const; + + /** [Eiger] Set the energies where the detector is trimmed */ + void setTrimEnergies(std::vector energies, Positions pos = {}); + + /** [Eiger] + * @returns deadtime in ns, 0 = disabled + */ + Result getRateCorrection(Positions pos = {}) const; + + /** + * [Eiger] Set Rate correction + * 0 disable correction, <0 set to default, >0 deadtime in ns + */ + void setRateCorrection(int64_t dead_time_ns, Positions pos = {}); + + /** [Eiger] Sends an internal software trigger to the detector */ + void sendSoftwareTrigger(Positions pos = {}); + + /** [Eiger] */ + Result getPartialReadout(Positions pos = {}) const; + + /** [Eiger] Number of lines to read out per half module + * Options: 0 - 256. Depending on dynamic range and + * 10 GbE enabled, only specific values are accepted. + */ + void setPartialReadout(const int lines, Positions pos = {}); + + /** [Eiger] */ + Result getIODelay(Positions pos = {}) const; + + /** [Eiger] */ + void setIODelay(int value, Positions pos = {}); + + /** [Eiger] */ + Result getInterruptSubframe(Positions pos = {}) const; + + /** [Eiger] when set, the last subframe is interrupted at end of acq */ + void setInterruptSubframe(const bool enable, Positions pos = {}); + + /** [Eiger] */ + Result getCounterBit(Positions pos = {}) const; + + /** [Eiger] If it is set, it resets chips completely (else partially) before + * an acquisition TODO: if it makes sense */ + void setCounterBit(bool value, Positions pos = {}); + + /** + * [Eiger] Pulse Pixel n times at x and y coordinates + */ + void pulsePixel(int n, int x, int y, Positions pos = {}); + + /** [Eiger] Pulse Pixel n times and move by a relative value of x and y + * coordinates */ + void pulsePixelNMove(int n, int x, int y, Positions pos = {}); + + /** [Eiger] Pulse chip n times */ + void pulseChip(int n, Positions pos = {}); + + /** [Eiger] */ + Result getActive(Positions pos = {}) const; + + /** [Eiger] */ + void setActive(bool active, Positions pos = {}); /** [Eiger] */ Result getRxPadDeactivatedMod(Positions pos = {}) const; @@ -997,61 +715,291 @@ class Detector { */ void setRxPadDeactivatedMod(bool pad, Positions pos = {}); - Result getReceiverUDPSocketBufferSize(Positions pos = {}) const; + /** [Eiger] with specific quad hardware */ + Result getQuad(Positions pos = {}) const; - void setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, - Positions pos = {}); - Result - getReceiverRealUDPSocketBufferSize(Positions pos = {}) const; + /** [Eiger] with specific quad hardware */ + void setQuad(const bool enable); + + /** [Eiger] minimum two frames */ + Result getMeasuredPeriod(Positions pos = {}) const; + + /** [Eiger] */ + Result getMeasuredSubFramePeriod(Positions pos = {}) const; /************************************************** * * - * ACQUISITION * + * Jungfrau Specific * * * * ************************************************/ - /** - * Blocking call, starts the receiver and detector. - * Increments file index if file write enabled. - * Acquired the number of frames set. - */ - void acquire(); + + /** [Jungfrau] */ + Result getThresholdTemperature(Positions pos = {}) const; /** - * Get the acquiring flag. When true the detector blocks - * any attempt to start a new acquisition. + * [Jungfrau]Set threshold temperature + * If temperature crosses threshold temperature + * and temperature control is enabled, + * power to chip will be switched off and + * temperature event will be set + * @param val value in millidegrees TODO! Verify */ - bool getAcquiringFlag() const; + void setThresholdTemperature(int temp, Positions pos = {}); + + /** [Jungfrau] */ + Result getTemperatureControl(Positions pos = {}) const; + + /** [Jungfrau] */ + void setTemperatureControl(bool enable, Positions pos = {}); + + /** [Jungfrau] */ + Result getTemperatureEvent(Positions pos = {}) const; + + /** [Jungfrau] */ + void ResetTemperatureEvent(Positions pos = {}); + + /** [Jungfrau] */ + Result getPowerChip(Positions pos = {}) const; + + /** [Jungfrau] */ + void setPowerChip(bool on, Positions pos = {}); + + /** [Jungfrau] */ + Result getAutoCompDisable(Positions pos = {}) const; + + /** [Jungfrau] TODO??? fix docs ? */ + void setAutoCompDisable(bool value, Positions pos = {}); + + /** [Jungfrau] Advanced */ + Result getNumberOfAdditionalStorageCells() const; + + /** [Jungfrau] Advanced */ + void setNumberOfAdditionalStorageCells(int64_t value); + + /** [Jungfrau] Advanced */ + Result getStorageCellStart(Positions pos = {}) const; + + /** [Jungfrau] Advanced. Sets the storage cell storing the first acquisition of the + * series. Options: 0-15 + */ + void setStoragecellStart(int cell, Positions pos = {}); + + /** [Jungfrau] Advanced*/ + Result getStorageCellDelay(Positions pos = {}) const; + + /** [Jungfrau] Advanced + * Options: (0-1638375 ns (resolution of 25ns) */ + void setStorageCellDelay(ns value, Positions pos = {}); + + + /************************************************** + * * + * Gotthard Specific * + * * + * ************************************************/ + + /** [Gotthard]*/ + Result getROI(Positions pos = {}) const; /** - * Set the acquiring flag. This might have to done manually - * after an acquisition was aborted. + * [Gotthard] + * Options: Only a single ROI per module + * Can set only a single ROI at a time + * @param module position index */ - void setAcquiringFlag(bool value); + void setROI(defs::ROI value, int moduleId); - Result getRunStatus(Positions pos = {}); + /** [Gotthard] */ + Result getExptimeLeft(Positions pos = {}) const; - /** Non blocking */ - void startAcquisition(); + /** [Gotthard] */ + Result getPeriodLeft(Positions pos = {}) const; - void stopAcquisition(); + /** [Gotthard] */ + Result + getExternalSignalFlags(Positions pos = {}) const; - /** [Eiger] Sends an internal software trigger to the detector */ - void sendSoftwareTrigger(Positions pos = {}); + /** [Gotthard] Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE */ + void setExternalSignalFlags(defs::externalSignalFlag value, + Positions pos = {}); - /** Receiver starts listening to UDP packets from detector */ - void startReceiver(Positions pos = {}); + /** [Gotthard] subset modules not allowed */ + void loadDarkImage(const std::string &fname, Positions pos = {}); - /** Receiver stops listening to UDP packets from detector */ - void stopReceiver(Positions pos = {}); + /** [Gotthard] subset modules not allowed */ + void loadGainImage(const std::string &fname, Positions pos = {}); - /** Read back the run status of the receiver */ - Result getReceiverStatus(Positions pos = {}); + /** + * [Gotthard] subset modules not allowed + * @param startACQ if start acq after reading counter + */ + void getCounterMemoryBlock(const std::string &fname, bool startACQ, + Positions pos = {}); - Result getFramesCaughtByReceiver(Positions pos = {}) const; + /** + * [Gotthard] + * @param startACQ if start acq after resetting counter + * TODO! does it make sense to call one detector? + */ + void resetCounterBlock(bool startACQ, Positions pos = {}); - Result getReceiverCurrentFrameIndex(Positions pos = {}) const; + /** [Gotthard] */ + Result getDigitalTestBit(Positions pos = {}); + + /** [Gotthard] */ + Result setDigitalTestBit(const int value, Positions pos = {}); + + /************************************************** + * * + * CTB Specific * + * * + * ************************************************/ + + /** [CTB] */ + Result getNumberOfAnalogSamples(Positions pos = {}) const; + + /** [CTB] */ + void setNumberOfAnalogSamples(int64_t value, Positions pos = {}); + + /** [CTB] */ + Result getNumberOfDigitalSamples(Positions pos = {}) const; + + /** [CTB] */ + void setNumberOfDigitalSamples(int64_t value, Positions pos = {}); + + /** [CTB] */ + Result getSignalType(Positions pos = {}) const; + + /** [CTB] Options: NORMAL_READOUT = 0, DIGITAL_ONLY = 1, ANALOG_AND_DIGITAL + * = 2 */ + void setSignalType(int value, Positions pos = {}); + + /** [CTB] */ + Result getDBITPhase(bool inDeg, Positions pos = {}) const; + + /** [CTB] */ + void setDBITPhase(int value, bool inDeg, Positions pos = {}); + + /** [CTB] */ + Result getMaxDBITPhaseShift(Positions pos = {}) const; + + /** [CTB] */ + Result getADCClock(Positions pos = {}) const; + + /** [CTB] */ + void setADCClock(int value_in_MHz, Positions pos = {}); + + /** [CTB] */ + Result getDBITClock(Positions pos = {}) const; + + /** [CTB] */ + void setDBITClock(int value_in_MHz, Positions pos = {}); + + /** [CTB] */ + Result getRUNClock(Positions pos = {}) const; + + /** [CTB] */ + void setRUNClock(int value_in_MHz, Positions pos = {}); + + /** [CTB] */ + Result getSYNCClock(Positions pos = {}) const; + + /** [CTB] */ + Result getADCPipeline(Positions pos = {}) const; + + /** [CTB] */ + void setADCPipeline(int value, Positions pos = {}); + + /** [CTB] */ + Result getDBITPipeline(Positions pos = {}) const; + + /** [CTB] */ + void setDBITPipeline(int value, Positions pos = {}); + + /** [CTB] */ + Result getVrefVoltage(bool mV, Positions pos = {}) const; + + /** [CTB] */ + void setVrefVoltage(int value, bool mV, Positions pos = {}); + + /** [CTB] */ + Result getVoltage(defs::dacIndex index, Positions pos = {}) const; + + /** + * [CTB] mV + * Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C, + * V_POWER_D, V_POWER_IO, V_POWER_CHIP + */ + void setVoltage(int value, defs::dacIndex index, Positions pos = {}); + + /** + * [CTB] mV + * Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO, + * V_POWER_CHIP + */ + Result getMeasuredVoltage(defs::dacIndex index, + Positions pos = {}) const; + + /** + * [CTB] mA + * Options: I_POWER_A, I_POWER_B, I_POWER_C, I_POWER_D, I_POWER_IO + */ + Result getMeasuredCurrent(defs::dacIndex index, + Positions pos = {}) const; + + /** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 */ + Result getSlowADC(defs::dacIndex index, Positions pos = {}) const; + + /** [CTB]*/ + Result getADCEnableMask(Positions pos = {}) const; + + /** [CTB]*/ + void setADCEnableMask(uint32_t mask, Positions pos = {}); + + /** [CTB] */ + Result getADCInvert(Positions pos = {}) const; + + /** [CTB]*/ + void setADCInvert(uint32_t value, Positions pos = {}); + + /** [CTB] */ + Result getExternalSamplingSource(Positions pos = {}) const; + + /** [CTB] Value between 0-63 */ + void setExternalSamplingSource(int value, Positions pos = {}); + + /** [CTB] */ + Result getExternalSampling(Positions pos = {}) const; + + /** [CTB] */ + void setExternalSampling(bool value, Positions pos = {}); + + /** [CTB] */ + Result> getReceiverDbitList(Positions pos = {}) const; + + /** [CTB] list contains the set of bits (0-63) to save */ + void setReceiverDbitList(std::vector list, Positions pos = {}); + + /** [CTB] */ + Result getReceiverDbitOffset(Positions pos = {}) const; + + /** [CTB] Set number of bytes of digital data to skip in the Receiver */ + void setReceiverDbitOffset(int value, Positions pos = {}); + + /** + * [CTB] Set Digital IO Delay + * cannot get + * @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, Positions pos = {}); + + /** [CTB] */ + Result getLEDEnable(Positions pos = {}) const; + + /** [CTB] */ + void setLEDEnable(bool enable, Positions pos = {}); - void resetFramesCaught(Positions pos = {}); /************************************************** * * @@ -1114,6 +1062,105 @@ class Detector { * pattern */ void setPatternBitMask(uint64_t mask, Positions pos = {}); + + /************************************************** + * * + * Advanced * + * * + * ************************************************/ + + /** [Jungfrau][CTB] */ + void programFPGA(const std::string &fname, Positions pos = {}); + + /** [Jungfrau][CTB] */ + void resetFPGA(Positions pos = {}); + + /** [Jungfrau][Gotthard][CTB] + * Copy detector server fname from tftp folder of hostname to detector + * Also changes respawn server, which is effective after a reboot. + */ + void copyDetectorServer(const std::string &fname, + const std::string &hostname, Positions pos = {}); + + /** [Jungfrau][Gotthard][CTB] */ + void rebootController(Positions pos = {}); + + /** + * [Jungfrau][Gotthard][CTB] + * Updates the firmware, detector server and then reboots detector + * controller blackfin. + * @param sname name of detector server binary found on tftp folder of host + * pc + * @param hostname name of pc to tftp from + * @param fname programming file name + * @param pos detector positions + */ + void updateFirmwareAndServer(const std::string &sname, + const std::string &hostname, + const std::string &fname, Positions pos = {}); + + Result readRegister(uint32_t addr, Positions pos = {}) const; + + void writeRegister(uint32_t addr, uint32_t val, Positions pos = {}); + + void setBit(uint32_t addr, int bitnr, Positions pos = {}); + + void clearBit(uint32_t addr, int bitnr, Positions pos = {}); + + /** [Gotthard][Jungfrau][CTB] */ + Result executeFirmwareTest(Positions pos = {}); + + /** [Gotthard][Jungfrau][CTB] */ + Result executeBusTest(Positions pos = {}); + + /** [Gotthard][Jungfrau][CTB] not possible to read back*/ + void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {}); + + + /************************************************** + * * + * Insignificant * + * * + * ************************************************/ + + + + Result getControlPort(Positions pos = {}) const; + + /** Detector Control TCP port (for client communication with Detector + * control server) */ + void setControlPort(int value, Positions pos = {}); + + Result getStopPort(Positions pos = {}) const; + + /** Detector Stop TCP port (for client communication with Detector Stop + * server) */ + void setStopPort(int value, Positions pos = {}); + + Result getDetectorLock(Positions pos = {}) const; + + void setDetectorLock(bool lock, Positions pos = {}); + + /** Get last client IP saved on detector server */ + Result getLastClientIP(Positions pos = {}) const; + + /** Execute a command on the detector server */ + void execCommand(const std::string &value, Positions pos = {}); + + /** [Gotthard][Jungfrau][CTB] */ + Result getNumberOfFramesFromStart(Positions pos = {}) const; + + /** [Jungfrau][CTB] Get time from detector start */ + Result getActualTime(Positions pos = {}) const; + + /** [Jungfrau][CTB] Get timestamp at a frame start */ + Result getMeasurementTime(Positions pos = {}) const; + + std::string getUserDetails() const; + + Result getReceiverCurrentFrameIndex(Positions pos = {}) const; + + }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 367013933..d3250d016 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -57,17 +57,10 @@ struct sharedMultiSlsDetector { int numberOfDetector[2]; /** total number of channels for all detectors */ - int numberOfChannels; + int numberOfChannels[2]; - /** total number of channels for all detectors in one dimension*/ - int numberOfChannel[2]; - - /** total number of channels including gap pixels in one dimension */ - int numberOfChannelInclGapPixels[2]; - - /** max number of channels allowed for the complete set of detectors in - * one dimension */ - int maxNumberOfChannelsPerDetector[2]; + /** max number of channels for complete detector*/ + int maxNumberOfChannels[2]; /** flag for acquiring */ bool acquiringFlag; @@ -367,91 +360,32 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ size_t size() const;// - /** - * Returns number of detectors in dimension d - * @param d dimension d - * @returns number of detectors in dimension d - */ - int getNumberOfDetectors(dimension d) const;// - /** * Returns the number of detectors in each direction - @param nx number of detectors in x direction - @param ny number of detectors in y direction */ - void getNumberOfDetectors(int &nx, int &ny) const;// + slsDetectorDefs::xy getNumberOfDetectors() const;// /** - * Returns the total number of channels of all sls detectors from shared - * memory - * @param detPos -1 for all detectors in list or specific detector position - * @returns the total number of channels of all sls detectors - */ - int getTotalNumberOfChannels(int detPos = -1);// - - /** - * Returns the total number of channels of all sls detectors in dimension d - * from shared memory + * Returns the total number of channels of all sls detectors including gap pixels * @param d dimension d * @param detPos -1 for all detectors in list or specific detector position - * @returns the total number of channels of all sls detectors in dimension d + * @returns the total number of channels of all sls detectors including gap pixels */ - int getTotalNumberOfChannels(dimension d, int detPos = -1);// + slsDetectorDefs::xy getNumberOfChannels(int detPos = -1);// - /** - * Returns the total number of channels from shared memory in each dimension - * @returns the total number of channels in each dimension - */ - slsDetectorDefs::coordinates getNumberOfChannels() const; // - - /** - * Returns the total number of channels of all sls detectors in dimension d - * including gap pixels from shared memory - * @param d dimension d - * @param detPos -1 for all detectors in list or specific detector position - * @returns the total number of channels of all sls detectors in dimension d - * including gap pixels - */ - int getTotalNumberOfChannelsInclGapPixels(dimension d, int detPos = -1);// - - /** - * Returns the total number of channels including gap pixels - * @returns the total number of channels including gap pixels - */ - slsDetectorDefs::coordinates getTotalNumberOfChannelsInclGapPixels() const; // - - /** - * Returns the maximum number of channels of all sls detectors in each - * dimension d from shared memory. - * @param d dimension d - * @returns the maximum number of channels of all sls detectors in dimension - * d - */ - int getMaxNumberOfChannelsPerDetector(dimension d);// - - /** - * Sets the maximum number of channels of all sls detectors in each - * dimension d from shared memory - * @param d dimension d - * @param i maximum number of channels for multi structure in dimension d - * @returns the maximum number of channels of all sls detectors in dimension - * d - */ - int setMaxNumberOfChannelsPerDetector(dimension d, int i);// - /** * Returns maximum number of channels of all sls detectors in each * dimension d from shared memory * @returns maximum number of channels of all sls detectors */ - slsDetectorDefs::coordinates getMaxNumberOfChannels() const; // + slsDetectorDefs::xy getMaxNumberOfChannels() const; // /** * Sets maximum number of channels of all sls detectors in each * dimension d from shared memory * @param c maximum number of channels of all sls detectors */ - void setMaxNumberOfChannels(const slsDetectorDefs::coordinates c); // + void setMaxNumberOfChannels(const slsDetectorDefs::xy c); // /** * Get Quad Type (Only for Eiger Quad detector hardware) @@ -935,6 +869,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { std::string getDetectorMAC2(int detPos = -1); // /** + * //TODO: custom ip (eiger 10G and other detectors), use 0.0.0.0 and test * Validates the format of the detector IP address and sets it * @param detectorIP detector IP address * @param detPos -1 for all detectors in list or specific detector position @@ -985,6 +920,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { std::string getReceiverHostname(int detPos = -1) const; // /** + * TODO: replace this with setEthernetInterface * Validates the format of the receiver UDP IP address and sets it * @param udpip receiver UDP IP address * @param detPos -1 for all detectors in list or specific detector position diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index de23d310d..d6160f385 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -13,7 +13,7 @@ class ServerInterface; #define SLS_SHMAPIVERSION 0x190726 -#define SLS_SHMVERSION 0x190813 +#define SLS_SHMVERSION 0x190815 /** * @short structure allocated in shared memory to store detector settings for @@ -68,9 +68,6 @@ struct sharedSlsDetector { /** dynamic range of the detector data */ int dynamicRange; - /** size of the data that are transfered from the detector */ - int dataBytes; - /** roi */ slsDetectorDefs::ROI roi; @@ -171,9 +168,6 @@ struct sharedSlsDetector { /** gap pixels in each direction */ int nGappixels[2]; - /** data bytes including gap pixels */ - int dataBytesInclGapPixels; - /** additional json header */ char rxAdditionalJsonHeader[MAX_STR_LENGTH]; @@ -324,73 +318,17 @@ class slsDetector : public virtual slsDetectorDefs { */ int setDetectorType(detectorType type = GET_DETECTOR_TYPE); - /** - * Returns the total number of channels from shared memory - * @returns the total number of channels - */ - int getTotalNumberOfChannels() const; - /** * Update total number of channels (chiptestboard or moench) * depending on the number of samples, adenablemask, readout flags(ctb) */ - void updateTotalNumberOfChannels(); - - /** - * Returns the total number of channels in dimension d from shared memory - * @param d dimension d - * @returns the total number of channels in dimension d - */ - int getTotalNumberOfChannels(dimension d) const; - - /** - * Returns the total number of channels from shared memory in each dimension - * @returns the total number of channels in each dimension - */ - slsDetectorDefs::coordinates getNumberOfChannels() const; - - /** - * Returns the total number of channels of in dimension d including gap - * pixels from shared memory - * @param d dimension d - * @returns the total number of channels including gap pixels in dimension d - * including gap pixels - */ - int getTotalNumberOfChannelsInclGapPixels(dimension d) const; + void updateNumberOfChannels(); /** * Returns the total number of channels including gap pixels * @returns the total number of channels including gap pixels */ - slsDetectorDefs::coordinates getNumberOfChannelsInclGapPixels() const; - - /** - * returns the number of channels per chip from shared memory (Mythen) - * @returns number of channels per chip - */ - int getNChans() const; - - /** - * returns the number of channels per chip in dimension d from shared memory - * (Mythen) - * @param d dimension d - * @returns number of channels per chip in dimension d - */ - int getNChans(dimension d) const; - - /** - * returns the number of chips per module from shared memory (Mythen) - * @returns number of chips per module - */ - int getNChips() const; - - /** - * returns the number of chips per module in dimension d from shared memory - * (Mythen) - * @param d dimension d - * @returns number of chips per module in dimension d - */ - int getNChips(dimension d) const; + slsDetectorDefs::xy getNumberOfChannels() const; /** * Get Quad Type (Only for Eiger Quad detector hardware) @@ -654,7 +592,7 @@ class slsDetector : public virtual slsDetectorDefs { int setSpeed(speedVariable sp, int value = -1, int mode = 0); /** - * Set/get dynamic range and updates the number of dataBytes + * Set/get dynamic range * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to * 1) * @param i dynamic range (-1 get) @@ -665,18 +603,6 @@ class slsDetector : public virtual slsDetectorDefs { int getDynamicRangeFromShm(); - /** - * Recalculated number of data bytes - * @returns tota number of data bytes - */ - int getDataBytes(); - - /** - * Recalculated number of data bytes including gap pixels - * @returns tota number of data bytes including gap pixels - */ - int getDataBytesInclGapPixels(); - /** * Set/get dacs value * @param val value (in V) diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index f4280bb8a..8e6699f6c 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -8,14 +8,14 @@ namespace sls { using defs = slsDetectorDefs; -Detector::Detector(int multi_id) - : pimpl(sls::make_unique(multi_id)) {} +Detector::Detector(int shm_id) + : pimpl(sls::make_unique(shm_id)) {} Detector::~Detector() = default; // Configuration void Detector::freeSharedMemory() { pimpl->freeSharedMemory(); } -void Detector::setConfig(const std::string &fname) { +void Detector::loadConfig(const std::string &fname) { pimpl->readConfigurationFile(fname); } @@ -27,17 +27,9 @@ void Detector::setHostname(const std::vector &value) { pimpl->setHostname(value); } -int Detector::getMultiId() const { return pimpl->getMultiId(); } +int Detector::getShmId() const { return pimpl->getMultiId(); } -void Detector::checkDetectorVersionCompatibility(Positions pos) const { - pimpl->Parallel(&slsDetector::checkDetectorVersionCompatibility, pos); -} - -void Detector::checkReceiverVersionCompatibility(Positions pos) const { - pimpl->Parallel(&slsDetector::checkReceiverVersionCompatibility, pos); -} - -Result Detector::getDetectorFirmwareVersion(Positions pos) const { +Result Detector::getFirmwareVersion(Positions pos) const { return pimpl->Parallel(&slsDetector::getId, pos, defs::DETECTOR_FIRMWARE_VERSION); } @@ -47,40 +39,33 @@ Result Detector::getDetectorServerVersion(Positions pos) const { defs::DETECTOR_SOFTWARE_VERSION); } -Result Detector::getDetectorSerialNumber(Positions pos) const { +Result Detector::getSerialNumber(Positions pos) const { return pimpl->Parallel(&slsDetector::getId, pos, defs::DETECTOR_SERIAL_NUMBER); } -int64_t Detector::getClientSoftwareVersion() const { +int64_t Detector::getClientVersion() const { return pimpl->getClientSoftwareVersion(); } -Result Detector::getReceiverSoftwareVersion(Positions pos) const { +Result Detector::getReceiverVersion(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverSoftwareVersion, pos); } -std::string Detector::getUserDetailsFromSharedMemory() const { return pimpl->getUserDetails(); } +std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); } Result Detector::getDetectorType(Positions pos) const { return pimpl->Parallel(&slsDetector::getDetectorTypeAsEnum, pos); } -Result Detector::getDetectorTypeAsString(Positions pos) const { - return pimpl->Parallel(&slsDetector::getDetectorTypeAsString, pos); -} - int Detector::size() const { return pimpl->size(); } -defs::coordinates Detector::getNumberOfDetectors() const { - defs::coordinates coord; - coord.x = pimpl->getNumberOfDetectors(defs::X); - coord.y = pimpl->getNumberOfDetectors(defs::Y); - return coord; +defs::xy Detector::getModuleGeometry() const { + return pimpl->getNumberOfDetectors(); } -Result Detector::getNumberOfChannels(Positions pos) const { +Result Detector::getModuleSize(Positions pos) const { if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { // TODO: also check condition that pos.size == @@ -90,19 +75,11 @@ Result Detector::getNumberOfChannels(Positions pos) const { return pimpl->Parallel(&slsDetector::getNumberOfChannels, pos); } -Result -Detector::getNumberOfChannelsInclGapPixels(Positions pos) const { - if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) { - return {pimpl->getTotalNumberOfChannelsInclGapPixels()}; - } - return pimpl->Parallel(&slsDetector::getNumberOfChannelsInclGapPixels, pos); -} - -defs::coordinates Detector::getMaxNumberOfChannels() const { +defs::xy Detector::getDetectorSize() const { return pimpl->getMaxNumberOfChannels(); } -void Detector::setMaxNumberOfChannels(const defs::coordinates value) { +void Detector::setDetectorSize(const defs::xy value) { pimpl->setMaxNumberOfChannels(value); } @@ -110,16 +87,16 @@ Result Detector::getQuad(Positions pos) const { return pimpl->Parallel(&slsDetector::getQuad, pos); } -void Detector::setQuad(const bool value, Positions pos) { - pimpl->setQuad(value, 0); +void Detector::setQuad(const bool value) { + pimpl->setQuad(value); } -Result Detector::getReadNLines(Positions pos) const { +Result Detector::getPartialReadout(Positions pos) const { return pimpl->Parallel(&slsDetector::getReadNLines, pos); } -void Detector::setReadNLines(const int value, Positions pos) { - pimpl->Parallel(&slsDetector::setReadNLines, pos, value); +void Detector::setPartialReadout(const int lines, Positions pos) { + pimpl->Parallel(&slsDetector::setReadNLines, pos, lines); } Result Detector::getControlPort(Positions pos) const { @@ -138,30 +115,22 @@ void Detector::setStopPort(int value, Positions pos) { pimpl->Parallel(&slsDetector::setStopPort, pos, value); } -Result Detector::getLockServer(Positions pos) const { +Result Detector::getDetectorLock(Positions pos) const { return pimpl->Parallel(&slsDetector::lockServer, pos, -1); } -void Detector::setLockServer(bool value, Positions pos) { - pimpl->Parallel(&slsDetector::lockServer, pos, static_cast(value)); +void Detector::setDetectorLock(bool lock, Positions pos) { + pimpl->Parallel(&slsDetector::lockServer, pos, static_cast(lock)); } Result Detector::getLastClientIP(Positions pos) const { return pimpl->Parallel(&slsDetector::getLastClientIP, pos); } -void Detector::exitServer(Positions pos) { - pimpl->Parallel(&slsDetector::exitServer, pos); -} - void Detector::execCommand(const std::string &value, Positions pos) { pimpl->Parallel(&slsDetector::execCommand, pos, value); } -void Detector::writeConfigurationFile(const std::string &value) { - pimpl->writeConfigurationFile(value); -} - Result Detector::getSettings(Positions pos) const { return pimpl->Parallel(&slsDetector::getSettings, pos); } @@ -174,9 +143,9 @@ Result Detector::getThresholdEnergy(Positions pos) const { return pimpl->Parallel(&slsDetector::getThresholdEnergy, pos); } -void Detector::setThresholdEnergy(int value, defs::detectorSettings sett, - int tb, Positions pos) { - pimpl->Parallel(&slsDetector::setThresholdEnergy, pos, value, sett, tb); +void Detector::setThresholdEnergy(int threshold_ev, defs::detectorSettings settings, + bool trimbits, Positions pos) { + pimpl->Parallel(&slsDetector::setThresholdEnergy, pos, threshold_ev, settings, static_cast(trimbits)); } Result Detector::getSettingsDir(Positions pos) const { @@ -187,14 +156,10 @@ void Detector::setSettingsDir(const std::string &value, Positions pos) { pimpl->Parallel(&slsDetector::setSettingsDir, pos, value); } -void Detector::loadSettingsFile(const std::string &value, Positions pos) { +void Detector::loadTrimbits(const std::string &value, Positions pos) { pimpl->Parallel(&slsDetector::loadSettingsFile, pos, value); } -void Detector::saveSettingsFile(const std::string &value, Positions pos) { - pimpl->Parallel(&slsDetector::saveSettingsFile, pos, value); -} - void Detector::configureMAC(Positions pos) { pimpl->Parallel(&slsDetector::configureMAC, pos); } @@ -207,11 +172,11 @@ void Detector::setNumberOfFrames(int64_t value) { pimpl->Parallel(&slsDetector::setTimer, {}, defs::FRAME_NUMBER, value); } -Result Detector::getNumberOfCycles() const { +Result Detector::getNumberOfTriggers() const { return pimpl->Parallel(&slsDetector::setTimer, {}, defs::CYCLES_NUMBER, -1); } -void Detector::setNumberOfCycles(int64_t value) { +void Detector::setNumberOfTriggers(int64_t value) { pimpl->Parallel(&slsDetector::setTimer, {}, defs::CYCLES_NUMBER, value); } @@ -220,7 +185,7 @@ Result Detector::getNumberOfAdditionalStorageCells() const { defs::STORAGE_CELL_NUMBER, -1); } -void Detector::setNumberOfStorageCells(int64_t value) { +void Detector::setNumberOfAdditionalStorageCells(int64_t value) { pimpl->Parallel(&slsDetector::setTimer, {}, defs::STORAGE_CELL_NUMBER, value); } @@ -695,10 +660,10 @@ void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) { pimpl->Parallel(&slsDetector::clearBit, pos, addr, bitnr); } -Result Detector::getDetectorMAC(Positions pos) const { +Result Detector::getSourceUDPMAC(Positions pos) const { return pimpl->Parallel(&slsDetector::getDetectorMAC, pos); } -void Detector::setDetectorMAC(const std::string &detectorMAC, Positions pos) { +void Detector::setSourceUDPMAC(const std::string &detectorMAC, Positions pos) { pimpl->Parallel(&slsDetector::setDetectorMAC, pos, detectorMAC); } @@ -709,11 +674,11 @@ void Detector::setDetectorMAC2(const std::string &detectorMAC, Positions pos) { pimpl->Parallel(&slsDetector::setDetectorMAC2, pos, detectorMAC); } -Result Detector::getDetectorIP(Positions pos) const { +Result Detector::getSourceUDPIP(Positions pos) const { return pimpl->Parallel(&slsDetector::getDetectorIP, pos); } -void Detector::setDetectorIP(const std::string &detectorIP, Positions pos) { +void Detector::setSourceUDPIP(const std::string &detectorIP, Positions pos) { pimpl->Parallel(&slsDetector::setDetectorIP, pos, detectorIP); } @@ -733,11 +698,11 @@ void Detector::setReceiverHostname(const std::string &receiver, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverHostname, pos, receiver); } -Result Detector::getReceiverUDPIP(Positions pos) const { +Result Detector::getDestinationUDPIP(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverUDPIP, pos); } -void Detector::setReceiverUDPIP(const std::string &udpip, Positions pos) { +void Detector::setDestinationUDPIP(const std::string &udpip, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverUDPIP, pos, udpip); } @@ -749,11 +714,11 @@ void Detector::setReceiverUDPIP2(const std::string &udpip, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverUDPIP2, pos, udpip); } -Result Detector::getReceiverUDPMAC(Positions pos) const { +Result Detector::getDestinationUDPMAC(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverUDPMAC, pos); } -void Detector::setReceiverUDPMAC(const std::string &udpmac, Positions pos) { +void Detector::setDestinationUDPMAC(const std::string &udpmac, Positions pos) { pimpl->Parallel(&slsDetector::setReceiverUDPMAC, pos, udpmac); } @@ -1379,14 +1344,6 @@ Result Detector::getReceiverLastClientIP(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverLastClientIP, pos); } -void Detector::exitReceiver(Positions pos) { - pimpl->Parallel(&slsDetector::exitReceiver, pos); -} - -void Detector::execReceiverCommand(const std::string &cmd, Positions pos) { - pimpl->Parallel(&slsDetector::execReceiverCommand, pos, cmd); -} - Result Detector::getReceiverStreamingFrequency(Positions pos) const { return pimpl->Parallel(&slsDetector::setReceiverStreamingTimer, pos, -1); } @@ -1484,36 +1441,33 @@ Detector::getReceiverRealUDPSocketBufferSize(Positions pos) const { // Acquisition void Detector::acquire() { pimpl->acquire(); } -bool Detector::getAcquiringFlag() const { return pimpl->getAcquiringFlag(); } +void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); } -void Detector::setAcquiringFlag(bool value) { pimpl->setAcquiringFlag(value); } - -Result Detector::getRunStatus(Positions pos) { +Result Detector::getDetectorStatus(Positions pos) const{ return pimpl->Parallel(&slsDetector::getRunStatus, pos); } void Detector::startAcquisition() { - pimpl->startAcquisition(); + if (getUseReceiverFlag({}).squash()) + pimpl->Parallel(&slsDetector::startReceiver, {}); + pimpl->Parallel(&slsDetector::startAcquisition, {}); } -void Detector::stopAcquisition() { pimpl->stopAcquisition(); } +void Detector::stopAcquisition() { + pimpl->Parallel(&slsDetector::stopAcquisition, {}); + if (getUseReceiverFlag({}).squash()) //TODO: problem for acquire() + pimpl->Parallel(&slsDetector::stopReceiver, {}); +} void Detector::sendSoftwareTrigger(Positions pos) { pimpl->Parallel(&slsDetector::sendSoftwareTrigger, pos); } -void Detector::startReceiver(Positions pos) { - pimpl->Parallel(&slsDetector::startReceiver, pos); -} -void Detector::stopReceiver(Positions pos) { - pimpl->Parallel(&slsDetector::stopReceiver, pos); -} - -Result Detector::getReceiverStatus(Positions pos) { +Result Detector::getReceiverStatus(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverStatus, pos); } -Result Detector::getFramesCaughtByReceiver(Positions pos) const { +Result Detector::getFramesCaught(Positions pos) const { return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos); } @@ -1521,10 +1475,6 @@ Result Detector::getReceiverCurrentFrameIndex(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverCurrentFrameIndex, pos); } -void Detector::resetFramesCaught(Positions pos) { - pimpl->Parallel(&slsDetector::resetFramesCaught, pos); -} - // pattern void Detector::setPattern(const std::string &fname, Positions pos) { diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 90d9f1413..4424bc84d 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -278,13 +278,10 @@ void multiSlsDetector::initializeDetectorStructure() { multi_shm()->multiDetectorType = GENERIC; multi_shm()->numberOfDetector[X] = 0; multi_shm()->numberOfDetector[Y] = 0; - multi_shm()->numberOfChannels = 0; - multi_shm()->numberOfChannel[X] = 0; - multi_shm()->numberOfChannel[Y] = 0; - multi_shm()->numberOfChannelInclGapPixels[X] = 0; - multi_shm()->numberOfChannelInclGapPixels[Y] = 0; - multi_shm()->maxNumberOfChannelsPerDetector[X] = -1; - multi_shm()->maxNumberOfChannelsPerDetector[Y] = -1; + multi_shm()->numberOfChannels[X] = 0; + multi_shm()->numberOfChannels[Y] = 0; + multi_shm()->maxNumberOfChannels[X] = 0; + multi_shm()->maxNumberOfChannels[Y] = 0; multi_shm()->acquiringFlag = false; multi_shm()->receiver_upstream = false; } @@ -425,7 +422,6 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) { detectors.push_back( sls::make_unique(type, multiId, pos, false)); multi_shm()->numberOfDetectors = detectors.size(); - multi_shm()->numberOfChannels += detectors[pos]->getTotalNumberOfChannels(); detectors[pos]->setHostname(hostname); multi_shm()->multiDetectorType = getDetectorTypeAsEnum(-1);// -1 needed here } @@ -433,17 +429,12 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) { void multiSlsDetector::updateDetectorSize() { FILE_LOG(logDEBUG) << "Updating Multi-Detector Size: " << size(); - int my = detectors[0]->getTotalNumberOfChannels(Y); - int mx = detectors[0]->getTotalNumberOfChannels(X); - int mgy = detectors[0]->getTotalNumberOfChannelsInclGapPixels(Y); - int mgx = detectors[0]->getTotalNumberOfChannelsInclGapPixels(X); - if (mgy == 0) { - mgy = my; - mgx = mx; - } + slsDetectorDefs::xy res = detectors[0]->getNumberOfChannels(); + int my = res.x; + int mx = res.y; - int maxy = multi_shm()->maxNumberOfChannelsPerDetector[Y]; - if (maxy == -1) { + int maxy = multi_shm()->maxNumberOfChannels[Y]; + if (maxy == 0) { maxy = my * size(); } @@ -455,10 +446,8 @@ void multiSlsDetector::updateDetectorSize() { multi_shm()->numberOfDetector[X] = ndetx; multi_shm()->numberOfDetector[Y] = ndety; - multi_shm()->numberOfChannel[X] = mx * ndetx; - multi_shm()->numberOfChannel[Y] = my * ndety; - multi_shm()->numberOfChannelInclGapPixels[X] = mgx * ndetx; - multi_shm()->numberOfChannelInclGapPixels[Y] = mgy * ndety; + multi_shm()->numberOfChannels[X] = mx * ndetx; + multi_shm()->numberOfChannels[Y] = my * ndety; FILE_LOG(logDEBUG) << "\n\tNumber of Detectors in X direction:" @@ -466,22 +455,19 @@ void multiSlsDetector::updateDetectorSize() { << "\n\tNumber of Detectors in Y direction:" << multi_shm()->numberOfDetector[Y] << "\n\tNumber of Channels in X direction:" - << multi_shm()->numberOfChannel[X] + << multi_shm()->numberOfChannels[X] << "\n\tNumber of Channels in Y direction:" - << multi_shm()->numberOfChannel[Y] - << "\n\tNumber of Channels in X direction with Gap Pixels:" - << multi_shm()->numberOfChannelInclGapPixels[X] - << "\n\tNumber of Channels in Y direction with Gap Pixels:" - << multi_shm()->numberOfChannelInclGapPixels[Y]; + << multi_shm()->numberOfChannels[Y]; - multi_shm()->numberOfChannels = - multi_shm()->numberOfChannel[0] * multi_shm()->numberOfChannel[1]; for (auto &d : detectors) { d->updateMultiSize(multi_shm()->numberOfDetector[0], multi_shm()->numberOfDetector[1]); } -} + + multi_shm()->maxNumberOfChannels[X] = multi_shm()->numberOfChannels[X]; + multi_shm()->maxNumberOfChannels[Y] = multi_shm()->numberOfChannels[Y]; + } slsDetectorDefs::detectorType multiSlsDetector::getDetectorTypeAsEnum() const { return multi_shm()->multiDetectorType; @@ -512,86 +498,43 @@ std::string multiSlsDetector::getDetectorTypeAsString(int detPos) { size_t multiSlsDetector::size() const { return detectors.size(); } -int multiSlsDetector::getNumberOfDetectors(dimension d) const { - return multi_shm()->numberOfDetector[d]; +slsDetectorDefs::xy multiSlsDetector::getNumberOfDetectors() const { + slsDetectorDefs::xy res; + res.x = multi_shm()->numberOfDetector[X]; + res.y = multi_shm()->numberOfDetector[Y]; + return res; } -void multiSlsDetector::getNumberOfDetectors(int &nx, int &ny) const { - nx = multi_shm()->numberOfDetector[X]; - ny = multi_shm()->numberOfDetector[Y]; -} - -int multiSlsDetector::getTotalNumberOfChannels(int detPos) { +slsDetectorDefs::xy multiSlsDetector::getNumberOfChannels(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->getTotalNumberOfChannels(); + return detectors[detPos]->getNumberOfChannels(); } // multi - return multi_shm()->numberOfChannels; -} - -int multiSlsDetector::getTotalNumberOfChannels(dimension d, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getTotalNumberOfChannels(d); - } - - // multi - return multi_shm()->numberOfChannel[d]; -} - -slsDetectorDefs::coordinates multiSlsDetector::getNumberOfChannels() const { - slsDetectorDefs::coordinates coord; - coord.x = multi_shm()->numberOfChannel[X]; - coord.y = multi_shm()->numberOfChannel[Y]; + slsDetectorDefs::xy coord; + coord.x = multi_shm()->numberOfChannels[X]; + coord.y = multi_shm()->numberOfChannels[Y]; return coord; } -int multiSlsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getTotalNumberOfChannelsInclGapPixels(d); - } - - // multi - return multi_shm()->numberOfChannelInclGapPixels[d]; -} - -slsDetectorDefs::coordinates multiSlsDetector::getTotalNumberOfChannelsInclGapPixels() const { - slsDetectorDefs::coordinates coord; - coord.x = multi_shm()->numberOfChannelInclGapPixels[X]; - coord.y = multi_shm()->numberOfChannelInclGapPixels[Y]; +slsDetectorDefs::xy multiSlsDetector::getMaxNumberOfChannels() const { + slsDetectorDefs::xy coord; + coord.x = multi_shm()->maxNumberOfChannels[X]; + coord.y = multi_shm()->maxNumberOfChannels[Y]; return coord; } -int multiSlsDetector::getMaxNumberOfChannelsPerDetector(dimension d) { - return multi_shm()->maxNumberOfChannelsPerDetector[d]; -} - -int multiSlsDetector::setMaxNumberOfChannelsPerDetector(dimension d, int i) { - multi_shm()->maxNumberOfChannelsPerDetector[d] = i; - return multi_shm()->maxNumberOfChannelsPerDetector[d]; -} - -slsDetectorDefs::coordinates multiSlsDetector::getMaxNumberOfChannels() const { - slsDetectorDefs::coordinates coord; - coord.x = multi_shm()->maxNumberOfChannelsPerDetector[X]; - coord.y = multi_shm()->maxNumberOfChannelsPerDetector[Y]; - return coord; -} - -void multiSlsDetector::setMaxNumberOfChannels(const slsDetectorDefs::coordinates c) { - multi_shm()->maxNumberOfChannelsPerDetector[X] = c.x; - multi_shm()->maxNumberOfChannelsPerDetector[Y] = c.y; +void multiSlsDetector::setMaxNumberOfChannels(const slsDetectorDefs::xy c) { + multi_shm()->maxNumberOfChannels[X] = c.x; + multi_shm()->maxNumberOfChannels[Y] = c.y; } int multiSlsDetector::getQuad(int detPos) { int retval = detectors[0]->getQuad(); if (retval && size() > 1) { throw RuntimeError("Quad type is available only for 1 Eiger Quad Half " - "module, but it Quad is enabled for 1st readout"); + "module, but Quad is enabled for 1st readout"); } return retval; } @@ -1959,7 +1902,7 @@ void multiSlsDetector::loadImageToDetector(imageType index, // multi // read image for all - int nch = multi_shm()->numberOfChannels; + int nch = getNumberOfChannels().x; short int imageVals[nch]; if (readDataFile(fname, imageVals, nch) < nch * (int)sizeof(short int)) { throw RuntimeError("Could not open file or not enough data in file to " @@ -1968,7 +1911,7 @@ void multiSlsDetector::loadImageToDetector(imageType index, // send image to all for (size_t idet = 0; idet < detectors.size(); ++idet) { - detectors[idet]->sendImageToDetector(index, imageVals + idet * detectors[idet]->getTotalNumberOfChannels()); + detectors[idet]->sendImageToDetector(index, imageVals + idet * detectors[idet]->getNumberOfChannels().x); } } @@ -1980,11 +1923,11 @@ void multiSlsDetector::writeCounterBlockFile(const std::string &fname, } // multi - int nch = multi_shm()->numberOfChannels; + int nch = getNumberOfChannels().x; short int imageVals[nch]; for (size_t idet = 0; idet < detectors.size(); ++idet) { detectors[idet]->getCounterBlock( - imageVals + idet * detectors[idet]->getTotalNumberOfChannels(), + imageVals + idet * detectors[idet]->getNumberOfChannels().x, startACQ); } @@ -2255,16 +2198,27 @@ int multiSlsDetector::enableGapPixels(int val, int detPos) { int ret = sls::minusOneIfDifferent(r); if (val != -1) { - multi_shm()->numberOfChannelInclGapPixels[X] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, X)); - multi_shm()->numberOfChannelInclGapPixels[Y] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, Y)); + Parallel(&slsDetector::enableGapPixels, {}, val); + Result res = Parallel(&slsDetector::getNumberOfChannels, {}); + multi_shm()->numberOfChannels[X] = 0; + multi_shm()->numberOfChannels[Y] = 0; + for (auto &it : res) { + multi_shm()->numberOfChannels[X] += it.x; + multi_shm()->numberOfChannels[Y] += it.y; + } } return ret; } void multiSlsDetector::setGapPixelsEnable(bool enable, Positions pos){ Parallel(&slsDetector::enableGapPixels, pos, static_cast(enable)); - multi_shm()->numberOfChannelInclGapPixels[X] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, X)); - multi_shm()->numberOfChannelInclGapPixels[Y] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, Y)); + Result res = Parallel(&slsDetector::getNumberOfChannels, {}); + multi_shm()->numberOfChannels[X] = 0; + multi_shm()->numberOfChannels[Y] = 0; + for (auto &it : res) { + multi_shm()->numberOfChannels[X] += it.x; + multi_shm()->numberOfChannels[Y] += it.y; + } } int multiSlsDetector::setTrimEn(std::vector energies, int detPos) { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index faa8eb011..aa523aa7d 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -414,17 +414,9 @@ void slsDetector::initializeDetectorStructure(detectorType type) { shm()->nChans = shm()->nChan[X] * shm()->nChan[Y]; shm()->nChips = shm()->nChip[X] * shm()->nChip[Y]; - // calculating databytes - shm()->dataBytes = shm()->nChips * shm()->nChans * shm()->dynamicRange / 8; - shm()->dataBytesInclGapPixels = (shm()->nChip[X] * shm()->nChan[X] + - shm()->gappixels * shm()->nGappixels[X]) * - (shm()->nChip[Y] * shm()->nChan[Y] + - shm()->gappixels * shm()->nGappixels[Y]) * - shm()->dynamicRange / 8; - - // update #nchans and databytes, as it depends on #samples, adcmask, + // update #nchans, as it depends on #samples, adcmask, // readoutflags (ctb only) - updateTotalNumberOfChannels(); + updateNumberOfChannels(); } int slsDetector::sendModule(sls_detector_module *myMod, @@ -574,16 +566,11 @@ std::string slsDetector::getDetectorTypeAsString() const { return slsDetectorDefs::detectorTypeToString(getDetectorTypeAsEnum()); } -int slsDetector::getTotalNumberOfChannels() const { - return shm()->nChans * shm()->nChips; -} - -void slsDetector::updateTotalNumberOfChannels() { +void slsDetector::updateNumberOfChannels() { if (shm()->myDetectorType == CHIPTESTBOARD || shm()->myDetectorType == MOENCH) { int nachans = 0, ndchans = 0; - int adatabytes = 0, ddatabytes = 0; // analog channels (normal, analog/digital readout) if (shm()->roFlags == slsDetectorDefs::NORMAL_READOUT || ((shm()->roFlags & slsDetectorDefs::ANALOG_AND_DIGITAL) != 0)) { @@ -596,10 +583,7 @@ void slsDetector::updateTotalNumberOfChannels() { ++nachans; } } - adatabytes = nachans * (shm()->dynamicRange / 8) * - shm()->timerValue[ANALOG_SAMPLES]; - FILE_LOG(logDEBUG1) << "#Analog Channels:" << nachans - << " Databytes: " << adatabytes; + FILE_LOG(logDEBUG1) << "#Analog Channels:" << nachans; } // digital channels (ctb only, digital, analog/digital readout) @@ -607,50 +591,20 @@ void slsDetector::updateTotalNumberOfChannels() { (((shm()->roFlags & DIGITAL_ONLY) != 0) || ((shm()->roFlags & ANALOG_AND_DIGITAL) != 0))) { ndchans = 64; - ddatabytes = - (sizeof(uint64_t) * shm()->timerValue[DIGITAL_SAMPLES]); - FILE_LOG(logDEBUG1) << "#Digital Channels:" << ndchans - << " Databytes: " << ddatabytes; + FILE_LOG(logDEBUG1) << "#Digital Channels:" << ndchans; } shm()->nChans = nachans + ndchans; - shm()->dataBytes = adatabytes + ddatabytes; - FILE_LOG(logDEBUG1) << "# Total #Channels:" << shm()->nChans - << " Databytes: " << shm()->dataBytes; + FILE_LOG(logDEBUG1) << "# Total #Channels:" << shm()->nChans; } } -int slsDetector::getTotalNumberOfChannels(dimension d) const { - return shm()->nChan[d] * shm()->nChip[d]; -} - -slsDetectorDefs::coordinates slsDetector::getNumberOfChannels() const { - slsDetectorDefs::coordinates coord; - coord.x = shm()->nChan[X] * shm()->nChip[X]; - coord.y = shm()->nChan[Y] * shm()->nChip[Y]; - return coord; -} - -int slsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) const { - return (shm()->nChan[d] * shm()->nChip[d] + - shm()->gappixels * shm()->nGappixels[d]); -} - -slsDetectorDefs::coordinates slsDetector::getNumberOfChannelsInclGapPixels() const { - slsDetectorDefs::coordinates coord; +slsDetectorDefs::xy slsDetector::getNumberOfChannels() const { + slsDetectorDefs::xy coord; coord.x = (shm()->nChan[X] * shm()->nChip[X] + shm()->gappixels * shm()->nGappixels[X]); coord.y = (shm()->nChan[Y] * shm()->nChip[Y] + shm()->gappixels * shm()->nGappixels[Y]); return coord; } - -int slsDetector::getNChans() const { return shm()->nChans; } - -int slsDetector::getNChans(dimension d) const { return shm()->nChan[d]; } - -int slsDetector::getNChips() const { return shm()->nChips; } - -int slsDetector::getNChips(dimension d) const { return shm()->nChip[d]; } - bool slsDetector::getQuad() { int retval = -1; FILE_LOG(logDEBUG1) << "Getting Quad Type"; @@ -785,11 +739,7 @@ void slsDetector::updateCachedDetectorVariables() { // dr n += client.Receive(&i32, sizeof(i32)); - shm()->dynamicRange = i32; - - // databytes - n += client.Receive(&i32, sizeof(i32)); - shm()->dataBytes = i32; + shm()->dynamicRange = i32; // settings if ((shm()->myDetectorType != CHIPTESTBOARD) && @@ -881,9 +831,9 @@ void slsDetector::updateCachedDetectorVariables() { if (shm()->myDetectorType == MOENCH) setAdditionalJsonParameter("adcmask", std::to_string(u32)); - // update #nchans and databytes, as it depends on #samples, adcmask, + // update #nchans, as it depends on #samples, adcmask, // readoutflags - updateTotalNumberOfChannels(); + updateNumberOfChannels(); } if (n == 0) { @@ -1390,10 +1340,10 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { sendToDetector(F_SET_TIMER, args, retval); FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval; shm()->timerValue[index] = retval; - // update #nchans and databytes, as it depends on #samples, adcmask, + // update #nchans, as it depends on #samples, adcmask, // readoutflags if (index == ANALOG_SAMPLES || index == DIGITAL_SAMPLES) { - updateTotalNumberOfChannels(); + updateNumberOfChannels(); } // setting timers consequences (eiger (ratecorr) ) @@ -1477,27 +1427,10 @@ int slsDetector::setDynamicRange(int n) { // TODO! Properly handle fail int retval = -1; FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n; - int olddr = shm()->dynamicRange; sendToDetector(F_SET_DYNAMIC_RANGE, n, retval); FILE_LOG(logDEBUG1) << "Dynamic Range: " << retval; shm()->dynamicRange = retval; - // only for eiger - // setting dr consequences on databytes shm - // (a get can also change timer value, hence check difference) - if (olddr != shm()->dynamicRange) { - shm()->dataBytes = shm()->nChips * shm()->nChans * retval / 8; - shm()->dataBytesInclGapPixels = - (shm()->nChip[X] * shm()->nChan[X] + - shm()->gappixels * shm()->nGappixels[X]) * - (shm()->nChip[Y] * shm()->nChan[Y] + - shm()->gappixels * shm()->nGappixels[Y]) * - retval / 8; - FILE_LOG(logDEBUG1) << "Data bytes " << shm()->dataBytes; - FILE_LOG(logDEBUG1) << "Data bytes including gap pixels" - << shm()->dataBytesInclGapPixels; - } - if (shm()->useReceiverFlag) { n = shm()->dynamicRange; retval = -1; @@ -1512,12 +1445,6 @@ int slsDetector::getDynamicRangeFromShm() { return shm()->dynamicRange; } -int slsDetector::getDataBytes() { return shm()->dataBytes; } - -int slsDetector::getDataBytesInclGapPixels() { - return shm()->dataBytesInclGapPixels; -} - int slsDetector::setDAC(int val, dacIndex index, int mV) { int args[]{static_cast(index), mV, val}; int retval = -1; @@ -1565,10 +1492,10 @@ int slsDetector::setReadOutFlags(readOutFlags flag) { sendToDetector(F_SET_READOUT_FLAGS, arg, retval); FILE_LOG(logDEBUG1) << "Readout flag: " << retval; shm()->roFlags = retval; - // update #nchans and databytes, as it depends on #samples, adcmask, + // update #nchans, as it depends on #samples, adcmask, // readoutflags if (shm()->myDetectorType == CHIPTESTBOARD) { - updateTotalNumberOfChannels(); + updateNumberOfChannels(); } FILE_LOG(logDEBUG1) << "Setting receiver readout flags to " << arg; if (shm()->useReceiverFlag) { @@ -2246,7 +2173,7 @@ int slsDetector::digitalTest(digitalTestMode mode, int ival) { void slsDetector::loadImageToDetector(imageType index, const std::string &fname) { - int nChan = getTotalNumberOfChannels(); + int nChan = getNumberOfChannels().x; int16_t args[nChan]; FILE_LOG(logDEBUG1) << "Loading " << (index == 0u ? "Dark" : "Gain") << "image from file " << fname; @@ -2261,7 +2188,7 @@ void slsDetector::loadImageToDetector(imageType index, void slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) { int fnum = F_LOAD_IMAGE; - int nChan = getTotalNumberOfChannels(); + int nChan = getNumberOfChannels().x; int args[]{static_cast(index), nChan}; FILE_LOG(logDEBUG1) << "Sending image to detector"; auto client = DetectorSocket(shm()->hostname, shm()->controlPort); @@ -2281,7 +2208,7 @@ void slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) { void slsDetector::writeCounterBlockFile(const std::string &fname, int startACQ) { - int nChan = getTotalNumberOfChannels(); + int nChan = getNumberOfChannels().x; int16_t retvals[nChan]; FILE_LOG(logDEBUG1) << "Reading Counter to " << fname << (startACQ != 0 ? " and Restarting Acquisition" @@ -2292,7 +2219,7 @@ void slsDetector::writeCounterBlockFile(const std::string &fname, void slsDetector::getCounterBlock(int16_t image[], int startACQ) { int fnum = F_READ_COUNTER_BLOCK; - int nChan = getTotalNumberOfChannels(); + int nChan = getNumberOfChannels().x; int args[] = {startACQ, nChan}; FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ; sendToDetector(fnum, args, sizeof(args), image, nChan * sizeof(int16_t)); @@ -2322,7 +2249,7 @@ void slsDetector::clearROI() { void slsDetector::setROI(slsDetectorDefs::ROI arg) { int fnum = F_SET_ROI; int ret = FAIL; - if (arg.xmin < 0 || arg.xmax >= getTotalNumberOfChannels()) { + if (arg.xmin < 0 || arg.xmax >= getNumberOfChannels().x) { arg.xmin = -1; arg.xmax = -1; } @@ -2403,9 +2330,9 @@ void slsDetector::setADCEnableMask(uint32_t mask) { sendToDetector(F_SET_ADC_ENABLE_MASK, &arg, sizeof(arg), nullptr, 0); shm()->adcEnableMask = mask; - // update #nchans and databytes, as it depends on #samples, adcmask, + // update #nchans, as it depends on #samples, adcmask, // readoutflags - updateTotalNumberOfChannels(); + updateNumberOfChannels(); // send to processor if (shm()->myDetectorType == MOENCH) @@ -2592,16 +2519,6 @@ int slsDetector::enableGapPixels(int val) { sendToReceiver(fnum, &val, sizeof(val), &retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Gap pixels enable to receiver:" << retval; shm()->gappixels = retval; - // update databytes - shm()->dataBytesInclGapPixels = 0; - if (shm()->dynamicRange != 4) { - shm()->dataBytesInclGapPixels = - (shm()->nChip[X] * shm()->nChan[X] + - shm()->gappixels * shm()->nGappixels[X]) * - (shm()->nChip[Y] * shm()->nChan[Y] + - shm()->gappixels * shm()->nGappixels[Y]) * - shm()->dynamicRange / 8; - } } } return shm()->gappixels; diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index 3c3a7c36a..1a72cec51 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -322,7 +322,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { ++i; /*! \page config - - detsizechan [xmax] [ymax] sets the maximum number of channels in each dimension for complete detector set; -1 is no limit. Use for multi-detector system as first command in config file. \c Returns \c ("int int") + - detsizechan [xmax] [ymax] sets the maximum number of channels in each dimension for complete detector set; 0 is no limit. Use for multi-detector system as first command in config file. \c Returns \c ("int int") */ descrToFuncMap[i].m_pFuncName = "detsizechan"; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDetectorSize; @@ -3284,10 +3284,14 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg } if (cmd == "detsizechan") { - if ((sscanf(args[1], "%d", &val)) && (val > 0)) - myDet->setMaxNumberOfChannelsPerDetector(X, val); - if ((narg > 2) && (sscanf(args[2], "%d", &val)) && (val > 0)) - myDet->setMaxNumberOfChannelsPerDetector(Y, val); + int val2 = 0; + if ((!sscanf(args[1], "%d", &val)) || (narg <= 2) || (!sscanf(args[2], "%d", &val2))) { + return std::string("Could not scan det size chan values"); + } + slsDetectorDefs::xy res; + res.x = val; + res.y = val2; + myDet->setMaxNumberOfChannels(res); } if(cmd=="quad"){ @@ -3331,7 +3335,8 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg ROI roi = myDet->getROI(detPos); return (std::string("[") + std::to_string(roi.xmin) + std::string(",") + std::to_string(roi.xmax) + std::string("]")); } else if (cmd == "detsizechan") { - sprintf(ans, "%d %d", myDet->getMaxNumberOfChannelsPerDetector(X), myDet->getMaxNumberOfChannelsPerDetector(Y)); + slsDetectorDefs::xy res = myDet->getMaxNumberOfChannels(); + sprintf(ans, "%d %d", res.x, res.y); return std::string(ans); } else if (cmd=="quad") { return std::to_string(myDet->getQuad()); @@ -3362,7 +3367,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) { os << "dr i \n sets the dynamic range of the detector" << std::endl; os << "clearroi \n resets region of interest" << std::endl; os << "roi xmin xmax \n sets region of interest " << std::endl; - os << "detsizechan x y \n sets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl; + os << "detsizechan x y \n sets the maximum number of channels for complete detector set in both directions; 0 is no limit" << std::endl; os << "quad i \n if i = 1, sets the detector size to a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl; os << "flippeddatax x \n sets if the data should be flipped on the x axis" << std::endl; os << "flippeddatay y \n sets if the data should be flipped on the y axis" << std::endl; @@ -3371,7 +3376,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) { if (action == GET_ACTION || action == HELP_ACTION) { os << "dr \n gets the dynamic range of the detector" << std::endl; os << "roi \n gets region of interest" << std::endl; - os << "detsizechan \n gets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl; + os << "detsizechan \n gets the maximum number of channels for complete detector set in both directions; 0 is no limit" << std::endl; os << "quad \n returns 1 if the detector size is a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl; os << "flippeddatax\n gets if the data will be flipped on the x axis" << std::endl; os << "flippeddatay\n gets if the data will be flipped on the y axis" << std::endl; diff --git a/slsDetectorSoftware/src/slsDetectorUsers.cpp b/slsDetectorSoftware/src/slsDetectorUsers.cpp index 8e89ca408..ec24f7dd4 100755 --- a/slsDetectorSoftware/src/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/src/slsDetectorUsers.cpp @@ -9,14 +9,16 @@ int slsDetectorUsers::size() const { } int slsDetectorUsers::getMaximumDetectorSize(int &nx, int &ny){ - nx=detector.getMaxNumberOfChannelsPerDetector(slsDetectorDefs::X); - ny=detector.getMaxNumberOfChannelsPerDetector(slsDetectorDefs::Y); + slsDetectorDefs::xy res = detector.getMaxNumberOfChannels(); + nx=res.x; + ny=res.y; return nx*ny; } int slsDetectorUsers::getDetectorSize(int &nx, int &ny, int detPos){ - nx=detector.getTotalNumberOfChannels(slsDetectorDefs::X, detPos); - ny=detector.getTotalNumberOfChannels(slsDetectorDefs::Y, detPos); + slsDetectorDefs::xy res = detector.getNumberOfChannels(); + nx=res.x; + ny=res.y; return nx*ny; } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 816836d9e..f9d2f9b00 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -292,7 +292,7 @@ format }; #ifdef __cplusplus - struct coordinates { + struct xy { int x{0}; int y{0}; };