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, ...)

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

DAQ_Viewer user interface.

6.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[OrderedDict]

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
bkg
current_data
daq_type

DAQTypesEnum: Get/Set the daq_type

daq_types

list of str: List of available DAQ_TYPES

detector

str: Get/Set the detector among detectors property

detectors

list of str: List of available detectors of the current daq_type

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 of Viewers from the UI

viewers_docks

Methods

append_data([data, where])

Appends current DataToExport to a DetectorEnlargeableSaver

child_added(param, data)

Non-mandatory method to be subclassed for actions to perform when a param has been added in self.settings

connect_tcp_ip()

Init a TCPClient in a separated thread to communicate with a distant TCp/IP Server

get_scaling_options()

Create axes scaling options depending on the ('main_settings', 'axes') settings

grab()

Programmatic click on the UI grab button

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

init_hardware_ui([do_init])

Send a command to the underlying UI to click the init button

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)

ParameterManager subclassed method.

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

Process data dimensionality and send appropriate data to their data viewers

show_data(data)

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

show_temp_data(data)

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

snap()

Programmatic click on the UI snap button

snapshot([pathname, dosave, send_to_tcpip])

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

stop_grab()

Programmatic entry to stop data grabbing from detectors or current value polling from actuator

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

daq_type_changed_from_ui

data_saved

detector_changed_from_ui

detectors_changed_from_ui

grab_done_signal

grab_status

ini_det_fun

init_det

overshoot_signal

setup_saving_objects

stop

append_data(data: Optional[DataToExport] = None, where: Optional[Union[Node, str]] = None)[source]

Appends current DataToExport to a DetectorEnlargeableSaver

Parameters

See also

DetectorEnlargeableSaver

child_added(param, data)[source]

Non-mandatory method to be subclassed for actions to perform when a param has been added in self.settings

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_adress and port to specify the connection

See also

TCPServer

get_scaling_options()[source]

Create axes scaling options depending on the (‘main_settings’, ‘axes’) settings

Return type

pymodaq.utils.data.ScalingOptions

grab()[source]

Programmatic click on the UI grab button

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 grabing if False stops the grab

  • send_to_tcpip (bool) – If True, send the grabed 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)

init_hardware_ui(do_init=True)[source]

Send a command to the underlying UI to click the init button

insert_data(indexes: Tuple[int], where: Optional[Union[Node, str]] = None, distribution=DataDistribution.uniform)[source]

Insert DataToExport to a DetectorExtendedSaver at specified indexes

Parameters
  • indexes (tuple(int)) – The indexes within the extended array where to place these data

  • where (Node or str) –

  • distribution (DataDistribution enum) –

  • save_raw_only (bool) – If True save only Raw data (no data processed from Roi)

See also

DAQ_Scan, DetectorExtendedSaver

static load_data()[source]

Opens a H5 file in the H5Browser module

Convenience static method.

param_deleted(param)[source]

ParameterManager subclassed method. Process events from parameter deleted by user in the UI Settings

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 * ‘get_axis’: request the plugin to send its axis info

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

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(data, temp=False)[source]

Process data dimensionality and send appropriate data to their data viewers

