Ejemplo n.º 1
0
    def set_file_remote(self, filename, show=True):
        """

        """
        children = ioxml.XML_file_to_parameter(filename)
        self.remote_params = Parameter.create(title='Shortcuts:', name='shortcuts', type='group', children=children)
        if show:
            self.show_remote()
Ejemplo n.º 2
0
    def set_file_overshoot(self, filename, show=True):
        """

        """
        children = ioxml.XML_file_to_parameter(filename)
        self.overshoot_params = Parameter.create(title='Overshoot',
                                                 name='Overshoot',
                                                 type='group',
                                                 children=children)
        if show:
            self.show_overshoot()
Ejemplo n.º 3
0
    def set_file_preset(self, filename, show=True):
        """

        """
        status = False
        self.pid_type = False
        children = ioxml.XML_file_to_parameter(filename)
        self.preset_params = Parameter.create(title='Preset',
                                              name='Preset',
                                              type='group',
                                              children=children)
        if show:
            status = self.show_preset()
        return status
Ejemplo n.º 4
0
    def set_file_batch(self, filename=None, show=True):
        """

        """

        if filename is None or filename == False:
            filename = pymodaq.daq_utils.gui_utils.file_io.select_file(start_path=self.batch_path, save=False, ext='xml')
            if filename == '':
                return

        status = False
        settings_tmp = Parameter.create(title='Batch', name='settings_tmp',
                                        type='group', children=ioxml.XML_file_to_parameter(str(filename)))

        children = settings_tmp.child('scans').children()
        self.settings = Parameter.create(title='Batch', name='settings', type='group', children=self.params)
        actuators = children[0].child('modules', 'actuators').value()['all_items']
        if actuators != self.actuators:
            pymodaq.daq_utils.messenger.show_message('The loaded actuators from the batch file do not corresponds to the'
                                ' dashboard actuators')
            return
        else:
            self.actuators = actuators

        detectors = children[0].child('modules', 'detectors').value()['all_items']
        if detectors != self.detectors:
            pymodaq.daq_utils.messenger.show_message('The loaded detectors from the batch file do not corresponds to the'
                                ' dashboard detectors')
            return
        else:
            self.detectors = detectors

        for child in children:
            self.add_scan(name=child.name(), title=child.opts['title'])
            self.settings.child('scans', child.name()).restoreState(child.saveState())

        if show:
            status = self.show_tree()
        else:
            self.tree.setParameters(self.settings, showTop=False)
        return status
Ejemplo n.º 5
0
    def load_ROI(self, path=None, params=None):
        try:
            if params is None:
                if path is None:
                    path = select_file(start_path=Path.home(),
                                       save=False,
                                       ext='xml')
                    if path != '':
                        params = Parameter.create(
                            title='Settings',
                            name='settings',
                            type='group',
                            children=ioxml.XML_file_to_parameter(path))

            if params is not None:
                self.clear_ROI()
                QtWidgets.QApplication.processEvents()

                for param in params:
                    if 'roi_type' in putils.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
Ejemplo n.º 6
0
    def set_PID_preset(self, pid_model):
        self.pid_type = True
        filename = os.path.join(utils.get_set_pid_path(), pid_model + '.xml')
        if os.path.isfile(filename):
            children = ioxml.XML_file_to_parameter(filename)
            self.preset_params = Parameter.create(title='Preset',
                                                  name='Preset',
                                                  type='group',
                                                  children=children)

        else:
            model_mod = importlib.import_module('pymodaq_pid_models')
            model = importlib.import_module('.' + pid_model,
                                            model_mod.__name__ + '.models')
            model_class = getattr(model, pid_model)
            actuators = model_class.actuators
            actuators_name = model_class.actuators_name
            detectors_type = model_class.detectors_type
            detectors_name = model_class.detectors_name
            detectors = model_class.detectors

            param = [
                {
                    'title': 'Filename:',
                    'name': 'filename',
                    'type': 'str',
                    'value': pid_model,
                    'readonly': True
                },
            ]

            params_move = [{
                'title': 'Actuators:',
                'name': 'Moves',
                'type': 'groupmove'
            }]  # PresetScalableGroupMove(name="Moves")]
            params_det = [{
                'title': 'Detectors:',
                'name': 'Detectors',
                'type': 'groupdet'
            }]  # [PresetScalableGroupDet(name="Detectors")]
            self.preset_params = Parameter.create(title='Preset',
                                                  name='Preset',
                                                  type='group',
                                                  children=param +
                                                  params_move + params_det)

            QtWidgets.QApplication.processEvents()
            for ind_act, act in enumerate(actuators):
                self.preset_params.child(('Moves')).addNew(act)
                self.preset_params.child(
                    'Moves', 'move{:02.0f}'.format(ind_act),
                    'name').setValue(actuators_name[ind_act])
                QtWidgets.QApplication.processEvents()

            for ind_det, det in enumerate(detectors):
                self.preset_params.child(
                    ('Detectors')).addNew(detectors_type[ind_det] + '/' + det)
                self.preset_params.child(
                    'Detectors', 'det{:02.0f}'.format(ind_det),
                    'name').setValue(detectors_name[ind_det])
                QtWidgets.QApplication.processEvents()

        status = self.show_preset()
        return status