areaDetector 1-8
/home/epics/devel/areaDetector/ADApp/pluginSrc/NDFileNexus.h
Go to the documentation of this file.
00001 /*
00002  * NDFileTIFF.h
00003  * Writes NDArrays to NeXus (HDF) files.
00004  * John Hammonds
00005  * April 17, 2009
00006  */
00007 
00008 #ifndef DRV_NDFileNexus_H
00009 #define DRV_NDFileNexus_H
00010 
00011 #include "NDPluginFile.h"
00012 #include <napi.h>
00013 #include <tinyxml.h>
00014 
00015 /* This version number is an attribute in the Nexus file to allow readers
00016  * to handle changes in the file contents */
00017 #define NDNexusFileVersion 1.0
00018 
00019 
00020 #define NDFileNexusTemplatePathString "TEMPLATE_FILE_PATH"
00021 #define NDFileNexusTemplateFileString "TEMPLATE_FILE_NAME"
00022 #define NDFileNexusTemplateValidString "TEMPLATE_FILE_VALID"
00023 #define NUM_ND_FILE_NEXUS_PARAMS (sizeof(NDFileNexusParamString)/sizeof(NDFileNexusParamString[0]))
00024 
00031 class NDFileNexus : public NDPluginFile {
00032 public:
00033     NDFileNexus(const char *portName, int queueSize, int blockingCallbacks,
00034                  const char *NDArrayPort, int NDArrayAddr,
00035                  int priority, int stackSize);
00036 
00037     /* The methods that this class implements */
00038     virtual asynStatus openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray);
00039     virtual asynStatus readFile(NDArray **pArray);
00040     virtual asynStatus writeFile(NDArray *pArray);
00041     virtual asynStatus closeFile();
00042     asynStatus writeOctet(asynUser *pasynUser, const char *value,
00043                                     size_t nChars, size_t *nActual);
00044 protected:
00045     int NDFileNexusTemplatePath;
00046     #define FIRST_NDFILE_NEXUS_PARAM NDFileNexusTemplatePath
00047     int NDFileNexusTemplateFile;
00048     int NDFileNexusTemplateValid;
00049     #define LAST_NDFILE_NEXUS_PARAM NDFileNexusTemplateValid
00050 
00051 private:
00052     NXhandle nxFileHandle;
00053     int bitsPerSample;
00054     NDColorMode_t colorMode;
00055     TiXmlDocument configDoc;
00056     TiXmlElement *rootNode;
00057     NDAttributeList *pFileAttributes;
00058     NXname dataPath;
00059     NXname dataName;
00060     int imageNumber;
00061 
00062     int processNode(TiXmlNode *curNode, NDArray *);
00063     int processStreamData(NDArray *);
00064     void getAttrTypeNSize(NDAttribute *pAttr, int *retType, int *retSize);
00065     void iterateNodes(TiXmlNode *curNode, NDArray *pArray);
00066     void findConstText(TiXmlNode *curNode, char *outtext);
00067     void * allocConstValue(int dataType, int length);
00068     void constTextToDataType(char *inText, int dataType, void *pValue);
00069     int typeStringToVal( const char * typeStr );
00070     void loadTemplateFile();
00071 
00072 };
00073 #define NUM_NDFILE_NEXUS_PARAMS (&LAST_NDFILE_NEXUS_PARAM - &FIRST_NDFILE_NEXUS_PARAM + 1)
00074 
00075 #endif
00076