Class AbstractScannableNexusDevice<N extends NXobject>
- Type Parameters:
N-
- All Implemented Interfaces:
IGDAScannableNexusDevice<N>,INexusDevice<N>,IWritableNexusDevice<N>
- Direct Known Subclasses:
ConfiguredScannableNexusDevice,DefaultScannableNexusDevice
Scannable to INexusDevice.
There are two concrete subclasses:ConfiguredScannableNexusDeviceis used where aScannableNexusDeviceConfigurationis defined (normally created in spring) with the same name;DefaultScannableNexusDeviceis used otherwise
-
Field Summary
FieldsFields inherited from class gda.data.scan.nexus.device.AbstractNexusDeviceAdapter
DOUBLE_DATA_BYTE_SIZEFields inherited from interface org.eclipse.dawnsci.nexus.IWritableNexusDevice
SCALAR_DATASET_SHAPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidcreateDataNodes(NexusScanInfo scanInfo) Creates the data fields for the nexus object.protected org.eclipse.january.dataset.ILazyWriteableDatasetcreateLazyWritableDataset(String fieldName, Class<?> clazz, int rank, int[] chunking) protected NgetFieldDataNode(String fieldName) Returns theDataNodefor the given field name, ornullif there is not such field.String[]The names of the fields for this scannable.protected StringgetFieldUnits(int fieldIndex) protected NexusBaseClassprotected NexusBaseClassReturns the object provider required for writing correct NeXus files.protected intprotected Stringprotected ScannablebooleanvoidscanEnd()Called at the end of a scan.voidsetScanObject(IScanObject scanObject) Set theIScanObjectdescribing the movement of this scannable in the scan.toString()protected voidwriteControllerRecordName(NXpositioner positioner) voidwritePosition(Object position, org.eclipse.january.dataset.SliceND scanSlice) Write the given position at the given slice.writePosition(Object demandPosition, IPosition scanPosition) Methods inherited from class gda.data.scan.nexus.device.AbstractNexusDeviceAdapter
addAttributesToDataNode, configureNexusWrapper, createNexusProvider, getDevice, getFillValue, getName, registerAttributesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.dawnsci.nexus.INexusDevice
getCustomNexusModification, getNexusProviders, register
-
Field Details
-
nexusRole
-
-
Constructor Details
-
AbstractScannableNexusDevice
-
-
Method Details
-
getScannable
-
getPrimaryDataFieldIndex
protected int getPrimaryDataFieldIndex() -
getPrimaryDataFieldName
- Specified by:
getPrimaryDataFieldNamein classAbstractNexusDeviceAdapter<N extends NXobject>
-
getNexusCategory
- Throws:
NexusException
-
getFieldDataNode
Description copied from interface:IGDAScannableNexusDeviceReturns theDataNodefor the given field name, ornullif there is not such field.- Parameters:
fieldName-- Returns:
- the data node for the given field name
-
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>- Overrides:
getNexusProviderin classAbstractNexusDeviceAdapter<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
-
addFields
-
createNexusObject
- Specified by:
createNexusObjectin classAbstractNexusDeviceAdapter<N extends NXobject>- Throws:
NexusException
-
setScanObject
Set theIScanObjectdescribing the movement of this scannable in the scan.- Parameters:
scanObject-
-
getNexusBaseClass
- Throws:
NexusException
-
createDataNodes
Creates the data fields for the nexus object. These are theDataNodes - and the datasets that they contain - for each of the fields returned byScannable.getInputNames()andScannable.getExtraNames(). If the wrapped scannable is a metadata scannable these datasets will beIDatasets containing a single scalar value from the position returned byScannable.getPosition()(turned into an array by {#getPositionArray()}, otherwise they will beILazyWriteableDatasets, which will be written into during each call towritePosition(Object, IPosition)} Create the DataNodes for theScannable.- Parameters:
scanInfo-- Throws:
NexusException
-
getFieldUnits
-
createLazyWritableDataset
-
writeControllerRecordName
-
writePosition
- Throws:
Exception
-
writePosition
public void writePosition(Object position, org.eclipse.january.dataset.SliceND scanSlice) throws NexusException Write the given position at the given slice.- Parameters:
position- the position to writescanSlice- the scan slice, i.e. where to write in the datasets- Throws:
NexusException- if the position cannot be written for any reason
-
getFieldNames
Description copied from interface:IGDAScannableNexusDeviceThe names of the fields for this scannable. The resulting array may be empty, nevernull.- Returns:
- field names
-
isNexusObjectCreated
public boolean isNexusObjectCreated() -
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>- Overrides:
scanEndin classAbstractNexusDeviceAdapter<N extends NXobject>- Throws:
NexusException- if an error occurred for any reason
-
toString
-