Class NexusTemplateDevice<N extends NXobject>
- Type Parameters:
N- class of nexus object, a subinterface ofNXobject
- All Implemented Interfaces:
INexusDevice<N>
INexusDevice that creates a nexus object according to a template.
The template can be specified in one of three ways:
- by directly setting a template map using
setTemplateMap(Map); - by specifying the path to the template file by using
setTemplateFilePath(String); - or as a string by using
setTemplateString(String).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()Returns the name of this nexus device.Returns the object provider required for writing correct NeXus files.voidvoidsetTemplateFilePath(String templateFilePath) voidsetTemplateMap(Map<String, Object> templateMap) Sets the template as a map.voidsetTemplateString(String templateString) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.dawnsci.nexus.INexusDevice
getCustomNexusModification, getNexusProviders, register
-
Constructor Details
-
NexusTemplateDevice
public NexusTemplateDevice()
-
-
Method Details
-
getName
Description copied from interface:INexusDeviceReturns the name of this nexus device.- Specified by:
getNamein interfaceINexusDevice<N extends NXobject>- Returns:
- name of nexus device
-
setName
-
setTemplateMap
Sets the template as a map. This can be used for very simple template and can be configured in spring, e.g. <bean id="templateDevice" class="org.eclipse.dawnsci.nexus.template.device">- Parameters:
templateMap-
-
setTemplateFilePath
-
setTemplateString
-
getNexusProvider
Description copied from interface:INexusDeviceReturns the object provider required for writing correct NeXus files.In this method you should prepare the
LazyDatasets the device will fill during the scan. You can also write out static device metadata, which will not change during the scan.Use the methods on
NexusNodeFactoryto create a NeXus object which matches the device e.g. aNXdetector.final NXdetector detector = NexusNodeFactory.createNXdetector();On the detector object you can create
In this method you can also write static metadata such as the detector exposure e.g.LazyDatasets and keep references which you can later use during the scan to write data. e.g.imageData = detector.initializeLazyDataset(NXdetector.NX_DATA, info.getRank() + 2, Double.class);You should also set chunking on theLazyDatasets you create e.g.imageData.setChunking(info.createChunk(detectorXSize, detectorYSize));.detector.setField("exposure_time", model.getExposure());. Or static datasets such as the image axis datadetector.setDataset("image_x_axis", DatasetFactory.createLinearSpace(DoubleDataset.class, minX, maxX, xPoints));For fields that are defined in the NXDL base class definition for the returned nexus object, a setXXX or setXXXScalar method may be used as appropriate, e.g.detector.setLocalName(DatasetFactory.createFromObject("my detector"));ordetector.setLocalNameScalar("my detector");If this device is a 'metadata scannable', then the device should write its data at this point directly into the returned nexus object. This can be done with the
NXobject.setField(String, Object)method, or thesetXXXScalarmethods for fields defined in the appropriate NXDL base class definition.The default implementation of this method throws
UnsupportedOperationException. One of either this method orINexusDevice.getNexusProviders(NexusScanInfo)must be overridden to create and return the nexus object(s) for thisINexusDevice.- Specified by:
getNexusProviderin interfaceINexusDevice<N extends NXobject>- Parameters:
info- information about the scan which can be useful when creating datasets e.g.info.getRank()- Returns:
- The
NXobjectcreated using thenodeFactoryto represent this device - Throws:
NexusException- if the nexus object could not be created for any reason
-