areaDetector 3-14
EPICS areaDetector framework
merlinDetector.h
Go to the documentation of this file.
1/*
2 * merlinDetector.h
3 *
4 * Created on: 16 Oct 2013
5 * Author: hgv27681
6 */
7
8#ifndef MEDIPIXDETECTOR_H_
9#define MEDIPIXDETECTOR_H_
10
12#define MAX_MESSAGE_SIZE 256
13#define MAX_FILENAME_LEN 256
14#define MAX_BAD_PIXELS 100
16#define ASYN_POLL_TIME .01
17#define Labview_DEFAULT_TIMEOUT 2.0
19#define FILE_READ_DELAY .01
20
21#define DIMS 2
22
28
49
50
61
64#define TMTrigInternal (char*)"0"
65#define TMTrigRising (char*)"1"
66#define TMTrigFalling (char*)"2"
67#define TMTrigSoftware (char*)"3"
68
71#define merlinDelayTimeString "DELAY_TIME"
72#define merlinThreshold0String "THRESHOLD0"
73#define merlinThreshold1String "THRESHOLD1"
74#define merlinThreshold2String "THRESHOLD2"
75#define merlinThreshold3String "THRESHOLD3"
76#define merlinThreshold4String "THRESHOLD4"
77#define merlinThreshold5String "THRESHOLD5"
78#define merlinThreshold6String "THRESHOLD6"
79#define merlinThreshold7String "THRESHOLD7"
80#define merlinOperatingEnergyString "OPERATINGENERGY"
81
82#define merlinThresholdApplyString "THRESHOLD_APPLY"
83#define merlinThresholdAutoApplyString "THRESHOLD_AUTO_APPLY"
84#define merlinArmedString "ARMED"
85
86#define merlinmedpixThresholdScanString "THRESHOLDSCAN"
87#define merlinStartThresholdScanString "THRESHOLDSTART"
88#define merlinStopThresholdScanString "THRESHOLDSTOP"
89#define merlinStepThresholdScanString "THRESHOLDSTEP"
90#define merlinStartThresholdScanningString "STARTTHRESHOLDSCANNING"
91#define merlinCounterDepthString "COUNTERDEPTH"
92#define merlinResetString "RESET"
93#define merlinSoftwareTriggerString "SOFTWARETRIGGER"
94#define merlinEnableCounter1String "ENABLECOUNTER1"
95#define merlinContinuousRWString "CONTINUOUSRW"
96
97// Merlin XBPM SPECIFIC
98#define merlinProfileControlString "PROFILECONTROL"
99#define merlinProfileXString "PROFILE_AVERAGE_X"
100#define merlinProfileYString "PROFILE_AVERAGE_Y"
101
102// UoM BPM SPECIFIC
103#define merlinEnableBackgroundCorrString "ENABLEBACKGROUNDCORR"
104#define merlinEnableImageSumString "ENABLESUMAVERAGE"
105
106// Merlin Quad
107#define merlinQuadMerlinModeString "QUADMERLINMODE"
108#define merlinSelectGuiString "SELECTGUI"
109
110class mpxConnection;
111
114{
115public:
116 merlinDetector(const char *portName, const char *LabviewCmdPort,
117 const char *LabviewDataPort, int maxSizeX, int maxSizeY,
118 int detectorType, int maxBuffers, size_t maxMemory, int priority,
119 int stackSize);
120
121 /* These are the methods that we override from ADDriver */
122 virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
123 virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
124// virtual asynStatus writeOctet(asynUser *pasynUser, const char *value,
125// size_t nChars, size_t *nActual);
126 void report(FILE *fp, int details);
127 void merlinTask(); /* This should be private but is called from C so must be public */
128 void merlinStatus(); /* This should be private but is called from C so must be public */
129
130 void fromLabViewStr(const char *str);
131 void toLabViewStr(const char *str);
132
133protected:
135#define FIRST_merlin_PARAM merlinDelayTime
165
166#define LAST_merlin_PARAM merlinSelectGui
167
168private:
169 /* These are the methods that are new to this class */
170 void abortAcquisition();
171 asynStatus SetQuadMode(int mode);
172 asynStatus setModeCommands(int function);
173 asynStatus setAcquireParams();
174 asynStatus getThreshold();
175 asynStatus updateThresholdScanParms();
176 asynStatus setROI();
177
178 NDArray* copyProfileToNDArray32(size_t *dims, char *buffer,
179 int profileMask);
180 NDArray* copyToNDArray8(size_t *dims, char *buffer, int offset);
181 NDArray* copyToNDArray16(size_t *dims, char *buffer, int offset);
182 NDArray* copyToNDArray32(size_t *dims, char *buffer, int offset);
183 inline void endian_swap(unsigned short& x);
184 inline void endian_swap(unsigned int& x);
185 inline void endian_swap(uint64_t& x);
186 unsigned int maxSize[2];
187
188 /* Our data */
189 int imagesRemaining;
190 NDArray *pFlatField;
191 int multipleFileNumber;
192 asynUser *pasynLabViewCmd;
193 asynUser *pasynLabViewData;
194 double averageFlatField;
195 int framesPerAcquire;
196
197 int *profileX;
198 int *profileY;
199
200 bool startingUp; // used to avoid very chatty initialisation
201
202 char LabviewCommandPortName[20];
203 char LabviewDataPortName[20];
204
205 merlinDetectorType detType;
206
207 mpxConnection *cmdConnection;
208 mpxConnection *dataConnection;
209};
210
211#define NUM_merlin_PARAMS (&LAST_merlin_PARAM - &FIRST_merlin_PARAM + 1)
212
213static const char *driverName = "merlinDetector";
214
215#endif /* MEDIPIXDETECTOR_H_ */
Class from which areaDetector drivers are directly derived.
Definition ADDriver.h:132
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition NDArray.h:99
Driver for Dectris merlin pixel array detectors using their Labview server over TCP/IP socket.
Definition merlinDetector.h:114
int merlinProfileX
Definition merlinDetector.h:159
int merlinEnableBackgroundCorr
Definition merlinDetector.h:161
int merlinOperatingEnergy
Definition merlinDetector.h:144
int merlinDelayTime
Definition merlinDetector.h:134
int merlinSoftwareTrigger
Definition merlinDetector.h:154
void merlinTask()
This thread controls acquisition, reads image files to get the image data, and does the callbacks to ...
Definition merlinDetector.cpp:51
int merlinThreshold6
Definition merlinDetector.h:142
int merlinReset
Definition merlinDetector.h:155
int merlinThreshold1
Definition merlinDetector.h:137
int merlinEnableCounter1
Definition merlinDetector.h:156
int merlinThreshold2
Definition merlinDetector.h:138
int merlinCounterDepth
Definition merlinDetector.h:153
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition merlinDetector.cpp:1033
int merlinSelectGui
Definition merlinDetector.h:164
int merlinQuadMerlinMode
Definition merlinDetector.h:163
int merlinThresholdAutoApply
Definition merlinDetector.h:146
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition merlinDetector.cpp:1195
int merlinStepThresholdScan
Definition merlinDetector.h:151
int merlinTvxVersion
Definition merlinDetector.h:152
int merlinThresholdApply
Definition merlinDetector.h:145
int merlinArmed
Definition merlinDetector.h:147
void fromLabViewStr(const char *str)
Definition merlinDetector.cpp:347
int merlinThreshold5
Definition merlinDetector.h:141
int merlinProfileY
Definition merlinDetector.h:160
int merlinThresholdScan
Definition merlinDetector.h:148
int merlinStartThresholdScan
Definition merlinDetector.h:149
int merlinEnableImageSum
Definition merlinDetector.h:162
void toLabViewStr(const char *str)
Definition merlinDetector.cpp:352
int merlinProfileControl
Definition merlinDetector.h:158
void merlinStatus()
This thread periodically read the detector status (temperature, humidity, etc.) It does not run if we...
Definition merlinDetector.cpp:916
void report(FILE *fp, int details)
Report status of the driver.
Definition merlinDetector.cpp:1315
int merlinContinuousRW
Definition merlinDetector.h:157
int merlinStopThresholdScan
Definition merlinDetector.h:150
int merlinThreshold3
Definition merlinDetector.h:139
int merlinThreshold4
Definition merlinDetector.h:140
int merlinThreshold0
Definition merlinDetector.h:136
int merlinThreshold7
Definition merlinDetector.h:143
Definition mpxConnection.h:21
MPXQuadMode_t
Enumeration of merlin quad modes.
Definition merlinDetector.h:53
@ MPXQuadModeContinuousRW
Definition merlinDetector.h:57
@ MPXQuadModeSumming
Definition merlinDetector.h:59
@ MPXQuadMode2Threshold
Definition merlinDetector.h:56
@ MPXQuadMode12Bit
Definition merlinDetector.h:54
@ MPXQuadModeColour
Definition merlinDetector.h:58
@ MPXQuadMode24Bit
Definition merlinDetector.h:55
merlinTriggerMode
Trigger modes.
Definition merlinDetector.h:31
@ TMSoftwareTrigger
Definition merlinDetector.h:37
@ TMExternalEnable
Definition merlinDetector.h:33
@ TMExternalTriggerHigh
Definition merlinDetector.h:34
@ TMExternalTriggerRising
Definition merlinDetector.h:36
@ TMExternalTriggerLow
Definition merlinDetector.h:35
@ TMInternal
Definition merlinDetector.h:32
MPXImageMode_t
Trigger modes.
Definition merlinDetector.h:42
@ MPXBackgroundCalibrate
Definition merlinDetector.h:47
@ MPXThresholdScan
Definition merlinDetector.h:46
@ MPXImageContinuous
Collect images continuously until Acquire is set to 0.
Definition merlinDetector.h:45
@ MPXImageMultiple
Collect ADNumImages images per Acquire command.
Definition merlinDetector.h:44
@ MPXImageSingle
Collect a single image per Acquire command.
Definition merlinDetector.h:43
merlinDetectorType
Detector Types.
Definition merlinDetector.h:25
@ MerlinQuad
Definition merlinDetector.h:26
@ UomXBPM
Definition merlinDetector.h:26
@ MerlinXBPM
Definition merlinDetector.h:26
@ Merlin
Definition merlinDetector.h:26