Class MalcolmDevice
java.lang.Object
org.eclipse.scanning.api.AbstractNameable
org.eclipse.scanning.api.device.AbstractRunnableDevice<IMalcolmModel>
org.eclipse.scanning.malcolm.core.AbstractMalcolmDevice
org.eclipse.scanning.malcolm.core.MalcolmDevice
- 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:
ProcessingMalcolmDevice
Object that make the connection to the device and monitors its status.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final longstatic final StringFields inherited from class org.eclipse.scanning.malcolm.core.AbstractMalcolmDevice
isMultiScan, outputDir, pointGenerator, scanModelFields inherited from class org.eclipse.scanning.api.device.AbstractRunnableDevice
connectorService, model, runnableDeviceService -
Constructor Summary
ConstructorsConstructorDescriptionMalcolmDevice(String name, IMalcolmConnection malcolmConnection, IRunnableDeviceService runnableDeviceService) -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Call to terminate the scan before it has finished.voidAt the end of a scan, Malcolm remains in a FINISHED state until reset() is called.voidconfigure(IMalcolmModel model) Call to configure the device.voiddisable()Call to disable the device, stopping all activity.voiddispose()Disposes of the malcolm device causing it to disconnect from the underlying malcolm device.Returns the axes that this malcolm device can move.Returns aMalcolmTableobject describing the datasets that this malcolm device is configured to create during a scan.Returns theMalcolmDetectorInfos for the detectors controlled by this malcolm device, describing their current state.Please override to provide a device health (which a malcolm device will have) The default returns null.OverridesIRunnableDevice.getDeviceState()to ask the actual malcolm device for the device state.Returns the most recent device state from malcolm.getModel()The model being used for the device.Returns the version of this malcolm device.protected voidhandleStateChange(DeviceState newState, String message) protected voidhandleStateChange(MalcolmMessage message) protected voidhandleStepsCompleted(MalcolmMessage message) voidInitializes the connection to the actual malcolm device.booleanGets whether the device is busy or notbooleanisLocked()Attempts to determine if the device is locked doing something like a configure or a run.voidpause()Pauses the device.voidreset()Allowed from Fault.voidresume()Allowed when the device is in Paused state.voidBlocking call to execute the scan.voidseek(int stepNumber) Seek to/from a point number (absolute) in the scan.static voidsetResetAfterScan(boolean resetAfterScan) voidsetSeekStrategy(SeekStrategy strategy) It this is set, it will calculate the scan point the device should resume from based on the last scan point and other device parameters.validate(IMalcolmModel model) If overriding don't forget the old super.validate(...)Methods inherited from class org.eclipse.scanning.malcolm.core.AbstractMalcolmDevice
addMalcolmListener, afterExecute, beforeExecute, calculateAxesToMove, close, configureScan, getBreakpoints, getConfiguredAxes, getConfiguredAxes, getConfiguredScan, getDeviceInformation, getMultiScanModel, getNexusProviders, getOutputDir, getPointGenerator, register, removeMalcolmListener, scanFinally, sendEvent, setOutputDir, setPointGenerator, setTemplateBean, startMethods inherited from class org.eclipse.scanning.api.device.AbstractRunnableDevice
addRunListener, fireRunPerformed, fireRunWillPerform, fireStateChanged, fireWritePerformed, fireWriteWillPerform, getConfigureTime, getConnectorService, getDeviceInformation, getLevel, getPublisher, getRole, getRunnableDeviceService, getScanAttribute, getScanAttributeNames, getScanId, getSupportedScanModes, isActivated, isAlive, removeRunListener, setActivated, setAlive, setBusy, setConfigureTime, setConnectorService, setDeviceInformation, setDeviceState, setLevel, setModel, setPublisher, setRole, setRunnableDeviceService, setScanAttribute, setScanId, setSupportedScanMode, setSupportedScanModes, setSupportedScanModes, toStringMethods 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.IModelProvider
setModel, updateModelMethods inherited from interface org.eclipse.dawnsci.nexus.INexusDevice
getCustomNexusModification, getName, getNexusProviderMethods inherited from interface org.eclipse.scanning.api.device.IRunnableDevice
isAlive, latch, latch, 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
-
Field Details
-
ATTRIBUTE_NAME_COMPLETED_STEPS
- See Also:
-
ATTRIBUTE_NAME_LAST_GOOD_STEP
- See Also:
-
FILE_EXTENSION_H5
- See Also:
-
STANDARD_MALCOLM_ERROR_STR
- See Also:
-
POSITION_COMPLETE_INTERVAL
public static final long POSITION_COMPLETE_INTERVAL
-
-
Constructor Details
-
MalcolmDevice
public MalcolmDevice() -
MalcolmDevice
public MalcolmDevice(String name, IMalcolmConnection malcolmConnection, IRunnableDeviceService runnableDeviceService)
-
-
Method Details
-
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- Overrides:
initializein classAbstractMalcolmDevice- Throws:
MalcolmDeviceException- if the malcolm device could not be initialized
-
handleStepsCompleted
-
handleStateChange
-
handleStateChange
-
getLatestDeviceState
Returns the most recent device state from malcolm. This returns the device state from the most recently state change from the actual malcolm device. This value returned from this method is the same value thatMalcolmStateChangedEvent.getPreviousState()will be in the next such event.- Returns:
- latest device state of the malcolm device
- Throws:
ScanningException
-
getDeviceState
OverridesIRunnableDevice.getDeviceState()to ask the actual malcolm device for the device state.- Specified by:
getDeviceStatein interfaceIRunnableDevice<IMalcolmModel>- Overrides:
getDeviceStatein classAbstractRunnableDevice<IMalcolmModel>- Returns:
- the device state of the malcolm device
- Throws:
MalcolmDeviceException
-
getModel
Description copied from interface:IRunnableDeviceThe model being used for the device.- Specified by:
getModelin interfaceIModelProvider<IMalcolmModel>- Specified by:
getModelin interfaceIRunnableDevice<IMalcolmModel>- Overrides:
getModelin classAbstractRunnableDevice<IMalcolmModel>- Returns:
-
getDetectorInfos
Description copied from interface:IMalcolmDeviceReturns theMalcolmDetectorInfos for the detectors controlled by this malcolm device, describing their current state.- Returns:
- detector infos
-
getDeviceHealth
Description copied from class:AbstractRunnableDevicePlease override to provide a device health (which a malcolm device will have) The default returns null.- Specified by:
getDeviceHealthin interfaceIRunnableDevice<IMalcolmModel>- Overrides:
getDeviceHealthin classAbstractRunnableDevice<IMalcolmModel>- Returns:
- the current device Health.
- Throws:
MalcolmDeviceException
-
isDeviceBusy
Description copied from class:AbstractRunnableDeviceGets whether the device is busy or not- Specified by:
isDeviceBusyin interfaceIRunnableDevice<IMalcolmModel>- Overrides:
isDeviceBusyin classAbstractRunnableDevice<IMalcolmModel>- Returns:
- the current value of the device 'busy' flag.
- Throws:
MalcolmDeviceException
-
validate
Description copied from class:AbstractRunnableDeviceIf overriding don't forget the old super.validate(...)- Specified by:
validatein interfaceIValidator<IMalcolmModel>- Overrides:
validatein classAbstractRunnableDevice<IMalcolmModel>- Parameters:
model- - a model of type T to validate- Returns:
- a valid model
- Throws:
ValidationException
-
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 classAbstractMalcolmDevice- Parameters:
model-- Throws:
ScanningException
-
run
Description copied from interface:IRunnableDeviceBlocking call to execute the scan. The position specified may be null.- Throws:
MalcolmDeviceException
-
seek
Description copied from interface:IPausableDeviceSeek to/from a point number (absolute) in the scan.- Specified by:
seekin interfaceIPausableDevice<IMalcolmModel>- Overrides:
seekin classAbstractRunnableDevice<IMalcolmModel>- Throws:
MalcolmDeviceException
-
abort
Description copied from interface:IRunnableDeviceCall to terminate the scan before it has finished.- Specified by:
abortin interfaceIRunnableDevice<IMalcolmModel>- Overrides:
abortin classAbstractRunnableDevice<IMalcolmModel>- Throws:
MalcolmDeviceException
-
disable
Description copied from interface:IRunnableDeviceCall to disable the device, stopping all activity.- Specified by:
disablein interfaceIRunnableDevice<IMalcolmModel>- Overrides:
disablein classAbstractRunnableDevice<IMalcolmModel>- Throws:
MalcolmDeviceException
-
reset
Description copied from interface:IResettableDeviceAllowed from Fault. Will try to reset the device into Idle state. Will block until the device is in a rest state.- Specified by:
resetin interfaceIResettableDevice- Overrides:
resetin classAbstractRunnableDevice<IMalcolmModel>- Throws:
MalcolmDeviceException
-
pause
Pauses the device. The implementation delegates to #seek, resulting in a PAUSE command to Malcolm. The defaultSeekStrategyinstructs Malcolm to eventually resume from the last scan point.- Specified by:
pausein interfaceIPausableDevice<IMalcolmModel>- Overrides:
pausein classAbstractRunnableDevice<IMalcolmModel>- Throws:
MalcolmDeviceException
-
resume
Description copied from interface:IPausableDeviceAllowed when the device is in Paused state. Will block until the device is unpaused. When paused the same thread must call resume() or abort() which has paused or an IllegalMonitorState Exception will be thrown.- Specified by:
resumein interfaceIPausableDevice<IMalcolmModel>- Overrides:
resumein classAbstractRunnableDevice<IMalcolmModel>- Throws:
MalcolmDeviceException
-
dispose
Description copied from interface:IMalcolmDeviceDisposes of the malcolm device causing it to disconnect from the underlying malcolm device.- Specified by:
disposein interfaceIMalcolmDevice- Overrides:
disposein classAbstractMalcolmDevice- Throws:
MalcolmDeviceException
-
getVersion
Description copied from interface:IMalcolmDeviceReturns the version of this malcolm device.- Returns:
- version
- Throws:
MalcolmDeviceException- if the version cannot be returned for any reason
-
isLocked
Description copied from interface:IMalcolmDeviceAttempts to determine if the device is locked doing something like a configure or a run.- Returns:
- true if not in locked state, otherwise false.
- Throws:
MalcolmDeviceException
-
getAvailableAxes
Description copied from interface:IMalcolmDeviceReturns the axes that this malcolm device can move.- Returns:
- the axes this malcolm device can move, never
null - Throws:
MalcolmDeviceException
-
getDatasets
Description copied from interface:IMalcolmDeviceReturns aMalcolmTableobject describing the datasets that this malcolm device is configured to create during a scan. This method should only be called afterhas been called on this malcolm device.invalid reference
#configure(IMalcolmModel)- Returns:
- a table of the datasets created by this malcolm device
- Throws:
MalcolmDeviceException- if the datasets table could not be returned for any reason
-
setResetAfterScan
public static void setResetAfterScan(boolean resetAfterScan) -
getSeekStrategy
-
setSeekStrategy
It this is set, it will calculate the scan point the device should resume from based on the last scan point and other device parameters. Otherwise, the default value is -1, indicating the device should resume from the last scanned position. -
closeFile
At the end of a scan, Malcolm remains in a FINISHED state until reset() is called. Only at this point will Malcolm close the file.- Throws:
MalcolmDeviceException
-