areaDetector  3-5-0
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 "eigerParam.h"
9 
10 // areaDetector NDArray data source
11 #define EigDataSourceStr "DATA_SOURCE"
12 
13 // FileWriter Parameters
14 #define EigFWEnableStr "FW_ENABLE"
15 #define EigFWClearStr "CLEAR"
16 #define EigFWCompressionStr "COMPRESSION"
17 #define EigFWNamePatternStr "NAME_PATTERN"
18 #define EigFWNImgsPerFileStr "NIMAGES_PER_FILE"
19 #define EigFWAutoRemoveStr "AUTO_REMOVE"
20 #define EigFWFreeStr "FW_FREE"
21 #define EigFWStateStr "FW_STATE"
22 #define EigFWImgNumStartStr "FW_IMG_NUM_START"
23 
24 // Acquisition Metadata Parameters
25 #define EigWavelengthStr "WAVELENGTH"
26 #define EigAutoSummationStr "AUTO_SUMMATION"
27 
28 // Detector Metadata Parameters
29 #define EigDescriptionStr "DESCRIPTION"
30 
31 // MX Parameters (firmware 1.6.2 onwards)
32 #define EigOmegaStr "OMEGA"
33 
34 // Acquisition Parameters
35 #define EigPhotonEnergyStr "PHOTON_ENERGY"
36 #define EigThresholdStr "THRESHOLD"
37 #define EigTriggerStr "TRIGGER"
38 #define EigTriggerExpStr "TRIGGER_EXPOSURE"
39 #define EigNTriggersStr "NUM_TRIGGERS"
40 #define EigManualTriggerStr "MANUAL_TRIGGER"
41 #define EigCompressionAlgoStr "COMPRESSION_ALGO"
42 // ROI Mode is only available on Eiger 9M and 16M
43 #define EigROIModeStr "ROI_MODE"
44 
45 // Detector Status Parameters
46 #define EigStateStr "STATE"
47 #define EigErrorStr "ERROR"
48 #define EigThTemp0Str "TH_TEMP_0"
49 #define EigThHumid0Str "TH_HUMID_0"
50 #define EigLink0Str "LINK_0"
51 #define EigLink1Str "LINK_1"
52 #define EigLink2Str "LINK_2"
53 #define EigLink3Str "LINK_3"
54 #define EigDCUBufFreeStr "DCU_BUF_FREE"
55 
56 // Other Parameters
57 #define EigArmedStr "ARMED"
58 #define EigSequenceIdStr "SEQ_ID"
59 #define EigPendingFilesStr "PENDING_FILES"
60 
61 // File Saving Parameters
62 #define EigSaveFilesStr "SAVE_FILES"
63 #define EigFileOwnerStr "FILE_OWNER"
64 #define EigFileOwnerGroupStr "FILE_OWNER_GROUP"
65 #define EigFilePermsStr "FILE_PERMISSIONS"
66 
67 // Monitor API Parameters
68 #define EigMonitorEnableStr "MONITOR_ENABLE"
69 #define EigMonitorTimeoutStr "MONITOR_TIMEOUT"
70 #define EigMonitorStateStr "MONITOR_STATE"
71 #define EigMonitorBufSizeStr "MONITOR_BUF_SIZE"
72 
73 // Stream API Parameters
74 #define EigStreamEnableStr "STREAM_ENABLE"
75 #define EigStreamDroppedStr "STREAM_DROPPED"
76 #define EigStreamStateStr "STREAM_STATE"
77 #define EigStreamDecompressStr "STREAM_DECOMPRESS"
78 
79 // Driver for the Dectris' Eiger pixel array detector using their REST server
80 class eigerDetector : public ADDriver
81 {
82 public:
83  eigerDetector(const char *portName, const char *serverHostname,
84  int maxBuffers, size_t maxMemory, int priority, int stackSize);
85 
86  // These are the methods that we override from ADDriver
87  virtual asynStatus writeInt32 (asynUser *pasynUser, epicsInt32 value);
88  virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
89  virtual asynStatus writeOctet (asynUser *pasynUser, const char *value,
90  size_t nChars, size_t *nActual);
91  void report(FILE *fp, int details);
92  virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo,
93  const char **pptypeName, size_t *psize);
94 
95  // These should be private but are called from C so must be public
96  void controlTask (void);
97  void pollTask (void);
98  void downloadTask (void);
99  void parseTask (void);
100  void saveTask (void);
101  void reapTask (void);
102  void monitorTask (void);
103  void streamTask (void);
104 
105  enum roi_mode
106  {
109  };
110 
112  {
115  };
116 
117 protected:
118  // Driver-only parameters
133 
134  // Eiger parameters: metadata
136 
137  // Eiger parameters: acquisition
145 
146  // Eiger parameters: status
156 
157  // Eiger parameters: filewriter interface
166 
167  // Eiger parameters: monitor interface
171 
172  // Eiger parameters: streaming interface
176 
177  // Base class parameters
187 
188 private:
189  char mHostname[512];
190  RestAPI mApi;
191  epicsEvent mStartEvent, mStopEvent, mTriggerEvent, mStreamEvent, mStreamDoneEvent,
192  mPollDoneEvent;
193  epicsMessageQueue mPollQueue, mDownloadQueue, mParseQueue, mSaveQueue,
194  mReapQueue;
195  bool mPollStop, mPollComplete, mStreamComplete;
196  unsigned int mFrameNumber;
197  uid_t mFsUid, mFsGid;
198  EigerParamSet mParams;
199  int mFirstParam;
200  std::map<std::string, sys_t> mSubSystemMap;
201 
202  // Read all parameters from detector and set some default values
203  asynStatus initParams (void);
204 
205  // File parsers
206  asynStatus parseH5File (char *buf, size_t len);
207  asynStatus parseTiffFile (char *buf, size_t len);
208 
209  // Read some detector status parameters
210  asynStatus eigerStatus (void);
211 
212  // Helper that returns ADStatus == ADStatusAcquire
213  bool acquiring (void);
214 };
215 
216 #endif
virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t nChars, size_t *nActual)
Called when asyn clients call pasynOctet->write().
Definition: eigerDetector.cpp:526
EigerParam * mSerialNumber
Definition: eigerDetector.h:183
Class from which areaDetector drivers are directly derived.
Definition: ADDriver.h:141
EigerParam * mSequenceId
Definition: eigerDetector.h:125
EigerParam * mFWAutoRemove
Definition: eigerDetector.h:120
EigerParam * mMonitorEnable
Definition: eigerDetector.h:168
EigerParam * mFWEnable
Definition: eigerDetector.h:158
EigerParam * mStreamState
Definition: eigerDetector.h:175
EigerParam * mThTemp0
Definition: eigerDetector.h:149
EigerParam * mFWNamePattern
Definition: eigerDetector.h:160
void streamTask(void)
Definition: eigerDetector.cpp:1178
Definition: restApi.h:39
EigerParam * mROIMode
Definition: eigerDetector.h:143
Definition: eigerDetector.h:113
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Sets an int32 parameter.
Definition: eigerDetector.cpp:386
void downloadTask(void)
Definition: eigerDetector.cpp:976
Definition: eigerDetector.h:114
EigerParam * mState
Definition: eigerDetector.h:147
EigerParam * mFirmwareVersion
Definition: eigerDetector.h:182
list value
Definition: makeDbAndEdl.py:234
compression_algo
Definition: eigerDetector.h:111
EigerParam * mFWImgNumStart
Definition: eigerDetector.h:162
Definition: eigerDetector.h:107
void reapTask(void)
Definition: eigerDetector.cpp:1112
EigerParam * mWavelength
Definition: eigerDetector.h:138
void controlTask(void)
Definition: eigerDetector.cpp:621
void pollTask(void)
Definition: eigerDetector.cpp:881
EigerParam * mManualTrigger
Definition: eigerDetector.h:123
void parseTask(void)
Definition: eigerDetector.cpp:1006
char * portName
The name of this asyn port.
Definition: asynPortDriver.h:179
EigerParam * mDescription
Definition: eigerDetector.h:135
EigerParam * mTemperatureActual
Definition: eigerDetector.h:184
Definition: eigerParam.h:130
EigerParam * mThreshold
Definition: eigerDetector.h:140
void saveTask(void)
Definition: eigerDetector.cpp:1026
EigerParam * mThHumid0
Definition: eigerDetector.h:150
EigerParam * mMonitorTimeout
Definition: eigerDetector.h:131
EigerParam * mNumImages
Definition: eigerDetector.h:180
EigerParam * mLink2
Definition: eigerDetector.h:153
EigerParam * mTrigger
Definition: eigerDetector.h:121
EigerParam * mAutoSummation
Definition: eigerDetector.h:144
EigerParam * mNDArraySizeY
Definition: eigerDetector.h:186
void monitorTask(void)
Definition: eigerDetector.cpp:1146
virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo, const char **pptypeName, size_t *psize)
Called by asynManager to pass a pasynUser structure and drvInfo string to the driver; Assigns pasynUs...
Definition: eigerDetector.cpp:1677
EigerParam * mStreamEnable
Definition: eigerDetector.h:173
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: eigerDetector.cpp:468
EigerParam * mStreamDecompress
Definition: eigerDetector.h:132
EigerParam * mAcquirePeriod
Definition: eigerDetector.h:179
EigerParam * mTriggerMode
Definition: eigerDetector.h:181
EigerParam * mFWFree
Definition: eigerDetector.h:164
roi_mode
Definition: eigerDetector.h:105
EigerParam * mNDArraySizeX
Definition: eigerDetector.h:185
EigerParam * mFileOwner
Definition: eigerDetector.h:128
EigerParam * mStreamDropped
Definition: eigerDetector.h:174
EigerParam * mFWCompression
Definition: eigerDetector.h:159
EigerParam * mAcquireTime
Definition: eigerDetector.h:178
EigerParam * mDataSource
Definition: eigerDetector.h:119
EigerParam * mLink0
Definition: eigerDetector.h:151
EigerParam * mPhotonEnergy
Definition: eigerDetector.h:139
EigerParam * mFWState
Definition: eigerDetector.h:163
Definition: eigerDetector.h:80
EigerParam * mFileOwnerGroup
Definition: eigerDetector.h:129
EigerParam * mLink1
Definition: eigerDetector.h:152
EigerParam * mDCUBufFree
Definition: eigerDetector.h:155
EigerParam * mTriggerExp
Definition: eigerDetector.h:122
EigerParam * mSaveFiles
Definition: eigerDetector.h:127
Definition: eigerParam.h:43
EigerParam * mFWNImgsPerFile
Definition: eigerDetector.h:161
EigerParam * mMonitorBufSize
Definition: eigerDetector.h:169
void report(FILE *fp, int details)
Report status of the driver.
Definition: eigerDetector.cpp:602
unsigned char * buf
Definition: udp_client_pixirad_single.cpp:70
Definition: eigerDetector.h:108
EigerParam * mFilePerms
Definition: eigerDetector.h:130
EigerParam * mCompressionAlgo
Definition: eigerDetector.h:142
EigerParam * mLink3
Definition: eigerDetector.h:154
EigerParam * mPendingFiles
Definition: eigerDetector.h:126
eigerDetector(const char *portName, const char *serverHostname, int maxBuffers, size_t maxMemory, int priority, int stackSize)
Definition: eigerDetector.cpp:164
EigerParam * mFWClear
Definition: eigerDetector.h:165
EigerParam * mNTriggers
Definition: eigerDetector.h:141
EigerParam * mError
Definition: eigerDetector.h:148
EigerParam * mMonitorState
Definition: eigerDetector.h:170
EigerParam * mArmed
Definition: eigerDetector.h:124