mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 07:40:03 +02:00
merge conflict resolved
This commit is contained in:
commit
70a1b87603
2
.clang-format
Normal file
2
.clang-format
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
@ -14,8 +14,8 @@ else ()
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
|
||||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
|
||||||
|
|
||||||
find_package(Qt4)
|
find_package(Qt4)
|
||||||
find_package(Qwt 6)
|
find_package(Qwt 6)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,41 +2,44 @@
|
|||||||
#define MULTI_SLS_DETECTOR_H
|
#define MULTI_SLS_DETECTOR_H
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@libdoc The multiSlsDetector class is used to operate several slsDetectors in parallel.
|
@libdoc The multiSlsDetector class is used to operate several slsDetectors in
|
||||||
|
parallel.
|
||||||
* @short This is the base class for multi detector system functionalities
|
* @short This is the base class for multi detector system functionalities
|
||||||
* @author Anna Bergamaschi
|
* @author Anna Bergamaschi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "error_defs.h"
|
#include "error_defs.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
|
|
||||||
class slsDetector;
|
class slsDetector;
|
||||||
class SharedMemory;
|
class SharedMemory;
|
||||||
class ZmqSocket;
|
class ZmqSocket;
|
||||||
class detectorData;
|
class detectorData;
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <mutex>
|
||||||
#include <string>
|
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#define MULTI_SHMVERSION 0x181002
|
#define MULTI_SHMVERSION 0x181002
|
||||||
#define SHORT_STRING_LENGTH 50
|
#define SHORT_STRING_LENGTH 50
|
||||||
#define DATE_LENGTH 30
|
#define DATE_LENGTH 30
|
||||||
|
|
||||||
class multiSlsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
|
class multiSlsDetector : public virtual slsDetectorDefs,
|
||||||
|
public virtual errorDefs {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short structure allocated in shared memory to store detector settings for IPC and cache
|
* @short structure allocated in shared memory to store detector settings
|
||||||
|
* for IPC and cache
|
||||||
*/
|
*/
|
||||||
typedef struct sharedMultiSlsDetector {
|
typedef struct sharedMultiSlsDetector {
|
||||||
|
|
||||||
|
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND
|
||||||
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND ------*/
|
* ------*/
|
||||||
|
|
||||||
/** shared memory version */
|
/** shared memory version */
|
||||||
int shmversion;
|
int shmversion;
|
||||||
@ -53,10 +56,8 @@ private:
|
|||||||
/** number of sls detectors in shared memory */
|
/** number of sls detectors in shared memory */
|
||||||
int numberOfDetectors;
|
int numberOfDetectors;
|
||||||
|
|
||||||
/** END OF FIXED PATTERN -----------------------------------------------*/
|
/** END OF FIXED PATTERN
|
||||||
|
* -----------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Number of detectors operated at once */
|
/** Number of detectors operated at once */
|
||||||
int numberOfDetector[2];
|
int numberOfDetector[2];
|
||||||
@ -101,10 +102,6 @@ private:
|
|||||||
/** timer values */
|
/** timer values */
|
||||||
int64_t timerValue[MAX_TIMERS];
|
int64_t timerValue[MAX_TIMERS];
|
||||||
|
|
||||||
/** threaded processing flag (i.e. if data are processed and written to
|
|
||||||
* file in a separate thread) */
|
|
||||||
int threadedProcessing;
|
|
||||||
|
|
||||||
/** flag for acquiring */
|
/** flag for acquiring */
|
||||||
bool acquiringFlag;
|
bool acquiringFlag;
|
||||||
|
|
||||||
@ -117,16 +114,12 @@ private:
|
|||||||
|
|
||||||
} sharedMultiSlsDetector;
|
} sharedMultiSlsDetector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param id multi detector id
|
* @param id multi detector id
|
||||||
* @param verify true to verify if shared memory version matches existing one
|
* @param verify true to verify if shared memory version matches existing
|
||||||
|
* one
|
||||||
* @param update true to update last user pid, date etc
|
* @param update true to update last user pid, date etc
|
||||||
*/
|
*/
|
||||||
multiSlsDetector(int id = 0, bool verify = true, bool update = true);
|
multiSlsDetector(int id = 0, bool verify = true, bool update = true);
|
||||||
@ -139,7 +132,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Creates/open shared memory, initializes detector structure and members
|
* Creates/open shared memory, initializes detector structure and members
|
||||||
* Called by constructor/ set hostname / read config file
|
* Called by constructor/ set hostname / read config file
|
||||||
* @param verify true to verify if shared memory version matches existing one
|
* @param verify true to verify if shared memory version matches existing
|
||||||
|
* one
|
||||||
* @param update true to update last user pid, date etc
|
* @param update true to update last user pid, date etc
|
||||||
*/
|
*/
|
||||||
void setupMultiDetector(bool verify = true, bool update = true);
|
void setupMultiDetector(bool verify = true, bool update = true);
|
||||||
@ -156,16 +150,19 @@ public:
|
|||||||
* and return a vector of results
|
* and return a vector of results
|
||||||
*/
|
*/
|
||||||
template <typename RT, typename... CT>
|
template <typename RT, typename... CT>
|
||||||
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...), CT... Args);
|
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...),
|
||||||
|
CT... Args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If specific position, then provide result with that detector at position pos
|
* If specific position, then provide result with that detector at position
|
||||||
* else concatenate the result of all detectors
|
* pos else concatenate the result of all detectors
|
||||||
* @param somefunc function pointer
|
* @param somefunc function pointer
|
||||||
* @param pos positin of detector in array (-1 is for all)
|
* @param pos positin of detector in array (-1 is for all)
|
||||||
* @returns result for detector at that position or concatenated string of all detectors
|
* @returns result for detector at that position or concatenated string of
|
||||||
|
* all detectors
|
||||||
*/
|
*/
|
||||||
// std::string concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos);
|
// std::string concatResultOrPos(std::string (slsDetector::*somefunc)(int),
|
||||||
|
// int pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes which detector and the corresponding channel numbers for it
|
* Decodes which detector and the corresponding channel numbers for it
|
||||||
@ -234,21 +231,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
int64_t getId(idMode mode, int detPos = -1);
|
int64_t getId(idMode mode, int detPos = -1);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sls detector object from position in detectors array
|
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
|
||||||
* @returns pointer to sls detector object
|
|
||||||
*/
|
|
||||||
// slsDetector* getSlsDetector(int detPos = -1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Accessing the sls detector from the multi list using position
|
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
|
||||||
* @returns slsDetector object
|
|
||||||
*/
|
|
||||||
// slsDetector *operator()(int detPos = -1) const;
|
|
||||||
|
|
||||||
// slsDetector* operator[](int detPos) const;
|
|
||||||
/**
|
/**
|
||||||
* Free shared memory from the command line
|
* Free shared memory from the command line
|
||||||
* avoiding creating the constructor classes and mapping
|
* avoiding creating the constructor classes and mapping
|
||||||
@ -284,23 +266,25 @@ public:
|
|||||||
* Gets the hostname of detector at particular position
|
* Gets the hostname of detector at particular position
|
||||||
* or concatenated hostnames of all the sls detectors
|
* or concatenated hostnames of all the sls detectors
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns concatenated hostnames of all detectors or hostname of specific one
|
* @returns concatenated hostnames of all detectors or hostname of specific
|
||||||
|
* one
|
||||||
*/
|
*/
|
||||||
std::string getHostname(int detPos = -1);
|
std::string getHostname(int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends detectors to the end of the list in shared memory
|
* Appends detectors to the end of the list in shared memory
|
||||||
* Connects to them to set up online flag
|
* Connects to them to set up online flag
|
||||||
* @param name concatenated hostname of the sls detectors to be appended to the list
|
* @param name concatenated hostname of the sls detectors to be appended to
|
||||||
|
* the list
|
||||||
*/
|
*/
|
||||||
void addMultipleDetectors(const char *name);
|
void addMultipleDetectors(const char *name);
|
||||||
|
|
||||||
|
|
||||||
using slsDetectorDefs::getDetectorType;
|
using slsDetectorDefs::getDetectorType;
|
||||||
/**
|
/**
|
||||||
* Get Detector type for a particular sls detector or get the first one
|
* 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
|
* @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
|
* @returns detector type of sls detector in position pos, if -1, returns
|
||||||
|
* the first det type
|
||||||
*/
|
*/
|
||||||
detectorType getDetectorsType(int detPos = -1);
|
detectorType getDetectorsType(int detPos = -1);
|
||||||
|
|
||||||
@ -308,14 +292,16 @@ public:
|
|||||||
* Concatenates string types of all sls detectors or
|
* Concatenates string types of all sls detectors or
|
||||||
* returns the detector type of the first sls detector
|
* returns the detector type of the first sls detector
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns detector type of sls detector in position pos, if -1, concatenates
|
* @returns detector type of sls detector in position pos, if -1,
|
||||||
|
* concatenates
|
||||||
*/
|
*/
|
||||||
std::string sgetDetectorsType(int detPos = -1);
|
std::string sgetDetectorsType(int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets Detector type (concatenates if different)
|
* Gets Detector type (concatenates if different)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns detector type of sls detector in position pos, if -1, concatenates
|
* @returns detector type of sls detector in position pos, if -1,
|
||||||
|
* concatenates
|
||||||
*/
|
*/
|
||||||
std::string getDetectorType(int detPos = -1);
|
std::string getDetectorType(int detPos = -1);
|
||||||
|
|
||||||
@ -340,7 +326,8 @@ public:
|
|||||||
void getNumberOfDetectors(int &nx, int &ny);
|
void getNumberOfDetectors(int &nx, int &ny);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total number of channels of all sls detectors from shared memory
|
* Returns the total number of channels of all sls detectors from shared
|
||||||
|
* memory
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns the total number of channels of all sls detectors
|
* @returns the total number of channels of all sls detectors
|
||||||
*/
|
*/
|
||||||
@ -366,21 +353,23 @@ public:
|
|||||||
int getTotalNumberOfChannelsInclGapPixels(dimension d, int detPos = -1);
|
int getTotalNumberOfChannelsInclGapPixels(dimension d, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum number of channels of all sls detectors in each dimension d
|
* Returns the maximum number of channels of all sls detectors in each
|
||||||
* from shared memory. multi detector shared memory variable to calculate
|
* dimension d from shared memory. multi detector shared memory variable to
|
||||||
* offsets for each sls detector
|
* calculate offsets for each sls detector
|
||||||
* @param d dimension d
|
* @param d dimension d
|
||||||
* @returns the maximum number of channels of all sls detectors in dimension d
|
* @returns the maximum number of channels of all sls detectors in dimension
|
||||||
|
* d
|
||||||
*/
|
*/
|
||||||
int getMaxNumberOfChannelsPerDetector(dimension d);
|
int getMaxNumberOfChannelsPerDetector(dimension d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the maximum number of channels of all sls detectors in each dimension d
|
* Sets the maximum number of channels of all sls detectors in each
|
||||||
* from shared memory, multi detector shared memory variable to calculate
|
* dimension d from shared memory, multi detector shared memory variable to
|
||||||
* offsets for each sls detector
|
* calculate offsets for each sls detector
|
||||||
* @param d dimension d
|
* @param d dimension d
|
||||||
* @param i maximum number of channels for multi structure in dimension d
|
* @param i maximum number of channels for multi structure in dimension d
|
||||||
* @returns the maximum number of channels of all sls detectors in dimension d
|
* @returns the maximum number of channels of all sls detectors in dimension
|
||||||
|
* d
|
||||||
*/
|
*/
|
||||||
int setMaxNumberOfChannelsPerDetector(dimension d, int i);
|
int setMaxNumberOfChannelsPerDetector(dimension d, int i);
|
||||||
|
|
||||||
@ -388,7 +377,8 @@ public:
|
|||||||
* Get Detector offset from shared memory in dimension d
|
* Get Detector offset from shared memory in dimension d
|
||||||
* @param d dimension d
|
* @param d dimension d
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns offset in dimension d, -1 if pos is not an actual position in list
|
* @returns offset in dimension d, -1 if pos is not an actual position in
|
||||||
|
* list
|
||||||
*/
|
*/
|
||||||
int getDetectorOffset(dimension d, int detPos = -1);
|
int getDetectorOffset(dimension d, int detPos = -1);
|
||||||
|
|
||||||
@ -401,8 +391,8 @@ public:
|
|||||||
void setDetectorOffset(dimension d, int off, int detPos = -1);
|
void setDetectorOffset(dimension d, int off, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the channel offsets in X and Y dimension for all the sls detectors
|
* Updates the channel offsets in X and Y dimension for all the sls
|
||||||
* It is required for decodeNMod and setting ROI
|
* detectors It is required for decodeNMod and setting ROI
|
||||||
*/
|
*/
|
||||||
void updateOffsets();
|
void updateOffsets();
|
||||||
|
|
||||||
@ -410,8 +400,10 @@ public:
|
|||||||
* Checks if the multi detectors are online and sets the online flag
|
* Checks if the multi detectors are online and sets the online flag
|
||||||
* @param online if GET_ONLINE_FLAG, only returns shared memory online flag,
|
* @param online if GET_ONLINE_FLAG, only returns shared memory online flag,
|
||||||
* else sets the detector in online/offline state
|
* else sets the detector in online/offline state
|
||||||
* if OFFLINE_FLAG, (i.e. no communication to the detector - using only local structure - no data acquisition possible!);
|
* if OFFLINE_FLAG, (i.e. no communication to the detector - using only
|
||||||
* if ONLINE_FLAG, detector in online state (i.e. communication to the detector updating the local structure)
|
* local structure - no data acquisition possible!); if ONLINE_FLAG,
|
||||||
|
* detector in online state (i.e. communication to the detector updating the
|
||||||
|
* local structure)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns online/offline status
|
* @returns online/offline status
|
||||||
*/
|
*/
|
||||||
@ -493,9 +485,9 @@ public:
|
|||||||
detectorSettings getSettings(int detPos = -1);
|
detectorSettings getSettings(int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load detector settings from the settings file picked from the trimdir/settingsdir
|
* Load detector settings from the settings file picked from the
|
||||||
* Eiger only stores in shared memory ( a get will overwrite this)
|
* trimdir/settingsdir Eiger only stores in shared memory ( a get will
|
||||||
* For Eiger, one must use threshold
|
* overwrite this) For Eiger, one must use threshold
|
||||||
* @param isettings settings
|
* @param isettings settings
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns current settings
|
* @returns current settings
|
||||||
@ -517,7 +509,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns current threshold value for imod in ev (-1 failed)
|
* @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);
|
int setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS,
|
||||||
|
int tb = 1, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the detector trimbit/settings directory \sa sharedSlsDetector
|
* Returns the detector trimbit/settings directory \sa sharedSlsDetector
|
||||||
@ -588,14 +581,16 @@ public:
|
|||||||
int sendSoftwareTrigger(int detPos = -1);
|
int sendSoftwareTrigger(int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start detector acquisition and read all data (Blocking until end of acquisition)
|
* Start detector acquisition and read all data (Blocking until end of
|
||||||
|
* acquisition)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int startAndReadAll(int detPos = -1);
|
int startAndReadAll(int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start readout (without exposure or interrupting exposure) (Eiger store in ram)
|
* Start readout (without exposure or interrupting exposure) (Eiger store in
|
||||||
|
* ram)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
@ -620,7 +615,8 @@ public:
|
|||||||
* @param index timer index
|
* @param index timer index
|
||||||
* @param t time in ns or number of...(e.g. frames, gates, probes)
|
* @param t time in ns or number of...(e.g. frames, gates, probes)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns timer set value in ns or number of...(e.g. frames, gates, probes)
|
* @returns timer set value in ns or number of...(e.g. frames, gates,
|
||||||
|
* probes)
|
||||||
*/
|
*/
|
||||||
int64_t setTimer(timerIndex index, int64_t t = -1, int detPos = -1);
|
int64_t setTimer(timerIndex index, int64_t t = -1, int detPos = -1);
|
||||||
|
|
||||||
@ -631,7 +627,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns exposure time in ns, or s if specified
|
* @returns exposure time in ns, or s if specified
|
||||||
*/
|
*/
|
||||||
double setExposureTime(double t = -1, bool inseconds = false, int detPos = -1);
|
double setExposureTime(double t = -1, bool inseconds = false,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get exposure period
|
* Set/get exposure period
|
||||||
@ -640,7 +637,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns exposure period in ns, or s if specified
|
* @returns exposure period in ns, or s if specified
|
||||||
*/
|
*/
|
||||||
double setExposurePeriod(double t = -1, bool inseconds = false, int detPos = -1);
|
double setExposurePeriod(double t = -1, bool inseconds = false,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get delay after trigger (Gotthard, Jungfrau(not for this release))
|
* Set/get delay after trigger (Gotthard, Jungfrau(not for this release))
|
||||||
@ -649,7 +647,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns delay after trigger in ns, or s if specified
|
* @returns delay after trigger in ns, or s if specified
|
||||||
*/
|
*/
|
||||||
double setDelayAfterTrigger(double t = -1, bool inseconds = false, int detPos = -1);
|
double setDelayAfterTrigger(double t = -1, bool inseconds = false,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Advanced users)
|
* (Advanced users)
|
||||||
@ -659,7 +658,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns sub frame exposure time in ns, or s if specified
|
* @returns sub frame exposure time in ns, or s if specified
|
||||||
*/
|
*/
|
||||||
double setSubFrameExposureTime(double t = -1, bool inseconds = false, int detPos = -1);
|
double setSubFrameExposureTime(double t = -1, bool inseconds = false,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Advanced users)
|
* (Advanced users)
|
||||||
@ -669,7 +669,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns sub frame dead time in ns, or s if specified
|
* @returns sub frame dead time in ns, or s if specified
|
||||||
*/
|
*/
|
||||||
double setSubFrameExposureDeadTime(double t = -1, bool inseconds = false, int detPos = -1);
|
double setSubFrameExposureDeadTime(double t = -1, bool inseconds = false,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get number of frames
|
* Set/get number of frames
|
||||||
@ -722,18 +723,22 @@ public:
|
|||||||
double getMeasuredSubFramePeriod(bool inseconds = false, int detPos = -1);
|
double getMeasuredSubFramePeriod(bool inseconds = false, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get timer value left in acquisition (not all implemented for all detectors)
|
* Set/get timer value left in acquisition (not all implemented for all
|
||||||
|
* detectors)
|
||||||
* @param index timer index
|
* @param index timer index
|
||||||
* @param t time in ns or number of...(e.g. frames, gates, probes)
|
* @param t time in ns or number of...(e.g. frames, gates, probes)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns timer set value in ns or number of...(e.g. frames, gates, probes)
|
* @returns timer set value in ns or number of...(e.g. frames, gates,
|
||||||
|
* probes)
|
||||||
*/
|
*/
|
||||||
int64_t getTimeLeft(timerIndex index, int detPos = -1);
|
int64_t getTimeLeft(timerIndex index, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set speed
|
* Set speed
|
||||||
* @param sp speed type (clkdivider option for Jungfrau and Eiger, others for Mythen/Gotthard)
|
* @param sp speed type (clkdivider option for Jungfrau and Eiger, others
|
||||||
* @param value (clkdivider 0,1,2 for full, half and quarter speed). Other values check manual
|
* for Mythen/Gotthard)
|
||||||
|
* @param value (clkdivider 0,1,2 for full, half and quarter speed). Other
|
||||||
|
* values check manual
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns value of speed set
|
* @returns value of speed set
|
||||||
*/
|
*/
|
||||||
@ -741,7 +746,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get dynamic range and updates the number of dataBytes
|
* 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)
|
* (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to
|
||||||
|
* 1)
|
||||||
* @param i dynamic range (-1 get)
|
* @param i dynamic range (-1 get)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns current dynamic range
|
* @returns current dynamic range
|
||||||
@ -770,7 +776,8 @@ public:
|
|||||||
* Get adc value
|
* Get adc value
|
||||||
* @param index adc(DAC) index
|
* @param index adc(DAC) index
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns current adc value (temperature for eiger and jungfrau in millidegrees)
|
* @returns current adc value (temperature for eiger and jungfrau in
|
||||||
|
* millidegrees)
|
||||||
*/
|
*/
|
||||||
int getADC(dacIndex index, int detPos = -1);
|
int getADC(dacIndex index, int detPos = -1);
|
||||||
|
|
||||||
@ -780,20 +787,26 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns current timing mode
|
* @returns current timing mode
|
||||||
*/
|
*/
|
||||||
externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE, int detPos = -1);
|
externalCommunicationMode setExternalCommunicationMode(
|
||||||
|
externalCommunicationMode pol = GET_EXTERNAL_COMMUNICATION_MODE,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get external signal flags (to specify triggerinrising edge etc) (Gotthard, Mythen)
|
* Set/get external signal flags (to specify triggerinrising edge etc)
|
||||||
|
* (Gotthard, Mythen)
|
||||||
* @param pol external signal flag (-1 gets)
|
* @param pol external signal flag (-1 gets)
|
||||||
* @param signalindex singal index (0 - 3)
|
* @param signalindex singal index (0 - 3)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns current timing mode
|
* @returns current timing mode
|
||||||
*/
|
*/
|
||||||
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0, int detPos = -1);
|
externalSignalFlag
|
||||||
|
setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG,
|
||||||
|
int signalindex = 0, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get readout flags (Eiger, Mythen)
|
* Set/get readout flags (Eiger, Mythen)
|
||||||
* @param flag readout flag (Eiger options: parallel, nonparallel, safe etc.) (-1 gets)
|
* @param flag readout flag (Eiger options: parallel, nonparallel, safe
|
||||||
|
* etc.) (-1 gets)
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns readout flag
|
* @returns readout flag
|
||||||
*/
|
*/
|
||||||
@ -856,7 +869,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns network parameter value set (from getNetworkParameter)
|
* @returns network parameter value set (from getNetworkParameter)
|
||||||
*/
|
*/
|
||||||
std::string setNetworkParameter(networkParameter parameter, std::string value, int detPos = -1);
|
std::string setNetworkParameter(networkParameter parameter,
|
||||||
|
std::string value, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get network parameter
|
* Get network parameter
|
||||||
@ -870,9 +884,11 @@ public:
|
|||||||
* (advanced users)
|
* (advanced users)
|
||||||
* Set/Get receiver streaming out ZMQ port and restarts receiver sockets
|
* Set/Get receiver streaming out ZMQ port and restarts receiver sockets
|
||||||
* @param i sets, -1 gets
|
* @param i sets, -1 gets
|
||||||
* If detPos is -1(multi module), port calculated (increments) for all the individual detectors using i
|
* 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
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns receiver streaming out ZMQ port (if multiple, of first receiver socket)
|
* @returns receiver streaming out ZMQ port (if multiple, of first receiver
|
||||||
|
* socket)
|
||||||
*/
|
*/
|
||||||
int setReceiverDataStreamingOutPort(int i = -1, int detPos = -1);
|
int setReceiverDataStreamingOutPort(int i = -1, int detPos = -1);
|
||||||
|
|
||||||
@ -880,9 +896,11 @@ public:
|
|||||||
* (advanced users)
|
* (advanced users)
|
||||||
* Set/Get client streaming in ZMQ port and restarts client sockets
|
* Set/Get client streaming in ZMQ port and restarts client sockets
|
||||||
* @param i sets, -1 gets
|
* @param i sets, -1 gets
|
||||||
* If detPos is -1(multi module), port calculated (increments) for all the individual detectors using i
|
* 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
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns receiver streaming out ZMQ port (if multiple, of first receiver socket)
|
* @returns receiver streaming out ZMQ port (if multiple, of first receiver
|
||||||
|
* socket)
|
||||||
*/
|
*/
|
||||||
int setClientDataStreamingInPort(int i = -1, int detPos = -1);
|
int setClientDataStreamingInPort(int i = -1, int detPos = -1);
|
||||||
|
|
||||||
@ -894,7 +912,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns receiver streaming out ZMQ IP
|
* @returns receiver streaming out ZMQ IP
|
||||||
*/
|
*/
|
||||||
std::string setReceiverDataStreamingOutIP(std::string ip="", int detPos = -1);
|
std::string setReceiverDataStreamingOutIP(std::string ip = "",
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (advanced users)
|
* (advanced users)
|
||||||
@ -904,7 +923,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns client streaming in ZMQ IP
|
* @returns client streaming in ZMQ IP
|
||||||
*/
|
*/
|
||||||
std::string setClientDataStreamingInIP(std::string ip="", int detPos = -1);
|
std::string setClientDataStreamingInIP(std::string ip = "",
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set 10GbE Flow Control (Eiger)
|
* Set 10GbE Flow Control (Eiger)
|
||||||
@ -930,7 +950,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int loadImageToDetector(imageType index, const std::string& fname, int detPos = -1);
|
int loadImageToDetector(imageType index, const std::string &fname,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the counter memory block from the detector (Gotthard)
|
* Writes the counter memory block from the detector (Gotthard)
|
||||||
@ -939,7 +960,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int writeCounterBlockFile(const std::string& fname,int startACQ=0, int detPos = -1);
|
int writeCounterBlockFile(const std::string &fname, int startACQ = 0,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets counter in detector (Gotthard)
|
* Resets counter in detector (Gotthard)
|
||||||
@ -951,7 +973,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/get counter bit in detector (Gotthard)
|
* Set/get counter bit in detector (Gotthard)
|
||||||
* @param i is -1 to get, 0 to reset and any other value to set the counter bit
|
* @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
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns the counter bit in detector
|
* @returns the counter bit in detector
|
||||||
*/
|
*/
|
||||||
@ -975,7 +998,8 @@ public:
|
|||||||
int setROI(int n = -1, ROI roiLimits[] = NULL, int detPos = -1);
|
int setROI(int n = -1, ROI roiLimits[] = NULL, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get ROI from each detector and convert it to the multi detector scale (Gotthard)
|
* Get ROI from each detector and convert it to the multi detector scale
|
||||||
|
* (Gotthard)
|
||||||
* @param n number of rois
|
* @param n number of rois
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
@ -983,7 +1007,8 @@ public:
|
|||||||
ROI *getROI(int &n, int detPos = -1);
|
ROI *getROI(int &n, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users
|
* Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert
|
||||||
|
* users
|
||||||
* @param addr address of adc register
|
* @param addr address of adc register
|
||||||
* @param val value
|
* @param val value
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
@ -1001,9 +1026,11 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set deactivated Receiver padding mode (Eiger only)
|
* Set deactivated Receiver padding mode (Eiger only)
|
||||||
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
|
* @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
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
|
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for
|
||||||
|
* padding option
|
||||||
*/
|
*/
|
||||||
int setDeactivatedRxrPaddingMode(int padding = -1, int detPos = -1);
|
int setDeactivatedRxrPaddingMode(int padding = -1, int detPos = -1);
|
||||||
|
|
||||||
@ -1273,7 +1300,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns frames discard policy set in receiver
|
* @returns frames discard policy set in receiver
|
||||||
*/
|
*/
|
||||||
frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY, int detPos = -1);
|
frameDiscardPolicy setReceiverFramesDiscardPolicy(
|
||||||
|
frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the partial frames padding enable in receiver
|
* Sets the partial frames padding enable in receiver
|
||||||
@ -1395,7 +1423,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* (previously setReadReceiverFrequency)
|
* (previously setReadReceiverFrequency)
|
||||||
* Sets the receiver streaming frequency
|
* Sets the receiver streaming frequency
|
||||||
* @param freq nth frame streamed out, if 0, streamed out at a timer of 200 ms
|
* @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
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns receiver streaming frequency
|
* @returns receiver streaming frequency
|
||||||
*/
|
*/
|
||||||
@ -1478,7 +1507,8 @@ public:
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK/FAIL
|
* @returns OK/FAIL
|
||||||
*/
|
*/
|
||||||
int setCTBPatLoops(int level,int &start, int &stop, int &n, int detPos = -1);
|
int setCTBPatLoops(int level, int &start, int &stop, int &n,
|
||||||
|
int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the wait address in the CTB
|
* Sets the wait address in the CTB
|
||||||
@ -1501,8 +1531,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Loads the detector setup from file
|
* Loads the detector setup from file
|
||||||
* @param fname file to read from
|
* @param fname file to read from
|
||||||
* @param level if 2 reads also reads trimbits, angular conversion coefficients etc.
|
* @param level if 2 reads also reads trimbits, angular conversion
|
||||||
* from files with default extensions as generated by dumpDetectorSetup
|
* coefficients etc. from files with default extensions as generated by
|
||||||
|
* dumpDetectorSetup
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int retrieveDetectorSetup(const std::string &fname, int level = 0);
|
int retrieveDetectorSetup(const std::string &fname, int level = 0);
|
||||||
@ -1510,8 +1541,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Saves the detector setup to file
|
* Saves the detector setup to file
|
||||||
* @param fname file to write to
|
* @param fname file to write to
|
||||||
* @param level if 2 reads also trimbits, flat field, angular correction etc.
|
* @param level if 2 reads also trimbits, flat field, angular correction
|
||||||
* and writes them to files with automatically added extension
|
* etc. and writes them to files with automatically added extension
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int dumpDetectorSetup(const std::string &fname, int level = 0);
|
int dumpDetectorSetup(const std::string &fname, int level = 0);
|
||||||
@ -1522,7 +1553,8 @@ public:
|
|||||||
* gets detector status and progress index as arguments
|
* gets detector status and progress index as arguments
|
||||||
* @param pArg argument
|
* @param pArg argument
|
||||||
*/
|
*/
|
||||||
void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg);
|
void registerAcquisitionFinishedCallback(int (*func)(double, int, void *),
|
||||||
|
void *pArg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register callback for accessing measurement final data
|
* register callback for accessing measurement final data
|
||||||
@ -1530,7 +1562,8 @@ public:
|
|||||||
* gets detector status and progress index as arguments
|
* gets detector status and progress index as arguments
|
||||||
* @param pArg argument
|
* @param pArg argument
|
||||||
*/
|
*/
|
||||||
void registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg);
|
void registerMeasurementFinishedCallback(int (*func)(int, int, void *),
|
||||||
|
void *pArg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register callback for accessing detector progress
|
* register callback for accessing detector progress
|
||||||
@ -1549,23 +1582,19 @@ public:
|
|||||||
* s is for subframe number for eiger for 32 bit mode
|
* s is for subframe number for eiger for 32 bit mode
|
||||||
* @param pArg argument
|
* @param pArg argument
|
||||||
*/
|
*/
|
||||||
void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg);
|
void registerDataCallback(int (*userCallback)(detectorData *, int, int,
|
||||||
|
void *),
|
||||||
|
void *pArg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a complete acquisition
|
* Performs a complete acquisition
|
||||||
* resets frames caught in receiver, starts receiver, starts detector,
|
* resets frames caught in receiver, starts receiver, starts detector,
|
||||||
* blocks till detector finished acquisition, stop receiver, increments file index,
|
* blocks till detector finished acquisition, stop receiver, increments file
|
||||||
* loops for measurements, calls required call backs.
|
* index, loops for measurements, calls required call backs.
|
||||||
* @returns OK or FAIL depending on if it already started
|
* @returns OK or FAIL depending on if it already started
|
||||||
*/
|
*/
|
||||||
int acquire();
|
int acquire();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set/get if the data processing thread si enabled
|
|
||||||
* @param enable 0 no data processing thread, 1 separate thread, -1 get
|
|
||||||
*/
|
|
||||||
int setThreadedProcessing(int enable=-1);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if detector position is out of bounds
|
* Returns true if detector position is out of bounds
|
||||||
*/
|
*/
|
||||||
@ -1575,11 +1604,12 @@ public:
|
|||||||
* Combines data from all readouts and gives it to the gui
|
* Combines data from all readouts and gives it to the gui
|
||||||
* or just gives progress of acquisition by polling receivers
|
* or just gives progress of acquisition by polling receivers
|
||||||
*/
|
*/
|
||||||
void* processData();
|
void processData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Initialize (open/create) shared memory for the sharedMultiDetector structure
|
* Initialize (open/create) shared memory for the sharedMultiDetector
|
||||||
|
* structure
|
||||||
* @param verify true to verify if shm size matches existing one
|
* @param verify true to verify if shm size matches existing one
|
||||||
* @param update true to update last user pid, date etc
|
* @param update true to update last user pid, date etc
|
||||||
* @returns true if shared memory was created in this call, else false
|
* @returns true if shared memory was created in this call, else false
|
||||||
@ -1618,7 +1648,8 @@ private:
|
|||||||
/**
|
/**
|
||||||
* add gap pixels to the image (only for Eiger in 4 bit mode)
|
* add gap pixels to the image (only for Eiger in 4 bit mode)
|
||||||
* @param image pointer to image without gap pixels
|
* @param image pointer to image without gap pixels
|
||||||
* @param gpImage poiner to image with gap pixels, if NULL, allocated inside function
|
* @param gpImage poiner to image with gap pixels, if NULL, allocated inside
|
||||||
|
* function
|
||||||
* @returns number of data bytes of image with gap pixels
|
* @returns number of data bytes of image with gap pixels
|
||||||
*/
|
*/
|
||||||
int processImageWithGapPixels(char *image, char *&gpImage);
|
int processImageWithGapPixels(char *image, char *&gpImage);
|
||||||
@ -1651,22 +1682,22 @@ private:
|
|||||||
*/
|
*/
|
||||||
void startProcessingThread();
|
void startProcessingThread();
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Static function to call processing thread
|
// * Static function to call processing thread
|
||||||
*/
|
// */
|
||||||
static void* startProcessData(void *n);
|
// static void* startProcessData(void *n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if processing thread is ready to join main thread
|
* Check if processing thread is ready to join main thread
|
||||||
* @returns true if ready, else false
|
* @returns true if ready, else false
|
||||||
*/
|
*/
|
||||||
int checkJoinThread();
|
bool getJoinThreadFlag() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main thread sets if the processing thread should join it
|
* Main thread sets if the processing thread should join it
|
||||||
* @param v true if it should join, else false
|
* @param v true if it should join, else false
|
||||||
*/
|
*/
|
||||||
void setJoinThread(int v);
|
void setJoinThreadFlag(bool value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen to key event to stop acquiring
|
* Listen to key event to stop acquiring
|
||||||
@ -1674,7 +1705,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
int kbhit(void);
|
int kbhit(void);
|
||||||
|
|
||||||
|
|
||||||
/** Multi detector Id */
|
/** Multi detector Id */
|
||||||
int detId;
|
int detId;
|
||||||
|
|
||||||
@ -1693,11 +1723,12 @@ private:
|
|||||||
/** ZMQ Socket - Receiver to Client */
|
/** ZMQ Socket - Receiver to Client */
|
||||||
std::vector<std::unique_ptr<ZmqSocket>> zmqSocket;
|
std::vector<std::unique_ptr<ZmqSocket>> zmqSocket;
|
||||||
|
|
||||||
|
/** semaphore to let postprocessing thread continue for next
|
||||||
/** semaphore to let postprocessing thread continue for next scan/measurement */
|
* scan/measurement */
|
||||||
sem_t sem_newRTAcquisition;
|
sem_t sem_newRTAcquisition;
|
||||||
|
|
||||||
/** semaphore to let main thread know it got all the dummy packets (also from ext. process) */
|
/** semaphore to let main thread know it got all the dummy packets (also
|
||||||
|
* from ext. process) */
|
||||||
sem_t sem_endRTAcquisition;
|
sem_t sem_endRTAcquisition;
|
||||||
|
|
||||||
/** Total number of frames/images for next acquisition */
|
/** Total number of frames/images for next acquisition */
|
||||||
@ -1707,19 +1738,20 @@ private:
|
|||||||
int progressIndex;
|
int progressIndex;
|
||||||
|
|
||||||
/** mutex to synchronize main and data processing threads */
|
/** mutex to synchronize main and data processing threads */
|
||||||
pthread_mutex_t mp;
|
mutable std::mutex mp;
|
||||||
|
|
||||||
/** mutex to synchronizedata processing and plotting threads */
|
/** mutex to synchronizedata processing and plotting threads */
|
||||||
pthread_mutex_t mg;
|
mutable std::mutex mg;
|
||||||
|
|
||||||
/** sets when the acquisition is finished */
|
/** sets when the acquisition is finished */
|
||||||
int jointhread;
|
bool jointhread;
|
||||||
|
|
||||||
/** set when detector finishes acquiring */
|
/** set when detector finishes acquiring */
|
||||||
int acquiringDone;
|
int acquiringDone;
|
||||||
|
|
||||||
/** the data processing thread */
|
/** the data processing thread */
|
||||||
pthread_t dataProcessingThread;
|
// pthread_t dataProcessingThread;
|
||||||
|
std::thread dataProcessingThread;
|
||||||
|
|
||||||
/** gui data */
|
/** gui data */
|
||||||
double *fdata;
|
double *fdata;
|
||||||
@ -1738,14 +1770,6 @@ private:
|
|||||||
|
|
||||||
int (*dataReady)(detectorData *, int, int, void *);
|
int (*dataReady)(detectorData *, int, int, void *);
|
||||||
void *pCallbackArg;
|
void *pCallbackArg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -400,7 +400,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
|||||||
thisDetector->nTrimEn = 0;
|
thisDetector->nTrimEn = 0;
|
||||||
for(int i = 0; i < MAX_TRIMEN; ++i)
|
for(int i = 0; i < MAX_TRIMEN; ++i)
|
||||||
thisDetector->trimEnergies[i] = 0;
|
thisDetector->trimEnergies[i] = 0;
|
||||||
thisDetector->threadedProcessing = 1;
|
// thisDetector->threadedProcessing = 1;
|
||||||
thisDetector->nROI = 0;
|
thisDetector->nROI = 0;
|
||||||
memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
||||||
thisDetector->roFlags = NORMAL_READOUT;
|
thisDetector->roFlags = NORMAL_READOUT;
|
||||||
|
@ -120,7 +120,7 @@ private:
|
|||||||
|
|
||||||
/** threaded processing flag
|
/** threaded processing flag
|
||||||
* (i.e. if data are processed in a separate thread) */
|
* (i.e. if data are processed in a separate thread) */
|
||||||
int threadedProcessing;
|
// int threadedProcessing;
|
||||||
|
|
||||||
/** number of rois defined */
|
/** number of rois defined */
|
||||||
int nROI;
|
int nROI;
|
||||||
|
@ -819,12 +819,12 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRateCorr;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRateCorr;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
/*! \page data
|
// /*! \page data
|
||||||
- <b>threaded [i]</b> Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded.
|
// - <b>threaded [i]</b> Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded.
|
||||||
*/
|
// */
|
||||||
descrToFuncMap[i].m_pFuncName="threaded"; //
|
// descrToFuncMap[i].m_pFuncName="threaded"; //
|
||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
// descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
||||||
++i;
|
// ++i;
|
||||||
|
|
||||||
/*! \page data
|
/*! \page data
|
||||||
- <b>darkimage fn</b> Loads the dark image to the detector from file fn (pedestal image). Cannot get. For Gotthard only.
|
- <b>darkimage fn</b> Loads the dark image to the detector from file fn (pedestal image). Cannot get. For Gotthard only.
|
||||||
@ -2154,21 +2154,21 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action, int detPo
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
||||||
#endif
|
#endif
|
||||||
int b;
|
//int b;
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
return string("cannot set");
|
return string("cannot set");
|
||||||
} else if (action==HELP_ACTION) {
|
} else if (action==HELP_ACTION) {
|
||||||
return helpData(HELP_ACTION);
|
return helpData(HELP_ACTION);
|
||||||
} else {
|
} else {
|
||||||
b=myDet->setThreadedProcessing(-1);
|
// b=myDet->setThreadedProcessing(-1);
|
||||||
myDet->setThreadedProcessing(0);
|
// myDet->setThreadedProcessing(0);
|
||||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
// myDet->setOnline(ONLINE_FLAG, detPos);
|
||||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
// myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||||
myDet->readAll(detPos);
|
// myDet->readAll(detPos);
|
||||||
//processdata in receiver is useful only for gui purposes
|
// //processdata in receiver is useful only for gui purposes
|
||||||
if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG)
|
// if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG)
|
||||||
myDet->processData();
|
// myDet->processData();
|
||||||
myDet->setThreadedProcessing(b);
|
// myDet->setThreadedProcessing(b);
|
||||||
return string("");
|
return string("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2743,21 +2743,21 @@ string slsDetectorCommand::helpRateCorr(int action){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
// string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
||||||
int ival;
|
// int ival;
|
||||||
char answer[1000];
|
// char answer[1000];
|
||||||
|
|
||||||
if (action==HELP_ACTION)
|
// if (action==HELP_ACTION)
|
||||||
return helpThreaded(action);
|
// return helpThreaded(action);
|
||||||
|
|
||||||
if (action==PUT_ACTION) {
|
// if (action==PUT_ACTION) {
|
||||||
if (sscanf(args[1],"%d",&ival))
|
// if (sscanf(args[1],"%d",&ival))
|
||||||
myDet->setThreadedProcessing(ival);
|
// myDet->setThreadedProcessing(ival);
|
||||||
}
|
// }
|
||||||
sprintf(answer,"%d",myDet->setThreadedProcessing());
|
// sprintf(answer,"%d",myDet->setThreadedProcessing());
|
||||||
return string(answer);
|
// return string(answer);
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
string slsDetectorCommand::helpThreaded(int action){
|
string slsDetectorCommand::helpThreaded(int action){
|
||||||
|
@ -113,7 +113,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
|||||||
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1);
|
// std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
|
||||||
|
@ -42,7 +42,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param dataModifyReadycb pointer to data ready call back function with modified
|
* @param dataModifyReadycb pointer to data ready call back function with modified
|
||||||
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
||||||
*/
|
*/
|
||||||
DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype,
|
DataProcessor(int ind, detectorType dtype, Fifo* f, fileFormat* ftype,
|
||||||
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
bool* fp, bool* act, bool* depaden, bool* sm,
|
bool* fp, bool* act, bool* depaden, bool* sm,
|
||||||
@ -121,7 +121,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
*/
|
*/
|
||||||
void SetFifo(Fifo*& f);
|
void SetFifo(Fifo* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset parameters for new acquisition (including all scans)
|
* Reset parameters for new acquisition (including all scans)
|
||||||
|
@ -31,7 +31,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param ajh additional json header
|
* @param ajh additional json header
|
||||||
* @param sm pointer to silent mode
|
* @param sm pointer to silent mode
|
||||||
*/
|
*/
|
||||||
DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
||||||
uint64_t* fi, int* fd, char* ajh, bool* sm);
|
uint64_t* fi, int* fd, char* ajh, bool* sm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
*/
|
*/
|
||||||
void SetFifo(Fifo*& f);
|
void SetFifo(Fifo* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset parameters for new acquisition (including all scans)
|
* Reset parameters for new acquisition (including all scans)
|
||||||
|
@ -37,7 +37,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param depaden pointer to deactivated padding enable
|
* @param depaden pointer to deactivated padding enable
|
||||||
* @param sm pointer to silent mode
|
* @param sm pointer to silent mode
|
||||||
*/
|
*/
|
||||||
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
|
||||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||||
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm);
|
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm);
|
||||||
@ -96,7 +96,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
*/
|
*/
|
||||||
void SetFifo(Fifo*& f);
|
void SetFifo(Fifo* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset parameters for new acquisition (including all scans)
|
* Reset parameters for new acquisition (including all scans)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "receiver_defs.h"
|
#include "receiver_defs.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "container_utils.h"
|
||||||
class GeneralData;
|
class GeneralData;
|
||||||
class Listener;
|
class Listener;
|
||||||
class DataProcessor;
|
class DataProcessor;
|
||||||
@ -18,6 +18,7 @@ class Fifo;
|
|||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class slsReceiverImplementation: private virtual slsDetectorDefs {
|
class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||||
public:
|
public:
|
||||||
@ -767,8 +768,6 @@ private:
|
|||||||
//*** receiver parameters ***
|
//*** receiver parameters ***
|
||||||
/** Number of Threads */
|
/** Number of Threads */
|
||||||
int numThreads;
|
int numThreads;
|
||||||
/** Number of Jobs */
|
|
||||||
int numberofJobs;
|
|
||||||
/** Number of channels in roi for jungfrauctb */
|
/** Number of channels in roi for jungfrauctb */
|
||||||
uint32_t nroichannels;
|
uint32_t nroichannels;
|
||||||
/** Maximum Number of Listening Threads/ UDP Ports */
|
/** Maximum Number of Listening Threads/ UDP Ports */
|
||||||
@ -832,13 +831,13 @@ private:
|
|||||||
/** General Data Properties */
|
/** General Data Properties */
|
||||||
GeneralData* generalData;
|
GeneralData* generalData;
|
||||||
/** Listener Objects that listen to UDP and push into fifo */
|
/** Listener Objects that listen to UDP and push into fifo */
|
||||||
std::vector <Listener*> listener;
|
std::vector<std::unique_ptr<Listener>> listener;
|
||||||
/** DataProcessor Objects that pull from fifo and process data */
|
/** DataProcessor Objects that pull from fifo and process data */
|
||||||
std::vector <DataProcessor*> dataProcessor;
|
std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
|
||||||
/** DataStreamer Objects that stream data via ZMQ */
|
/** DataStreamer Objects that stream data via ZMQ */
|
||||||
std::vector <DataStreamer*> dataStreamer;
|
std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
|
||||||
/** Fifo Structure to store addresses of memory writes */
|
/** Fifo Structure to store addresses of memory writes */
|
||||||
std::vector <Fifo*> fifo;
|
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||||
|
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
const std::string DataProcessor::TypeName = "DataProcessor";
|
const std::string DataProcessor::TypeName = "DataProcessor";
|
||||||
|
|
||||||
|
|
||||||
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
|
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||||
fileFormat* ftype, bool fwenable,
|
fileFormat* ftype, bool fwenable,
|
||||||
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
@ -125,7 +125,7 @@ void DataProcessor::StopRunning() {
|
|||||||
runningFlag = false;
|
runningFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo*& f) {
|
void DataProcessor::SetFifo(Fifo* f) {
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
||||||
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
runningFlag(0),
|
runningFlag(0),
|
||||||
@ -70,7 +70,7 @@ void DataStreamer::StopRunning() {
|
|||||||
runningFlag = false;
|
runningFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::SetFifo(Fifo*& f) {
|
void DataStreamer::SetFifo(Fifo* f) {
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
const std::string Listener::TypeName = "Listener";
|
const std::string Listener::TypeName = "Listener";
|
||||||
|
|
||||||
|
|
||||||
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
|
||||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||||
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) :
|
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) :
|
||||||
@ -108,7 +108,7 @@ void Listener::StopRunning() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Listener::SetFifo(Fifo*& f) {
|
void Listener::SetFifo(Fifo* f) {
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,20 +42,9 @@ void slsReceiverImplementation::DeleteMembers() {
|
|||||||
generalData=0;
|
generalData=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* it : listener)
|
|
||||||
delete it;
|
|
||||||
listener.clear();
|
listener.clear();
|
||||||
|
|
||||||
for (auto* it : dataProcessor)
|
|
||||||
delete it;
|
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
|
|
||||||
for (auto* it : dataStreamer)
|
|
||||||
delete it;
|
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
for (auto* it : fifo)
|
|
||||||
delete it;
|
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +72,6 @@ void slsReceiverImplementation::InitializeMembers() {
|
|||||||
|
|
||||||
//*** receiver parameters ***
|
//*** receiver parameters ***
|
||||||
numThreads = 1;
|
numThreads = 1;
|
||||||
numberofJobs = 1;
|
|
||||||
nroichannels = 0;
|
nroichannels = 0;
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
activated = true;
|
activated = true;
|
||||||
@ -217,14 +205,13 @@ uint64_t slsReceiverImplementation::getTotalFramesCaught() const {
|
|||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
|
|
||||||
std::vector<DataProcessor*>::const_iterator it;
|
for (const auto& it : dataProcessor){
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
flagsum += it->GetMeasurementStartedFlag();
|
||||||
flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0);
|
sum += it->GetNumTotalFramesCaught();
|
||||||
sum += (*it)->GetNumTotalFramesCaught();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//no data processed
|
//no data processed
|
||||||
if (flagsum != dataProcessor.size()) return 0;
|
if (flagsum != dataProcessor.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (sum/dataProcessor.size());
|
return (sum/dataProcessor.size());
|
||||||
}
|
}
|
||||||
@ -233,13 +220,13 @@ uint64_t slsReceiverImplementation::getFramesCaught() const {
|
|||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
for (const auto& it : dataProcessor){
|
||||||
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
|
flagsum += it->GetMeasurementStartedFlag();
|
||||||
sum += (*it)->GetNumFramesCaught();
|
sum += it->GetNumFramesCaught();
|
||||||
}
|
}
|
||||||
|
|
||||||
//no data processed
|
//no data processed
|
||||||
if (flagsum != dataProcessor.size()) return 0;
|
if (flagsum != dataProcessor.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (sum/dataProcessor.size());
|
return (sum/dataProcessor.size());
|
||||||
}
|
}
|
||||||
@ -248,13 +235,13 @@ int64_t slsReceiverImplementation::getAcquisitionIndex() const {
|
|||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
for (const auto& it : dataProcessor){
|
||||||
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
|
flagsum += it->GetMeasurementStartedFlag();
|
||||||
sum += (*it)->GetActualProcessedAcquisitionIndex();
|
sum += it->GetActualProcessedAcquisitionIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
//no data processed
|
//no data processed
|
||||||
if (flagsum != dataProcessor.size()) return -1;
|
if (flagsum != dataProcessor.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
return (sum/dataProcessor.size());
|
return (sum/dataProcessor.size());
|
||||||
}
|
}
|
||||||
@ -409,25 +396,25 @@ void slsReceiverImplementation::setDetectorHostname(const char *c){
|
|||||||
|
|
||||||
void slsReceiverImplementation::setMultiDetectorSize(const int* size) {
|
void slsReceiverImplementation::setMultiDetectorSize(const int* size) {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
char message[100];
|
std::string log_message = "Detector Size: (";
|
||||||
strcpy(message, "Detector Size: (");
|
|
||||||
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
|
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
|
||||||
if (myDetectorType == EIGER && (!i))
|
if (myDetectorType == EIGER && (!i))
|
||||||
numDet[i] = size[i]*2;
|
numDet[i] = size[i]*2;
|
||||||
else
|
else
|
||||||
numDet[i] = size[i];
|
numDet[i] = size[i];
|
||||||
sprintf(message,"%s%d",message,numDet[i]);
|
log_message += std::to_string(numDet[i]);
|
||||||
if (i < MAX_DIMENSIONS-1 )
|
if (i < MAX_DIMENSIONS-1 )
|
||||||
strcat(message,",");
|
log_message += ", ";
|
||||||
}
|
}
|
||||||
strcat(message,")");
|
log_message += ")";
|
||||||
FILE_LOG(logINFO) << message;
|
FILE_LOG(logINFO) << log_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverImplementation::setFlippedData(int axis, int enable){
|
void slsReceiverImplementation::setFlippedData(int axis, int enable){
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
if(axis<0 || axis>1) return;
|
if(axis<0 || axis>1)
|
||||||
|
return;
|
||||||
flippedData[axis] = enable==0?0:1;
|
flippedData[axis] = enable==0?0:1;
|
||||||
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
||||||
}
|
}
|
||||||
@ -439,11 +426,8 @@ int slsReceiverImplementation::setGapPixelsEnable(const bool b) {
|
|||||||
|
|
||||||
// side effects
|
// side effects
|
||||||
generalData->SetGapPixelsEnable(b, dynamicRange);
|
generalData->SetGapPixelsEnable(b, dynamicRange);
|
||||||
// to update npixelsx, npixelsy in file writer
|
for (const auto& it : dataProcessor)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->SetPixelDimension();
|
||||||
(*it)->SetPixelDimension();
|
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -463,9 +447,9 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f){
|
|||||||
fileFormatType = BINARY;
|
fileFormatType = BINARY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//destroy file writer, set file format and create file writer
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for(const auto& it : dataProcessor)
|
||||||
(*it)->SetFileFormat(f);
|
it->SetFileFormat(f);
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
||||||
}
|
}
|
||||||
@ -612,17 +596,15 @@ int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i)
|
|||||||
|
|
||||||
generalData->SetROI(i);
|
generalData->SetROI(i);
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
framesPerFile = generalData->maxFramesPerFile;
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->SetGeneralData(generalData);
|
it->SetGeneralData(generalData);
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (const auto& it : dataProcessor)
|
||||||
(*it)->SetGeneralData(generalData);
|
it->SetGeneralData(generalData);
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
for (const auto& it : dataStreamer)
|
||||||
(*it)->SetGeneralData(generalData);
|
it->SetGeneralData(generalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -667,22 +649,17 @@ int slsReceiverImplementation::setDataStreamEnable(const bool enable) {
|
|||||||
dataStreamEnable = enable;
|
dataStreamEnable = enable;
|
||||||
|
|
||||||
//data sockets have to be created again as the client ones are
|
//data sockets have to be created again as the client ones are
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
try {
|
try {
|
||||||
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(i, fifo[i].get(), &dynamicRange,
|
||||||
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
|
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode));
|
||||||
dataStreamer.push_back(s);
|
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
dataStreamEnable = false;
|
dataStreamEnable = false;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -767,7 +744,6 @@ int slsReceiverImplementation::setNumberofSamples(const uint64_t i) {
|
|||||||
numberOfSamples = i;
|
numberOfSamples = i;
|
||||||
|
|
||||||
generalData->setNumberofSamples(i, nroichannels);
|
generalData->setNumberofSamples(i, nroichannels);
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -780,15 +756,11 @@ int slsReceiverImplementation::setNumberofSamples(const uint64_t i) {
|
|||||||
int slsReceiverImplementation::setDynamicRange(const uint32_t i) {
|
int slsReceiverImplementation::setDynamicRange(const uint32_t i) {
|
||||||
if (dynamicRange != i) {
|
if (dynamicRange != i) {
|
||||||
dynamicRange = i;
|
dynamicRange = i;
|
||||||
|
|
||||||
//side effects
|
|
||||||
generalData->SetDynamicRange(i,tengigaEnable);
|
generalData->SetDynamicRange(i,tengigaEnable);
|
||||||
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
|
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
|
||||||
// to update npixelsx, npixelsy in file writer
|
// to update npixelsx, npixelsy in file writer
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (const auto& it : dataProcessor)
|
||||||
(*it)->SetPixelDimension();
|
it->SetPixelDimension();
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -802,8 +774,6 @@ int slsReceiverImplementation::setTenGigaEnable(const bool b) {
|
|||||||
tengigaEnable = b;
|
tengigaEnable = b;
|
||||||
//side effects
|
//side effects
|
||||||
generalData->SetTenGigaEnable(b,dynamicRange);
|
generalData->SetTenGigaEnable(b,dynamicRange);
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -815,8 +785,6 @@ int slsReceiverImplementation::setTenGigaEnable(const bool b) {
|
|||||||
int slsReceiverImplementation::setFifoDepth(const uint32_t i) {
|
int slsReceiverImplementation::setFifoDepth(const uint32_t i) {
|
||||||
if (fifoDepth != i) {
|
if (fifoDepth != i) {
|
||||||
fifoDepth = i;
|
fifoDepth = i;
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -887,11 +855,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
|||||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
framesPerFile = generalData->maxFramesPerFile;
|
||||||
|
|
||||||
//local network parameters
|
|
||||||
SetLocalNetworkParameters();
|
SetLocalNetworkParameters();
|
||||||
|
|
||||||
//create fifo structure
|
|
||||||
numberofJobs = -1;
|
|
||||||
if (SetupFifoStructure() == FAIL) {
|
if (SetupFifoStructure() == FAIL) {
|
||||||
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure";
|
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure";
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -901,37 +865,31 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
|||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
|
auto fifo_ptr = fifo[i].get();
|
||||||
|
listener.push_back(sls::make_unique<Listener>(i, myDetectorType, fifo_ptr, &status,
|
||||||
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
|
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
|
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
|
||||||
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode);
|
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode));
|
||||||
listener.push_back(l);
|
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
|
||||||
|
|
||||||
DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType,
|
|
||||||
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||||
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
||||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||||
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady));
|
||||||
dataProcessor.push_back(p);
|
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
listener.clear();
|
listener.clear();
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//set up writer and callbacks
|
//set up writer and callbacks
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
(*it)->SetGeneralData(generalData);
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
(*it)->SetGeneralData(generalData);
|
|
||||||
|
|
||||||
|
for (const auto& it : listener)
|
||||||
|
it->SetGeneralData(generalData);
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
|
it->SetGeneralData(generalData);
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
|
|
||||||
// check udp socket buffer size
|
// check udp socket buffer size
|
||||||
@ -967,14 +925,12 @@ void slsReceiverImplementation::setDetectorPositionId(const int i){
|
|||||||
/***acquisition functions***/
|
/***acquisition functions***/
|
||||||
void slsReceiverImplementation::resetAcquisitionCount() {
|
void slsReceiverImplementation::resetAcquisitionCount() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
it->ResetParametersforNewAcquisition();
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->ResetParametersforNewAcquisition();
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
for (const auto& it: dataStreamer)
|
||||||
|
it->ResetParametersforNewAcquisition();
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Acquisition Count has been reset";
|
FILE_LOG(logINFO) << "Acquisition Count has been reset";
|
||||||
}
|
}
|
||||||
@ -996,7 +952,7 @@ int slsReceiverImplementation::startReceiver(char *c) {
|
|||||||
//callbacks
|
//callbacks
|
||||||
if (startAcquisitionCallBack) {
|
if (startAcquisitionCallBack) {
|
||||||
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
(generalData->imageSize) + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
||||||
if (rawDataReadyCallBack != NULL) {
|
if (rawDataReadyCallBack != NULL) {
|
||||||
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
||||||
}
|
}
|
||||||
@ -1038,11 +994,12 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
while(running) {
|
while(running) {
|
||||||
running = false;
|
running = false;
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
if ((*it)->IsRunning())
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
if ((*it)->IsRunning())
|
for (const auto& it : dataProcessor)
|
||||||
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1052,9 +1009,9 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
if (fileWriteEnable && fileFormatType == HDF5) {
|
if (fileWriteEnable && fileFormatType == HDF5) {
|
||||||
uint64_t maxIndexCaught = 0;
|
uint64_t maxIndexCaught = 0;
|
||||||
bool anycaught = false;
|
bool anycaught = false;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
for (const auto& it : dataProcessor) {
|
||||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
maxIndexCaught = std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
|
||||||
if((*it)->GetMeasurementStartedFlag())
|
if(it->GetMeasurementStartedFlag())
|
||||||
anycaught = true;
|
anycaught = true;
|
||||||
}
|
}
|
||||||
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
||||||
@ -1065,8 +1022,8 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
running = true;
|
running = true;
|
||||||
while(running) {
|
while(running) {
|
||||||
running = false;
|
running = false;
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
for (const auto& it : dataStreamer)
|
||||||
if ((*it)->IsRunning())
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1107,46 +1064,39 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
void slsReceiverImplementation::startReadout(){
|
void slsReceiverImplementation::startReadout(){
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
if(status == RUNNING){
|
if(status == RUNNING){
|
||||||
|
|
||||||
// wait for incoming delayed packets
|
// wait for incoming delayed packets
|
||||||
//current packets caught
|
int totalPacketsReceived = 0;
|
||||||
volatile int totalP = 0,prev=-1;
|
int previousValue=-1;
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for(const auto& it : listener)
|
||||||
totalP += (*it)->GetPacketsCaught();
|
totalPacketsReceived += it->GetPacketsCaught();
|
||||||
|
|
||||||
//wait for all packets
|
//wait for all packets
|
||||||
if((unsigned long long int)totalP!=numberOfFrames*generalData->packetsPerFrame*listener.size()){
|
const auto numPacketsToReceive = numberOfFrames * generalData->packetsPerFrame * listener.size();
|
||||||
|
if(totalPacketsReceived != numPacketsToReceive){
|
||||||
|
while(totalPacketsReceived != previousValue){
|
||||||
|
FILE_LOG(logDEBUG3) << "waiting for all packets, previousValue:" << previousValue <<
|
||||||
|
" totalPacketsReceived: " << totalPacketsReceived;
|
||||||
|
usleep(5*1000);/* TODO! Need to find optimal time **/
|
||||||
|
previousValue = totalPacketsReceived;
|
||||||
|
totalPacketsReceived = 0;
|
||||||
|
for(const auto& it : listener)
|
||||||
|
totalPacketsReceived += it->GetPacketsCaught();
|
||||||
|
|
||||||
//wait as long as there is change from prev totalP,
|
FILE_LOG(logDEBUG3) << "\tupdated: totalPacketsReceived:" << totalPacketsReceived;
|
||||||
while(prev != totalP){
|
|
||||||
FILE_LOG(logDEBUG3) << "waiting for all packets prevP:" << prev <<
|
|
||||||
" totalP: " << totalP;
|
|
||||||
//usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);
|
|
||||||
usleep(5*1000);/* Need to find optimal time **/
|
|
||||||
|
|
||||||
prev = totalP;
|
|
||||||
totalP = 0;
|
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
totalP += (*it)->GetPacketsCaught();
|
|
||||||
FILE_LOG(logDEBUG3) << "\tupdated: totalP:" << totalP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//set status
|
|
||||||
status = TRANSMITTING;
|
status = TRANSMITTING;
|
||||||
FILE_LOG(logINFO) << "Status: Transmitting";
|
FILE_LOG(logINFO) << "Status: Transmitting";
|
||||||
}
|
}
|
||||||
//shut down udp sockets so as to make listeners push dummy (end) packets for processors
|
//shut down udp sockets to make listeners push dummy (end) packets for processors
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverImplementation::shutDownUDPSockets() {
|
void slsReceiverImplementation::shutDownUDPSockets() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->ShutDownUDPSocket();
|
it->ShutDownUDPSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1155,10 +1105,10 @@ void slsReceiverImplementation::closeFiles() {
|
|||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
uint64_t maxIndexCaught = 0;
|
uint64_t maxIndexCaught = 0;
|
||||||
bool anycaught = false;
|
bool anycaught = false;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
for (const auto& it : dataProcessor) {
|
||||||
(*it)->CloseFiles();
|
it->CloseFiles();
|
||||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
maxIndexCaught = std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
|
||||||
if((*it)->GetMeasurementStartedFlag())
|
if(it->GetMeasurementStartedFlag())
|
||||||
anycaught = true;
|
anycaught = true;
|
||||||
}
|
}
|
||||||
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
||||||
@ -1169,11 +1119,10 @@ void slsReceiverImplementation::closeFiles() {
|
|||||||
int slsReceiverImplementation::restreamStop() {
|
int slsReceiverImplementation::restreamStop() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
bool ret = OK;
|
bool ret = OK;
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
for (const auto& it : dataStreamer){
|
||||||
if ((*it)->RestreamStop() == FAIL)
|
if (it->RestreamStop() == FAIL)
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if fail, prints in datastreamer
|
// if fail, prints in datastreamer
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logINFO) << "Restreaming Dummy Header via ZMQ successful";
|
FILE_LOG(logINFO) << "Restreaming Dummy Header via ZMQ successful";
|
||||||
@ -1238,8 +1187,8 @@ void slsReceiverImplementation::SetLocalNetworkParameters() {
|
|||||||
void slsReceiverImplementation::SetThreadPriorities() {
|
void slsReceiverImplementation::SetThreadPriorities() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
for (const auto& it : listener){
|
||||||
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
if (it->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
||||||
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1254,34 +1203,27 @@ void slsReceiverImplementation::SetThreadPriorities() {
|
|||||||
|
|
||||||
int slsReceiverImplementation::SetupFifoStructure() {
|
int slsReceiverImplementation::SetupFifoStructure() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
numberofJobs = 1;
|
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
|
|
||||||
//create fifo structure
|
//create fifo structure
|
||||||
try {
|
try {
|
||||||
Fifo* f = new Fifo (i,
|
fifo.push_back(sls::make_unique<Fifo>(i,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
(generalData->imageSize) + (generalData->fifoBufferHeaderSize),
|
||||||
fifoDepth);
|
fifoDepth));
|
||||||
fifo.push_back(f);
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure of index " << i;
|
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure of index " << i;
|
||||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
//set the listener & dataprocessor threads to point to the right fifo
|
//set the listener & dataprocessor threads to point to the right fifo
|
||||||
if(listener.size())listener[i]->SetFifo(fifo[i]);
|
if(listener.size())listener[i]->SetFifo(fifo[i].get());
|
||||||
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i].get());
|
||||||
if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i]);
|
if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i].get());
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << ( ((generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ;
|
FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << ( ((generalData->imageSize) + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ;
|
||||||
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
|
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -1290,16 +1232,17 @@ int slsReceiverImplementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
|
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
for (const auto& it : listener)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->ResetParametersforNewMeasurement();
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
for (const auto& it : dataProcessor)
|
||||||
|
it->ResetParametersforNewMeasurement();
|
||||||
|
|
||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
char fnametostream[MAX_STR_LENGTH];
|
char fnametostream[MAX_STR_LENGTH];
|
||||||
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
|
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
for (const auto& it : dataStreamer)
|
||||||
(*it)->ResetParametersforNewMeasurement(fnametostream);
|
it->ResetParametersforNewMeasurement(fnametostream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1345,16 +1288,16 @@ int slsReceiverImplementation::SetupWriter() {
|
|||||||
void slsReceiverImplementation::StartRunning() {
|
void slsReceiverImplementation::StartRunning() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
//set running mask and post semaphore to start the inner loop in execution thread
|
//set running mask and post semaphore to start the inner loop in execution thread
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
|
for (const auto& it : listener){
|
||||||
(*it)->StartRunning();
|
it->StartRunning();
|
||||||
(*it)->Continue();
|
it->Continue();
|
||||||
}
|
}
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
for (const auto& it : dataProcessor){
|
||||||
(*it)->StartRunning();
|
it->StartRunning();
|
||||||
(*it)->Continue();
|
it->Continue();
|
||||||
}
|
}
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
for (const auto& it : dataStreamer){
|
||||||
(*it)->StartRunning();
|
it->StartRunning();
|
||||||
(*it)->Continue();
|
it->Continue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ T minusOneIfDifferent(const std::vector<T>& container)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO!(Erik)Should try to move away from using this in the slsDetectorPackage
|
//TODO!(Erik)Should try to move away from using this in the slsDetectorPackage
|
||||||
|
inline
|
||||||
std::string concatenateIfDifferent(std::vector<std::string> container)
|
std::string concatenateIfDifferent(std::vector<std::string> container)
|
||||||
{
|
{
|
||||||
if (allEqual(container)) {
|
if (allEqual(container)) {
|
||||||
@ -110,7 +111,7 @@ std::string concatenateIfDifferent(std::vector<std::string> container)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inline
|
||||||
std::vector<std::string> split(const std::string& strToSplit, char delimeter)
|
std::vector<std::string> split(const std::string& strToSplit, char delimeter)
|
||||||
{
|
{
|
||||||
std::stringstream ss(strToSplit);
|
std::stringstream ss(strToSplit);
|
||||||
@ -122,6 +123,7 @@ std::vector<std::string> split(const std::string& strToSplit, char delimeter)
|
|||||||
return splittedStrings;
|
return splittedStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
std::string concatenateNonEmptyStrings(const std::vector<std::string>& vec){
|
std::string concatenateNonEmptyStrings(const std::vector<std::string>& vec){
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (const auto& s : vec)
|
for (const auto& s : vec)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user