TCP/IP related methods

Created on Fri Aug 30 12:21:56 2019

@author: Weber

class pymodaq.daq_utils.tcp_server_client.Grabber(grab_method=None)[source]
Do a grab session using 2 profile :
  • if grab pb checked do a continous save and send an “update_channels” thread command and a “grab” too.
  • if not send a “stop_grab” thread command with settings “main settings-naverage” node value as an attribute.

See also

daq_utils.ThreadCommand(), set_enabled_Ini_buttons()

class pymodaq.daq_utils.tcp_server_client.MockServer(client_type='GRABBER')[source]
class pymodaq.daq_utils.tcp_server_client.TCPClient(ipaddress='', 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

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 the current opened server. Update the settings tree consequently.

See also

set_connected_clients_table(), daq_utils.ThreadCommand()


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 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

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


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.
  • 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()


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