areaDetector  3-5-0
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 /* Parameters defining characteristics of the array data from the detector.
46  * NDArraySizeX and NDArraySizeY are the actual dimensions of the array data,
47  * including effects of the region definition and binning */
48 #define NDArraySizeXString "ARRAY_SIZE_X"
49 #define NDArraySizeYString "ARRAY_SIZE_Y"
50 #define NDArraySizeZString "ARRAY_SIZE_Z"
51 #define NDArraySizeString "ARRAY_SIZE"
52 #define NDNDimensionsString "ARRAY_NDIMENSIONS"
53 #define NDDimensionsString "ARRAY_DIMENSIONS"
54 #define NDDataTypeString "DATA_TYPE"
55 #define NDColorModeString "COLOR_MODE"
56 #define NDUniqueIdString "UNIQUE_ID"
57 #define NDTimeStampString "TIME_STAMP"
58 #define NDEpicsTSSecString "EPICS_TS_SEC"
59 #define NDEpicsTSNsecString "EPICS_TS_NSEC"
60 #define NDBayerPatternString "BAYER_PATTERN"
61 #define NDCodecString "CODEC"
62 #define NDCompressedSizeString "COMPRESSED_SIZE"
64 /* Statistics on number of arrays collected */
65 #define NDArrayCounterString "ARRAY_COUNTER"
67 /* File name related parameters for saving data.
68  * Drivers are not required to implement file saving, but if they do these parameters
69  * should be used.
70  * The driver will normally combine NDFilePath, NDFileName, and NDFileNumber into
71  * a file name that order using the format specification in NDFileTemplate.
72  * For example NDFileTemplate might be "%s%s_%d.tif" */
73 #define NDFilePathString "FILE_PATH"
74 #define NDFilePathExistsString "FILE_PATH_EXISTS"
75 #define NDFileNameString "FILE_NAME"
76 #define NDFileNumberString "FILE_NUMBER"
77 #define NDFileTemplateString "FILE_TEMPLATE"
78 #define NDAutoIncrementString "AUTO_INCREMENT"
79 #define NDFullFileNameString "FULL_FILE_NAME"
80 #define NDFileFormatString "FILE_FORMAT"
81 #define NDAutoSaveString "AUTO_SAVE"
82 #define NDWriteFileString "WRITE_FILE"
83 #define NDReadFileString "READ_FILE"
84 #define NDFileWriteModeString "WRITE_MODE"
85 #define NDFileWriteStatusString "WRITE_STATUS"
86 #define NDFileWriteMessageString "WRITE_MESSAGE"
87 #define NDFileNumCaptureString "NUM_CAPTURE"
88 #define NDFileNumCapturedString "NUM_CAPTURED"
89 #define NDFileCaptureString "CAPTURE"
90 #define NDFileDeleteDriverFileString "DELETE_DRIVER_FILE"
91 #define NDFileLazyOpenString "FILE_LAZY_OPEN"
92 #define NDFileCreateDirString "CREATE_DIR"
93 #define NDFileTempSuffixString "FILE_TEMP_SUFFIX"
95 #define NDAttributesFileString "ND_ATTRIBUTES_FILE"
96 #define NDAttributesStatusString "ND_ATTRIBUTES_STATUS"
97 #define NDAttributesMacrosString "ND_ATTRIBUTES_MACROS"
99 /* The detector array data */
100 #define NDArrayDataString "ARRAY_DATA"
101 #define NDArrayCallbacksString "ARRAY_CALLBACKS"
103 /* NDArray Pool status and control */
104 #define NDPoolMaxBuffersString "POOL_MAX_BUFFERS"
105 #define NDPoolAllocBuffersString "POOL_ALLOC_BUFFERS"
106 #define NDPoolFreeBuffersString "POOL_FREE_BUFFERS"
107 #define NDPoolMaxMemoryString "POOL_MAX_MEMORY"
108 #define NDPoolUsedMemoryString "POOL_USED_MEMORY"
109 #define NDPoolEmptyFreeListString "POOL_EMPTY_FREELIST"
111 /* Queued arrays */
112 #define NDNumQueuedArraysString "NUM_QUEUED_ARRAYS"
119 class epicsShareFunc asynNDArrayDriver : public asynPortDriver {
120 public:
121  asynNDArrayDriver(const char *portName, int maxAddr, int maxBuffers, size_t maxMemory,
122  int interfaceMask, int interruptMask,
123  int asynFlags, int autoConnect, int priority, int stackSize);
124  virtual ~asynNDArrayDriver();
125  /* These are the methods that we override from asynPortDriver */
126  virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
127  size_t *nActual);
128  virtual asynStatus readGenericPointer(asynUser *pasynUser, void *genericPointer);
129  virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *genericPointer);
130  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
131  virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
132  virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
133  virtual void report(FILE *fp, int details);
135  /* These are the methods that are new to this class */
136  virtual asynStatus createFilePath(const char *path, int pathDepth);
137  virtual asynStatus checkPath();
138  virtual bool checkPath(std::string &filePath);
139  virtual asynStatus createFileName(int maxChars, char *fullFileName);
140  virtual asynStatus createFileName(int maxChars, char *filePath, char *fileName);
141  virtual asynStatus readNDAttributesFile();
142  virtual asynStatus getAttributes(NDAttributeList *pAttributeList);
144  asynStatus incrementQueuedArrayCount();
145  asynStatus decrementQueuedArrayCount();
146  int getQueuedArrayCount();
147  void updateQueuedArrayCount();
152 protected:
154  #define FIRST_NDARRAY_PARAM NDPortNameSelf
170  int NDCodec;
207  class NDArray **pArrays;
212 private:
213  NDArrayPool *pNDArrayPoolPvt_;
214  epicsMutex *queuedArrayCountMutex_;
215  epicsEventId queuedArrayEvent_;
216  int queuedArrayCount_;
218  bool queuedArrayUpdateRun_;
219  epicsEventId queuedArrayUpdateDone_;
221  friend class NDArrayPool;
223 };
225 #endif
int NDFileNumber
Definition: asynNDArrayDriver.h:176
int NDNumQueuedArrays
Definition: asynNDArrayDriver.h:205
class NDArray ** pArrays
An array of NDArray pointers used to store data in the driver.
Definition: asynNDArrayDriver.h:207
int NDPoolUsedMemory
Definition: asynNDArrayDriver.h:203
int NDPoolFreeBuffers
Definition: asynNDArrayDriver.h:201
Definition: asynNDArrayDriver.h:28
The NDArrayPool class manages a free list (pool) of NDArray objects.
Definition: NDArray.h:161
Definition: asynNDArrayDriver.h:23
int NDArrayData
Definition: asynNDArrayDriver.h:197
Enumeration of file saving modes.
Definition: asynNDArrayDriver.h:15
int NDFileNumCapture
Definition: asynNDArrayDriver.h:187
Base class for asyn port drivers; handles most of the bookkeeping for writing an asyn port driver wit...
Definition: asynPortDriver.h:41
int NDPortNameSelf
Definition: asynNDArrayDriver.h:153
int NDArraySizeX
Definition: asynNDArrayDriver.h:157
int NDArraySizeZ
Definition: asynNDArrayDriver.h:159
int NDArraySize
Definition: asynNDArrayDriver.h:160
int NDNDimensions
Definition: asynNDArrayDriver.h:161
int NDFileWriteMessage
Definition: asynNDArrayDriver.h:186
int NDFileFormat
Definition: asynNDArrayDriver.h:180
list value
int NDDriverVersion
Definition: asynNDArrayDriver.h:156
int NDFileName
Definition: asynNDArrayDriver.h:175
int NDArrayCounter
Definition: asynNDArrayDriver.h:172
Definition: asynNDArrayDriver.h:29
int NDFileCapture
Definition: asynNDArrayDriver.h:189
int NDFilePath
Definition: asynNDArrayDriver.h:173
int threadPriority_
Definition: asynNDArrayDriver.h:210
int NDEpicsTSSec
Definition: asynNDArrayDriver.h:167
int NDAttributesFile
Definition: asynNDArrayDriver.h:194
int NDPoolEmptyFreeList
Definition: asynNDArrayDriver.h:204
int NDFileTempSuffix
Definition: asynNDArrayDriver.h:193
int NDADCoreVersion
Definition: asynNDArrayDriver.h:155
virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *pointer)
Called when asyn clients call pasynGenericPointer->write().
Definition: asynPortDriver.cpp:2719
This is the class from which NDArray drivers are derived; implements the asynGenericPointer functions...
Definition: asynNDArrayDriver.h:119
virtual void report(FILE *fp, int details)
Reports on status of the driver.
Definition: asynPortDriver.cpp:3035
int NDPoolAllocBuffers
Definition: asynNDArrayDriver.h:200
int NDAutoSave
Definition: asynNDArrayDriver.h:181
int NDCodec
Definition: asynNDArrayDriver.h:170
int threadStackSize_
Definition: asynNDArrayDriver.h:209
int NDDataType
Definition: asynNDArrayDriver.h:163
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: asynPortDriver.cpp:1727
Definition: NDAttributeList.h:21
int NDFileWriteMode
Definition: asynNDArrayDriver.h:184
Stream arrays continuously to a single file if the file format supports this.
Definition: asynNDArrayDriver.h:19
int NDFileCreateDir
Definition: asynNDArrayDriver.h:192
Definition: asynNDArrayDriver.h:24
int NDEpicsTSNsec
Definition: asynNDArrayDriver.h:168
int NDFileNumCaptured
Definition: asynNDArrayDriver.h:188
int NDDimensions
Definition: asynNDArrayDriver.h:162
class NDAttributeList * pAttributeList
An NDAttributeList object used to obtain the current values of a set of attributes.
Definition: asynNDArrayDriver.h:208
Definition: asynNDArrayDriver.h:31
virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars, size_t *nActual)
Called when asyn clients call pasynOctet->write().
Definition: asynPortDriver.cpp:2188
int NDColorMode
Definition: asynNDArrayDriver.h:164
int NDBayerPattern
Definition: asynNDArrayDriver.h:169
int NDArraySizeY
Definition: asynNDArrayDriver.h:158
Write 1 array per file.
Definition: asynNDArrayDriver.h:16
int NDFileLazyOpen
Definition: asynNDArrayDriver.h:191
virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value)
Called when asyn clients call pasynInt32->read().
Definition: asynPortDriver.cpp:1679
int NDFileTemplate
Definition: asynNDArrayDriver.h:177
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:149
Definition: asynNDArrayDriver.h:22
int NDUniqueId
Definition: asynNDArrayDriver.h:165
int NDAutoIncrement
Definition: asynNDArrayDriver.h:178
int NDAttributesStatus
Definition: asynNDArrayDriver.h:195
int NDFileWriteStatus
Definition: asynNDArrayDriver.h:185
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:92
Definition: NDFileHDF5Layout.h:42
Definition: asynNDArrayDriver.h:27
int NDWriteFile
Definition: asynNDArrayDriver.h:182
int NDPoolMaxMemory
Definition: asynNDArrayDriver.h:202
Definition: asynNDArrayDriver.h:30
int NDFullFileName
Definition: asynNDArrayDriver.h:179
virtual asynStatus readGenericPointer(asynUser *pasynUser, void *pointer)
Called when asyn clients call pasynGenericPointer->read().
Definition: asynPortDriver.cpp:2696
int NDTimeStamp
Definition: asynNDArrayDriver.h:166
int NDPoolMaxBuffers
Definition: asynNDArrayDriver.h:199
int NDAttributesMacros
Definition: asynNDArrayDriver.h:196
int NDCompressedSize
Definition: asynNDArrayDriver.h:171
int NDReadFile
Definition: asynNDArrayDriver.h:183
int NDFilePathExists
Definition: asynNDArrayDriver.h:174
virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value)
Called when asyn clients call pasynFloat64->read().
Definition: asynPortDriver.cpp:2030
int NDArrayCallbacks
Definition: asynNDArrayDriver.h:198
int NDFileDeleteDriverFile
Definition: asynNDArrayDriver.h:190