hvl_ccb.comm.tcp

digraph inheritance84e61f9c15 { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "CommunicationProtocol" [URL="../hvl_ccb.comm.base.html#hvl_ccb.comm.base.CommunicationProtocol",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Communication protocol abstract base class."]; "ConfigurationMixin" -> "CommunicationProtocol" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "CommunicationProtocol" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ConfigurationMixin" [URL="../hvl_ccb.configuration.html#hvl_ccb.configuration.ConfigurationMixin",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin providing configuration to a class."]; "ABC" -> "ConfigurationMixin" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Tcp" [URL="../hvl_ccb.comm.tcp.html#hvl_ccb.comm.tcp.Tcp",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Tcp Communication Protocol."]; "CommunicationProtocol" -> "Tcp" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TcpCommunicationConfig" [URL="../hvl_ccb.comm.tcp.html#hvl_ccb.comm.tcp.TcpCommunicationConfig",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Configuration dataclass for :class:`TcpCommunication`."]; }

TCP communication protocol. Makes use of the socket library.

class Tcp(configuration)[source]

Bases: CommunicationProtocol

Tcp Communication Protocol.

close() None[source]

Close TCP connection.

static config_cls() type[hvl_ccb.comm.tcp.TcpCommunicationConfig][source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

open() None[source]

Open TCP connection.

read() str[source]

TCP read function :return: information read from TCP buffer formatted as string

write(command: str = '') None[source]

TCP write function :param command: command string to be sent :return: none

class TcpCommunicationConfig(host: str | IPv4Address | IPv6Address, port: int = 54321, bufsize: int = 1024)[source]

Bases: object

Configuration dataclass for TcpCommunication.

bufsize: int = 1024
clean_values()[source]
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

host: str | IPv4Address | IPv6Address
is_configdataclass = True
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

port: int = 54321
classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.