GeoCOM

Description

Module: geocompy.geo

The geo package provides wrapper methods for all GeoCOM RPC functions available on supported instruments running various versions of the TPS system software, or software based on the TPS system.

Types

  • GeoCom

Submodules

  • geocompy.geo.gcdata

  • geocompy.geo.gctypes

  • geocompy.geo.aus

  • geocompy.geo.aut

  • geocompy.geo.bap

  • geocompy.geo.bmm

  • geocompy.geo.cam

  • geocompy.geo.com

  • geocompy.geo.csv

  • geocompy.geo.ctl

  • geocompy.geo.dna

  • geocompy.geo.edm

  • geocompy.geo.ftr

  • geocompy.geo.img

  • geocompy.geo.kdm

  • geocompy.geo.mot

  • geocompy.geo.sup

  • geocompy.geo.tmc

  • geocompy.geo.wir

Definitions

class GeoCom(connection: Connection, *, logger: Logger | None = None, attempts: int = 2, checksum: bool = False)[source]

GeoCOM protocol handler.

The individual commands are available through their respective subsystems.

Examples

Opening a simple serial connection:

>>> from geocompy.communication import open_serial
>>> from geocompy.geo import GeoCom
>>>
>>> with open_serial("COM1") as line:
...     tps = GeoCom(line)
...     tps.com.nullprocess()
...
>>>

Passing a logger:

>>> from sys import stdout
>>> from logging import getLogger, DEBUG, StreamHandler
>>>
>>> from geocompy.communication import open_serial
>>> from geocompy.geo import GeoCom
>>>
>>> logger = getLogger("TPS")
>>> logger.addHandler(StreamHandler(stdout))
>>> logger.setLevel(DEBUG)
>>> with open_serial("COM1") as com:
...     tps = GeoCom(com, logger=logger)
...     tps.com.nullprocess()
...
>>>
GeoComResponse(COM_NullProc) ... # Startup connection test
GeoComResponse(COM_GetDoublePrecision) ... # Precision sync
GeoComResponse(COM_NullProc) ... # First executed command

After the subsystems are initialized, the connection is tested by sending an LF character to clear the receiver buffer, then the COM_NullProc is executed. If the test fails, it is retried with one second delay (if multiple attempts are allowed).

Parameters:
connection: Connection

Connection to use for communication (usually a serial connection).

logger: Logger | None = None

Logger to log all requests and responses, by default None

attempts: int = 2

Number of tries at connection validation before raising exception, by default 2

checksum: bool = False

Use and verify checksums in requests, by default False

Raises:

ConnectionRefusedError – If the connection could not be verified in the specified number of attempts.

abort() GeoComResponse[None][source]

Aborts the current motorized function.

Returns:

Error codes:
  • UNDEFINED: The command was accepted, but the response indicated failed execution. Possibly nothing to abort.

  • COM_FAILED: The abort command could not be sent due to a communication issue.

Return type:

GeoComResponse

Note

The abort command does not actually use the GeoCOM syntax, but the function returns a GeoComResponse anyway, in order to maintain the uniformity with the rest of the commands.

parse_response(cmd: str, response: str, parsers: Callable[[str], _T] | None = None) GeoComResponse[_T][source]
parse_response(cmd: str, response: str, parsers: Iterable[Callable[[str], Any]] | None = None) GeoComResponse[tuple[Any, ...]]

Parses RPC response and constructs GeoComResponse instance.

Parameters:
cmd: str

Full, serialized request, that invoked the response.

response: str

Full, received response.

parsers: Callable[[str], _T] | None = None
parsers: Iterable[Callable[[str], Any]] | None = None

Parser functions for the values in the RPC response, by default None

Returns:

Parsed return codes and parameters from the RPC response.

Return type:

GeoComResponse

request(rpc: int, params: Iterable[int | float | bool | str | Angle | Byte | Enum] = (), parsers: Callable[[str], _T] | None = None) GeoComResponse[_T][source]
request(rpc: int, params: Iterable[int | float | bool | str | Angle | Byte | Enum] = (), parsers: Iterable[Callable[[str], Any]] | None = None) GeoComResponse[tuple[Any, ...]]

Executes an RPC request and returns the parsed GeoCOM response.

Constructs a request(from the given RPC code and parameters), writes it to the serial line, then reads the response. The response is then parsed using the provided parser functions.

Parameters:
rpc: int

Number of the RPC to execute.

params: Iterable[int | float | bool | str | Angle | Byte | Enum] = ()

Parameters for the request, by default()

parsers: Callable[[str], _T] | None = None
parsers: Iterable[Callable[[str], Any]] | None = None

Parser functions for the values in the RPC response, by default None

Returns:

Parsed return codes and parameters from the RPC response.

Return type:

GeoComResponse

aus : GeoComAUS[source]

Alt User subsystem.

Added in version GeoCOM-TPS1100.

aut : GeoComAUT[source]

Automation subsystem.

bap : GeoComBAP[source]

Basic applications subsystem.

bmm : GeoComBMM[source]

Basic man-machine interface subsystem.

cam : GeoComCAM[source]

Camera subsystem.

Added in version GeoCOM-VivaTPS.

com : GeoComCOM[source]

Communications subsystem.

csv : GeoComCSV[source]

Central services subsystem.

ctl : GeoComCTL[source]

Control task subsystem.

Removed in version GeoCOM-TPS1200.

dna : GeoComDNA[source]

Digital level subsystem.

Added in version GeoCOM-LS.

edm : GeoComEDM[source]

Electronic distance measurement subsystem.

ftr : GeoComFTR[source]

File transfer subsystem.

Added in version GeoCOM-TPS1200.

img : GeoComIMG[source]

Image processing subsystem.

Added in version GeoCOM-TPS1200.

kdm : GeoComKDM[source]

Keyboard display unit subsystem.

Added in version GeoCOM-VivaTPS.

mot : GeoComMOT[source]

Motorization subsytem.

property precision : int[source]

Decimal precision in serial communication.

sup : GeoComSUP[source]

Supervisor subsystem.

tmc : GeoComTMC[source]

Theodolite measurement and calculation subsystem.

transaction_counter[source]

Number of command transactions started during the current session.

wir : GeoComWIR[source]

Word Index registration subsystem.

Removed in version GeoCOM-TPS1200.