Package gda.scan
Class ScanBase
java.lang.Object
gda.scan.ScanBase
- All Implemented Interfaces:
NestableScan,Scan,ScanChild,Serializable
- Direct Known Subclasses:
AsynchronousTimeScan,CentroidScan,ConcurrentScanChild,GridScan,MultiRegionScan,MultiScan,PseudoDeviceTimeScan,StaticScan,TimeScan
Base class for objects using the Scan interface.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface gda.scan.Scan
Scan.ScanStatus -
Field Summary
FieldsModifier and TypeFieldDescriptionall the detectors being operated in this scan.all the scannables being operated in this scan, but *not* Detectors.protected booleanprotected Scanprotected StringCommand line.protected intCounter to get the current point number.static final Stringstatic final Stringprotected Stringinstrument name.protected booleanto allow nested scans to ignore the baton (as it will have already been taken)protected Stringunique identifier for this scanprotected intprotected NestableScanprotected ScanBase.ParentScanComponentprotected intprotected ScanDataPointPipelineUsed to broadcast points and to write them to a DataWriter.protected IScanStepIdprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidstatic ObjectcheckStartStopStep(Object startObj, Object stopObj, Object stepObj) Makes sure the step has the correct sign and that there are the same number of start, stop and step values.protected voidprotected voidThis should be called at each node of the scan.protected ScanDataPointprotected voidprotected voidcreateScanDataPointPipeline(DataWriter dataWriter) abstract voidThe method in which the work of the scan is performed.protected voidendScan()This should be called by all scans when they have finished, including when an exception has been raised.protected StringgetChild()Gets the reference to the dataHandler object which this scan uses.Returns the list of Detector objects which form part of the scan.intdefault implementation.protected int[]getName()Returns the unique identifier for this scan.intintReturns the ScanDataPoint pipeline.intReturns the list of all the Scannable objects which are part of this scanintprotected List<IScanStepId> intbooleanisChild()Returns true if this scan is nested inside another scan.booleanbooleanvoidnotifyServer(Object data) Deprecated.voidnotifyServer(Object source, Object data) Deprecated.Behaviour now inScanDataPointPipelineimplementationsintvoidpause()pause the scans progressprotected voidvoidThis should called by all scans just before they start to collect data.protected voidprotected voidprotected voidprotected voidSamples the position of Scannables (via getPosition()), readouts detectors (via readout) and creates a ScanDataPointprotected voidReadout detectors into ScanDataPoint and add to pipeline for possible completion and publishing.protected voidOrder the allScannables vector using the 'level' attribute.static StringReturn a string representation of an error in the form 'ExceptionTypeName:message'.voidSet this scan to complete current scan data point and complete normally without doing any further data points.voidresume()resume the scans progress after a pause has been calledfinal voidrun()allows the scan in its own thread.voidrunScan()Does the work of creating a new thread and calling the run() method.booleanReturns true if the scan baton has been claimed by a scan that has already started.protected voidsendScanEvent(ScanEvent.EventType reason) voidvoidsetDataWriter(DataWriter dataWriter) Gives the scan a reference to the DataWriter it should use to record data.voidsetDetectors(List<Detector> allDetectors) Sets the list of Detectors for this scan.voidsetIsChild(boolean child) Tells the scan if it is a child.voidsetLineScanNeedsDoing(boolean lineScanNeedsDoing) voidsetNumberOfChildScans(int numberOfChildScans) voidsetParent(NestableScan parent) voidsetPositionCallableThreadPoolSize(int positionCallableThreadPoolSize) voidsetScanDataPointPipeline(ScanDataPointPipeline scanDataPointPipeline) Sets the scan data point pipeline used to populate, write and broadcast ScanDataPoints.voidsetScanDataPointQueueLength(int scanDataPointQueueLength) protected voidvoidsetScannables(List<Scannable> allScannables) Sets the list of all the Scannable objects.voidsetScanNumber(int scanNumber) voidsetScanPlotSettings(ScanPlotSettings scanPlotSettings) voidsetStatus(Scan.ScanStatus status) voidsetStepId(IScanStepId stepId) protected voidsetUp()This should be called by all scans during their constructor.protected voidshutdownScandataPipeline(boolean waitForProcessingCompletion) protected voidprotected voidstatic ObjectsortArguments(Object startObj, Object stopObj, Object stepObj) Deprecated, for removal: This API element is subject to removal in a future version.callcheckStartStopStep(Object, Object, Object)insteadvoidBlocks while detectors are readout and point is added to pipeline (for the previous point).protected voidbooleanTrue if the scan was asked to complete earlyprotected static DeviceException
-
Field Details
-
GDA_SCANBASE_FIRST_SCAN_NUMBER_FOR_TEST
- See Also:
-
GDA_SCANBASE_PRINT_TIMESTAMP_TO_TERMINAL
- See Also:
-
allDetectors
all the detectors being operated in this scan. This list is generated from detectors inallScannablesandallDetectors. This list is to be used byDataHandlers when writing out the data. -
allScannables
all the scannables being operated in this scan, but *not* Detectors. for some scan types this may be a single scannable object. -
child
-
command
Command line. -
currentPointCount
protected int currentPointCountCounter to get the current point number. 0 based as for ScanDataPoint -
instrument
instrument name. -
isChild
protected boolean isChildto allow nested scans to ignore the baton (as it will have already been taken) -
name
unique identifier for this scan -
numberOfChildScans
protected int numberOfChildScans -
parent
-
permissionLevel
protected int permissionLevel -
scanDataPointPipeline
Used to broadcast points and to write them to a DataWriter. Created before a scan is run. -
stepId
-
totalNumberOfPoints
protected int totalNumberOfPoints -
callCollectDataOnDetectors
protected boolean callCollectDataOnDetectors -
parentComponent
-
-
Constructor Details
-
ScanBase
protected ScanBase()
-
-
Method Details
-
representThrowable
Return a string representation of an error in the form 'ExceptionTypeName:message'. Useful for e.g. logging. Works for exceptions thrown from Jython code, which would otherwise always contain a null message. -
getScanNumber
public int getScanNumber()- Specified by:
getScanNumberin interfaceScan- Returns:
- The unique id of the scan. Null if not set
-
setScanNumber
public void setScanNumber(int scanNumber) -
requestFinishEarly
public void requestFinishEarly()Description copied from interface:ScanSet this scan to complete current scan data point and complete normally without doing any further data points.- Specified by:
requestFinishEarlyin interfaceScan
-
isFinishEarlyRequested
public boolean isFinishEarlyRequested()- Specified by:
isFinishEarlyRequestedin interfaceScan
-
setStatus
-
getStatus
- Specified by:
getStatusin interfaceScan- Returns:
- The
Scan.ScanStatus
-
waitIfPaused
- Throws:
InterruptedException
-
scanRunning
public boolean scanRunning()Returns true if the scan baton has been claimed by a scan that has already started.- Returns:
- boolean
-
sortArguments
@Deprecated(forRemoval=true, since="9.33") public static Object sortArguments(Object startObj, Object stopObj, Object stepObj) Deprecated, for removal: This API element is subject to removal in a future version.callcheckStartStopStep(Object, Object, Object)insteadThis method is deprecated as it is misnamed, as it does in fact sort its arguments. Instead it returns a step size object with sign(s) corrected, and checks that -
checkStartStopStep
Makes sure the step has the correct sign and that there are the same number of start, stop and step values. Start, stop and step can be aNumberor either a list of array of numbers. It returns the correct step object, i.e. with the sign(s) corrected to be in the same direction as start -> stop.- Parameters:
startObj- start objectstopObj- stop objectstepObj- step object- Returns:
- the correct step object, with sign(s) corrected
-
callAtCommandFailureHooks
protected void callAtCommandFailureHooks() -
collectData
This should be called at each node of the scan. The collectData method is called for all detectors in the DetectorBase.ActiveDetectors static arraylist. Throws two types of errors as scans may want to handle these differently.NOTE: Used only by a few scans, not ScanBase or ConcurrentScan
- Throws:
Exception
-
setScanIdentifierInScanDataPoint
-
readDevicesAndPublishScanDataPoint
Samples the position of Scannables (via getPosition()), readouts detectors (via readout) and creates a ScanDataPoint- Throws:
Exception
-
createScanDataPoint
- Throws:
DeviceException
-
readoutDetectorsAndPublish
Readout detectors into ScanDataPoint and add to pipeline for possible completion and publishing.- Parameters:
point-- Throws:
Exception
-
waitForDetectorReadoutAndPublishCompletion
public void waitForDetectorReadoutAndPublishCompletion() throws InterruptedException, ExecutionExceptionBlocks while detectors are readout and point is added to pipeline (for the previous point). -
cancelReadoutAndPublishCompletion
protected void cancelReadoutAndPublishCompletion() -
wrappedException
-
createScanDataPointPipeline
- Throws:
Exception
-
createScanDataPointPipeline
-
doCollection
Description copied from interface:ScanThe method in which the work of the scan is performed. This method assumes that the data handler has already been created and the baton claimed.- Specified by:
doCollectionin interfaceScan- Throws:
Exception
-
endScan
This should be called by all scans when they have finished, including when an exception has been raised.- Throws:
DeviceExceptionInterruptedException
-
signalScanStarted
protected void signalScanStarted() -
signalScanComplete
protected void signalScanComplete() -
sendScanEvent
-
getScanInformation
- Specified by:
getScanInformationin interfaceScan
-
shutdownScandataPipeline
- Throws:
DeviceException
-
callDetectorsEndCollection
- Throws:
DeviceException
-
callScannablesAtScanEnd
- Throws:
DeviceException
-
callScannablesAtScanLineEnd
- Throws:
DeviceException
-
generateRandomName
-
getChild
-
getDataWriter
Gets the reference to the dataHandler object which this scan uses.- Specified by:
getDataWriterin interfaceScan- Returns:
- DataWriter
-
getDetectors
Description copied from interface:ScanReturns the list of Detector objects which form part of the scan.- Specified by:
getDetectorsin interfaceScan- Returns:
- Vector of Detectors
-
getDimension
public int getDimension()default implementation. Classes that derive from ScanBase which want to support the reporting of scan dimensions -@see getDimensions need to override this method- Specified by:
getDimensionin interfaceScan- Returns:
- the number of points of this scan object - the whole scan execution can be a hierarchy of parent scan objects and layers of child scan objects
- See Also:
-
getDimensions
protected int[] getDimensions()- Returns:
- the dimensions of the hierarchy of scan and child scans that together constitute an individual scan execution For a 1d scan of 10 points the return value is new int[]{10} For a 2d scan of 10 x 20 points the return value is new int[]{10,20}
-
getName
Returns the unique identifier for this scan. Nested (child) scans share the same identifier as their parents. -
getNumberOfChildScans
public int getNumberOfChildScans() -
getParent
-
getPositionCallableThreadPoolSize
public int getPositionCallableThreadPoolSize() -
getScanDataPointPipeline
Description copied from interface:ScanReturns the ScanDataPoint pipeline.- Specified by:
getScanDataPointPipelinein interfaceScan
-
getScanDataPointQueueLength
public int getScanDataPointQueueLength() -
getScannables
Description copied from interface:ScanReturns the list of all the Scannable objects which are part of this scan- Specified by:
getScannablesin interfaceScan- Returns:
- Vector of Scannables
-
getScanPlotSettings
- Specified by:
getScanPlotSettingsin interfaceScan- Returns:
- Settings for plotting
-
getStepId
-
getStepIds
-
getTotalNumberOfPoints
public int getTotalNumberOfPoints()- Specified by:
getTotalNumberOfPointsin interfaceScan- Returns:
- the total number of nodes at which data will be collected in this scan. This includes all the dimensions in a multi-dimensional scan.
-
isChild
public boolean isChild()Description copied from interface:ScanReturns true if this scan is nested inside another scan. -
isLineScanNeedsDoing
public boolean isLineScanNeedsDoing() -
notifyServer
Deprecated.Behaviour now inScanDataPointPipelineimplementationsGive the command server the latest data object to fan out to its observers.- Parameters:
data-
-
notifyServer
Deprecated.Behaviour now inScanDataPointPipelineimplementationsA better way to notify the observer which allows users to specify source of the data, not like the one above.- Parameters:
source-data-
-
numberOfScannablesThatCanProvidePositionCallables
public int numberOfScannablesThatCanProvidePositionCallables() -
pause
public void pause()Description copied from interface:Scanpause the scans progress -
prepareDevicesForCollection
- Throws:
Exception
-
callScannablesAtScanStart
- Throws:
DeviceException
-
callScannablesAtScanLineStart
- Throws:
DeviceException
-
prepareForCollection
This should called by all scans just before they start to collect data. It resets the static variable which the scan classes use and creates a dataHandler if one has not been created yet.- Specified by:
prepareForCollectionin interfaceScan- Throws:
Exception
-
prepareScanForCollection
- Throws:
Exception
-
prepareScanNumber
- Throws:
IOException
-
prepareStaticVariables
protected void prepareStaticVariables() -
reorderScannables
protected void reorderScannables()Order the allScannables vector using the 'level' attribute. -
resume
public void resume()Description copied from interface:Scanresume the scans progress after a pause has been called -
run
Description copied from interface:Scanallows the scan in its own thread. This should NOT be called directly otherwise this may cause thread handling issues and instability in the command server. runScan() should be called instead. -
runScan
Description copied from interface:ScanDoes the work of creating a new thread and calling the run() method. Inheriting classes may also declare a runScan method with arguments identical to their constructor. The convention would be to create a new scan object, and then call this runScan method.- Specified by:
runScanin interfaceScan- Throws:
InterruptedExceptionException
-
setChild
-
setDataWriter
Description copied from interface:ScanGives the scan a reference to the DataWriter it should use to record data. This will create a new ScanDataPointPipeline appropriate for the Scannables to be scanned.- Specified by:
setDataWriterin interfaceScan- Parameters:
dataWriter-
-
setDetectors
Description copied from interface:ScanSets the list of Detectors for this scan.- Specified by:
setDetectorsin interfaceScan- Parameters:
allDetectors-- See Also:
-
setIsChild
public void setIsChild(boolean child) Description copied from interface:ScanTells the scan if it is a child.- Specified by:
setIsChildin interfaceScan- Parameters:
child-
-
setLineScanNeedsDoing
public void setLineScanNeedsDoing(boolean lineScanNeedsDoing) -
setNumberOfChildScans
public void setNumberOfChildScans(int numberOfChildScans) -
setParent
-
setPositionCallableThreadPoolSize
public void setPositionCallableThreadPoolSize(int positionCallableThreadPoolSize) -
setScanDataPointPipeline
Description copied from interface:ScanSets the scan data point pipeline used to populate, write and broadcast ScanDataPoints. Should not normally be set directly except on a child (or sub) scan.- Specified by:
setScanDataPointPipelinein interfaceScan- Parameters:
scanDataPointPipeline-
-
setScanDataPointQueueLength
public void setScanDataPointQueueLength(int scanDataPointQueueLength) -
setScannables
Description copied from interface:ScanSets the list of all the Scannable objects. This should only be used for a parent scan giving its list to a child scan and not for setting up a scan (that work is done by ScanBase.setUp).- Specified by:
setScannablesin interfaceScan- Parameters:
allScannables-
-
setScanPlotSettings
- Specified by:
setScanPlotSettingsin interfaceScan
-
setStepId
-
setUp
protected void setUp()This should be called by all scans during their constructor. In this method the objects to scan over and the detectors to use are identified, and the data handlers objects are created and setup. -
wasScanExplicitlyHalted
public boolean wasScanExplicitlyHalted()True if the scan was asked to complete early -
checkThreadInterrupted
- Throws:
InterruptedException
-
ScanDataPointPipelineimplementations