areaDetector  3-12-1
EPICS areaDetector framework
Go to the documentation of this file.
1 #ifndef asynNDArrayDriver_H
2 #define asynNDArrayDriver_H
4 #include <epicsMutex.h>
5 #include <epicsEvent.h>
7 #include "asynPortDriver.h"
8 #include "NDArray.h"
9 #include "ADCoreVersion.h"
12 #define MAX_FILENAME_LEN 256
15 typedef enum {
20 } NDFileMode_t;
22 typedef enum {
27 typedef enum {
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 NDFileCaptureString "CAPTURE"
103 #define NDFileDeleteDriverFileString "DELETE_DRIVER_FILE"
104 #define NDFileLazyOpenString "FILE_LAZY_OPEN"
105 #define NDFileCreateDirString "CREATE_DIR"
106 #define NDFileTempSuffixString "FILE_TEMP_SUFFIX"
108 #define NDAttributesFileString "ND_ATTRIBUTES_FILE"
109 #define NDAttributesStatusString "ND_ATTRIBUTES_STATUS"
110 #define NDAttributesMacrosString "ND_ATTRIBUTES_MACROS"
112 /* The detector array data */
113 #define NDArrayDataString "ARRAY_DATA"
114 #define NDArrayCallbacksString "ARRAY_CALLBACKS"
116 /* NDArray Pool status and control */
117 #define NDPoolMaxBuffersString "POOL_MAX_BUFFERS"
118 #define NDPoolAllocBuffersString "POOL_ALLOC_BUFFERS"
119 #define NDPoolFreeBuffersString "POOL_FREE_BUFFERS"
120 #define NDPoolMaxMemoryString "POOL_MAX_MEMORY"
121 #define NDPoolUsedMemoryString "POOL_USED_MEMORY"
122 #define NDPoolEmptyFreeListString "POOL_EMPTY_FREELIST"
124 /* Queued arrays */
125 #define NDNumQueuedArraysString "NUM_QUEUED_ARRAYS"
132 class ADCORE_API asynNDArrayDriver : public asynPortDriver {
133 public:
134  asynNDArrayDriver(const char *portName, int maxAddr, int maxBuffers, size_t maxMemory,
135  int interfaceMask, int interruptMask,
136  int asynFlags, int autoConnect, int priority, int stackSize);
137  virtual ~asynNDArrayDriver();
138  /* These are the methods that we override from asynPortDriver */
139  virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
140  size_t *nActual);
141  virtual asynStatus readGenericPointer(asynUser *pasynUser, void *genericPointer);
142  virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *genericPointer);
143  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
144  virtual asynStatus setIntegerParam(int index, int value);
145  virtual asynStatus setIntegerParam(int list, int index, int value);
146  virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
147  virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
148  virtual void report(FILE *fp, int details);
150  /* These are the methods that are new to this class */
151  virtual asynStatus createFilePath(const char *path, int pathDepth);
152  virtual asynStatus checkPath();
153  virtual bool checkPath(std::string &filePath);
154  virtual asynStatus createFileName(int maxChars, char *fullFileName);
155  virtual asynStatus createFileName(int maxChars, char *filePath, char *fileName);
156  virtual asynStatus readNDAttributesFile();
157  virtual asynStatus getAttributes(NDAttributeList *pAttributeList);
159  asynStatus incrementQueuedArrayCount();
160  asynStatus decrementQueuedArrayCount();
161  int getQueuedArrayCount();
162  void updateQueuedArrayCount();
167 protected:
169  #define FIRST_NDARRAY_PARAM NDPortNameSelf
173  int ADModel;
193  int NDCodec;
230  class NDArray **pArrays;
235 private:
236  NDArrayPool *pNDArrayPoolPvt_;
237  epicsMutex *queuedArrayCountMutex_;
238  epicsEventId queuedArrayEvent_;
239  int queuedArrayCount_;
241  bool queuedArrayUpdateRun_;
242  epicsEventId queuedArrayUpdateDone_;
244  friend class NDArrayPool;
246 };
248 #endif
int NDFileNumber
Definition: asynNDArrayDriver.h:199
int NDNumQueuedArrays
Definition: asynNDArrayDriver.h:228
class NDArray ** pArrays
An array of NDArray pointers used to store data in the driver.
Definition: asynNDArrayDriver.h:230
int NDPoolUsedMemory
Definition: asynNDArrayDriver.h:226
int NDPoolFreeBuffers
Definition: asynNDArrayDriver.h:224
Definition: asynNDArrayDriver.h:28
The NDArrayPool class manages a free list (pool) of NDArray objects.
Definition: NDArray.h:163
Definition: asynNDArrayDriver.h:23
int NDArrayData
Definition: asynNDArrayDriver.h:220
Enumeration of file saving modes.
Definition: asynNDArrayDriver.h:15
int NDFileNumCapture
Definition: asynNDArrayDriver.h:210
int NDPortNameSelf
Definition: asynNDArrayDriver.h:168
int NDArraySizeX
Definition: asynNDArrayDriver.h:180
int NDArraySizeZ
Definition: asynNDArrayDriver.h:182
int ADSerialNumber
Definition: asynNDArrayDriver.h:174
int NDArraySize
Definition: asynNDArrayDriver.h:183
int NDNDimensions
Definition: asynNDArrayDriver.h:184
int NDFileWriteMessage
Definition: asynNDArrayDriver.h:209
int NDFileFormat
Definition: asynNDArrayDriver.h:203
list value
int NDDriverVersion
Definition: asynNDArrayDriver.h:171
int NDFileName
Definition: asynNDArrayDriver.h:198
int NDArrayCounter
Definition: asynNDArrayDriver.h:195
Definition: asynNDArrayDriver.h:29
int NDFileCapture
Definition: asynNDArrayDriver.h:212
int NDFilePath
Definition: asynNDArrayDriver.h:196
int threadPriority_
Definition: asynNDArrayDriver.h:233
int NDEpicsTSSec
Definition: asynNDArrayDriver.h:190
int NDAttributesFile
Definition: asynNDArrayDriver.h:217
int NDPoolEmptyFreeList
Definition: asynNDArrayDriver.h:227
int NDFileTempSuffix
Definition: asynNDArrayDriver.h:216
int NDADCoreVersion
Definition: asynNDArrayDriver.h:170
This is the class from which NDArray drivers are derived; implements the asynGenericPointer functions...
Definition: asynNDArrayDriver.h:132
int NDPoolAllocBuffers
Definition: asynNDArrayDriver.h:223
int ADWaitForPlugins
Definition: asynNDArrayDriver.h:179
int NDAutoSave
Definition: asynNDArrayDriver.h:204
int ADAcquireBusy
Definition: asynNDArrayDriver.h:178
int NDCodec
Definition: asynNDArrayDriver.h:193
int threadStackSize_
Definition: asynNDArrayDriver.h:232
int NDDataType
Definition: asynNDArrayDriver.h:186
Definition: NDAttributeList.h:21
int ADSDKVersion
Definition: asynNDArrayDriver.h:175
int ADManufacturer
Definition: asynNDArrayDriver.h:172
int NDFileWriteMode
Definition: asynNDArrayDriver.h:207
Stream arrays continuously to a single file if the file format supports this.
Definition: asynNDArrayDriver.h:19
int NDFileCreateDir
Definition: asynNDArrayDriver.h:215
Definition: asynNDArrayDriver.h:24
int NDEpicsTSNsec
Definition: asynNDArrayDriver.h:191
int NDFileNumCaptured
Definition: asynNDArrayDriver.h:211
int ADAcquire
Definition: asynNDArrayDriver.h:177
int NDDimensions
Definition: asynNDArrayDriver.h:185
class NDAttributeList * pAttributeList
An NDAttributeList object used to obtain the current values of a set of attributes.
Definition: asynNDArrayDriver.h:231
Definition: asynNDArrayDriver.h:31
int NDColorMode
Definition: asynNDArrayDriver.h:187
int NDBayerPattern
Definition: asynNDArrayDriver.h:192
int NDArraySizeY
Definition: asynNDArrayDriver.h:181
Write 1 array per file.
Definition: asynNDArrayDriver.h:16
int NDFileLazyOpen
Definition: asynNDArrayDriver.h:214
int NDFileTemplate
Definition: asynNDArrayDriver.h:200
Capture NDNumCapture arrays into memory, write them out when capture is complete.
Definition: asynNDArrayDriver.h:17
class NDArrayPool * pNDArrayPool
An NDArrayPool pointer that is initialized to pNDArrayPoolPvt_ in the constructor.
Definition: asynNDArrayDriver.h:164
Definition: asynNDArrayDriver.h:22
int NDUniqueId
Definition: asynNDArrayDriver.h:188
int NDAutoIncrement
Definition: asynNDArrayDriver.h:201
int NDAttributesStatus
Definition: asynNDArrayDriver.h:218
int NDFileWriteStatus
Definition: asynNDArrayDriver.h:208
int ADFirmwareVersion
Definition: asynNDArrayDriver.h:176
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:94
Definition: NDFileHDF5Layout.h:44
Definition: asynNDArrayDriver.h:27
int NDWriteFile
Definition: asynNDArrayDriver.h:205
int NDPoolMaxMemory
Definition: asynNDArrayDriver.h:225
Definition: asynNDArrayDriver.h:30
#define ADCORE_API
Definition: ADCoreAPI.h:41
int ADModel
Definition: asynNDArrayDriver.h:173
int NDFullFileName
Definition: asynNDArrayDriver.h:202
int NDTimeStamp
Definition: asynNDArrayDriver.h:189
int NDPoolMaxBuffers
Definition: asynNDArrayDriver.h:222
int NDAttributesMacros
Definition: asynNDArrayDriver.h:219
int NDCompressedSize
Definition: asynNDArrayDriver.h:194
int NDReadFile
Definition: asynNDArrayDriver.h:206
int NDFilePathExists
Definition: asynNDArrayDriver.h:197
int NDArrayCallbacks
Definition: asynNDArrayDriver.h:221
int NDFileDeleteDriverFile
Definition: asynNDArrayDriver.h:213