Class Xspress4Detector

All Implemented Interfaces:
Detector, NexusDetector, Device, Scannable, Configurable, Findable, gda.observable.IObservable, Serializable, DetectorWithConfigurationFile, FluorescenceDetector
Direct Known Subclasses:
Xspress4OdinDetector

Class to setup and readout from Xspress4 detector.

Setup and running of the detector is similar to Xspress3 (i.e. through Epics via PVs) but data produced and to be written to the Nexus file is more similar to Xspress2. All detector data is contained in the hdf file written by the detector, and a small subset of this will be processed and added to the GDA Nexus file via readout() method. The exact values written to Nexus file depend on the readout mode setting (i.e. resolution grade information, deadtime correction calculation information, in-window sum, total FF, etc).

The strategy is to store settings for the collection using the XspressParameters class (as used by

invalid reference
XSpress2
). Access to PVs on the detector is via an implementation of Xspress4Controller.
See Also:
  • Constructor Details

    • Xspress4Detector

      public Xspress4Detector()
  • Method Details

    • 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
    • checkControllersAreSet

      protected void checkControllersAreSet()
    • setController

      public void setController(Xspress4Controller controller)
    • getController

      public Xspress4Controller getController()
    • stopDetector

      public void stopDetector(boolean waitForStop) throws DeviceException
      Stop the detector and hdf writer (and Odin metawriter), optionally wait for the detector to become idle.
      Parameters:
      waitForStop -
      Throws:
      DeviceException
    • startDetector

      public void startDetector() throws DeviceException
      Start the detector and hdf writer (and Odin metawriter)
      Throws:
      DeviceException
    • 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:
    • setupNumFramesToCollect

      public void setupNumFramesToCollect(int numberOfFramesToCollect) throws DeviceException
      Throws:
      DeviceException
    • setupHdfWriter

      public void setupHdfWriter(int numberOfFramesToCollect) throws DeviceException
      Set the number of frames to collect, the default file path and default file name in the Hdf writer plugin. The output directory (i.e. output path) is created if it doesn't already exist.
      Parameters:
      numberOfFramesToCollect -
      Throws:
      DeviceException
    • generateHdfDirectoryPath

      public String generateHdfDirectoryPath()
      Create name of path to where hdf will be written. By calling Xspress3Detector.XspressHelperMethods.getFilePath(String, String) with the currently set values from getFilePath() and getFilePrefix()
      Returns:
    • generateDefaultHdfFileName

      public String generateDefaultHdfFileName()
      Generate name of Hdf file for current scan using Xspress3Detector.XspressHelperMethods.getFilePrefix(String) with current value of getFilePrefix()
      Returns:
    • waitForFileWriter

      protected void waitForFileWriter() throws DeviceException
      Wait for Hdf file writing to flush the final frame of data. If number of captured frames is less than the number of demand frames, then stop immediately.
      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 ScannableBase
      Throws:
      DeviceException
      See Also:
    • addLinkToNexusFile

      protected void addLinkToNexusFile(String hdfFileFullName, String pathToDataInHdfFile, String linkName)
    • 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:
    • atPointEnd

      public void atPointEnd() throws DeviceException
      Description copied from class: ScannableBase
      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) Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.
      Specified by:
      atPointEnd in interface Scannable
      Overrides:
      atPointEnd in class ScannableBase
      Throws:
      DeviceException
      See Also:
    • acquireFrameAndWait

      public void acquireFrameAndWait() throws DeviceException
      Throws:
      DeviceException
    • acquireFrameAndWait

      public void acquireFrameAndWait(double collectionTimeMillis, double timeoutMillis) throws DeviceException
      Acquire new frame of data on detector and wait until it's finished. i.e. counter for 'total frames readout' (:ArrayCounter_RBV) has been incremented, or timeout has been reached
      Parameters:
      collectionTimeMillis - Frame time (milliseconds).
      timeoutMillis - Timeout - how long to wait for detector after expected collection time (milliseconds)
      Throws:
      DeviceException
    • atPointStart

      public void atPointStart() throws DeviceException
      Description copied from class: ScannableBase
      Called on every Scannable at every data point, for scans which are broken down into individual points (i.e. non-continuous scans) Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.
      Specified by:
      atPointStart in interface Scannable
      Overrides:
      atPointStart 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:
    • waitForMcaCollection

      public void waitForMcaCollection() 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
    • 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
    • getMCAData

      public double[][] getMCAData(double timeMillis) throws DeviceException
      Description copied from interface: FluorescenceDetector
      Perform a 'snapshot' data collection and return the MCA data. No file writing is involved.
      Specified by:
      getMCAData in interface FluorescenceDetector
      Parameters:
      timeMillis - The collection time in milliseconds
      Returns:
      the MCA data as a double array: [detector element][MCA channel]
      Throws:
      DeviceException
    • acquireMcaData

      protected void acquireMcaData(double timeMs) throws InterruptedException, DeviceException
      Acquire MCA data on detector and wait.
      Parameters:
      timeMs - collection time (milliseconds)
      Throws:
      InterruptedException
      DeviceException
    • getNumberOfElements

      public int getNumberOfElements()
      Specified by:
      getNumberOfElements in interface FluorescenceDetector
      Returns:
      The number of detector elements (sometimes also called channels but this risks confusion with the channels which make up the MCA)
    • getMCASize

      public int getMCASize()
      Specified by:
      getMCASize in interface FluorescenceDetector
      Returns:
      The number of channels in the MCA (Multi-Channel Analyser)
    • getMaxNumberOfRois

      public int getMaxNumberOfRois()
      Specified by:
      getMaxNumberOfRois in interface FluorescenceDetector
      Returns:
      The maximum number of ROIs per channel
    • setMaxNumberOfRois

      public void setMaxNumberOfRois(int maxRois)
    • getConfigurationParameters

      public FluorescenceDetectorParameters getConfigurationParameters()
      Specified by:
      getConfigurationParameters in interface FluorescenceDetector
      Returns:
      The current detector configuration
    • getConfigFileName

      public String getConfigFileName()
      Specified by:
      getConfigFileName in interface DetectorWithConfigurationFile
    • setConfigFileName

      public void setConfigFileName(String configFileName)
      Specified by:
      setConfigFileName in interface DetectorWithConfigurationFile
    • setDeadtimeFileName

      public void setDeadtimeFileName(String dtcParametersFileName)
    • getDeadtimeFileName

      public String getDeadtimeFileName()
    • getExtraNames

      public String[] getExtraNames()
      Description copied from interface: Scannable
      Additional names for extra values that returned by getPosition().
      Specified by:
      getExtraNames in interface Scannable
      Overrides:
      getExtraNames in class ScannableBase
      Returns:
      array of names of the extra elements if the array returned by getPosition is larger than the array required by moveTo
    • 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
      Overrides:
      getOutputFormat in class ScannableBase
      Returns:
      string array
    • setOutputFormat

      public void setOutputFormat(String[] outputFormat)
      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
      Overrides:
      setOutputFormat in class ScannableBase
      Parameters:
      outputFormat -
    • getMcaGrades

      public int getMcaGrades()
    • setScalerNameIndexMap

      public void setScalerNameIndexMap(Map<String,Integer> scalerIndexMap)
    • getScalerNameIndexMap

      public Map<String,Integer> getScalerNameIndexMap()
    • getAsciiScalerNameIndexMap

      public Map<String,Integer> getAsciiScalerNameIndexMap()
    • setAsciiScalerNameIndexMap

      public void setAsciiScalerNameIndexMap(Map<String,Integer> asciiScalerNameIndexMap)
    • loadConfigurationFromFile

      public void loadConfigurationFromFile(String configFilename)
    • loadDeadtimeParametersFromFile

      public void loadDeadtimeParametersFromFile(String configFilename)
    • getDeadtimeParameters

      public XspressDeadTimeParameters getDeadtimeParameters()
    • setDeadtimeParameters

      public void setDeadtimeParameters(XspressDeadTimeParameters deadtimeParameters)
    • getResolutionThreshold

      public int getResolutionThreshold()
    • setupCurrentSettings

      public void setupCurrentSettings()
    • applyConfigurationParameters

      public void applyConfigurationParameters(FluorescenceDetectorParameters parameters) throws Exception
      Description copied from interface: FluorescenceDetector
      Configure the detector using the given parameters
      Specified by:
      applyConfigurationParameters in interface FluorescenceDetector
      Parameters:
      parameters -
      Throws:
      Exception
    • applyConfigurationParameters

      public void applyConfigurationParameters() throws Exception
      Configure detector using current set of parameters
      Throws:
      Exception
    • setScalerWindow

      public void setScalerWindow(int windowNumber) throws DeviceException
      Apply current set of scaler window parameters to detector (window start, end)
      Parameters:
      windowNumber - scaler window to apply settings to (0 = window1, 1 = window2)
      Throws:
      DeviceException
    • setScalerWindowsFromRois

      public void setScalerWindowsFromRois() throws DeviceException
      Set scaler windows using values in ROI settings
      Throws:
      DeviceException
    • setDefaultScalerIndexMap

      public void setDefaultScalerIndexMap()
    • getLiveStats

      public Double[] getLiveStats() throws DeviceException
      Return array used by
      invalid reference
      MonitorViewBase
      to update view with latest data. Need to return 2d array with 3 columns (total counts, deadtime correction factor, unused column)
      Throws:
      DeviceException
    • getDeadtimeCorrectionFactors

      public double[] getDeadtimeCorrectionFactors() throws DeviceException
      Specified by:
      getDeadtimeCorrectionFactors in interface FluorescenceDetector
      Returns:
      An array of 'deadtime correction' factor values (one for each element of the detector)
      Throws:
      DeviceException
    • 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
    • setTriggerModeForScans

      public void setTriggerModeForScans(int intMode) throws DeviceException
      Set the trigger mode to be used when doing scans - usually 3 (TtlVeto) or 0 (Software) This is applied in atScanStart().
      Parameters:
      intMode -
      Throws:
      DeviceException
    • getTriggerModeForScans

      public Xspress4Detector.TriggerMode getTriggerModeForScans() throws DeviceException
      Throws:
      DeviceException
    • setTriggerMode

      public void setTriggerMode(Xspress4Detector.TriggerMode mode) throws DeviceException
      Set the current trigger mode on the detector
      Parameters:
      mode -
      Throws:
      DeviceException
    • setTriggerMode

      public void setTriggerMode(int intMode) throws DeviceException
      Set the current trigger mode on the detector by using integer rather than Xspress4Detector.TriggerMode enum. Xspress4Detector.TriggerMode enum value set is TriggerMode.values()[intMode];
      Parameters:
      intMode -
      Throws:
      IOException
      DeviceException
    • getTriggerMode

      public Xspress4Detector.TriggerMode getTriggerMode() throws DeviceException
      Return the current trigger mode setting by reading from PV.
      Returns:
      Throws:
      IOException
      DeviceException
    • getTfgFFI0

      public TfgFFoverI0 getTfgFFI0()
    • setTfgFFI0

      public void setTfgFFI0(TfgFFoverI0 tfgFFI0)
    • getI0

      public double getI0()
      Get I0 value from TfgScaler of FFI0 device. This is used form nomalising the res_bin_norm values in
      invalid reference
      #addResolutionGradeData
      . Use value of 1 if FFI0 is not available or it throws an exception.
      Returns:
      I0 value
    • setAcquireTime

      public void setAcquireTime(double time) throws DeviceException
      Throws:
      DeviceException
    • setDtcEnergyKev

      public void setDtcEnergyKev(double dtcEnergy) throws DeviceException
      Throws:
      DeviceException
    • getDtcEnergyKev

      public double getDtcEnergyKev() throws DeviceException
      Throws:
      DeviceException
    • setWriteHDF5Files

      public void setWriteHDF5Files(boolean writeHdfFiles)
      Description copied from interface: FluorescenceDetector
      Set to true to configure the detector to write an HDF5 file during a scan.
      Specified by:
      setWriteHDF5Files in interface FluorescenceDetector
      Parameters:
      writeHdfFiles -
    • isWriteHDF5Files

      public boolean isWriteHDF5Files()
      Specified by:
      isWriteHDF5Files in interface FluorescenceDetector
      Returns:
      true if detector creates an HDF5 file during a scan. This is normally created by Epics via the HDF plugin of the area detector.
    • getFilePath

      public String getFilePath()
    • setFilePath

      public void setFilePath(String filePath)
    • getFilePrefix

      public String getFilePrefix()
    • setFilePrefix

      public void setFilePrefix(String filePrefix)
    • getDefaultSubdirectory

      public String getDefaultSubdirectory()
    • setDefaultSubdirectory

      public void setDefaultSubdirectory(String defaultSubDirectory)
      Set a subdirectory to use when writing the hdf files. This is a subdirectory at the default datadirectory location (gda.data.scan.datawriter.datadir) and is used if no explicit filePath has been set (using setFilePath(String)).
      Parameters:
      defaultSubdirectory -
    • isWindowSettingUsesThreads

      public boolean isWindowSettingUsesThreads()
    • setWindowSettingUsesThreads

      public void setWindowSettingUsesThreads(boolean windowSettingUsesThreads)
    • getMcaReadoutWaitTimeMs

      public long getMcaReadoutWaitTimeMs()
    • setMcaReadoutWaitTimeMs

      public void setMcaReadoutWaitTimeMs(long waitTimeMs)
    • getMaxRetries

      public int getMaxRetries()
    • setMaxRetries

      public void setMaxRetries(int maxRetries)
    • getRetryDelayMs

      public long getRetryDelayMs()
    • setRetryDelayMs

      public void setRetryDelayMs(long retryDelayMs)