6.4.2. TCP/IP related methods¶
Created on Fri Aug 30 12:21:56 2019
@author: Weber
- class pymodaq.utils.tcp_server_client.Grabber(parent: Optional[QObject] = None)[source]¶
Methods
Do a grab session using 2 profile :
command_tcpip
connect_tcp_ip
process_tcpip_cmds
snapshot
- grab_data()[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.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
Methods
get_data
(message)- param message
post_init
([extra_commands])To implement in a real object implementation
queue_command
([command])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
Do stuff (like read data) when messages arrive through the socket
Send stuff into the socket
Error in the socket communication
cmd_signal
data_ready
not_connected
process_error_in_polling
send_data
send_info_string
send_infos_xml
- queue_command(command=<class 'pymodaq.utils.daq_utils.ThreadCommand'>)[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.utils.tcp_server_client.TCPServer(client_type='GRABBER')[source]¶
Abstract class to be used as inherited by DAQ_Viewer_TCP or DAQ_Move_TCP
Methods
close the current opened server.
Find a socket type from a connected client with socket content corresponding.
find_socket_within_connected_clients
(client_type)Find a socket from a conneceted client with socket type corresponding.
Server function.
print_status
(status)Print the given status.
process_cmds
(command[, command_sock])Process the given command.
read_info
([sock, test_info, test_value])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])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. :type timeout: (float) optional timeout argument specifies a time-out as a floating point number in seconds.
send_command
(sock[, command])Send one of the message contained in self.message_list toward a socket with identity socket_type.
timerEvent
(event)Called by set timers.
command_done
command_to_from_client
emit_status
init_server
read_data
read_info_xml
read_infos
remove_client
send_data
set_connected_clients_table
- 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
- print_status(status)[source]¶
Print the given status.
Parameters
Type
Description
status
string list
a string list representing the status socket
- 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