Summary of the classes dealing with the DAQ_Viewer control module:
|
Main PyMoDAQ class to drive detectors |
|
Worker class to control the instrument plugin |
|
DAQ_Viewer user interface. |
8.1.2. DAQ_Viewer class
This documentation highlights the useful entry and output points that you may use in your applications.
- class pymodaq.control_modules.daq_viewer.DAQ_Viewer(parent=None, title='Testing', daq_type='DAQ0D', dock_settings=None, dock_viewer=None)[source]
Bases:
ParameterManager
,ControlModule
Main PyMoDAQ class to drive detectors
Qt object and generic UI to drive actuators. The class is giving you full functionality to select (daq_detector), initialize detectors (init_hardware), grab or snap data (grab_data) and save them (save_new, save_current). If a DockArea is given as parent widget, the full User Interface (DAQ_Viewer_UI) is loaded allowing easy control of the instrument.
- grab_done_signal
Signal emitted when the data from the plugin (and eventually from the data viewers) has been received. To be used by connected objects.
- Type
Signal[DataToExport]
- custom_sig
use this to propagate info/data coming from the hardware plugin to another object
- Type
Signal[ThreadCommand]
- overshoot_signal
This signal is emitted when some 0D data from the plugin is higher than the overshoot threshold set in the settings
- Type
Signal[bool]
See also
ControlModule
,DAQ_Viewer_UI
,ParameterManager
Notes
A particular signal from the 2D DataViewer is directly connected to the plugin: ROI_select_signal. The position and size of the corresponding ROI is then directly transferred to a plugin function named ROISelect that you have to create if one want to receive infos from the ROI
- Attributes
- Naverage
bkg
Get the background data object
current_data
Get the current data stored internally
daq_type
Get/Set the daq_type as a DAQTypesEnum
daq_types
List of available DAQ_TYPES as keys of the DAQTypesEnum
detector
str
: Get/Set the currently selected detector among available detectorsdetectors
list
ofstr
: List of available detectors of the current daq_type (DAQTypesEnum)do_bkg
bool
: Get/Set if background subtraction should be donegrab_state
bool
: Get the current grabbing statusviewer_docks
list of Viewer Docks from the UI
viewers
list
: Get/Set the Viewers (instances of real implementation of ViewerBase class) from the UIviewers_docks
list of Viewer Docks from the UI, for back compatibility
Methods
append_data
([dte, where])Appends current DataToExport to a DetectorEnlargeableSaver
child_added
(param, data)Adds a child in the settings attribute
Init a TCPClient in a separated thread to communicate with a distant TCp/IP Server
daq_type_changed_from_ui
(daq_type)Apply changes from the selection of a different DAQTypesEnum in the UI
Create axes scaling options depending on the ('main_settings', 'axes') settings
grab
()Launch a continuous grab
grab_data
([grab_state, send_to_tcpip, ...])Generic method to grab or snap data from the selected (and initialized) detector
init_hardware
([do_init])Init the selected detector
insert_data
(indexes[, where, distribution])Insert DataToExport to a DetectorExtendedSaver at specified indexes
Opens a H5 file in the H5Browser module
param_deleted
(param)Remove a child from the settings attribute
process_tcpip_cmds
(status)Receive commands from the TCP Server (if connected) and process them
process_ui_cmds
(cmd)Process commands sent by actions done in the ui
quit_fun
()Quit the application, closing the hardware and other modules
Save current data into a h5file
save_new
()Snap data and save them into a h5file
set_data_to_viewers
(dte[, temp])Process data dimensionality and send appropriate data to their data viewers
Configure the objects dealing with the continuous saving mode
show_data
(dte)Send data to their dedicated viewers
show_temp_data
(data)Send data to their dedicated viewers but those will not emit processed data signal
snap
()Launch a single grab
snapshot
([pathname, dosave, send_to_tcpip])Do one single grab (snap) and eventually save the data.
stop
()Stop the current continuous grabbing
Stop the current continuous grabbing and unchecked the stop button of the UI
take_bkg
()Do a snap and store data to be used as background into an attribute: self._bkg
thread_status
(status)Get back info (using the ThreadCommand object) from the hardware
value_changed
(param)ParameterManager subclassed method.
custom_sig
data_saved
detector_changed_from_ui
detectors_changed_from_ui
grab_done_signal
grab_status
overshoot_signal
update_plugin_config
- append_data(dte: Optional[DataToExport] = None, where: Optional[Union[Node, str]] = None)[source]
Appends current DataToExport to a DetectorEnlargeableSaver
Method to be used when performing continuous saving into a h5file (continuous mode or DAQ_Logger)
- Parameters
dte (DataToExport) – not really used
where (Node or str) –
See also
DetectorEnlargeableSaver
- child_added(param, data)[source]
Adds a child in the settings attribute
- Parameters
param (Parameter) – the parameter where child will be added
data (Parameter) – the child parameter
- connect_tcp_ip()[source]
Init a TCPClient in a separated thread to communicate with a distant TCp/IP Server
Use the settings: ip_address and port to specify the connection
See also
TCPServer
- daq_type_changed_from_ui(daq_type: DAQTypesEnum)[source]
Apply changes from the selection of a different DAQTypesEnum in the UI
- Parameters
daq_type (DAQTypesEnum) –
- get_scaling_options()[source]
Create axes scaling options depending on the (‘main_settings’, ‘axes’) settings
- Return type
Tuple[Axis]
- grab_data(grab_state=False, send_to_tcpip=False, snap_state=False)[source]
Generic method to grab or snap data from the selected (and initialized) detector
- init_hardware(do_init=True)[source]
Init the selected detector
- Parameters
do_init (bool) – If True, create a DAQ_Detector instance and move it into a separated thread, connected its signals/slots to the DAQ_Viewer object (self) If False, force the instrument to close and kill the Thread (still not done properly in some cases)
- insert_data(indexes: Tuple[int], where: Optional[Union[Node, str]] = None, distribution=DataDistribution.uniform)[source]
Insert DataToExport to a DetectorExtendedSaver at specified indexes
Method to be used when saving into an already initialized array within a h5file (DAQ_Scan for instance)
- Parameters
See also
DAQ_Scan
,DetectorExtendedSaver
- param_deleted(param)[source]
Remove a child from the settings attribute
- Parameters
param (Parameter) – a given parameter whose value has been changed by user
- process_tcpip_cmds(status)[source]
Receive commands from the TCP Server (if connected) and process them
- Parameters
status (ThreadCommand) – Possible commands are: * ‘Send Data: to trigger a snapshot * ‘connected’: show that connection is ok * ‘disconnected’: show that connection is not OK * ‘Update_Status’: update a status command * ‘set_info’: receive settings from the server side and update them on this side
See also
connect_tcp_ip
,TCPServer
- process_ui_cmds(cmd: ThreadCommand)[source]
Process commands sent by actions done in the ui
- Parameters
cmd (ThreadCommand) –
- Possible values are:
init
quit
grab
snap
stop
show_log
detector_changed
daq_type_changed
save_current
save_new
do_bkg
take_bkg
viewers_changed
show_config
- set_data_to_viewers(dte: DataToExport, temp=False)[source]
Process data dimensionality and send appropriate data to their data viewers
- Parameters
dte (DataToExport) –
temp (bool) – if True notify the data viewers to display data as temporary (meaning not exporting processed data from roi)
See also
ViewerBase
,Viewer0D
,Viewer1D
,Viewer2D
- show_data(dte: DataToExport)[source]
Send data to their dedicated viewers
Slot receiving data from plugins emitted with the data_grabed_signal Process the data as specified in the settings, display them into the dedicated data viewers depending on the settings:
create a container (OrderedDict _data_to_save_export) with info from this DAQ_Viewer (title), a timestamp…
call _process_data
do background subtraction if any
check refresh time (if set in the settings) to send or not data to data viewers
either send to the data viewers (if refresh time is ok and/or show data option in settings is set)
- either
send grab_done_signal (to the slot _save_export_data ) to save the data
- Parameters
dte (DataToExport) –
See also
_init_show_data
,_process_data
- show_temp_data(data: DataToExport)[source]
Send data to their dedicated viewers but those will not emit processed data signal
Slot receiving data from plugins emitted with the data_grabed_signal_temp
- Parameters
data (list of DataFromPlugins) –
- snapshot(pathname=None, dosave=False, send_to_tcpip=False)[source]
Do one single grab (snap) and eventually save the data.
- stop_grab()[source]
Stop the current continuous grabbing and unchecked the stop button of the UI
See also
- take_bkg()[source]
Do a snap and store data to be used as background into an attribute: self._bkg
The content of the bkg will be saved if data is further saved with do_bkg property set to True
- thread_status(status: ThreadCommand)[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
Commands valid for all control modules are defined in the parent class, here are described only the specific ones
- Parameters
status (ThreadCommand) –
- The info returned from the hardware, the command (str) can be either:
ini_detector: update the status with “detector initialized” value and init state if attribute not null.
grab : emit grab_status(True)
grab_stopped: emit grab_status(False)
init_lcd: display a LCD panel
lcd: display on the LCD panel, the content of the attribute
stop: stop the grab
- value_changed(param: Parameter)[source]
ParameterManager subclassed method. Process events from value changed by user in the UI Settings
- Parameters
param (Parameter) – a given parameter whose value has been changed by user
- property bkg: DataToExport
Get the background data object
- property current_data: DataToExport
Get the current data stored internally
- property daq_type: DAQTypesEnum
Get/Set the daq_type as a DAQTypesEnum
Update the detector property with the list of available detectors of a given daq_type
8.1.3. DAQ_Detector class
The Detector class is an object leaving in the plugin thread and responsible for the communication between DAQ_Viewer and the plugin itself
- class pymodaq.control_modules.daq_viewer.DAQ_Detector(title, settings_parameter, detector_name)[source]
Worker class to control the instrument plugin
- detector
- Type
real instance of the instrument plugin class
- controller
wrapper object used to control a given instrument in the instrument plugin
- Type
DAQ_Viewer_base
- controller_adress
unique integer used to identify a controller shared among multiple instrument plugins
- Type
- Attributes
- title
Methods
close
()Call the close method of the instrument plugin class
data_ready
(data)Process the data received from the instrument plugin class
emit_temp_data
(data)Convenience method to export temporary data using the data_detector_temp_sig Signal
grab_data
([Naverage, live])General method to grab data from the instrument plugin class
ini_detector
([params_state, controller])Initialize an instrument plugin class and tries to apply preset settings
queue_command
(command)Transfer command from the main module to the hardware module
single
([Naverage])Convenience function to grab a single set of data
update_settings
(settings_parameter_dict)Apply a Parameter serialized as a dict to the instrument plugin class or to self
data_detector_sig
data_detector_temp_sig
status_sig
- data_ready(data: DataToExport)[source]
Process the data received from the instrument plugin class
Processing here is eventual software averaging if it was not possible in the instrument plugin class
- Parameters
data (DataToExport) –
- emit_temp_data(data: DataToExport)[source]
Convenience method to export temporary data using the data_detector_temp_sig Signal
- Parameters
data (DataToExport) –
- grab_data(Naverage=1, live=True, **kwargs)[source]
General method to grab data from the instrument plugin class
Will check if the plugin class can do hardware averaging (if NAverage > 1) and and live_mode, otherwise do both software wise here
- ini_detector(params_state=None, controller=None)[source]
Initialize an instrument plugin class and tries to apply preset settings
When the instrument is initialized from the Dashboard using a Preset, tries to apply the preset settings to the instrument instance
- Parameters
params_state (dict) –
controller (wrapper) –
- queue_command(command: ThreadCommand)[source]
Transfer command from the main module to the hardware module
- Parameters
command (ThreadCommand) – The specific (or generic) command (str) to pass to the hardware, either: * ini_detector * close * grab * single * stop_grab * stop_all * update_scanner * move_at_navigator * update_wait_time * get_axis * any string that the hardware is able to understand
- single(Naverage=1, *args, **kwargs)[source]
Convenience function to grab a single set of data
- Parameters
Naverage (int) – The number of data to average before displaying
kwargs (optional named arguments) –
- update_settings(settings_parameter_dict)[source]
Apply a Parameter serialized as a dict to the instrument plugin class or to self
- Parameters
settings_parameter_dict (dict) – dictionary serializing a Parameter object
Examples
If the parameter is of the form (‘detector_settings’, ‘xxx’) then the parameter is sent to the instrument plugin class.
8.1.4. The Viewer UI class
This object is the User Interface of the DAQ_Viewer, allowing easy access to all of the DAQ_Viewer functionnalities in a generic interface.
- class pymodaq.control_modules.daq_viewer_ui.DAQ_Viewer_UI(parent, title='DAQ_Viewer', daq_type='DAQ2D', dock_settings=None, dock_viewer=None)[source]
DAQ_Viewer user interface.
This class manages the UI and emit dedicated signals depending on actions from the user
- command_sig
This signal is emitted whenever some actions done by the user has to be applied on the main module. Possible commands are:
init
quit
grab
snap
stop
show_log
detector_changed
daq_type_changed
save_current
save_new
- Type
Signal[Threadcommand]
- Attributes
- daq_type
- daq_types
- data_ready
- detector
detector_init
bool: the status of the init LED.
- detectors
Methods
Connect actions and/or other widgets signal to methods
do_grab
([do_grab])Programmatically press the Grab button API entry :param do_grab: will fire the Init button depending on the argument value and the button check state :type do_grab: bool
do_init
([do_init])Programmatically press the Init button API entry :param do_init: will fire the Init button depending on the argument value and the button check state :type do_init: bool
do_snap
()Programmatically press the Snap button API entry
do_stop
()Programmatically press the Stop button API entry
send_init
(checked)Should be implemented to send to the main app the fact that someone (un)checked init.
Method where to create actions to be subclassed.
Mandatory method to be subclassed to setup the docks layout
update_viewers
(viewers_type)- param viewers_type
add_setting_tree
close
command_sig
show_controls
show_settings
- do_grab(do_grab=True)[source]
Programmatically press the Grab button API entry :param do_grab: will fire the Init button depending on the argument value and the button check state :type do_grab: bool
- do_init(do_init=True)[source]
Programmatically press the Init button API entry :param do_init: will fire the Init button depending on the argument value and the button check state :type do_init: bool
- send_init(checked: bool)[source]
Should be implemented to send to the main app the fact that someone (un)checked init.
- setup_actions()[source]
Method where to create actions to be subclassed. Mandatory
Examples
>>> self.add_action('Quit', 'close2', "Quit program") >>> self.add_action('Grab', 'camera', "Grab from camera", checkable=True) >>> self.add_action('Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera", checkable=False) >>> self.add_action('Save', 'SaveAs', "Save current data", checkable=False)
See also
ActionManager.add_action
- setup_docks()[source]
Mandatory method to be subclassed to setup the docks layout
Examples
>>>self.docks[‘ADock’] = gutils.Dock(‘ADock name’) >>>self.dockarea.addDock(self.docks[‘ADock’]) >>>self.docks[‘AnotherDock’] = gutils.Dock(‘AnotherDock name’) >>>self.dockarea.addDock(self.docks[‘AnotherDock’’’], ‘bottom’, self.docks[‘ADock’])
See also
pyqtgraph.dockarea.Dock