GSI Online DNA

Description

Module: geocompy.gsi.dna

The dna package provides wrapper methods for all GSI Online commands available on a DNA digital level instrument.

Types

  • GsiOnlineDNA

Submodules

  • geocompy.gsi.dna.settings

  • geocompy.gsi.dna.measurements

Definitions

class GsiOnlineDNA(connection: Connection, *, logger: Logger | None = None, attempts: int = 2)[source]

DNA GSI Online 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.gsi.dna import GsiOnlineDNA
>>>
>>> with open_serial("COM1") as line:
...     dna = GsiOnlineDNA(line)
...     dna.beep('SHORT')
...
>>>

Passing a logger:

>>> from sys import stdout
>>> from logging import getLogger, DEBUG, StreamHandler
>>>
>>> from geocompy.communication import open_serial
>>> from geocompy.gsi.dna import GsiOnlineDNA
>>>
>>> logger = getLogger("TPS")
>>> logger.addHandler(StreamHandler(stdout))
>>> logger.setLevel(DEBUG)
>>> with open_serial("COM1") as com:
...     dna = GsiOnlineDNA(com, logger=logger)
...     dna.beep('SHORT')
...
>>>
GsiOnlineResponse(GSI Type) ... # Startup GSI format sync
GsiOnlineResponse(Beep) ... # First executed command

After all subsystems are initialized, the connection is tested / initiated with a wake up command (this means the instrument does not have to be turned on manually before initiating the connection). If the test fails, it is retried with one second delay (if multiple attempts are allowed).

Parameters:
connection: Connection

Connection to the DNA instrument (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

Raises:

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

class BEEPTYPE(*values)[source]
ALARM = 2[source]
LONG = 1[source]
SHORT = 0[source]
beep(beeptype: BEEPTYPE | str) GsiOnlineResponse[bool][source]

Gives a beep signal command to the instrument.

Parameters:
beeptype: BEEPTYPE | str

Type of the beep signal to give off.

Returns:

Success of the execution.

Return type:

GsiOnlineResponse

clear() GsiOnlineResponse[bool][source]

Clears the command receiver buffer and aborts any running continuous measurement.

Returns:

Success of the execution.

Return type:

GsiOnlineResponse

confrequest(param: int, parser: Callable[[str], _T]) GsiOnlineResponse[_T][source]

Executes a GSI Online CONF command and returns the result of the parameter query.

Parameters:
param: int

Index of the parameter to query.

parser: Callable[[str], _T]

Parser function to process the result of the query.

Returns:

Parsed parameter value.

Return type:

GsiOnlineResponse

getrequest(mode: str, wordtype: type[_G]) GsiOnlineResponse[_G][source]

Executes a GSI Online GET command and returns the parsed result of the GSI word query.

Parameters:
mode: str

Request mode. I: internal/instant, M: measure, C: continuous.

wordtype: type[_G]

GsiWord type to request.

Returns:

Parsed value.

Return type:

GsiOnlineResponse

putrequest(word: GsiWord) GsiOnlineResponse[bool][source]

Executes a GSI Online PUT command and returns the success of the operation.

Parameters:
word: GsiWord

GSI word to send.

Returns:

Success of the change.

Return type:

GsiOnlineResponse

request(cmd: str, desc: str = '') GsiOnlineResponse[bool][source]

Executes a low level GSI Online command and returns the success of the execution.

Parameters:
cmd: str

Command string to send to instrument.

desc: str = ''

Command description to show in response.

Returns:

Success of the execution.

Return type:

GsiOnlineResponse

setrequest(param: int, value: int) GsiOnlineResponse[bool][source]

Executes a GSI Online SET command and returns the success of the operation.

Parameters:
param: int

Index of the parameter to set.

value: int

Value to set the parameter to.

Returns:

Success of the parameter change.

Return type:

GsiOnlineResponse

shutdown() GsiOnlineResponse[bool][source]

Shuts down the instrument.

Returns:

Success of the execution.

Return type:

GsiOnlineResponse

wakeup() GsiOnlineResponse[bool][source]

Wakes up the instrument.

Returns:

Success of the execution.

Return type:

GsiOnlineResponse

property is_client_gsi16 : bool[source]
measurements : GsiOnlineDNAMeasurements[source]

Measurements subsystem.

settings : GsiOnlineDNASettings[source]

Instrument settings subsystem.