Parameters
  • data (list of DataFromPlugins) –

  • 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(data: List[DataFromPlugins])[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 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

data (list of DataFromPlugins) –

See also

_init_show_data, _process_data

show_temp_data(data: List[DataFromPlugins])[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]

Programmatic click on the UI snap button

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 grabed data through the TCP/IP pipe

stop_grab()[source]

Programmatic entry to stop data grabbing from detectors or current value polling from actuator

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

Parameters

status (ThreadCommand) –

The info returned from the hardware, the command (str) can be either:
  • Update_Status: display messages and log info

  • ini_detector: update the status with “detector initialized” value and init state if attribute not null.

  • close: close the current thread and delete corresponding attribute on cascade.

  • grab : emit grab_status(True)

  • grab_stopped: emit grab_status(False)

  • x_axis: update x_axis from status attribute and User Interface viewer consequently. (Deprecated)

  • y_axis: update y_axis from status attribute and User Interface viewer consequently. (Deprecated)

  • update_channel: update the viewer channels in case of 0D DAQ_type (deprecated)

  • 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

  • init_lcd: display a LCD panel

  • lcd: display on the LCD panel, the content of the attribute

  • stop: stop the grab

value_changed(param)[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 daq_type: DAQTypesEnum

Get/Set the daq_type

Update the detector property with the list of available detectors of a given daq_type

Type

DAQTypesEnum

property daq_types

List of available DAQ_TYPES

Type

list of str

property detector

Get/Set the detector among detectors property

Type

str

property detectors

List of available detectors of the current daq_type

Type

list of str

property do_bkg

Get/Set if background subtraction should be done

Type

bool

property grab_state

Get the current grabbing status

Type

bool

property viewer_docks

list of Viewer Docks from the UI

property viewers: List[ViewerBase]

list of Viewers from the UI

6.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]

Attributes

Type

status_sig

instance of pyqt Signal

data_detector_sig

instance of pyqt Signal

data_detector_temp_sig

instance of pyqt Signal

waiting_for_data

boolean

controller

???

detector_name

string

detector

???

controller_adress

???

grab_state

boolean

single_grab

boolean

x_axis

1D numpy array

y_axis

1D numpy array

datas

dictionnary

ind_average

int

Naverage

int

average_done

boolean

hardware_averaging

boolean

show_averaging

boolean

wait_time

int

daq_type

string

Methods

close()

close the current instance of DAQ_Detector.

data_ready(datas)

Update the local datas attribute from the given datas parameter if the averaging has to be done software wise.

grab_data([Naverage, live])

Update status with 'Start Grabing' Update_status sub command of the Thread command.

ini_detector([params_state, controller])

Init the detector from params_state parameter and DAQ_type class attribute :

queue_command(command)

Transfer command from the main module to the hardware module

single([Naverage, args_as_dict])

Call the grab method with Naverage parameter as an attribute.

update_settings(settings_parameter_dict)

Set attribute values in case of "main_settings" path with corresponding parameter values.

data_detector_sig

data_detector_temp_sig

emit_temp_data

status_sig

close()[source]

close the current instance of DAQ_Detector.

data_ready(datas)[source]
Update the local datas attribute from the given datas parameter if the averaging has to be done software wise.

Else emit the data detector signals with datas parameter as an attribute.

Parameters

Type

Description

datas

list

the datas to be emitted.

See also

daq_utils.ThreadCommand

grab_data(Naverage=1, live=True, **kwargs)[source]
Update status with ‘Start Grabing’ Update_status sub command of the Thread command.
Process events and grab naverage is needed.

Parameters

Type

Description

Naverage

int

See also

daq_utils.ThreadCommand, grab

ini_detector(params_state=None, controller=None)[source]
Init the detector from params_state parameter and DAQ_type class attribute :
  • in 0D profile : update the local status and send the “x_axis” Thread command via a status signal

  • in 1D profile : update the local status and send the “x_axis” Thread command via a status signal

  • in 2D profile : update the local status and send the “x_axis” and the “y_axis” Thread command via a status signal

Parameters

Type

Description

params_state

???

the parameter’s state of initialization

See also

ini_detector, daq_utils.ThreadCommand

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_com * update_wait_time * get_axis * any string that the hardware is able to understand

single(Naverage=1, args_as_dict={})[source]

Call the grab method with Naverage parameter as an attribute.

Parameters

Type

Description

Naverage

int

savepath

str

eventual savepath

See also

daq_utils.ThreadCommand, grab

update_settings(settings_parameter_dict)[source]
Set attribute values in case of “main_settings” path with corresponding parameter values.
Recursively call the method on detector class attribute else.

Parameters

Type

Description

settings_parameter_dict

dictionnary

the (pathname,parameter) dictionnary

See also

update_settings

6.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

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

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