Beispiel #1
0
    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 update_settings(self, settings_parameter_dict):
        """
            Update the settings tree from settings_parameter_dict.
            Finally do a commit to activate changes.
            
            ========================== ============= =====================================================
            **Parameters**              **Type**      **Description**
            *settings_parameter_dict*   dictionnnary  a dictionnary listing path and associated parameter
            ========================== ============= =====================================================

            See Also
            --------
            send_param_status, commit_settings
        """
        # settings_parameter_dict=edict(path=path,param=param)
        try:
            path = settings_parameter_dict['path']
            param = settings_parameter_dict['param']
            change = settings_parameter_dict['change']
            try:
                self.settings.sigTreeStateChanged.disconnect(
                    self.send_param_status)
            except:
                pass
            if change == 'value':
                self.settings.child(*path[1:]).setValue(
                    param.value())  #blocks signal back to main UI
            elif change == 'childAdded':
                child = Parameter.create(name='tmp')
                child.restoreState(param)
                self.settings.child(*path[1:]).addChild(
                    child)  #blocks signal back to main UI
                param = child

            elif change == 'parent':
                children = custom_tree.get_param_from_name(
                    self.settings, param.name())

                if children is not None:
                    path = custom_tree.get_param_path(children)
                    self.settings.child(*path[1:-1]).removeChild(children)

            self.settings.sigTreeStateChanged.connect(self.send_param_status)

            self.commit_settings(param)
        except Exception as e:
            self.emit_status(ThreadCommand("Update_Status", [str(e), 'log']))
Beispiel #3
0
    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)
Beispiel #4
0
    def update_settings(
        self, settings_parameter_dict
    ):  #settings_parameter_dict=edict(path=path,param=param)
        """
            Receive the settings_parameter signal from the param_tree_changed method and make hardware updates of mmodified values.

            ==========================  =========== ==========================================================================================================
            **Arguments**               **Type**     **Description**
            *settings_parameter_dict*   dictionnary Dictionnary with the path of the parameter in hardware structure as key and the parameter name as element
            ==========================  =========== ==========================================================================================================

            See Also
            --------
            send_param_status, commit_settings
        """
        path = settings_parameter_dict['path']
        param = settings_parameter_dict['param']
        change = settings_parameter_dict['change']
        try:
            self.settings.sigTreeStateChanged.disconnect(
                self.send_param_status)
        except:
            pass
        if change == 'value':
            self.settings.child(*path[1:]).setValue(
                param.value())  # blocks signal back to main UI
        elif change == 'childAdded':
            child = Parameter.create(name='tmp')
            child.restoreState(param)
            self.settings.child(*path[1:]).addChild(
                child)  # blocks signal back to main UI
            param = child

        elif change == 'parent':
            children = custom_tree.get_param_from_name(self.settings,
                                                       param.name())

            if children is not None:
                path = custom_tree.get_param_path(children)
                self.settings.child(*path[1:-1]).removeChild(children)

        self.settings.sigTreeStateChanged.connect(self.send_param_status)
        self.commit_common_settings(param)
        self.commit_settings(param)