Class AbstractNexusDeviceAdapter<N extends NXobject>
- Type Parameters:
N-
- All Implemented Interfaces:
IGDAScannableNexusDevice<N>,INexusDevice<N>,IWritableNexusDevice<N>
- Direct Known Subclasses:
AbstractDetectorNexusDeviceAdapter,AbstractScannableNexusDevice
Scannables (including Detectors)
to INexusDevice, so that they can be used by the NexusScanFileService.-
Field Summary
FieldsFields inherited from interface org.eclipse.dawnsci.nexus.IWritableNexusDevice
SCALAR_DATASET_SHAPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAttributesToDataNode(String inputFieldName, int numDecimals, String unitsStr, DataNode dataNode) protected voidconfigureNexusWrapper(NexusObjectWrapper<N> nexusWrapper, NexusScanInfo info) Configure the nexus wrapper, an object that contains the nexus object and contains additional information describing how the nexus object should be added to the nexus tree - in particular toNXdatagroups.protected abstract Nprotected NexusObjectProvider<N> createNexusProvider(N nexusObject, NexusScanInfo info) protected Scannableprotected static ObjectgetFillValue(Class<?> clazz) getName()Returns the name of this nexus device.Returns the object provider required for writing correct NeXus files.protected abstract Stringprotected voidregisterAttributes(NXobject nexusObject) Add the attributes for the given attribute container into the given nexus object.voidscanEnd()Called at the end of a scan.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gda.data.scan.datawriter.IGDAScannableNexusDevice
getFieldDataNode, getFieldNamesMethods inherited from interface org.eclipse.dawnsci.nexus.INexusDevice
getCustomNexusModification, getNexusProviders, registerMethods inherited from interface org.eclipse.dawnsci.nexus.IWritableNexusDevice
writePosition
-
Field Details
-
DOUBLE_DATA_BYTE_SIZE
protected static final int DOUBLE_DATA_BYTE_SIZE- See Also:
-
-
Constructor Details
-
AbstractNexusDeviceAdapter
-
-
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
-
getDevice
-
registerAttributes
Add the attributes for the given attribute container into the given nexus object. TODO: consider removing this and providing an easier mechanism. see DAQ-3186.- Throws:
NexusException- if the attributes could not be added for any reason
-
addAttributesToDataNode
-
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
-
createNexusObject
- Throws:
NexusException
-
createNexusProvider
protected NexusObjectProvider<N> createNexusProvider(N nexusObject, NexusScanInfo info) throws NexusException - Throws:
NexusException
-
configureNexusWrapper
protected void configureNexusWrapper(NexusObjectWrapper<N> nexusWrapper, NexusScanInfo info) throws NexusException Configure the nexus wrapper, an object that contains the nexus object and contains additional information describing how the nexus object should be added to the nexus tree - in particular toNXdatagroups.- Parameters:
nexusWrapper-info-- Throws:
NexusException
-
getPrimaryDataFieldName
-
getFillValue
-
scanEnd
Description copied from interface:IWritableNexusDeviceCalled at the end of a scan. The implementation should use this to clear up any state, such as closing any files and releasing any cached datasets so that this device can be used in subsequent scans.- Specified by:
scanEndin interfaceIWritableNexusDevice<N extends NXobject>- Throws:
NexusException- if an error occurred for any reason
-