Class AbstractScanHook

All Implemented Interfaces:
Device, Scannable, Configurable, Findable, gda.observable.IObservable
Direct Known Subclasses:
ProcessingScannable, SingleFileProcessingRequest

public abstract class AbstractScanHook extends DeviceBase implements Scannable
A base class for creating scan hooks. Allows subclasses to be included in scans without dealing with any input/output. Provides a simple way to add functionality to certain points in a scan.
  • Constructor Details

    • AbstractScanHook

      public AbstractScanHook(String name)
  • Method Details

    • setName

      public final void setName(String name)
      Description copied from class: DeviceBase
      Set the name of the device
      Specified by:
      setName in interface Findable
      Overrides:
      setName in class DeviceBase
      Parameters:
      name - The name to set.
    • getPosition

      public final Object getPosition()
      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.
    • moveTo

      public final void moveTo(Object position)
      Description copied from interface: Scannable
      Trigger a move/operation and block until completion.
      Specified by:
      moveTo in interface Scannable
      Parameters:
      position -
    • asynchronousMoveTo

      public final void asynchronousMoveTo(Object position)
      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.
    • checkPositionValid

      public final 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.
    • 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()
      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
    • waitWhileBusy

      public void waitWhileBusy() throws InterruptedException
      Description copied from interface: Scannable
      Returns when operation carried out by moveTo has completed
      Specified by:
      waitWhileBusy in interface Scannable
      Throws:
      InterruptedException
    • isAt

      public final boolean isAt(Object positionToTest)
      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
    • 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 -
    • 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 final 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 final 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 -
    • getExtraNames

      public final 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
    • setExtraNames

      public final 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 final 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 final 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
    • 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