diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 18ab1ea3b..702b5bae6 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index fc26c2c3b..698745633 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index cbc6eae02..1f8ecfcd1 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index b4ddf576e..c42593836 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index aafccc72c..b8f1a6ebd 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 7df2acc7e..a11a7ae72 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1167,12 +1167,12 @@ int set_dac(int file_des) { if (val != -1) { //changing dac changes settings to undefined switch(serverDacIndex) { - case VCMP_LL: - case VCMP_LR: - case VCMP_RL: - case VCMP_RR: - case VRF: - case VCP: + case E_VCMP_LL: + case E_VCMP_LR: + case E_VCMP_RL: + case E_VCMP_RR: + case E_VRF: + case E_VCP: setSettings(UNDEFINED); FILE_LOG(logERROR, ("Settings has been changed " "to undefined (changed specific dacs)\n")); @@ -2495,6 +2495,13 @@ int send_update(int file_des) { if (n < 0) return printSocketReadError(); #endif + // num udp interfaces +#ifdef JUNGFRAUD + i32 = getNumberofUDPInterfaces(); + n = sendData(file_des,&i32,sizeof(i32),INT32); + if (n < 0) return printSocketReadError(); +#endif + if (lockStatus == 0) { lastClientIP = thisClientIP; } diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index c493f933b..2e880fd2c 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -221,93 +221,24 @@ class multiSlsDetector : public virtual slsDetectorDefs { void parallelCall(void (slsDetector::*somefunc)(CT...) const, typename NonDeduced::type... Args) const; - /** - * Set acquiring flag in shared memory - * @param b acquiring flag - */ - void setAcquiringFlag(bool flag); // + /** set acquiring flag in shared memory */ + void setAcquiringFlag(bool flag); - /** - * Get acquiring flag from shared memory - * @returns acquiring flag - */ - bool getAcquiringFlag() const; // + /** return multi detector shared memory ID */ + int getMultiId() const; - /** - * Check version compatibility with detector software - * (if hostname/rx_hostname has been set/ sockets created) - * @param p port type control port or receiver port - * @param detPos -1 for all detectors in list or specific detector position - */ - void checkDetectorVersionCompatibility(int detPos = -1); // - - /** - * Check version compatibility with receiver software - * (if hostname/rx_hostname has been set/ sockets created) - * @param p port type control port or receiver port - * @param detPos -1 for all detectors in list or specific detector position - */ - void checkReceiverVersionCompatibility(int detPos = -1); // - - /** - * Get ID or version numbers - * @param mode version type - * @param detPos -1 for all detectors in list or specific detector position - * @returns Id or version number of that type - */ - int64_t getId(idMode mode, - int detPos = -1); // not needed anymore (later remove - // this_software_version from enum) - - int getMultiId() const { return multiId; } // part of multi also - - /** - * Get package version (git branch) - * @returns package version - */ std::string getPackageVersion() const; - /** - * Get Client Software version - * @returns client software version - */ - int64_t getClientSoftwareVersion() const; // + int64_t getClientSoftwareVersion() const; - /** - * Get Receiver software version - * @return receiver software version - */ - int64_t getReceiverSoftwareVersion(int detPos = -1); // + /** Free specific shared memory from the command line without creating object */ + static void freeSharedMemory(int multiId, int detPos = -1); - /** - * Get Detector Number - * @returns vector of detector number - */ - std::vector - getDetectorNumber(); // renamed to getDetectorSerialNumber - /** - * Free shared memory from the command line - * avoiding creating the constructor classes and mapping - * @param multiId multi detector Id - * @param detPos -1 for all detectors in list or specific detector position - */ - static void freeSharedMemory(int multiId, - int detPos = -1); // private or not needed + /** Free all modules from current multi Id shared memory and delete members */ + void freeSharedMemory(); - /** - * Free shared memory and delete shared memory structure - * occupied by the sharedMultiSlsDetector structure - * Clears all the vectors and bring - * object back to state before object creation amap - * @param detPos -1 for all detectors in list or specific detector position - */ - void freeSharedMemory(int detPos = -1); // - - /** - * Get user details of shared memory - * @returns string with user details - */ - std::string getUserDetails(); // part of multi + /** Get user details of shared memory */ + std::string getUserDetails(); /** * Connect to Virtual Detector Servers at local host @@ -316,1248 +247,27 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ void setVirtualDetectorServers(const int numdet, const int port); - /** - * Sets the hostname of all sls detectors in shared memory and updates local - * cache - * @param name hostname of all the sls detectors - */ - void setHostname( - const std::vector &name); // cannot set individually + /** Sets the hostname of all sls detectors in shared memory and updates local cache */ + void setHostname(const std::vector &name); - /** - * Sets the hostname of all sls detectors in shared memory - * Connects to them - * @param name concatenated hostname of all the sls detectors - * @param detPos -1 for all detectors in list or specific detector position - */ - void setHostname(const char *name, int detPos = -1); // not needed + /** Gets the total number of detectors */ + int size() const; - /** - * Gets the hostname of detector at particular position - * or concatenated hostnames of all the sls detectors - * @param detPos -1 for all detectors in list or specific detector position - * @returns concatenated hostnames of all detectors or hostname of specific - * one - */ - std::string getHostname(int detPos = -1) const; // + slsDetectorDefs::xy getNumberOfDetectors() const; - /** - * Get Detector type as an enum - * @returns detector type - */ - detectorType getDetectorTypeAsEnum() const; // + slsDetectorDefs::xy getNumberOfChannels() const; - /** - * Get Detector type for a particular sls detector or get the first one - * @param detPos -1 for all detectors in list or specific detector position - * @returns detector type of sls detector in position pos, if -1, returns - * the first det type - */ - detectorType getDetectorTypeAsEnum(int detPos); // + /** Must be set before setting hostname + * Sets maximum number of channels of all sls detectors */ + void setNumberOfChannels(const slsDetectorDefs::xy c); - /** - * Concatenates string types of all sls detectors or - * returns the detector type of the first sls detector - * @param detPos -1 for all detectors in list or specific detector position - * @returns detector type of sls detector in position pos, if -1, - * concatenates - */ - std::string getDetectorTypeAsString(int detPos = -1); // - - /** - * Returns the number of detectors in the multidetector structure - * @returns number of detectors - */ - size_t size() const; // - - /** - * Returns the number of detectors in each direction - */ - slsDetectorDefs::xy getNumberOfDetectors() const; // - - /** - * Returns the total number of channels of all sls detectors including gap - * pixels - * @param detPos -1 for all detectors in list or specific detector position - * @returns the total number of channels of all sls detectors including gap - * pixels - */ - slsDetectorDefs::xy getNumberOfChannels(int detPos = -1) const; // - - /** - * Must be set before setting hostname - * 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 setNumberOfChannels(const slsDetectorDefs::xy c); // - - /** - * Get Quad Type (Only for Eiger Quad detector hardware) - * @param detPos -1 for all detectors in list or specific detector position - * @returns quad type - */ - int getQuad(int detPos = -1); // - - /** - * Set Quad Type (Only for Eiger Quad detector hardware) - * @param enable true if quad type set, else false - * @param detPos -1 for all detectors in list or specific detector position - */ - void setQuad(const bool enable, int detPos = -1); // - - /** - * Set number of rows to read out (Only for Eiger) - * @param value number of lines - * @param detPos -1 for all detectors in list or specific detector position - */ - void setReadNLines(const int value, int detPos = -1); // - - /** - * Get number of rows to read out (Only for Eiger) - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of lines - */ - int getReadNLines(int detPos = -1); // - - /** - * Set/Gets TCP Port of the detector - * @param port_number (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns port number - */ - int setControlPort(int port_number = -1, int detPos = -1); // - - /** - * Set/Gets TCP STOP Port of the detector - * @param port_number (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns port number - */ - int setStopPort(int port_number = -1, int detPos = -1); // - - /** - * Set/Gets TCP Port of the receiver - * @param port_number (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns port number - */ - int setReceiverPort(int port_number = -1, int detPos = -1); // - - /** - * Get Receiver port - * @param detPos -1 for all detectors in list or specific detector position - * @returns vector of receiver port - */ - int getReceiverPort(int detPos = -1) const; // - - /** - * Lock server for this client IP - * @param p 0 to unlock, 1 to lock - * @param detPos -1 for all detectors in list or specific detector position - * @returns 1 for locked or 0 for unlocked - */ - int lockServer(int p = -1, int detPos = -1); // - - /** - * Exit detector server - * @param detPos -1 for all detectors in list or specific detector position - */ - void exitServer(int detPos = -1); // - - /** - * Execute a command on the detector server - * @param cmd command - * @param detPos -1 for all detectors in list or specific detector position - */ - void execCommand(const std::string &cmd, int detPos); // - - /** - * Load configuration from a configuration File - * @param fname configuration file name - */ - void readConfigurationFile(const std::string &fname); // - - /** - * Write current configuration to a file - * @param fname configuration file name - */ - void writeConfigurationFile(const std::string &fname); // - - /** - * Get detector settings - * @param detPos -1 for all detectors in list or specific detector position - * @returns current settings - */ - detectorSettings getSettings(int detPos = -1); // - - /** - * 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 threshold - * @param isettings settings - * @param detPos -1 for all detectors in list or specific detector position - * @returns current settings - */ - detectorSettings setSettings(detectorSettings isettings, - int detPos = -1); // - - /** - * Get threshold energy (Eiger) - * @param detPos -1 for all detectors in list or specific detector position - * @returns current threshold value for imod in ev (-1 failed) - */ - int getThresholdEnergy(int detPos = -1); // - - /** - * Set threshold energy (Eiger) - * @param e_eV threshold in eV - * @param isettings ev. change settings - * @param tb 1 to include trimbits, 0 to exclude - * @param detPos -1 for all detectors in list or specific detector position - * @returns current threshold value for imod in ev (-1 failed) - */ - int setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS, - int tb = 1, int detPos = -1); // - - /** - * Returns the detector trimbit/settings directory - * @param detPos -1 for all detectors in list or specific detector position - * @returns the trimbit/settings directory - */ - std::string getSettingsDir(int detPos = -1); // - - /** - * Sets the detector trimbit/settings directory - * @param s trimbits/settings directory - * @param detPos -1 for all detectors in list or specific detector position - * @returns the trimbit/settings directory - */ - std::string setSettingsDir(const std::string &directory, - int detPos = -1); // - - /** - * Loads the modules settings/trimbits reading from a specific file - * file name extension is automatically generated. - * @param fname specific settings/trimbits file - * @param detPos -1 for all detectors in list or specific detector position - */ - void loadSettingsFile(const std::string &fname, int detPos = -1); // - - /** - * Saves the modules settings/trimbits to a specific file - * file name extension is automatically generated. - * @param fname specific settings/trimbits file - * @param detPos -1 for all detectors in list or specific detector position - */ - void saveSettingsFile(const std::string &fname, int detPos = -1); // - - /** - * Configures in detector the destination for UDP packets - * @param detPos -1 for all detectors in list or specific detector position - */ - //void configureMAC(int detPos = -1); //TODO - - /** - * Set starting frame number for the next acquisition - * @param val starting frame number - * @param detPos -1 for all detectors in list or specific detector position - */ - void setStartingFrameNumber(const uint64_t value, int detPos = -1); // - - /** - * Get starting frame number for the next acquisition - * @param detPos -1 for all detectors in list or specific detector position - * @returns starting frame number - */ - uint64_t getStartingFrameNumber(int detPos = -1); // - - /** - * Set/get timer value (not all implemented for all detectors) - * @param index timer index - * @param t time in ns or number of...(e.g. frames, probes) - * @param detPos -1 for all detectors in list or specific detector position - * @returns timer set value in ns or number of...(e.g. frames, - * probes) - */ - int64_t setTimer(timerIndex index, int64_t t = -1, int detPos = -1); // - - /** - * Set/get exposure time - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns exposure time in ns, or s if specified - */ - double setExposureTime(double t = -1, bool inseconds = false, - int detPos = -1); // - - /** - * Set/get exposure period - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns exposure period in ns, or s if specified - */ - double setExposurePeriod(double t = -1, bool inseconds = false, - int detPos = -1); // - - /** - * Set/get delay after trigger (Gotthard, Jungfrau(not for this release)) - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns delay after trigger in ns, or s if specified - */ - double setDelayAfterTrigger(double t = -1, bool inseconds = false, - int detPos = -1); // - - /** - * (Advanced users) - * Set/get sub frame exposure time (Eiger in 32 bit mode) - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns sub frame exposure time in ns, or s if specified - */ - double setSubFrameExposureTime(double t = -1, bool inseconds = false, - int detPos = -1); // - - /** - * (Advanced users) - * Set/get sub frame dead time (Eiger in 32 bit mode) - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns sub frame dead time in ns, or s if specified - */ - double setSubFrameExposureDeadTime(double t = -1, bool inseconds = false, - int detPos = -1); // - - /** - * Set/get number of frames - * @param t number of frames (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of frames - */ - int64_t setNumberOfFrames(int64_t t = -1, int detPos = -1); // - - /** - * Set/get number of triggers - * @param t number of triggers (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of triggers - */ - int64_t setNumberOfTriggers(int64_t t = -1, int detPos = -1); // - - /** - * Set/get number of additional storage cells (Jungfrau) - * @param t number of additional storage cells. Default is 0. (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of additional storage cells - */ - int64_t setNumberOfStorageCells(int64_t t = -1, int detPos = -1); // - - /** - * Get measured period between previous two frames (EIGER) - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns sub frame dead time in ns, or s if specified - */ - double getMeasuredPeriod(bool inseconds = false, int detPos = -1); // - - /** - * Get sub period between previous two sub frames in 32 bit mode (EIGER) - * @param t time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param detPos -1 for all detectors in list or specific detector position - * @returns sub frame dead time in ns, or s if specified - */ - double getMeasuredSubFramePeriod(bool inseconds = false, - int detPos = -1); // - - /** - * Set/get timer value left in acquisition (not all implemented for all - * detectors) - * @param index timer index - * @param t time in ns or number of...(e.g. frames, probes) - * @param detPos -1 for all detectors in list or specific detector position - * @returns timer set value in ns or number of...(e.g. frames, - * probes) - */ - int64_t getTimeLeft(timerIndex index, int detPos = -1); // - - /** - * Set speed - * @param sp speed type (clkdivider option for Jungfrau and Eiger, - * adcphase for Gotthard, others for CTB & Moench) - * @param value (clkdivider 0,1,2 for full, half and quarter speed). Other - * values check manual - * @param mode 0 for shift, 1 for degrees. relevant only for speed type - * adcphase and dbit phase - * @param detPos -1 for all detectors in list or specific detector position - * @returns value of speed set - */ - int setSpeed(speedVariable index, int value = -1, int mode = 0, - int detPos = -1); // - - /** - * Set/get dynamic range and updates the number of dataBytes - * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to - * 1) - * @param i dynamic range (-1 get) - * @param detPos -1 for all detectors in list or specific detector position - * @returns current dynamic range - */ - int setDynamicRange(int dr = -1, int detPos = -1); // - - /** - * Set/get dacs value - * @param val value (in V) - * @param index DAC index - * @param mV 0 in dac units or 1 in mV - * @param detPos -1 for all detectors in list or specific detector position - * @returns current DAC value - */ - int setDAC(int val, dacIndex index, int mV, int detPos = -1); // - - /** - * Get adc value - * @param index adc(DAC) index - * @param detPos -1 for all detectors in list or specific detector position - * @returns current adc value (temperature for eiger and jungfrau in - * millidegrees) - */ - int getADC(dacIndex index, int detPos = -1); // - - /** - * Set/get timing mode - * @param pol timing mode (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns current timing mode - */ - timingMode setTimingMode(timingMode pol = GET_TIMING_MODE, - int detPos = -1); // - - /** - * Set/get external signal flags (to specify triggerinrising edge etc) - * (Gotthard, Mythen) - * @param pol external signal flag (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns current timing mode - */ - externalSignalFlag - setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG, - int detPos = -1); // - - /** - * Set readout mode (Only for CTB and Moench) - * @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL - * @param detPos -1 for all detectors in list or specific detector position - */ - void setReadoutMode(const readoutMode mode, int detPos = -1); - - /** - * Get readout mode(Only for CTB and Moench) - * @param detPos -1 for all detectors in list or specific detector position - * @returns readout mode - */ - readoutMode getReadoutMode(int detPos = -1); - - /** - * Set Interrupt last sub frame (Only for Eiger) - * @param enable true if interrupt last subframe set, else false - * @param detPos -1 for all detectors in list or specific detector position - */ - void setInterruptSubframe(const bool enable, int detPos = -1); - - /** - * Get Interrupt last sub frame (Only for Eiger) - * @param detPos -1 for all detectors in list or specific detector position - * @returns 1 if interrupt last subframe set, else 0, -1 different values - */ - int getInterruptSubframe(int detPos = -1); - - /** - * Write in a register. For Advanced users - * @param addr address of register - * @param val value to write into register - * @param detPos -1 for all detectors in list or specific detector position - * @returns value read after writing - */ - uint32_t writeRegister(uint32_t addr, uint32_t val, int detPos = -1); // - - /** - * Read from a register. For Advanced users - * @param addr address of register - * @param detPos -1 for all detectors in list or specific detector position - * @returns value read from register - */ - uint32_t readRegister(uint32_t addr, int detPos = -1); // - - /** - * Set bit in a register. For Advanced users - * @param addr address of register - * @param n nth bit - * @param detPos -1 for all detectors in list or specific detector position - * @returns value read from register - */ - uint32_t setBit(uint32_t addr, int n, int detPos = -1); // - - /** - * Clear bit in a register. For Advanced users - * @param addr address of register - * @param n nth bit - * @param detPos -1 for all detectors in list or specific detector position - * @returns value read from register - */ - uint32_t clearBit(uint32_t addr, int n, int detPos = -1); // - - /** - * Validates and sets the receiver. - * Also updates the receiver with all the shared memory parameters - * significant for the receiver Also configures the detector to the receiver - * as UDP destination - * @param receiver receiver hostname or IP address - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver IP address from shared memory - */ - std::string setReceiverHostname(const std::string &receiver, - int detPos = -1); // - - /** - * Returns the receiver IP address - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver IP address - */ - std::string getReceiverHostname(int detPos = -1) const; // - - /** - * ets the number of UDP interfaces to stream data from detector (Jungfrau - * only) - * @param n number of interfaces. Options 1 or 2. - * @param detPos -1 for all detectors in list or specific detector position - */ - void setNumberofUDPInterfaces(int n, int detPos = -1); // - - /** - * Returns the number of UDP interfaces to stream data from detector - * (Jungfrau only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns the number of interfaces - */ - int getNumberofUDPInterfaces(int detPos = -1) ; // - - /** - * Selects the UDP interfaces to stream data from detector. Effective only - * when number of interfaces is 1. (Jungfrau only) - * @param n selected interface. Options 1 or 2. - * @param detPos -1 for all detectors in list or specific detector position - */ - void selectUDPInterface(int n, int detPos = -1); - - /** - * Returns the UDP interfaces to stream data from detector. Effective only - * when number of interfaces is 1. (Jungfrau only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns the interface selected - */ - int getSelectedUDPInterface(int detPos = -1) ; // - - /** - * (advanced users) - * Set/Get client streaming in ZMQ port and restarts client sockets - * @param i sets, -1 gets - * If detPos is -1(multi module), port calculated (increments) for all the - * individual detectors using i - * @param detPos -1 for all detectors in list or specific detector position - */ - void setClientDataStreamingInPort(int i = -1, int detPos = -1); - - /** - * Returns the client zmq port - * If detPos is -1(multi module), port returns client streaming port of - * first module - * @param detPos -1 for all detectors in list or specific detector position - * @returns the client zmq port - */ - int getClientStreamingPort(int detPos = -1); // - - /** - * (advanced users) - * Set/Get receiver streaming out ZMQ port and restarts receiver sockets - * @param i sets, -1 gets - * If detPos is -1(multi module), port calculated (increments) for all the - * individual detectors using i - * @param detPos -1 for all detectors in list or specific detector position - */ - void setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); // - - /** - * Returns the receiver zmq port - * If detPos is -1(multi module), port returns receiver streaming port of - * first module - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver zmq port - */ - int getReceiverStreamingPort(int detPos = -1); // - - /** - * Sets the transmission delay for left, right or entire frame - * (Eiger, Jungfrau(only entire frame)) - * @param index type of delay - * @param delay delay - * @param detPos -1 for all detectors in list or specific detector position - * @returns transmission delay - */ - int setDetectorNetworkParameter(networkParameter index, int delay, - int detPos = -1); // maybe not needed in API - - /** - * Sets the additional json header - * @param jsonheader additional json header - * @param detPos -1 for all detectors in list or specific detector position - * @returns additional json header, default is empty - */ - std::string setAdditionalJsonHeader(const std::string &jsonheader, - int detPos = -1); // - - /** - * Returns the additional json header - * @param detPos -1 for all detectors in list or specific detector position - * @returns the additional json header, default is empty - */ - std::string getAdditionalJsonHeader(int detPos = -1); // - - /** - * Sets the value for the additional json header parameter if found, else - * append it - * @param key additional json header parameter - * @param value additional json header parameter value (cannot be empty) - * @param detPos -1 for all detectors in list or specific detector position - * @returns the additional json header parameter value, - * empty if no parameter found in additional json header - */ - std::string setAdditionalJsonParameter(const std::string &key, - const std::string &value, - int detPos = -1); // - - /** - * Returns the additional json header parameter value - * @param key additional json header parameter - * @param detPos -1 for all detectors in list or specific detector position - * @returns the additional json header parameter value, - * empty if no parameter found in additional json header - */ - std::string getAdditionalJsonParameter(const std::string &key, - int detPos = -1); // - - /** - * Sets the detector minimum/maximum energy threshold in processor (for - * Moench only) - * @param index 0 for emin, antyhing else for emax - * @param v value to set (-1 gets) - * @returns detector minimum/maximum energy threshold (-1 for not found or - * error in computing json parameter value) - */ - int setDetectorMinMaxEnergyThreshold(const int index, int value, - int detPos = -1); // - - /** - * Sets the frame mode in processor (Moench only) - * @param value frameModeType (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns frame mode (-1 for not found or error in computing json - * parameter value) - */ - int setFrameMode(frameModeType value, int detPos = -1); - - /** - * Sets the detector mode in processor (Moench only) - * @param value detectorModetype (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns detector mode (-1 for not found or error in computing json - * parameter value) - */ - int setDetectorMode(detectorModeType value, int detPos = -1); - - /** - * Sets the receiver UDP socket buffer size - * @param udpsockbufsize additional json header - * @param detPos -1 for all detectors in list or specific detector position - * @returns receiver udp socket buffer size - */ - int64_t setReceiverUDPSocketBufferSize(int64_t udpsockbufsize = -1, - int detPos = -1); // - - /** - * Returns the receiver UDP socket buffer size - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver UDP socket buffer size - */ - int64_t getReceiverUDPSocketBufferSize(int detPos = -1); // - - /** - * Returns the receiver real UDP socket buffer size - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver real UDP socket buffer size - */ - int64_t getReceiverRealUDPSocketBufferSize(int detPos = -1); // - - /** (users only) - * Set 10GbE Flow Control (Eiger) - * @param enable 1 to set, 0 to unset, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns 10GbE flow Control - */ - int setFlowControl10G(int enable = -1, int detPos = -1); // - - /** - * Execute a digital test (Gotthard, Jungfrau, CTB) - * @param mode testmode type - * @param value 1 to set or 0 to clear the image test bit (Gotthard) - * @param detPos -1 for all detectors in list or specific detector position - * @returns result of test - */ - int digitalTest(digitalTestMode mode, int ival = -1, int detPos = -1); - - /** - * Set/get counter bit in detector (Eiger) - * @param i is -1 to get, 0 to reset and any other value to set the counter - * bit - * @param detPos -1 for all detectors in list or specific detector position - * @returns the counter bit in detector - */ - int setCounterBit(int i = -1, int detPos = -1); // - - /** - * Clear ROI (Gotthard) - * @param detPos -1 for all detectors in list or specific detector position - */ - void clearROI(int detPos = -1); - - /** - * Set ROI (Gotthard) - * At the moment only one set allowed per module - * Only allowed to set one ROI per module - * @param arg roi - * @param detPos specific detector position - */ - void setROI(slsDetectorDefs::ROI arg, int detPos = -1); - - /** - * Get ROI (Gotthard) - * Only allowed to set one ROI per module - * @param detPos specific detector position - * @returns roi - */ - slsDetectorDefs::ROI getROI(int detPos) const; - - /** - * Set ADC Enable Mask (CTB, Moench) - * @param mask ADC Enable mask - * @param detPos -1 for all detectors in list or specific detector position - */ - void setADCEnableMask(uint32_t mask, int detPos = -1); // - - /** - * Get ADC Enable Mask (CTB, Moench) - * @param detPos -1 for all detectors in list or specific detector position - * @returns ADC Enable mask - */ - uint32_t getADCEnableMask(int detPos = -1); // - - /** - * Set ADC invert register (CTB, Moench) - * @param value ADC invert value - * @param detPos -1 for all detectors in list or specific detector position - */ - void setADCInvert(uint32_t value, int detPos = -1); // - - /** - * Get ADC invert register (CTB, Moench) - * @param detPos -1 for all detectors in list or specific detector position - * @returns ADC invert value - */ - uint32_t getADCInvert(int detPos = -1); // - - /** - * Set external sampling source (CTB only) - * @param value external sampling source (Option: 0-63) - * @param detPos -1 for all detectors in list or specific detector position - */ - void setExternalSamplingSource(int value, int detPos = -1); // - - /** - * Get external sampling source (CTB only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling source - */ - int getExternalSamplingSource(int detPos = -1); // - - /** - * Set external sampling enable (CTB only) - * @param value external sampling source (Option: 0-63) - * @param detPos -1 for all detectors in list or specific detector position - */ - void setExternalSampling(bool value, int detPos = -1); // - - /** - * Get external sampling source (CTB only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling enable - */ - int getExternalSampling(int detPos = -1); // - - /** - * Set external sampling enable (CTB only) - * @param list external sampling source (Option: 0-63) - * @param detPos -1 for all detectors in list or specific detector position - */ - void setReceiverDbitList(std::vector list, int detPos = -1); // - - /** - * Get external sampling source (CTB only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling enable - */ - std::vector getReceiverDbitList(int detPos = -1); // - - /** - * Set digital data offset in bytes (CTB only) - * @param value digital data offset in bytes - * @param detPos -1 for all detectors in list or specific detector position - */ - void setReceiverDbitOffset(int value, int detPos = -1); // - - /** - * Get digital data offset in bytes (CTB only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns digital data offset in bytes - */ - int getReceiverDbitOffset(int detPos = -1); // - - /** - * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert - * users - * @param addr address of adc register - * @param val value - * @param detPos -1 for all detectors in list or specific detector position - */ - void writeAdcRegister(uint32_t addr, uint32_t val, int detPos = -1); // - - /** - * Activates/Deactivates the detector (Eiger only) - * @param enable active (1) or inactive (0), -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns 0 (inactive) or 1 (active)for activate mode - */ - int activate(int const enable = -1, int detPos = -1); // - - /** - * Set deactivated Receiver padding mode (Eiger only) - * @param padding padding option for deactivated receiver. Can be 1 - * (padding), 0 (no padding), -1 (gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for - * padding option - */ - int setDeactivatedRxrPaddingMode(int padding = -1, int detPos = -1); - - /** - * Returns the enable if data will be flipped across x axis (Eiger) - * @param detPos -1 for all detectors in list or specific detector position - * @returns 1 for flipped, else 0 - */ - int getFlippedDataX(int detPos = -1); // - - /** - * Sets the enable which determines if - * data will be flipped across x axis (Eiger) - * @param value 0 or 1 to reset/set or -1 to get value - * @param detPos -1 for all detectors in list or specific detector position - * @returns enable flipped data across x or y axis - */ - int setFlippedDataX(int value = -1, int detPos = -1); // - - /** - * Sets all the trimbits to a particular value (Eiger) - * @param val trimbit value - * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL - */ - int setAllTrimbits(int val, int detPos = -1); // + void readConfigurationFile(const std::string &fname); /** * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. (Eiger) * 4 bit mode gap pixels only in gui call back - * @param val 1 sets, 0 unsets, -1 gets - * @returns gap pixel enable or -1 for error */ - int enableGapPixels(int val = -1, int detPos = -1); // - - void setGapPixelsEnable(bool enable, sls::Positions pos = {}); - /** - * Sets the number of trim energies and their value (Eiger) - * - * @param nen number of energies - * @param en array of energies - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of trim energies - */ - int setTrimEn(std::vector energies, int detPos = -1); // - - /** - * Returns the number of trim energies and their value (Eiger) - * - * @param detPos -1 for all detectors in list or specific detector position - * @returns vector of trim energies - */ - std::vector getTrimEn(int detPos = -1); // - - /** - * Pulse Pixel (Eiger) - * @param n is number of times to pulse - * @param x is x coordinate - * @param y is y coordinate - * @param detPos -1 for all detectors in list or specific detector position - */ - void pulsePixel(int n = 0, int x = 0, int y = 0, int detPos = -1); // - - /** - * Pulse Pixel and move by a relative value (Eiger) - * @param n is number of times to pulse - * @param x is relative x value - * @param y is relative y value - * @param detPos -1 for all detectors in list or specific detector position - */ - void pulsePixelNMove(int n = 0, int x = 0, int y = 0, int detPos = -1); // - - /** - * Pulse Chip (Eiger) - * @param n is number of times to pulse - * @param detPos -1 for all detectors in list or specific detector position - */ - void pulseChip(int n = 0, int detPos = -1); // - - /** - * Set/gets threshold temperature (Jungfrau) - * @param val value in millidegrees, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns threshold temperature in millidegrees - */ - int setThresholdTemperature(int val = -1, int detPos = -1); // - - /** - * Enables/disables temperature control (Jungfrau) - * @param val value, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns temperature control enable - */ - int setTemperatureControl(int val = -1, int detPos = -1); // - - /** - * Resets/ gets over-temperature event (Jungfrau) - * @param val value, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns over-temperature event - */ - int setTemperatureEvent(int val = -1, int detPos = -1); // - - /** - * Set storage cell that stores first acquisition of the series (Jungfrau) - * @param value storage cell index. Value can be 0 to 15. (-1 gets) - * @param detPos -1 for all detectors in list or specific detector position - * @returns the storage cell that stores the first acquisition of the series - */ - int setStoragecellStart(int pos = -1, int detPos = -1); // - - /** - * Programs FPGA with pof file (Jungfrau, CTB, Moench) - * @param fname file name - * @param detPos -1 for all detectors in list or specific detector position - */ - void programFPGA(const std::string &fname, int detPos = -1); // - - /** - * Resets FPGA (Jungfrau, CTB, Moench) - * @param detPos -1 for all detectors in list or specific detector position - */ - void resetFPGA(int detPos = -1); // - - /** - * Copies detector server from tftp and changes respawn server (Not Eiger) - * @param fname name of detector server binary - * @param hostname name of pc to tftp from - * @param detPos -1 for all detectors in list or specific detector position - */ - void copyDetectorServer(const std::string &fname, - const std::string &hostname, int detPos = -1); // - - /** - * Reboot detector controller (Not Eiger) - * @param detPos -1 for all detectors in list or specific detector position - */ - void rebootController(int detPos = -1); // - - /** - * Updates the firmware, detector server and then reboots detector - * controller blackfin. (Not Eiger) - * @param sname name of detector server binary - * @param hostname name of pc to tftp from - * @param fname programming file name - * @param detPos -1 for all detectors in list or specific detector position - */ - void update(const std::string &sname, const std::string &hostname, - const std::string &fname, int detPos = -1); // - - /** - * Power on/off Chip (Jungfrau) - * @param ival on is 1, off is 0, -1 to get - * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL - */ - int powerChip(int ival = -1, int detPos = -1); // - - /** - * Automatic comparator disable (Jungfrau) - * @param ival on is 1, off is 0, -1 to get - * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL - */ - int setAutoComparatorDisableMode(int ival = -1, int detPos = -1); // - - /** - * Set Default Rate correction from trimbit file ( Eiger) - * @param detPos -1 for all detectors in list or specific detector position - */ - void setDefaultRateCorrection(int detPos = -1); // - - /** - * Set Rate correction ( Eiger) - * @param t dead time in ns - if 0 disable correction, - * if >0 set dead time to t, cannot be < 0 - * @param detPos -1 for all detectors in list or specific detector position - */ - void setRateCorrection(int64_t t = 0, int detPos = -1); // - - /** - * Get rate correction ( Eiger) - * @param detPos -1 for all detectors in list or specific detector position - * @returns 0 if rate correction disabled, > 0 otherwise (ns) - */ - int64_t getRateCorrection(int detPos = -1); // - - /** - * Prints receiver configuration - * @param detPos -1 for all detectors in list or specific detector position - * @returns receiver configuration - */ - std::string printReceiverConfiguration(int detPos = -1); // - - /** - * Get receiver online status - * @param detPos -1 for all detectors in list or specific detector position - * @returns use receiver flag - */ - bool getUseReceiverFlag(int detPos = -1); // - - /** - * Locks/Unlocks the connection to the receiver - * @param lock sets (1), usets (0), gets (-1) the lock - * @param detPos -1 for all detectors in list or specific detector position - * @returns lock status of the receiver - */ - int lockReceiver(int lock = -1, int detPos = -1); // - - /** - * Turns off the receiver server! - * @param detPos -1 for all detectors in list or specific detector position - */ - void exitReceiver(int detPos = -1); - - /** - * Executes a system command on the receiver server - * e.g. mount an nfs disk, reboot and returns answer etc. - * @param cmd command to be executed - * @param detPos -1 for all detectors in list or specific detector position - */ - void execReceiverCommand(const std::string &cmd, int detPos = -1); - - /** - * Returns output file directory - * @param detPos -1 for all detectors in list or specific detector position - * @returns output file directory - */ - std::string getFilePath(int detPos = -1); // - - /** - * Sets up the file directory - * @param detPos -1 for all detectors in list or specific detector position - * @param s file directory - * @returns file dir - */ - std::string setFilePath(const std::string &path, int detPos = -1); // - - /** - * Returns file name prefix - * @param detPos -1 for all detectors in list or specific detector position - * @returns file name prefix - */ - std::string getFileName(int detPos = -1); // - - /** - * Sets up the file name prefix - * @param detPos -1 for all detectors in list or specific detector position - * @param s file name prefix - * @returns file name prefix - */ - std::string setFileName(const std::string &fname, int detPos = -1); // - - /** - * Sets the max frames per file in receiver - * @param f max frames per file - * @param detPos -1 for all detectors in list or specific detector position - * @returns max frames per file in receiver - */ - int setFramesPerFile(int f = -1, int detPos = -1); // - - /** - * Gets the max frames per file in receiver - * @param detPos -1 for all detectors in list or specific detector position - * @returns max frames per file in receiver - */ - int getFramesPerFile(int detPos = -1) const; // - - /** - * Sets the frames discard policy in receiver - * @param f frames discard policy - * @param detPos -1 for all detectors in list or specific detector position - * @returns frames discard policy set in receiver - */ - frameDiscardPolicy setReceiverFramesDiscardPolicy( - frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY, int detPos = -1); // - - /** - * Sets the partial frames padding enable in receiver - * @param f partial frames padding enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns partial frames padding enable in receiver - */ - int setPartialFramesPadding(bool padding, int detPos = -1); // - - int getPartialFramesPadding(int detPos = -1) const; // - - /** - * Returns file format - * @param detPos -1 for all detectors in list or specific detector position - * @returns file name - */ - fileFormat getFileFormat(int detPos = -1); // - - /** - * Sets up the file format - * @param f file format - * @param detPos -1 for all detectors in list or specific detector position - * @returns file format - */ - fileFormat setFileFormat(fileFormat f, int detPos = -1); // - - /** - * Sets up the file index - * @param i file index - * @param detPos -1 for all detectors in list or specific detector position - * @returns file index - */ - int64_t setFileIndex(int64_t i, int detPos = -1); // - - /** - * Get File index - * @param detPos -1 for all detectors in list or specific detector - * position - * @returns file index - */ - int64_t getFileIndex(int detPos = -1) const; // - - /** - * Gets the number of frames caught by receiver - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of frames caught by receiver - */ - int getFramesCaughtByReceiver(int detPos = -1); // - - /** - * Gets the current frame index of receiver - * @param detPos -1 for all detectors in list or specific detector position - * @returns average of all current frame index of receiver - */ - uint64_t getReceiverCurrentFrameIndex(int detPos = -1); // - - /** - * Sets/Gets receiver file write enable - * @param value 1 or 0 to set/reset file write enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns file write enable - */ - int setFileWrite(bool value, int detPos = -1); // - - /** - * Gets file write enable - * @returns file write enable - */ - int getFileWrite(int detPos = -1) const; // - - /** - * Sets/Gets receiver master file write enable - * @param value 1 or 0 to set/reset master file write enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns master file write enable - */ - int setMasterFileWrite(bool value, int detPos = -1); // - - /** - * Gets master file write enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns master file write enable - */ - int getMasterFileWrite(int detPos = -1) const; // - - /** - * Sets/Gets file overwrite enable - * @param enable 1 or 0 to set/reset file overwrite enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns file overwrite enable - */ - int setFileOverWrite(bool enable, int detPos = -1); // - - /** - * Gets file over write enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns file over write enable - */ - int getFileOverWrite(int detPos = -1) const; // - - /** - * (previously setReadReceiverFrequency) - * Sets the receiver streaming frequency - * @param freq nth frame streamed out, if 0, streamed out at a timer of 200 - * ms - * @param detPos -1 for all detectors in list or specific detector position - * @returns receiver streaming frequency - */ - int setReceiverStreamingFrequency(int freq = -1, int detPos = -1); - - /** - * (previously setReceiverReadTimer) - * Sets the receiver streaming timer - * If receiver streaming frequency is 0, then this timer between each - * data stream is set. Default is 200 ms. - * @param time_in_ms timer between frames - * @param detPos -1 for all detectors in list or specific detector position - * @returns receiver streaming timer in ms - */ - int setReceiverStreamingTimer(int time_in_ms = 200, int detPos = -1); // + void setGapPixelsinReceiver(bool enable); /** * Enable data streaming to client @@ -1566,145 +276,8 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ bool enableDataStreamingToClient(int enable = -1); - /** - * Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @param detPos -1 for all detectors in list or specific detector position - * @returns data streaming from receiver enable - */ - int enableDataStreamingFromReceiver(int enable = -1, int detPos = -1); + void savePattern(const std::string &fname); - /** - * Enable/disable or 10Gbe - * @param i is -1 to get, 0 to disable and 1 to enable - * @param detPos -1 for all detectors in list or specific detector position - * @returns if 10Gbe is enabled - */ - int enableTenGigabitEthernet(int i = -1, int detPos = -1); // - - /** - * Set/get receiver fifo depth - * @param i is -1 to get, any other value to set the fifo deph - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver fifo depth - */ - int setReceiverFifoDepth(int i = -1, int detPos = -1); // - - /** - * Set/get receiver silent mode - * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode - * @param detPos -1 for all detectors in list or specific detector position - * @returns the receiver silent mode enable - */ - int setReceiverSilentMode(int i = -1, int detPos = -1); // - - /** - * Opens pattern file and sends pattern (CTB/ Moench) - * @param fname pattern file to open - * @param detPos -1 for all detectors in list or specific detector position - */ - void setPattern(const std::string &fname, int detPos = -1); // - - /** - * Executes and saves pattern to file (CTB/ Moench) - * @param fname pattern file to save to - */ - void savePattern(const std::string &fname); // - - /** - * Sets pattern IO control (CTB/ Moench) - * @param word 64bit word to be written, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns actual value - */ - uint64_t setPatternIOControl(uint64_t word = -1, int detPos = -1); // - - /** - * Sets pattern clock control (CTB/ Moench) - * @param word 64bit word to be written, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns actual value - */ - uint64_t setPatternClockControl(uint64_t word = -1, int detPos = -1); // - - /** - * Writes a pattern word (CTB/ Moench) - * @param addr address of the word - * @param word 64bit word to be written, -1 reads the addr (same as - * executing the pattern) - * @param detPos -1 for all detectors in list or specific detector position - * @returns actual value - */ - uint64_t setPatternWord(int addr, uint64_t word, int detPos = -1); // - - /** - * Sets the wait address (CTB/ Moench) - * @param level 0,1,2, wait level - * @param addr wait address, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns actual value - */ - int setPatternWaitAddr(int level, int addr = -1, int detPos = -1); // - - /** - * Sets the wait time (CTB/ Moench) - * @param level 0,1,2, wait level - * @param t wait time, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns actual value - */ - uint64_t setPatternWaitTime(int level, uint64_t t = -1, int detPos = -1); // - - /** - * Sets the mask applied to every pattern (CTB/ Moench) - * @param mask mask to be applied - * @param detPos -1 for all detectors in list or specific detector position - */ - void setPatternMask(uint64_t mask, int detPos = -1); // - - /** - * Gets the mask applied to every pattern (CTB/ Moench) - * @param detPos -1 for all detectors in list or specific detector position - * @returns mask set - */ - uint64_t getPatternMask(int detPos = -1); // - - /** - * Selects the bits that the mask will be applied to for every pattern (CTB/ - * Moench) - * @param mask mask to select bits - * @param detPos -1 for all detectors in list or specific detector position - */ - void setPatternBitMask(uint64_t mask, int detPos = -1); // - - /** - * Gets the bits that the mask will be applied to for every pattern (CTB/ - * Moench) - * @param detPos -1 for all detectors in list or specific detector position - * @returns mask of bits selected - */ - uint64_t getPatternBitMask(int detPos = -1); // - - /** - * Set LED Enable (Moench, CTB only) - * @param enable 1 to switch on, 0 to switch off, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - * @returns LED enable - */ - int setLEDEnable(int enable = -1, int detPos = -1); // - - /** - * Set Digital IO Delay (Moench, CTB only) - * @param digital IO mask to select the pins - * @param delay delay in ps(1 bit=25ps, max of 775 ps) - * @param detPos -1 for all detectors in list or specific detector position - */ - void setDigitalIODelay(uint64_t pinMask, int delay, int detPos = -1); // - - /** - * Loads the detector setup from file - * @param fname file to read from - */ void loadParameters(const std::string &fname); /** @@ -1736,7 +309,7 @@ class multiSlsDetector : public virtual slsDetectorDefs { * index, loops for measurements, calls required call backs. * @returns OK or FAIL depending on if it already started */ - int acquire(); // + int acquire(); /** * Combines data from all readouts and gives it to the gui @@ -1763,72 +336,33 @@ class multiSlsDetector : public virtual slsDetectorDefs { void setupMultiDetector(bool verify = true, bool update = true); /** - * Initialize (open/create) shared memory for the sharedMultiDetector - * structure + * Creates shm and initializes shm structure OR + * Open shm and maps to structure * @param verify true to verify if shm size matches existing one * @param update true to update last user pid, date etc - * @returns true if shared memory was created in this call, else false */ void initSharedMemory(bool verify = true); - /** - * Initialize detector structure for the shared memory just created - */ + /** Initialize detector structure for the shared memory just created */ void initializeDetectorStructure(); - /** - * Initialize class members (and from parent classes) + /** Initialize members (eg. slsDetectors from shm, zmqsockets) * @param verify true to verify if shm size matches existing one */ void initializeMembers(bool verify = true); - /** - * Update user details in detector structure - */ + /** Update in shm */ void updateUserdetails(); - /** - * Check if acquiring flag is set, set error if set - * @returns FAIL if not ready, OK if ready - */ bool isAcquireReady(); - /** - * Execute in command line and return result - * @param cmd command - * @returns result - */ + /** Execute command in terminal and return result */ std::string exec(const char *cmd); - /** - * Add sls detector - * @param s hostname of the single detector - */ void addSlsDetector(const std::string &hostname); - /** - * Updates the channel size in X and Y dimension for all the sls - * detectors - */ void updateDetectorSize(); - /** - * increments file index - * @param detPos -1 for all detectors in list or specific detector position - * @returns the file index - */ - int64_t incrementFileIndex(int detPos = -1); - - /** - * add gap pixels to the image (only for Eiger in 4 bit mode) - * @param image pointer to image without gap pixels - * @param gpImage poiner to image with gap pixels, if NULL, allocated - * inside function - * quadEnable quad enabled - * @returns number of data bytes of image with gap pixels - */ - int processImageWithGapPixels(char *image, char *&gpImage, bool quadEnable); - /** * Create Receiving Data Sockets * @param destroy is true to destroy all the sockets @@ -1843,31 +377,23 @@ class multiSlsDetector : public virtual slsDetectorDefs { void readFrameFromReceiver(); /** - * Set total progress (total number of frames/images in an acquisition) - * @returns total progress + * add gap pixels to the image (only for Eiger in 4 bit mode) + * @param image pointer to image without gap pixels + * @param gpImage poiner to image with gap pixels, if NULL, allocated + * inside function + * quadEnable quad enabled + * @returns number of data bytes of image with gap pixels */ + int processImageWithGapPixels(char *image, char *&gpImage, bool quadEnable); + int setTotalProgress(); - /** - * Get progress in current acquisition - * @returns current progress - */ double getCurrentProgress(); - /** - * Increment progress by one - */ void incrementProgress(); - /** - * Set current progress to argument - * @param i current progress - */ void setCurrentProgress(int i = 0); - /** - * Start data processing thread - */ void startProcessingThread(); /** diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index 5faf2806b..01a7c74b2 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -169,6 +169,9 @@ struct sharedSlsDetector { /** reciever dbit offset */ int rxDbitOffset; + + /** num udp interfaces */ + int numUDPInterfaces; }; class slsDetector : public virtual slsDetectorDefs { @@ -258,13 +261,7 @@ class slsDetector : public virtual slsDetectorDefs { * Get Detector type from shared memory variable * @returns detector type from shared memory variable */ - detectorType getDetectorTypeAsEnum() const; - - /** - * Gets string version of detector type from shared memory variable - * @returns string version of detector type from shared memory variable - */ - std::string getDetectorTypeAsString() const; + detectorType getDetectorType() const; /** * Gets detector type from detector and set it in receiver @@ -554,8 +551,6 @@ class slsDetector : public virtual slsDetectorDefs { */ int setDynamicRange(int n = -1); - int getDynamicRangeFromShm(); - /** * Set/get dacs value * @param val value (in V) @@ -848,6 +843,9 @@ class slsDetector : public virtual slsDetectorDefs { */ void setNumberofUDPInterfaces(int n); + /** Returns the number of udp interfaces from shared memory */ + int getNumberofUDPInterfacesFromShm(); + /** * Returns the number of UDP interfaces to stream data from detector * (Jungfrau only) diff --git a/slsDetectorSoftware/include/slsDetectorCommand.h b/slsDetectorSoftware/include/slsDetectorCommand.h index 396ed1666..450b4006c 100755 --- a/slsDetectorSoftware/include/slsDetectorCommand.h +++ b/slsDetectorSoftware/include/slsDetectorCommand.h @@ -33,16 +33,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::vector getAllCommands(); - - /* /\** */ - /* returns the help for the executeLine command */ - /* \param os output stream to return the help to */ - /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ - /* *\/ */ - std::string helpLine(int narg, const char * const args[], int action=HELP_ACTION, int detPos = -1); static std::string helpAcquire(int action); - static std::string helpFree(int action); - static std::string helpSN(int action); static std::string helpConfiguration(int action); @@ -51,9 +42,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdUnknown(int narg, const char * const args[], int action, int detPos = -1); std::string cmdAcquire(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdFree(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdHelp(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdSN(int narg, const char * const args[], int action, int detPos = -1); std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 74b957000..d91ba39fd 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -67,7 +67,7 @@ Result Detector::getReceiverVersion(Positions pos) const { } Result Detector::getDetectorType(Positions pos) const { - return pimpl->Parallel(&slsDetector::getDetectorTypeAsEnum, pos); + return pimpl->Parallel(&slsDetector::getDetectorType, pos); } int Detector::size() const { return pimpl->size(); } @@ -173,7 +173,7 @@ Result Detector::getSpeed(Positions pos) const { auto res = pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1, 0); Result speedResult(res.size()); - for (size_t i = 0; i < res.size(); ++i) { + for (unsigned int i = 0; i < res.size(); ++i) { speedResult[i] = static_cast(res[i]); } return speedResult; @@ -314,7 +314,7 @@ void Detector::stopReceiver() { } void Detector::startDetector() { - if (getDetectorType({}).squash() == defs::EIGER) { + if (getDetectorType().squash() == defs::EIGER) { pimpl->Parallel(&slsDetector::prepareAcquisition, {}); } pimpl->Parallel(&slsDetector::startAcquisition, {}); @@ -782,7 +782,9 @@ Result Detector::getDynamicRange(Positions pos) const { return pimpl->Parallel(&slsDetector::setDynamicRange, pos, -1); } -void Detector::setDynamicRange(int value) { pimpl->setDynamicRange(value); } +void Detector::setDynamicRange(int value) { + pimpl->Parallel(&slsDetector::setDynamicRange, {}, value); +} Result Detector::getSubExptime(Positions pos) const { return pimpl->Parallel(&slsDetector::setTimer, pos, @@ -832,7 +834,7 @@ Result Detector::getRxAddGapPixels(Positions pos) const { } void Detector::setRxAddGapPixels(bool enable) { - pimpl->setGapPixelsEnable(enable, {}); + pimpl->setGapPixelsinReceiver(enable); } Result Detector::getParallelMode(Positions pos) const { @@ -968,7 +970,13 @@ Result Detector::getQuad(Positions pos) const { return pimpl->Parallel(&slsDetector::getQuad, pos); } -void Detector::setQuad(const bool value) { pimpl->setQuad(value); } +void Detector::setQuad(const bool value) { + if (value && size() > 1) { + throw RuntimeError("Cannot set Quad type as it is available only for 1 " + "Eiger Quad Half module."); + } + pimpl->Parallel(&slsDetector::setQuad, {}, value); +} // Jungfrau Specific @@ -1007,8 +1015,8 @@ Result Detector::getPowerChip(Positions pos) const { void Detector::setPowerChip(bool on, Positions pos) { if ((pos.empty() || pos[0] == -1) && on && pimpl->size() > 3) { - for (unsigned int i = 0; i != pimpl->size(); ++i) { - pimpl->powerChip(static_cast(on), i); + for (int i = 0; i != pimpl->size(); ++i) { + pimpl->Parallel(&slsDetector::powerChip, {i}, static_cast(on)); usleep(1000 * 1000); } } else { @@ -1618,12 +1626,12 @@ Result Detector::getRxCurrentFrameIndex(Positions pos) const { std::vector Detector::getPortNumbers(int start_port) { int num_sockets_per_detector = 1; - switch (getDetectorType({}).squash()) { + switch (getDetectorType().squash()) { case defs::EIGER: num_sockets_per_detector *= 2; break; case defs::JUNGFRAU: - if (getNumberofUDPInterfaces({}).squash() == 2) { + if (getNumberofUDPInterfaces().squash() == 2) { num_sockets_per_detector *= 2; } break; diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index f1f7288e7..8f6a40994 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -136,53 +136,12 @@ void multiSlsDetector::setAcquiringFlag(bool flag) { multi_shm()->acquiringFlag = flag; } -bool multiSlsDetector::getAcquiringFlag() const { - return multi_shm()->acquiringFlag; -} - -void multiSlsDetector::checkDetectorVersionCompatibility(int detPos) { - if (detPos >= 0) { - detectors[detPos]->checkDetectorVersionCompatibility(); - } - - parallelCall(&slsDetector::checkDetectorVersionCompatibility); -} - -void multiSlsDetector::checkReceiverVersionCompatibility(int detPos) { - if (detPos >= 0) { - detectors[detPos]->checkReceiverVersionCompatibility(); - } - - parallelCall(&slsDetector::checkReceiverVersionCompatibility); -} - -int64_t multiSlsDetector::getId(idMode mode, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getId(mode); - } - - auto r = parallelCall(&slsDetector::getId, mode); - return sls::minusOneIfDifferent(r); -} +int multiSlsDetector::getMultiId() const { return multiId; } std::string multiSlsDetector::getPackageVersion() const { return GITBRANCH; } int64_t multiSlsDetector::getClientSoftwareVersion() const { return APILIB; } -int64_t multiSlsDetector::getReceiverSoftwareVersion(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getReceiverSoftwareVersion(); - } - - auto r = parallelCall(&slsDetector::getReceiverSoftwareVersion); - return sls::minusOneIfDifferent(r); -} - -std::vector multiSlsDetector::getDetectorNumber() { - return parallelCall(&slsDetector::getId, - slsDetectorDefs::DETECTOR_SERIAL_NUMBER); -} - void multiSlsDetector::freeSharedMemory(int multiId, int detPos) { // single if (detPos >= 0) { @@ -209,14 +168,7 @@ void multiSlsDetector::freeSharedMemory(int multiId, int detPos) { } } -void multiSlsDetector::freeSharedMemory(int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->freeSharedMemory(); - return; - } - - // multi +void multiSlsDetector::freeSharedMemory() { zmqSocket.clear(); for (auto &d : detectors) { d->freeSharedMemory(); @@ -243,13 +195,13 @@ std::string multiSlsDetector::getUserDetails() { sstream << "\nType: "; // get type from multi shm if (multi_shm()->shmversion >= MULTI_SHMAPIVERSION) { - sstream << ToString(getDetectorTypeAsEnum()); + sstream << ToString(multi_shm()->multiDetectorType); } // get type from slsdet shm else { for (auto &d : detectors) { sstream << (d->isFixedPatternSharedMemoryCompatible() - ? d->getDetectorTypeAsString() + ? ToString(d->getDetectorType()) : "Unknown") << "+"; } @@ -327,10 +279,10 @@ bool multiSlsDetector::isAcquireReady() { << "Acquire has already started. " "If previous acquisition terminated unexpectedly, " "reset busy flag to restart.(sls_detector_put busy 0)"; - return FAIL != 0u; + return false; } multi_shm()->acquiringFlag = true; - return OK != 0u; + return true; } std::string multiSlsDetector::exec(const char *cmd) { @@ -382,40 +334,6 @@ void multiSlsDetector::setHostname(const std::vector &name) { updateDetectorSize(); } -void multiSlsDetector::setHostname(const char *name, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setHostname(name); - return; - } - - // multi - // this check is there only to allow the previous detsizechan command - if (multi_shm()->numberOfDetectors != 0) { - FILE_LOG(logWARNING) - << "There are already detector(s) in shared memory." - "Freeing Shared memory now."; - freeSharedMemory(); - setupMultiDetector(); - } - for (const auto &hostname : sls::split(name, '+')) { - addSlsDetector(hostname); - } - updateDetectorSize(); -} - -std::string multiSlsDetector::getHostname(int detPos) const { - // single - if (detPos >= 0) { - return detectors[detPos]->getHostname(); - } - - // multi - auto r = serialCall(&slsDetector::getHostname); - return sls::concatenateNonEmptyStrings(r); -} - - void multiSlsDetector::addSlsDetector(const std::string &hostname) { FILE_LOG(logINFO) << "Adding detector " << hostname; @@ -448,8 +366,8 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) { detectors[pos]->setControlPort(port); detectors[pos]->setStopPort(port + 1); detectors[pos]->setHostname(host); - multi_shm()->multiDetectorType = - getDetectorTypeAsEnum(-1); // -1 needed here + // detector type updated by now + multi_shm()->multiDetectorType = Parallel(&slsDetector::getDetectorType, {}).tsquash("Inconsistent detector types."); } void multiSlsDetector::updateDetectorSize() { @@ -487,46 +405,13 @@ void multiSlsDetector::updateDetectorSize() { } } -slsDetectorDefs::detectorType multiSlsDetector::getDetectorTypeAsEnum() const { - return multi_shm()->multiDetectorType; -} - -slsDetectorDefs::detectorType -multiSlsDetector::getDetectorTypeAsEnum(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getDetectorTypeAsEnum(); - } - - // multi - auto r = serialCall(&slsDetector::getDetectorTypeAsEnum); - return (detectorType)sls::minusOneIfDifferent(r); -} - -std::string multiSlsDetector::getDetectorTypeAsString(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getDetectorTypeAsString(); - } - - // multi - auto r = serialCall(&slsDetector::getDetectorTypeAsString); - return sls::concatenateIfDifferent(r); -} - -size_t multiSlsDetector::size() const { return detectors.size(); } +int multiSlsDetector::size() const { return detectors.size(); } slsDetectorDefs::xy multiSlsDetector::getNumberOfDetectors() const { return multi_shm()->numberOfDetector; } -slsDetectorDefs::xy multiSlsDetector::getNumberOfChannels(int detPos) const { - // single - if (detPos >= 0) { - return detectors[detPos]->getNumberOfChannels(); - } - - // multi +slsDetectorDefs::xy multiSlsDetector::getNumberOfChannels() const { return multi_shm()->numberOfChannels; } @@ -538,104 +423,6 @@ void multiSlsDetector::setNumberOfChannels(const slsDetectorDefs::xy c) { multi_shm()->numberOfChannels = c; } -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 Quad is enabled for 1st readout"); - } - return retval; -} - -void multiSlsDetector::setQuad(const bool enable, int detPos) { - if (enable && size() > 1) { - throw RuntimeError("Cannot set Quad type as it is available only for 1 " - "Eiger Quad Half module."); - } - - detectors[0]->setQuad(enable); -} - -void multiSlsDetector::setReadNLines(const int value, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setReadNLines(value); - } - - // multi - parallelCall(&slsDetector::setReadNLines, value); -} - -int multiSlsDetector::getReadNLines(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getReadNLines(); - } - - // multi - auto r = parallelCall(&slsDetector::getReadNLines); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setControlPort(int port_number, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->setControlPort(port_number); - } - - auto r = serialCall(&slsDetector::setControlPort, port_number); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setStopPort(int port_number, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->setStopPort(port_number); - } - - auto r = serialCall(&slsDetector::setStopPort, port_number); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setReceiverPort(int port_number, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->setReceiverPort(port_number); - } - - auto r = serialCall(&slsDetector::setReceiverPort, port_number); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getReceiverPort(int detPos) const { - if (detPos >= 0) { - return detectors[detPos]->getReceiverPort(); - } - - auto r = serialCall(&slsDetector::getReceiverPort); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::lockServer(int p, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->lockServer(p); - } - auto r = parallelCall(&slsDetector::lockServer, p); - return sls::minusOneIfDifferent(r); -} - - -void multiSlsDetector::exitServer(int detPos) { - if (detPos >= 0) { - detectors[detPos]->exitServer(); - } - parallelCall(&slsDetector::exitServer); -} - -void multiSlsDetector::execCommand(const std::string &cmd, int detPos) { - if (detPos >= 0) { - detectors[detPos]->execCommand(cmd); - } - parallelCall(&slsDetector::execCommand, cmd); -} - void multiSlsDetector::readConfigurationFile(const std::string &fname) { freeSharedMemory(); setupMultiDetector(); @@ -662,1089 +449,9 @@ void multiSlsDetector::readConfigurationFile(const std::string &fname) { input_file.close(); } -void multiSlsDetector::writeConfigurationFile(const std::string &fname) { - // TODO! make exception safe! - const std::vector header{"detsizechan", "hostname"}; - std::ofstream outfile; - - outfile.open(fname.c_str(), std::ios_base::out); - if (outfile.is_open()) { - for (const auto &cmd : header) - multiSlsDetectorClient(cmd, GET_ACTION, this, outfile); - - // single detector configuration - for (auto &detector : detectors) { - outfile << '\n'; - auto det_commands = detector->getConfigFileCommands(); - for (const auto &cmd : det_commands) - multiSlsDetectorClient(cmd, GET_ACTION, this, outfile); - } - } else { - throw RuntimeError("Could not open configuration file " + fname + - " for writing"); - } -} - -slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getSettings(); - } - - // multi - auto r = parallelCall(&slsDetector::getSettings); - return (detectorSettings)sls::minusOneIfDifferent(r); -} - -slsDetectorDefs::detectorSettings -multiSlsDetector::setSettings(detectorSettings isettings, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setSettings(isettings); - } - - // multi - auto r = parallelCall(&slsDetector::setSettings, isettings); - return (detectorSettings)sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getThresholdEnergy(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getThresholdEnergy(); - } - - // multi - auto r = parallelCall(&slsDetector::getThresholdEnergy); - if (sls::allEqualWithTol(r, 200)) { - return r.front(); - } - return -1; -} - -int multiSlsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, - int tb, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setThresholdEnergy(e_eV, isettings, tb); - } - - // multi - auto r = - parallelCall(&slsDetector::setThresholdEnergy, e_eV, isettings, tb); - if (sls::allEqualWithTol(r, 200)) { - return r.front(); - } - return -1; -} - -std::string multiSlsDetector::getSettingsDir(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getSettingsDir(); - } - - // multi - auto r = serialCall(&slsDetector::getSettingsDir); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::setSettingsDir(const std::string &directory, - int detPos) { - if (detPos >= 0) { - return detectors[detPos]->setSettingsDir(directory); - } - - auto r = parallelCall(&slsDetector::setSettingsDir, directory); - return sls::concatenateIfDifferent(r); -} - -void multiSlsDetector::loadSettingsFile(const std::string &fname, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->loadSettingsFile(fname); - } - - // multi - parallelCall(&slsDetector::loadSettingsFile, fname); -} - -void multiSlsDetector::saveSettingsFile(const std::string &fname, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->saveSettingsFile(fname); - } - - // multi - parallelCall(&slsDetector::saveSettingsFile, fname); -} - - -void multiSlsDetector::setStartingFrameNumber(const uint64_t value, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setStartingFrameNumber(value); - } - - // multi - parallelCall(&slsDetector::setStartingFrameNumber, value); -} - -uint64_t multiSlsDetector::getStartingFrameNumber(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getStartingFrameNumber(); - } - - // multi - auto r = parallelCall(&slsDetector::getStartingFrameNumber); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values for next acquisition - std::ostringstream ss; - ss << "Error: Different Values for starting frame number"; - throw RuntimeError(ss.str()); -} - -int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setTimer(index, t); - } - - // multi - auto r = parallelCall(&slsDetector::setTimer, index, t); - return sls::minusOneIfDifferent(r); -} - -int64_t multiSlsDetector::secondsToNanoSeconds(double t) { - int64_t ns = lround(t * 1E9); - return (ns < 0) ? -1 : ns; -} - -double multiSlsDetector::setExposureTime(double t, bool inseconds, int detPos) { - if (!inseconds) { - return setTimer(ACQUISITION_TIME, (int64_t)t, detPos); - } - auto t_ns = setTimer(ACQUISITION_TIME, secondsToNanoSeconds(t), detPos); - return (t_ns < 0) ? -1 : 1E-9 * t_ns; -} - -double multiSlsDetector::setExposurePeriod(double t, bool inseconds, - int detPos) { - if (!inseconds) { - return setTimer(FRAME_PERIOD, (int64_t)t, detPos); - } - auto t_ns = setTimer(FRAME_PERIOD, secondsToNanoSeconds(t), detPos); - return (t_ns < 0) ? -1 : 1E-9 * t_ns; -} - -double multiSlsDetector::setDelayAfterTrigger(double t, bool inseconds, - int detPos) { - if (!inseconds) { - return setTimer(DELAY_AFTER_TRIGGER, (int64_t)t, detPos); - } - auto t_ns = setTimer(DELAY_AFTER_TRIGGER, secondsToNanoSeconds(t), detPos); - return (t_ns < 0) ? -1 : 1E-9 * t_ns; -} - -double multiSlsDetector::setSubFrameExposureTime(double t, bool inseconds, - int detPos) { - if (!inseconds) { - return setTimer(SUBFRAME_ACQUISITION_TIME, (int64_t)t, detPos); - } - auto t_ns = - setTimer(SUBFRAME_ACQUISITION_TIME, secondsToNanoSeconds(t), detPos); - return (t_ns < 0) ? -1 : 1E-9 * t_ns; -} - -double multiSlsDetector::setSubFrameExposureDeadTime(double t, bool inseconds, - int detPos) { - if (!inseconds) { - return setTimer(SUBFRAME_DEADTIME, (int64_t)t, detPos); - } - auto t_ns = setTimer(SUBFRAME_DEADTIME, secondsToNanoSeconds(t), detPos); - return (t_ns < 0) ? -1 : 1E-9 * t_ns; -} - -int64_t multiSlsDetector::setNumberOfFrames(int64_t t, int detPos) { - return setTimer(FRAME_NUMBER, t, detPos); -} - -int64_t multiSlsDetector::setNumberOfTriggers(int64_t t, int detPos) { - return setTimer(TRIGGER_NUMBER, t, detPos); -} - -int64_t multiSlsDetector::setNumberOfStorageCells(int64_t t, int detPos) { - return setTimer(STORAGE_CELL_NUMBER, t, detPos); -} - -double multiSlsDetector::getMeasuredPeriod(bool inseconds, int detPos) { - if (!inseconds) { - return getTimeLeft(MEASURED_PERIOD, detPos); - } else { - int64_t tms = getTimeLeft(MEASURED_PERIOD, detPos); - if (tms < 0) { - return -1; - } - return ((1E-9) * (double)tms); - } -} - -double multiSlsDetector::getMeasuredSubFramePeriod(bool inseconds, int detPos) { - if (!inseconds) { - return getTimeLeft(MEASURED_SUBPERIOD, detPos); - } else { - int64_t tms = getTimeLeft(MEASURED_SUBPERIOD, detPos); - if (tms < 0) { - return -1; - } - return ((1E-9) * (double)tms); - } -} - -int64_t multiSlsDetector::getTimeLeft(timerIndex index, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getTimeLeft(index); - } - - // multi - auto r = parallelCall(&slsDetector::getTimeLeft, index); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setSpeed(speedVariable index, int value, int mode, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setSpeed(index, value, mode); - } - - // multi - auto r = parallelCall(&slsDetector::setSpeed, index, value, mode); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setDynamicRange(int dr, int detPos) { - // single - if (detPos >= 0) { - throw RuntimeError("Dynamic Range cannot be set individually"); - } - - // multi - int prevValue = -1; - auto temp = Parallel(&slsDetector::getDynamicRangeFromShm, {}); - if (temp.equal()) { - prevValue = temp.squash(); - } - - auto r = parallelCall(&slsDetector::setDynamicRange, dr); - int ret = sls::minusOneIfDifferent(r); - - // change in dr - if (dr != -1 && dr != prevValue) { - - // update speed, check ratecorrection - if (getDetectorTypeAsEnum() == EIGER) { - - // rate correction before speed for consistency - // (else exception at speed makes ratecorr inconsistent) - parallelCall(&slsDetector::updateRateCorrection); - - // speed(usability) - switch (dr) { - case 32: - FILE_LOG(logINFO) - << "Setting Clock to Quarter Speed to cope with " - "Dynamic Range of 32"; - setSpeed(CLOCK_DIVIDER, 2); - break; - case 16: - FILE_LOG(logINFO) - << "Setting Clock to Half Speed for Dynamic Range of 16"; - setSpeed(CLOCK_DIVIDER, 1); - break; - default: - break; - } - } - } - - return ret; -} - -int multiSlsDetector::setDAC(int val, dacIndex index, int mV, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setDAC(val, index, mV); - } - - // multi - auto r = parallelCall(&slsDetector::setDAC, val, index, mV); - if (getDetectorTypeAsEnum() != EIGER && index != HIGH_VOLTAGE) { - return sls::minusOneIfDifferent(r); - } - - // ignore slave values for hv (-999) - int firstValue = r.front(); - for (const auto &value : r) { - if ((value != -999) && (value != firstValue)) { - return -1; - } - } - - return firstValue; -} - -int multiSlsDetector::getADC(dacIndex index, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getADC(index); - } - - // multi - auto r = parallelCall(&slsDetector::getADC, index); - return sls::minusOneIfDifferent(r); -} - -slsDetectorDefs::timingMode multiSlsDetector::setTimingMode(timingMode pol, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setTimingMode(pol); - } - - // multi - auto r = parallelCall(&slsDetector::setTimingMode, pol); - return sls::minusOneIfDifferent(r); -} - -slsDetectorDefs::externalSignalFlag -multiSlsDetector::setExternalSignalFlags(externalSignalFlag pol, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setExternalSignalFlags(pol); - } - - // multi - auto r = parallelCall(&slsDetector::setExternalSignalFlags, pol); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setReadoutMode(const slsDetectorDefs::readoutMode mode, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setReadoutMode(mode); - } - - // multi - parallelCall(&slsDetector::setReadoutMode, mode); -} - -slsDetectorDefs::readoutMode multiSlsDetector::getReadoutMode(int detPos) { - // single - if (detPos >= 0) { - return (detectors[detPos]->getReadoutMode()); - } - - // multi - auto r = parallelCall(&slsDetector::getReadoutMode); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setInterruptSubframe(const bool enable, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setInterruptSubframe(enable); - } - - // multi - parallelCall(&slsDetector::setInterruptSubframe, enable); -} - -int multiSlsDetector::getInterruptSubframe(int detPos) { - // single - if (detPos >= 0) { - return static_cast(detectors[detPos]->getInterruptSubframe()); - } - - // multi - auto r = parallelCall(&slsDetector::getInterruptSubframe); - return sls::minusOneIfDifferent(r); -} - -uint32_t multiSlsDetector::writeRegister(uint32_t addr, uint32_t val, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->writeRegister(addr, val); - } - - // multi - auto r = parallelCall(&slsDetector::writeRegister, addr, val); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values - std::ostringstream ss; - ss << "Error: Different Values for function writeRegister (write 0x" - << std::hex << val << " to addr 0x" << std::hex << addr << std::dec - << ")"; - throw RuntimeError(ss.str()); -} - -uint32_t multiSlsDetector::readRegister(uint32_t addr, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->readRegister(addr); - } - - // multi - auto r = parallelCall(&slsDetector::readRegister, addr); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values - std::ostringstream ss; - ss << "Error: Different Values for function readRegister (read from 0x" - << std::hex << addr << std::dec << ")"; - throw RuntimeError(ss.str()); -} - -uint32_t multiSlsDetector::setBit(uint32_t addr, int n, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setBit(addr, n); - } - - // multi - auto r = parallelCall(&slsDetector::setBit, addr, n); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values - std::ostringstream ss; - ss << "Error: Different Values for function setBit " - "(set bit " - << n << " to addr 0x" << std::hex << addr << std::dec << ")"; - throw RuntimeError(ss.str()); -} - -uint32_t multiSlsDetector::clearBit(uint32_t addr, int n, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->clearBit(addr, n); - } - - // multi - auto r = parallelCall(&slsDetector::clearBit, addr, n); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values - std::ostringstream ss; - ss << "Error: Different Values for function clearBit (clear bit " << n - << " to addr 0x" << std::hex << addr << std::dec << ")"; - throw RuntimeError(ss.str()); -} - -std::string multiSlsDetector::setReceiverHostname(const std::string &receiver, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setReceiverHostname(receiver); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverHostname, receiver); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::getReceiverHostname(int detPos) const { - // single - if (detPos >= 0) { - return detectors[detPos]->getReceiverHostname(); - } - - // multi - auto r = parallelCall(&slsDetector::getReceiverHostname); - return sls::concatenateIfDifferent(r); -} - - -void multiSlsDetector::setNumberofUDPInterfaces(int n, int detPos) { - - bool previouslyClientStreaming = enableDataStreamingToClient(); - int previouslyReceiverStreaming = enableDataStreamingFromReceiver(); - - // single - if (detPos >= 0) { - detectors[detPos]->setNumberofUDPInterfaces(n); - } - - // multi - parallelCall(&slsDetector::setNumberofUDPInterfaces, n); - - // redo the zmq sockets - if (previouslyClientStreaming) { - enableDataStreamingToClient(0); - enableDataStreamingToClient(1); - } - if (previouslyReceiverStreaming != 0) { - enableDataStreamingFromReceiver(0); - enableDataStreamingFromReceiver(1); - } -} - -int multiSlsDetector::getNumberofUDPInterfaces(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getNumberofUDPInterfaces(); - } - - // multi - auto r = parallelCall(&slsDetector::getNumberofUDPInterfaces); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::selectUDPInterface(int n, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->selectUDPInterface(n); - } - - // multi - parallelCall(&slsDetector::selectUDPInterface, n); -} - -int multiSlsDetector::getSelectedUDPInterface(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getSelectedUDPInterface(); - } - - // multi - auto r = parallelCall(&slsDetector::getSelectedUDPInterface); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) { - if (i >= 0) { - bool prev_streaming = enableDataStreamingToClient(); - - // single - if (detPos >= 0) { - detectors[detPos]->setClientStreamingPort(i); - } - // multi - else { - // calculate ports individually - int firstPort = i; - int numSockets = (getDetectorTypeAsEnum() == EIGER) ? 2 : 1; - if (getNumberofUDPInterfaces() == 2) - numSockets *= 2; - - for (size_t idet = 0; idet < detectors.size(); ++idet) { - auto port = firstPort + (idet * numSockets); - detectors[idet]->setClientStreamingPort(port); - } - } - - if (prev_streaming) { - enableDataStreamingToClient(0); - enableDataStreamingToClient(1); - } - } -} - -int multiSlsDetector::getClientStreamingPort(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getClientStreamingPort(); - } - - // multi - auto r = serialCall(&slsDetector::getClientStreamingPort); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setReceiverDataStreamingOutPort(int i, int detPos) { - if (i >= 0) { - int prev_streaming = enableDataStreamingFromReceiver(-1, detPos); - - // single - if (detPos >= 0) { - detectors[detPos]->setReceiverStreamingPort(i); - } - // multi - else { - // calculate ports individually - int firstPort = i; - int numSockets = (getDetectorTypeAsEnum() == EIGER) ? 2 : 1; - if (getNumberofUDPInterfaces() == 2) - numSockets *= 2; - - for (size_t idet = 0; idet < detectors.size(); ++idet) { - auto port = firstPort + (idet * numSockets); - detectors[idet]->setReceiverStreamingPort(port); - } - } - - if (prev_streaming != 0) { - enableDataStreamingFromReceiver(0, detPos); - enableDataStreamingFromReceiver(1, detPos); - } - } -} - -int multiSlsDetector::getReceiverStreamingPort(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getReceiverStreamingPort(); - } - - // multi - auto r = serialCall(&slsDetector::getReceiverStreamingPort); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setDetectorNetworkParameter(networkParameter index, - int value, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setDetectorNetworkParameter(index, value); - } - - // multi - auto r = - parallelCall(&slsDetector::setDetectorNetworkParameter, index, value); - return sls::minusOneIfDifferent(r); -} - -std::string -multiSlsDetector::setAdditionalJsonHeader(const std::string &jsonheader, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setAdditionalJsonHeader(jsonheader); - } - - // multi - auto r = parallelCall(&slsDetector::setAdditionalJsonHeader, jsonheader); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::getAdditionalJsonHeader(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getAdditionalJsonHeader(); - } - - // multi - auto r = serialCall(&slsDetector::getAdditionalJsonHeader); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::setAdditionalJsonParameter( - const std::string &key, const std::string &value, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setAdditionalJsonParameter(key, value); - } - - // multi - auto r = parallelCall(&slsDetector::setAdditionalJsonParameter, key, value); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::getAdditionalJsonParameter(const std::string &key, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getAdditionalJsonParameter(key); - } - - // multi - auto r = serialCall(&slsDetector::getAdditionalJsonParameter, key); - return sls::concatenateIfDifferent(r); -} - -int multiSlsDetector::setDetectorMinMaxEnergyThreshold(const int index, - int value, int detPos) { - std::string parameter = (index != 0 ? "emax" : "emin"); - - std::string result; - if (value < 0) { - result = getAdditionalJsonParameter(parameter, detPos); - } else { - result = setAdditionalJsonParameter(parameter, std::to_string(value), - detPos); - } - - // convert to integer - try { - return stoi(result); - } - // not found or cannot scan integer - catch (...) { - return -1; - } -} - -int multiSlsDetector::setFrameMode(frameModeType value, int detPos) { - std::string parameter = "frameMode"; - std::string result; - - if (value == GET_FRAME_MODE) { - result = getAdditionalJsonParameter(parameter, detPos); - } else { - result = setAdditionalJsonParameter(parameter, sls::ToString(value), - detPos); - } - - return sls::StringTo(result); -} - -int multiSlsDetector::setDetectorMode(detectorModeType value, int detPos) { - std::string parameter = "detectorMode"; - std::string result; - - if (value == GET_DETECTOR_MODE) { - result = getAdditionalJsonParameter(parameter, detPos); - } else { - result = setAdditionalJsonParameter(parameter, - sls::ToString(value), detPos); - } - - return sls::StringTo(result); -} - -int64_t multiSlsDetector::setReceiverUDPSocketBufferSize(int64_t udpsockbufsize, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setReceiverUDPSocketBufferSize( - udpsockbufsize); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverUDPSocketBufferSize, - udpsockbufsize); - return sls::minusOneIfDifferent(r); -} - -int64_t multiSlsDetector::getReceiverUDPSocketBufferSize(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getReceiverUDPSocketBufferSize(); - } - - // multi - auto r = serialCall(&slsDetector::getReceiverUDPSocketBufferSize); - return sls::minusOneIfDifferent(r); -} - -int64_t multiSlsDetector::getReceiverRealUDPSocketBufferSize(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getReceiverRealUDPSocketBufferSize(); - } - - // multi - auto r = serialCall(&slsDetector::getReceiverRealUDPSocketBufferSize); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setFlowControl10G(int enable, int detPos) { - if (enable != -1) { - enable = ((enable >= 1) ? 1 : 0); - } - return setDetectorNetworkParameter(FLOW_CONTROL_10G, enable, detPos); -} - -int multiSlsDetector::digitalTest(digitalTestMode mode, int ival, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->digitalTest(mode, ival); - } - - // multi - auto r = parallelCall(&slsDetector::digitalTest, mode, ival); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setCounterBit(int i, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setCounterBit(i); - } - - // multi - auto r = parallelCall(&slsDetector::setCounterBit, i); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::clearROI(int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->clearROI(); - } - - // multi - parallelCall(&slsDetector::clearROI); -} - -void multiSlsDetector::setROI(slsDetectorDefs::ROI arg, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setROI(arg); - } - - // multi - if (detPos < 0 && size() > 1) { - throw RuntimeError("Cannot set ROI for all modules simultaneously"); - } - detectors[0]->setROI(arg); -} - -slsDetectorDefs::ROI multiSlsDetector::getROI(int detPos) const { - // single - if (detPos >= 0) { - return detectors[detPos]->getROI(); - } - - // multi - if (detPos < 0 && size() > 1) { - throw RuntimeError("Cannot get ROI for all modules simultaneously"); - } - return detectors[0]->getROI(); -} - -void multiSlsDetector::setADCEnableMask(uint32_t mask, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setADCEnableMask(mask); - } - - parallelCall(&slsDetector::setADCEnableMask, mask); -} - -uint32_t multiSlsDetector::getADCEnableMask(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getADCEnableMask(); - } - - auto r = parallelCall(&slsDetector::getADCEnableMask); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values - throw RuntimeError("Error: Different Values for function getADCEnableMask"); -} - -void multiSlsDetector::setADCInvert(uint32_t value, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setADCInvert(value); - } - - parallelCall(&slsDetector::setADCInvert, value); -} - -uint32_t multiSlsDetector::getADCInvert(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getADCInvert(); - } - - auto r = parallelCall(&slsDetector::getADCInvert); - if (sls::allEqual(r)) { - return r.front(); - } - - // can't have different values - throw RuntimeError("Error: Different Values for function getADCInvert"); -} - -void multiSlsDetector::setExternalSamplingSource(int value, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setExternalSamplingSource(value); - } - - parallelCall(&slsDetector::setExternalSamplingSource, value); -} - -int multiSlsDetector::getExternalSamplingSource(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getExternalSamplingSource(); - } - - auto r = parallelCall(&slsDetector::getExternalSamplingSource); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setExternalSampling(bool value, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setExternalSampling(static_cast(value)); - } - - parallelCall(&slsDetector::setExternalSampling, static_cast(value)); -} - -int multiSlsDetector::getExternalSampling(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getExternalSampling(); - } - - auto r = parallelCall(&slsDetector::getExternalSampling); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setReceiverDbitList(std::vector list, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setReceiverDbitList(list); - } - - parallelCall(&slsDetector::setReceiverDbitList, list); -} - -std::vector multiSlsDetector::getReceiverDbitList(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getReceiverDbitList(); - } - - auto r = parallelCall(&slsDetector::getReceiverDbitList); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setReceiverDbitOffset(int value, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setReceiverDbitOffset(value); - } - - parallelCall(&slsDetector::setReceiverDbitOffset, value); -} - -int multiSlsDetector::getReceiverDbitOffset(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getReceiverDbitOffset(); - } - - auto r = parallelCall(&slsDetector::getReceiverDbitOffset); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::writeAdcRegister(uint32_t addr, uint32_t val, - int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->writeAdcRegister(addr, val); - } - - // multi - parallelCall(&slsDetector::writeAdcRegister, addr, val); -} - -int multiSlsDetector::activate(int const enable, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->activate(enable); - } - - // multi - auto r = parallelCall(&slsDetector::activate, enable); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setDeactivatedRxrPaddingMode(int padding, int detPos) { - // single - if (detPos >= 0) { - return static_cast( - detectors[detPos]->setDeactivatedRxrPaddingMode(padding)); - } - - // multi - auto r = parallelCall(&slsDetector::setDeactivatedRxrPaddingMode, padding); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getFlippedDataX(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getFlippedDataX(); - } - - // multi - auto r = serialCall(&slsDetector::getFlippedDataX); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setFlippedDataX(int value, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setFlippedDataX(value); - } - - // multi - auto r = parallelCall(&slsDetector::setFlippedDataX, value); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setAllTrimbits(int val, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setAllTrimbits(val); - } - - // multi - auto r = parallelCall(&slsDetector::setAllTrimbits, val); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::enableGapPixels(int val, int detPos) { - if (getDetectorTypeAsEnum() != EIGER) { - if (val >= 0) { - throw NotImplementedError( - "Function (enableGapPixels) not implemented for this detector"); - } - return 0; - } - - // single - if (detPos >= 0) { - if (val >= 0) { - throw RuntimeError("Function (enableGapPixels) must be called from " - "a multi detector level."); - } - return detectors[detPos]->enableGapPixels(val); - } - - // multi - auto r = parallelCall(&slsDetector::enableGapPixels, val); - int ret = sls::minusOneIfDifferent(r); - - if (val != -1) { - 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)); +void multiSlsDetector::setGapPixelsinReceiver(bool enable) { + Parallel(&slsDetector::enableGapPixels, {}, static_cast(enable)); + // update number of channels Result res = Parallel(&slsDetector::getNumberOfChannels, {}); multi_shm()->numberOfChannels.x = 0; @@ -1755,481 +462,6 @@ void multiSlsDetector::setGapPixelsEnable(bool enable, Positions pos) { } } -int multiSlsDetector::setTrimEn(std::vector energies, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->setTrimEn(energies); - } - auto r = parallelCall(&slsDetector::setTrimEn, energies); - return sls::minusOneIfDifferent(r); -} - -std::vector multiSlsDetector::getTrimEn(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getTrimEn(); - } - auto r = parallelCall(&slsDetector::getTrimEn); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::pulsePixel(int n, int x, int y, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->pulsePixel(n, x, y); - } - - // multi - parallelCall(&slsDetector::pulsePixel, n, x, y); -} - -void multiSlsDetector::pulsePixelNMove(int n, int x, int y, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->pulsePixelNMove(n, x, y); - } - - // multi - parallelCall(&slsDetector::pulsePixelNMove, n, x, y); -} - -void multiSlsDetector::pulseChip(int n, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->pulseChip(n); - } - - // multi - parallelCall(&slsDetector::pulseChip, n); -} - -int multiSlsDetector::setThresholdTemperature(int val, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setThresholdTemperature(val); - } - - // multi - auto r = parallelCall(&slsDetector::setThresholdTemperature, val); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setTemperatureControl(int val, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setTemperatureControl(val); - } - - // multi - auto r = parallelCall(&slsDetector::setTemperatureControl, val); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setTemperatureEvent(int val, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setTemperatureEvent(val); - } - - // multi - auto r = parallelCall(&slsDetector::setTemperatureEvent, val); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setStoragecellStart(int pos, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setStoragecellStart(pos); - } - - // multi - auto r = parallelCall(&slsDetector::setStoragecellStart, pos); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::programFPGA(const std::string &fname, int detPos) { - FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; - // read pof file - std::vector buffer = readPofFile(fname); - - // single - if (detPos >= 0) { - detectors[detPos]->programFPGA(buffer); - } - - // multi - parallelCall(&slsDetector::programFPGA, buffer); -} - -void multiSlsDetector::resetFPGA(int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->resetFPGA(); - } - - // multi - parallelCall(&slsDetector::resetFPGA); -} - -void multiSlsDetector::copyDetectorServer(const std::string &fname, - const std::string &hostname, - int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->copyDetectorServer(fname, hostname); - detectors[detPos]->rebootController(); - // reboot and copy should be independant for - // update command - } - - // multi - parallelCall(&slsDetector::copyDetectorServer, fname, hostname); - parallelCall(&slsDetector::rebootController); -} - -void multiSlsDetector::rebootController(int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->rebootController(); - } - - // multi - parallelCall(&slsDetector::rebootController); -} - -void multiSlsDetector::update(const std::string &sname, - const std::string &hostname, - const std::string &fname, int detPos) { - FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; - // read pof file - std::vector buffer = readPofFile(fname); - - // single - if (detPos >= 0) { - detectors[detPos]->copyDetectorServer(sname, hostname); - detectors[detPos]->programFPGA(buffer); - } - - // multi - parallelCall(&slsDetector::copyDetectorServer, sname, hostname); - parallelCall(&slsDetector::programFPGA, buffer); -} - -int multiSlsDetector::powerChip(int ival, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->powerChip(ival); - } - - // multi delayed call for safety - if (ival >= 0 && size() > 3) { - std::vector r; - r.reserve(detectors.size()); - for (auto &d : detectors) { - r.push_back(d->powerChip(ival)); - usleep(1000 * 1000); - } - return sls::minusOneIfDifferent(r); - } - // multi parallel - auto r = parallelCall(&slsDetector::powerChip, ival); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setAutoComparatorDisableMode(ival); - } - - // multi - auto r = parallelCall(&slsDetector::setAutoComparatorDisableMode, ival); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setDefaultRateCorrection(int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setDefaultRateCorrection(); - } - - // multi - parallelCall(&slsDetector::setDefaultRateCorrection); -} - -void multiSlsDetector::setRateCorrection(int64_t t, int detPos) { - if (t < 0) { - throw sls::RuntimeError("Dead time has to be greater or equal to 0"); - } - // single - if (detPos >= 0) { - detectors[detPos]->setRateCorrection(t); - } - - // multi - parallelCall(&slsDetector::setRateCorrection, t); -} - -int64_t multiSlsDetector::getRateCorrection(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getRateCorrection(); - } - - // multi - auto r = parallelCall(&slsDetector::getRateCorrection); - return sls::minusOneIfDifferent(r); -} - -std::string multiSlsDetector::printReceiverConfiguration(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->printReceiverConfiguration(); - } - - // multi - auto r = parallelCall(&slsDetector::printReceiverConfiguration); - // concatenate without '+' - std::string ret; - for (const auto &s : r) - if (!s.empty()) - ret += s; - return ret; -} - -bool multiSlsDetector::getUseReceiverFlag(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getUseReceiverFlag(); - } - - // multi - auto r = parallelCall(&slsDetector::getUseReceiverFlag); - if (sls::allEqual(r)) { - return r.front(); - } else { - throw RuntimeError("Inconsistent Use receiver flags"); - } -} - -int multiSlsDetector::lockReceiver(int lock, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->lockReceiver(lock); - } - - // multi - auto r = parallelCall(&slsDetector::lockReceiver, lock); - return sls::minusOneIfDifferent(r); -} - - - -void multiSlsDetector::exitReceiver(int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->exitReceiver(); - } - - // multi - parallelCall(&slsDetector::exitReceiver); -} - -void multiSlsDetector::execReceiverCommand(const std::string &cmd, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->execReceiverCommand(cmd); - } - - // multi - parallelCall(&slsDetector::execReceiverCommand, cmd); -} - -std::string multiSlsDetector::getFilePath(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getFilePath(); - } - - // multi - auto r = serialCall(&slsDetector::getFilePath); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::setFilePath(const std::string &path, int detPos) { - if (path.empty()) { - return getFilePath(detPos); - } - - // single - if (detPos >= 0) { - return detectors[detPos]->setFilePath(path); - } - - // multi - auto r = parallelCall(&slsDetector::setFilePath, path); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::getFileName(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getFileName(); - } - - // multi - auto r = serialCall(&slsDetector::getFileName); - return sls::concatenateIfDifferent(r); -} - -std::string multiSlsDetector::setFileName(const std::string &fname, - int detPos) { - if (fname.empty()) { - return getFileName(detPos); - } - - // single - if (detPos >= 0) { - return detectors[detPos]->setFileName(fname); - } - - // multi - auto r = parallelCall(&slsDetector::setFileName, fname); - return sls::concatenateIfDifferent(r); -} - -int multiSlsDetector::setFramesPerFile(int f, int detPos) { - if (detPos >= 0) { - return detectors[detPos]->setFramesPerFile(f); - } - auto r = parallelCall(&slsDetector::setFramesPerFile, f); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getFramesPerFile(int detPos) const { - if (detPos >= 0) { - return detectors[detPos]->getFramesPerFile(); - } - auto r = parallelCall(&slsDetector::getFramesPerFile); - return sls::minusOneIfDifferent(r); -} - -slsDetectorDefs::frameDiscardPolicy -multiSlsDetector::setReceiverFramesDiscardPolicy(frameDiscardPolicy f, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setReceiverFramesDiscardPolicy(f); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverFramesDiscardPolicy, f); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setPartialFramesPadding(bool padding, int detPos) { - if (detPos >= 0) - return static_cast( - detectors[detPos]->setPartialFramesPadding(padding)); - auto r = parallelCall(&slsDetector::setPartialFramesPadding, padding); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getPartialFramesPadding(int detPos) const { - if (detPos >= 0) - return static_cast(detectors[detPos]->getPartialFramesPadding()); - auto r = parallelCall(&slsDetector::getPartialFramesPadding); - return sls::minusOneIfDifferent(r); -} - -slsDetectorDefs::fileFormat multiSlsDetector::getFileFormat(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getFileFormat(); - } - - // multi - auto r = serialCall(&slsDetector::getFileFormat); - return sls::minusOneIfDifferent(r); -} - -slsDetectorDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setFileFormat(f); - } - - // multi - auto r = parallelCall(&slsDetector::setFileFormat, f); - return sls::minusOneIfDifferent(r); -} - -int64_t multiSlsDetector::incrementFileIndex(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->incrementFileIndex(); - } - - // multi - auto r = parallelCall(&slsDetector::incrementFileIndex); - return sls::minusOneIfDifferent(r); -} - -int64_t multiSlsDetector::setFileIndex(int64_t i, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setFileIndex(i); - } - - // multi - auto r = parallelCall(&slsDetector::setFileIndex, i); - return sls::minusOneIfDifferent(r); -} - -int64_t multiSlsDetector::getFileIndex(int detPos) const { - if (detPos >= 0) - return detectors[detPos]->getFileIndex(); - auto r = parallelCall(&slsDetector::getFileIndex); - return sls::minusOneIfDifferent(r); -} - - -int multiSlsDetector::getFramesCaughtByReceiver(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getFramesCaughtByReceiver(); - } - - // multi - auto r = parallelCall(&slsDetector::getFramesCaughtByReceiver); - - // prevent divide by all or do not take avg when -1 for "did not connect" - if ((detectors.empty()) || (sls::anyEqualTo(r, -1))) { - return -1; - } - - // return average - return ((sls::sum(r)) / (int)detectors.size()); -} - -uint64_t multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getReceiverCurrentFrameIndex(); - } - - // multi - auto r = parallelCall(&slsDetector::getReceiverCurrentFrameIndex); - - // prevent divide by all or do not take avg when -1 for "did not connect" - if ((detectors.empty()) || - (sls::anyEqualTo(r, static_cast(-1)))) { - return -1; - } - - // return average - return ((sls::sum(r)) / (int)detectors.size()); -} - int multiSlsDetector::createReceivingDataSockets(const bool destroy) { if (destroy) { FILE_LOG(logINFO) << "Going to destroy data sockets"; @@ -2245,10 +477,10 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) { size_t numSockets = detectors.size(); size_t numSocketsPerDetector = 1; - if (getDetectorTypeAsEnum() == EIGER) { + if (multi_shm()->multiDetectorType == EIGER) { numSocketsPerDetector = 2; } - if (getNumberofUDPInterfaces() == 2) { + if (Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {}).squash() == 2) { numSocketsPerDetector = 2; } numSockets *= numSocketsPerDetector; @@ -2287,7 +519,7 @@ void multiSlsDetector::readFrameFromReceiver() { bool gappixelsenable = false; bool quadEnable = false; bool eiger = false; - bool numInterfaces = getNumberofUDPInterfaces(); // cannot pick up from zmq + bool numInterfaces = Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {}).squash(); // cannot pick up from zmq bool runningList[zmqSocket.size()], connectList[zmqSocket.size()]; int numRunning = 0; @@ -2429,7 +661,7 @@ void multiSlsDetector::readFrameFromReceiver() { uint32_t yoffset = coordY * nPixelsY; uint32_t singledetrowoffset = nPixelsX * bytesPerPixel; uint32_t rowoffset = nX * singledetrowoffset; - if (getDetectorTypeAsEnum() == CHIPTESTBOARD) { + if (multi_shm()->multiDetectorType == CHIPTESTBOARD) { singledetrowoffset = size; } FILE_LOG(logDEBUG1) @@ -2673,76 +905,6 @@ int multiSlsDetector::processImageWithGapPixels(char *image, char *&gpImage, return gapdatabytes; } -int multiSlsDetector::setFileWrite(bool value, int detPos) { - if (detPos >= 0) { - return static_cast(detectors[detPos]->setFileWrite(value)); - } - auto r = parallelCall(&slsDetector::setFileWrite, value); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getFileWrite(int detPos) const { - if (detPos >= 0) { - return static_cast(detectors[detPos]->getFileWrite()); - } - auto r = parallelCall(&slsDetector::getFileWrite); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setMasterFileWrite(bool value, int detPos) { - if (detPos >= 0) { - return static_cast(detectors[detPos]->setMasterFileWrite(value)); - } - auto r = parallelCall(&slsDetector::setMasterFileWrite, value); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getMasterFileWrite(int detPos) const { - if (detPos >= 0) { - return static_cast(detectors[detPos]->getMasterFileWrite()); - } - auto r = parallelCall(&slsDetector::getMasterFileWrite); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setFileOverWrite(bool enable, int detPos) { - if (detPos >= 0) { - return static_cast(detectors[detPos]->setFileOverWrite(enable)); - } - auto r = parallelCall(&slsDetector::setFileOverWrite, enable); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::getFileOverWrite(int detPos) const { - if (detPos >= 0) { - return static_cast(detectors[detPos]->getFileOverWrite()); - } - auto r = parallelCall(&slsDetector::getFileOverWrite); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setReceiverStreamingFrequency(int freq, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setReceiverStreamingFrequency(freq); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverStreamingFrequency, freq); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setReceiverStreamingTimer(int time_in_ms, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setReceiverStreamingTimer(time_in_ms); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverStreamingTimer, time_in_ms); - return sls::minusOneIfDifferent(r); -} - bool multiSlsDetector::enableDataStreamingToClient(int enable) { if (enable >= 0) { // destroy data threads @@ -2758,61 +920,6 @@ bool multiSlsDetector::enableDataStreamingToClient(int enable) { return client_downstream; } -int multiSlsDetector::enableDataStreamingFromReceiver(int enable, int detPos) { - // single - if (detPos >= 0) { - return static_cast( - detectors[detPos]->enableDataStreamingFromReceiver(enable)); - } - - // multi - auto r = - parallelCall(&slsDetector::enableDataStreamingFromReceiver, enable); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::enableTenGigabitEthernet(int i, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->enableTenGigabitEthernet(i); - } - - // multi - auto r = parallelCall(&slsDetector::enableTenGigabitEthernet, i); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setReceiverFifoDepth(int i, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setReceiverFifoDepth(i); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverFifoDepth, i); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setReceiverSilentMode(int i, int detPos) { - // single - if (detPos >= 0) { - return static_cast(detectors[detPos]->setReceiverSilentMode(i)); - } - - // multi - auto r = parallelCall(&slsDetector::setReceiverSilentMode, i); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setPattern(const std::string &fname, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setPattern(fname); - } - - // multi - parallelCall(&slsDetector::setPattern, fname); -} void multiSlsDetector::savePattern(const std::string &fname) { std::ofstream outfile; @@ -2854,128 +961,6 @@ void multiSlsDetector::savePattern(const std::string &fname) { multiSlsDetectorClient(cmd, GET_ACTION, this, outfile); } -uint64_t multiSlsDetector::setPatternIOControl(uint64_t word, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setPatternIOControl(word); - } - - // multi - auto r = parallelCall(&slsDetector::setPatternIOControl, word); - return sls::minusOneIfDifferent(r); -} - -uint64_t multiSlsDetector::setPatternClockControl(uint64_t word, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setPatternClockControl(word); - } - - // multi - auto r = parallelCall(&slsDetector::setPatternClockControl, word); - return sls::minusOneIfDifferent(r); -} - -uint64_t multiSlsDetector::setPatternWord(int addr, uint64_t word, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setPatternWord(addr, word); - } - - // multi - auto r = parallelCall(&slsDetector::setPatternWord, addr, word); - return sls::minusOneIfDifferent(r); -} - -int multiSlsDetector::setPatternWaitAddr(int level, int addr, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setPatternWaitAddr(level, addr); - } - - // multi - auto r = parallelCall(&slsDetector::setPatternWaitAddr, level, addr); - return sls::minusOneIfDifferent(r); -} - -uint64_t multiSlsDetector::setPatternWaitTime(int level, uint64_t t, - int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setPatternWaitTime(level, t); - } - - // multi - auto r = parallelCall(&slsDetector::setPatternWaitTime, level, t); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setPatternMask(uint64_t mask, int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setPatternMask(mask); - } - - // multi - parallelCall(&slsDetector::setPatternMask, mask); -} - -uint64_t multiSlsDetector::getPatternMask(int detPos) { - if (detPos >= 0) - return detectors[detPos]->getPatternMask(); - auto r = parallelCall(&slsDetector::getPatternMask); - if (sls::allEqual(r)) { - return r.front(); - } else { - - throw RuntimeError("multiSlsDetector::getPatternMask: Error: Different " - "Values returned)"); - } -} - -void multiSlsDetector::setPatternBitMask(uint64_t mask, int detPos) { - if (detPos >= 0) { - detectors[detPos]->setPatternBitMask(mask); - } - parallelCall(&slsDetector::setPatternBitMask, mask); -} - -uint64_t multiSlsDetector::getPatternBitMask(int detPos) { - if (detPos >= 0) { - return detectors[detPos]->getPatternBitMask(); - } - auto r = parallelCall(&slsDetector::getPatternBitMask); - if (sls::allEqual(r)) { - return r.front(); - } - - // should not have different values - throw RuntimeError( - "multiSlsDetector::getPatternBitMask Different Values returned)"); -} - -int multiSlsDetector::setLEDEnable(int enable, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setLEDEnable(enable); - } - - // multi - auto r = parallelCall(&slsDetector::setLEDEnable, enable); - return sls::minusOneIfDifferent(r); -} - -void multiSlsDetector::setDigitalIODelay(uint64_t pinMask, int delay, - int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setDigitalIODelay(pinMask, delay); - } - - // multi - parallelCall(&slsDetector::setDigitalIODelay, pinMask, delay); -} - void multiSlsDetector::loadParameters(const std::string &fname) { std::ifstream input_file; input_file.open(fname.c_str(), std::ios_base::in); @@ -3010,13 +995,13 @@ void multiSlsDetector::registerDataCallback( void *pArg) { dataReady = userCallback; pCallbackArg = pArg; - if (getUseReceiverFlag()) { + if (Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) { if (dataReady == nullptr) { enableDataStreamingToClient(0); - enableDataStreamingFromReceiver(0); + Parallel(&slsDetector::enableDataStreamingFromReceiver, {}, 0); } else { enableDataStreamingToClient(1); - enableDataStreamingFromReceiver(1); + Parallel(&slsDetector::enableDataStreamingFromReceiver, {}, 1); } } } @@ -3031,7 +1016,7 @@ int multiSlsDetector::setTotalProgress() { } int ns = 1; - if (getDetectorTypeAsEnum() == JUNGFRAU) { + if (multi_shm()->multiDetectorType == JUNGFRAU) { ns = Parallel(&slsDetector::setTimer, {}, STORAGE_CELL_NUMBER, -1) .tsquash("Inconsistent number of additional storage cells"); ++ns; @@ -3068,7 +1053,7 @@ void multiSlsDetector::setCurrentProgress(int i) { int multiSlsDetector::acquire() { // ensure acquire isnt started multiple times by same client - if (static_cast(isAcquireReady()) == FAIL) { + if (!isAcquireReady()) { return FAIL; } @@ -3083,7 +1068,7 @@ int multiSlsDetector::acquire() { // process) sem_init(&sem_endRTAcquisition, 1, 0); - bool receiver = getUseReceiverFlag(); + bool receiver = Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false); progressIndex = 0; setJoinThreadFlag(false); @@ -3105,7 +1090,7 @@ int multiSlsDetector::acquire() { } // start and read all - if (getDetectorTypeAsEnum() == EIGER) { + if (multi_shm()->multiDetectorType == EIGER) { Parallel(&slsDetector::prepareAcquisition, {}); } Parallel(&slsDetector::startAndReadAll, {}); @@ -3119,7 +1104,7 @@ int multiSlsDetector::acquire() { // external process to be // done sending data to gui - incrementFileIndex(); + Parallel(&slsDetector::incrementFileIndex, {}); } // waiting for the data processing thread to finish! @@ -3157,7 +1142,7 @@ void multiSlsDetector::startProcessingThread() { } void multiSlsDetector::processData() { - if (getUseReceiverFlag()) { + if (Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) { if (dataReady != nullptr) { readFrameFromReceiver(); } @@ -3174,7 +1159,7 @@ void multiSlsDetector::processData() { } } // get progress - caught = getFramesCaughtByReceiver(0); + caught = Parallel(&slsDetector::getFramesCaughtByReceiver, {0}).squash(); // updating progress if (caught != -1) { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index f66f21895..4a39c1e1d 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -391,6 +391,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) { shm()->rxMasterFileWrite = true; shm()->rxFileOverWrite = true; shm()->rxDbitOffset = 0; + shm()->numUDPInterfaces = 1; // get the detector parameters based on type detParameters parameters{type}; @@ -545,14 +546,10 @@ int slsDetector::setDetectorType(detectorType const type) { return retval; } -slsDetectorDefs::detectorType slsDetector::getDetectorTypeAsEnum() const { +slsDetectorDefs::detectorType slsDetector::getDetectorType() const { return shm()->myDetectorType; } -std::string slsDetector::getDetectorTypeAsString() const { - return ToString(getDetectorTypeAsEnum()); -} - void slsDetector::updateNumberOfChannels() { if (shm()->myDetectorType == CHIPTESTBOARD || shm()->myDetectorType == MOENCH) { @@ -832,6 +829,12 @@ void slsDetector::updateCachedDetectorVariables() { updateNumberOfChannels(); } + // num udp interfaces + if (shm()->myDetectorType == JUNGFRAU) { + n += client.Receive(&i32, sizeof(i32)); + shm()->numUDPInterfaces = i32; + } + if (n == 0) { FILE_LOG(logERROR) << "Could not update detector, received 0 bytes"; } @@ -1312,6 +1315,8 @@ int slsDetector::setSpeed(speedVariable sp, int value, int mode) { int slsDetector::setDynamicRange(int n) { // TODO! Properly handle fail + int prevDr = shm()->dynamicRange; + int retval = -1; FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n; sendToDetector(F_SET_DYNAMIC_RANGE, n, retval); @@ -1325,11 +1330,22 @@ int slsDetector::setDynamicRange(int n) { sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, n, retval); FILE_LOG(logDEBUG1) << "Receiver Dynamic range: " << retval; } + + // changes in dr + int dr = shm()->dynamicRange; + if (prevDr != dr && shm()->myDetectorType == EIGER) { + updateRateCorrection(); + // update speed for usability + if (dr == 32) { + FILE_LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32"; setSpeed(CLOCK_DIVIDER, 2); + } else if (dr == 16) { + FILE_LOG(logINFO) << "Setting Clock to Half Speed to cope with Dynamic Range of 16"; setSpeed(CLOCK_DIVIDER, 1); + } + } + return shm()->dynamicRange; } -int slsDetector::getDynamicRangeFromShm() { return shm()->dynamicRange; } - int slsDetector::setDAC(int val, dacIndex index, int mV) { int args[]{static_cast(index), mV, val}; int retval = -1; @@ -1857,17 +1873,24 @@ int slsDetector::getDestinationUDPPort2() { void slsDetector::setNumberofUDPInterfaces(int n) { FILE_LOG(logDEBUG1) << "Setting number of udp interfaces to " << n; sendToDetector(F_SET_NUM_INTERFACES, n, nullptr); + shm()->numUDPInterfaces = n; if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_NUM_INTERFACES, n, nullptr); } } +int slsDetector::getNumberofUDPInterfacesFromShm() { + return shm()->numUDPInterfaces; +} + + int slsDetector::getNumberofUDPInterfaces() { int retval = -1; FILE_LOG(logDEBUG1) << "Getting number of udp interfaces"; sendToDetector(F_GET_NUM_INTERFACES, nullptr, retval); FILE_LOG(logDEBUG1) << "Number of udp interfaces: " << retval; - return retval; + shm()->numUDPInterfaces = retval; + return shm()->numUDPInterfaces; } void slsDetector::selectUDPInterface(int n) { @@ -2380,6 +2403,10 @@ int slsDetector::setAllTrimbits(int val) { int slsDetector::enableGapPixels(int val) { if (val >= 0) { + if (shm()->myDetectorType != EIGER) { + throw NotImplementedError( + "Function (enableGapPixels) not implemented for this detector"); + } int fnum = F_ENABLE_GAPPIXELS_IN_RECEIVER; int retval = -1; FILE_LOG(logDEBUG1) << "Sending gap pixels enable to receiver: " << val; diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index 1f35a1110..ab7b4f09c 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -1,5 +1,6 @@ #include "slsDetectorCommand.h" #include "multiSlsDetector.h" +#include "slsDetector.h" #include "string_utils.h" #include @@ -80,16 +81,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { - /*! \page test - - help Returns a list of possible commands. - */ - descrToFuncMap[i].m_pFuncName = "help"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdHelp; - ++i; - - - - /* Acquisition and status commands */ /*! \page acquisition Acquition commands Commands to control the acquisition @@ -103,28 +94,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { ++i; - /*! \page config - - \b free Free shared memory on the control PC - */ - descrToFuncMap[i].m_pFuncName = "free"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFree; - ++i; - - - /*! \page config - - checkdetversion Checks the version compatibility with detector server (if hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible") - */ - descrToFuncMap[i].m_pFuncName = "checkdetversion"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSN; - ++i; - - /*! \page config - - rx_checkversion Checks the version compatibility with receiver server (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible") - */ - descrToFuncMap[i].m_pFuncName = "rx_checkversion"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSN; - ++i; - /* settings dump/retrieve */ @@ -182,40 +151,6 @@ std::vector slsDetectorCommand::getAllCommands(){ return commands; } -std::string slsDetectorCommand::helpLine(int narg, const char * const args[], int action, int detPos) { - - std::ostringstream os; - - if (action == READOUT_ACTION) { - return helpAcquire(HELP_ACTION); - } - - if (narg == 0) { - os << "Command can be: " << std::endl; - for (int i = 0; i < numberOfCommands; ++i) { - os << descrToFuncMap[i].m_pFuncName << "\n"; - } - os << std::endl; - return os.str(); - } - return executeLine(narg, args, HELP_ACTION, detPos); -} - - -std::string slsDetectorCommand::cmdHelp(int narg, const char * const args[], int action, int detPos) { -#ifdef VERBOSE - std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n"); -#endif - - std::cout << narg << std::endl; - - if (narg >= 1) - return helpLine(narg - 1, args, action, detPos); - else - return helpLine(0, args, action, detPos); -} - - std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[], int action, int detPos) { @@ -237,10 +172,11 @@ std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[], if (myDet->acquire() == FAIL) return std::string("acquire failed"); - if (myDet->getUseReceiverFlag(detPos)) { - char answer[100]; - sprintf(answer, "\nAcquired %d", myDet->getFramesCaughtByReceiver(detPos)); - return std::string(answer); + if (myDet->Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) { + std::ostringstream os; + os << "\nAcquired "; + os << sls::ToString(myDet->Parallel(&slsDetector::getFramesCaughtByReceiver, {})); + return os.str(); } return std::string(); @@ -260,61 +196,6 @@ std::string slsDetectorCommand::helpAcquire(int action) { -std::string slsDetectorCommand::cmdFree(int narg, const char * const args[], int action, int detPos) { - -#ifdef VERBOSE - std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n"); -#endif - if (action == HELP_ACTION) { - return helpFree(HELP_ACTION); - } - - return ("Error: Should have been freed before creating constructor\n"); -} - -std::string slsDetectorCommand::helpFree(int action) { - return std::string("free \t frees the shared memory\n"); -} - - - - -std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int action, int detPos) { - - if (action == PUT_ACTION) - return std::string("cannot set"); - - if (action == HELP_ACTION) - return helpSN(action); - - - if (cmd == "checkdetversion") { - myDet->checkDetectorVersionCompatibility(detPos); - return std::string("compatible"); - } - - if (cmd == "rx_checkversion") { - myDet->checkReceiverVersionCompatibility(detPos); - return std::string("compatible"); - } - - return std::string("unknown id mode ") + cmd; -} - -std::string slsDetectorCommand::helpSN(int action) { - - std::ostringstream os; - if (action == GET_ACTION || action == HELP_ACTION) { - os << "checkdetversion \n gets the version compatibility with detector server (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl; - os << "rx_checkversion \n gets the version compatibility with receiver server (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl; - } - return os.str(); -} - - - - - std::string slsDetectorCommand::cmdConfiguration(int narg, const char * const args[], int action, int detPos) { diff --git a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp index f16946907..c068cab2b 100644 --- a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp +++ b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp @@ -3076,14 +3076,14 @@ TEST_CASE("zmqport", "[.cmd]") { } int port = 3500; REQUIRE_NOTHROW(multiSlsDetectorClient("zmqport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":zmqport", GET, nullptr, oss)); REQUIRE(oss.str() == "zmqport " + std::to_string(port + i * socketsperdetector) + '\n'); } port = 1954; REQUIRE_NOTHROW(multiSlsDetectorClient("zmqport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":zmqport", GET, nullptr, oss)); REQUIRE(oss.str() == "zmqport " + std::to_string(port + i * socketsperdetector) + '\n'); @@ -3104,14 +3104,14 @@ TEST_CASE("rx_zmqport", "[.cmd]") { } int port = 3500; REQUIRE_NOTHROW(multiSlsDetectorClient("rx_zmqport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_zmqport", GET, nullptr, oss)); REQUIRE(oss.str() == "rx_zmqport " + std::to_string(port + i * socketsperdetector) + '\n'); } port = 30001; REQUIRE_NOTHROW(multiSlsDetectorClient("rx_zmqport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_zmqport", GET, nullptr, oss)); REQUIRE(oss.str() == "rx_zmqport " + std::to_string(port + i * socketsperdetector) + '\n'); @@ -3337,14 +3337,14 @@ TEST_CASE("network", "[.cmd]") { } int port = 5500; REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":udp_dstport", GET, nullptr, oss)); REQUIRE(oss.str() == "udp_dstport " + std::to_string(port + i * socketsperdetector) + '\n'); } port = 50001; REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":udp_dstport", GET, nullptr, oss)); REQUIRE(oss.str() == "udp_dstport " + std::to_string(port + i * socketsperdetector) + '\n'); @@ -4235,7 +4235,7 @@ TEST_CASE("rx_tcpport", "[.cmd]") { multiSlsDetector d; int port = 3500; REQUIRE_NOTHROW(multiSlsDetectorClient("rx_tcpport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_tcpport", GET, nullptr, oss)); REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n'); @@ -4243,7 +4243,7 @@ TEST_CASE("rx_tcpport", "[.cmd]") { REQUIRE_THROWS(multiSlsDetectorClient("rx_tcpport 15", PUT)); port = 1954; REQUIRE_NOTHROW(multiSlsDetectorClient("rx_tcpport " + std::to_string(port), PUT)); - for (size_t i = 0; i != d.size(); ++i) { + for (int i = 0; i != d.size(); ++i) { std::ostringstream oss; REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_tcpport", GET, nullptr, oss)); REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n'); diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 548e6d87e..4d0aaa8b6 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -4,9 +4,9 @@ #define APIRECEIVER 0x190722 #define APIGUI 0x190723 #define APIMOENCH 0x190820 -#define APICTB 0x191029 -#define APIGOTTHARD 0x191029 -#define APIGOTTHARD2 0x191029 -#define APIEIGER 0x191029 -#define APIMYTHEN3 0x191030 #define APIJUNGFRAU 0x191030 +#define APIEIGER 0x191030 +#define APIGOTTHARD 0x191030 +#define APIGOTTHARD2 0x191030 +#define APIMYTHEN3 0x191030 +#define APICTB 0x191030