areaDetector
3-13
EPICS areaDetector framework
|
Writes NDArrays in the HDF5 file format; an XML file can control the structure of the HDF5 file. More...
#include <NDFileHDF5.h>
Public Member Functions | |
NDFileHDF5 (const char *portName, int queueSize, int blockingCallbacks, const char *NDArrayPort, int NDArrayAddr, int priority, int stackSize) | |
Constructor for NDFileHDF5; parameters are identical to those for NDPluginFile::NDPluginFile, and are passed directly to that base class constructor. More... | |
virtual asynStatus | openFile (const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray) |
Opens a HDF5 file. More... | |
virtual asynStatus | readFile (NDArray **pArray) |
Read NDArray data from a HDF5 file; NOTE: not implemented yet. More... | |
virtual asynStatus | writeFile (NDArray *pArray) |
Writes NDArray data to a HDF5 file. More... | |
virtual asynStatus | closeFile () |
Closes the HDF5 file opened with NDFileHDF5::openFile. More... | |
virtual void | report (FILE *fp, int details) |
Report status of the driver. More... | |
virtual asynStatus | writeInt32 (asynUser *pasynUser, epicsInt32 value) |
Perform any actions required when an int32 parameter is updated. More... | |
virtual asynStatus | writeOctet (asynUser *pasynUser, const char *value, size_t nChars, size_t *nActual) |
Called when asyn clients call pasynOctet->write(). More... | |
void | flushTask () |
Thread function for flush now command Waits for flush events, and upon receiving one, flushes all datasets and attributes, ensuring that the unique ID attribute is the last attribute flushed. More... | |
asynStatus | startSWMR () |
asynStatus | flushCallback () |
asynStatus | createXMLFileLayout () |
Create the groups and datasets in the HDF5 file. More... | |
asynStatus | storeOnOpenAttributes () |
Check through attributes and store any that have been marked as onOpen. More... | |
asynStatus | storeOnCloseAttributes () |
Check through attributes and store any that have been marked as onClose. More... | |
asynStatus | storeOnOpenCloseAttribute (hdf5::Element *element, bool open) |
Check attribute and store if marked as onOpen or onClose when opening or closing. More... | |
asynStatus | createTree (hdf5::Group *root, hid_t h5handle) |
Create the root group and recursively create all subgroups and datasets in the HDF5 file. More... | |
asynStatus | createHardLinks (hdf5::Group *root) |
Create the hardlinks in the HDF5 file. More... | |
hid_t | writeHdfConstDataset (hid_t h5_handle, hdf5::Dataset *dset) |
hid_t | writeH5dsetStr (hid_t element, const std::string &name, const std::string &str_value) const |
Write a string constant dataset. More... | |
hid_t | writeH5dsetInt32 (hid_t element, const std::string &name, const std::string &str_value) const |
hid_t | writeH5dsetFloat64 (hid_t element, const std::string &name, const std::string &str_value) const |
void | writeHdfAttributes (hid_t h5_handle, hdf5::Element *element) |
Check this element for any attached attributes and write them out. More... | |
hid_t | createDataset (hid_t group, hdf5::Dataset *dset) |
Create the dataset and write it out. More... | |
void | writeH5attrStr (hid_t element, const std::string &attr_name, const std::string &str_attr_value) const |
Write a string constant attribute. More... | |
void | writeH5attrInt32 (hid_t element, const std::string &attr_name, const std::string &str_attr_value) const |
Write an int (or array of ints) constant attribute. More... | |
void | writeH5attrFloat64 (hid_t element, const std::string &attr_name, const std::string &str_attr_value) const |
Write a float (or array of floats) constant attribute. More... | |
hid_t | fromHdfToHidDatatype (hdf5::DataType_t in) const |
Utility method to convert from hdf5 to hid datatype. More... | |
hid_t | createDatasetDetector (hid_t group, hdf5::Dataset *dset) |
Create a dataset in the HDF5 file with the details defined in the dset argument. More... | |
int | fileExists (char *filename) |
Check if the specified filename/path exists. More... | |
int | verifyLayoutXMLFile () |
Verify the XML layout file is valid. More... | |
hsize_t | getDim (int index) |
Return the requested dimension size. More... | |
hsize_t | getMaxDim (int index) |
Return the requested max dimension size. More... | |
hsize_t | getChunkDim (int index) |
Return the requested chunk dimension size. More... | |
hsize_t | getOffset (int index) |
Return the requested offset size. More... | |
hsize_t | getVirtualDim (int index) |
Return the requested virtual dimension size. More... | |
Public Member Functions inherited from NDPluginFile | |
NDPluginFile (const char *portName, int queueSize, int blockingCallbacks, const char *NDArrayPort, int NDArrayAddr, int maxAddr, int maxBuffers, size_t maxMemory, int interfaceMask, int interruptMask, int asynFlags, int autoConnect, int priority, int stackSize, int maxThreads, bool compressionAware=false) | |
Constructor for NDPluginFile; all parameters are simply passed to NDPluginDriver::NDPluginDriver. More... | |
virtual void | processCallbacks (NDArray *pArray) |
Callback function that is called by the NDArray driver with new NDArray data. More... | |
virtual asynStatus | writeNDArray (asynUser *pasynUser, void *genericPointer) |
Public Member Functions inherited from NDPluginDriver | |
NDPluginDriver (const char *portName, int queueSize, int blockingCallbacks, const char *NDArrayPort, int NDArrayAddr, int maxAddr, int maxBuffers, size_t maxMemory, int interfaceMask, int interruptMask, int asynFlags, int autoConnect, int priority, int stackSize, int maxThreads, bool compressionAware=false) | |
Constructor for NDPluginDriver; most parameters are simply passed to asynNDArrayDriver::asynNDArrayDriver. More... | |
~NDPluginDriver () | |
virtual asynStatus | writeFloat64 (asynUser *pasynUser, epicsFloat64 value) |
Called when asyn clients call pasynFloat64->write(). More... | |
virtual asynStatus | readInt32Array (asynUser *pasynUser, epicsInt32 *value, size_t nElements, size_t *nIn) |
Called when asyn clients call pasynInt32Array->read(). More... | |
virtual void | driverCallback (asynUser *pasynUser, void *genericPointer) |
Method that is called from the driver with a new NDArray. More... | |
virtual void | run (void) |
Starts the thread that receives NDArrays from the epicsMessageQueue. More... | |
virtual asynStatus | start (void) |
Starts the plugin threads. More... | |
void | sortingTask () |
Method runs as a separate thread, periodically doing NDArray callbacks to downstream plugins. More... | |
Public Member Functions inherited from asynNDArrayDriver | |
asynNDArrayDriver (const char *portName, int maxAddr, int maxBuffers, size_t maxMemory, int interfaceMask, int interruptMask, int asynFlags, int autoConnect, int priority, int stackSize) | |
This is the constructor for the asynNDArrayDriver class. More... | |
virtual | ~asynNDArrayDriver () |
virtual asynStatus | readGenericPointer (asynUser *pasynUser, void *genericPointer) |
This method copies an NDArray object from the asynNDArrayDriver to an NDArray pointer passed in by the caller. More... | |
virtual asynStatus | writeGenericPointer (asynUser *pasynUser, void *genericPointer) |
This method currently does nothing, but it should be implemented in this base class. More... | |
virtual asynStatus | setIntegerParam (int index, int value) |
Sets the value for an integer in the parameter library. More... | |
virtual asynStatus | setIntegerParam (int list, int index, int value) |
Sets the value for an integer in the parameter library. More... | |
virtual asynStatus | createFilePath (const char *path, int pathDepth) |
Function to create a directory path for a file. More... | |
virtual asynStatus | checkPath () |
Checks whether the directory specified NDFilePath parameter exists. More... | |
virtual bool | checkPath (std::string &filePath) |
Checks whether the directory specified exists. More... | |
virtual asynStatus | createFileName (int maxChars, char *fullFileName) |
Build a file name from component parts. More... | |
virtual asynStatus | createFileName (int maxChars, char *filePath, char *fileName) |
Build a file name from component parts. More... | |
virtual asynStatus | readNDAttributesFile () |
Create this driver's NDAttributeList (pAttributeList) by reading an XML file This clears any existing attributes from this drivers' NDAttributeList and then creates a new list based on the XML file. More... | |
virtual asynStatus | getAttributes (NDAttributeList *pAttributeList) |
Get the current values of attributes from this driver and appends them to an output attribute list. More... | |
virtual void | updateTimeStamps (NDArray *pArray) |
asynStatus | incrementQueuedArrayCount () |
asynStatus | decrementQueuedArrayCount () |
int | getQueuedArrayCount () |
void | updateQueuedArrayCount () |
Public Attributes | |
std::map< std::string, NDFileHDF5Dataset * > | detDataMap |
std::map< std::string, hid_t > | constDsetMap |
std::string | defDsetName |
std::string | ndDsetName |
std::map< std::string, hdf5::Element * > | onOpenMap |
std::map< std::string, hdf5::Element * > | onCloseMap |
Codec_t | codec |
Public Attributes inherited from NDPluginFile | |
int | supportsMultipleArrays |
Derived classes must set this flag to 0/1 if they cannot/can write multiple NDArrays to a single file. More... | |
Public Attributes inherited from asynNDArrayDriver | |
class NDArrayPool * | pNDArrayPool |
An NDArrayPool pointer that is initialized to pNDArrayPoolPvt_ in the constructor. More... | |
Static Public Attributes | |
static const char * | str_NDFileHDF5_chunkSize [MAX_CHUNK_DIMS] |
static const char * | str_NDFileHDF5_extraDimSize [MAXEXTRADIMS] |
static const char * | str_NDFileHDF5_extraDimName [MAXEXTRADIMS] |
static const char * | str_NDFileHDF5_extraDimChunk [MAXEXTRADIMS] |
static const char * | str_NDFileHDF5_posName [MAXEXTRADIMS] |
static const char * | str_NDFileHDF5_posIndex [MAXEXTRADIMS] |
Protected Member Functions | |
asynStatus | configureDims (NDArray *pArray) |
Configure the HDF5 dimension definitions based on NDArray dimensions. More... | |
void | calcNumFrames () |
Calculate the total number of frames that the current configured dimensions can contain. More... | |
void | setMultiFrameFile (bool multi) |
Set the multi frame parameter. More... | |
Protected Member Functions inherited from NDPluginDriver | |
virtual void | beginProcessCallbacks (NDArray *pArray) |
Method that is normally called at the beginning of the processCallbacks method in derived classes. More... | |
virtual asynStatus | endProcessCallbacks (NDArray *pArray, bool copyArray=false, bool readAttributes=true) |
Method that is normally called at the end of the processCallbacks()) method in derived classes. More... | |
virtual asynStatus | connectToArrayPort (void) |
Connect this plugin to an NDArray port driver; disconnect from any existing driver first, register for callbacks if enabled. More... | |
virtual asynStatus | setArrayInterrupt (int connect) |
Register or unregister to receive asynGenericPointer (NDArray) callbacks from the driver. More... | |
bool | throttled (NDArray *pArray) |
Writes NDArrays in the HDF5 file format; an XML file can control the structure of the HDF5 file.
NDFileHDF5::NDFileHDF5 | ( | const char * | portName, |
int | queueSize, | ||
int | blockingCallbacks, | ||
const char * | NDArrayPort, | ||
int | NDArrayAddr, | ||
int | priority, | ||
int | stackSize | ||
) |
Constructor for NDFileHDF5; parameters are identical to those for NDPluginFile::NDPluginFile, and are passed directly to that base class constructor.
After calling the base class constructor this method sets NDPluginFile::supportsMultipleArrays=1.
|
protected |
Calculate the total number of frames that the current configured dimensions can contain.
Sets the NDFileNumCapture parameter to the total value so file saving will complete at this number. This is called only from writeInt32 so the lock is already taken.
|
virtual |
Closes the HDF5 file opened with NDFileHDF5::openFile.
Implements NDPluginFile.
|
protected |
hid_t NDFileHDF5::createDataset | ( | hid_t | group, |
hdf5::Dataset * | dset | ||
) |
Create the dataset and write it out.
Only detector and constant datasets are created in the file out at this time.
NDAttribute datasets are created elsewhere in createAttributeDatasets()
hid_t NDFileHDF5::createDatasetDetector | ( | hid_t | group, |
hdf5::Dataset * | dset | ||
) |
Create a dataset in the HDF5 file with the details defined in the dset argument.
Return the hid_t handle to the new dataset on success; -1 on error. Errors: fail to set chunk size or failure to create the dataset in the file.
asynStatus NDFileHDF5::createHardLinks | ( | hdf5::Group * | root | ) |
Create the hardlinks in the HDF5 file.
asynStatus NDFileHDF5::createTree | ( | hdf5::Group * | root, |
hid_t | h5handle | ||
) |
Create the root group and recursively create all subgroups and datasets in the HDF5 file.
asynStatus NDFileHDF5::createXMLFileLayout | ( | ) |
Create the groups and datasets in the HDF5 file.
int NDFileHDF5::fileExists | ( | char * | filename | ) |
Check if the specified filename/path exists.
asynStatus NDFileHDF5::flushCallback | ( | ) |
void NDFileHDF5::flushTask | ( | ) |
Thread function for flush now command Waits for flush events, and upon receiving one, flushes all datasets and attributes, ensuring that the unique ID attribute is the last attribute flushed.
hid_t NDFileHDF5::fromHdfToHidDatatype | ( | hdf5::DataType_t | in | ) | const |
Utility method to convert from hdf5 to hid datatype.
hsize_t NDFileHDF5::getChunkDim | ( | int | index | ) |
Return the requested chunk dimension size.
[in] | index | of dimension |
hsize_t NDFileHDF5::getDim | ( | int | index | ) |
Return the requested dimension size.
[in] | index | of dimension |
hsize_t NDFileHDF5::getMaxDim | ( | int | index | ) |
Return the requested max dimension size.
[in] | index | of dimension |
hsize_t NDFileHDF5::getOffset | ( | int | index | ) |
Return the requested offset size.
[in] | index | of offset |
hsize_t NDFileHDF5::getVirtualDim | ( | int | index | ) |
Return the requested virtual dimension size.
[in] | index | of dimension |
|
virtual |
Opens a HDF5 file.
In write mode if NDFileModeMultiple is set then the first dataspace dimension is set to H5S_UNLIMITED to allow multiple arrays to be written to the same file. NOTE: Does not currently support NDFileModeRead or NDFileModeAppend.
[in] | fileName | Absolute path name of the file to open. |
[in] | openMode | Bit mask with one of the access mode bits NDFileModeRead, NDFileModeWrite, NDFileModeAppend. May also have the bit NDFileModeMultiple set if the file is to be opened to write or read multiple NDArrays into a single file. |
[in] | pArray | Pointer to an NDArray; this array is used to determine the header information and data structure for the file. |
Implements NDPluginFile.
|
virtual |
Read NDArray data from a HDF5 file; NOTE: not implemented yet.
[in] | pArray | Pointer to the address of an NDArray to read the data into. |
Implements NDPluginFile.
|
virtual |
Report status of the driver.
This method calls the report function in the asynPortDriver base class. It then calls the NDArrayPool::report() method if details >5.
[in] | fp | File pointed passed by caller where the output is written to. |
[in] | details | If >5 then NDArrayPool::report and NDAttributeList::report are both called. |
Reimplemented from asynNDArrayDriver.
|
protected |
Set the multi frame parameter.
[in] | multi | boolean to set the writer frame mode |
asynStatus NDFileHDF5::startSWMR | ( | ) |
asynStatus NDFileHDF5::storeOnCloseAttributes | ( | ) |
Check through attributes and store any that have been marked as onClose.
asynStatus NDFileHDF5::storeOnOpenAttributes | ( | ) |
Check through attributes and store any that have been marked as onOpen.
asynStatus NDFileHDF5::storeOnOpenCloseAttribute | ( | hdf5::Element * | element, |
bool | open | ||
) |
Check attribute and store if marked as onOpen or onClose when opening or closing.
int NDFileHDF5::verifyLayoutXMLFile | ( | ) |
Verify the XML layout file is valid.
This method checks the file exists and can be opened. If these checks pass then the file is opened and the XML is also parsed and verified. Any error messages are reported and the status set accordingly. This must be called with the lock already taken.
|
virtual |
Writes NDArray data to a HDF5 file.
[in] | pArray | Pointer to an NDArray to write to the file. This function can be called multiple times between the call to openFile and closeFile if NDFileModeMultiple was set in openMode in the call to NDFileHDF5::openFile. |
Implements NDPluginFile.
void NDFileHDF5::writeH5attrFloat64 | ( | hid_t | element, |
const std::string & | attr_name, | ||
const std::string & | str_attr_value | ||
) | const |
Write a float (or array of floats) constant attribute.
void NDFileHDF5::writeH5attrInt32 | ( | hid_t | element, |
const std::string & | attr_name, | ||
const std::string & | str_attr_value | ||
) | const |
Write an int (or array of ints) constant attribute.
void NDFileHDF5::writeH5attrStr | ( | hid_t | element, |
const std::string & | attr_name, | ||
const std::string & | str_attr_value | ||
) | const |
Write a string constant attribute.
hid_t NDFileHDF5::writeH5dsetFloat64 | ( | hid_t | element, |
const std::string & | name, | ||
const std::string & | str_value | ||
) | const |
hid_t NDFileHDF5::writeH5dsetInt32 | ( | hid_t | element, |
const std::string & | name, | ||
const std::string & | str_value | ||
) | const |
hid_t NDFileHDF5::writeH5dsetStr | ( | hid_t | element, |
const std::string & | name, | ||
const std::string & | str_value | ||
) | const |
Write a string constant dataset.
void NDFileHDF5::writeHdfAttributes | ( | hid_t | h5_handle, |
hdf5::Element * | element | ||
) |
Check this element for any attached attributes and write them out.
Supported types are 'string', 'int' and 'float'.
The types 'int' and 'float' can contain 1D arrays, where each element is separated by a ','
hid_t NDFileHDF5::writeHdfConstDataset | ( | hid_t | h5_handle, |
hdf5::Dataset * | dset | ||
) |
|
virtual |
Perform any actions required when an int32 parameter is updated.
Reimplemented from NDPluginFile.
|
virtual |
Called when asyn clients call pasynOctet->write().
This function performs actions for some parameters, including AttributesFile. For all parameters it sets the value in the parameter library and calls any registered callbacks..
[in] | pasynUser | pasynUser structure that encodes the reason and address. |
[in] | value | Address of the string to write. |
[in] | nChars | Number of characters to write. |
[out] | nActual | Number of characters actually written. |
Reimplemented from NDPluginDriver.
Codec_t NDFileHDF5::codec |
std::map<std::string, hid_t> NDFileHDF5::constDsetMap |
std::string NDFileHDF5::defDsetName |
std::map<std::string, NDFileHDF5Dataset *> NDFileHDF5::detDataMap |
std::string NDFileHDF5::ndDsetName |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
std::map<std::string, hdf5::Element *> NDFileHDF5::onCloseMap |
std::map<std::string, hdf5::Element *> NDFileHDF5::onOpenMap |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |