Class NexusTemplateDevice<N extends NXobject>

java.lang.Object
org.eclipse.dawnsci.nexus.template.device.NexusTemplateDevice<N>
Type Parameters:
N - class of nexus object, a subinterface of NXobject
All Implemented Interfaces:
INexusDevice<N>

public class NexusTemplateDevice<N extends NXobject> extends Object implements INexusDevice<N>
An INexusDevice that creates a nexus object according to a template.

The template can be specified in one of three ways:

This can be done easily in the spring configuration. Note: only call one of these set methods should be called.
  • Constructor Details

    • NexusTemplateDevice

      public NexusTemplateDevice()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: INexusDevice
      Returns the name of this nexus device.
      Specified by:
      getName in interface INexusDevice<N extends NXobject>
      Returns:
      name of nexus device
    • setName

      public void setName(String name)
    • setTemplateMap

      public void setTemplateMap(Map<String,Object> templateMap)
      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

      public void setTemplateFilePath(String templateFilePath)
    • setTemplateString

      public void setTemplateString(String templateString)
    • getNexusProvider

      public NexusObjectProvider<N> getNexusProvider(NexusScanInfo info) throws NexusException
      Description copied from interface: INexusDevice
      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 INexusDevice.getNexusProviders(NexusScanInfo) must be overridden to create and return the nexus object(s) for this INexusDevice.

      Specified by:
      getNexusProvider in interface INexusDevice<N extends NXobject>
      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