Class AbstractMalcolmDevice
java.lang.Object
org.eclipse.scanning.api.AbstractNameable
org.eclipse.scanning.api.device.AbstractRunnableDevice<IMalcolmModel>
org.eclipse.scanning.malcolm.core.AbstractMalcolmDevice
- All Implemented Interfaces:
INexusDevice<NXobject>,IActivatable,IPausableDevice<IMalcolmModel>,IResettableDevice,IRunnableDevice<IMalcolmModel>,IRunnableEventDevice<IMalcolmModel>,IDeviceRoleActor,IConfigurable<IMalcolmModel>,ILevel,IModelProvider<IMalcolmModel>,INameable,IScanAttributeContainer,IValidator<IMalcolmModel>,IMalcolmDevice
- Direct Known Subclasses:
DummyMalcolmDevice,MalcolmDevice
public abstract class AbstractMalcolmDevice
extends AbstractRunnableDevice<IMalcolmModel>
implements IMalcolmDevice, INexusDevice<NXobject>
Base class for Malcolm devices
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Stringprotected IPointGenerator<? extends IScanPointGeneratorModel> protected ScanModelFields inherited from class org.eclipse.scanning.api.device.AbstractRunnableDevice
connectorService, model, runnableDeviceService -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMalcolmDevice(IRunnableDeviceService runnableDeviceService) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMalcolmListener(IMalcolmEventListener listener) Add a listener to malcolm changes.protected voidEnacts any post-actions or conditions after the device completes a run of the task block.protected voidEnacts any pre-actions or conditions before the device attempts to run the task block.calculateAxesToMove(List<String> configuredAxes) Calculate the value of the axesToMove property of the EpicsMalcolmModel to send to malcolm, based on the given configured axes and the currently configured point generatorprotected voidclose()voidconfigure(IMalcolmModel model) Call to configure the device.voidconfigureScan(ScanModel scanModel) voiddispose()Disposes of the malcolm device causing it to disconnect from the underlying malcolm device.protected int[]The breakpoints array to pass to malcolm, only used withInterpolatedMultiScanModel, otherwisenull.Returns the axes that this malcolm device is currently configured to move.getConfiguredAxes(IMalcolmModel model) getDeviceInformation(boolean includeNonAlive) Do not override without calling super.getDeviceInformation() Method is final for now to help avoid that problem.protected Optional<InterpolatedMultiScanModel> Returns the object providers required for writing correct NeXus files.Get the directory where malcolm will write its h5 files to.IPointGenerator<? extends IScanPointGeneratorModel> Get the point generator that this malcolm device has been configured withvoidInitializes the connection to the actual malcolm device.voidregister()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.voidremoveMalcolmListener(IMalcolmEventListener listener) Remove a listener to malcolm changes.voidprotected voidsendEvent(MalcolmEvent event) voidsetOutputDir(String outputDir) Set the directory where malcolm will write its h5 files to.voidsetPointGenerator(IPointGenerator<? extends IScanPointGeneratorModel> pointGenerator) Set the point generator for the malcolm device.protected voidsetTemplateBean(MalcolmEvent bean) voidThe default implementation of start simply executes run in a thread named using the getName() value.Methods inherited from class org.eclipse.scanning.api.device.AbstractRunnableDevice
abort, addRunListener, disable, fireRunPerformed, fireRunWillPerform, fireStateChanged, fireWritePerformed, fireWriteWillPerform, getConfigureTime, getConnectorService, getDeviceHealth, getDeviceInformation, getDeviceState, getLevel, getModel, getPublisher, getRole, getRunnableDeviceService, getScanAttribute, getScanAttributeNames, getScanId, getSupportedScanModes, isActivated, isAlive, isDeviceBusy, pause, removeRunListener, reset, resume, seek, setActivated, setAlive, setBusy, setConfigureTime, setConnectorService, setDeviceInformation, setDeviceState, setLevel, setModel, setPublisher, setRole, setRunnableDeviceService, setScanAttribute, setScanId, setSupportedScanMode, setSupportedScanModes, setSupportedScanModes, toString, validateMethods inherited from class org.eclipse.scanning.api.AbstractNameable
equals, getName, hashCode, setNameMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.scanning.api.device.models.IDeviceRoleActor
getRole, getSupportedScanModes, setRoleMethods inherited from interface org.eclipse.scanning.api.malcolm.IMalcolmDevice
getAvailableAxes, getDatasets, getDetectorInfos, getVersion, isLockedMethods inherited from interface org.eclipse.scanning.api.IModelProvider
setModel, updateModelMethods inherited from interface org.eclipse.dawnsci.nexus.INexusDevice
getCustomNexusModification, getName, getNexusProviderMethods inherited from interface org.eclipse.scanning.api.device.IPausableDevice
pause, resume, seekMethods inherited from interface org.eclipse.scanning.api.device.IResettableDevice
resetMethods inherited from interface org.eclipse.scanning.api.device.IRunnableDevice
abort, disable, getDeviceHealth, getDeviceState, getModel, isAlive, isDeviceBusy, latch, latch, run, run, setAlive, throwFirstRunExceptionMethods inherited from interface org.eclipse.scanning.api.device.IRunnableEventDevice
addRunListener, fireRunPerformed, fireRunWillPerform, fireWritePerformed, fireWriteWillPerform, removeRunListenerMethods inherited from interface org.eclipse.scanning.api.IValidator
setService, validate
-
Field Details
-
scanModel
-
pointGenerator
-
outputDir
-
isMultiScan
protected boolean isMultiScan
-
-
Constructor Details
-
AbstractMalcolmDevice
-
-
Method Details
-
register
public void register()Description copied from class:AbstractRunnableDeviceUsed 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.- Specified by:
registerin interfaceINexusDevice<NXobject>- Overrides:
registerin classAbstractRunnableDevice<IMalcolmModel>
-
initialize
Description copied from interface:IMalcolmDeviceInitializes the connection to the actual malcolm device. This methods must be called before the malcolm device can be used.- Specified by:
initializein interfaceIMalcolmDevice- Throws:
MalcolmDeviceException- if the malcolm device could not be initialized
-
configureScan
-
getBreakpoints
protected int[] getBreakpoints()The breakpoints array to pass to malcolm, only used withInterpolatedMultiScanModel, otherwisenull. The array has the same size as the number of models in theInterpolatedMultiScanModel, where each value is the number of points in the scan for that model- Returns:
- breakpoints array
-
getConfiguredScan
-
configure
Description copied from interface:IConfigurableCall to configure the device. If the model provided is invalid, a scanning exception will be thrown.- Specified by:
configurein interfaceIConfigurable<IMalcolmModel>- Overrides:
configurein classAbstractRunnableDevice<IMalcolmModel>- Parameters:
model-- Throws:
ScanningException
-
getConfiguredAxes
Description copied from interface:IMalcolmDeviceReturns the axes that this malcolm device is currently configured to move. Normally, the value returned is the same asIMalcolmDevice.getAvailableAxes(), except if the last time that malcolm was configured by calling,invalid reference
IMalcolmDevice#configure(IMalcolmModel)IMalcolmModel.getAxesToMove()was non-null, in which case it is the- Specified by:
getConfiguredAxesin interfaceIMalcolmDevice- Returns:
- the axes that the malcolm device is currently configured to move
- Throws:
ScanningException
-
getConfiguredAxes
- Throws:
ScanningException
-
calculateAxesToMove
Calculate the value of the axesToMove property of the EpicsMalcolmModel to send to malcolm, based on the given configured axes and the currently configured point generator- Parameters:
configuredAxes- the axes malcolm is or would have been configured with- Returns:
- the axes that malcolm should move in the scan
-
setPointGenerator
Description copied from interface:IMalcolmDeviceSet the point generator for the malcolm device.- Specified by:
setPointGeneratorin interfaceIMalcolmDevice- Parameters:
pointGenerator- point generator
-
getMultiScanModel
-
getPointGenerator
Description copied from interface:IMalcolmDeviceGet the point generator that this malcolm device has been configured with- Specified by:
getPointGeneratorin interfaceIMalcolmDevice- Returns:
-
setOutputDir
Description copied from interface:IMalcolmDeviceSet the directory where malcolm will write its h5 files to. The directory should exist at the point that the malcolm device is configured, malcolm is not responsible for creating it.- Specified by:
setOutputDirin interfaceIMalcolmDevice
-
getOutputDir
Description copied from interface:IMalcolmDeviceGet the directory where malcolm will write its h5 files to.- Specified by:
getOutputDirin interfaceIMalcolmDevice
-
scanFinally
- Throws:
ScanningException
-
getDeviceInformation
public DeviceInformation<IMalcolmModel> getDeviceInformation(boolean includeNonAlive) throws ScanningException Description copied from class:AbstractRunnableDeviceDo not override without calling super.getDeviceInformation() Method is final for now to help avoid that problem. Gets the device information, with the ability to specify whether to get information that is potentially held on a device or not in the case that the device is not marked as being alive.- Overrides:
getDeviceInformationin classAbstractRunnableDevice<IMalcolmModel>- Parameters:
includeNonAlive- If set to false, if a device is not alive, information potentially held on the device will not be retrieved- Returns:
- Throws:
ScanningException
-
beforeExecute
Enacts any pre-actions or conditions before the device attempts to run the task block.- Throws:
Exception
-
afterExecute
Enacts any post-actions or conditions after the device completes a run of the task block.- Throws:
Exception
-
setTemplateBean
-
start
Description copied from interface:IRunnableDeviceThe default implementation of start simply executes run in a thread named using the getName() value.- Specified by:
startin interfaceIRunnableDevice<IMalcolmModel>- Parameters:
pos-- Throws:
ScanningExceptionInterruptedException
-
close
protected void close() -
dispose
Description copied from interface:IMalcolmDeviceDisposes of the malcolm device causing it to disconnect from the underlying malcolm device.- Specified by:
disposein interfaceIMalcolmDevice- Throws:
MalcolmDeviceException
-
getNexusProviders
public List<NexusObjectProvider<NXobject>> getNexusProviders(NexusScanInfo info) throws NexusException Description copied from interface:INexusDeviceReturns the object providers required for writing correct NeXus files. Implement this method if your device needs to create multiple nexus objects. These can implementNexusObjectProviderThe default implementation of this method calls
INexusDevice.getNexusProvider(NexusScanInfo)and returns aListwhose sole element is theNexusObjectProviderreturned from that method. One of either this method orINexusDevice.getNexusProviders(NexusScanInfo)must be overridden to create and return the nexus object(s) for thisINexusDevice.- Specified by:
getNexusProvidersin interfaceINexusDevice<NXobject>- Parameters:
info- information about the scan which can be useful when creating datasets e.g.info.getRank()- Returns:
- The
NXobjectcreated using thenodeFactoryto represent this device - Throws:
NexusException- if the nexus object could not be created for any reason
-
addMalcolmListener
Description copied from interface:IMalcolmDeviceAdd a listener to malcolm changes.- Specified by:
addMalcolmListenerin interfaceIMalcolmDevice- Parameters:
listener-
-
removeMalcolmListener
Description copied from interface:IMalcolmDeviceRemove a listener to malcolm changes.- Specified by:
removeMalcolmListenerin interfaceIMalcolmDevice- Parameters:
listener-
-
sendEvent
- Throws:
Exception
-