MockServer

class lsst.ts.m2com.MockServer(host, port_command=50000, port_telemetry=50001, timeout_in_second=0.05, log=None, socket_family=AddressFamily.AF_UNSPEC, is_csc=True)

Bases: object

Mock server of M2.

Parameters:
hoststr

IP address for this server; typically LOCALHOST for IP4 or “::” for IP6.

port_commandint, optional

IP port for the command server. (the default is 50000)

port_telemetryint, optional

IP port for the telemetry server. (the default is 50001)

timeout_in_secondfloat, optional

Read timeout in second. (the default is 0.05)

loglogging.Logger or None, optional

A logger. If None, a logger will be instantiated. (the default is None)

socket_familysocket.AddressFamily, optional

Can be set to socket.AF_INET or socket.AF_INET6 to limit the server to IPv4 or IPv6, respectively. If socket.AF_UNSPEC (the default) the family will be determined from host, and if host is None, the server may listen on both IPv4 and IPv6 sockets.

is_cscbool, optional

Is called by the commandable SAL component (CSC) or not. (the default is True)

Attributes:
loglogging.Logger

A logger.

modelMockModel

Mock model to simulate the M2 hardware behavior.

server_commandtcpip.OneClientServer

Command server.

server_telemetrytcpip.OneClientServer

Telemetry server.

timeout_in_secondfloat

Read timeout in second.

Attributes Summary

FAKE_ERROR_CODE

PERIOD_TELEMETRY_IN_SECOND

Methods Summary

are_servers_connected()

The command and telemetry sockets are connected or not.

close()

Cancel the tasks and close the connections.

start()

Start the command and telemetry TCP/IP servers.

Attributes Documentation

FAKE_ERROR_CODE = 99
PERIOD_TELEMETRY_IN_SECOND = 0.05

Methods Documentation

are_servers_connected()

The command and telemetry sockets are connected or not.

Returns:
bool

True if servers are connected. Else, False.

async close()

Cancel the tasks and close the connections.

Note: this function is safe to call even though there is no connection.

async start()

Start the command and telemetry TCP/IP servers.