Class ADDetector

All Implemented Interfaces:
Detector, NexusDetector, Device, Scannable, PositionCallableProvider<NexusTreeProvider>, Configurable, Findable, gda.observable.IObservable, Serializable, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
AdDetectorExtRoiDraw, ADPco, AravisCamera, HardwareTriggerableADDetector, VGScientaAnalyser, VGScientaAnalyserCamOnly

public class ADDetector extends DetectorBase implements org.springframework.beans.factory.InitializingBean, NexusDetector, PositionCallableProvider<NexusTreeProvider>
A Scannable Detector driver for Epics Area Detectors suitable for use within Scans that support detectors implementing PositionCallableProvider.

The NexusTreeProvider returned by the call method of the PositionCallableProvider implements GDANexusDetectorData which provides plottable and printable data as well as binary detector data and detector metadata. If configured to return filepaths the object supports NXDetectorDataWithFilepathForSrs which will result in the filepath being returned as the first Scannable extra field and printed to the terminal and SRS files.

The Epics AreaDetector software is very modular and this is reflected in the structure of this class. As far as ADDetector is concerned an EPICS AreaDetector consists of 2 or 3 parts:
  1. A Base plugin that supports the source of the data, e.g. camera, The base is used to setup the acquisition, exposure time trigger mode, and start/stop acquisition. The result of an acquisition is a chunk of binary data.
  2. A NDArray plugin that makes the binary data available over channel access.
  3. A file writer plugin that will write the binary data to a file of some format. Either 1 file per acquisition or 1 file per collection of acquisitions.
This camera can be used by GDA in 2 different modes:
  1. Camera base + PV
  2. Camera base + file writer
This structure is represented in ADDetector by 3 main components: The result of getPositionCallable() is the creation of an object that has sufficient information to allow creation of a NexusTreeProvider in its call method. This object can take data from:
  1. The NDArray object if present and selected
  2. An NDStats, that represents the NDStats plugin, if present and selected
  3. The ADTriggeringStrategy object if selected
  4. The FileWriter if selected
  5. Another NexusTreeProvider that provides meta data if present.
