Class Xspress4Detector
- All Implemented Interfaces:
Detector,NexusDetector,Device,Scannable,Configurable,Findable,gda.observable.IObservable,Serializable,DetectorWithConfigurationFile,FluorescenceDetector
- Direct Known Subclasses:
Xspress4OdinDetector
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
XSpress2Xspress4Controller.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTrigger modes (caget -d31 BL20I-EA-XSP4-01:TriggerMode). -
Field Summary
Fields inherited from class gda.device.detector.DetectorBase
collectionTimeFields inherited from class gda.device.scannable.ScannableBase
__doc__, DEFAULT_INPUT_NAME, DEFAULT_OUTPUT_FORMAT, extraNames, inputNames, level, outputFormatFields inherited from class gda.device.DeviceBase
DEFAULT_PROTECTION_LEVEL_PROPERTYFields inherited from interface gda.device.Scannable
ATTR_NEXUS_CATEGORY, ATTR_NX_CLASS, DEFAULT_INPUT_NAME, VALUE_UNAVAILABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidacquireFrameAndWait(double collectionTimeMillis, double timeoutMillis) Acquire new frame of data on detector and wait until it's finished.protected voidacquireMcaData(double timeMs) Acquire MCA data on detector and wait.protected voidaddLinkToNexusFile(String hdfFileFullName, String pathToDataInHdfFile, String linkName) voidConfigure detector using current set of parametersvoidConfigure the detector using the given parametersvoidHook to be used by Scan and pos commands to inform the Scannable that an exception, such as a DeviceExcpetion, has occurred.voidCalled on every Scannable at the end of every data point, for scans which are broken down into individual points (i.e.voidCalled on every Scannable at every data point, for scans which are broken down into individual points (i.e.voidCalled for every Scannable at the end of a group of nested scans (or a single scan if that is the case).voidCalled for every Scannable at the start of a group of nested scans (or a single scan if that is the case)protected voidvoidTells the detector to begin to collect a set of data, then returns immediately.voidDefault 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.booleanReturns a value which indicates whether the detector creates its own files.Generate name of Hdf file for current scan usingXspress3Detector.XspressHelperMethods.getFilePrefix(String)with current value ofgetFilePrefix()Create name of path to where hdf will be written.double[]doubleString[]Additional names for extra values that returned by getPosition().doublegetI0()Get I0 value from TfgScaler of FFI0 device.Double[]Return array used byto update view with latest data.invalid reference
MonitorViewBaseintintdouble[][]getMCAData(double timeMillis) Perform a 'snapshot' data collection and return the MCA data.intlongintintString[]Returns an array of strings which are the format strings to use when pretty printing parts of the outputintlongintReturns the current collecting state of the device.Return the current trigger mode setting by reading from PV.booleanbooleanvoidloadConfigurationFromFile(String configFilename) voidloadDeadtimeParametersFromFile(String configFilename) readout()Returns the latest data collected as well as general detector informationvoidsetAcquireTime(double time) voidsetAsciiScalerNameIndexMap(Map<String, Integer> asciiScalerNameIndexMap) voidsetConfigFileName(String configFileName) voidsetController(Xspress4Controller controller) voidsetDeadtimeFileName(String dtcParametersFileName) voidsetDeadtimeParameters(XspressDeadTimeParameters deadtimeParameters) voidvoidsetDefaultSubdirectory(String defaultSubDirectory) Set a subdirectory to use when writing the hdf files.voidsetDtcEnergyKev(double dtcEnergy) voidsetFilePath(String filePath) voidsetFilePrefix(String filePrefix) voidsetMaxNumberOfRois(int maxRois) voidsetMaxRetries(int maxRetries) voidsetMcaReadoutWaitTimeMs(long waitTimeMs) voidsetOutputFormat(String[] outputFormat) Sets the array of strings describing how best to format the positions from this scannablevoidsetRetryDelayMs(long retryDelayMs) voidsetScalerNameIndexMap(Map<String, Integer> scalerIndexMap) voidsetScalerWindow(int windowNumber) Apply current set of scaler window parameters to detector (window start, end)voidSet scaler windows using values in ROI settingsvoidsetTfgFFI0(TfgFFoverI0 tfgFFI0) voidsetTriggerMode(int intMode) Set the current trigger mode on the detector by using integer rather thanXspress4Detector.TriggerModeenum.voidSet the current trigger mode on the detectorvoidsetTriggerModeForScans(int intMode) Set the trigger mode to be used when doing scans - usually 3 (TtlVeto) or 0 (Software) This is applied inatScanStart().voidvoidsetupHdfWriter(int numberOfFramesToCollect) Set the number of frames to collect, the default file path and default file name in the Hdf writer plugin.voidsetupNumFramesToCollect(int numberOfFramesToCollect) voidsetWindowSettingUsesThreads(boolean windowSettingUsesThreads) voidsetWriteHDF5Files(boolean writeHdfFiles) Set to true to configure the detector to write an HDF5 file during a scan.voidStart the detector and hdf writer (and Odin metawriter)voidstop()Stop the current move/operation.voidstopDetector(boolean waitForStop) Stop the detector and hdf writer (and Odin metawriter), optionally wait for the detector to become idle.protected voidWait for Hdf file writing to flush the final frame of data.voidMethods inherited from class gda.device.detector.DetectorBase
asynchronousMoveTo, checkPositionValid, endCollection, getCollectionTime, getDataDimensions, getDescription, getDetectorID, getDetectorType, getPosition, isBusy, prepareForCollection, setCollectionTime, toFormattedStringMethods inherited from class gda.device.scannable.ScannableBase
__call__, __call__, __doc__, __getitem__, __len__, __repr__, __str__, atLevelEnd, atLevelMoveStart, atLevelStart, atScanLineEnd, atScanLineStart, externalToInternal, getInputNames, getLevel, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, internalToExternal, isAt, moveTo, rawAsynchronousMoveTo, rawGetPosition, setExtraNames, setInputNames, setLevel, setScanMetadataAttribute, setScanMetadataAttributes, throwExceptionIfInvalidTarget, toString, validateScannable, valueUnavailableString, waitWhileBusy, waitWhileBusyMethods inherited from class gda.device.DeviceBase
addIObserver, close, deleteIObserver, deleteIObservers, getAttribute, getName, getProtectionLevel, isBeingObserved, isConfigureAtStartup, notifyIObservers, setAttribute, setConfigureAtStartup, setName, setProtectionLevelMethods inherited from class gda.factory.ConfigurableBase
isConfigured, reconfigure, setConfiguredMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface gda.factory.Configurable
isConfigureAtStartup, isConfigured, reconfigureMethods inherited from interface gda.device.Detector
endCollection, getCollectionTime, getDataDimensions, getDescription, getDetectorID, getDetectorType, getFileStructure, prepareForCollection, setCollectionTime, waitWhileBusyMethods inherited from interface gda.device.Device
close, getAttribute, getProtectionLevel, setAttribute, setProtectionLevelMethods inherited from interface gda.observable.IObservable
addIObserver, deleteIObserver, deleteIObserversMethods inherited from interface gda.device.Scannable
asynchronousMoveTo, atLevelEnd, atLevelMoveStart, atLevelStart, atScanLineEnd, atScanLineStart, checkPositionValid, getInputNames, getLevel, getPosition, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, isAt, isBusy, moveTo, setExtraNames, setInputNames, setLevel, setScanMetadataAttribute, setScanMetadataAttributes, toFormattedString
-
Constructor Details
-
Xspress4Detector
public Xspress4Detector()
-
-
Method Details
-
configure
Description copied from class:ConfigurableBaseDefault 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:
configurein interfaceConfigurable- Overrides:
configurein classConfigurableBase- 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
-
getController
-
stopDetector
Stop the detector and hdf writer (and Odin metawriter), optionally wait for the detector to become idle.- Parameters:
waitForStop-- Throws:
DeviceException
-
startDetector
Start the detector and hdf writer (and Odin metawriter)- Throws:
DeviceException
-
atScanStart
Description copied from class:ScannableBaseCalled 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:
atScanStartin interfaceScannable- Overrides:
atScanStartin classScannableBase- Throws:
DeviceException- See Also:
-
setupNumFramesToCollect
- Throws:
DeviceException
-
setupHdfWriter
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
Create name of path to where hdf will be written. By callingXspress3Detector.XspressHelperMethods.getFilePath(String, String)with the currently set values fromgetFilePath()andgetFilePrefix()- Returns:
-
generateDefaultHdfFileName
Generate name of Hdf file for current scan usingXspress3Detector.XspressHelperMethods.getFilePrefix(String)with current value ofgetFilePrefix()- Returns:
-
waitForFileWriter
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
Description copied from class:ScannableBaseCalled 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:
atScanEndin interfaceScannable- Overrides:
atScanEndin classScannableBase- Throws:
DeviceException- See Also:
-
addLinkToNexusFile
-
atCommandFailure
Description copied from class:ScannableBaseHook 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 onlyScannable.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:
atCommandFailurein interfaceScannable- Overrides:
atCommandFailurein classScannableBase- Throws:
DeviceException- See Also:
-
atPointEnd
Description copied from class:ScannableBaseCalled 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:
atPointEndin interfaceScannable- Overrides:
atPointEndin classScannableBase- Throws:
DeviceException- See Also:
-
acquireFrameAndWait
- 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
Description copied from class:ScannableBaseCalled 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:
atPointStartin interfaceScannable- Overrides:
atPointStartin classScannableBase- Throws:
DeviceException- See Also:
-
stop
Description copied from class:ScannableBaseStop 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:
stopin interfaceScannable- Overrides:
stopin classScannableBase- Throws:
DeviceException- See Also:
-
waitForMcaCollection
- Throws:
DeviceException
-
getStatus
Description copied from interface:DetectorReturns the current collecting state of the device.- Specified by:
getStatusin interfaceDetector- 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
Description copied from interface:DetectorTells 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:
collectDatain interfaceDetector- Throws:
DeviceException
-
createsOwnFiles
Description copied from interface:DetectorReturns 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:
createsOwnFilesin interfaceDetector- Returns:
- true if readout() returns filenames
- Throws:
DeviceException
-
getMCAData
Description copied from interface:FluorescenceDetectorPerform a 'snapshot' data collection and return the MCA data. No file writing is involved.- Specified by:
getMCADatain interfaceFluorescenceDetector- Parameters:
timeMillis- The collection time in milliseconds- Returns:
- the MCA data as a double array: [detector element][MCA channel]
- Throws:
DeviceException
-
acquireMcaData
Acquire MCA data on detector and wait.- Parameters:
timeMs- collection time (milliseconds)- Throws:
InterruptedExceptionDeviceException
-
getNumberOfElements
public int getNumberOfElements()- Specified by:
getNumberOfElementsin interfaceFluorescenceDetector- 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:
getMCASizein interfaceFluorescenceDetector- Returns:
- The number of channels in the MCA (Multi-Channel Analyser)
-
getMaxNumberOfRois
public int getMaxNumberOfRois()- Specified by:
getMaxNumberOfRoisin interfaceFluorescenceDetector- Returns:
- The maximum number of ROIs per channel
-
setMaxNumberOfRois
public void setMaxNumberOfRois(int maxRois) -
getConfigurationParameters
- Specified by:
getConfigurationParametersin interfaceFluorescenceDetector- Returns:
- The current detector configuration
-
getConfigFileName
- Specified by:
getConfigFileNamein interfaceDetectorWithConfigurationFile
-
setConfigFileName
- Specified by:
setConfigFileNamein interfaceDetectorWithConfigurationFile
-
setDeadtimeFileName
-
getDeadtimeFileName
-
getExtraNames
Description copied from interface:ScannableAdditional names for extra values that returned by getPosition().- Specified by:
getExtraNamesin interfaceScannable- Overrides:
getExtraNamesin classScannableBase- Returns:
- array of names of the extra elements if the array returned by getPosition is larger than the array required by moveTo
-
getOutputFormat
Description copied from interface:ScannableReturns an array of strings which are the format strings to use when pretty printing parts of the output- Specified by:
getOutputFormatin interfaceScannable- Overrides:
getOutputFormatin classScannableBase- Returns:
- string array
-
setOutputFormat
Description copied from interface:ScannableSets the array of strings describing how best to format the positions from this scannable- Specified by:
setOutputFormatin interfaceScannable- Overrides:
setOutputFormatin classScannableBase- Parameters:
outputFormat-
-
getMcaGrades
public int getMcaGrades() -
setScalerNameIndexMap
-
getScalerNameIndexMap
-
getAsciiScalerNameIndexMap
-
setAsciiScalerNameIndexMap
-
loadConfigurationFromFile
-
loadDeadtimeParametersFromFile
-
getDeadtimeParameters
-
setDeadtimeParameters
-
getResolutionThreshold
public int getResolutionThreshold() -
setupCurrentSettings
public void setupCurrentSettings() -
applyConfigurationParameters
public void applyConfigurationParameters(FluorescenceDetectorParameters parameters) throws Exception Description copied from interface:FluorescenceDetectorConfigure the detector using the given parameters- Specified by:
applyConfigurationParametersin interfaceFluorescenceDetector- Parameters:
parameters-- Throws:
Exception
-
applyConfigurationParameters
Configure detector using current set of parameters- Throws:
Exception
-
setScalerWindow
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
Set scaler windows using values in ROI settings- Throws:
DeviceException
-
setDefaultScalerIndexMap
public void setDefaultScalerIndexMap() -
getLiveStats
Return array used byto update view with latest data. Need to return 2d array with 3 columns (total counts, deadtime correction factor, unused column)invalid reference
MonitorViewBase- Throws:
DeviceException
-
getDeadtimeCorrectionFactors
- Specified by:
getDeadtimeCorrectionFactorsin interfaceFluorescenceDetector- Returns:
- An array of 'deadtime correction' factor values (one for each element of the detector)
- Throws:
DeviceException
-
readout
Description copied from interface:NexusDetectorReturns the latest data collected as well as general detector information- Specified by:
readoutin interfaceDetector- Specified by:
readoutin interfaceNexusDetector- Returns:
- the data collected
- Throws:
DeviceException
-
setTriggerModeForScans
Set the trigger mode to be used when doing scans - usually 3 (TtlVeto) or 0 (Software) This is applied inatScanStart().- Parameters:
intMode-- Throws:
DeviceException
-
getTriggerModeForScans
- Throws:
DeviceException
-
setTriggerMode
Set the current trigger mode on the detector- Parameters:
mode-- Throws:
DeviceException
-
setTriggerMode
Set the current trigger mode on the detector by using integer rather thanXspress4Detector.TriggerModeenum.Xspress4Detector.TriggerModeenum value set is TriggerMode.values()[intMode];- Parameters:
intMode-- Throws:
IOExceptionDeviceException
-
getTriggerMode
Return the current trigger mode setting by reading from PV.- Returns:
- Throws:
IOExceptionDeviceException
-
getTfgFFI0
-
setTfgFFI0
-
getI0
public double getI0()Get I0 value from TfgScaler of FFI0 device. This is used form nomalising the res_bin_norm values in. Use value of 1 if FFI0 is not available or it throws an exception.invalid reference
#addResolutionGradeData- Returns:
- I0 value
-
setAcquireTime
- Throws:
DeviceException
-
setDtcEnergyKev
- Throws:
DeviceException
-
getDtcEnergyKev
- Throws:
DeviceException
-
setWriteHDF5Files
public void setWriteHDF5Files(boolean writeHdfFiles) Description copied from interface:FluorescenceDetectorSet to true to configure the detector to write an HDF5 file during a scan.- Specified by:
setWriteHDF5Filesin interfaceFluorescenceDetector- Parameters:
writeHdfFiles-
-
isWriteHDF5Files
public boolean isWriteHDF5Files()- Specified by:
isWriteHDF5Filesin interfaceFluorescenceDetector- 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
-
setFilePath
-
getFilePrefix
-
setFilePrefix
-
getDefaultSubdirectory
-
setDefaultSubdirectory
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 (usingsetFilePath(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)
-