@@ -12,12 +12,11 @@ def main(
1212 timeout : int = 15 ,
1313 retry : int = 1 ,
1414 sync_after_timeout : bool = False ,
15- coordinates : tuple [float , float , float ] = (0 , 0 , 0 ),
16- instrumentheight : float = 0 ,
17- orientation : str = "0-00-00"
15+ coordinates : tuple [float , float , float ] | None = None ,
16+ instrumentheight : float | None = None ,
17+ orientation : str | None = None ,
18+ azimuth : str | None = None
1819) -> None :
19- station = Coordinate (* coordinates )
20- ori = Angle .from_dms (orientation )
2120 with open_serial (
2221 port = port ,
2322 speed = baud ,
@@ -26,21 +25,35 @@ def main(
2625 sync_after_timeout = sync_after_timeout
2726 ) as com :
2827 tps = GeoCom (com )
29- resp_stn = tps .tmc .set_station (station , instrumentheight )
30- if resp_stn .error != GeoComCode .OK :
31- echo_red ("Cannot set station" )
32- exit (1 )
28+ if coordinates is not None and instrumentheight is not None :
29+ resp_stn = tps .tmc .set_station (
30+ Coordinate (* coordinates ),
31+ instrumentheight
32+ )
33+ if resp_stn .error != GeoComCode .OK :
34+ echo_red ("Cannot set station" )
35+ exit (1 )
36+ else :
37+ echo_green ("Station set" )
3338
34- resp_angle = tps .tmc .get_angle ()
35- if resp_angle .error != GeoComCode .OK or resp_angle .params is None :
36- echo_red ("Cannot set orientation" )
37- exit (1 )
39+ if azimuth is not None :
40+ hz = Angle .from_dms (azimuth )
41+ elif orientation is not None :
42+ resp_angle = tps .tmc .get_angle ()
43+ if resp_angle .error != GeoComCode .OK or resp_angle .params is None :
44+ echo_red ("Could not set orientation" )
45+ exit (1 )
46+
47+ hz = (
48+ resp_angle .params [0 ]
49+ + Angle .from_dms (orientation )
50+ ).normalized ()
51+ else :
52+ exit ()
3853
39- resp_ori = tps .tmc .set_azimuth (
40- (resp_angle .params [0 ] + ori ).normalized ()
41- )
54+ resp_ori = tps .tmc .set_azimuth (hz )
4255 if resp_ori .error != GeoComCode .OK :
43- echo_red ("Cannot set orientation" )
56+ echo_red ("Could not set orientation/azimuth " )
4457 exit (1 )
4558
46- echo_green ("Station and orientation set" )
59+ echo_green ("Orientation/azimuth set" )
0 commit comments