Class NexusDetectorProcessor

java.lang.Object
gda.device.detector.nexusprocessor.NexusDetectorProcessor
All Implemented Interfaces:
Detector, HardwareTriggerableDetector, HardwareTriggeredDetector, NexusDetector, Device, Scannable, PositionCallableProvider<GDANexusDetectorData>, Configurable, Findable, gda.observable.IObservable

public class NexusDetectorProcessor extends Object implements NexusDetector, PositionCallableProvider<GDANexusDetectorData>, HardwareTriggerableDetector
Class to delegate calls to a detector. Used for overriding method of an existing detector Turns a detector that does not support PositionCallableProvider into one that does Functions add data to the NexusData provide helper functions to get the image data from the detector for derived classes Passes data to processor. Once 1 thread per processor.
  • Constructor Details

    • NexusDetectorProcessor

      public NexusDetectorProcessor()
  • Method Details

    • isEnableProcessing

      public boolean isEnableProcessing()
    • setEnableProcessing

      public void setEnableProcessing(boolean enableProcessing)
    • getDetector

      public NexusDetector getDetector()
    • setDetector

      public void setDetector(NexusDetector detector)
    • isMergeWithDetectorData

      public boolean isMergeWithDetectorData()
    • setMergeWithDetectorData

      public void setMergeWithDetectorData(boolean mergeWithDetectorData)
    • getProcessor

      public NexusTreeProviderProcessor getProcessor()
    • setProcessor

      public void setProcessor(NexusTreeProviderProcessor processor)
    • rescanProcessors

      public void rescanProcessors()
      Method to allow the correct setting of extraNames following enabling of processors Maybe the object should listen to the sub processors
    • clearProcessorCache

      protected void clearProcessorCache()
    • setName

      public void setName(String name)
      Description copied from interface: Findable
      Set or change the name of the object (as defined in XML).
      Specified by:
      setName in interface Findable
      Parameters:
      name - the object name
    • configure

      public void configure() throws FactoryException
      Description copied from interface: Configurable
      Perform operations that must be done after Spring initialisation i.e. anything that goes beyond setting member variables.
      Specified by:
      configure in interface Configurable
      Throws:
      FactoryException - if there is an error in configuration e.g. required variable not set or cannot connect to device
    • isConfigured

      public boolean isConfigured()
      Description copied from interface: Configurable
      Checks to see if the object is already configured.
      Specified by:
      isConfigured in interface Configurable
      Returns:
      return true if configured false otherwise
    • reconfigure

      public void reconfigure() throws FactoryException
      Description copied from interface: Configurable
      Re-initialisation of values and states.

      Moved from Reconfigurable which has been deleted

      Specified by:
      reconfigure in interface Configurable
      Throws:
      FactoryException
    • isConfigureAtStartup

      public boolean isConfigureAtStartup()
      Description copied from interface: Configurable
      Indicates whether this object should be configured at startup.

      Moved from ConditionallyConfigurable which has been deleted

      Specified by:
      isConfigureAtStartup in interface Configurable
    • getPosition

      public Object getPosition() throws DeviceException
      Description copied from interface: Scannable
      Returns the current position of the Scannable. Called by ConcurentScan at the end of the point.
      Specified by:
      getPosition in interface Scannable
      Returns:
      Current position with an element for each input and extra field. null if their are no fields.
      Throws:
      DeviceException
    • getName

      public String getName()
      Description copied from interface: Findable
      Get the object name. Used by Castor to check if the object name has been set before calling the Findable.setName(String) method.
      Specified by:
      getName in interface Findable
      Returns:
      a String containing the object name.
    • addIObserver

      public void addIObserver(gda.observable.IObserver observer)
      Specified by:
      addIObserver in interface gda.observable.IObservable
    • setAttribute

      public void setAttribute(String attributeName, Object value) throws DeviceException
      Description copied from interface: Device
      Set any attribute the implementing classes may provide
      Specified by:
      setAttribute in interface Device
      Parameters:
      attributeName - is the name of the attribute
      value - is the value of the attribute
      Throws:
      DeviceException - if an attribute cannot be set
    • deleteIObserver

      public void deleteIObserver(gda.observable.IObserver observer)
      Specified by:
      deleteIObserver in interface gda.observable.IObservable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • deleteIObservers

      public void deleteIObservers()
      Specified by:
      deleteIObservers in interface gda.observable.IObservable
    • getAttribute

      public Object getAttribute(String attributeName) throws DeviceException
      Description copied from interface: Device
      Get the value of the specified attribute
      Specified by:
      getAttribute in interface Device
      Parameters:
      attributeName - is the name of the attribute
      Returns:
      the value of the attribute as an Object type
      Throws:
      DeviceException - if an attribute cannot be retrieved
    • moveTo

      public void moveTo(Object position) throws DeviceException
      Description copied from interface: Scannable
      Trigger a move/operation and block until completion.
      Specified by:
      moveTo in interface Scannable
      Parameters:
      position -
      Throws:
      DeviceException
    • 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
    • asynchronousMoveTo

      public void asynchronousMoveTo(Object position) throws DeviceException
      Description copied from interface: Scannable
      Trigger a move/operation and return immediately. Implementations of this method should be non-blocking to allow concurrent motion; the isBusy method will be used to determine when the move has completed.
      Specified by:
      asynchronousMoveTo in interface Scannable
      Parameters:
      position - Position to move to should have an element for each input field.
      Throws:
      DeviceException
    • setCollectionTime

      public void setCollectionTime(double time) throws DeviceException
      Description copied from interface: Detector
      Sets the collection time, in seconds, to be used during the next call of collectData.
      Specified by:
      setCollectionTime in interface Detector
      Parameters:
      time - the collection time in seconds
      Throws:
      DeviceException
    • close

      public void close() throws DeviceException
      Description copied from interface: Device
      Close and unconfigure the device.
      Specified by:
      close in interface Device
      Throws:
      DeviceException
    • setProtectionLevel

      public void setProtectionLevel(int newLevel)
      Description copied from interface: Device
      Sets the permission level for this object. If this is not set then a default value will be applied.
      Specified by:
      setProtectionLevel in interface Device
      Parameters:
      newLevel -
    • getCollectionTime

      public double getCollectionTime() throws DeviceException
      Description copied from interface: Detector
      Returns the time, in seconds, the detector collects for during the next call to collectData()
      Specified by:
      getCollectionTime in interface Detector
      Returns:
      double
      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
    • checkPositionValid

      public String checkPositionValid(Object position) throws DeviceException
      Description copied from interface: Scannable
      Tests if the given object is meaningful to this Scannable and so could be used by one of the move commands. May check limits and other things too. This is the method called by scans on all points before the scan is run.
      Specified by:
      checkPositionValid in interface Scannable
      Parameters:
      position -
      Returns:
      null if position is valid, or returns a description if not.
      Throws:
      DeviceException
    • getProtectionLevel

      public int getProtectionLevel()
      Specified by:
      getProtectionLevel in interface Device
      Returns:
      int - the permission level for this object.
    • 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
    • stop

      public void stop() throws DeviceException
      Description copied from interface: Scannable
      Stop the current move/operation.
      Specified by:
      stop in interface Scannable
      Throws:
      DeviceException
    • isBusy

      public boolean isBusy() throws DeviceException
      Description copied from interface: Scannable
      Check if the Scannable is moving/operating.
      Specified by:
      isBusy in interface Scannable
      Returns:
      true - if operation carried out by moveTo has not completed yet
      Throws:
      DeviceException
    • getDataDimensions

      public int[] getDataDimensions() throws DeviceException
      Description copied from interface: Detector
      Returns the dimensions of the data object returned by the Detector.readout() method.
      Specified by:
      getDataDimensions in interface Detector
      Returns:
      the dimensions of the data object returned by the Detector.readout() method
      Throws:
      DeviceException
    • waitWhileBusy

      public void waitWhileBusy() throws DeviceException, InterruptedException
      Description copied from interface: Detector
      Wait while the detector collects data. Should return as soon as the exposure completes and it is safe to move motors. i.e. counts must be safely latched either in hardware or software before returning.
      Specified by:
      waitWhileBusy in interface Detector
      Specified by:
      waitWhileBusy in interface Scannable
      Throws:
      DeviceException
      InterruptedException
    • prepareForCollection

      public void prepareForCollection() throws DeviceException
      Description copied from interface: Detector
      Method called before a scan starts. May be used to setup detector for collection, for example MAR345 uses this to erase.

      Note: it is recommended to not implement this method, but to implement one or both of Scannable.atScanLineStart() or Scannable.atScanStart() instead. Implementing this method may cause issues when the detector class is used in multi-dimensional scans.

      Specified by:
      prepareForCollection in interface Detector
      Throws:
      DeviceException
    • isAt

      public boolean isAt(Object positionToTest) throws DeviceException
      Description copied from interface: Scannable
      Tests if the scannable is at (or if appropriate, close to) the value positionToTest.
      Specified by:
      isAt in interface Scannable
      Parameters:
      positionToTest - The position to compare the scannable's position to.
      Returns:
      true if scannable is at positionToTest
      Throws:
      DeviceException
    • endCollection

      public void endCollection() throws DeviceException
      Description copied from interface: Detector
      Method called at the end of collection to tell detector when a scan has finished. Typically integrating detectors used in powder diffraction do not output until the end of the scan and need to be told when this happens.
      Specified by:
      endCollection in interface Detector
      Throws:
      DeviceException
    • setLevel

      public void setLevel(int level)
      Description copied from interface: Scannable
      Used for ordering the operations of Scannables during scans
      Specified by:
      setLevel in interface Scannable
      Parameters:
      level -
    • 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
    • getLevel

      public int getLevel()
      Description copied from interface: Scannable
      get the operation level of this scannable.
      Specified by:
      getLevel in interface Scannable
      Returns:
      int - the level
    • getInputNames

      public String[] getInputNames()
      Description copied from interface: Scannable
      gets a array of InputNames used by moveTo of this scannable.
      Specified by:
      getInputNames in interface Scannable
      Returns:
      array of the names of the elements of the object returned by getPosition
    • setInputNames

      public void setInputNames(String[] names)
      Description copied from interface: Scannable
      sets the array of names returned by getInputNames method of this scannable.
      Specified by:
      setInputNames in interface Scannable
      Parameters:
      names -
    • getDescription

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

      public String[] getExtraNames()
      Description copied from interface: Scannable
      Additional names for extra values that returned by getPosition().
      Specified by:
      getExtraNames in interface Scannable
      Returns:
      array of names of the extra elements if the array returned by getPosition is larger than the array required by moveTo
    • getDetectorID

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

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

      public void setExtraNames(String[] names)
      Description copied from interface: Scannable
      Sets the array of names returned by getExtraNames of this scannable.
      Specified by:
      setExtraNames in interface Scannable
      Parameters:
      names -
    • setOutputFormat

      public void setOutputFormat(String[] names)
      Description copied from interface: Scannable
      Sets the array of strings describing how best to format the positions from this scannable
      Specified by:
      setOutputFormat in interface Scannable
      Parameters:
      names -
    • getOutputFormat

      public String[] getOutputFormat()
      Description copied from interface: Scannable
      Returns an array of strings which are the format strings to use when pretty printing parts of the output
      Specified by:
      getOutputFormat in interface Scannable
      Returns:
      string array
    • atScanStart

      public void atScanStart() throws DeviceException
      Description copied from interface: Scannable
      Called for every Scannable at the start of a group of nested scans (or a single scan if that is the case)
      Specified by:
      atScanStart in interface Scannable
      Throws:
      DeviceException
    • atScanEnd

      public void atScanEnd() throws DeviceException
      Description copied from interface: Scannable
      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()

      Specified by:
      atScanEnd in interface Scannable
      Throws:
      DeviceException
    • atScanLineStart

      public void atScanLineStart() throws DeviceException
      Description copied from interface: Scannable
      Called for every Scannable at the start of every scan
      Specified by:
      atScanLineStart in interface Scannable
      Throws:
      DeviceException
    • atScanLineEnd

      public void atScanLineEnd() throws DeviceException
      Description copied from interface: Scannable
      Called for every Scannable at the end of every scan
      Specified by:
      atScanLineEnd in interface Scannable
      Throws:
      DeviceException
    • atPointStart

      public void atPointStart() throws DeviceException
      Description copied from interface: Scannable
      Called on every Scannable at every data point, for scans which are broken down into individual points (i.e. non-continuous scans)
      Specified by:
      atPointStart in interface Scannable
      Throws:
      DeviceException
    • atPointEnd

      public void atPointEnd() throws DeviceException
      Description copied from interface: Scannable
      Called on every Scannable at the end of every data point, for scans which are broken down into individual points (i.e. non-continous scans)
      Specified by:
      atPointEnd in interface Scannable
      Throws:
      DeviceException
    • atLevelMoveStart

      public void atLevelMoveStart() throws DeviceException
      Description copied from interface: Scannable
      Called by both the pos and scan commands at the start of each subsequent level move only on Scannables that will be moved as part that level's movement.

      For example "pos a 1 b 2 c 3", will, if a and b have the same level and c a higher level will result in:

       a.atLevelMoveStart()   invalid input: '<'----
       b.atLevelMoveStart()   invalid input: '<'----
       a.asynchronousMoveTo()
       b.asynchronousMoveTo()
       a.waitWhileBusy()
       b.waitWhileBusy()
       c.atLevelMoveStart()   invalid input: '<'----
       c.asynchronousMoveTo()
       c.waitWhileBusy()
       
      This hook is used by CoordinatedMotionScannables.
      Specified by:
      atLevelMoveStart in interface Scannable
      Throws:
      DeviceException
    • atLevelStart

      public void atLevelStart() throws DeviceException
      Description copied from interface: Scannable
      Called by both the pos and scan commands at the start of each subsequent level move on all Scannables that are part that level's movement.

      This provides a useful mechanism for e.g. creating a Scannable that opens a shutter after motors have moved but before a detector is exposed.

      Specified by:
      atLevelStart in interface Scannable
      Throws:
      DeviceException
    • atLevelEnd

      public void atLevelEnd() throws DeviceException
      Specified by:
      atLevelEnd in interface Scannable
      Throws:
      DeviceException
    • atCommandFailure

      public void atCommandFailure() throws DeviceException
      Description copied from interface: Scannable
      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.

      Specified by:
      atCommandFailure in interface Scannable
      Throws:
      DeviceException
    • toFormattedString

      public String toFormattedString()
      Description copied from interface: Scannable
      Returns a string representation of the Scannable and its current position/value/status

      Typically should return:

      name : position

      or for detectors, name : status

      If the position/status cannot be determined, the function should return Scannable.VALUE_UNAVAILABLE in its place.

      Specified by:
      toFormattedString in interface Scannable
      Returns:
      string as defined above
    • getPositionCallable

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

      public void setHardwareTriggering(boolean b) throws DeviceException
      Description copied from interface: HardwareTriggerableDetector
      Configure the Detector to trigger on hardware triggers, or not.
      Specified by:
      setHardwareTriggering in interface HardwareTriggerableDetector
      Parameters:
      b -
      Throws:
      DeviceException
    • isHardwareTriggering

      public boolean isHardwareTriggering()
      Specified by:
      isHardwareTriggering in interface HardwareTriggerableDetector
      Returns:
      true if configured to triger on hardware triggers.
    • getHardwareTriggerProvider

      public HardwareTriggerProvider getHardwareTriggerProvider()
      Description copied from interface: HardwareTriggeredDetector
      Get the HardwareTriggerProvider that represents the controller this Detector is wired to.
      Specified by:
      getHardwareTriggerProvider in interface HardwareTriggeredDetector
      Returns:
      the trigger provider
    • setNumberImagesToCollect

      public void setNumberImagesToCollect(int numberImagesToCollect)
      Description copied from interface: HardwareTriggeredDetector
      Tell the detector how many scan points to collect. (Unfortunately named images).
      Specified by:
      setNumberImagesToCollect in interface HardwareTriggeredDetector
      Parameters:
      numberImagesToCollect -
    • integratesBetweenPoints

      public boolean integratesBetweenPoints()
      Description copied from interface: HardwareTriggeredDetector
      Detectors that sample some value at the time of a trigger should return False. Detectors such as counter timers should return True. If true ,TrajectoryScanLine will generate a trigger half a point before the motor reaches a demanded point such that the resulting bin of data is centred on the demand position. Area detectors that will be triggered by the first pulse should also return true.
      Specified by:
      integratesBetweenPoints in interface HardwareTriggeredDetector
      Returns:
      true for detectors that integrates b