66from geocompy .data import Angle
77from geocompy .geo import GeoCom
88from geocompy .geo .gctypes import GeoComCode
9+ from geocompy .gsi .dna import GsiOnlineDNA
910from geocompy .communication import open_serial
1011
1112from ..utils import (
1516)
1617
1718
18- def tests (tps : GeoCom ) -> None :
19+ def tests_geocom (tps : GeoCom ) -> None :
1920 echo ("GeoCom connection successful" )
2021 echo (
2122 "Various GeoCom functions will be tested. Certain settings will be "
@@ -55,8 +56,44 @@ def tests(tps: GeoCom) -> None:
5556 echo_yellow (f"Mororization unavailable ({ resp_changeface .response } )" )
5657
5758
59+ def tests_gsidna (dna : GsiOnlineDNA ) -> None :
60+ echo ("GSI Online connection successful" )
61+ echo (
62+ "Various GSI Online DNA functions will be tested. Certain settings "
63+ "might be changed on the instrument (staff mode, point number, etc.)."
64+ )
65+ pause ("Press any key when ready to proceed..." )
66+
67+ echo ("Testing settings..." )
68+ staff_get = dna .settings .get_staff_mode ()
69+ if staff_get .value is None :
70+ echo_red ("Settings queries unavailable" )
71+ else :
72+ echo_green ("Settings queries available" )
73+
74+ staff_set = dna .settings .set_staff_mode (False )
75+ if not staff_set .value :
76+ echo_red ("Settings commands unavailable" )
77+ else :
78+ echo_green ("Settings commands available" )
79+
80+ echo ("Testing measurements..." )
81+ point_get = dna .measurements .get_point_id ()
82+ if point_get is None :
83+ echo_red ("Measurement/database queries unavailable" )
84+ else :
85+ echo_green ("Measurement/database queries available" )
86+
87+ point_set = dna .measurements .set_point_id ("TEST" )
88+ if not point_set .value :
89+ echo_red ("Measurement/database commands unavailable" )
90+ else :
91+ echo_green ("Measurement/database commands available" )
92+
93+
5894def main (
5995 port : str ,
96+ protocol : str ,
6097 baud : int = 9600 ,
6198 timeout : int = 15 ,
6299 retry : int = 1 ,
@@ -70,7 +107,11 @@ def main(
70107 retry = retry ,
71108 sync_after_timeout = sync_after_timeout
72109 ) as com :
73- tps = GeoCom (com )
74- tests (tps )
110+ if protocol == "geocom" :
111+ tps = GeoCom (com )
112+ tests_geocom (tps )
113+ elif protocol == "gsidna" :
114+ dna = GsiOnlineDNA (com )
115+ tests_gsidna (dna )
75116 except (SerialException , ConnectionError ) as e :
76- echo_red (f"GeoCom connection was not successful ({ e } )" )
117+ echo_red (f"Connection was not successful ({ e } )" )
0 commit comments