Class ScannableMotionBase
- All Implemented Interfaces:
INeXusInfoWriteable,Device,Scannable,ScannableMotion,Configurable,Findable,gda.observable.IObservable
- Direct Known Subclasses:
CVScan,CVScan,DummyControlPoint,DummyScannable,EpicsControlPoint,JythonScannableWrapper,MonoMoveWithOffsetScannable,ScannableMotionUnitsBase,ScannableMotionWithScannableFieldsBase,TemperatureBase
ScannableMotion Device.-
Field Summary
FieldsFields 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_UNAVAILABLEFields inherited from interface gda.device.ScannableMotion
FIRSTINPUTLIMITS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidQuick-to-type version of asynchronousMoveTo for use in Jython environmentvoidaddPositionValidator(PositionValidator validator) voidQuick-to-type version of an asynchronous relative move for use in Jython environmentvoidasynchronousMoveTo(Object externalPosition) Trigger a move/operation and return immediately.checkPositionValid(Object externalPosition) Checks the position against the Scannable's limits and against any additional position validators added with additionalPositionValidators().checkPositionWithinGdaLimits(Double[] externalPosition) Deprecated.checkPositionWithinGdaLimits(Object externalPosition) Deprecated.protected voidThis method should be called at the end of an inheriting class's constructor.externalToInternal(Object externalPosition) Converts a position in its external representation to its internal representation.protected StringgetAttribute(String attributeName) Get the value of the specified attributeDouble[]Double[]getInputLimits(int index) static Double[]getInputLimits(ScannableMotion sm, int input) Double[]Get lower Scannable limits in external representation.intThis is the number of times the Scannable should attempt to move to the target position.Double[]Returns offset(s) in amounts of external quantities.Double[]Returns scaling factor(s) as Doubles.Double[]WARNING: This method will not work with units.Double[]Get upper Scannable limits in external representationinternalToExternal(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.booleanisBusy()Check if the Scannable is moving/operating.voidIf the numberTries and tolerance attributes have been set then repeatedly tries to move this Scannable until the position is within the tolerance range.voidQuick-to-type version of a relative move for use in Jython environmentbooleanDeprecated.voidremovePositionValidator(PositionValidator validator) voidsetAdditionalPositionValidators(Set<PositionValidator> additionalPositionValidators) voidsetLimitsComponent(ScannableLimitsComponent limitsComponent) Sets the limits component used by this object.voidsetLowerGdaLimits(Double lowerLim) Set lower Scannable limit in external representation.voidsetLowerGdaLimits(Double[] externalLowerLim) Set lower Scannable limits in external representation.voidsetNumberTries(int numberTries) voidSet offset(s) in amounts of external quantities.voidsetOffsetAndScalingComponent(ScannableOffsetAndScalingComponent offsetAndScalingComponent) voidsetScalingFactor(Double... scaleArray) Set scaling factor(s) as Doubles.voidsetTolerance(Double tolerence) voidsetTolerances(Double[] tolerance) WARNING: This method will not work with units.voidsetUpperGdaLimits(Double upperLim) Set upper Scannable limit in external representation.voidsetUpperGdaLimits(Double[] externalUpperLim) Set upper Scannable limits in external representation.Returns a string representation of the Scannable and its current position/value/statusvoidwriteNeXusInformation(NexusFile file, Node node) protected voidwriteNeXusInformationLimits(NexusFile file, GroupNode group) Methods inherited from class gda.device.scannable.ScannableBase
__call__, __call__, __doc__, __getitem__, __len__, __repr__, __str__, atCommandFailure, atLevelEnd, atLevelMoveStart, atLevelStart, atPointEnd, atPointStart, atScanEnd, atScanLineEnd, atScanLineStart, atScanStart, getExtraNames, getInputNames, getLevel, getOutputFormat, getPosition, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, rawAsynchronousMoveTo, rawGetPosition, setExtraNames, setInputNames, setLevel, setOutputFormat, setScanMetadataAttribute, setScanMetadataAttributes, stop, throwExceptionIfInvalidTarget, toString, validateScannable, valueUnavailableString, waitWhileBusy, waitWhileBusyMethods inherited from class gda.device.DeviceBase
addIObserver, close, deleteIObserver, deleteIObservers, 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, getProtectionLevel, setAttribute, setProtectionLevelMethods inherited from interface gda.observable.IObservable
addIObserver, deleteIObserver, deleteIObserversMethods inherited from interface gda.device.Scannable
atCommandFailure, atLevelEnd, atLevelMoveStart, atLevelStart, atPointEnd, atPointStart, atScanEnd, atScanLineEnd, atScanLineStart, atScanStart, getExtraNames, getInputNames, getLevel, getOutputFormat, getPosition, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, setExtraNames, setInputNames, setLevel, setOutputFormat, setScanMetadataAttribute, setScanMetadataAttributes, stop, waitWhileBusy
-
Field Details
-
numberTries
protected int numberTries -
tolerance
Array of tolerance values. Used by the isAt() method. Can be set manually via setTolerance or setTolerances.
-
-
Constructor Details
-
ScannableMotionBase
public ScannableMotionBase()
-
-
Method Details
-
asynchronousMoveTo
Description copied from class:ScannableBaseTrigger 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- Overrides:
asynchronousMoveToin classScannableBase- Parameters:
externalPosition- Position to move to should have an element for each input field.- Throws:
DeviceException
-
setLimitsComponent
Sets the limits component used by this object.- Parameters:
limitsComponent- the limits component
-
getLimitsComponent
-
setOffsetAndScalingComponent
public void setOffsetAndScalingComponent(ScannableOffsetAndScalingComponent offsetAndScalingComponent) -
internalToExternal
Description copied from class:ScannableBaseConverts 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.
- Overrides:
internalToExternalin classScannableBase- Parameters:
internalPosition-- Returns:
- an object array if the scannable has multiple fields, otherwise an object.
-
externalToInternal
Description copied from class:ScannableBaseConverts 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()".
- Overrides:
externalToInternalin classScannableBase- 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.
-
isBusy
Check if the Scannable is moving/operating.. Calls onto rawIsBusy for historical reasons, although there is currently no need for this.- Specified by:
isBusyin interfaceScannable- Returns:
- true - if operation carried out by moveTo has not completed yet
- Throws:
DeviceException- See Also:
-
rawIsBusy
Deprecated.Should be implemented by inheriting classes- Returns:
- true if busy and last action started by asynchronousMoveTo not completed yet
- Throws:
DeviceException- See Also:
-
moveTo
If the numberTries and tolerance attributes have been set then repeatedly tries to move this Scannable until the position is within the tolerance range.- Specified by:
moveToin interfaceScannable- Overrides:
moveToin classScannableBase- Parameters:
position-- Throws:
DeviceException- See Also:
-
a
Quick-to-type version of asynchronousMoveTo for use in Jython environment- Specified by:
ain interfaceScannableMotion- Parameters:
position-- Throws:
DeviceException
-
r
Quick-to-type version of a relative move for use in Jython environment- Specified by:
rin interfaceScannableMotion- Parameters:
amount-- Throws:
DeviceException
-
ar
Quick-to-type version of an asynchronous relative move for use in Jython environment- Specified by:
arin interfaceScannableMotion- Parameters:
amount-- Throws:
DeviceException
-
checkPositionValid
Checks the position against the Scannable's limits and against any additional position validators added with additionalPositionValidators().- Specified by:
checkPositionValidin interfaceScannable- Overrides:
checkPositionValidin classScannableBase- Parameters:
externalPosition-- Returns:
- null if position is valid, or returns a description if not.
- Throws:
DeviceException- See Also:
-
checkPositionWithinGdaLimits
@Deprecated(since="at least 2012") public String checkPositionWithinGdaLimits(Double[] externalPosition) Deprecated.Description copied from interface:ScannableMotionReturns null if okay, or a descriptive error if not. Code only called if limits are set.- Specified by:
checkPositionWithinGdaLimitsin interfaceScannableMotion- Parameters:
externalPosition- position in external representation- Returns:
- null if okay, or a descriptive error if not
-
checkPositionWithinGdaLimits
@Deprecated(since="at least 2012") public String checkPositionWithinGdaLimits(Object externalPosition) Deprecated.Description copied from interface:ScannableMotionReturns null if okay, or a descriptive error if not. Code only called if limits are set.- Specified by:
checkPositionWithinGdaLimitsin interfaceScannableMotion- Parameters:
externalPosition- position in external representation- Returns:
- null or description of any error
-
getLowerGdaLimits
Description copied from interface:ScannableMotionGet lower Scannable limits in external representation. Will be null if no lower limits are set. Otherwise, any element can be null indicating that the corresponding field has no limit.- Specified by:
getLowerGdaLimitsin interfaceScannableMotion- Returns:
- Double[] limit in external representation
-
getUpperGdaLimits
Description copied from interface:ScannableMotionGet upper Scannable limits in external representation- Specified by:
getUpperGdaLimitsin interfaceScannableMotion- Returns:
- Double[] limit in external representation
-
setLowerGdaLimits
Description copied from interface:ScannableMotionSet lower Scannable limits in external representation. Setting the input null will remove lower limits from the Scannable. Otherwise, any element can be null indicating that the corresponding field has no limit.- Specified by:
setLowerGdaLimitsin interfaceScannableMotion- Parameters:
externalLowerLim- limit in external representation- Throws:
Exception
-
setUpperGdaLimits
Description copied from interface:ScannableMotionSet upper Scannable limits in external representation. Setting the input null will remove upper limits from the Scannable. Otherwise, any element can be null indicating that the corresponding field has no limit.- Specified by:
setUpperGdaLimitsin interfaceScannableMotion- Parameters:
externalUpperLim- limit in external representation- Throws:
Exception
-
setLowerGdaLimits
Description copied from interface:ScannableMotionSet lower Scannable limit in external representation. Setting the input null will remove the lower limit from the Scannable.- Specified by:
setLowerGdaLimitsin interfaceScannableMotion- Parameters:
lowerLim- limit in external representation- Throws:
Exception
-
setUpperGdaLimits
Description copied from interface:ScannableMotionSet upper Scannable limit in external representation. Setting the input null will remove the upper limit from the Scannable.- Specified by:
setUpperGdaLimitsin interfaceScannableMotion- Parameters:
upperLim- limit in external representation- Throws:
Exception
-
getNumberTries
public int getNumberTries()Description copied from interface:ScannableMotionThis is the number of times the Scannable should attempt to move to the target position. Useful when the underlying hardware is problematic and often fails or ignores calls without throwing an exception. This should be used in conjunction with setting the tolerance attribute.- Specified by:
getNumberTriesin interfaceScannableMotion- Returns:
- the numberTries
- See Also:
-
setNumberTries
public void setNumberTries(int numberTries) - Specified by:
setNumberTriesin interfaceScannableMotion- Parameters:
numberTries- the numberTries to set- See Also:
-
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 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() to see if they are within the tolerance specified in the scannable's tolerance array. Both values are first converted to arrays using objectToArray() from ScannableUtils.
- Specified by:
isAtin interfaceScannable- Overrides:
isAtin classScannableBase- Parameters:
positionToTest- The position to compare the scannable's position to.- Returns:
- true if scannable is at positionToTest
- Throws:
DeviceException- See Also:
-
setTolerances
WARNING: This method will not work with units.- Specified by:
setTolerancesin interfaceScannableMotion- Parameters:
tolerance-- Throws:
DeviceException
-
setTolerance
- Specified by:
setTolerancein interfaceScannableMotion- Parameters:
tolerence-- Throws:
DeviceException- See Also:
-
getTolerances
WARNING: This method will not work with units.- Specified by:
getTolerancesin interfaceScannableMotion- Returns:
- double[]
- Throws:
DeviceException- See Also:
-
writeNeXusInformation
- Specified by:
writeNeXusInformationin interfaceINeXusInfoWriteable- Parameters:
file- nexus file handlenode-- Throws:
NexusException
-
writeNeXusInformationLimits
- Throws:
NexusException
-
getInputLimits
-
getAttribute
Get the value of the specified attribute To distributed some of the extra methods in the ScannableMotion interface- Specified by:
getAttributein interfaceDevice- Overrides:
getAttributein classDeviceBase- Parameters:
attributeName- is the name of the attribute- Returns:
- the value of the attribute as an Object type
- Throws:
DeviceException- See Also:
-
getInputLimits
-
getFirstInputLimits
- Throws:
DeviceException
-
completeInstantiation
This method should be called at the end of an inheriting class's constructor.It will do things such as validate that the class instantiated was valid, register the scannable with other objects and generally complete the instantiation of the object.
- Throws:
InstantiationException
-
getOffset
Description copied from interface:ScannableMotionReturns offset(s) in amounts of external quantities. May be null, or any element may be null, indicating no offset is to be applied/removed.- Specified by:
getOffsetin interfaceScannableMotion
-
getScalingFactor
Description copied from interface:ScannableMotionReturns scaling factor(s) as Doubles. May be null, or any element may be null, indicating no scale is to be applied/removed.- Specified by:
getScalingFactorin interfaceScannableMotion
-
setOffset
Description copied from interface:ScannableMotionSet offset(s) in amounts of external quantities. May be null, or any element may be null, indicating no offset is to be applied/removed.- Specified by:
setOffsetin interfaceScannableMotion- Parameters:
offsetArray- must match number of input fields.
-
setScalingFactor
Description copied from interface:ScannableMotionSet scaling factor(s) as Doubles. May be null, or any element may be null, indicating no scale is to be applied/removed.- Specified by:
setScalingFactorin interfaceScannableMotion- Parameters:
scaleArray- must match number of input fields.
-
addPositionValidator
-
removePositionValidator
- Throws:
IllegalArgumentException- if validator is null
-
setAdditionalPositionValidators
-
getAdditionalPositionValidators
-
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- Overrides:
toFormattedStringin classScannableBase- Returns:
- string as defined above
-
generateScannableLimitsReport
-