Package gda.device.scannable
Class ScannableMotor
- All Implemented Interfaces:
INeXusInfoWriteable,ControllerRecord,Device,IScannableMotor,Scannable,ScannableMotion,ScannableMotionUnits,Configurable,Findable,gda.observable.IObservable
- Direct Known Subclasses:
AirBearingScannableMotor,B18EnergyScannable,ControllerScannable,Crystal1PitchScannable,IdealBaseX,QexafsScannable,ScannableAttenuatorWedge,SmarGonScannableMotor,TrajectoryScannableMotor,TurboXasScannable,TweakableScannableMotor,ZebraScannableMotor,ZebraScannableMotorForQexafs
@ServiceInterface(IScannableMotor.class)
public class ScannableMotor
extends ScannableMotionUnitsBase
implements IScannableMotor
Adapter class for motor to work as scannables. This class uses units and has an offset/scaling factor for the motor
position.
The returned position (user position) is calculated by:
userPosition = (motorPosition*scalingFactor) + offset
GDALimits are based on the userPosition, but must be in the same units as the motor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of java property which when set true causes the upper invalid input: '&' lower gda limits to be set from the motor limits if not already set.Fields inherited from class gda.device.scannable.ScannableMotionUnitsBase
unitsComponentFields inherited from class gda.device.scannable.ScannableMotionBase
numberTries, toleranceFields 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.IScannableMotor
WAS_ALREADY_BUSY_SO_COULD_NOT_BE_MOVEDFields 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 TypeMethodDescriptionprotected voidvoidDefault 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.protected ObjectgetAttribute(String attributeName) Get the value of the specified attributeGets the name of the controller record, e.g.protected ObjectReturn the last demanded user/external position if one has been set.doubleSeesetReturnDemandPosition(boolean)Value is in internal/motor units and scaleDouble[]Returns the innermost (i.e.Returns the lower motor limit in its external representation.getMotor()Method required by scripts which need to access the real motor at times.
Before the script could get the motor name but now that the motor may be set by spring, scripts cannot get the underlying motor.doubleReturns the current position of the Scannable.doublegetSpeed()Get the speed of the underlying motordoubleReturns this motor's time to velocity.Returns the innermost (i.e.Returns the upper motor limit in its external representation.doublebooleanisBusy()Return true if motor is busy.booleanvoidrawAsynchronousMoveTo(Object internalPosition) [Consider abstract] Trigger a move/operation to an internal/hardware position and return immediately.protected ObjectReturn the last demanded motor/internal position if one has been set, otherwise return the current position.Read the position in its internal (user) representation.voidsetDemandPositionTolerance(double demandPositionTolerance) SeesetReturnDemandPosition(boolean)Value is in internal/motor units and scalevoidsetLogMoveRequestsWithInfo(boolean logMoveRequestsWithInfo) voidSets the motor used by this scannable motor.voidsetMotorLimitsComponent(MotorLimitsComponent motorLimitsComponent) voidsetMotorName(String motorName) voidsetNotifyObserverPositionChangeEvents(boolean notifyObserverPositionChangeEvents) voidsetPosition(Object position) Set the positionvoidsetReturnDemandPosition(boolean returnDemandPosition) If true, calls torawGetPosition()will return the last demanded position.voidsetSpeed(double theSpeed) Set the speed of the underlying motorvoidsetTimeToVelocity(double timeToVelocity) Sets this motor's time to velocity.voidstop()Stop the current move/operation.Returns a string representation of the Scannable and its current position/value/statusvoidReturns when operation carried out by moveTo has completedMethods inherited from class gda.device.scannable.ScannableMotionUnitsBase
addAcceptableUnit, externalToInternal, getAcceptableUnits, getHardwareUnitString, getInitialUserUnits, getOffset, getUserUnits, internalToExternal, isAt, setHardwareUnitString, setInitialUserUnits, setOffset, setOffset, setUserUnitsMethods inherited from class gda.device.scannable.ScannableMotionBase
a, addPositionValidator, ar, asynchronousMoveTo, checkPositionValid, checkPositionWithinGdaLimits, checkPositionWithinGdaLimits, completeInstantiation, generateScannableLimitsReport, getAdditionalPositionValidators, getInputLimits, getInputLimits, getLimitsComponent, getLowerGdaLimits, getNumberTries, getScalingFactor, getTolerances, getUpperGdaLimits, moveTo, r, rawIsBusy, removePositionValidator, setAdditionalPositionValidators, setLimitsComponent, setLowerGdaLimits, setLowerGdaLimits, setNumberTries, setOffsetAndScalingComponent, setScalingFactor, setTolerance, setTolerances, setUpperGdaLimits, setUpperGdaLimits, writeNeXusInformation, writeNeXusInformationLimitsMethods 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, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, setExtraNames, setInputNames, setLevel, setOutputFormat, setScanMetadataAttribute, setScanMetadataAttributes, throwExceptionIfInvalidTarget, toString, validateScannable, valueUnavailableString, 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
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.Device
close, getProtectionLevel, setAttribute, setProtectionLevelMethods inherited from interface gda.observable.IObservable
addIObserver, deleteIObserver, deleteIObserversMethods inherited from interface gda.device.Scannable
asynchronousMoveTo, atCommandFailure, atLevelEnd, atLevelMoveStart, atLevelStart, atPointEnd, atPointStart, atScanEnd, atScanLineEnd, atScanLineStart, atScanStart, checkPositionValid, getExtraNames, getInputNames, getLevel, getOutputFormat, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, isAt, moveTo, setExtraNames, setInputNames, setLevel, setOutputFormat, setScanMetadataAttribute, setScanMetadataAttributesMethods inherited from interface gda.device.ScannableMotion
a, ar, checkPositionWithinGdaLimits, checkPositionWithinGdaLimits, getLowerGdaLimits, getNumberTries, getOffset, getScalingFactor, getTolerances, getUpperGdaLimits, r, setLowerGdaLimits, setLowerGdaLimits, setNumberTries, setOffset, setScalingFactor, setTolerance, setTolerances, setUpperGdaLimits, setUpperGdaLimitsMethods inherited from interface gda.device.ScannableMotionUnits
addAcceptableUnit, getAcceptableUnits, getHardwareUnitString, getUserUnits, setHardwareUnitString, setOffset, setUserUnits
-
Field Details
-
COPY_MOTOR_LIMITS_INTO_SCANNABLE_LIMITS
Name of java property which when set true causes the upper invalid input: '&' lower gda limits to be set from the motor limits if not already set. Due to the possibility the motor high limit can be associated with a gda low limit we cannot separate out the setting of the upper gda limit without also setting the lower gda limit and vice versa. If the motor lower and upper limits are not set they are taken to be -Double.MAX_VALUE and Double.MAX_VALUE respectively.- See Also:
-
-
Constructor Details
-
ScannableMotor
public ScannableMotor()
-
-
Method Details
-
setMotor
Sets the motor used by this scannable motor.- Specified by:
setMotorin interfaceIScannableMotor- Parameters:
motor- the motor
-
getMotor
Method required by scripts which need to access the real motor at times.
Before the script could get the motor name but now that the motor may be set by spring, scripts cannot get the underlying motor.- Specified by:
getMotorin interfaceIScannableMotor- Returns:
- Motor
-
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
-
attachMotorObserver
protected void attachMotorObserver() -
getAttribute
Description copied from class:ScannableMotionBaseGet the value of the specified attribute To distributed some of the extra methods in the ScannableMotion interface- Specified by:
getAttributein interfaceDevice- Overrides:
getAttributein classScannableMotionUnitsBase- Parameters:
attributeName- is the name of the attribute- Returns:
- the value of the attribute as an Object type
- Throws:
DeviceException- See Also:
-
getFirstInputLimits
- Overrides:
getFirstInputLimitsin classScannableMotionBase- Throws:
DeviceException
-
getMotorName
- Specified by:
getMotorNamein interfaceIScannableMotor- Returns:
- Returns the motorName.
-
setMotorName
- Specified by:
setMotorNamein interfaceIScannableMotor- Parameters:
motorName- The motorName to set.
-
rawAsynchronousMoveTo
[Consider abstract] Trigger a move/operation to an internal/hardware position and return immediately.. Triggers a motor to move. Throws a DeviceException if the motor is already busy. This method's guts are synchronised so that another thread can't enter it before the first thread has completed the motor's (asynchronous) moveTo call. For the DeviceException to be thrown properly when a move request is made of a moving motor, the motor's getStatus() method must *immediately* report BUSY after it's moveTo call has completed.- Overrides:
rawAsynchronousMoveToin classScannableBase- Parameters:
internalPosition- Position in its internal/hardware representation. e.g. with units and offsets removed- Throws:
DeviceException- See Also:
-
rawGetPosition
Read the position in its internal (user) representation. If configured to return demand positions withsetReturnDemandPosition(boolean)and the last demanded position is withingetDemandPositionTolerance()of the physical internal motor position, then return this demand position instead.- Overrides:
rawGetPositionin classScannableBase- Returns:
- the value represented by this Scannable
- Throws:
DeviceException- See Also:
-
rawGetDemandPosition
Return the last demanded motor/internal position if one has been set, otherwise return the current position. If the motor is stopped, and the actual position is not close to the the demand position, then the current position is returned instead.- 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. Return the demand position fromgetDemandPosition()if configured withsetReturnDemandPosition(boolean)to do so and the motor is not moving, otherwise returns the actual position. i.e. if the motor is moving the actual position is always returned.- Specified by:
getPositionin interfaceScannable- Overrides:
getPositionin classScannableBase- Returns:
- Current position with an element for each input and extra field. null if their are no fields.
- Throws:
DeviceException
-
setPosition
Set the position- Specified by:
setPositionin interfaceIScannableMotor- Throws:
DeviceException
-
getDemandPosition
Return the last demanded user/external position if one has been set. If the motor is stopped, and the actual position is not close to the the demand position, then the current position is returned instead.- Throws:
DeviceException
-
getActualPosition
- Throws:
DeviceException
-
isBusy
Return true if motor is busy.- Specified by:
isBusyin interfaceScannable- Overrides:
isBusyin classScannableMotionBase- Returns:
- true - if operation carried out by moveTo has not completed yet
- Throws:
DeviceException- See Also:
-
waitWhileBusy
Description copied from class:ScannableBaseReturns 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- Overrides:
waitWhileBusyin classScannableBase- Throws:
DeviceExceptionInterruptedException
-
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:
-
getLowerMotorLimit
Returns the lower motor limit in its external representation. Null if there is no lower Motor limit.- Specified by:
getLowerMotorLimitin interfaceIScannableMotor- Returns:
- limit in external representation
- Throws:
DeviceException
-
getUpperMotorLimit
Returns the upper motor limit in its external representation. Null if there is no upper Motor limit.- Specified by:
getUpperMotorLimitin interfaceIScannableMotor- Returns:
- limit in external representation
- Throws:
DeviceException
-
getLowerInnerLimit
Returns the innermost (i.e. the most limiting) of the lower Scannable and Motor limits.- Specified by:
getLowerInnerLimitin interfaceIScannableMotor- Returns:
- the highest minimum limit, or null if neither are set.
- Throws:
DeviceException
-
getUpperInnerLimit
Returns the innermost (i.e. the most limiting) of the upper Scannable and Motor limits.- Specified by:
getUpperInnerLimitin interfaceIScannableMotor- Returns:
- the lowest maximum limit, or null if neither are set.
- 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- Overrides:
toFormattedStringin classScannableMotionUnitsBase- Returns:
- string as defined above
-
getSpeed
Get the speed of the underlying motor- Specified by:
getSpeedin interfaceIScannableMotor- Returns:
- speed in the motor's units
- Throws:
DeviceException
-
setSpeed
Set the speed of the underlying motor- Specified by:
setSpeedin interfaceIScannableMotor- Parameters:
theSpeed- in the motor's units- Throws:
DeviceException
-
getTimeToVelocity
Returns this motor's time to velocity.- Specified by:
getTimeToVelocityin interfaceIScannableMotor- Throws:
DeviceException
-
setTimeToVelocity
Sets this motor's time to velocity.- Specified by:
setTimeToVelocityin interfaceIScannableMotor- Throws:
DeviceException
-
setMotorLimitsComponent
-
getMotorLimitsComponent
-
setNotifyObserverPositionChangeEvents
public void setNotifyObserverPositionChangeEvents(boolean notifyObserverPositionChangeEvents) -
setLogMoveRequestsWithInfo
public void setLogMoveRequestsWithInfo(boolean logMoveRequestsWithInfo) -
setReturnDemandPosition
public void setReturnDemandPosition(boolean returnDemandPosition) If true, calls torawGetPosition()will return the last demanded position. If the current position is greater than demandPositionTolerance from the last demanded position the actual current position is returned and a warning logged and displayed on the console.- Parameters:
returnDemandPosition-
-
isReturningDemandPosition
public boolean isReturningDemandPosition() -
setDemandPositionTolerance
public void setDemandPositionTolerance(double demandPositionTolerance) SeesetReturnDemandPosition(boolean)Value is in internal/motor units and scale -
getDemandPositionTolerance
public double getDemandPositionTolerance()SeesetReturnDemandPosition(boolean)Value is in internal/motor units and scale- Specified by:
getDemandPositionTolerancein interfaceIScannableMotor- Returns:
- the deadband retry of an EPICS motor for eg.
-
getMotorResolution
- Specified by:
getMotorResolutionin interfaceIScannableMotor- Returns:
- the resolution of the motor
- Throws:
DeviceException
-
getUserOffset
- Specified by:
getUserOffsetin interfaceIScannableMotor- Returns:
- the user offset on the motor
- Throws:
DeviceException
-
getControllerRecordName
Description copied from interface:ControllerRecordGets the name of the controller record, e.g. EPICS process variable name. For example, in NeXus this value can be written as the value of thecontroller_recordfield for theNXpositionerfor the scannable.- Specified by:
getControllerRecordNamein interfaceControllerRecord- Returns:
- controller record name
- See Also:
-