def commit_settings(self, param): """ Activate parameters changes on the hardware. =============== ================================ =========================== **Parameters** **Type** **Description** *param* instance of pyqtgraph Parameter the parameter to activate =============== ================================ =========================== See Also -------- set_Mock_data """ try: if param.name() in custom_tree.iter_children( self.settings.child(('cam_settings')), []): self.stop() while self.controller.is_acquiring_images: self.stop() QtWidgets.QApplication.processEvents() feature = self.controller.device.node_map.get_node( param.name()) interface_type = feature.node.principal_interface_type if interface_type == EInterfaceType.intfIInteger: val = int((param.value() // param.opts['step']) * param.opts['step']) else: val = param.value() feature.value = val #set the desired value param.setValue(feature.value) # retrieve the actually set one #self.update_features() if param.name() in ['Height', 'Width', 'OffsetX', 'OffsetY']: if param.name() in ['Height', 'Width' ] and not self.settings.child( 'ROIselect', 'use_ROI').value(): self.width = self.controller.device.node_map.get_node( 'Width').value self.height = self.controller.device.node_map.get_node( 'Height').value self.data = np.zeros((self.height, self.width)) if param.name() in custom_tree.iter_children( self.settings.child(('ROIselect')), []): while self.controller.is_acquiring_images: QThread.msleep(50) self.stop() QtWidgets.QApplication.processEvents() self.set_ROI() except Exception as e: self.emit_status( ThreadCommand('Update_Status', [getLineInfo() + str(e), 'log']))
def commit_settings(self, param): if param.name() not in custom_tree.iter_children( self.settings.child(('stage_settings'))): super(DAQ_2DViewer_FLIM, self).commit_settings(param) else: if param.name() == 'time_interval': self.stage._get_read() self.stage.set_time_interval( Time(param.value(), unit='m')) # set time interval between pixels elif param.name() == 'show_navigator': self.emit_status(ThreadCommand('show_navigator')) self.emit_status(ThreadCommand('show_scanner')) param.setValue(False) elif param.name() in custom_tree.iter_children( self.settings.child('stage_settings', 'move_at'), []): pos_x = self.settings.child('stage_settings', 'move_at', 'move_at_x').value() pos_y = self.settings.child('stage_settings', 'move_at', 'move_at_y').value() self.move_at_navigator(pos_x, pos_y)
def parameter_tree_changed(self, param, changes): for param, change, data in changes: path = self.settings.childPath(param) if change == 'childAdded': pass elif change == 'value': if param.name() == 'show_file': param.setValue(False) self.show_file_content() elif param.name() == 'base_path': try: if not os.path.isdir(param.value()): os.mkdir(param.value()) except: self.update_status( "The base path couldn't be set, please check your options" ) elif param.name() in custom_tree.iter_children( self.settings.child(('compression_options')), []): self.filters = tables.Filters( complevel=self.settings.child('compression_options', 'h5comp_level').value(), complib=self.settings.child('compression_options', 'h5comp_library').value()) elif change == 'parent': pass
def parameter_tree_changed(self, param, changes): for param, change, data in changes: path = self.settings.childPath(param) if path is not None: childName = '.'.join(path) else: childName = param.name() if change == 'childAdded': self.update_peak_source() if param.name() == 'peak_options': QtWidgets.QApplication.processEvents() #self.update_peak_finding() elif change == 'value': if param.name() in custom_tree.iter_children( self.settings.child(('peak_options')), []): self.update_peak_finding() elif param.name() == 'fit_units': if self.table_model is not None: self.table_model.setHeaderData(2, Qt.Horizontal, data) if self.settings.child('fit_options', 'do_calib').value(): self.calculate_calibration( self.settings.child(('peaks_table')).value()._data) elif change == 'parent': pass
def load_ROI(self, path=None, params=None): try: if params is None: if path is None: path = select_file(save=False, ext='xml') if path != '': params = Parameter.create( title='Settings', name='settings', type='group', children=custom_tree.XML_file_to_parameter(path)) if params is not None: self.clear_ROI() QtWidgets.QApplication.processEvents() for param in params: if 'roi_type' in custom_tree.iter_children(param, []): self.settings.child(('ROIs')).addNew( param.child(('roi_type')).value()) else: self.settings.child(('ROIs')).addNew() #self.settings.child(('ROIs')).addChildren(params) QtWidgets.QApplication.processEvents() # settings = Parameter.create(title='Settings', name='settings', type='group') # # for param in params: # settings.addChildren(custom_tree.XML_string_to_parameter(custom_tree.parameter_to_xml_string(param))) self.set_roi(self.settings.child(('ROIs')).children(), params) except Exception as e: pass
def commit_settings(self, param): """ Activate parameters changes on the hardware from parameter's name. see documentation :ref:`hardware_settings` """ try: ############################################################### ##################to modify below ############################### if param.name() == 'set_point': self.controller.SetTemperature(param.value()) elif param.name() == 'readout' or param.name( ) in custom_parameter_tree.iter_children( self.settings.child('camera_settings', 'readout_settings')): self.update_read_mode() elif param.name() == 'exposure': self.controller.SetExposureTime( self.settings.child('camera_settings', 'exposure').value() / 1000) #temp should be in s (err, timings) = self.controller.GetAcquisitionTimings() self.settings.child('camera_settings', 'exposure').setValue( timings['exposure'] * 1000) #################################################################### ######################################################################### except Exception as e: self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))
def parameter_tree_changed(self, param, changes): """ | Check eventual changes in the changes list parameter. | | In case of changed values, emit the signal containing the current path and parameter via update_settings_signal to the connected hardware. =============== ==================================== ================================================== **Parameters** **Type** **Description** *param* instance of pyqtgraph parameter The parameter to be checked *changes* (parameter,change,infos) tuple list The (parameter,change,infos) list to be treated =============== ==================================== ================================================== """ for param, change, data in changes: path = self.settings.childPath(param) if path is not None: childName = '.'.join(path) else: childName = param.name() if change == 'childAdded': pass elif change == 'value': if param.name() in custom_tree.iter_children( self.settings.child(('shortcuts')), []): if param.parent().name() == 'shortcuts': param_index = custom_tree.iter_children( self.settings.child(('shortcuts')), []).index(param.name()) action = self.shortcut_manager.shortcut_params.child( ('actions')).children()[param_index].child( ('action')).value() self.activate_shortcut(self.shortcuts[param_index], action, activate=param.value()) elif change == 'parent': pass
def commit_settings(self, param): if param.name() in custom_tree.iter_children( self.settings.child(('infos')), []): grabber_socket = \ [client['socket'] for client in self.connected_clients if client['type'] == self.client_type][0] grabber_socket.send_string('set_info') path = custom_tree.get_param_path( param )[2:] # get the path of this param as a list starting at parent 'infos' grabber_socket.send_list(path) # send value data = custom_tree.parameter_to_xml_string(param) grabber_socket.send_string(data)
def commit_settings(self, param): if param.name() in custom_tree.iter_children( self.settings.child(('infos')), []): actuator_socket = [ client['socket'] for client in self.connected_clients if client['type'] == 'ACTUATOR' ][0] send_string(actuator_socket, 'set_info') path = custom_tree.get_param_path( param )[2:] #get the path of this param as a list starting at parent 'infos' send_list(actuator_socket, path) #send value data = custom_tree.parameter_to_xml_string(param) send_string(actuator_socket, data)
def commit_settings(self,param): """ Activate parameters changes on the hardware. """ #here we update the hardware if parameters have been changed by the user #for instance: if param.name()=='conex_lib': #then init the dll on the new path defined by the parameter value #for instance call the update_dll method of the controller object, fake here: self.controller.update_dll(param.value()) #here check if the name of the parameter is a child of the group_parameter parameter # the group_parameter is obtained from self.settings using the child method #iter_children returns a list of all parameter names that are children or subchildren of 'group_parameter' elif param.name() in iter_children(self.settings.child('group_parameter'),childlist=[]): #then do something on self.controller or something else! pass
def read_info(self, sock=None, test_info='an_info', test_value=''): """ if the client is not from PyMoDAQ it can use this method to display some info into the server widget """ ##first get the info type if sock is None: info = test_info data = test_value else: info = sock.get_string() data = sock.get_string() if info not in custom_tree.iter_children( self.settings.child(('infos')), []): self.settings.child(('infos')).addChild({ 'name': info, 'type': 'str', 'value': data }) pass else: self.settings.child('infos', info).setValue(data)
def commit_settings(self,param): """ Setting the mock data ============== ========= ================= **Parameters** **Type** **Description** *param* none not used ============== ========= ================= See Also -------- set_Mock_data """ if param.name() in custom_tree.iter_children(self.settings.child(('x_axis')), []): if param.name() == 'x0': self.get_spectro_wl() self.set_x_axis() self.emit_x_axis() else: self.set_Mock_data()
def load_ROI(self, path=None, params=None): try: if params is None: if path is None: path = select_file(save=False, ext='xml') if path != '': params = custom_tree.XML_file_to_parameter(path) if params is not None: for roi in self.ROIs.values(): index = roi.index self.viewer_widget.plotitem.removeItem(roi) # self.settings.sigTreeStateChanged.disconnect() self.settings.child(*('ROIs', 'ROI_%02.0d' % index)).remove() # self.settings.sigTreeStateChanged.connect(self.roi_tree_changed) self.ROIs = OrderedDict([]) for param in params: if 'roi_type' in custom_tree.iter_children(param, []): self.settings.child(('ROIs')).addNew( param.child(('roi_type')).value()) else: self.settings.child(('ROIs')).addNew() #self.settings.child(('ROIs')).addChildren(params) QtWidgets.QApplication.processEvents() # settings = Parameter.create(title='Settings', name='settings', type='group') # # for param in params: # settings.addChildren(custom_tree.XML_string_to_parameter(custom_tree.parameter_to_xml_string(param))) self.set_roi(self.settings.child(('ROIs')).children(), params) except Exception as e: pass
def roi_tree_changed(self, param, changes): for param, change, data in changes: path = self.settings.childPath(param) if path is not None: childName = '.'.join(path) else: childName = param.name() if change == 'childAdded': #new roi to create par = data[0] newindex = int(par.name()[-2:]) if par.child(('type')).value() == '1D': roi_type = '' pos = self.viewer_widget.plotItem.vb.viewRange()[0] newroi = LinearROI(index=newindex, pos=pos) newroi.setZValue(-10) newroi.setBrush(par.child(('Color')).value()) newroi.setOpacity(0.2) elif par.child(('type')).value() == '2D': roi_type = par.child(('roi_type')).value() xrange = self.viewer_widget.plotItem.vb.viewRange()[0] yrange = self.viewer_widget.plotItem.vb.viewRange()[1] width = np.max(((xrange[1] - xrange[0]) / 10, 2)) height = np.max(((yrange[1] - yrange[0]) / 10, 2)) pos = [ int(np.mean(xrange) - width / 2), int(np.mean(yrange) - width / 2) ] if roi_type == 'RectROI': newroi = RectROI(index=newindex, pos=pos, size=[width, height]) else: newroi = EllipseROI(index=newindex, pos=pos, size=[width, height]) newroi.setPen(par.child(('Color')).value()) newroi.sigRegionChanged.connect(self.ROI_changed.emit) newroi.sigRegionChangeFinished.connect( self.ROI_changed_finished.emit) newroi.index_signal[int].connect(self.update_roi_tree) try: self.settings.sigTreeStateChanged.disconnect() except: pass self.settings.sigTreeStateChanged.connect( self.roi_tree_changed) self.viewer_widget.plotItem.addItem(newroi) self.ROIs["ROI_%02.0d" % newindex] = newroi self.new_ROI_signal.emit(newindex, roi_type) self.update_roi_tree(newindex) # self.ui.RoiCurve_H["ROI_%02.0d" % newindex]=self.ui.Lineout_H.plot(pen=QtGui.QColor(*self.color_list[newindex])) # self.ui.RoiCurve_V["ROI_%02.0d" % newindex]=self.ui.Lineout_V.plot(pen=QtGui.QColor(*self.color_list[newindex])) # self.ui.RoiCurve_integrated["ROI_%02.0d" % newindex]=self.ui.Lineout_integrated.plot(pen=QtGui.QColor(*self.color_list[newindex])) # self.data_integrated_plot["ROI_%02.0d" % newindex]=np.zeros((2,1)) # #self.data_to_export["%02.0d" % newindex]=None # self.roiChanged() elif change == 'value': if param.name() in custom_tree.iter_children( self.settings.child(('ROIs')), []): if param.name() == 'Color' or param.name() == 'angle': parent = param.parent().name() else: parent = param.parent().parent().name() self.update_roi(parent, param) elif change == 'parent': if 'ROI' in param.name(): roi = self.ROIs.pop(param.name()) self.viewer_widget.plotItem.removeItem(roi) self.remove_ROI_signal.emit(param.name()) if param.name() != 'measurements': self.roi_settings_changed.emit([(param, 'value', param.value()) ]) self.ROI_changed_finished.emit()
def commit_settings(self, param): """ | Activate parameters changes on the hardware from parameter's name. | =============== ================================ ========================= **Parameters** **Type** **Description** *param* instance of pyqtgraph parameter The parameter to activate =============== ================================ ========================= Three profile of parameter : * **bin_x** : set binning camera from bin_x parameter's value * **bin_y** : set binning camera from bin_y parameter's value * **set_point** : Set the camera's temperature from parameter's value. """ try: if param.name() == 'set_point': self.controller.SetTemperature(param.value()) elif param.name() == 'readout' or param.name( ) in custom_parameter_tree.iter_children( self.settings.child('camera_settings', 'readout_settings')): self.update_read_mode() elif param.name() == 'exposure': self.controller.SetExposureTime( self.settings.child('camera_settings', 'exposure').value() / 1000) #temp should be in s (err, timings) = self.controller.GetAcquisitionTimings() self.settings.child('camera_settings', 'exposure').setValue( timings['exposure'] * 1000) elif param.name() == 'grating': index_grating = self.grating_list.index(param.value()) self.get_set_grating(index_grating) self.emit_status( ThreadCommand('show_splash', ["Setting wavelength"])) err = self.controller.SetWavelengthSR( 0, self.settings.child('spectro_settings', 'spectro_wl').value()) self.emit_status(ThreadCommand('close_splash')) elif param.name() == 'spectro_wl': self.emit_status( ThreadCommand('show_splash', ["Setting wavelength"])) err = self.controller.SetWavelengthSR(0, param.value()) self.emit_status(ThreadCommand('close_splash')) if err != 'SHAMROCK_SUCCESS': raise Exception(err) self.x_axis = self.get_xaxis() elif param.name() == 'zero_order': if param.value(): param.setValue(False) err = self.controller.GotoZeroOrderSR(0) if err != 'SHAMROCK_SUCCESS': raise Exception(err) elif param.name() in custom_parameter_tree.iter_children( self.settings.child('camera_settings', 'shutter'), []): self.set_shutter() pass except Exception as e: self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))
def commit_settings(self, param): """ | Activate parameters changes on the hardware from parameter's name. | =============== ================================ ========================= **Parameters** **Type** **Description** *param* instance of pyqtgraph parameter The parameter to activate =============== ================================ ========================= Three profile of parameter : * **bin_x** : set binning camera from bin_x parameter's value * **bin_y** : set binning camera from bin_y parameter's value * **set_point** : Set the camera's temperature from parameter's value. """ try: if param.name() == 'mult2': if param.value(): self.mult_image() param.setValue(False) Nx = self.settings.child('stem_settings', 'pixels_settings', 'Nx').value() Ny = self.settings.child('stem_settings', 'pixels_settings', 'Ny').value() self.settings.child('stem_settings', 'spot_settings', 'spot_x').setOpts(bounds=(0, Nx - 1)) self.settings.child('stem_settings', 'spot_settings', 'spot_y').setOpts(bounds=(0, Ny - 1)) if param.name() == 'div2': if param.value(): self.divide_image() param.setValue(False) Nx = self.settings.child('stem_settings', 'pixels_settings', 'Nx').value() Ny = self.settings.child('stem_settings', 'pixels_settings', 'Ny').value() self.settings.child('stem_settings', 'spot_settings', 'spot_x').setOpts(bounds=(0, Nx - 1)) self.settings.child('stem_settings', 'spot_settings', 'spot_y').setOpts(bounds=(0, Ny - 1)) elif param.name() == 'input1' or param.name() == 'input2': input1 = self.settings.child('stem_settings', 'inputs', 'input1').value() input2 = self.settings.child('stem_settings', 'inputs', 'input2').value() self.stem_scan.SetInputs( [self.inputs.index(input1), self.inputs.index(input2)]) self.spim_scan.SetInputs( [self.inputs.index(input1), self.inputs.index(input2)]) elif param.name() == 'Nx' or param.name() == 'Ny': self.init_data( self.settings.child('stem_settings', 'pixels_settings', 'Nx').value(), self.settings.child('stem_settings', 'pixels_settings', 'Ny').value()) Nx = self.settings.child('stem_settings', 'pixels_settings', 'Nx').value() Ny = self.settings.child('stem_settings', 'pixels_settings', 'Ny').value() self.settings.child('stem_settings', 'spot_settings', 'spot_x').setOpts(bounds=(0, Nx - 1)) self.settings.child('stem_settings', 'spot_settings', 'spot_y').setOpts(bounds=(0, Ny - 1)) # elif param.name() in custom_tree.iter_children(self.settings.child(('ROIselect')),[]): # # self.init_data() # # # elif param.name() in custom_tree.iter_children( self.settings.child('stem_settings', 'times'), []): self.stem_scan.pixelTime = param.value() / 1e6 elif param.name() == 'angle': self.stem_scan.setScanRotation( self.settings.child('stem_settings', 'mag_rot', 'angle').value()) self.get_set_field() elif param.name() == 'field': self.get_set_field() elif param.name() == 'do_hyperspectroscopy': if param.value(): data_stem_STEM_as_reference = self.data_stem.reshape( (2, self.SIZEX, self.SIZEY)).astype(np.float64) self.data_stem_STEM_as_reference = [ DataFromPlugins(name=self.settings.child( 'stem_settings', 'inputs', 'input1').value(), data=[data_stem_STEM_as_reference[0]], dim='Data2D'), DataFromPlugins(name=self.settings.child( 'stem_settings', 'inputs', 'input2').value(), data=[data_stem_STEM_as_reference[1]], dim='Data2D'), ] # init the viewers self.emit_data_init() if self.is_Orsay_camera: self.settings.child( ('hyperspectroscopy')).show(param.value()) if param.value(): self.settings.child(('ROIselect')).show(True) self.settings.child('ROIselect', 'use_ROI').setValue(True) self.settings.child('ROIselect', 'use_ROI').setOpts(readonly=True) QtWidgets.QApplication.processEvents() self.init_data() #init the viewers type self.emit_data_temp([ DataFromPlugins( name='SPIM ', data=[np.zeros((1024, 10, 10))], dim='DataND'), #data from SPIM camera DataFromPlugins(name='Spectrum', data=[np.zeros((1024, ))], dim='Data1D') ]) else: self.settings.child('ROIselect', 'use_ROI').setOpts(readonly=False) if self.camera is None: #remove viewers related to camera self.emit_data_temp() elif param.name() in custom_tree.iter_children( self.settings.child(('hyperspectroscopy')), []): #parameters related to camera if self.camera is not None: self.camera.commit_settings(param) except Exception as e: self.emit_status( ThreadCommand('Update_Status', [getLineInfo() + str(e), 'log']))
def test_commands(self, get_server, qtbot): server = get_server() server.socket_types = socket_types #Combination of general messages and specific ones (depending the connected client, Grabber or Actuator server.message_list = [ "Quit", "Done", "Info", "Infos", "Info_xml", #"Send Data 0D", "Send Data 1D", "Send Data 2D", "Send Data ND", "Status", # 'x_axis', 'y_axis' ] #read_info server.read_info(None, 'random_info', 'random info value') assert 'random_info' in custom_tree.iter_children( server.settings.child(('infos')), []) assert server.settings.child( 'infos', 'random_info').value() == 'random info value' # read_infos params = [{ 'title': 'Device index:', 'name': 'device', 'type': 'int', 'value': 0, 'max': 3, 'min': 0 }, { 'title': 'Infos:', 'name': 'infos', 'type': 'str', 'value': "one_info", 'readonly': True }, { 'title': 'Line Settings:', 'name': 'line_settings', 'type': 'group', 'expanded': False, 'children': [ { 'title': 'Device index:', 'name': 'device1', 'type': 'int', 'value': 0, 'max': 3, 'min': 0 }, { 'title': 'Device index:', 'name': 'device2', 'type': 'int', 'value': 0, 'max': 3, 'min': 0 }, ] }] param = Parameter.create(name='settings', type='group', children=params) params_xml = custom_tree.parameter_to_xml_string(param) server.read_infos(None, params_xml) assert 'device' in custom_tree.iter_children( server.settings.child(('settings_client')), []) assert 'infos' in custom_tree.iter_children( server.settings.child(('settings_client')), []) assert server.settings.child('settings_client', 'infos').value() == 'one_info' assert 'line_settings' in custom_tree.iter_children( server.settings.child(('settings_client')), []) assert server.settings.child('settings_client', 'line_settings').opts['type'] == 'group' # read_info_xml one_param = param.child(('infos')) one_param.setValue('another_info') assert one_param.value() == 'another_info' path = param.childPath(one_param) path.insert(0, '') #add one to mimic correct behaviour server.read_info_xml(None, path, custom_tree.parameter_to_xml_string(one_param)) assert server.settings.child('settings_client', 'infos').value() == 'another_info'
def parameter_tree_changed(self, param, changes): for param, change, data in changes: path = self.settings.childPath(param) if path is not None: childName = '.'.join(path) else: childName = param.name() if change == 'childAdded': pass elif change == 'value': if param.name() == 'show_det': self.show_detector(data) elif param.name() == 'spectro_center_freq': unit = self.settings.child('acq_settings', 'units').value() if unit == 'nm': center_wavelength = data elif unit == 'cm-1': center_wavelength = Ecmrel2Enm( data, self.settings.child('config_settings', 'laser_wl').value()) elif unit == 'eV': center_wavelength = eV2nm(data) if int(self.spectro_wl * 100) != int( 100 * center_wavelength): #comprison at 1e-2 self.spectro_wl = center_wavelength self.update_axis() elif param.name() == 'units': if self.settings.child( 'acq_settings', 'spectro_center_freq').value() > 0.000000001: if data == 'nm': self.settings.child( 'acq_settings', 'spectro_center_freq').setValue( self._spectro_wl) elif data == 'cm-1': self.settings.child( 'acq_settings', 'spectro_center_freq').setValue( Enm2cmrel( self._spectro_wl, self.settings.child( 'config_settings', 'laser_wl').value())) elif data == 'eV': self.settings.child( 'acq_settings', 'spectro_center_freq').setValue( nm2eV(self._spectro_wl)) self.set_status_center( self.settings.child('acq_settings', 'spectro_center_freq').value(), self.settings.child('acq_settings', 'units').value()) elif param.name() == 'laser_wl_list': if data is not None: self.move_laser_wavelength(data) elif param.name() == 'laser_wl': if data is not None: self.move_laser_wavelength(data) if int(data) == 0: self.settings.child('acq_settings', 'units').setValue('nm') self.settings.child('acq_settings', 'units').setOpts(readonly=True) else: self.settings.child( 'acq_settings', 'units').setOpts(readonly=False) if data != 0: self.set_manual_laser_wl(data) elif param.name() == 'exposure_ms': self.set_exposure_ms(data) elif param.name() == 'do_calib': if len(self.raw_data) != 0: if data: self.calib_dock = Dock('Calibration module') self.dockarea.addDock(self.calib_dock) self.calibration = Calibration(self.dockarea) self.calib_dock.addWidget(self.calibration) self.calibration.coeffs_calib.connect( self.update_calibration) else: self.calib_dock.close() elif param.name() == 'save_calib': filename = select_file(start_path=self.save_file_pathname, save=True, ext='xml') if filename != '': custom_tree.parameter_to_xml_file( self.settings.child('calib_settings', 'calib_coeffs'), filename) elif param.name() == 'load_calib': filename = select_file(start_path=self.save_file_pathname, save=False, ext='xml') if filename != '': children = custom_tree.XML_file_to_parameter(filename) self.settings.child( 'calib_settings', 'calib_coeffs').restoreState( Parameter.create( title='Calibration coeffs:', name='calib_coeffs', type='group', children=children).saveState()) elif param.name() in custom_tree.iter_children(self.settings.child('calib_settings', 'calib_coeffs')) \ or param.name() == 'use_calib': if self.settings.child('calib_settings', 'use_calib').value(): calib_coeffs = [ self.settings.child('calib_settings', 'calib_coeffs', 'third_calib').value(), self.settings.child('calib_settings', 'calib_coeffs', 'second_calib').value(), self.settings.child('calib_settings', 'calib_coeffs', 'slope_calib').value(), self.settings.child('calib_settings', 'calib_coeffs', 'center_calib').value() ] self.update_center_frequency( self.settings.child('calib_settings', 'calib_coeffs', 'center_calib').value()) self.settings.child('acq_settings', 'spectro_center_freq').show() self.settings.child( 'acq_settings', 'spectro_center_freq').setOpts(readonly=True) self.status_center.setStyleSheet( "background-color: green") self.settings.child('acq_settings', 'spectro_center_freq_txt').hide() x_axis_pxls = np.linspace(0, self.raw_data[0].size - 1, self.raw_data[0].size) self.viewer_freq_axis['data'] = np.polyval( calib_coeffs, x_axis_pxls - np.max(x_axis_pxls) / 2) self.update_axis() else: self.settings.child('acq_settings', 'spectro_center_freq').hide() self.settings.child('acq_settings', 'spectro_center_freq_txt').show() self.status_center.setStyleSheet( "background-color: red") elif change == 'parent': pass
def parameter_tree_changed(self,param,changes): """ Foreach value changed, update : * Viewer in case of **DAQ_type** parameter name * visibility of button in case of **show_averaging** parameter name * visibility of naverage in case of **live_averaging** parameter name * scale of axis **else** (in 2D pymodaq type) Once done emit the update settings signal to link the commit. =============== =================================== ================================================================ **Parameters** **Type** **Description** *param* instance of ppyqtgraph parameter the parameter to be checked *changes* tuple list Contain the (param,changes,info) list listing the changes made =============== =================================== ================================================================ See Also -------- change_viewer, daq_utils.custom_parameter_tree.iter_children """ for param, change, data in changes: path = self.settings.childPath(param) if change == 'childAdded': pass elif change == 'value': if param.name() == 'model_class': self.get_set_model_params(param.value()) elif param.name() == 'module_settings': if param.value(): self.settings.sigTreeStateChanged.disconnect( self.parameter_tree_changed) param.setValue(False) self.settings.sigTreeStateChanged.connect( self.parameter_tree_changed) self.preset_manager.set_PID_preset(self.settings.child('models','model_class').value()) elif param.name() == 'refresh_plot_time' or param.name() == 'timeout': self.command_pid.emit(ThreadCommand('update_timer', [param.name(),param.value()])) elif param.name() == 'set_point': if self.pid_led.state: self.command_pid.emit(ThreadCommand('update_options', dict(setpoint=param.value()))) else: output = self.model_class.convert_output(param.value(),0, stab=False) for ind_act, act in enumerate(self.actuator_modules): act.move_Abs(output[ind_act]) elif param.name() == 'sample_time': self.command_pid.emit(ThreadCommand('update_options', dict(sample_time=param.value()))) elif param.name() in custom_tree.iter_children(self.settings.child('main_settings', 'pid_controls', 'output_limits'), []): output_limits = [None, None] if self.settings.child('main_settings', 'pid_controls', 'output_limits', 'output_limit_min_enabled').value(): output_limits[0] = self.settings.child('main_settings', 'pid_controls', 'output_limits', 'output_limit_min').value() if self.settings.child('main_settings', 'pid_controls', 'output_limits', 'output_limit_max_enabled').value(): output_limits[1] = self.settings.child('main_settings', 'pid_controls', 'output_limits', 'output_limit_max').value() self.command_pid.emit(ThreadCommand('update_options', dict(output_limits=output_limits))) elif param.name() in custom_tree.iter_children(self.settings.child('main_settings', 'pid_controls', 'filter'), []): self.command_pid.emit(ThreadCommand('update_filter', [dict(enable=self.settings.child('main_settings', 'pid_controls', 'filter', 'filter_enable').value(), value=self.settings.child('main_settings', 'pid_controls', 'filter', 'filter_step').value())])) elif param.name() in custom_tree.iter_children(self.settings.child('main_settings', 'pid_controls', 'pid_constants'), []): Kp = self.settings.child('main_settings', 'pid_controls', 'pid_constants', 'kp').value() Ki = self.settings.child('main_settings', 'pid_controls', 'pid_constants', 'ki').value() Kd = self.settings.child('main_settings', 'pid_controls', 'pid_constants', 'kd').value() self.command_pid.emit(ThreadCommand('update_options', dict(tunings= (Kp, Ki, Kd)))) elif param.name() in custom_tree.iter_children(self.settings.child('models', 'model_params'),[]): self.model_class.update_settings(param) elif param.name() == 'detector_modules': self.model_class.update_detector_names() elif change == 'parent': pass