Class DummyNXDetector

java.lang.Object
gda.factory.ConfigurableBase
gda.device.detector.DummyNXDetector
All Implemented Interfaces:
Detector, NexusDetector, Device, Scannable, Configurable, Findable, gda.observable.IObservable

public class DummyNXDetector extends ConfigurableBase implements NexusDetector
  • Constructor Details

    • DummyNXDetector

      public DummyNXDetector(String name, int numElements)
      Parameters:
      name - - prefix for each element
      numElements - - number of elements - if 1 then the name is simply the value of name
  • Method Details

    • readout

      public NXDetectorData 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
    • 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
    • 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
    • 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
    • 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
    • getDescription

      public String getDescription() throws DeviceException
      Specified by:
      getDescription in interface Detector
      Returns:
      A description of the detector.
      Throws:
      DeviceException
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • checkPositionValid

      public String checkPositionValid(Object position)
      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.
    • 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
    • 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 -
    • 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 -
    • 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 -
    • 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 -
    • stop

      public void stop() throws DeviceException
      Description copied from interface: Scannable
      Stop the current move/operation.
      Specified by:
      stop in interface Scannable
      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
    • close

      public void close() throws DeviceException
      Description copied from interface: Device
      Close and unconfigure the device.
      Specified by:
      close in interface Device
      Throws:
      DeviceException
    • 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
    • getProtectionLevel

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

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

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

      public void deleteIObservers()
      Specified by:
      deleteIObservers in interface gda.observable.IObservable
    • 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
      Overrides:
      reconfigure in class ConfigurableBase
      Throws:
      FactoryException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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