Engines
An MxDC Engine is an object which manages common operations involving multiple devices. Engines can spawn threads to run operations asynchronously as needed.
All engines in MxDC are derived from the base class mxdc.Engine
which provides a default set of methods attributes
and signals for all device types. Specific Engines types can be created by subclassing mxdc.Engine
and adding
required methods, signals and attributes.
- class mxdc.Engine
Base class for all Engines.
An Engine provides utilities for running stoppable/pausable activities in a thread, reporting progress and notifying watchers of the start, end and progress of the activity
Signals
started: arg_types=(data: object,)
stopped: arg_types=(data: object,)
busy: arg_types=(bool,)
done: arg_types=(data: object,)
error: arg_types=(str,)
paused: arg_types=(paused: bool, reason: str)
progress: arg_types=(fraction: float, message: str)
Attributes
beamline: Beamline Object
- execute()
Run engine in the current thread :return: the result of the run method
- is_busy()
Check if the engine is busy
- is_paused()
Check if the engine is paused
- is_stopped()
Check if the engine is stopped
- pause(reason='')
Pause the engine
- Parameters
reason – Optional string describing the reason for the pause
- resume()
Resume from the paused state
- run()
This method should contain the implementation details of the engine operation. It should appropriately monitor the stopped and paused variables and act accordingly.
- start()
Start the engine as a daemon thread
- stop()
Stop the engine
The following are some examples of engines included by default.
- class mxdc.engines.scanning.BasicScan
Base Class for all Scan engines.
Signals
new-point: (object,) new scan point
new-row: (int,) new scan row for multi-row scans
message: (str,) messages
- configure(**kwargs)
Set configuration parameters
- Parameters
kwargs – keyword, value pairs to add to configuration
- Returns
config object, fields are dictionary keywords
- extend(amount)
Extend the scan by the given amount. Subclasses should update the configuration before calling the base class extend() method since this method will start the scan.
- Parameters
amount – amount to extend scan by
- finalize()
Convert the data after the scan is complete and finalize before wrapping up
- get_specs()
Get the scan specification describing the scan and scan data
- Returns
dictionary
- prepare_xdi(data=None)
Prepare XDI file for saving :param data: If provided, use this data instead of self.data :return: xdi_data object
- run()
Run the scan in the current execution loop. Normally executed in a thread when the start method is called. Sub-classes are discouraged from re-implementing this method. Instead override the
scan()
method.
- save(filename=None, suffix='')
Save the scan data.
- Parameters
filename – full path to data file. If None, a file name will be generated.
suffix – text to add to filename before extension
- Returns
the file name of the saved file
- scan()
Scan implementation. Details must be implemented by sub-classes
- setup(motors, counters, i0=None)
Setup scan data configuration
- Parameters
motors – sequence of motors
counters – sequence of counters
i0 – reference counter
- start()
Start the scan engine