Class ScannableBase
- All Implemented Interfaces:
Device,Scannable,Configurable,Findable,gda.observable.IObservable
- Direct Known Subclasses:
AbstractKeithley2600Series,AbstractKeithley6400Series,AgilentWaveform,AlignmentStageScannable,Apple2IDScannableBase,AsciiFileProcessor,BaseChipRegScannable,BeamDimensions,BeamlineConditionMonitorBase,BimorphMirrorScannable,BSSCScannable,CameraXYScannable,CombinedManipulator,CurrentAmplifierBase,DAServerStatusChecker,DetectorBase,DetectorDistance,DetectorMonitorDataProvider,DummyEpicsLakeshore336,DummyLakeshoreScannable,DummyPersistentEnumScannable,DummySampleWheel,DummySpinner,DummyTopupScannable,EH2ShutterControl,EigerThresholdScannable,EnergyScannable,EnergyScannable,EnumPositionerBase,EpicsBpmController,EpicsCurrAmpGain,EpicsDouble,EpicsEurotherm903,EpicsLakeshore336,EpicsRecord,EpicsSimpleArray,Eurotherm,ExafsScannable,ExperimentShutterController,ExternalSourceWrapper,FastAttenuatorFilters,FastAttenuatorScannable,FrameIndexer,GainWithScalingAndOffset,GasInjectionScannable,GasInjectionScannable,GasInjectionScannablePumpOn,HidenRGAScannable,I05Apple,I11Robot,JEPScannable,Keyence,Lakeshore340Scannable,LakeshoreScannable,LakeshoreScannable,Ln2Scannable,MecaRobotMover,MetashopDataScannable,MirrorCoating,MirrorInOut,MonitorBase,MonitorZebraAndMoveScannable,MonoCoolScannable,PolarisationScannable,PositionerDeterminedScannable,PowerSupplyScannable,PressureCell,PulseTubeMeta,PVScannable,RotatedXyScannable,RotationAxisXScannable,SamplePlateMoverBase,SampleWheel,ScaledScannable,ScanEventHandlerScannable,ScannableGaussian,ScannableGroup,ScannableMotionBase,ScriptAdapter,ShutterChecker,ShutterOpenClose,SimplePVScannable,SimpleScannable,SimpleScannable,SimpleUDPServerScannable,Spin,Spinner,StringValueScannable,TestingEurotherm,TimeDelayScannable,TimeScannable,TimeTravelScannable,TogglerScannable,TwoDScanPlotter,WheelAttenuators,XasProgressUpdater,XasScannable,XpsConstantVelocityMoveController,XspressFillMonitor,XspressHdfWriter,ZebraConstantVelocityMoveController,ZebraMonitorController,ZebraScannableMonitor
Scannable Device.
Routes calls to asynchronousMoveTo through an externalToInternal method to rawAsynchronousMoveTo; and, vice-versa, calls to getPosition through an internalToExternal method from rawGetPosition. The protected methods externalArrayToInternal and internalArraytoExternal should be overridden to provide automated support for things such as offsets and unit conversion. By default they do nothing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringThis is the Jython documentation.static final Stringstatic final Stringprotected String[]Array names for additional readout elements of this Scannable.protected String[]Array names for the positioner elements in this Scannable.protected intThe move priority for this Scannableprotected String[]Array of strings which specify the format to output when getting the position of this Scannable.Fields inherited from class gda.device.DeviceBase
DEFAULT_PROTECTION_LEVEL_PROPERTYFields inherited from interface gda.device.Scannable
ATTR_NEXUS_CATEGORY, ATTR_NX_CLASS, VALUE_UNAVAILABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.python.core.PyObject__call__()org.python.core.PyObject__call__(org.python.core.PyObject new_position) Moves the scannable to new_position when a scannable(new_position) call is made from Python__doc__()org.python.core.PyObject__getitem__(org.python.core.PyObject index) int__len__()__repr__()Jython method to return a string representation of the object__str__()Jython method to return string description of the objectvoidasynchronousMoveTo(Object externalPosition) Trigger a move/operation and return immediately.voidHook to be used by Scan and pos commands to inform the Scannable that an exception, such as a DeviceExcpetion, has occurred.voidDefault behaviour is to do nothing.voidCalled by both the pos and scan commands at the start of each subsequent level move only on Scannables that will be moved as part that level's movement.voidCalled by both the pos and scan commands at the start of each subsequent level move on all Scannables that are part that level's movement.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 end of every scanvoidCalled for every Scannable at the start of every scanvoidCalled for every Scannable at the start of a group of nested scans (or a single scan if that is the case)checkPositionValid(Object illDefinedPosObject) This default behaviour should be extended by most subclasses! Tests if the given object is meaningful to this Scannable and so could be used by one of the move commands.externalToInternal(Object externalPosition) Converts a position in its external representation to its internal representation.String[]Additional names for extra values that returned by getPosition().String[]gets a array of InputNames used by moveTo of this scannable.intgetLevel()get the operation level of this scannable.String[]Returns an array of strings which are the format strings to use when pretty printing parts of the outputReturns the current position of the Scannable.getScanMetadataAttribute(String attributeName) Returns the value of the scan attribute, ornullif no such attribute exists (or if the value of the attribute isnull) The type of the value returned can be: a dataset; a primitive type supported by datasets; an array whose component type that is supported by datasets; a list whose element type is supported by datasets.Returns the name of the scan attributes.internalToExternal(Object internalPosition) Converts a position in its internal representation to its external representation.booleanTests if the scannable is at (or if appropriate, close to) the value positionToTest.voidTrigger a move/operation and block until completion.voidrawAsynchronousMoveTo(Object position) [Consider abstract] Trigger a move/operation to an internal/hardware position and return immediately.[Consider abstract] Read the position in its internal (user) representation.voidsetExtraNames(String[] names) Sets the array of names returned by getExtraNames of this scannable.voidsetInputNames(String[] names) sets the array of names returned by getInputNames method of this scannable.voidsetLevel(int level) Used for ordering the operations of Scannables during scansvoidsetOutputFormat(String[] names) Sets the array of strings describing how best to format the positions from this scannablevoidsetScanMetadataAttribute(String attributeName, Object value) Sets the scan attribute with the given name to the given value.voidsetScanMetadataAttributes(Map<String, Object> attributes) voidstop()Stop the current move/operation.protected voidthrowExceptionIfInvalidTarget(Object position) Returns a string representation of the Scannable and its current position/value/statustoString()static voidvalidateScannable(Scannable scannable) This performs a series of tests to check that the internal setup of the Scannable is consistent.protected StringName/value string that can be used by toFormattedString() when getting current value/position failsvoidReturns when operation carried out by moveTo has completedvoidwaitWhileBusy(double timeoutInSeconds) Its like waitWhileBusy, has a timeout and will throws a DeviceException if the time limit is reached.Methods 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
configure, 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
configure, isConfigureAtStartup, isConfigured, reconfigureMethods inherited from interface gda.device.Device
close, getAttribute, getProtectionLevel, setAttribute, setProtectionLevelMethods inherited from interface gda.observable.IObservable
addIObserver, deleteIObserver, deleteIObservers
-
Field Details
-
DEFAULT_INPUT_NAME
- See Also:
-
DEFAULT_OUTPUT_FORMAT
- See Also:
-
__doc__
This is the Jython documentation. Use it in the GDA Jython via the help command. -
level
protected int levelThe move priority for this Scannable -
inputNames
Array names for the positioner elements in this Scannable. -
extraNames
Array names for additional readout elements of this Scannable. -
outputFormat
Array of strings which specify the format to output when getting the position of this Scannable.
-
-
Constructor Details
-
ScannableBase
public ScannableBase()
-
-
Method Details
-
validateScannable
This performs a series of tests to check that the internal setup of the Scannable is consistent. It does not and should not operate the scannable by calling getPosition().It will set the internal arrays of strings to defaults to prevent NPE where appropriate.
- Parameters:
scannable-- Throws:
DeviceException
-
asynchronousMoveTo
Trigger a move/operation and return immediately. Implementations of this method should be non-blocking to allow concurrent motion; the isBusy method will be used to determine when the move has completed. Converts the external (user) position to an internal position and passes this to rawAsynchronousMoveTo.- Specified by:
asynchronousMoveToin interfaceScannable- Parameters:
externalPosition- Position to move to should have an element for each input field.- Throws:
DeviceException
-
getPosition
Returns the current position of the Scannable. Called by ConcurentScan at the end of the point. Reads an internal (hardware) position from rawGetPosition, converts this to an external (user) position and returns it.- Specified by:
getPositionin interfaceScannable- Returns:
- Current position with an element for each input and extra field. null if their are no fields.
- Throws:
DeviceException
-
rawAsynchronousMoveTo
[Consider abstract] Trigger a move/operation to an internal/hardware position and return immediately.- Parameters:
position- Position in its internal/hardware representation. e.g. with units and offsets removed- Throws:
DeviceException- See Also:
-
rawGetPosition
[Consider abstract] Read the position in its internal (user) representation.- Returns:
- the value represented by this Scannable
- Throws:
DeviceException- See Also:
-
externalToInternal
Converts a position in its external representation to its internal representation.Verifies that the object (represented as an array) has the same number of fields as the scannable has input fields, or the total number of fields of the scannable. The later allows scripts to provide the output of getPosition to moveTo methods, e.g. "pos scannable_with_extra_fields scannable_with_extra_fields()".
- Parameters:
externalPosition- an object array if the Scannable has multiple input fields, otherwise an object. The length must match the number of the Scannables input fields.- Returns:
- an object array if the Scannable has multiple input fields, otherwise an object. The length will match the number of the Scannables input fields.
-
internalToExternal
Converts a position in its internal representation to its external representation.Verifies that the object (represented as an array) has the same number of fields as the scannable.
- Parameters:
internalPosition-- Returns:
- an object array if the scannable has multiple fields, otherwise an object.
-
atPointEnd
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:
atPointEndin interfaceScannable- Throws:
DeviceException- See Also:
-
atPointStart
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:
atPointStartin interfaceScannable- Throws:
DeviceException- See Also:
-
atScanLineEnd
Called for every Scannable at the end of every scan Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.- Specified by:
atScanLineEndin interfaceScannable- Throws:
DeviceException- See Also:
-
atScanEnd
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:
atScanEndin interfaceScannable- Throws:
DeviceException- See Also:
-
atLevelStart
Called by both the pos and scan commands at the start of each subsequent level move on all Scannables that are part that level's movement.This provides a useful mechanism for e.g. creating a Scannable that opens a shutter after motors have moved but before a detector is exposed. Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.
- Specified by:
atLevelStartin interfaceScannable- Throws:
DeviceException- See Also:
-
atLevelMoveStart
Called by both the pos and scan commands at the start of each subsequent level move only on Scannables that will be moved as part that level's movement.For example "pos a 1 b 2 c 3", will, if a and b have the same level and c a higher level will result in:
This hook is used by CoordinatedMotionScannables. Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.a.atLevelMoveStart() invalid input: '<'---- b.atLevelMoveStart() invalid input: '<'---- a.asynchronousMoveTo() b.asynchronousMoveTo() a.waitWhileBusy() b.waitWhileBusy() c.atLevelMoveStart() invalid input: '<'---- c.asynchronousMoveTo() c.waitWhileBusy()
- Specified by:
atLevelMoveStartin interfaceScannable- Throws:
DeviceException- See Also:
-
atLevelEnd
Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.- Specified by:
atLevelEndin interfaceScannable- Throws:
DeviceException- See Also:
-
atCommandFailure
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 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- Throws:
DeviceException- See Also:
-
atScanStart
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:
atScanStartin interfaceScannable- Throws:
DeviceException- See Also:
-
atScanLineStart
Called for every Scannable at the start of every scan Default behaviour is to do nothing. Inheriting classes have the option to implement this if their specific behaviour requires it.- Specified by:
atScanLineStartin interfaceScannable- Throws:
DeviceException- See Also:
-
getExtraNames
Description copied from interface:ScannableAdditional names for extra values that returned by getPosition().- Specified by:
getExtraNamesin interfaceScannable- Returns:
- array of names of the extra elements if the array returned by getPosition is larger than the array required by moveTo
-
getInputNames
Description copied from interface:Scannablegets a array of InputNames used by moveTo of this scannable.- Specified by:
getInputNamesin interfaceScannable- Returns:
- array of the names of the elements of the object returned by getPosition
-
getLevel
public int getLevel()Description copied from interface:Scannableget the operation level of this scannable. -
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- Returns:
- string array
-
moveTo
Trigger a move/operation and block until completion. If this is overridden, asynchronousMoveTo must also be valid, and the externalToInternal conversion must be applied.- Specified by:
moveToin interfaceScannable- Parameters:
position-- Throws:
DeviceException
-
setExtraNames
Description copied from interface:ScannableSets the array of names returned by getExtraNames of this scannable.- Specified by:
setExtraNamesin interfaceScannable- Parameters:
names-
-
setInputNames
Description copied from interface:Scannablesets the array of names returned by getInputNames method of this scannable.- Specified by:
setInputNamesin interfaceScannable- Parameters:
names-
-
setLevel
public void setLevel(int level) Description copied from interface:ScannableUsed for ordering the operations of Scannables during scans -
setOutputFormat
Description copied from interface:ScannableSets the array of strings describing how best to format the positions from this scannable- Specified by:
setOutputFormatin interfaceScannable- Parameters:
names-
-
stop
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:
stopin interfaceScannable- Throws:
DeviceException- See Also:
-
toString
-
toFormattedString
Description copied from interface:ScannableReturns a string representation of the Scannable and its current position/value/statusTypically should return:
name : position
or for detectors, name : status
If the position/status cannot be determined, the function should return
Scannable.VALUE_UNAVAILABLEin its place.- Specified by:
toFormattedStringin interfaceScannable- Returns:
- string as defined above
-
waitWhileBusy
Returns when operation carried out by moveTo has completed If this is to be overriden, isBusy must also be valid. Although the pos and scan command currently use this method to determine if the Scannable is busy, this must not be relied upon.- Specified by:
waitWhileBusyin interfaceScannable- Throws:
DeviceExceptionInterruptedException
-
waitWhileBusy
Its like waitWhileBusy, has a timeout and will throws a DeviceException if the time limit is reached.- Parameters:
timeoutInSeconds-- Throws:
DeviceExceptionInterruptedException
-
checkPositionValid
This default behaviour should be extended by most subclasses! Tests if the given object is meaningful to this Scannable and so could be used by one of the move commands. May check limits and other things too. This is the method called by scans on all points before the scan is run.- Specified by:
checkPositionValidin interfaceScannable- Parameters:
illDefinedPosObject-- Returns:
- null if position is valid, or returns a description if not.
- Throws:
DeviceException- See Also:
-
throwExceptionIfInvalidTarget
- Throws:
DeviceException
-
isAt
Tests if the scannable is at (or if appropriate, close to) the value positionToTest. If positionToTest is a string (as will be the case for valves or pneumatics for example), this is compared to the value obtained from getPosition(). An exception is thrown if this is not also a string.Otherwise if positionToTest is not a string the object is compared to the value from getPosition(), after having first pushed both values through objectToArray() from ScannableUtils.
This behaviour should be extended where possible, and has been in ScannableMotionBase
- Specified by:
isAtin interfaceScannable- Parameters:
positionToTest- The position to compare the scannable's position to.- Returns:
- true if scannable is at positionToTest
- Throws:
DeviceException- See Also:
-
setScanMetadataAttribute
Sets the scan attribute with the given name to the given value. A scan attribute is an attribute that should be written into the scan output (e.g. a NeXus file). The type of the value can be:- a dataset;
- a primitive type supported by datasets;
- an array whose component type that is supported by datasets;
- a list whose element type is supported by datasets.
There are two special attributes, 'NXclass' and 'nexusCategory'. If set these attributes are not written into the nexus file as fields. Instead the control how the nexus object is created and added to the nexus tree. Specifically:
- 'NXclass' specifies what Nexus base class the nexus object has;
- 'nexusCategory' specifies the class of the parent group the nexus object is added to, e.g. if this attribute has the value 'NXsample' then the nexus object will be added to the NXsample group.
Sets the entry for this attribute name in the map. Subclasses may override.
- Specified by:
setScanMetadataAttributein interfaceScannable- Parameters:
attributeName- attribute namevalue- value of attribute- Throws:
DeviceException- if the attribute could not be set for any reason
-
getScanMetadataAttribute
Returns the value of the scan attribute, ornullif no such attribute exists (or if the value of the attribute isnull) The type of the value returned can be:- a dataset;
- a primitive type supported by datasets;
- an array whose component type that is supported by datasets;
- a list whose element type is supported by datasets.
Note: this is a temporary mechanism to allow GDA8 devices to work with the new scanning framework. It should be removed once GDA9 scans use templates to write Nexus files.
Sets the entry for this attribute name in the map. Subclasses may override.
- Specified by:
getScanMetadataAttributein interfaceScannable- Parameters:
attributeName- the name of the attribute- Throws:
DeviceException- if the value of the attribute could not be retrieved for any reason
-
getScanMetadataAttributeNames
Returns the name of the scan attributes. These are the attributes that should be written into the scan output (e.g. a NeXus file).Note: this is a temporary mechanism to allow GDA8 devices to work with the new scanning framework. It should be removed once GDA9 scans use templates to write Nexus files.
Sets the entry for this attribute name in the map. Subclasses may override.
- Specified by:
getScanMetadataAttributeNamesin interfaceScannable- Returns:
- names of scan attributes
- Throws:
DeviceException- if the names of the scan attributes could not be retrieved for any reason
-
setScanMetadataAttributes
- Specified by:
setScanMetadataAttributesin interfaceScannable- Throws:
DeviceException
-
getScanMetadataAttributes
- Specified by:
getScanMetadataAttributesin interfaceScannable- Throws:
DeviceException
-
__call__
- Returns:
- the position of this object as a native or array of natives
- Throws:
DeviceException- See Also:
-
__call__
public org.python.core.PyObject __call__(org.python.core.PyObject new_position) throws DeviceException Moves the scannable to new_position when a scannable(new_position) call is made from Python- Parameters:
new_position-- Returns:
- a message explaining what happened
- Throws:
DeviceException- See Also:
-
__len__
public int __len__()- Returns:
- the size of input names. This is intentional as slicing should only work over input parameters. (A design request)
-
__getitem__
public org.python.core.PyObject __getitem__(org.python.core.PyObject index) throws org.python.core.PyException - Parameters:
index- a number or a PySlice object- Returns:
- the part of the objects array of position as defined by index
- Throws:
org.python.core.PyException
-
__str__
Jython method to return string description of the object- Returns:
- the result of the toString method
-
__repr__
Jython method to return a string representation of the object- Returns:
- the result of the toString method
-
__doc__
- Returns:
- the name of the scannable
-