areaDetector  3-14
EPICS areaDetector framework
eigerDetector.h
Go to the documentation of this file.
1 #ifndef EIGER_DETECTOR_H
2 #define EIGER_DETECTOR_H
3 
4 #include <map>
5 #include <vector>
6 
7 #include "restApi.h"
8 #include "streamApi.h"
9 #include "eigerParam.h"
10 
11 typedef enum {
13  Eiger2
15 
16 // areaDetector NDArray data source
17 #define EigDataSourceStr "DATA_SOURCE"
18 
19 // FileWriter Parameters
20 #define EigFWEnableStr "FW_ENABLE"
21 #define EigFWClearStr "CLEAR"
22 #define EigFWCompressionStr "COMPRESSION"
23 #define EigFWNamePatternStr "NAME_PATTERN"
24 #define EigFWNImgsPerFileStr "NIMAGES_PER_FILE"
25 #define EigFWAutoRemoveStr "AUTO_REMOVE"
26 #define EigFWFreeStr "FW_FREE"
27 #define EigFWStateStr "FW_STATE"
28 #define EigFWImgNumStartStr "FW_IMG_NUM_START"
29 
30 // Acquisition Metadata Parameters
31 #define EigWavelengthStr "WAVELENGTH"
32 #define EigAutoSummationStr "AUTO_SUMMATION"
33 
34 // Detector Metadata Parameters
35 #define EigDescriptionStr "DESCRIPTION"
36 
37 // MX Parameters (firmware 1.6.2 onwards)
38 #define EigOmegaStr "OMEGA"
39 
40 // Acquisition Parameters
41 #define EigPhotonEnergyStr "PHOTON_ENERGY"
42 #define EigThresholdStr "THRESHOLD"
43 #define EigThreshold1EnableStr "THRESHOLD1_ENABLE"
44 #define EigThreshold2Str "THRESHOLD2"
45 #define EigThreshold2EnableStr "THRESHOLD2_ENABLE"
46 #define EigThresholdDiffEnableStr "THRESHOLD_DIFF_ENABLE"
47 #define EigTriggerStr "TRIGGER"
48 #define EigTriggerExpStr "TRIGGER_EXPOSURE"
49 #define EigNTriggersStr "NUM_TRIGGERS"
50 #define EigManualTriggerStr "MANUAL_TRIGGER"
51 #define EigTriggerStartDelayStr "TRIGGER_START_DELAY"
52 #define EigExtGateModeStr "EXT_GATE_MODE"
53 #define EigCompressionAlgoStr "COMPRESSION_ALGO"
54 // ROI Mode is only available on Eiger 9M and 16M
55 #define EigROIModeStr "ROI_MODE"
56 
57 // Detector Status Parameters
58 #define EigStateStr "STATE"
59 #define EigErrorStr "ERROR"
60 #define EigInitializeStr "INITIALIZE"
61 #define EigThTemp0Str "TH_TEMP_0"
62 #define EigThHumid0Str "TH_HUMID_0"
63 #define EigLink0Str "LINK_0"
64 #define EigLink1Str "LINK_1"
65 #define EigLink2Str "LINK_2"
66 #define EigLink3Str "LINK_3"
67 #define EigDCUBufFreeStr "DCU_BUF_FREE"
68 
69 // Other Parameters
70 #define EigArmedStr "ARMED"
71 #define EigSequenceIdStr "SEQ_ID"
72 #define EigPendingFilesStr "PENDING_FILES"
73 #define EigHVResetTimeStr "HV_RESET_TIME"
74 #define EigHVResetStr "HV_RESET"
75 #define EigHVStateStr "HV_STATE"
76 
77 // File Saving Parameters
78 #define EigSaveFilesStr "SAVE_FILES"
79 #define EigFileOwnerStr "FILE_OWNER"
80 #define EigFileOwnerGroupStr "FILE_OWNER_GROUP"
81 #define EigFilePermsStr "FILE_PERMISSIONS"
82 
83 // Monitor API Parameters
84 #define EigMonitorEnableStr "MONITOR_ENABLE"
85 #define EigMonitorTimeoutStr "MONITOR_TIMEOUT"
86 #define EigMonitorStateStr "MONITOR_STATE"
87 #define EigMonitorBufSizeStr "MONITOR_BUF_SIZE"
88 
89 // Stream API Parameters
90 #define EigStreamEnableStr "STREAM_ENABLE"
91 #define EigStreamDroppedStr "STREAM_DROPPED"
92 #define EigStreamStateStr "STREAM_STATE"
93 #define EigStreamDecompressStr "STREAM_DECOMPRESS"
94 
95 // Epsilon Parameters (minimum amount of change allowed)
96 #define EigWavelengthEpsilonStr "WAVELENGTH_EPSILON"
97 #define EigEnergyEpsilonStr "ENERGY_EPSILON"
98 
99 // Driver for the Dectris' Eiger pixel array detector using their REST server
100 class eigerDetector : public ADDriver
101 {
102 public:
103  eigerDetector(const char *portName, const char *serverHostname,
104  int maxBuffers, size_t maxMemory, int priority, int stackSize);
105 
106  // These are the methods that we override from ADDriver
107  virtual asynStatus writeInt32 (asynUser *pasynUser, epicsInt32 value);
108  virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
109  virtual asynStatus writeOctet (asynUser *pasynUser, const char *value,
110  size_t nChars, size_t *nActual);
111  void report(FILE *fp, int details);
112  virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo,
113  const char **pptypeName, size_t *psize);
114 
115  // These should be private but are called from C so must be public
116  void controlTask (void);
117  void pollTask (void);
118  void downloadTask (void);
119  void parseTask (void);
120  void saveTask (void);
121  void reapTask (void);
122  void monitorTask (void);
123  void streamTask (void);
124  void initializeTask();
125 
126  enum roi_mode
127  {
130  };
131 
133  {
136  };
137 
139  {
146  };
147 
148 protected:
149  // Driver-only parameters
170 
171  // Eiger parameters: metadata
173 
174  // Eiger parameters: acquisition
187 
188  // Eiger parameters: status
199 
200  // Eiger parameters: filewriter interface
209 
210  // Eiger parameters: monitor interface
214 
215  // Eiger parameters: streaming interface
219 
220  // Base class parameters
232 
233 private:
234  char mHostname[512];
235  RestAPI mApi;
236  StreamAPI *mStreamAPI;
237  eigerModel_t mEigerModel;
238  eigerAPIVersion_t mAPIVersion;
239  epicsEvent mStartEvent, mStopEvent, mTriggerEvent, mStreamEvent, mStreamDoneEvent,
240  mPollDoneEvent, mInitializeEvent;
241  epicsMessageQueue mPollQueue, mDownloadQueue, mParseQueue, mSaveQueue,
242  mReapQueue;
243  bool mPollStop, mPollComplete, mStreamComplete;
244  unsigned int mFrameNumber;
245  uid_t mFsUid, mFsGid;
246  EigerParamSet mParams;
247  int mFirstParam;
248  std::map<std::string, sys_t> mSubSystemMap;
249 
250  // Read all parameters from detector and set some default values
251  asynStatus initParams (void);
252 
253  // File parsers
254  asynStatus parseH5File (char *buf, size_t len);
255  asynStatus parseTiffFile (char *buf, size_t len);
256 
257  // Read some detector status parameters
258  asynStatus eigerStatus (void);
259 
260  // Helper that returns ADStatus == ADStatusAcquire
261  bool acquiring (void);
262 };
263 
264 #endif
Class from which areaDetector drivers are directly derived.
Definition: ADDriver.h:132
Definition: eigerParam.h:44
Definition: eigerParam.h:131
Definition: restApi.h:45
Definition: streamApi.h:33
Definition: eigerDetector.h:101
void monitorTask(void)
Definition: eigerDetector.cpp:1283
EigerParam * mFileOwner
Definition: eigerDetector.h:160
EigerParam * mArmed
Definition: eigerDetector.h:156
roi_mode
Definition: eigerDetector.h:127
@ ROI_MODE_DISABLED
Definition: eigerDetector.h:128
@ ROI_MODE_4M
Definition: eigerDetector.h:129
EigerParam * mTemperatureActual
Definition: eigerDetector.h:229
EigerParam * mLink3
Definition: eigerDetector.h:197
EigerParam * mMonitorBufSize
Definition: eigerDetector.h:212
EigerParam * mSDKVersion
Definition: eigerDetector.h:226
EigerParam * mState
Definition: eigerDetector.h:189
void reapTask(void)
Definition: eigerDetector.cpp:1249
EigerParam * mSerialNumber
Definition: eigerDetector.h:228
EigerParam * mInitialize
Definition: eigerDetector.h:165
EigerParam * mHVState
Definition: eigerDetector.h:190
EigerParam * mFWState
Definition: eigerDetector.h:206
EigerParam * mStreamDecompress
Definition: eigerDetector.h:164
EigerParam * mDataSource
Definition: eigerDetector.h:150
EigerParam * mMonitorState
Definition: eigerDetector.h:213
EigerParam * mFirmwareVersion
Definition: eigerDetector.h:227
EigerParam * mDCUBufFree
Definition: eigerDetector.h:198
EigerParam * mManualTrigger
Definition: eigerDetector.h:154
void controlTask(void)
Definition: eigerDetector.cpp:730
EigerParam * mSequenceId
Definition: eigerDetector.h:157
EigerParam * mHVResetTime
Definition: eigerDetector.h:166
EigerParam * mAutoSummation
Definition: eigerDetector.h:186
void initializeTask()
Definition: eigerDetector.cpp:1489
EigerParam * mFilePerms
Definition: eigerDetector.h:162
eigerDetector(const char *portName, const char *serverHostname, int maxBuffers, size_t maxMemory, int priority, int stackSize)
Definition: eigerDetector.cpp:172
EigerParam * mNDArraySizeY
Definition: eigerDetector.h:231
EigerParam * mHVReset
Definition: eigerDetector.h:167
EigerParam * mNumExposures
Definition: eigerDetector.h:224
EigerParam * mTrigger
Definition: eigerDetector.h:152
EigerParam * mSaveFiles
Definition: eigerDetector.h:159
EigerParam * mFWClear
Definition: eigerDetector.h:208
EigerParam * mFWEnable
Definition: eigerDetector.h:201
void report(FILE *fp, int details)
Report status of the driver.
Definition: eigerDetector.cpp:711
EigerParam * mMonitorTimeout
Definition: eigerDetector.h:163
virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo, const char **pptypeName, size_t *psize)
Definition: eigerDetector.cpp:1888
void saveTask(void)
Definition: eigerDetector.cpp:1163
EigerParam * mWavelength
Definition: eigerDetector.h:175
EigerParam * mFWAutoRemove
Definition: eigerDetector.h:151
EigerParam * mThreshold2
Definition: eigerDetector.h:179
EigerParam * mMonitorEnable
Definition: eigerDetector.h:211
EigerParam * mTriggerExp
Definition: eigerDetector.h:153
EigerParam * mDescription
Definition: eigerDetector.h:172
void pollTask(void)
Definition: eigerDetector.cpp:1018
EigerParam * mEnergyEpsilon
Definition: eigerDetector.h:169
void parseTask(void)
Definition: eigerDetector.cpp:1143
EigerParam * mFWNImgsPerFile
Definition: eigerDetector.h:204
EigerParam * mAcquireTime
Definition: eigerDetector.h:221
EigerParam * mLink0
Definition: eigerDetector.h:194
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Sets an int32 parameter.
Definition: eigerDetector.cpp:451
trigger_mode
Definition: eigerDetector.h:139
@ TRIGGER_MODE_EXTG
Definition: eigerDetector.h:145
@ TRIGGER_MODE_EXTS
Definition: eigerDetector.h:142
@ TRIGGER_MODE_INTS
Definition: eigerDetector.h:140
@ TRIGGER_MODE_EXTE
Definition: eigerDetector.h:143
@ TRIGGER_MODE_INTE
Definition: eigerDetector.h:141
@ TRIGGER_MODE_CONTINUOUS
Definition: eigerDetector.h:144
EigerParam * mAcquirePeriod
Definition: eigerDetector.h:222
EigerParam * mROIMode
Definition: eigerDetector.h:185
EigerParam * mThHumid0
Definition: eigerDetector.h:193
EigerParam * mCompressionAlgo
Definition: eigerDetector.h:184
EigerParam * mStreamEnable
Definition: eigerDetector.h:216
compression_algo
Definition: eigerDetector.h:133
@ COMP_ALGO_BSLZ4
Definition: eigerDetector.h:135
@ COMP_ALGO_LZ4
Definition: eigerDetector.h:134
EigerParam * mTriggerMode
Definition: eigerDetector.h:225
EigerParam * mError
Definition: eigerDetector.h:191
EigerParam * mNTriggers
Definition: eigerDetector.h:182
EigerParam * mThresholdDiffEnable
Definition: eigerDetector.h:181
EigerParam * mFWCompression
Definition: eigerDetector.h:202
EigerParam * mExtGateMode
Definition: eigerDetector.h:183
EigerParam * mTriggerStartDelay
Definition: eigerDetector.h:155
EigerParam * mFWFree
Definition: eigerDetector.h:207
EigerParam * mFileOwnerGroup
Definition: eigerDetector.h:161
virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t nChars, size_t *nActual)
Called when asyn clients call pasynOctet->write().
Definition: eigerDetector.cpp:635
void downloadTask(void)
Definition: eigerDetector.cpp:1113
EigerParam * mLink2
Definition: eigerDetector.h:196
EigerParam * mThreshold
Definition: eigerDetector.h:177
EigerParam * mThreshold2Enable
Definition: eigerDetector.h:180
EigerParam * mNumImages
Definition: eigerDetector.h:223
EigerParam * mLink1
Definition: eigerDetector.h:195
EigerParam * mFWImgNumStart
Definition: eigerDetector.h:205
EigerParam * mPendingFiles
Definition: eigerDetector.h:158
EigerParam * mThTemp0
Definition: eigerDetector.h:192
EigerParam * mWavelengthEpsilon
Definition: eigerDetector.h:168
EigerParam * mStreamDropped
Definition: eigerDetector.h:217
EigerParam * mFWNamePattern
Definition: eigerDetector.h:203
void streamTask(void)
Definition: eigerDetector.cpp:1315
EigerParam * mThreshold1Enable
Definition: eigerDetector.h:178
EigerParam * mStreamState
Definition: eigerDetector.h:218
EigerParam * mPhotonEnergy
Definition: eigerDetector.h:176
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Definition: eigerDetector.cpp:563
EigerParam * mNDArraySizeX
Definition: eigerDetector.h:230
eigerModel_t
Definition: eigerDetector.h:11
@ Eiger1
Definition: eigerDetector.h:12
@ Eiger2
Definition: eigerDetector.h:13
list value
Definition: makeDbAndEdl.py:234
eigerAPIVersion_t
Definition: restApi.h:13
unsigned char * buf
Definition: udp_client_pixirad_single.cpp:70