|
Abstract Base class common to both DAQ_Move and DAQ_Viewer control modules |
|
Abstract base shared by ActuatorWorker and DetectorWorker. |
|
8.1.1. ControlModule base classes
Both DAQ_Move and DAQ_Viewer control modules share some specificities and inherit from a base class: the ControlModule
- class pymodaq.control_modules.utils.ControlModule(title='')[source]
Abstract Base class common to both DAQ_Move and DAQ_Viewer control modules
- Variables:
init_signal (
pyqtSignal) – This signal is emitted when the chosen hardware is correctly initializedcommand_hardware (
pyqtSignal) – This signal is used to communicate with the instrument plugin within a separate threadquit_signal (
pyqtSignal) – This signal is emitted when the user requested to stop the module
- Attributes:
- h5saver
initialized_statebool: Check if the module is initialized
module_and_data_saverThe module saver used for continuous saving (see ParameterControlModule).
module_typeGet the module type, either DAQ_Move or DAQ_viewer
titlestr: get the title of the module
- ui
Methods
grab()Programmatic entry to grab data from detectors or current value from actuator
init_hardware([do_init])Programmatic entry to initialize/deinitialize the control module
init_hardware_ui([do_init])Programmatic entry to simulate a click on the user interface init button
manage_ui_actions(action_name, attribute, value)Method to manage actions for the UI (if any).
quit_fun()Programmatic entry to quit the control module
Handle a timeout event: display a status message.
Programmatic entry to stop data grabbing from detectors or current value polling from actuator
Programmatic entry to stop the Control module either moving, polling or grabbing
thread_status(status)Get back info (using the ThreadCommand object) from the hardware
update_status(txt[, log])Display a message in the ui status bar and eventually log the message
append_data
close_file
command_hardware
create_new_file
custom_command
custom_sig
get_color_from_status
init_signal
instrument_changed
quit_signal
status_sig
timeout_signal
- init_hardware(do_init=True)[source]
Programmatic entry to initialize/deinitialize the control module
- Parameters:
do_init (
bool) – if True initialize the selected hardware else deinitialize it
See also
- init_hardware_ui(do_init=True)[source]
Programmatic entry to simulate a click on the user interface init button
- Parameters:
do_init (
bool) – if True initialize the selected hardware else deinitialize it
Notes
This method should be preferred to
init_hardware()
- manage_ui_actions(action_name, attribute, value)[source]
Method to manage actions for the UI (if any).
Will try to apply the given value to the given attribute of the corresponding action
- Parameters:
Examples
>>>manage_ui_actions(‘quit’, ‘setEnabled’, False) # will disable the quit action (button) on the UI
- stop_grab()[source]
Programmatic entry to stop data grabbing from detectors or current value polling from actuator
- stop_module()[source]
Programmatic entry to stop the Control module either moving, polling or grabbing
- thread_status(status)[source]
Get back info (using the ThreadCommand object) from the hardware
And re-emit this ThreadCommand using the custom_sig signal if it should be used in a higher level module
- Parameters:
status (
ThreadCommand) –The info returned from the hardware, the command (str) can be either:
Update_Status: display messages and log info (deprecated)
update_status: display info on the UI status bar
error: an exception was raised by the plugin, display it on the UI status bar and mark the module in error
close: close the current thread and delete corresponding attribute on cascade.
update_settings: Update the “detector setting” node in the settings tree.
update_main_settings: update the “main setting” node in the settings tree
raise_timeout:
show_splash: Display the splash screen with attribute as message
close_splash
show_config: display the plugin configuration
- update_status(txt, log=True)[source]
Display a message in the ui status bar and eventually log the message
- property module_and_data_saver: DetectorSaver | ActuatorSaver | None
The module saver used for continuous saving (see ParameterControlModule).
No fallback onto the generic
self.h5saver: its getter creates or reopens a file on every access, which used to leave stray files behind each time a saver was attached here before its real h5saver.- Setter accepts:
- property module_type: ControleModuleType
Get the module type, either DAQ_Move or DAQ_viewer
The hardware plugin of each control module lives in a separate thread, wrapped in a worker deriving from the HardwareWorkerBase class
- class pymodaq.control_modules.utils.HardwareWorkerBase(title, plugin_name)[source]
Abstract base shared by ActuatorWorker and DetectorWorker.
Provides common signals, a unified plugin reference, shared update_settings dispatch, and a queue_command handler for the commands that both worker classes share (ini_hardware, close).
Subclasses must implement:
ini_hardware(params_state, controller) -> edictclose() -> str
and set the class attribute
_kind: str, e.g. ‘actuator’ or ‘detector’. The settings key is derived automatically as"<kind>_settings".- Attributes:
- plugin_name
- title
Methods
queue_command(command)Handle commands shared by all hardware workers.
report_error(error[, context])Log an exception raised by the instrument plugin and show it in the control module
update_settings(settings_parameter_dict)Route a settings change to either main_settings or the plugin subtree.
close
close_hardware
ini_hardware
status_sig
- queue_command(command)[source]
Handle commands shared by all hardware workers.
Returns True if the command was consumed, False so the subclass can handle its own commands.
- Return type:
- report_error(error, context='')[source]
Log an exception raised by the instrument plugin and show it in the control module
The control module displays the message in its status bar and marks itself in error (see
ControlModule.thread_status()), so that a refused move or a failed reading is not only visible in the log.
The same is also true for the UI of these modules sharing a common UI base class: the ControlModuleUI