Hamlib  4.0~git
rotator.h
Go to the documentation of this file.
1 /*
2  * Hamlib Interface - Rotator API header
3  * Copyright (c) 2000-2005 by Stephane Fillod
4  *
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
21 
22 #ifndef _ROTATOR_H
23 #define _ROTATOR_H 1
24 
25 #include <hamlib/rig.h>
26 #include <hamlib/rotlist.h>
27 
43 __BEGIN_DECLS
44 
45 /* Forward struct references */
46 
47 struct rot;
48 struct rot_state;
49 
50 
55 typedef struct rot ROT;
56 
57 
67 typedef float elevation_t;
68 
69 
79 typedef float azimuth_t;
80 
81 
85 #define NETROTCTL_RET "RPRT "
86 
87 
93 #define ROT_RESET_ALL 1
94 
95 
103 typedef int rot_reset_t;
104 
105 
109 typedef enum {
110  ROT_FLAG_AZIMUTH = (1 << 1),
111  ROT_FLAG_ELEVATION = (1 << 2)
112 } rot_type_t;
113 
114 #define ROT_TYPE_MASK (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION)
115 
116 #define ROT_TYPE_OTHER 0
117 #define ROT_TYPE_AZIMUTH ROT_FLAG_AZIMUTH
118 #define ROT_TYPE_ELEVATION ROT_FLAG_ELEVATION
119 #define ROT_TYPE_AZEL (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION)
120 
121 
132 #define ROT_MOVE_UP (1<<1)
133 
144 #define ROT_MOVE_DOWN (1<<2)
145 
156 #define ROT_MOVE_LEFT (1<<3)
157 
169 #define ROT_MOVE_CCW ROT_MOVE_LEFT
170 
181 #define ROT_MOVE_RIGHT (1<<4)
182 
194 #define ROT_MOVE_CW ROT_MOVE_RIGHT
195 
196 
197 /* Basic rot type, can store some useful info about different rotators. Each
198  * lib must be able to populate this structure, so we can make useful
199  * enquiries about capablilities.
200  */
201 
219 #define ROT_MODEL(arg) .rot_model=arg,.macro_name=#arg
220 struct rot_caps {
222  const char *model_name;
223  const char *macro_name;
224  const char *mfg_name;
225  const char *version;
226  const char *copyright;
229  int rot_type;
241  int timeout;
242  int retry;
245  /*
246  * Movement range, az is relative to North
247  * negative values allowed for overlap
248  */
257  const struct confparams *cfgparams;
258  const rig_ptr_t priv;
259  const char *rot_model_macro_name;
261  /*
262  * Rot Admin API
263  *
264  */
265 
266  int (*rot_init)(ROT *rot);
267  int (*rot_cleanup)(ROT *rot);
268  int (*rot_open)(ROT *rot);
269  int (*rot_close)(ROT *rot);
270 
271  int (*set_conf)(ROT *rot, token_t token, const char *val);
272  int (*get_conf)(ROT *rot, token_t token, char *val);
273 
274  /*
275  * General API commands, from most primitive to least.. :()
276  * List Set/Get functions pairs
277  */
278 
279  int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
280  int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
281 
282  int (*stop)(ROT *rot);
283  int (*park)(ROT *rot);
284  int (*reset)(ROT *rot, rot_reset_t reset);
285  int (*move)(ROT *rot, int direction, int speed);
286 
287  /* get firmware info, etc. */
288  const char * (*get_info)(ROT *rot);
289 
290  /* more to come... */
291 };
292 
293 
305 struct rot_state {
306  /*
307  * overridable fields
308  */
317  /*
318  * non overridable fields, internal use
319  */
323  rig_ptr_t priv;
324  rig_ptr_t obj;
326  /* etc... */
327 };
328 
329 
342 struct rot {
343  struct rot_caps *caps;
344  struct rot_state state;
345 };
346 
347 
348 /* --------------- API function prototypes -----------------*/
349 
350 extern HAMLIB_EXPORT(ROT *)
351 rot_init HAMLIB_PARAMS((rot_model_t rot_model));
352 
353 extern HAMLIB_EXPORT(int)
354 rot_open HAMLIB_PARAMS((ROT *rot));
355 
356 extern HAMLIB_EXPORT(int)
357 rot_close HAMLIB_PARAMS((ROT *rot));
358 
359 extern HAMLIB_EXPORT(int)
360 rot_cleanup HAMLIB_PARAMS((ROT *rot));
361 
362 extern HAMLIB_EXPORT(int)
363 rot_set_conf HAMLIB_PARAMS((ROT *rot,
364  token_t token,
365  const char *val));
366 extern HAMLIB_EXPORT(int)
367 rot_get_conf HAMLIB_PARAMS((ROT *rot,
368  token_t token,
369  char *val));
370 
371 /*
372  * General API commands, from most primitive to least.. )
373  * List Set/Get functions pairs
374  */
375 extern HAMLIB_EXPORT(int)
376 rot_set_position HAMLIB_PARAMS((ROT *rot,
377  azimuth_t azimuth,
378  elevation_t elevation));
379 extern HAMLIB_EXPORT(int)
380 rot_get_position HAMLIB_PARAMS((ROT *rot,
381  azimuth_t *azimuth,
382  elevation_t *elevation));
383 
384 extern HAMLIB_EXPORT(int)
385 rot_stop HAMLIB_PARAMS((ROT *rot));
386 
387 extern HAMLIB_EXPORT(int)
388 rot_park HAMLIB_PARAMS((ROT *rot));
389 
390 extern HAMLIB_EXPORT(int)
391 rot_reset HAMLIB_PARAMS((ROT *rot,
392  rot_reset_t reset));
393 
394 extern HAMLIB_EXPORT(int)
395 rot_move HAMLIB_PARAMS((ROT *rot,
396  int direction,
397  int speed));
398 
399 extern HAMLIB_EXPORT(const char *)
400 rot_get_info HAMLIB_PARAMS((ROT *rot));
401 
402 extern HAMLIB_EXPORT(int)
403 rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
404 
405 extern HAMLIB_EXPORT(int)
406 rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
407 
408 extern HAMLIB_EXPORT(int)
409 rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps *,
410  rig_ptr_t),
411  rig_ptr_t data));
412 
413 extern HAMLIB_EXPORT(int)
414 rot_load_backend HAMLIB_PARAMS((const char *be_name));
415 
416 extern HAMLIB_EXPORT(int)
417 rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
418 
419 extern HAMLIB_EXPORT(int)
420 rot_load_all_backends HAMLIB_PARAMS((void));
421 
422 extern HAMLIB_EXPORT(rot_model_t)
423 rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
424 
425 extern HAMLIB_EXPORT(int)
426 rot_token_foreach HAMLIB_PARAMS((ROT *rot,
427  int (*cfunc)(const struct confparams *,
428  rig_ptr_t),
429  rig_ptr_t data));
430 
431 extern HAMLIB_EXPORT(const struct confparams *)
432 rot_confparam_lookup HAMLIB_PARAMS((ROT *rot,
433  const char *name));
434 
435 extern HAMLIB_EXPORT(token_t)
436 rot_token_lookup HAMLIB_PARAMS((ROT *rot,
437  const char *name));
438 
439 extern HAMLIB_EXPORT(const struct rot_caps *)
440 rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
441 
442 extern HAMLIB_EXPORT(int)
443 qrb HAMLIB_PARAMS((double lon1,
444  double lat1,
445  double lon2,
446  double lat2,
447  double *distance,
448  double *azimuth));
449 
450 extern HAMLIB_EXPORT(double)
451 distance_long_path HAMLIB_PARAMS((double distance));
452 
453 extern HAMLIB_EXPORT(double)
454 azimuth_long_path HAMLIB_PARAMS((double azimuth));
455 
456 extern HAMLIB_EXPORT(int)
457 longlat2locator HAMLIB_PARAMS((double longitude,
458  double latitude,
459  char *locator_res,
460  int pair_count));
461 
462 extern HAMLIB_EXPORT(int)
463 locator2longlat HAMLIB_PARAMS((double *longitude,
464  double *latitude,
465  const char *locator));
466 
467 extern HAMLIB_EXPORT(double)
468 dms2dec HAMLIB_PARAMS((int degrees,
469  int minutes,
470  double seconds,
471  int sw));
472 
473 extern HAMLIB_EXPORT(int)
474 dec2dms HAMLIB_PARAMS((double dec,
475  int *degrees,
476  int *minutes,
477  double *seconds,
478  int *sw));
479 
480 extern HAMLIB_EXPORT(int)
481 dec2dmmm HAMLIB_PARAMS((double dec,
482  int *degrees,
483  double *minutes,
484  int *sw));
485 
486 extern HAMLIB_EXPORT(double)
487 dmmm2dec HAMLIB_PARAMS((int degrees,
488  double minutes,
489  int sw));
490 
491 
501 #define rot_debug rig_debug
502 
503 __END_DECLS
504 
505 #endif /* _ROTATOR_H */
506 
rig_port_e
rig_port_e
Port type.
Definition: rig.h:195
rot_caps::model_name
const char * model_name
Definition: rotator.h:222
hamlib_port
Port definition.
Definition: rig.h:1656
rot_get_info
const char * rot_get_info(ROT *rot)
get general information from the rotator
Definition: rotator.c:806
rot_stop
int rot_stop(ROT *rot)
stop the rotator
Definition: rotator.c:708
rot_caps::macro_name
const char * macro_name
Definition: rotator.h:223
ROT_FLAG_ELEVATION
@ ROT_FLAG_ELEVATION
Definition: rotator.h:111
azimuth_long_path
double azimuth_long_path(double azimuth)
Calculate the long path bearing between two points.
Definition: locator.c:696
azimuth_t
float azimuth_t
Type definition for azimuth.
Definition: rotator.h:79
rot
This is the master data structure, acting as a handle for the controlled rotator.
Definition: rotator.h:342
rig_status_e
rig_status_e
Development status of the backend.
Definition: rig.h:280
rot_caps::priv
const char * priv
Definition: rotator.h:258
rot_state::max_az
azimuth_t max_az
Definition: rotator.h:310
rot_caps::serial_rate_max
int serial_rate_max
Definition: rotator.h:233
rot_state::priv
char * priv
Definition: rotator.h:323
rot_caps::serial_data_bits
int serial_data_bits
Definition: rotator.h:234
rot_caps::port_type
enum rig_port_e port_type
Definition: rotator.h:230
rot_caps::write_delay
int write_delay
Definition: rotator.h:239
rot_reset
int rot_reset(ROT *rot, rot_reset_t reset)
reset the rotator
Definition: rotator.c:742
confparams
Configuration parameter structure.
Definition: rig.h:625
rot_caps::min_el
elevation_t min_el
Definition: rotator.h:252
rot_caps::serial_stop_bits
int serial_stop_bits
Definition: rotator.h:235
rot_token_foreach
int rot_token_foreach(ROT *rot, int(*cfunc)(const struct confparams *, char *), char *data)
Executes cfunc on all the elements stored in the conf table.
Definition: rot_conf.c:490
rot_caps::rot_type
int rot_type
Definition: rotator.h:229
rot_park
int rot_park(ROT *rot)
park the antenna
Definition: rotator.c:675
rot_get_conf
int rot_get_conf(ROT *rot, token_t token, char *val)
get the value of a configuration parameter
Definition: rot_conf.c:684
rot_confparam_lookup
const struct confparams * rot_confparam_lookup(ROT *rot, const char *name)
lookup conf token by its name, return pointer to confparams struct.
Definition: rot_conf.c:544
rot_init
ROT * rot_init(rot_model_t rot_model)
allocate a new ROT handle
Definition: rotator.c:197
rot_cleanup
int rot_cleanup(ROT *rot)
release a rot handle and free associated memory
Definition: rotator.c:519
serial_handshake_e
serial_handshake_e
Serial handshake.
Definition: rig.h:228
rot_reset_t
int rot_reset_t
Type definition for rotator reset.
Definition: rotator.h:103
rot_caps
Rotator data structure.
Definition: rotator.h:220
rot_caps::min_az
azimuth_t min_az
Definition: rotator.h:249
rot_caps::copyright
const char * copyright
Definition: rotator.h:226
rot_get_position
int rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation)
get the azimuth and elevation of the rotator
Definition: rotator.c:624
rot::state
struct rot_state state
Definition: rotator.h:344
rot_caps::serial_handshake
enum serial_handshake_e serial_handshake
Definition: rotator.h:237
rig.h
Hamlib rig data structures.
rot_state::south_zero
int south_zero
Definition: rotator.h:313
rot_state::min_az
azimuth_t min_az
Definition: rotator.h:309
rot_caps::serial_parity
enum serial_parity_e serial_parity
Definition: rotator.h:236
rot_caps::timeout
int timeout
Definition: rotator.h:241
dec2dmmm
int dec2dmmm(double dec, int *degrees, double *minutes, int *sw)
Convert a decimal angle into D M.MMM notation.
Definition: locator.c:345
rot_state::max_el
elevation_t max_el
Definition: rotator.h:312
rot_set_position
int rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation)
set the azimuth and elevation of the rotator
Definition: rotator.c:564
rot_caps::status
enum rig_status_e status
Definition: rotator.h:227
rot_state::el_offset
elevation_t el_offset
Definition: rotator.h:315
longlat2locator
int longlat2locator(double longitude, double latitude, char *locator, int pair_count)
Convert longitude/latitude to Maidenhead grid locator.
Definition: locator.c:485
rot_caps::max_az
azimuth_t max_az
Definition: rotator.h:250
rot_caps::cfgparams
const struct confparams * cfgparams
Definition: rotator.h:257
rot_caps::version
const char * version
Definition: rotator.h:225
rot_state::az_offset
azimuth_t az_offset
Definition: rotator.h:314
rot_move
int rot_move(ROT *rot, int direction, int speed)
move the rotator in the specified direction
Definition: rotator.c:773
rot_state::min_el
elevation_t min_el
Definition: rotator.h:311
dmmm2dec
double dmmm2dec(int degrees, double minutes, int sw)
Convert D M.MMM notation to decimal degrees.
Definition: locator.c:196
rot_caps::retry
int retry
Definition: rotator.h:242
rot_open
int rot_open(ROT *rot)
open the communication to the rot
Definition: rotator.c:318
ROT_FLAG_AZIMUTH
@ ROT_FLAG_AZIMUTH
Definition: rotator.h:110
rot_caps::max_el
elevation_t max_el
Definition: rotator.h:254
serial_parity_e
serial_parity_e
Serial parity.
Definition: rig.h:216
confparams::token
token_t token
Definition: rig.h:626
rot_state::comm_state
int comm_state
Definition: rotator.h:322
qrb
int qrb(double lon1, double lat1, double lon2, double lat2, double *distance, double *azimuth)
Calculate the distance and bearing between two points.
Definition: locator.c:557
rot_token_lookup
token_t rot_token_lookup(ROT *rot, const char *name)
Simple lookup returning token id associated with name.
Definition: rot_conf.c:601
rot_model_t
int rot_model_t
Convenience type definition for rotator model.
Definition: rotlist.h:406
elevation_t
float elevation_t
Type definition for elevation.
Definition: rotator.h:67
rotlist.h
Hamlib amplifier model definitions.
token_t
long token_t
configuration token
Definition: rig.h:590
rot_caps::mfg_name
const char * mfg_name
Definition: rotator.h:224
rot_state
Live data and customized fields.
Definition: rotator.h:305
rot_caps::rot_model
rot_model_t rot_model
Definition: rotator.h:221
rot::caps
struct rot_caps * caps
Definition: rotator.h:343
dec2dms
int dec2dms(double dec, int *degrees, int *minutes, double *seconds, int *sw)
Convert decimal degrees angle into DMS notation.
Definition: locator.c:252
dms2dec
double dms2dec(int degrees, int minutes, double seconds, int sw)
Convert DMS to decimal degrees.
Definition: locator.c:141
distance_long_path
double distance_long_path(double distance)
Calculate the long path distance between two points.
Definition: locator.c:676
rot_close
int rot_close(ROT *rot)
close the communication to the rot
Definition: rotator.c:440
rot_caps::rot_model_macro_name
const char * rot_model_macro_name
Definition: rotator.h:259
locator2longlat
int locator2longlat(double *longitude, double *latitude, const char *locator)
Convert Maidenhead grid locator to Longitude/Latitude.
Definition: locator.c:397
rot_caps::serial_rate_min
int serial_rate_min
Definition: rotator.h:232
rot_caps::post_write_delay
int post_write_delay
Definition: rotator.h:240
rot_type_t
rot_type_t
Rotator type flags.
Definition: rotator.h:109
rot_state::obj
char * obj
Definition: rotator.h:324
rot_set_conf
int rot_set_conf(ROT *rot, token_t token, const char *val)
set a rotator configuration parameter
Definition: rot_conf.c:632
rot_state::rotport
hamlib_port_t rotport
Definition: rotator.h:320

Generated by doxygen 1.8.17

Hamlib documentation for version 4.0~git -- Sun Apr 5 2020 00:00:00
Project page: http://www.hamlib.org