Class MythenDetectorImpl

All Implemented Interfaces:
Detector, Mythen, Device, Scannable, Configurable, Findable, gda.observable.IObservable, Serializable, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
MythenDetector, MythenNexusImpl, ShutterControlledMythenDetectorImpl, SummingMythenDetector

@ServiceInterface(Mythen.class) public class MythenDetectorImpl extends DetectorBase implements Mythen, org.springframework.beans.factory.InitializingBean
Implementation of the GDA Mythen interface.
See Also:
  • Field Details

    • exposureTime

      protected BigDecimal exposureTime
      Exposure time in seconds.
    • status

      protected volatile int status
    • detectorID

      protected String detectorID
    • scanNumTracker

      protected NumTracker scanNumTracker
    • collectionNumber

      protected volatile long collectionNumber
    • mythenClient

      protected MythenClient mythenClient
      The Mythen client that actually interacts with the Mythen controller hardware.
    • deltaScannable

      protected Scannable deltaScannable
    • scannablesForHeader

      protected Map<Scannable,String> scannablesForHeader
      Map containing scannables to record position of in the header. key=scannable, value=label to use to annotate the value (optional, can be null)
    • dataConverter

      protected DataConverter dataConverter
      The converter that converts raw Mythen data (channel and count) to processed data (angle and count).
    • subDirectory

      protected String subDirectory
      The directory below the main data collection directory in which Mythen data files are saved.
    • numberOfModules

      protected int numberOfModules
    • atScanStartTasks

      protected List<ScanTask> atScanStartTasks
    • atPointEndTasks

      protected List<AtPointEndTask> atPointEndTasks
    • atScanEndTasks

      protected List<ScanTask> atScanEndTasks
    • rawData

      protected volatile MythenRawDataset rawData
      The most recently collected raw dataset.
    • rawFile

      protected volatile File rawFile
      File containing the most recently collected raw dataset.
    • processedData

      protected volatile MythenProcessedDataset processedData
      The most recently collected processed dataset.
    • processedFile

      protected volatile File processedFile
      File containing the most recently collected processed dataset.
    • scanNumber

      protected volatile long scanNumber
    • collectionFilename

      protected String collectionFilename
    • delta

      protected double delta
  • Constructor Details

    • MythenDetectorImpl

      public MythenDetectorImpl()
      Creates a new Mythen detector with a default collection time of 1s.
  • 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
    • addScannableForHeader

      public void addScannableForHeader(Scannable scn)
    • addScannableForHeader

      public void addScannableForHeader(Scannable scn, String userLabel)
    • clearScannablesForHeader

      public void clearScannablesForHeader()
    • getScannablesForHeader

      public Map<Scannable,String> getScannablesForHeader()
    • setScannablesForHeader

      public void setScannablesForHeader(Map<Scannable,String> scannablesForHeader)
    • setDetectorID

      public void setDetectorID(String detectorID)
      Sets the detector ID.
      Parameters:
      detectorID - the detector ID
    • setMythenClient

      public void setMythenClient(MythenClient mythenClient)
      Sets the Mythen client used by this Mythen detector object.
      Parameters:
      mythenClient - the Mythen client
    • setDeltaScannable

      public void setDeltaScannable(Scannable deltaScannable)
      Sets the Scannable representing the delta circle.
      Parameters:
      deltaScannable - the delta scannable
    • setDataConverter

      public void setDataConverter(DataConverter dataConverter)
      Sets the Mythen data converter used by this Mythen detector object.
      Parameters:
      dataConverter - the data converter
    • getDataConverter

      public DataConverter getDataConverter()
    • setSubDirectory

      public void setSubDirectory(String subDirectory)
    • getSubDirectory

      public String getSubDirectory()
    • getDataDirectory

      public File getDataDirectory()
      Returns the data directory into which Mythen data files will be written.
      Returns:
      the data directory
    • setNumberOfModules

      public void setNumberOfModules(int numberOfModules)
      Sets the number of modules in the detector.
    • setAtScanStartTasks

      public void setAtScanStartTasks(List<ScanTask> tasks)
      Sets the list of tasks that will be executed at the start of the scan.
    • setAtPointEndTasks

      public void setAtPointEndTasks(List<AtPointEndTask> tasks)
      Sets the list of tasks that will be executed after each point in the scan.
    • setAtScanEndTasks

      public void setAtScanEndTasks(List<ScanTask> tasks)
      Sets the list of tasks that will be executed at the end of the scan.
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • 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
    • 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:
    • getCurrentFilename

      public String getCurrentFilename()
    • buildFilenameWithoutSuffix

      protected String buildFilenameWithoutSuffix(int number)
    • buildFilenameWithoutSuffix

      protected String buildFilenameWithoutSuffix(String s)
    • buildFilename

      protected String buildFilename(int number, MythenDataFileUtils.FileType type)
    • buildRawFilename

      public String buildRawFilename(int number)
      rebuild Raw data file name added for Jython use as Jython does not support enum Java type yet.
      Parameters:
      number -
      Returns:
      filename
    • buildFilename

      protected String buildFilename(String s, MythenDataFileUtils.FileType type)
    • beforeCollectData

      protected void beforeCollectData() throws DeviceException
      Throws:
      DeviceException
    • beforeCollectData

      protected void beforeCollectData(long collectionNumber) throws DeviceException
      this method is developed for external scripting where the script control collection number.
      Parameters:
      collectionNumber -
      Throws:
      DeviceException
    • getHeaderStrings

      protected List<String> getHeaderStrings()
      Make list of additional header strings from positions of scannables.
    • updateDeltaPosition

      protected void updateDeltaPosition() throws DeviceException
      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
    • afterCollectData

      protected void afterCollectData()
    • readout

      public Object 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
      Returns:
      the data collected
      Throws:
      DeviceException
    • readoutProcessedData

      public MythenProcessedDataset readoutProcessedData()
      Description copied from interface: Mythen
      Reads out the processed data.
      Specified by:
      readoutProcessedData in interface Mythen
      Returns:
      the processed data
    • 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:
    • 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:
    • 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:
    • 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
    • getDescription

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

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

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

      public void setCollectionTime(double collectionTime) 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
      Overrides:
      setCollectionTime in class DetectorBase
      Parameters:
      collectionTime - the collection time in seconds
      Throws:
      DeviceException
    • multi

      public void multi(int numFrames, double delayBeforeFrames, double exposureTime, double delayAfterFrames) throws DeviceException
      Captures multiple frames using a software trigger.
      Throws:
      DeviceException
    • smulti

      public void smulti(int numFrames, double exposureTime, double delayAfterFrames) throws DeviceException
      Captures multiple frames using a single trigger to start acquisition of all frames.
      Throws:
      DeviceException
    • cmulti

      public void cmulti(int numFrames, double delayBeforeFrames, double exposureTime) throws DeviceException
      Captures multiple frames using one trigger per frame.
      Throws:
      DeviceException
    • gated

      public void gated(int numFrames, int numGates) throws DeviceException
      Throws:
      DeviceException
    • gated

      public void gated(int numGates) throws DeviceException
      Throws:
      DeviceException
    • gated

      public void gated(int numFrames, int numGates, long scanNumber, File dataDirectory, int collectionNumber) throws DeviceException
      Throws:
      DeviceException
    • gated

      public void gated(int numFrames, int numGates, long scanNumber) throws DeviceException
      gated multiple frames collection - one frame per file - where Mythen detector controls the frame number increment starting from 0. It launches only single textclient to collect multiple frames
      Parameters:
      numFrames -
      numGates -
      scanNumber -
      Throws:
      DeviceException
    • afterCollectData

      protected void afterCollectData(String collectionFilenameRoot, int numFiles)
      post processes of multiple frames collection and plotting them. this method is developed for external scripting use in which the collection file name is settable
      Parameters:
      collectionFilenameRoot -
    • atPointEnd

      public void atPointEnd(String filename, MythenProcessedDataset processedData, boolean clearFirst)
      plotting processed data.
      Parameters:
      filename -
      processedData -
      clearFirst -
    • gated

      public void gated(int numFrames, int numGates, long scanNumber, int collectionNumber) throws DeviceException
      gated multiple or single frame collection - one or more frames per file - where GDA controls the collection number increment.
      Parameters:
      numFrames -
      numGates -
      scanNumber -
      collectionNumber -
      Throws:
      DeviceException
    • afterCollectData

      protected void afterCollectData(File rawFile, int num)
    • isIncludeHeaders

      public boolean isIncludeHeaders()
    • setIncludeHeaders

      public void setIncludeHeaders(boolean includeHeaders)
    • plot

      public void plot(String filename, MythenProcessedDataset processedData, int num)
    • afterCollectData

      protected void afterCollectData(File rawFile, String collectionFilename)
      this method is developed for external scripting use in which the collection file name is settable
      Parameters:
      collectionFilename -
    • atPointEnd

      public void atPointEnd(String filename, MythenProcessedDataset processedData) throws DeviceException
      Throws:
      DeviceException
    • isHasChannelInfo

      public boolean isHasChannelInfo()
    • setHasChannelInfo

      public void setHasChannelInfo(boolean hasChannelInfo)