Class MalcolmDeviceProxy
java.lang.Object
org.eclipse.scanning.event.remote.MalcolmDeviceProxy
- All Implemented Interfaces:
AutoCloseable,IActivatable,IPausableDevice<IMalcolmModel>,IResettableDevice,IRunnableDevice<IMalcolmModel>,IRunnableEventDevice<IMalcolmModel>,IDeviceRoleActor,IConnection,IConfigurable<IMalcolmModel>,ILevel,IModelProvider<IMalcolmModel>,INameable,IValidator<IMalcolmModel>,IMalcolmDevice
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IEventServiceprotected DeviceInformation<IMalcolmModel> protected Stringprotected final IRequester<DeviceRequest> protected URI -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Call to terminate the scan before it has finished.voidaddMalcolmListener(IMalcolmEventListener listener) Add a listener to malcolm changes.voidA listener which notifies when a run of the device will occur and after it has occurred.voidconfigure(IMalcolmModel model) Call to configure the device.voiddisable()Call to disable the device, stopping all activity.voidCall to disconnect any resources which we no longer need.voiddispose()Disposes of the malcolm device causing it to disconnect from the underlying malcolm device.voidfireRunPerformed(IPosition position) Called during the scanning to notify the device that the run method has been called at a given position.voidfireRunWillPerform(IPosition position) Called during the scanning to notify the device that the run method will be called at a given position.voidfireWritePerformed(IPosition position) Called during the scanning to notify the device that the write method has been called at a given position, if the device implements one.voidfireWriteWillPerform(IPosition position) Called during the scanning to notify the device that the write method will be called at a given position, if the device implements one.Returns the axes that this malcolm device can move.Returns the axes that this malcolm device is currently configured to 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.protected IEventServiceintgetLevel()getModel()The model being used for the device.getName()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 withgetRole()The role of the device.Returns a set of the scan modes that this device can participate in.getUri()Returns the version of this malcolm device.voidInitializes the connection to the actual malcolm device.booleanbooleanisAlive()Gets whether the device is 'alive' or not.booleanReturns whether this connection is connected.booleanbooleanisLocked()Attempts to determine if the device is locked doing something like a configure or a run.protected voidmerge(DeviceInformation<IMalcolmModel> info) protected voidmethod(DeviceRequest deviceRequest) voidpause()Allowed when the device is in Running state.voidremoveMalcolmListener(IMalcolmEventListener listener) Remove a listener to malcolm changes.voidA listener which notifies when a run of the device will occur and after it has occurred.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.booleansetActivated(boolean activated) voidsetAlive(boolean alive) Sets whether the device is alive or notvoidsetConnected(boolean isConnected) voidsetEventService(IEventService eservice) voidsetLevel(int level) voidvoidsetOutputDir(String fileDir) Set the directory where malcolm will write its h5 files to.voidsetPointGenerator(IPointGenerator<? extends IScanPointGeneratorModel> pointGenerator) Set the point generator for the malcolm device.voidsetRole(DeviceRole role) The role of the device.voidprotected DeviceRequestupdate()validate(IMalcolmModel model) If the given model is considered "invalid", this method may either throw a ModelValidationException explaining why it is considered invalid or return a modified version of the model that does pass validation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.scanning.api.IConfigurable
configureMethods inherited from interface org.eclipse.scanning.api.event.core.IConnection
closeMethods 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.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, start, throwFirstRunExceptionMethods inherited from interface org.eclipse.scanning.api.IValidator
setService, validate
-
Field Details
-
name
-
info
-
requester
-
eservice
-
uri
-
-
Method Details
-
addRunListener
Description copied from interface:IRunnableEventDeviceA listener which notifies when a run of the device will occur and after it has occurred. This can be used to modify the model before the next run.- Specified by:
addRunListenerin interfaceIRunnableEventDevice<IMalcolmModel>- Throws:
ScanningException
-
removeRunListener
Description copied from interface:IRunnableEventDeviceA listener which notifies when a run of the device will occur and after it has occurred. This can be used to modify the model before the next run.- Specified by:
removeRunListenerin interfaceIRunnableEventDevice<IMalcolmModel>- Throws:
ScanningException
-
fireRunWillPerform
Description copied from interface:IRunnableEventDeviceCalled during the scanning to notify the device that the run method will be called at a given position. This method is called on the same thread that the run() method is called on, e.g. parallel execution by level in the case of AcquisitionDevice.- Specified by:
fireRunWillPerformin interfaceIRunnableEventDevice<IMalcolmModel>- Parameters:
position-- Throws:
ScanningException
-
fireRunPerformed
Description copied from interface:IRunnableEventDeviceCalled during the scanning to notify the device that the run method has been called at a given position. This method is called on the same thread that the run() method is called on, e.g. parallel execution by level in the case of AcquisitionDevice.- Specified by:
fireRunPerformedin interfaceIRunnableEventDevice<IMalcolmModel>- Parameters:
position-- Throws:
ScanningException
-
fireWriteWillPerform
Description copied from interface:IRunnableEventDeviceCalled during the scanning to notify the device that the write method will be called at a given position, if the device implements one. This method is called on the same thread that the write() method is called on, e.g. parallel execution by level in the case of AcquisitionDevice. NOTE: If the write method returns false, fireWritePerformed is not called. However fireWriteWillPerform will still be called. This is because until the device attempts to write we do not know if is has written.- Specified by:
fireWriteWillPerformin interfaceIRunnableEventDevice<IMalcolmModel>- Parameters:
position-- Throws:
ScanningException
-
fireWritePerformed
Description copied from interface:IRunnableEventDeviceCalled during the scanning to notify the device that the write method has been called at a given position, if the device implements one. This method is called on the same thread that the write() method is called on, e.g. parallel execution by level in the case of AcquisitionDevice. NOTE: If the write method returns false, fireWritePerformed is not called. However fireWriteWillPerform will still be called. This is because until the device attempts to write we do not know if is has written.- Specified by:
fireWritePerformedin interfaceIRunnableEventDevice<IMalcolmModel>- Parameters:
position-- Throws:
ScanningException
-
pause
Description copied from interface:IPausableDeviceAllowed when the device is in Running state. Will block until the device is in a rest state. When paused the same thread must call resume() or abort() which has paused or an IllegalMonitorState Exception will be thrown.- Specified by:
pausein interfaceIPausableDevice<IMalcolmModel>- Throws:
ScanningExceptionInterruptedException
-
seek
Description copied from interface:IPausableDeviceSeek to/from a point number (absolute) in the scan.- Specified by:
seekin interfaceIPausableDevice<IMalcolmModel>- Throws:
ScanningExceptionInterruptedException
-
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>- Throws:
ScanningExceptionInterruptedException
-
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
-
isLocked
Description copied from interface:IMalcolmDeviceAttempts to determine if the device is locked doing something like a configure or a run.- Specified by:
isLockedin interfaceIMalcolmDevice- Returns:
- true if not in locked state, otherwise false.
- Throws:
MalcolmDeviceException
-
getVersion
Description copied from interface:IMalcolmDeviceReturns the version of this malcolm device.- Specified by:
getVersionin interfaceIMalcolmDevice- Returns:
- version
- Throws:
MalcolmDeviceException- if the version cannot be returned for any reason
-
getAvailableAxes
Description copied from interface:IMalcolmDeviceReturns the axes that this malcolm device can move.- Specified by:
getAvailableAxesin interfaceIMalcolmDevice- Returns:
- the axes this malcolm device can move, never
null - Throws:
MalcolmDeviceException
-
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
-
getDetectorInfos
Description copied from interface:IMalcolmDeviceReturns theMalcolmDetectorInfos for the detectors controlled by this malcolm device, describing their current state.- Specified by:
getDetectorInfosin interfaceIMalcolmDevice- Returns:
- detector infos
- 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)- Specified by:
getDatasetsin interfaceIMalcolmDevice- Returns:
- a table of the datasets created by this malcolm device
- Throws:
MalcolmDeviceException- if the datasets table could not be returned for any reason
-
setPointGenerator
Description copied from interface:IMalcolmDeviceSet the point generator for the malcolm device.- Specified by:
setPointGeneratorin interfaceIMalcolmDevice- Parameters:
pointGenerator- point generator
-
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
-
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-
-
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
-
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<M>- Parameters:
model-- Throws:
ScanningException
-
getModel
Description copied from interface:IRunnableDeviceThe model being used for the device.- Specified by:
getModelin interfaceIModelProvider<M>- Specified by:
getModelin interfaceIRunnableDevice<M>- Returns:
-
getDeviceHealth
- Specified by:
getDeviceHealthin interfaceIRunnableDevice<M>- Returns:
- the current device Health.
- Throws:
ScanningException
-
isDeviceBusy
- Specified by:
isDeviceBusyin interfaceIRunnableDevice<M>- Returns:
- the current value of the device 'busy' flag.
- Throws:
ScanningException
-
getRole
Description copied from interface:IDeviceRoleActorThe role of the device.- Specified by:
getRolein interfaceIDeviceRoleActor- Returns:
- role of the device
-
setRole
Description copied from interface:IDeviceRoleActorThe role of the device.- Specified by:
setRolein interfaceIDeviceRoleActor- Parameters:
role- role of the device
-
getSupportedScanModes
Description copied from interface:IDeviceRoleActorReturns a set of the scan modes that this device can participate in.- Specified by:
getSupportedScanModesin interfaceIDeviceRoleActor- Returns:
- possible roles of the device
-
validate
Description copied from interface:IValidatorIf the given model is considered "invalid", this method may either throw a ModelValidationException explaining why it is considered invalid or return a modified version of the model that does pass validation. If the model is valid, it is returned. A model should be considered invalid if its parameters would cause the generator implementation to hang or crash.- Specified by:
validatein interfaceIValidator<M>- Parameters:
model- - a model of type T to validate- Returns:
- a valid model
- Throws:
ValidationException
-
getDeviceState
- Specified by:
getDeviceStatein interfaceIRunnableDevice<M>- Returns:
- the current device State. This is not the same as the Status of the scan.
- Throws:
ScanningException
-
update
-
run
Description copied from interface:IRunnableDeviceBlocking call to execute the scan. The position specified may be null.- Specified by:
runin interfaceIRunnableDevice<M>- Throws:
ScanningExceptionInterruptedException
-
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- Throws:
ScanningException
-
abort
Description copied from interface:IRunnableDeviceCall to terminate the scan before it has finished.- Specified by:
abortin interfaceIRunnableDevice<M>- Throws:
ScanningException
-
disable
Description copied from interface:IRunnableDeviceCall to disable the device, stopping all activity.- Specified by:
disablein interfaceIRunnableDevice<M>- Throws:
ScanningException
-
isActivated
public boolean isActivated()- Specified by:
isActivatedin interfaceIActivatable- Returns:
- true if device is activated.
-
setActivated
- Specified by:
setActivatedin interfaceIActivatable- Parameters:
activated-- Returns:
- the old value of activated
- Throws:
ScanningException
-
isAlive
public boolean isAlive()Description copied from interface:IRunnableDeviceGets whether the device is 'alive' or not. 'Alive' is taken to mean that the device is on and responding.- Specified by:
isAlivein interfaceIRunnableDevice<M>- Returns:
-
setAlive
public void setAlive(boolean alive) Description copied from interface:IRunnableDeviceSets whether the device is alive or not- Specified by:
setAlivein interfaceIRunnableDevice<M>- Parameters:
alive-
-
disconnect
Description copied from interface:IConnectionCall to disconnect any resources which we no longer need. The resource may have timed out so it might not be connected, in that case it silently returns. Note, that the methodIConnection.close(), inherited fromAutoCloseablecalls this method, which means that if an object of a class implementingIConnectionis used with a try-with-resources block this method will be called automatically when exiting that block.- Throws:
EventException- if resource could not be disconnected.
-
getName
-
setName
-
setLevel
public void setLevel(int level) -
getLevel
public int getLevel() -
merge
-
method
- Throws:
ScanningException
-
getEventService
-
setEventService
-
getUri
-
setUri
-
isConnected
public boolean isConnected()Description copied from interface:IConnectionReturns whether this connection is connected. This method returnstrueuntil disconnect is called, even if the connection is created lazily.- Specified by:
isConnectedin interfaceIConnection- Returns:
trueif connected,falseotherwise
-
setConnected
public void setConnected(boolean isConnected)
-