dxp 3-4
/home/epics/devel/areaDetector/ADCore/ADApp/ADSrc/asynNDArrayDriver.h
Go to the documentation of this file.
00001 #ifndef asynNDArrayDriver_H
00002 #define asynNDArrayDriver_H
00003 
00004 #include "asynPortDriver.h"
00005 #include "NDArray.h"
00006 
00008 #define MAX_FILENAME_LEN 256
00009 
00011 typedef enum {
00012     NDFileModeSingle,       
00013     NDFileModeCapture,      
00015     NDFileModeStream        
00016 } NDFileMode_t;
00017 
00018 typedef enum {
00019     NDFileWriteOK,
00020     NDFileWriteError
00021 } NDFileWriteStatus_t;
00022 
00027  /*                               String                 asyn interface  access   Description  */
00028 #define NDPortNameSelfString    "PORT_NAME_SELF"    
00030     /* Parameters defining characteristics of the array data from the detector.
00031      * NDArraySizeX and NDArraySizeY are the actual dimensions of the array data,
00032      * including effects of the region definition and binning */
00033 #define NDArraySizeXString      "ARRAY_SIZE_X"      
00034 #define NDArraySizeYString      "ARRAY_SIZE_Y"      
00035 #define NDArraySizeZString      "ARRAY_SIZE_Z"      
00036 #define NDArraySizeString       "ARRAY_SIZE"        
00037 #define NDNDimensionsString     "ARRAY_NDIMENSIONS" 
00038 #define NDDimensionsString      "ARRAY_DIMENSIONS"  
00039 #define NDDataTypeString        "DATA_TYPE"         
00040 #define NDColorModeString       "COLOR_MODE"        
00041 #define NDUniqueIdString        "UNIQUE_ID"         
00042 #define NDTimeStampString       "TIME_STAMP"        
00043 #define NDEpicsTSSecString      "EPICS_TS_SEC"      
00044 #define NDEpicsTSNsecString     "EPICS_TS_NSEC"     
00045 #define NDBayerPatternString    "BAYER_PATTERN"     
00047     /* Statistics on number of arrays collected */
00048 #define NDArrayCounterString    "ARRAY_COUNTER"     
00050     /* File name related parameters for saving data.
00051      * Drivers are not required to implement file saving, but if they do these parameters
00052      * should be used.
00053      * The driver will normally combine NDFilePath, NDFileName, and NDFileNumber into
00054      * a file name that order using the format specification in NDFileTemplate.
00055      * For example NDFileTemplate might be "%s%s_%d.tif" */
00056 #define NDFilePathString        "FILE_PATH"         
00057 #define NDFilePathExistsString  "FILE_PATH_EXISTS"  
00058 #define NDFileNameString        "FILE_NAME"         
00059 #define NDFileNumberString      "FILE_NUMBER"       
00060 #define NDFileTemplateString    "FILE_TEMPLATE"     
00061 #define NDAutoIncrementString   "AUTO_INCREMENT"    
00062 #define NDFullFileNameString    "FULL_FILE_NAME"    
00063 #define NDFileFormatString      "FILE_FORMAT"       
00064 #define NDAutoSaveString        "AUTO_SAVE"         
00065 #define NDWriteFileString       "WRITE_FILE"        
00066 #define NDReadFileString        "READ_FILE"         
00067 #define NDFileWriteModeString   "WRITE_MODE"        
00068 #define NDFileWriteStatusString "WRITE_STATUS"      
00069 #define NDFileWriteMessageString "WRITE_MESSAGE"    
00070 #define NDFileNumCaptureString  "NUM_CAPTURE"       
00071 #define NDFileNumCapturedString "NUM_CAPTURED"      
00072 #define NDFileCaptureString     "CAPTURE"           
00073 #define NDFileDeleteDriverFileString  "DELETE_DRIVER_FILE"  
00074 #define NDFileLazyOpenString    "FILE_LAZY_OPEN"    
00077 #define NDAttributesFileString  "ND_ATTRIBUTES_FILE" 
00079     /* The detector array data */
00080 #define NDArrayDataString       "ARRAY_DATA"        
00081 #define NDArrayCallbacksString  "ARRAY_CALLBACKS"   
00083     /* NDArray Pool status */
00084 #define NDPoolMaxBuffersString      "POOL_MAX_BUFFERS"
00085 #define NDPoolAllocBuffersString    "POOL_ALLOC_BUFFERS"
00086 #define NDPoolFreeBuffersString     "POOL_FREE_BUFFERS"
00087 #define NDPoolMaxMemoryString       "POOL_MAX_MEMORY"
00088 #define NDPoolUsedMemoryString      "POOL_USED_MEMORY"
00089 
00095 class epicsShareFunc asynNDArrayDriver : public asynPortDriver {
00096 public:
00097     asynNDArrayDriver(const char *portName, int maxAddr, int numParams, int maxBuffers, size_t maxMemory,
00098                       int interfaceMask, int interruptMask,
00099                       int asynFlags, int autoConnect, int priority, int stackSize);
00100     virtual ~asynNDArrayDriver();
00101     /* These are the methods that we override from asynPortDriver */
00102     virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
00103                           size_t *nActual);
00104     virtual asynStatus readGenericPointer(asynUser *pasynUser, void *genericPointer);
00105     virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *genericPointer);
00106     virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
00107     virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
00108     virtual void report(FILE *fp, int details);
00109 
00110     /* These are the methods that are new to this class */
00111     virtual int checkPath();
00112     virtual int createFileName(int maxChars, char *fullFileName);
00113     virtual int createFileName(int maxChars, char *filePath, char *fileName);
00114     virtual int readNDAttributesFile(const char *fileName);
00115     virtual int getAttributes(NDAttributeList *pAttributeList);
00116 
00117 protected:
00118     int NDPortNameSelf;
00119     #define FIRST_NDARRAY_PARAM NDPortNameSelf
00120     int NDArraySizeX;
00121     int NDArraySizeY;
00122     int NDArraySizeZ;
00123     int NDArraySize;
00124     int NDNDimensions;
00125     int NDDimensions;
00126     int NDDataType;
00127     int NDColorMode;
00128     int NDUniqueId;
00129     int NDTimeStamp;
00130     int NDEpicsTSSec;
00131     int NDEpicsTSNsec;
00132     int NDBayerPattern;
00133     int NDArrayCounter;
00134     int NDFilePath;
00135     int NDFilePathExists;
00136     int NDFileName;
00137     int NDFileNumber;
00138     int NDFileTemplate;
00139     int NDAutoIncrement;
00140     int NDFullFileName;
00141     int NDFileFormat;
00142     int NDAutoSave;
00143     int NDWriteFile;
00144     int NDReadFile;
00145     int NDFileWriteMode;
00146     int NDFileWriteStatus;
00147     int NDFileWriteMessage;
00148     int NDFileNumCapture;
00149     int NDFileNumCaptured;
00150     int NDFileCapture;   
00151     int NDFileDeleteDriverFile;
00152     int NDFileLazyOpen;
00153     int NDAttributesFile;
00154     int NDArrayData;
00155     int NDArrayCallbacks;
00156     int NDPoolMaxBuffers;
00157     int NDPoolAllocBuffers;
00158     int NDPoolFreeBuffers;
00159     int NDPoolMaxMemory;
00160     int NDPoolUsedMemory;
00161     #define LAST_NDARRAY_PARAM NDPoolUsedMemory
00162 
00163     NDArray **pArrays;             
00164     NDArrayPool *pNDArrayPool;     
00165     class NDAttributeList *pAttributeList;  
00167 };
00168 
00169 #define NUM_NDARRAY_PARAMS ((int)(&LAST_NDARRAY_PARAM - &FIRST_NDARRAY_PARAM + 1))
00170 #endif