See Also:
  • Field Details

    • FILEPATH_EXTRANAME

      protected static final String FILEPATH_EXTRANAME
      See Also:
    • afterPropertiesSetCalled

      protected boolean afterPropertiesSetCalled
    • firstReadoutInScan

      protected boolean firstReadoutInScan
  • Constructor Details

    • ADDetector

      public ADDetector()
  • Method Details

    • setCollectionStrategy

      public void setCollectionStrategy(NXCollectionStrategyPlugin collectionStrategy)
    • setAdBase

      public void setAdBase(ADBase adBase)
    • setNdStats

      public void setNdStats(NDStats ndStats)
    • setNdArray

      public void setNdArray(NDArray ndArray)
    • setNdFile

      public void setNdFile(NDFile ndFile)
    • setNdPython

      public void setNdPython(NDPython ndPython)
    • setNdOverlays

      public void setNdOverlays(List<NDOverlaySimple> ndOverlays)
    • setDescription

      public void setDescription(String description)
    • setDetectorType

      public void setDetectorType(String detectorType)
    • setComputeStats

      public void setComputeStats(boolean computeStats)
    • setComputeCentroid

      public void setComputeCentroid(boolean computeCentroid)
    • setReadArray

      public void setReadArray(boolean readArray)
    • setReadAcquisitionTime

      public void setReadAcquisitionTime(boolean readAcquisitionTime)
    • setReadAcquisitionPeriod

      public void setReadAcquisitionPeriod(boolean readAcquisitionPeriod)
    • setReadFilepath

      public void setReadFilepath(boolean readFilepath)
    • getCollectionStrategy

      public NXCollectionStrategyPlugin getCollectionStrategy()
    • getAdBase

      public ADBase getAdBase()
    • getNdStats

      public NDStats getNdStats()
    • getNdArray

      public NDArray getNdArray()
    • getNdFile

      public NDFile getNdFile()
    • getNdPython

      public NDPython getNdPython()
    • getNdOverlays

      public List<NDOverlaySimple> getNdOverlays()
    • isComputeStats

      public boolean isComputeStats()
    • isComputeCentroid

      public boolean isComputeCentroid()
    • isReadArray

      public boolean isReadArray()
    • isReadAcquisitionTime

      public boolean isReadAcquisitionTime()
    • isReadAcquisitionPeriod

      public boolean isReadAcquisitionPeriod()
    • isReadFilepath

      public boolean isReadFilepath()
    • createsOwnFiles

      public boolean createsOwnFiles() throws DeviceException
      Description copied from interface: Detector
      Returns a value which indicates whether the detector creates its own files. If it does (return true) the readout() method returns the name of the latest file created as a string. If it does not (return false) the readout() method will return the data directly.
      Specified by:
      createsOwnFiles in interface Detector
      Returns:
      true if readout() returns filenames
      Throws:
      DeviceException
    • getMetaDataProvider

      public NexusTreeProvider getMetaDataProvider()
    • setMetaDataProvider

      public void setMetaDataProvider(NexusTreeProvider metaDataProvider)
    • getFileWriter

      public NXFileWriterPlugin getFileWriter()
    • setFileWriter

      public void setFileWriter(NXFileWriterPlugin fileWriter)
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • configure

      public void configure() throws FactoryException
      Description copied from class: ConfigurableBase
      Default implementation for classes that do not have to do any specific configuration.
      Classes that do their own configuration should *not* call this superclass function, as it may cause the object to appear configured before it really is.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class ConfigurableBase
      Throws:
      FactoryException - if there is an error in configuration e.g. required variable not set or cannot connect to device
    • reset

      public void reset() throws Exception
      Throws:
      Exception
    • configureExtraNamesAndOutputFormat

      protected void configureExtraNamesAndOutputFormat()
      Extra name for each element in the stats and centroid statistics, if the instance is set to compute these.
    • asynchronousMoveTo

      public void asynchronousMoveTo(Object collectionTime) throws DeviceException
      Description copied from class: DetectorBase
      Default implementation is to set the collection time and to call the collectData method
      Specified by:
      asynchronousMoveTo in interface Scannable
      Overrides:
      asynchronousMoveTo in class DetectorBase
      Parameters:
      collectionTime - Position to move to should have an element for each input field.
      Throws:
      DeviceException
      See Also:
    • isBusy

      public boolean isBusy() throws DeviceException
      Description copied from class: DetectorBase
      Check if the Scannable is moving/operating. default implementation is to call the getStatus method
      Specified by:
      isBusy in interface Scannable
      Overrides:
      isBusy in class DetectorBase
      Returns:
      true - if operation carried out by moveTo has not completed yet
      Throws:
      DeviceException
      See Also:
    • getPosition

      public Object getPosition() throws DeviceException
      Description copied from class: DetectorBase
      Returns the current position of the Scannable. Called by ConcurentScan at the end of the point. Reads an internal (hardware) position from rawGetPosition, converts this to an external (user) position and returns it. Also, if createsOwnFiles attempts to register the file with all FileRegistrars (primarily for data archiving). Note that this method will be called if the detector is triggered from a 'pos' command but not if the detector is triggered by the scan command (which ignores the detector's scannable interface).
      Specified by:
      getPosition in interface Scannable
      Overrides:
      getPosition in class DetectorBase
      Returns:
      Current position with an element for each input and extra field. null if their are no fields.
      Throws:
      DeviceException
      See Also:
    • prepareForCollection

      public final void prepareForCollection() throws DeviceException
      Description copied from class: DetectorBase
      Default which should be overridden by subclasses.
      Specified by:
      prepareForCollection in interface Detector
      Overrides:
      prepareForCollection in class DetectorBase
      Throws:
      DeviceException
      See Also:
    • atScanStart

      public void atScanStart() throws DeviceException
      Description copied from class: ScannableBase
      Called for every Scannable at the start of a group of nested scans (or a single scan if that is the case) Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.
      Specified by:
      atScanStart in interface Scannable
      Overrides:
      atScanStart in class ScannableBase
      Throws:
      DeviceException
      See Also:
    • collectData

      public void collectData() throws DeviceException
      Description copied from interface: Detector
      Tells the detector to begin to collect a set of data, then returns immediately. Should cause the hardware to start collecting immediately: if there is any delay then detectors used in the same scan would collect over different times when beam conditions may differ.
      Specified by:
      collectData in interface Detector
      Throws:
      DeviceException
    • endCollection

      public final void endCollection() throws DeviceException
      Description copied from class: DetectorBase
      Default which should be overridden by subclasses.
      Specified by:
      endCollection in interface Detector
      Overrides:
      endCollection in class DetectorBase
      Throws:
      DeviceException
      See Also:
    • atScanEnd

      public void atScanEnd() throws DeviceException
      Description copied from class: ScannableBase
      Called for every Scannable at the end of a group of nested scans (or a single scan if that is the case).

      Note that this is only called if the Scan finishes normally, or has been requested to finish early. This will not be called if the scan finishes due to an exception of any kind. See Scannable.atCommandFailure() Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.

      Specified by:
      atScanEnd in interface Scannable
      Overrides:
      atScanEnd in class ScannableBase
      Throws:
      DeviceException
      See Also:
    • stop

      public void stop() throws DeviceException
      Description copied from class: ScannableBase
      Stop the current move/operation. Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.
      Specified by:
      stop in interface Scannable
      Overrides:
      stop in class ScannableBase
      Throws:
      DeviceException
      See Also:
    • atCommandFailure

      public void atCommandFailure() throws DeviceException
      Description copied from class: ScannableBase
      Hook to be used by Scan and pos commands to inform the Scannable that an exception, such as a DeviceExcpetion, has occurred. However not called when the command is aborted using an InterruptionException. If a Scan is aborted then only Scannable.stop() will be called by the Scan or pos command.

      Useful for telling Scannables which hold state during a scan for example, to reset themselves. Used for example by CoordinatedMotionScannables. This hook should be used not in the same way as the stop hook. Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.

      Specified by:
      atCommandFailure in interface Scannable
      Overrides:
      atCommandFailure in class ScannableBase
      Throws:
      DeviceException
      See Also:
    • prepareForArrayAndStatsCollection

      public void prepareForArrayAndStatsCollection() throws DeviceException
      Throws:
      DeviceException
    • getStatus

      public int getStatus() throws DeviceException
      Description copied from interface: Detector
      Returns the current collecting state of the device.
      Specified by:
      getStatus in interface Detector
      Returns:
      BUSY if the detector has not finished the requested operation(s), IDLE if in an completely idle state and STANDBY if temporarily suspended.
      Throws:
      DeviceException
    • waitWhileBusy

      public void waitWhileBusy() throws InterruptedException, DeviceException
      Description copied from class: ScannableBase
      Returns when operation carried out by moveTo has completed If this is to be overriden, isBusy must also be valid. Although the pos and scan command currently use this method to determine if the Scannable is busy, this must not be relied upon.
      Specified by:
      waitWhileBusy in interface Detector
      Specified by:
      waitWhileBusy in interface Scannable
      Overrides:
      waitWhileBusy in class ScannableBase
      Throws:
      InterruptedException
      DeviceException
    • getDescription

      public String getDescription() throws DeviceException
      Specified by:
      getDescription in interface Detector
      Overrides:
      getDescription in class DetectorBase
      Returns:
      A description of the detector.
      Throws:
      DeviceException
    • getDetectorID

      public String getDetectorID() throws DeviceException
      Specified by:
      getDetectorID in interface Detector
      Overrides:
      getDetectorID in class DetectorBase
      Returns:
      A identifier for this detector.
      Throws:
      DeviceException
    • setDetectorID

      public void setDetectorID(String detectorID)
    • getDetectorType

      public String getDetectorType() throws DeviceException
      Specified by:
      getDetectorType in interface Detector
      Overrides:
      getDetectorType in class DetectorBase
      Returns:
      The type of detector.
      Throws:
      DeviceException
    • clearCachedCallable

      protected void clearCachedCallable()
    • addDoubleItemToNXData

      protected void addDoubleItemToNXData(NXDetectorData data, String name, Double val)
    • addMultipleDoubleItemsToNXData

      protected final void addMultipleDoubleItemsToNXData(NXDetectorData data, String[] nameArray, Double[] valArray)
    • readout

      public NexusTreeProvider readout() throws DeviceException
      Description copied from interface: NexusDetector
      Returns the latest data collected as well as general detector information
      Specified by:
      readout in interface Detector
      Specified by:
      readout in interface NexusDetector
      Returns:
      the data collected
      Throws:
      DeviceException
    • createFileName

      protected String createFileName() throws Exception
      Throws:
      Exception
    • setDisableCallbacks

      public void setDisableCallbacks(boolean disableCallbacks)
    • isDisableCallbacks

      public boolean isDisableCallbacks()
    • isUsePipeline

      public boolean isUsePipeline()
    • setUsePipeline

      public void setUsePipeline(boolean usePipeline)
    • isCheckFileExists

      public boolean isCheckFileExists()
    • setCheckFileExists

      public void setCheckFileExists(boolean checkFileExists)
    • getPositionCallable

      public Callable<NexusTreeProvider> getPositionCallable() throws DeviceException
      Specified by:
      getPositionCallable in interface PositionCallableProvider<NexusTreeProvider>
      Throws:
      DeviceException
    • createNXDetectorData

      protected NXDetectorData createNXDetectorData() throws Exception, DeviceException
      Throws:
      Exception
      DeviceException
    • appendDataAxes

      protected void appendDataAxes(NXDetectorData data) throws Exception
      This stub adds rather stupid axes. Overriding classes are highly encouraged to do better.
      Parameters:
      data -
      Throws:
      Exception
    • readoutArrayIntoNXDetectorData

      protected void readoutArrayIntoNXDetectorData(NXDetectorData data, NDArray ndArray, String detectorName) throws Exception, DeviceException
      Throws:
      Exception
      DeviceException
    • getDataChunking

      public int[] getDataChunking()
    • setDataChunking

      public void setDataChunking(int[] dataChunking)
    • appendNXDetectorDataFromCollectionStrategy

      protected void appendNXDetectorDataFromCollectionStrategy(NXDetectorData data) throws Exception
      Throws:
      Exception
    • isReadCapturedFramesCount

      public boolean isReadCapturedFramesCount()
    • setReadCapturedFramesCount

      public void setReadCapturedFramesCount(boolean readCapturedFramesCount)