Summary of the classes dealing with the DAQ_Viewer control module:

DAQ_Viewer([parent, title, daq_type, ...])

Main PyMoDAQ class to drive detectors

DAQ_Detector(title, settings_parameter, ...)

Worker class to control the instrument plugin

DAQ_Viewer_UI(parent[, title, daq_type, ...])

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 detectors

detectors

list of str: List of available detectors of the current daq_type (DAQTypesEnum)

do_bkg

bool: Get/Set if background subtraction should be done

grab_state

bool: Get the current grabbing status

viewer_docks

list of Viewer Docks from the UI

viewers

list: Get/Set the Viewers (instances of real implementation of ViewerBase class) from the UI

viewers_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

connect_tcp_ip()

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

get_scaling_options()

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

load_data()

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()

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

setup_continuous_saving()

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_grab()

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

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()[source]

Launch a continuous grab

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

Parameters
  • grab_state (bool) – Defines the grab status: if True: do live grabbing if False stops the grab

  • send_to_tcpip (bool) – If True, send the grabbed data through the TCP/IP pipe

  • snap_state (bool) – if True performs a single grab

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
  • indexes (tuple(int)) – The indexes within the extended array where to place these data

  • where (Node or str) –

  • distribution (DataDistribution enum) –

See also

DAQ_Scan, DetectorExtendedSaver

static load_data()[source]

Opens a H5 file in the H5Browser module

Convenience static method.

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

quit_fun()[source]

Quit the application, closing the hardware and other modules

save_current()[source]

Save current data into a h5file

save_new()[source]

Snap data and save them into a h5file

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

setup_continuous_saving()[source]

Configure the objects dealing with the continuous saving mode

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) –

snap()[source]

Launch a single grab

snapshot(pathname=None, dosave=False, send_to_tcpip=False)[source]

Do one single grab (snap) and eventually save the data.

Parameters
  • pathname (str or Path object) – The path where to save data

  • dosave (bool) – Do save or just grab data

  • send_to_tcpip (bool) – If True, send the grabbed data through the TCP/IP pipe

stop()[source]

Stop the current continuous grabbing

stop_grab()[source]

Stop the current continuous grabbing and unchecked the stop button of the UI

See also

stop()

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

property daq_types: List[str]

List of available DAQ_TYPES as keys of the DAQTypesEnum

property detector: str

Get/Set the currently selected detector among available detectors

Type

str

property detectors: str

List of available detectors of the current daq_type (DAQTypesEnum)

Type

list of str

property do_bkg: bool

Get/Set if background subtraction should be done

Type

bool

property grab_state

Get the current grabbing status

Type

bool

property viewer_docks: List[Dock]

list of Viewer Docks from the UI

property viewers: List[ViewerBase]

Get/Set the Viewers (instances of real implementation of ViewerBase class) from the UI

Type

list

property viewers_docks: List[Dock]

list of Viewer Docks from the UI, for back compatibility

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

int

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

close()[source]

Call the close method of the instrument plugin class

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

Parameters
  • Naverage (int) – The number of data to average

  • live (bool) – Try to run the instrument plugin class grabbing in live mode

  • kwargs (optional named arguments passed to the grab_data method of the instrument plugin class) –

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]

display_value(value: float)

Update the display of the actuator’s value on the UI

do_init()[source]

Programmatic init

Attributes
daq_type
daq_types
data_ready
detector
detector_init

bool: the status of the init LED.

detectors

Methods

connect_things()

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.

setup_actions()

Method where to create actions to be subclassed.

setup_docks()

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

connect_things()[source]

Connect actions and/or other widgets signal to methods

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

do_snap()[source]

Programmatically press the Snap button API entry

do_stop()[source]

Programmatically press the Stop button API entry

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

update_viewers(viewers_type: List[ViewersEnum])[source]
Parameters
  • viewers_type (List[ViewersEnum]) –

  • viewers_name (List[str] or None) –

  • force (bool) – if True remove all viewers before update else check if new viewers type are compatible with old ones

property detector_init

the status of the init LED.

Type

bool