Class BufferedScaler

All Implemented Interfaces:
CounterTimer, Detector, BufferedDetector, DarkCurrentDetector, Device, Scannable, Configurable, Findable, gda.observable.IObservable, Serializable

public class BufferedScaler extends TfgScalerWithLogValues implements BufferedDetector
Adapter for the TfgScalerWithLogValues class so that it may be used in ContinuousScans.

Assumes that the TTL signal driving the TFG time-frames is connected to TFG socket TTL INPUT 0.

See Also:
  • Constructor Details

    • BufferedScaler

      public BufferedScaler()
  • Method Details

    • getFramesRead

      public double[][] getFramesRead()
    • clearFramesRead

      public void clearFramesRead()
    • 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
      Overrides:
      collectData in class TfgScaler
      Throws:
      DeviceException
    • readAllFrames

      public Object[] readAllFrames() throws DeviceException
      Description copied from interface: BufferedDetector
      An array of the data from the detector. Each element is one frame of data.
      Specified by:
      readAllFrames in interface BufferedDetector
      Returns:
      Object
      Throws:
      DeviceException
    • readFrames

      public Object[] readFrames(int startFrame, int finalFrame) throws DeviceException
      Description copied from interface: BufferedDetector
      An array of the data from the detector. Each element is one frame of data. The first frame is 0.
      Specified by:
      readFrames in interface BufferedDetector
      Parameters:
      startFrame -
      finalFrame -
      Returns:
      Object
      Throws:
      DeviceException
    • readout

      public double[] readout() throws DeviceException
      Description copied from interface: Detector
      Returns the latest data collected. The size of the Object returned must be consistent with the values returned by getDataDimensions and getExtraNames.

      If LocalProperties.GDA_SCAN_CONCURRENTSCAN_READOUT_CONCURRENTLY is true then motors may be moved while the detector readouts. The value returned must not be effected by any concurrent motor or shutter movements. See Detector.waitWhileBusy() and ConcurrentScan. Readout must block until the detector is ready to respond quickly to Detector.collectData() again.

      Specified by:
      readout in interface Detector
      Overrides:
      readout in class TfgScalerWithLogValues
      Returns:
      the data collected
      Throws:
      DeviceException
      See Also:
    • setContinuousMode

      public void setContinuousMode(boolean on) throws DeviceException
      Description copied from interface: BufferedDetector
      When in slave mode the detector will be triggered by an external signal to collect each frame of data.
      Specified by:
      setContinuousMode in interface BufferedDetector
      Parameters:
      on -
      Throws:
      DeviceException
    • 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 TfgScalerWithDarkCurrent
      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 TfgScaler
      Throws:
      DeviceException
      See Also:
    • setupTimeFrames

      protected void setupTimeFrames(boolean externalTriggerStart, boolean externalTriggerFrames) throws DeviceException
      Setup and send the time frame commands to the Tfg. If externalTriggerFrames = true :
    • each time frame is externally triggered
    • the dead and live time of each frame is set from user specified values of frameLiveTime and frameDeadTime.
    • Trigger options (dead and live pause) are from user specified deadPause value, and value of ttlSocket respectively (0 if ttlSocket is null)
    • Parameters:
      externalTriggerStart - - set to true to use external trigger can be used to start the Tfg
      externalTriggerFrames - - set to true to use external trigger to trigger each time frame within the group
      Throws:
      DeviceException
    • getInitialDaServerCommand

      protected String getInitialDaServerCommand(boolean externalTriggerStart)
    • getFrameDaServerCommand

      protected String getFrameDaServerCommand(int numFrames, double totalTime, boolean externalTriggerFrames)
    • startTfg

      public void startTfg(boolean externalTrigger) throws DeviceException
      Throws:
      DeviceException
    • isManualStart

      public boolean isManualStart()
    • setManualStart

      public void setManualStart(boolean manualStart)
    • isContinuousMode

      public boolean isContinuousMode()
      Specified by:
      isContinuousMode in interface BufferedDetector
      Returns:
      true if the detector is ready to accept trigger pulses
    • getContinuousParameters

      public ContinuousParameters getContinuousParameters()
      Specified by:
      getContinuousParameters in interface BufferedDetector
      Returns:
      ContinuousParameters
    • setContinuousParameters

      public void setContinuousParameters(ContinuousParameters parameters)
      Description copied from interface: BufferedDetector
      Sets the parameters which define the continuous movement to use
      Specified by:
      setContinuousParameters in interface BufferedDetector
      Parameters:
      parameters -
    • clearMemory

      public void clearMemory() throws DeviceException
      Description copied from interface: BufferedDetector
      Clears the detector memory
      Specified by:
      clearMemory in interface BufferedDetector
      Throws:
      DeviceException
    • isWaitingForTrigger

      public boolean isWaitingForTrigger() throws DeviceException
      Returns:
      Return true if tfg is armed and waiting for an external trigger
      Throws:
      DeviceException
    • getNumberFrames

      public int getNumberFrames() throws DeviceException
      Specified by:
      getNumberFrames in interface BufferedDetector
      Returns:
      number of frames of data in memory which have been collected
      Throws:
      DeviceException
    • setOverrunTime

      public void setOverrunTime(double overrunTime)
    • getOverrunTime

      public double getOverrunTime()
      The excess time to collect data for above the movement time. This ensures all motor encoder data has been read.

      Default is 0.1;

      Returns:
      double time in seconds
    • getDaserver

      public DAServer getDaserver()
    • setDaserver

      public void setDaserver(DAServer daserver)
    • setReturnCountRates

      public void setReturnCountRates(Boolean returnCountRates)
    • getReturnCountRates

      public Boolean getReturnCountRates()
    • maximumReadFrames

      public int maximumReadFrames() throws DeviceException
      Description copied from interface: BufferedDetector
      As certain detectors may cause memory issues if too many frames are attempted to be read in one go, this is the maximum for this detector based on its current configuration (i.e. after setContinuousMode(True) has been called.

      The lowest value returned from any of the detectors in a continuous scan will be the limit set.

      If there is no limit then this method should return Integer.MAX_VALUE.

      Specified by:
      maximumReadFrames in interface BufferedDetector
      Returns:
      int - the maximum number of frames which should be read at any one time from this detector
      Throws:
      DeviceException
    • getTtlSocket

      public int getTtlSocket()
    • setTtlSocket

      public void setTtlSocket(Integer ttlSocket)
      Set the TTL trigger input to use for external start and for live pause (value = 0...3).
      Parameters:
      ttlSocket -
    • getNumCycles

      public int getNumCycles()
    • setNumCycles

      public void setNumCycles(int numCycles)
    • getCurrentCycle

      public int getCurrentCycle() throws DeviceException
      Return cycle currently being executed by Tfg by parsing the value of the Cycle field from the Tfg 'progress' string. (Note: Parent class implementation returns current lap which is different to current cycle). return
      Specified by:
      getCurrentCycle in interface CounterTimer
      Overrides:
      getCurrentCycle in class CounterTimerBase
      Returns:
      the current cycle number
      Throws:
      DeviceException
    • clearMemoryFrames

      public void clearMemoryFrames(int startFrame, int finalFrame) throws DeviceException
      Clear specified block of scaler memory. Intended to be used with multiple cycles, so that frames of scaler memory used for a cycle can be cleared once they have been read, ready to be re-used on subsequent cycles.
      Parameters:
      startFrame -
      finalFrame -
      Throws:
      DeviceException
      Since:
      25/1/2017
    • getFrameLiveTime

      public double getFrameLiveTime()
    • setFrameLiveTime

      public void setFrameLiveTime(double frameLiveTime)
    • getFrameDeadTime

      public double getFrameDeadTime()
    • setFrameDeadTime

      public void setFrameDeadTime(double frameDeadTime)
      Set the dead frame time. This is the gap to use between adjacent timeframes in sequence of externally or internally triggered frames.
      Parameters:
      frameDeadTime -
    • getDeadPause

      public int getDeadPause()
    • setDeadPause

      public void setDeadPause(int deadPause)
      Set the dead pause value - used when using externally triggered frames (e.g. 8 to continue on rising edge of TTL0, 9 for TTL1 etc).
      Parameters:
      deadPause -
    • isExternalTriggeredFrames

      public boolean isExternalTriggeredFrames()
    • setExternalTriggeredFrames

      public void setExternalTriggeredFrames(boolean externalTriggeredFrames)
      Set to true to have each time frame triggered by external source (Controls the dead pause and live pause values -
      Parameters:
      externalTriggeredFrames -
    • isExternalTriggerStart

      public boolean isExternalTriggerStart()
    • setExternalTriggerStart

      public void setExternalTriggerStart(boolean externalTriggerStart)
      Set to true to have the Tfg start when external TTL trigger signal is received. (TTL input port to use is set with setTtlSocket(Integer)).
      Parameters:
      externalTriggerStart -
    • setUseExternalTriggers

      public void setUseExternalTriggers(boolean tf)
    • isFrameCountDuringCycles

      public boolean isFrameCountDuringCycles()
    • setFrameCountDuringCycles

      public void setFrameCountDuringCycles(boolean frameCountDuringCycles)
      If set to false, getNumberFrames() will return zero while the Tfg is collecting frames across multiple cycles.
      Parameters:
      frameCountDuringCycles -
    • getGroupInitialCommand

      public String getGroupInitialCommand()
    • setGroupInitialCommand

      public void setGroupInitialCommand(String groupInitialCommand)