msl.equipment.connection_socket module
Base classes for equipment that is connected through a socket.
- class msl.equipment.connection_socket.ConnectionSocket(record)[source]
Bases:
ConnectionMessageBased
Base class for equipment that is connected through a socket.
The
properties
for a socket connection supports the following key-value pairs in the Connections Database (see alsosocket
for more details):'buffer_size': int, the maximum number of bytes to read at a time [default: 4096] 'encoding': str, the encoding to use [default: 'utf-8'] 'encoding_errors': str, encoding error handling scheme, e.g. 'strict', 'ignore' [default: 'strict'] 'family': str, the address family, e.g., 'INET', 'INET6', 'IPX' [default: 'INET'] 'max_read_size': int, the maximum number of bytes that can be read [default: 1 MB] 'proto': int, the socket protocol number [default: 0] 'read_termination': str or None, read until this termination sequence is found [default: '\n'] 'rstrip': bool, whether to remove trailing whitespace from "read" messages [default: False] 'socket_type': str, the socket type, e.g. 'STREAM', 'DGRAM' [default: 'STREAM'] 'termination': shortcut for setting both 'read_termination' and 'write_termination' to this value 'timeout': float or None, the timeout (in seconds) for read and write operations [default: None] 'write_termination': str or None, termination sequence appended to write messages [default: '\r\n']
The
backend
value must be equal toMSL
to use this class for the communication system. This is achieved by setting the value in the Backend field for a connection record in the Connections Database to beMSL
.Do not instantiate this class directly. Use the
connect()
method to connect to the equipment.- Parameters:
record (
EquipmentRecord
) – A record from an Equipment-Register Database.- Raises:
MSLConnectionError – If the socket cannot be opened.
- static parse_address(address)[source]
Get the host and port from an address.
- Parameters:
address (
str
) – The address of aConnectionRecord
.- Returns:
dict
orNone
– The value of the host and the port orNone
if address is not valid for a socket.