11.3.1.1. TCP/IP related methods

Created on Fri Aug 30 12:21:56 2019

@author: Weber

class pymodaq.daq_utils.tcp_server_client.MockServer(client_type='GRABBER')[source]
class pymodaq.daq_utils.tcp_server_client.TCPClient(ipaddress='192.168.1.62', port=6341, params_state=None, client_type='GRABBER')[source]

PyQt5 object initializing a TCP socket client. Can be used by any module but is a builtin functionnality of all actuators and detectors of PyMoDAQ

The module should init TCPClient, move it in a thread and communicate with it using a custom signal connected to TCPClient.queue_command slot. The module should also connect TCPClient.cmd_signal to one of its methods inorder to get info/data back from the client

The client itself communicate with a TCP server, it is best to use a server object subclassing the TCPServer class defined within this python module

get_data(message)[source]
Parameters:message
queue_command(command=<pymodaq.daq_utils.daq_utils.ThreadCommand object>)[source]

when this TCPClient object is within a thread, the corresponding module communicate with it with signal and slots from module to client: module_signal to queue_command slot from client to module: self.cmd_signal to a module slot

class pymodaq.daq_utils.tcp_server_client.TCPServer(client_type='GRABBER')[source]

Abstract class to be used as inherited by DAQ_Viewer_TCP or DAQ_Move_TCP

close_server()[source]

close the current opened server. Update the settings tree consequently.

See also

set_connected_clients_table(), daq_utils.ThreadCommand()

find_socket_type_within_connected_clients(sock)[source]

Find a socket type from a connected client with socket content corresponding.

Parameters Type Description
sock ??? The socket content corresponding.
Returns:the socket dictionnary
Return type:dictionnary
find_socket_within_connected_clients(client_type)[source]

Find a socket from a conneceted client with socket type corresponding.

Parameters Type Description
client_type string The corresponding client type
Returns:the socket dictionnary
Return type:dictionnary
listen_client()[source]

Server function. Used to connect or listen incoming message from a client.

print_status(status)[source]

Print the given status.

Parameters Type Description
status string list a string list representing the status socket
process_cmds(command, command_sock=None)[source]

Process the given command.

read_info(sock=None, test_info='an_info', test_value='')[source]

if the client is not from PyMoDAQ it can use this method to display some info into the server widget

select(rlist, wlist=[], xlist=[], timeout=0)[source]

Implements the select method, https://docs.python.org/3/library/select.html :param rlist: :type rlist: (list) wait until ready for reading :param wlist: :type wlist: (list) wait until ready for writing :param xlist: :type xlist: (list) wait for an “exceptional condition” :param timeout: When the timeout argument is omitted the function blocks until at least one file descriptor is ready.

A time-out value of zero specifies a poll and never blocks.
Returns:
  • list (readable sockets)
  • list (writable sockets)
  • list (sockets with error pending)
send_command(sock, command='move_at')[source]

Send one of the message contained in self.message_list toward a socket with identity socket_type. First send the length of the command with 4bytes.

Parameters Type Description
sock ??? The current socket
command string The command as a string

See also

utility_classes.DAQ_Viewer_base.emit_status(), daq_utils.ThreadCommand(), message_to_bytes()

set_connected_clients_table()[source]
timerEvent(event)[source]

Called by set timers. If the process is free, start the listen_client function.

Parameters Type Description
event QTimerEvent object Containing id from timer issuing this event

See also

listen_client()