Class ScannableNexusWrapper<N extends NXobject>
- All Implemented Interfaces:
INexusDevice<N>,IActivatable,IBoundable<Object>,ILevel,INameable,IScanAttributeContainer,IScannable<Object>,ITimeoutable,ITolerable<Object>,IPositionListenable
- Direct Known Subclasses:
JythonScannableNexusWrapper
Scannable and adapts to both IScannable and INexusDevice.
This allows a scannable to be used in a new scanning (a.k.a. solstice scanning) scan and write to the nexus file.
The nexus writing delegated to an instanceof AbstractScannableNexusDevice.
Note that an instance of this class is used only in new scanning.-
Field Summary
Fields inherited from class org.eclipse.scanning.api.AbstractScannable
delegate -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Call to terminate a movement before it is complete, for example when ScannablePositioner#abort is called due to an exception with another IScannable's movementvoidaddPositionListener(IPositionListener listener) Use to be notified as levels / positions are reached.booleanReturns an object that performs a custom modification to anNXentry.intgetLevel()get the operation level of this scannable.The upper limit in the same unit as the position.The lower limit in the same unit as the position.getName()Name of the scannableReturns the object provider required for writing correct NeXus files.Returns the object providers required for writing correct NeXus files.String[]Returns a list of the permitted values for this object, ornullif the values are not restricted to a set of permitted valuesThe position is the value which should be: 1.getUnit()The unit is the unit in which the setPosition and getPosition values are in.voidremovePositionListener(IPositionListener listener) Use to be notified as levels / positions are reached.voidvoidsetLevel(int level) Used for ordering the operations of Scannables during scansvoidSet the name of the device.setPosition(Object value) Moves to the position required, blocking until it is complete.setPosition(Object value, IPosition scanPosition) Moves to the position required, blocking until it is complete.voidsetScannable(Scannable scannable) Used from spring to connect the wrapper to a particular GDA8 scannable.toString()voidMethods inherited from class org.eclipse.scanning.api.AbstractScannable
getDeviceInformation, getModel, getScanAttribute, getScanAttributeNames, getTolerance, isActivated, register, setActivated, setMaximum, setMinimum, setModel, setPublisher, setScanAttribute, setToleranceMethods inherited from class org.eclipse.scanning.api.AbstractNameableTimeoutable
equals, getTimeout, hashCode, setTimeoutMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.dawnsci.nexus.INexusDevice
registerMethods inherited from interface org.eclipse.scanning.api.scan.event.IPositionListenable
getPositioner, setPositionerMethods inherited from interface org.eclipse.scanning.api.ITimeoutable
getTimeout, setTimeout
-
Constructor Details
-
ScannableNexusWrapper
public ScannableNexusWrapper()Used from spring
-
-
Method Details
-
setScannable
Used from spring to connect the wrapper to a particular GDA8 scannable.- Parameters:
scannable- the GDA8 scannable to wrap- Throws:
IllegalStateException- if the scannable is already set
-
getScannable
-
canReadPosition
public boolean canReadPosition() -
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
-
getNexusProviders
Description copied from interface:INexusDeviceReturns the object providers required for writing correct NeXus files. Implement this method if your device needs to create multiple nexus objects. These can implementNexusObjectProviderThe default implementation of this method calls
INexusDevice.getNexusProvider(NexusScanInfo)and returns aListwhose sole element is theNexusObjectProviderreturned from that method. One of either this method orINexusDevice.getNexusProviders(NexusScanInfo)must be overridden to create and return the nexus object(s) for thisINexusDevice.- Specified by:
getNexusProvidersin 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
-
getCustomNexusModification
Description copied from interface:INexusDeviceReturns an object that performs a custom modification to anNXentry.NOTE: Use this method with caution as it can be used to break the central design concept of the new Nexus writing framework, namely that the nexus framework itself knows where to put the nexus groups for devices and build any required
NXdatagroups. It is currently used by the new Nexus framework to partially support legacy GDA8 spring configurations, in particular the 'locationmap'.The nexus framework will call this method after
, so this method create links to nodes created in that method if appropriate.invalid reference
#createNexusObject(NexusNodeFactory, NexusScanInfo)The easiest way to implement this method is to make this object itself also implement
CustomNexusEntryModification. This method can then be overridden to simply returnthis.- Specified by:
getCustomNexusModificationin interfaceINexusDevice<N extends NXobject>- Returns:
- a
CustomNexusEntryModificationthat makes a custom modification, ornullif this device should not make custom modifications
-
setLevel
public void setLevel(int level) Description copied from interface:ILevelUsed for ordering the operations of Scannables during scans- Specified by:
setLevelin interfaceILevel- Overrides:
setLevelin classAbstractScannable<Object>- Parameters:
level-
-
getLevel
public int getLevel()Description copied from interface:ILevelget the operation level of this scannable.- Specified by:
getLevelin interfaceILevel- Overrides:
getLevelin classAbstractScannable<Object>- Returns:
- int - the level
-
getName
Description copied from interface:INameableName of the scannable- Specified by:
getNamein interfaceINameable- Specified by:
getNamein interfaceINexusDevice<N extends NXobject>- Overrides:
getNamein classAbstractNameable- Returns:
-
setName
Description copied from interface:INameableSet the name of the device.- Specified by:
setNamein interfaceINameable- Overrides:
setNamein classAbstractNameable- Parameters:
name-
-
getPosition
Description copied from interface:IBoundableThe position is the value which should be: 1. Greater than or equal to the lower 2. Less than or equal to the upper. 3. One of the permitted values, if they are not null.- Specified by:
getPositionin interfaceIBoundable<N extends NXobject>- Returns:
- Throws:
ScanningException- if the position cannot be read for any reason
-
setPosition
Description copied from interface:IScannableMoves to the position required, blocking until it is complete. Similar to moveTo(...) in GDA8 Same as calling setPosition(value, null);- Specified by:
setPositionin interfaceIScannable<N extends NXobject>- Parameters:
value-- Returns:
- the new position attained by the device, if known. (Saves additional call to getPosition()) If not know the demand value is returned. NOTE if null is returned the system will call getPosition() again.
- Throws:
ScanningException
-
setPosition
Description copied from interface:IScannableMoves to the position required, blocking until it is complete. Similar to moveTo(...) in GDA8- Specified by:
setPositionin interfaceIScannable<N extends NXobject>- Parameters:
value- that this scalar should take.scanPosition- if within in a scan or null if not within a scan.- Returns:
- the new position attained by the device, if known. (Saves additional call to getPosition()) If not know the demand value is returned. NOTE if null is returned the system will call getPosition() again.
- Throws:
ScanningException
-
getUnit
Description copied from interface:IScannableThe unit is the unit in which the setPosition and getPosition values are in.- Specified by:
getUnitin interfaceIScannable<N extends NXobject>- Returns:
- String representation of unit which setPosition and getPosition are using.
-
getMaximum
Description copied from interface:IBoundableThe upper limit in the same unit as the position.- Specified by:
getMaximumin interfaceIBoundable<N extends NXobject>- Overrides:
getMaximumin classAbstractScannable<Object>- Returns:
- null if there is no upper limit. In this case it will be the upper limit of the type T.
-
getMinimum
Description copied from interface:IBoundableThe lower limit in the same unit as the position.- Specified by:
getMinimumin interfaceIBoundable<N extends NXobject>- Overrides:
getMinimumin classAbstractScannable<Object>- Returns:
- null if there is no upper limit. In this case it will be the upper limit of the type T.
-
getPermittedValues
Description copied from interface:IBoundableReturns a list of the permitted values for this object, ornullif the values are not restricted to a set of permitted values- Specified by:
getPermittedValuesin interfaceIBoundable<N extends NXobject>- Returns:
- list of permitted values, or
null - Throws:
Exception
-
scanFinally
public void scanFinally() -
addPositionListener
Description copied from interface:IPositionListenableUse to be notified as levels / positions are reached. Not usually necessary as setPosition is blocking until the position is reached but useful for other objects which need to change when new positions are reached.- Specified by:
addPositionListenerin interfaceIPositionListenable- Overrides:
addPositionListenerin classAbstractScannable<Object>- Parameters:
listener-
-
removePositionListener
Description copied from interface:IPositionListenableUse to be notified as levels / positions are reached.- Specified by:
removePositionListenerin interfaceIPositionListenable- Overrides:
removePositionListenerin classAbstractScannable<Object>- Parameters:
listener-
-
update
-
toString
- Overrides:
toStringin classAbstractNameableTimeoutable
-
abort
Description copied from interface:IScannableCall to terminate a movement before it is complete, for example when ScannablePositioner#abort is called due to an exception with another IScannable's movement- Specified by:
abortin interfaceIScannable<N extends NXobject>- Throws:
ScanningException
-