areaDetector  3-13
EPICS areaDetector framework
asynNDArrayDriver.h
Go to the documentation of this file.
1 #ifndef asynNDArrayDriver_H
2 #define asynNDArrayDriver_H
3 
4 #include <epicsMutex.h>
5 #include <epicsEvent.h>
6 
7 #include "asynPortDriver.h"
8 #include "NDArray.h"
9 #include "ADCoreVersion.h"
10 
12 #define MAX_FILENAME_LEN 256
13 
15 typedef enum {
21 
22 typedef enum {
26 
27 typedef enum {
33 
38  /* String asyn interface access Description */
39 #define NDPortNameSelfString "PORT_NAME_SELF"
42 #define NDADCoreVersionString "ADCORE_VERSION"
43 #define NDDriverVersionString "DRIVER_VERSION"
45 /* These parameters were previously in ADDriver.h.
46  * We moved them here so they can be used by other types of drivers
47  * For consistency the #define and parameter names should begin with ND rather than AD but that would break
48  * backwards compatibility. */
49 #define ADManufacturerString "MANUFACTURER"
50 #define ADModelString "MODEL"
51 #define ADSerialNumberString "SERIAL_NUMBER"
52 #define ADSDKVersionString "SDK_VERSION"
53 #define ADFirmwareVersionString "FIRMWARE_VERSION"
54 #define ADAcquireString "ACQUIRE"
55 #define ADAcquireBusyString "ACQUIRE_BUSY"
56 #define ADWaitForPluginsString "WAIT_FOR_PLUGINS"
58 /* Parameters defining characteristics of the array data from the detector.
59  * NDArraySizeX and NDArraySizeY are the actual dimensions of the array data,
60  * including effects of the region definition and binning */
61 #define NDArraySizeXString "ARRAY_SIZE_X"
62 #define NDArraySizeYString "ARRAY_SIZE_Y"
63 #define NDArraySizeZString "ARRAY_SIZE_Z"
64 #define NDArraySizeString "ARRAY_SIZE"
65 #define NDNDimensionsString "ARRAY_NDIMENSIONS"
66 #define NDDimensionsString "ARRAY_DIMENSIONS"
67 #define NDDataTypeString "DATA_TYPE"
68 #define NDColorModeString "COLOR_MODE"
69 #define NDUniqueIdString "UNIQUE_ID"
70 #define NDTimeStampString "TIME_STAMP"
71 #define NDEpicsTSSecString "EPICS_TS_SEC"
72 #define NDEpicsTSNsecString "EPICS_TS_NSEC"
73 #define NDBayerPatternString "BAYER_PATTERN"
74 #define NDCodecString "CODEC"
75 #define NDCompressedSizeString "COMPRESSED_SIZE"
77 /* Statistics on number of arrays collected */
78 #define NDArrayCounterString "ARRAY_COUNTER"
80 /* File name related parameters for saving data.
81  * Drivers are not required to implement file saving, but if they do these parameters
82  * should be used.
83  * The driver will normally combine NDFilePath, NDFileName, and NDFileNumber into
84  * a file name that order using the format specification in NDFileTemplate.
85  * For example NDFileTemplate might be "%s%s_%d.tif" */
86 #define NDFilePathString "FILE_PATH"
87 #define NDFilePathExistsString "FILE_PATH_EXISTS"
88 #define NDFileNameString "FILE_NAME"
89 #define NDFileNumberString "FILE_NUMBER"
90 #define NDFileTemplateString "FILE_TEMPLATE"
91 #define NDAutoIncrementString "AUTO_INCREMENT"
92 #define NDFullFileNameString "FULL_FILE_NAME"
93 #define NDFileFormatString "FILE_FORMAT"
94 #define NDAutoSaveString "AUTO_SAVE"
95 #define NDWriteFileString "WRITE_FILE"
96 #define NDReadFileString "READ_FILE"
97 #define NDFileWriteModeString "WRITE_MODE"
98 #define NDFileWriteStatusString "WRITE_STATUS"
99 #define NDFileWriteMessageString "WRITE_MESSAGE"
100 #define NDFileNumCaptureString "NUM_CAPTURE"
101 #define NDFileNumCapturedString "NUM_CAPTURED"
102 #define NDFileFreeCaptureString "FREE_CAPTURE"
103 #define NDFileCaptureString "CAPTURE"
104 #define NDFileDeleteDriverFileString "DELETE_DRIVER_FILE"
105 #define NDFileLazyOpenString "FILE_LAZY_OPEN"
106 #define NDFileCreateDirString "CREATE_DIR"
107 #define NDFileTempSuffixString "FILE_TEMP_SUFFIX"
109 #define NDAttributesFileString "ND_ATTRIBUTES_FILE"
110 #define NDAttributesStatusString "ND_ATTRIBUTES_STATUS"
111 #define NDAttributesMacrosString "ND_ATTRIBUTES_MACROS"
113 /* The detector array data */
114 #define NDArrayDataString "ARRAY_DATA"
115 #define NDArrayCallbacksString "ARRAY_CALLBACKS"
117 /* NDArray Pool status and control */
118 #define NDPoolMaxBuffersString "POOL_MAX_BUFFERS"
119 #define NDPoolAllocBuffersString "POOL_ALLOC_BUFFERS"
120 #define NDPoolPreAllocBuffersString "POOL_PRE_ALLOC_BUFFERS"
121 #define NDPoolNumPreAllocBuffersString "POOL_NUM_PRE_ALLOC_BUFFERS"
122 #define NDPoolFreeBuffersString "POOL_FREE_BUFFERS"
123 #define NDPoolMaxMemoryString "POOL_MAX_MEMORY"
124 #define NDPoolUsedMemoryString "POOL_USED_MEMORY"
125 #define NDPoolEmptyFreeListString "POOL_EMPTY_FREELIST"
126 #define NDPoolPollStatsString "POOL_POLL_STATS"
127 
128 /* Queued arrays */
129 #define NDNumQueuedArraysString "NUM_QUEUED_ARRAYS"
130 
136 class ADCORE_API asynNDArrayDriver : public asynPortDriver {
137 public:
138  asynNDArrayDriver(const char *portName, int maxAddr, int maxBuffers, size_t maxMemory,
139  int interfaceMask, int interruptMask,
140  int asynFlags, int autoConnect, int priority, int stackSize);
141  virtual ~asynNDArrayDriver();
142  /* These are the methods that we override from asynPortDriver */
143  virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
144  size_t *nActual);
145  virtual asynStatus readGenericPointer(asynUser *pasynUser, void *genericPointer);
146  virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *genericPointer);
147  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
148  virtual asynStatus setIntegerParam(int index, int value);
149  virtual asynStatus setIntegerParam(int list, int index, int value);
150  virtual void report(FILE *fp, int details);
151 
152  /* These are the methods that are new to this class */
153  virtual asynStatus createFilePath(const char *path, int pathDepth);
154  virtual asynStatus checkPath();
155  virtual bool checkPath(std::string &filePath);
156  virtual asynStatus createFileName(int maxChars, char *fullFileName);
157  virtual asynStatus createFileName(int maxChars, char *filePath, char *fileName);
158  virtual asynStatus readNDAttributesFile();
159  virtual asynStatus getAttributes(NDAttributeList *pAttributeList);
160  virtual void updateTimeStamps(NDArray *pArray);
161 
162  asynStatus incrementQueuedArrayCount();
163  asynStatus decrementQueuedArrayCount();
164  int getQueuedArrayCount();
165  void updateQueuedArrayCount();
166 
170 protected:
172  #define FIRST_NDARRAY_PARAM NDPortNameSelf
176  int ADModel;
196  int NDCodec;
236 
237  class NDArray **pArrays;
241 
242 private:
243  asynStatus preAllocateBuffers();
244  NDArrayPool *pNDArrayPoolPvt_;
245  epicsMutex *queuedArrayCountMutex_;
246  epicsEventId queuedArrayEvent_;
247  int queuedArrayCount_;
248 
249  bool queuedArrayUpdateRun_;
250  epicsEventId queuedArrayUpdateDone_;
251 
252  friend class NDArrayPool;
253 
254 };
255 
256 #endif
#define ADCORE_API
Definition: ADCoreAPI.h:41
NDAttributesStatus_t
Definition: asynNDArrayDriver.h:27
@ NDAttributesMacroError
Definition: asynNDArrayDriver.h:31
@ NDAttributesFileNotFound
Definition: asynNDArrayDriver.h:29
@ NDAttributesXMLSyntaxError
Definition: asynNDArrayDriver.h:30
@ NDAttributesOK
Definition: asynNDArrayDriver.h:28
NDFileMode_t
Enumeration of file saving modes.
Definition: asynNDArrayDriver.h:15
@ NDFileModeStream
Stream arrays continuously to a single file if the file format supports this.
Definition: asynNDArrayDriver.h:19
@ NDFileModeCapture
Capture NDNumCapture arrays into memory, write them out when capture is complete.
Definition: asynNDArrayDriver.h:17
@ NDFileModeSingle
Write 1 array per file.
Definition: asynNDArrayDriver.h:16
NDFileWriteStatus_t
Definition: asynNDArrayDriver.h:22
@ NDFileWriteOK
Definition: asynNDArrayDriver.h:23
@ NDFileWriteError
Definition: asynNDArrayDriver.h:24
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:99
The NDArrayPool class manages a free list (pool) of NDArray objects.
Definition: NDArray.h:168
NDAttributeList.h.
Definition: NDAttributeList.h:21
This is the class from which NDArray drivers are derived; implements the asynGenericPointer functions...
Definition: asynNDArrayDriver.h:136
int NDAttributesStatus
Definition: asynNDArrayDriver.h:222
int NDFileDeleteDriverFile
Definition: asynNDArrayDriver.h:217
int NDDimensions
Definition: asynNDArrayDriver.h:188
int NDPoolUsedMemory
Definition: asynNDArrayDriver.h:232
int NDCompressedSize
Definition: asynNDArrayDriver.h:197
int NDArrayData
Definition: asynNDArrayDriver.h:224
int NDDriverVersion
Definition: asynNDArrayDriver.h:174
int NDFileTemplate
Definition: asynNDArrayDriver.h:203
int ADManufacturer
Definition: asynNDArrayDriver.h:175
int NDFileWriteMessage
Definition: asynNDArrayDriver.h:212
int NDFilePathExists
Definition: asynNDArrayDriver.h:200
int NDCodec
Definition: asynNDArrayDriver.h:196
int NDEpicsTSNsec
Definition: asynNDArrayDriver.h:194
int threadStackSize_
Definition: asynNDArrayDriver.h:239
int ADModel
Definition: asynNDArrayDriver.h:176
int ADFirmwareVersion
Definition: asynNDArrayDriver.h:179
int NDAttributesFile
Definition: asynNDArrayDriver.h:221
int NDFileName
Definition: asynNDArrayDriver.h:201
int NDFileTempSuffix
Definition: asynNDArrayDriver.h:220
int NDPoolMaxBuffers
Definition: asynNDArrayDriver.h:226
int NDWriteFile
Definition: asynNDArrayDriver.h:208
int NDFileNumber
Definition: asynNDArrayDriver.h:202
int NDBayerPattern
Definition: asynNDArrayDriver.h:195
class NDArray ** pArrays
An array of NDArray pointers used to store data in the driver.
Definition: asynNDArrayDriver.h:237
int NDPoolMaxMemory
Definition: asynNDArrayDriver.h:231
int NDFileCreateDir
Definition: asynNDArrayDriver.h:219
int NDArraySizeZ
Definition: asynNDArrayDriver.h:185
int NDAutoSave
Definition: asynNDArrayDriver.h:207
int NDArraySizeY
Definition: asynNDArrayDriver.h:184
int NDArraySizeX
Definition: asynNDArrayDriver.h:183
class NDAttributeList * pAttributeList
An NDAttributeList object used to obtain the current values of a set of attributes.
Definition: asynNDArrayDriver.h:238
int NDFileFormat
Definition: asynNDArrayDriver.h:206
int ADSDKVersion
Definition: asynNDArrayDriver.h:178
int NDUniqueId
Definition: asynNDArrayDriver.h:191
int NDFileLazyOpen
Definition: asynNDArrayDriver.h:218
int NDPoolFreeBuffers
Definition: asynNDArrayDriver.h:230
int NDPoolNumPreAllocBuffers
Definition: asynNDArrayDriver.h:229
int NDAutoIncrement
Definition: asynNDArrayDriver.h:204
int NDTimeStamp
Definition: asynNDArrayDriver.h:192
int ADAcquire
Definition: asynNDArrayDriver.h:180
int NDNDimensions
Definition: asynNDArrayDriver.h:187
int NDFileNumCaptured
Definition: asynNDArrayDriver.h:214
int ADSerialNumber
Definition: asynNDArrayDriver.h:177
int threadPriority_
Definition: asynNDArrayDriver.h:240
int ADAcquireBusy
Definition: asynNDArrayDriver.h:181
int NDFileWriteStatus
Definition: asynNDArrayDriver.h:211
int NDAttributesMacros
Definition: asynNDArrayDriver.h:223
int NDFileNumCapture
Definition: asynNDArrayDriver.h:213
int NDArrayCounter
Definition: asynNDArrayDriver.h:198
int NDArraySize
Definition: asynNDArrayDriver.h:186
int NDColorMode
Definition: asynNDArrayDriver.h:190
int NDFilePath
Definition: asynNDArrayDriver.h:199
int NDReadFile
Definition: asynNDArrayDriver.h:209
int NDPortNameSelf
Definition: asynNDArrayDriver.h:171
int NDFullFileName
Definition: asynNDArrayDriver.h:205
class NDArrayPool * pNDArrayPool
An NDArrayPool pointer that is initialized to pNDArrayPoolPvt_ in the constructor.
Definition: asynNDArrayDriver.h:167
int NDADCoreVersion
Definition: asynNDArrayDriver.h:173
int NDPoolPreAllocBuffers
Definition: asynNDArrayDriver.h:228
int ADWaitForPlugins
Definition: asynNDArrayDriver.h:182
int NDFileCapture
Definition: asynNDArrayDriver.h:216
int NDPoolAllocBuffers
Definition: asynNDArrayDriver.h:227
int NDFileWriteMode
Definition: asynNDArrayDriver.h:210
int NDFileFreeCapture
Definition: asynNDArrayDriver.h:215
int NDArrayCallbacks
Definition: asynNDArrayDriver.h:225
int NDPoolEmptyFreeList
Definition: asynNDArrayDriver.h:233
int NDDataType
Definition: asynNDArrayDriver.h:189
int NDEpicsTSSec
Definition: asynNDArrayDriver.h:193
int NDPoolPollStats
Definition: asynNDArrayDriver.h:234
int NDNumQueuedArrays
Definition: asynNDArrayDriver.h:235
@ string
Definition: NDFileHDF5Layout.h:44
list value
Definition: makeDbAndEdl.py:234