Ejemplo n.º 1
0
    def get_data(self, message):
        """

        Parameters
        ----------
        message

        Returns
        -------

        """
        messg = ThreadCommand(message)

        if message == 'set_info':
            list_len = get_int(self.socket)
            path = []
            for ind in range(list_len):
                path.append(get_string(self.socket))
            param_xml = get_string(self.socket)
            messg.attributes = [path, param_xml]

        elif message == 'move_abs':
            position = get_scalar(self.socket)
            messg.attributes = [position]

        elif message == 'move_rel':
            position = get_scalar(self.socket)
            messg.attributes = [position]

        self.cmd_signal.emit(messg)
Ejemplo n.º 2
0
    def process_cmds(self, command, command_sock=None):
        """
            Process the given command.

            Depending on the command name :
            * Done :

                * Find a socket from the 'GRABBER' connected client.
                * Send data to a viewer or a client (depending on command_sock).

            * Info : Find a socket from the 'GRABBER' connected client and read infos.

            * Send Data 0D :

                * Find a socket from the 'GRABBER' connected client.
                * set a 1D Mock data.

            * Send Data 1D :

                * Find a socket from the 'GRABBER' connected client.
                * set a 1D Mock data.

            * Send Data 2D :

                * Find a socket from the 'GRABBER' connected client.
                * set a 2D Mock data.

            =============== =========== ==========================
            **Parameters**    **Type**    **Description**
            *command*         string      the command as a string
            *command_sock*    ???
            =============== =========== ==========================

            See Also
            --------
            find_socket_within_connected_clients, read_data, send_data, utility_classes.DAQ_Viewer_base.emit_status, daq_utils.ThreadCommand, send_command, set_1D_Mock_data, set_2D_Mock_data, process_cmds
        """
        if command not in self.message_list:
            return

        if command == 'Done':  # means the given socket finished grabbing data and is ready to send them
            self.command_done(command_sock)

        elif command == "Infos":
            try:
                sock = self.find_socket_within_connected_clients(
                    self.client_type)
                if sock is not None:  # if client self.client_type is connected then send it the command
                    self.read_infos(sock)

            except Exception as e:
                self.emit_status(
                    ThreadCommand("Update_Status", [str(e), 'log']))

        elif command == "Info":
            try:
                sock = self.find_socket_within_connected_clients(
                    self.client_type)
                if sock is not None:  # if client self.client_type is connected then send it the command
                    self.read_info(sock)
            except Exception as e:
                self.emit_status(
                    ThreadCommand("Update_Status", [str(e), 'log']))

        elif command == 'Info_xml':
            sock = self.find_socket_within_connected_clients(self.client_type)
            if sock is not None:
                list_len = get_int(sock)
                path = []
                for ind in range(list_len):
                    data_len = int.from_bytes(check_received_length(sock, 4),
                                              'big')
                    path.append(check_received_length(sock, data_len).decode())
                data_len = int.from_bytes(check_received_length(sock, 4),
                                          'big')
                param_xml = check_received_length(sock, data_len).decode()
                param_dict = custom_tree.XML_string_to_parameter(param_xml)[0]

                param_here = self.settings.child('infos', *path[1:])
                param_here.restoreState(param_dict)

        else:
            self.command_to_from_client(command)