Class ScannableMotionUnitsBase
- All Implemented Interfaces:
INeXusInfoWriteable,Device,Scannable,ScannableMotion,ScannableMotionUnits,Configurable,Findable,gda.observable.IObservable
- Direct Known Subclasses:
BeamlineWavelength,BeamSize,BeforeAfterScannable,BeforeAfterScannables,BeforeCheckScannable,ConvertorScannable,CoupledScannable,DeferredScannable,DummyContinuouslyScannable,DummyMultiFieldUnitsScannable,DummyRealPositionReader,DummyUnitsScannable,EpicsScannable,GapControlCheckingEnergyController,I18SampleFocusScannable,KeyenceLightScannable,MultiPVScannable,QexafsTestingScannable,SampleXYZAxis,ScannableMotionUnitsObservableWrapper,ScannableMotionWithScannableFieldsBase.ScannableField,ScannableMotor,ScannableRotatingGonio,TwoJawSlitPosition,VmxmJacksPiezoScannable,XESEnergyScannable,XesSpectrometerScannableBase
ScannableMotionUnits Device.
The position passed to asynchronousMoveTo and returned by getPosition will be in the external (user) representation.
getPosition will return the amount of the the Scannable's position Quantity in external (user) units as a Double (or
array of Doubles). See UnitsComponent.internalTowardExternal(Object). getPositionQuantity will return the
position as a quantity in external (user) units. asynchronousMoveTo asynchronousMoveTo will accept a Quantity that is
compatible with the internal (hardware) unit. A String will be parsed into quantity. Otherwise it will take will take
anything that ScannableMotionBase's will take (except an arbitrary String). See
UnitsComponent.externalTowardInternal(Object)
As units are important, then the objects probably are representing hardware, so the isPositionValid method should be implemented.
By default the hardware and user units are the dimensionless ONE. The hardware and user unit cannot be configured to be incompatible.
-
Field Summary
FieldsFields 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.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 TypeMethodDescriptionvoidaddAcceptableUnit(String newUnit) Adds a new unit to the list of acceptable units based on the supllied stringexternalToInternal(Object externalPosition) Converts a position in its external representation to its internal representation.String[]getAttribute(String attributeName) Get the value of the specified attributeDouble[]Returns offset(s) in amounts of external quantities.Returns a string representation of the current reporting unitsinternalToExternal(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.voidsetHardwareUnitString(String hardwareUnitString) Sets the hardware unit to hardwareUnitString.voidsetInitialUserUnits(String initialUserUnits) Sets the initial user units.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.voidsetUserUnits(String userUnitsString) Sets the user unit to userUnitString.Returns a string representation of the Scannable and its current position/value/statusMethods inherited from class gda.device.scannable.ScannableMotionBase
a, addPositionValidator, ar, asynchronousMoveTo, checkPositionValid, checkPositionWithinGdaLimits, checkPositionWithinGdaLimits, completeInstantiation, generateScannableLimitsReport, getAdditionalPositionValidators, getFirstInputLimits, getInputLimits, getInputLimits, getLimitsComponent, getLowerGdaLimits, getNumberTries, getScalingFactor, getTolerances, getUpperGdaLimits, isBusy, 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, 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
asynchronousMoveTo, atCommandFailure, atLevelEnd, atLevelMoveStart, atLevelStart, atPointEnd, atPointStart, atScanEnd, atScanLineEnd, atScanLineStart, atScanStart, checkPositionValid, getExtraNames, getInputNames, getLevel, getOutputFormat, getPosition, getScanMetadataAttribute, getScanMetadataAttributeNames, getScanMetadataAttributes, isBusy, moveTo, setExtraNames, setInputNames, setLevel, setOutputFormat, setScanMetadataAttribute, setScanMetadataAttributes, stop, waitWhileBusyMethods inherited from interface gda.device.ScannableMotion
a, ar, checkPositionWithinGdaLimits, checkPositionWithinGdaLimits, getLowerGdaLimits, getNumberTries, getScalingFactor, getTolerances, getUpperGdaLimits, r, setLowerGdaLimits, setLowerGdaLimits, setNumberTries, setScalingFactor, setTolerance, setTolerances, setUpperGdaLimits, setUpperGdaLimits
-
Field Details
-
unitsComponent
-
-
Constructor Details
-
ScannableMotionUnitsBase
public ScannableMotionUnitsBase()
-
-
Method Details
-
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 classScannableMotionBase- 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 classScannableMotionBase- 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.
-
isAt
Description copied from class:ScannableMotionBaseTests 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 classScannableMotionBase- Parameters:
externalPosition- The position to compare the scannable's position to.- Returns:
- true if scannable is at positionToTest
- Throws:
DeviceException- See Also:
-
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 classScannableMotionBase- Parameters:
attributeName- is the name of the attribute- Returns:
- the value of the attribute as an Object type
- Throws:
DeviceException- See Also:
-
getUserUnits
Description copied from interface:ScannableMotionUnitsReturns a string representation of the current reporting units- Specified by:
getUserUnitsin interfaceScannableMotionUnits- Returns:
- Returns the reportingUnitsString.
-
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
-
getHardwareUnitString
- Specified by:
getHardwareUnitStringin interfaceScannableMotionUnits- Returns:
- Returns the motorUnitString.
-
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
-
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
-
getInitialUserUnits
- Returns:
- Returns the initialUserUnits.
-
setInitialUserUnits
Sets the initial user units.- 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 classScannableMotionBase- Returns:
- string as defined above
-
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- Overrides:
getOffsetin classScannableMotionBase
-
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- Overrides:
setOffsetin classScannableMotionBase- Parameters:
offsetAmountsInExternalUnits- must match number of input fields.
-
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-
-