Summary of the classes dealing with the DAQ_Viewer control module:

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

Main PyMoDAQ class to drive detectors

DetectorWorker(title, settings_parameter, ...)

Worker class to control the instrument plugin

pymodaq.control_modules.daq_viewer_ui.ui_base.DAQ_Viewer_UI(...)

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', area=None, rois_dock=None, **kwargs)[source]

Bases: ParameterControlModule

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.

Variables:
  • grab_done_signal (pyqtSignal) – Signal emitted when the data from the plugin (and eventually from the data viewers) has been received. To be used by connected objects.

  • custom_sig (pyqtSignal) – use this to propagate info/data coming from the hardware plugin to another object

See also

ControlModule, DAQ_Viewer_UI, ParameterManager

Notes

The ROIselect and the crosshair of the data viewers are forwarded to the plugin: each time the user moves them, the plugin methods roi_select(roi_info, ind_viewer) and crosshair(crosshair_info, ind_viewer) are called (they do nothing by default and can be overridden in the plugin).

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

Get/Set the currently selected detector among available detectors

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 DetectorTimeSaver

grab([send_to_leco])

Launch a continuous grab

grab_data([grab_state, send_to_leco, snap_state])

Generic method to grab or snap data from the selected (and initialized) detector

listener_class

process_leco_commands(status)

Receive commands from the LECO network and process them.

process_ui_cmds(cmd)

Process commands sent by actions done in the ui

save_current()

Save current data into a h5file

set_data_to_viewers(dte[, temp])

Process data dimensionality and send appropriate data to their data viewers

setup_continuous_saving([init])

Configure the objects dealing with the continuous saving mode

show_data(dte)

Receive data from plugins and send them to their dedicated viewers

show_temp_data(data)

Send data to their dedicated viewers but those will not emit processed data signal

snap([send_to_leco])

Launch a single grab

snapshot([pathname, dosave, send_to_leco])

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 Grab button of the UI

stop_module()

Programmatic entry to stop the Control module either moving, polling or grabbing

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

custom_sig

data_saved

detector_changed_from_ui

get_detector_module

grab_done_signal

grab_status

reset_live_averaging

listener_class

alias of ActorListener

append_data(dte=None, where=None, **kwargs)[source]

Appends current DataToExport to a DetectorTimeSaver

Method to be used when performing continuous saving into a h5file (continuous mode or DAQ_Logger)

Parameters:

See also

DetectorTimeSaver

grab(send_to_leco=False)[source]

Launch a continuous grab

grab_data(grab_state=False, send_to_leco=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_leco (bool) – If True, send the grabbed data through the LECO Coordinator

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

process_leco_commands(status)[source]

Receive commands from the LECO network and process them.

Parameters:

status (ThreadCommand) –

Possible commands are:

  • LECOViewerCommands.GRAB: start a continuous grab and later forward acquired data to LECO.

  • LECOViewerCommands.SNAP: take a single snapshot and later forward the data to LECO.

  • LECOViewerCommands.STOP: stop an ongoing grab.

Return type:

None

process_ui_cmds(cmd)[source]

Process commands sent by actions done in the ui

See pymodaq.control_modules.thread_commands.UiToMainViewer

Parameters:

cmd (ThreadCommand) –

Possible values are:
  • init

  • grab

  • snap

  • detector_changed

  • save_current

  • do_bkg

  • take_bkg

  • viewers_changed

  • quit

save_current()[source]

Save current data into a h5file

set_data_to_viewers(dte, 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(init=True)[source]

Configure the objects dealing with the continuous saving mode

show_data(dte)[source]

Receive data from plugins and send them 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 (DataToExport _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)[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 (DataToExport)

snap(send_to_leco=False)[source]

Launch a single grab

snapshot(pathname=None, dosave=False, send_to_leco=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_leco (bool) – If True, send the grabbed data through the LECO Coordinator

stop()[source]

Stop the current continuous grabbing

stop_grab()[source]

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

See also

stop()

stop_module()[source]

Programmatic entry to stop the Control module either moving, polling or grabbing

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)[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_hardware: update the status with “Viewer 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

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: SelectedModule

Get/Set the currently selected detector among available detectors

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. DetectorWorker class

The DetectorWorker class is an object living in the plugin thread and responsible for the communication between DAQ_Viewer and the plugin itself

class pymodaq.control_modules.daq_viewer.DetectorWorker(title, settings_parameter, detector)[source]

Worker class to control the instrument plugin

Variables:
  • plugin (real instance of the instrument plugin class)

  • controller (DAQ_Viewer_base) – wrapper object used to control a given instrument in the instrument plugin

  • controller_address (int) – unique integer used to identify a controller shared among multiple instrument plugins

Attributes:
controller_adress
detector
detector_name

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

Deprecated: use ini_hardware instead.

ini_hardware([params_state, controller])

Initialize an instrument plugin class and tries to apply experiment 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

data_detector_sig

data_detector_temp_sig

close()[source]

Call the close method of the instrument plugin class.

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

Deprecated: use ini_hardware instead.

ini_hardware(params_state=None, controller=None)[source]

Initialize an instrument plugin class and tries to apply experiment settings

When the instrument is initialized from the Dashboard using an Experiment, tries to apply the experiment settings to the instrument instance

Parameters:
  • params_state (dict)

  • controller (wrapper)

queue_command(command)[source]

Transfer command from the main module to the hardware module.

Common commands (ini_hardware, close) are handled by the base class. Detector-specific commands are handled here.

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)

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.ui_base.DAQ_Viewer_UI(app, parent, title='DAQ_Viewer', rois_dock=None, settings_dock=None, area=None, **kwargs)[source]

DAQ_Viewer user interface.

This class manages the UI and emit dedicated signals depending on actions from the user

Variables:

command_sig (pyqtSignal) –

This signal is emitted whenever some actions done by the user has to be applied on the main module. Possible commands are:

  • init

  • grab

  • snap

  • detector_changed

  • daq_type_changed

  • save_current

Methods:
  • display_value(value (float)) – Update the display of the actuator’s value on the UI

  • do_init() – Programmatic init

See also

pymodaq.utils.daq_utils.ThreadCommand

Attributes:
data_ready
detector
detector_init

bool: the internal init status.

Methods

close()

connect_things()

do_grab([do_grab])

Programmatically press the Grab button API entry :type do_grab: bool :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 :type do_init: bool :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 uncheck the grab button API entry

quit_fun()

send_init(checked)

setup_actions()

setup_docks_and_widgets()

setup_menus_and_toolbars([menubar])

update_viewers(viewers_type[, viewers_name, ...])

show_graphs

do_grab(do_grab=True)[source]

Programmatically press the Grab button API entry :type do_grab: bool :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 :type do_init: bool :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 uncheck the grab button API entry

property detector_init

the internal init status.

Type:

bool