Interface INexusDevice<N extends NXobject>

Type Parameters:
N - the type of nexus object to be created, a sub-interface of NXobject, e.g. NXdetector
All Known Subinterfaces:
IGDAScannableNexusDevice<N>, INexusDeviceDecorator<N>, INexusMetadataDevice<N>, IWritableNexusDevice<N>
All Known Implementing Classes:
AbstractAreaDetectorRunnableDevice, AbstractDetectorNexusDeviceAdapter, AbstractMalcolmDevice, AbstractNexusContextAppender, AbstractNexusDecorator, AbstractNexusDeviceAdapter, AbstractNexusMetadataDevice, AbstractScannableNexusDevice, AbstractTransformationsAppender, AbstractWriteRegionsImmediatelyNXDetector, AreaDetectorRunnableDevice, AreaDetectorRunnableDeviceProxy, AreaDetectorRunnableDeviceWaitForArray, AreaDetectorWritingFilesRunnableDevice, BeamNexusDevice, BeforeScanSnapshotWriter, CalibrationFrameCollector, CompositeNexusScannable, CompoundNexusContextAppender, ConfiguredScannableNexusDevice, ConstantVelocityDevice, CounterTimerNexusDevice, DarkImageDetector, DefaultScannableNexusDevice, DetectorCollectionScannable, DetectorTransformationsAppender, DummyMalcolmDevice, DummyMalcolmTriggeredDetector, ElectronAnalyserRunnableDevice, FileCreatorDetectorNexusDevice, FrameCollectingScannable, GenericDetectorNexusDevice, InsertionDeviceNexusDevice, JythonScannableNexusWrapper, LegacyNexusDetectorNexusDevice, MalcolmDevice, MandelbrotDetector, MeasurementGroupWriter, MockNeXusScannable, MockNeXusSlit, MockStringNexusScannable, MonochromatorNexusDevice, NexusDetectorNexusDevice, NexusMetadataAppender, NexusMetadataDevice, NexusNodeCopyAppender, NexusObjectAppender, NexusScanMetadataWriter, NexusSlitsWrapper, NexusTemplateAppender, NexusTemplateDevice, NXObjectScannable, NXSampleScannable, PosDetector, PositionerTransformationsAppender, ProcessingMalcolmDevice, RandomIntDetector, RandomLineDevice, RunnableDeviceProxy, ScannableNexusWrapper, SimpleNexusDevice, SimpleNexusMetadataAppender, SimpleNexusMetadataDevice, SolsticeScanMetadataWriter, SourceNexusDevice, SpecsPhoibosSolsticeAnalyser, UserNexusDevice, VGScientaAnalyserNXDetector, XmapRunnableDevice, XmapRunnableDeviceBase, XmapWritingFilesRunnableDevice, ZebraRunnableDevice

public interface INexusDevice<N extends NXobject>
Any device which can write NeXus should implement this interface. This can be done easily by extending AbstractNexusObjectProvider
  • Method Details

    • getName

      String getName()
      Returns the name of this nexus device.
      Returns:
      name of nexus device
    • getNexusProvider

      default NexusObjectProvider<N> getNexusProvider(NexusScanInfo info) throws NexusException
      Returns 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 NexusNodeFactory to create a NeXus object which matches the device e.g. a NXdetector. final NXdetector detector = NexusNodeFactory.createNXdetector();

      On the detector object you can create 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 the LazyDatasets you create e.g. imageData.setChunking(info.createChunk(detectorXSize, detectorYSize));.

      In this method you can also write static metadata such as the detector exposure e.g. detector.setField("exposure_time", model.getExposure());. Or static datasets such as the image axis data detector.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")); or detector.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 the setXXXScalar methods for fields defined in the appropriate NXDL base class definition.

      The default implementation of this method throws UnsupportedOperationException. One of either this method or getNexusProviders(NexusScanInfo) must be overridden to create and return the nexus object(s) for this INexusDevice.

      Parameters:
      info - information about the scan which can be useful when creating datasets e.g. info.getRank()
      Returns:
      The NXobject created using the nodeFactory to represent this device
      Throws:
      NexusException - if the nexus object could not be created for any reason
    • getNexusProviders

      default List<NexusObjectProvider<N>> getNexusProviders(NexusScanInfo info) throws NexusException
      Returns the object providers required for writing correct NeXus files. Implement this method if your device needs to create multiple nexus objects. These can implement NexusObjectProvider

      The default implementation of this method calls getNexusProvider(NexusScanInfo) and returns a List whose sole element is the NexusObjectProvider returned from that method. One of either this method or getNexusProviders(NexusScanInfo) must be overridden to create and return the nexus object(s) for this INexusDevice.

      Parameters:
      info - information about the scan which can be useful when creating datasets e.g. info.getRank()
      Returns:
      The NXobject created using the nodeFactory to represent this device
      Throws:
      NexusException - if the nexus object could not be created for any reason
    • getCustomNexusModification

      default CustomNexusEntryModification getCustomNexusModification()
      Returns an object that performs a custom modification to an NXentry.

      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 NXdata groups. 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

      invalid reference
      #createNexusObject(NexusNodeFactory, NexusScanInfo)
      , so this method create links to nodes created in that method if appropriate.

      The easiest way to implement this method is to make this object itself also implement CustomNexusEntryModification. This method can then be overridden to simply return this.

      Returns:
      a CustomNexusEntryModification that makes a custom modification, or null if this device should not make custom modifications
    • register

      default void register()
      Registers this INexusDevice with the INexusDeviceService. Clients may use this to register INexusDevices to be looked up later by name. Note that this is not necessary for most devices, if they can be found some other way. It is however nec for INexusDeviceDecorators to call this method in order to decorate a device with the same name when
      invalid reference
      INexusDeviceService#getNexusDevice(INexusDevice)
      is called, for example a device that adds metadata.