core.scpi_tcpserver:SCPI_TCP_Server

Define Polling Server.

Usage

Source

core.scpi_tcpserver:SCPI_TCP_Server(
    cmd_list,
    host="localhost",
    port=DEFAULT_PORT,
)

TCP server that implements SCPI-like command handling.

Parameters

cmd_list: dict

The SCPI commands and their associated functions; the values should be derived from Command.

host: str = "localhost"

The host address to bind the server to. Default is ‘localhost’.

port: int = DEFAULT_PORT
The port number to listen on. Default is 8898.

Attributes

running: bool

Whether the server is currently running.

server: ThreadedTCPServer
The actual TCP server instance.

Notes

Command list syntax: {scpi string: [value types, set function, set parameters, get function, get parameters], …}

  • scpi string: lower case, e.g. “:field:set”. Commands must be unique if only the first four characters within each pair of ‘::’ are used.
  • value types: list or tuple of types, or one of float, int, str, bool. None if no set function is to be defined.
  • set/get function: e.g. ex.setField (do not add brackets).
  • parameters: e.g. (2) if ex.setField(value, axis) is to be called with axis=2.

A trailing ‘?’ on the scpi string calls the get function, otherwise the set function is called and the value is split. Format: ‘scpiStr value’ (set) or ‘scpiStr?’ (get).

Value formats: - list: e.g. “1, 2, 3”, also mixed lists, e.g. “1, 2.3432, abc”; passed as list to the set function, check the entry types yourself. - int: “1”, bool: “0”, float: “-1.343e-23”, str: “curvename”

Methods

Name Description
start() Start the server.
stop() Stop the server.

start()

Start the server.

Usage

Source

start()

Starts the server if it’s not already running.


stop()

Stop the server.

Usage

Source

stop()

Stops the server if it’s currently running.