Class ScriptDrivenScannableMotionUnits
- All Implemented Interfaces:
Device,Scannable,ScannableMotion,ScannableMotionUnits,Configurable,Findable,gda.observable.IObservable,org.springframework.beans.factory.InitializingBean
-
Field Summary
Fields inherited from interface gda.device.Scannable
ATTR_NEXUS_CATEGORY, ATTR_NX_CLASS, DEFAULT_INPUT_NAME, VALUE_UNAVAILABLEFields inherited from interface gda.device.ScannableMotion
FIRSTINPUTLIMITSFields inherited from interface gda.device.ScannableMotionUnits
HARDWAREUNITS, USERUNITS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddAcceptableUnit(String newUnit) Adds a new unit to the list of acceptable units based on the supllied stringvoidaddIObserver(gda.observable.IObserver anIObserver) voidvoidvoidasynchronousMoveTo(Object position) 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.voidvoidCalled 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 position) Tests if the given object is meaningful to this Scannable and so could be used by one of the move commands.checkPositionWithinGdaLimits(Double[] externalPosition) Returns null if okay, or a descriptive error if not.checkPositionWithinGdaLimits(Object externalPosition) Returns null if okay, or a descriptive error if not.voidclose()Close and unconfigure the device.voidPerform operations that must be done after Spring initialisation i.e.voiddeleteIObserver(gda.observable.IObserver anIObserver) voidString[]getAttribute(String attributeName) Get the value of the specified attributeString[]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.Double[]Get lower Scannable limits in external representation.getName()Get the object name.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.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.intDouble[]Returns scaling factor(s) as Doubles.Double[]Gets the scannables values of tolerance.Double[]Get upper Scannable limits in external representationReturns a string representation of the current reporting unitsbooleanTests if the scannable is at (or if appropriate, close to) the value positionToTest.booleanisBusy()Check if the Scannable is moving/operating.booleanIndicates whether this object should be configured at startup.booleanChecks to see if the object is already configured.voidTrigger a move/operation and block until completion.voidvoidRe-initialisation of values and states.voidsetAttribute(String attributeName, Object value) Set any attribute the implementing classes may providevoidsetCommandFormat(String commandFormat) voidsetCommandRunner(ICommandRunner commandRunner) voidsetExtraNames(String[] names) Sets the array of names returned by getExtraNames of this scannable.voidsetHardwareUnitString(String hardwareUnitString) Sets the hardware unit to hardwareUnitString.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 scansvoidsetLowerGdaLimits(Double externalLowerLim) Set lower Scannable limit in external representation.voidsetLowerGdaLimits(Double[] externalLowerLim) Set lower Scannable limits in external representation.voidSet or change the name of the object (as defined in XML).voidsetNumberTries(int numberTries) voidSet offset(s) in amounts of external quantities.voidSet offset(s) in amounts of external quantities asScannableMotion.setOffset(Double...), but allows any position container containing objects that may be quantities.voidsetOutputFormat(String[] names) Sets the array of strings describing how best to format the positions from this scannablevoidsetProtectionLevel(int newLevel) Sets the permission level for this object.voidsetScalingFactor(Double... scaleArray) Set scaling factor(s) as Doubles.voidsetScannable(ScannableMotionUnits scannable) voidsetTolerance(Double tolerence) voidsetTolerances(Double[] tolerence) voidsetUpperGdaLimits(Double externalUpperLim) Set upper Scannable limit in external representation.voidsetUpperGdaLimits(Double[] externalUpperLim) Set upper Scannable limits in external representation.voidsetUserUnits(String userUnitsString) Sets the user unit to userUnitString.voidstop()Stop the current move/operation.Returns a string representation of the Scannable and its current position/value/statustoString()voidReturns when operation carried out by moveTo has completedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface gda.device.Scannable
getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, setScanMetadataAttribute, setScanMetadataAttributes
-
Constructor Details
-
ScriptDrivenScannableMotionUnits
public ScriptDrivenScannableMotionUnits()
-
-
Method Details
-
getScannable
-
setScannable
-
getCommandRunner
-
setCommandRunner
-
getCommandFormat
-
setCommandFormat
-
setName
Description copied from interface:FindableSet or change the name of the object (as defined in XML). -
configure
Description copied from interface:ConfigurablePerform operations that must be done after Spring initialisation i.e. anything that goes beyond setting member variables.- Specified by:
configurein interfaceConfigurable- Throws:
FactoryException- if there is an error in configuration e.g. required variable not set or cannot connect to device
-
isConfigured
public boolean isConfigured()Description copied from interface:ConfigurableChecks to see if the object is already configured.- Specified by:
isConfiguredin interfaceConfigurable- Returns:
- return
trueif configuredfalseotherwise
-
reconfigure
Description copied from interface:ConfigurableRe-initialisation of values and states.Moved from Reconfigurable which has been deleted
- Specified by:
reconfigurein interfaceConfigurable- Throws:
FactoryException
-
isConfigureAtStartup
public boolean isConfigureAtStartup()Description copied from interface:ConfigurableIndicates whether this object should be configured at startup.Moved from ConditionallyConfigurable which has been deleted
- Specified by:
isConfigureAtStartupin interfaceConfigurable
-
getPosition
Description copied from interface:ScannableReturns the current position of the Scannable. Called by ConcurentScan at the end of the point.- Specified by:
getPositionin interfaceScannable- Returns:
- Current position with an element for each input and extra field. null if their are no fields.
- Throws:
DeviceException
-
getName
Description copied from interface:FindableGet the object name. Used by Castor to check if the object name has been set before calling theFindable.setName(String)method. -
setAttribute
Description copied from interface:DeviceSet any attribute the implementing classes may provide- Specified by:
setAttributein interfaceDevice- Parameters:
attributeName- is the name of the attributevalue- is the value of the attribute- Throws:
DeviceException- if an attribute cannot be set
-
toString
-
getUserUnits
Description copied from interface:ScannableMotionUnitsReturns a string representation of the current reporting units- Specified by:
getUserUnitsin interfaceScannableMotionUnits- Returns:
- Returns the reportingUnitsString.
-
checkPositionWithinGdaLimits
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
-
setUserUnits
Description copied from interface:ScannableMotionUnitsSets the user unit to userUnitString. If a hardware unit has not been explicitly set, then the hardware unit is also set to userUnitString. If a hardware unit has been set, and the userUnit is not compatible with this, then a DeviceException is thrown.- Specified by:
setUserUnitsin interfaceScannableMotionUnits- Parameters:
userUnitsString- The reportingUnitsString to set.- Throws:
DeviceException- if string not found in list of acceptable units
-
moveTo
Description copied from interface:ScannableTrigger a move/operation and block until completion.- Specified by:
moveToin interfaceScannable- Parameters:
position-- Throws:
DeviceException
-
getAttribute
Description copied from interface:DeviceGet the value of the specified attribute- Specified by:
getAttributein interfaceDevice- Parameters:
attributeName- is the name of the attribute- Returns:
- the value of the attribute as an Object type
- Throws:
DeviceException- if an attribute cannot be retrieved
-
asynchronousMoveTo
Description copied from interface:ScannableTrigger 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.- Specified by:
asynchronousMoveToin interfaceScannable- Parameters:
position- Position to move to should have an element for each input field.- Throws:
DeviceException
-
checkPositionWithinGdaLimits
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
-
close
Description copied from interface:DeviceClose and unconfigure the device.- Specified by:
closein interfaceDevice- Throws:
DeviceException
-
setProtectionLevel
public void setProtectionLevel(int newLevel) Description copied from interface:DeviceSets the permission level for this object. If this is not set then a default value will be applied.- Specified by:
setProtectionLevelin interfaceDevice- Parameters:
newLevel-
-
getHardwareUnitString
- Specified by:
getHardwareUnitStringin interfaceScannableMotionUnits- Returns:
- Returns the motorUnitString.
-
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
-
setHardwareUnitString
Description copied from interface:ScannableMotionUnitsSets the hardware unit to hardwareUnitString. If a user unit has not been explicitly set then the user unit is also set to hardwareUnitString. If the user unit has been explicitly set and the new hardware unit would invalidate this then a DeviceException is thrown.Based on this string, this method will build a list of acceptable user-units. Afterwards, the acceptable units list can be added to via the addAcceptableUnits method if the defaults do not cover enough.
- Specified by:
setHardwareUnitStringin interfaceScannableMotionUnits- Parameters:
hardwareUnitString- The motorUnitString to set.- Throws:
DeviceException
-
getProtectionLevel
public int getProtectionLevel()- Specified by:
getProtectionLevelin interfaceDevice- Returns:
- int - the permission level for this object.
-
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:
externalLowerLim- limit in external representation- Throws:
Exception
-
stop
Description copied from interface:ScannableStop the current move/operation.- Specified by:
stopin interfaceScannable- Throws:
DeviceException
-
isBusy
Description copied from interface:ScannableCheck if the Scannable is moving/operating.- Specified by:
isBusyin interfaceScannable- Returns:
- true - if operation carried out by moveTo has not completed yet
- Throws:
DeviceException
-
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
-
getAcceptableUnits
- Specified by:
getAcceptableUnitsin interfaceScannableMotionUnits- Returns:
- Returns the acceptableUnitStrings.
-
addAcceptableUnit
Description copied from interface:ScannableMotionUnitsAdds a new unit to the list of acceptable units based on the supllied string- Specified by:
addAcceptableUnitin interfaceScannableMotionUnits- Parameters:
newUnit- - string representation of the new acceptable unit- Throws:
DeviceException
-
waitWhileBusy
Description copied from interface:ScannableReturns when operation carried out by moveTo has completed- Specified by:
waitWhileBusyin interfaceScannable- Throws:
DeviceExceptionInterruptedException
-
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
-
isAt
Description copied from interface:ScannableTests if the scannable is at (or if appropriate, close to) the value positionToTest.- Specified by:
isAtin interfaceScannable- Parameters:
positionToTest- The position to compare the scannable's position to.- Returns:
- true if scannable is at positionToTest
- Throws:
DeviceException
-
setOffset
Description copied from interface:ScannableMotionUnitsSet offset(s) in amounts of external quantities asScannableMotion.setOffset(Double...), but allows any position container containing objects that may be quantities.ScannableMotion.setOffset(Double...)- Specified by:
setOffsetin interfaceScannableMotionUnits- Parameters:
offsetPositionInExternalUnits-
-
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:
externalUpperLim- limit in external representation- Throws:
Exception
-
setLevel
public void setLevel(int level) Description copied from interface:ScannableUsed for ordering the operations of Scannables during scans -
getLevel
public int getLevel()Description copied from interface:Scannableget the operation level of this scannable. -
getUpperGdaLimits
Description copied from interface:ScannableMotionGet upper Scannable limits in external representation- Specified by:
getUpperGdaLimitsin interfaceScannableMotion- Returns:
- Double[] limit in external representation
-
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
-
checkPositionValid
Description copied from interface:ScannableTests 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:
position-- Returns:
- null if position is valid, or returns a description if not.
- Throws:
DeviceException
-
setInputNames
Description copied from interface:Scannablesets the array of names returned by getInputNames method of this scannable.- Specified by:
setInputNamesin interfaceScannable- Parameters:
names-
-
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
-
setExtraNames
Description copied from interface:ScannableSets the array of names returned by getExtraNames of this scannable.- Specified by:
setExtraNamesin interfaceScannable- Parameters:
names-
-
getTolerances
Description copied from interface:ScannableMotionGets the scannables values of tolerance. If no values have been set then returns an array of zeros. This is for 'real world' motors which may not move to their desired location and do not throw an exception.- Specified by:
getTolerancesin interfaceScannableMotion- Returns:
- Double[]
- Throws:
DeviceException
-
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-
-
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
-
setTolerance
- Specified by:
setTolerancein interfaceScannableMotion- Parameters:
tolerence-- Throws:
DeviceException
-
setTolerances
- Specified by:
setTolerancesin interfaceScannableMotion- Parameters:
tolerence-- Throws:
DeviceException
-
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
-
atScanStart
Description copied from interface:ScannableCalled for every Scannable at the start of a group of nested scans (or a single scan if that is the case)- Specified by:
atScanStartin interfaceScannable- Throws:
DeviceException
-
atScanEnd
Description copied from interface:ScannableCalled 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()- Specified by:
atScanEndin interfaceScannable- Throws:
DeviceException
-
setNumberTries
public void setNumberTries(int numberTries) - Specified by:
setNumberTriesin interfaceScannableMotion- Parameters:
numberTries- the numberTries to set
-
a
- Specified by:
ain interfaceScannableMotion- Throws:
DeviceException
-
atScanLineStart
Description copied from interface:ScannableCalled for every Scannable at the start of every scan- Specified by:
atScanLineStartin interfaceScannable- Throws:
DeviceException
-
ar
- Specified by:
arin interfaceScannableMotion- Throws:
DeviceException
-
r
- Specified by:
rin interfaceScannableMotion- Throws:
DeviceException
-
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.
-
atScanLineEnd
Description copied from interface:ScannableCalled for every Scannable at the end of every scan- Specified by:
atScanLineEndin interfaceScannable- Throws:
DeviceException
-
atPointStart
Description copied from interface:ScannableCalled on every Scannable at every data point, for scans which are broken down into individual points (i.e. non-continuous scans)- Specified by:
atPointStartin interfaceScannable- Throws:
DeviceException
-
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.
-
atPointEnd
Description copied from interface:ScannableCalled on every Scannable at the end of every data point, for scans which are broken down into individual points (i.e. non-continous scans)- Specified by:
atPointEndin interfaceScannable- Throws:
DeviceException
-
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
-
atLevelMoveStart
Description copied from interface:ScannableCalled 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.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
-
atLevelStart
Description copied from interface:ScannableCalled 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.
- Specified by:
atLevelStartin interfaceScannable- Throws:
DeviceException
-
atLevelEnd
- Specified by:
atLevelEndin interfaceScannable- Throws:
DeviceException
-
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
-
atCommandFailure
Description copied from interface:ScannableHook 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.
- Specified by:
atCommandFailurein interfaceScannable- Throws:
DeviceException
-
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
-
addIObserver
public void addIObserver(gda.observable.IObserver anIObserver) - Specified by:
addIObserverin interfacegda.observable.IObservable
-
deleteIObserver
public void deleteIObserver(gda.observable.IObserver anIObserver) - Specified by:
deleteIObserverin interfacegda.observable.IObservable
-
deleteIObservers
public void deleteIObservers()- Specified by:
deleteIObserversin interfacegda.observable.IObservable
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-