NDPluginFile is a base class from which actual file plugins are derived. There are currently file plugins for JPEG, TIFF, netCDF, Nexus, HDF5, and GraphicsMagick. The GraphicsMagick plugin can write a large number of formats, including JPEG, TIFF, PNG, PDF and many others.
NDPluginFile inherits from NDPluginDriver. The NDPluginFile class documentation describes this class in detail. This class is designed to simplify the task of supporting a new file format. A derived class to support a new file format will typically need to implement only the pure virtual functions openFile(), readFile(), writeFile(), and closeFile(). Note that none of the current file plugins actually support the readFile() function yet, but this is planned for future releases.
The NDArray callback data can be written to disk in 1 of 3 modes:
The CreateDirectory record controls whether directories are created if they don't exist. If it is zero (default), no directories are created. If it is negative, then the absolute value is the maximum of directories that will be created (i.e. -1 will create a maximum of one directory to complete the path, -2 will create a maximum of 2 directories). If it is positive, then at least that many directories in the path must exist (i.e. a value of 1 will create all directories below the root directory and 2 will not create a directory in the root directory).
If value of the LazyOpen record is "No" (0) then at least one array with the same datatype, array size, and attributes must have been collected by the driver (and/or plugins) from which the file saving plugin is getting its data before capture or stream mode file saving is started. This is required so that the openFile() function can know the dimensions and datatype of the arrays. If LazyOpen is "Yes" and the mode is Stream then the file open if deferred until the first array callback after streaming is started. This will slow down the saving of the first file.
NDPluginFile supports all of the file saving parameters defined in asynNDArrayDriver, e.g. NDFilePath, NDFileName, etc. Thus, the same interface that is used for saving files directly in a driver is used for this plugin.
The base class will delete the "original" file that the driver created for that array if the following are all true:
The file saving plugins normally determine the name of the file from the FileName and FileNumber records. However, it is possible to have these values come instead from attributes in the array passed to the callback. The following 3 special attributes are used:
Having the file information come from the array allows the driver to control which plugin saves a particular array. For example, there may be two file writing plugins active; the first saves the flat field files for a tomography experiment, and the second saves the normal projections. These plugins each stream data to a separate file. The driver knows which files are flat fields and which are normal projections, and adds the appropriate attributes to control which plugin saves each array. This would not be possible using a single plugin and EPICS PVs to switch the file, because of the problem of frames being buffered in the plugin queue.
Normally files in Stream and Capture mode are automatically closed when the requested number of frames have been collected, or when the Capture record is set back to 0. It is also possible to use an NDArray attribute to close the file. If the NDArray contains an attribute named FilePluginClose and the attribute value is non-zero then the current file will be closed.
NDFileNull inherits from NDPluginFile. This is a dummy file writer, which does not actually write anything. Its main purpose is to delete original driver files (DeleteDriverFile record) without writing the data to disk. For example, if the Pilatus is being used simply for alignment or testing one might want to display the images but then immediately delete the files that the Pilatus had created. This plugin allows one to do this, since it always reports success in "writing" the file, so the NDPluginFile base class will deleted the driver file if all the conditions outlined above are met.
The NDFileNull class documentation describes this class in detail.
The NDFileNull plugin is created with the NDFileNullConfigure command, either from C/C++ or from the EPICS IOC shell.
NDFileNullConfigure (const char *portName, int queueSize, int blockingCallbacks, const char *NDArrayPort, int NDArrayAddr, size_t maxMemory, int priority, int stackSize)
Performance measurements were made on the Linux and Windows systems shown in the following table.
Model | Operating system | CPU | RAM | Disk |
---|---|---|---|---|
Dell Precision T7500 | Windows 7 64-bit | Two quad-core Xeon X5647, 2.93 GHz (8 cores total) | 96 GB | Two 500 GB 15K RPM SAS disks RAID 0 |
Penguin Relion 1751 Server | Linux, Fedora Core 14 64-bit | Two quad-core Xeon E5630, 2.53 GHz (8 cores total) | 12 GB | Three 300 GB 15K RPM SAS disks No RAID |
The tests were performed under the following conditions:
File plugin | Mode | Windows (frames/s = MB/s) | Linux (frames/s = MB/s) |
---|---|---|---|
JPEG | Stream | 79.1 | 68.4 |
TIFF | Stream | 259.9 | 186.4 |
Magick, TIFF | Stream | 55.7 | 39.0 |
netCDF | Stream | 204.3 | 185.0 |
netCDF | Single | 133.7 | 179.1 |
Nexus | Stream | 192.3 | 193.4 |
Nexus | Single | 106.3 | 145.6 |
HDF5 | Stream | 1113.5 | 192.0 |
HDF5 | Single | 139.7 | 108.6 |