Package org.eclipse.scanning.api
Class AbstractScannable<T>
java.lang.Object
org.eclipse.scanning.api.AbstractNameable
org.eclipse.scanning.api.AbstractNameableTimeoutable
org.eclipse.scanning.api.AbstractScannable<T>
- Type Parameters:
T-
- All Implemented Interfaces:
IActivatable,IBoundable<T>,ILevel,INameable,IScanAttributeContainer,IScannable<T>,ITimeoutable,ITolerable<T>,IPositionListenable
- Direct Known Subclasses:
BeamScannable,CompositeNexusScannable,CountableScannable,DetectorCollectionScannable,FrameCollectingScannable,MockStringScannable,NexusSlitsWrapper,ScannableNexusWrapper
public abstract class AbstractScannable<T>
extends AbstractNameableTimeoutable
implements IScannable<T>, IScanAttributeContainer, IPositionListenable
Convenience class using inheritance to contain some of the general
things a scannable does that are the same for all scannables.
NOTE: Inheritance is designed to have three levels only
IScannable->AbstractScannable->A device
The preferred alternative if more complex behaviour is required would
be to create delegates for these interfaces which are then aggregated
in the device.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PositionDelegateImplementors should use the delegate to notify of position. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractScannable(IPublisher<Location> publisher) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPositionListener(IPositionListener listener) Use to be notified as levels / positions are reached.intgetLevel()get the operation level of this scannable.The upper limit in the same unit as the position.The lower limit in the same unit as the position.<M> MgetModel()<A> AgetScanAttribute(String attributeName) Get the value of the specified attributeThe tolerance is a value +/- position which when the position is still within this tolerance means that a setPosition(...) does nothing.booleanvoidregister()Used by spring to register the detector with the Runnable device service *WARNING* Before calling register the detector must be given a service to register this.voidremovePositionListener(IPositionListener listener) Use to be notified as levels / positions are reached.booleansetActivated(boolean activated) voidsetLevel(int level) Used for ordering the operations of Scannables during scanssetMaximum(T upper) setMinimum(T lower) <M> voidsetModel(M model) voidsetPublisher(IPublisher<Location> publisher) <A> voidsetScanAttribute(String attributeName, A value) Set any attribute the implementing classes may providesetTolerance(T tolerance) Set the tolerance which when set will allow setPosition(...) on the device to check if a position set is required.Methods inherited from class org.eclipse.scanning.api.AbstractNameableTimeoutable
equals, getTimeout, hashCode, setTimeout, toStringMethods inherited from class org.eclipse.scanning.api.AbstractNameable
getName, setNameMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.scanning.api.IBoundable
getPermittedValues, getPositionMethods inherited from interface org.eclipse.scanning.api.scan.event.IPositionListenable
getPositioner, setPositionerMethods inherited from interface org.eclipse.scanning.api.IScannable
abort, getUnit, setPosition, setPositionMethods inherited from interface org.eclipse.scanning.api.ITimeoutable
getTimeout, setTimeout
-
Field Details
-
delegate
Implementors should use the delegate to notify of position.
-
-
Constructor Details
-
AbstractScannable
protected AbstractScannable() -
AbstractScannable
- Parameters:
publisher-sservice-
-
-
Method Details
-
register
public void register()Used by spring to register the detector with the Runnable device service *WARNING* Before calling register the detector must be given a service to register this. This can be done from the constructor super(IRunnableDeviceService) of the detector to make it easy to instantiate a no-argument detector and register it from spring. -
addPositionListener
Description copied from interface:IPositionListenableUse to be notified as levels / positions are reached. Not usually necessary as setPosition is blocking until the position is reached but useful for other objects which need to change when new positions are reached.- Specified by:
addPositionListenerin interfaceIPositionListenable- Parameters:
listener-
-
removePositionListener
Description copied from interface:IPositionListenableUse to be notified as levels / positions are reached.- Specified by:
removePositionListenerin interfaceIPositionListenable- Parameters:
listener-
-
setPublisher
-
getScanAttributeNames
- Specified by:
getScanAttributeNamesin interfaceIScanAttributeContainer- Returns:
- null if no attributes, otherwise collection of the names of the attributes set
-
setScanAttribute
Set any attribute the implementing classes may provide- Specified by:
setScanAttributein interfaceIScanAttributeContainer- Parameters:
attributeName- is the name of the attributevalue- is the value of the attribute
-
getScanAttribute
Get the value of the specified attribute- Specified by:
getScanAttributein interfaceIScanAttributeContainer- Parameters:
attributeName- is the name of the attribute- Returns:
- the value of the attribute
-
getDeviceInformation
-
getLevel
public int getLevel()Description copied from interface:ILevelget the operation level of this scannable. -
setLevel
public void setLevel(int level) Description copied from interface:ILevelUsed for ordering the operations of Scannables during scans -
getMaximum
Description copied from interface:IBoundableThe upper limit in the same unit as the position.- Specified by:
getMaximumin interfaceIBoundable<T>- Returns:
- null if there is no upper limit. In this case it will be the upper limit of the type T.
-
setMaximum
-
getMinimum
Description copied from interface:IBoundableThe lower limit in the same unit as the position.- Specified by:
getMinimumin interfaceIBoundable<T>- Returns:
- null if there is no upper limit. In this case it will be the upper limit of the type T.
-
setMinimum
-
isActivated
public boolean isActivated()- Specified by:
isActivatedin interfaceIActivatable- Returns:
- true if device is activated.
-
setActivated
public boolean setActivated(boolean activated) - Specified by:
setActivatedin interfaceIActivatable- Parameters:
activated-- Returns:
- the old value of activated
-
getModel
public <M> M getModel() -
setModel
public <M> void setModel(M model) -
getTolerance
Description copied from interface:ITolerableThe tolerance is a value +/- position which when the position is still within this tolerance means that a setPosition(...) does nothing. This principle of tolerance allows jittery motors not to have value set when their current value is within acceptable accuracy or tolerance.- Specified by:
getTolerancein interfaceITolerable<T>- Returns:
-
setTolerance
Description copied from interface:ITolerableSet the tolerance which when set will allow setPosition(...) on the device to check if a position set is required. The tolerance is a value +/- position which when the position is still within this tolerance means that a setPosition(...) does nothing.- Specified by:
setTolerancein interfaceITolerable<T>- Parameters:
tolerance-- Returns:
- The previous value including null if tolerance is being set for the first time.
-