Hamlib  4.0~rc2
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 s_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 
107 
110 typedef enum {
111  ROT_FLAG_AZIMUTH = (1 << 1),
112  ROT_FLAG_ELEVATION = (1 << 2)
113 } rot_type_t;
114 
115 #define ROT_TYPE_MASK (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION)
116 
117 #define ROT_TYPE_OTHER 0
118 #define ROT_TYPE_AZIMUTH ROT_FLAG_AZIMUTH
119 #define ROT_TYPE_ELEVATION ROT_FLAG_ELEVATION
120 #define ROT_TYPE_AZEL (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION)
121 
123 
134 #define ROT_MOVE_UP (1<<1)
135 
146 #define ROT_MOVE_DOWN (1<<2)
147 
158 #define ROT_MOVE_LEFT (1<<3)
159 
171 #define ROT_MOVE_CCW ROT_MOVE_LEFT
172 
183 #define ROT_MOVE_RIGHT (1<<4)
184 
196 #define ROT_MOVE_CW ROT_MOVE_RIGHT
197 
198 
199 /* Basic rot type, can store some useful info about different rotators. Each
200  * lib must be able to populate this structure, so we can make useful
201  * enquiries about capabilities.
202  */
203 
222 #define ROT_MODEL(arg) .rot_model=arg,.macro_name=#arg
224 struct rot_caps {
225  rot_model_t rot_model;
226  const char *model_name;
227  const char *mfg_name;
228  const char *version;
229  const char *copyright;
230  enum rig_status_e status;
232  int rot_type;
233  enum rig_port_e port_type;
235  int serial_rate_min;
236  int serial_rate_max;
237  int serial_data_bits;
238  int serial_stop_bits;
239  enum serial_parity_e serial_parity;
240  enum serial_handshake_e serial_handshake;
242  int write_delay;
243  int post_write_delay;
244  int timeout;
245  int retry;
248  /*
249  * Movement range, az is relative to North
250  * negative values allowed for overlap
251  */
252  azimuth_t min_az;
253  azimuth_t max_az;
255  min_el;
257  max_el;
260  const struct confparams *cfgparams;
261  const rig_ptr_t priv;
263  /*
264  * Rot Admin API
265  *
266  */
267 
268  int (*rot_init)(ROT *rot);
269  int (*rot_cleanup)(ROT *rot);
270  int (*rot_open)(ROT *rot);
271  int (*rot_close)(ROT *rot);
272 
273  int (*set_conf)(ROT *rot, token_t token, const char *val);
274  int (*get_conf)(ROT *rot, token_t token, char *val);
275 
276  /*
277  * General API commands, from most primitive to least.. :()
278  * List Set/Get functions pairs
279  */
280 
281  int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
282  int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
283 
284  int (*stop)(ROT *rot);
285  int (*park)(ROT *rot);
286  int (*reset)(ROT *rot, rot_reset_t reset);
287  int (*move)(ROT *rot, int direction, int speed);
288 
289  /* get firmware info, etc. */
290  const char * (*get_info)(ROT *rot);
291 
292  const char *macro_name;
293  /* more to come... */
294 };
296 
297 
309 struct rot_state {
310  /*
311  * overridable fields
312  */
321  /*
322  * non overridable fields, internal use
323  */
324  hamlib_port_t rotport;
327  rig_ptr_t priv;
328  rig_ptr_t obj;
330  /* etc... */
331 };
332 
333 
346 struct s_rot {
347  struct rot_caps *caps;
348  struct rot_state state;
349 };
350 
351 
353 /* --------------- API function prototypes -----------------*/
354 
355 extern HAMLIB_EXPORT(ROT *)
356 rot_init HAMLIB_PARAMS((rot_model_t rot_model));
357 
358 extern HAMLIB_EXPORT(int)
359 rot_open HAMLIB_PARAMS((ROT *rot));
360 
361 extern HAMLIB_EXPORT(int)
362 rot_close HAMLIB_PARAMS((ROT *rot));
363 
364 extern HAMLIB_EXPORT(int)
365 rot_cleanup HAMLIB_PARAMS((ROT *rot));
366 
367 extern HAMLIB_EXPORT(int)
368 rot_set_conf HAMLIB_PARAMS((ROT *rot,
369  token_t token,
370  const char *val));
371 extern HAMLIB_EXPORT(int)
372 rot_get_conf HAMLIB_PARAMS((ROT *rot,
373  token_t token,
374  char *val));
375 
376 /*
377  * General API commands, from most primitive to least.. )
378  * List Set/Get functions pairs
379  */
380 extern HAMLIB_EXPORT(int)
381 rot_set_position HAMLIB_PARAMS((ROT *rot,
382  azimuth_t azimuth,
383  elevation_t elevation));
384 extern HAMLIB_EXPORT(int)
385 rot_get_position HAMLIB_PARAMS((ROT *rot,
386  azimuth_t *azimuth,
387  elevation_t *elevation));
388 
389 extern HAMLIB_EXPORT(int)
390 rot_stop HAMLIB_PARAMS((ROT *rot));
391 
392 extern HAMLIB_EXPORT(int)
393 rot_park HAMLIB_PARAMS((ROT *rot));
394 
395 extern HAMLIB_EXPORT(int)
396 rot_reset HAMLIB_PARAMS((ROT *rot,
397  rot_reset_t reset));
398 
399 extern HAMLIB_EXPORT(int)
400 rot_move HAMLIB_PARAMS((ROT *rot,
401  int direction,
402  int speed));
403 
404 extern HAMLIB_EXPORT(const char *)
405 rot_get_info HAMLIB_PARAMS((ROT *rot));
406 
407 extern HAMLIB_EXPORT(int)
408 rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
409 
410 extern HAMLIB_EXPORT(int)
411 rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
412 
413 extern HAMLIB_EXPORT(int)
414 rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps *,
415  rig_ptr_t),
416  rig_ptr_t data));
417 
418 extern HAMLIB_EXPORT(int)
419 rot_load_backend HAMLIB_PARAMS((const char *be_name));
420 
421 extern HAMLIB_EXPORT(int)
422 rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
423 
424 extern HAMLIB_EXPORT(int)
425 rot_load_all_backends HAMLIB_PARAMS((void));
426 
427 extern HAMLIB_EXPORT(rot_model_t)
428 rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
429 
430 extern HAMLIB_EXPORT(int)
431 rot_token_foreach HAMLIB_PARAMS((ROT *rot,
432  int (*cfunc)(const struct confparams *,
433  rig_ptr_t),
434  rig_ptr_t data));
435 
436 extern HAMLIB_EXPORT(const struct confparams *)
437 rot_confparam_lookup HAMLIB_PARAMS((ROT *rot,
438  const char *name));
439 
440 extern HAMLIB_EXPORT(token_t)
441 rot_token_lookup HAMLIB_PARAMS((ROT *rot,
442  const char *name));
443 
444 extern HAMLIB_EXPORT(const struct rot_caps *)
445 rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
446 
447 extern HAMLIB_EXPORT(int)
448 qrb HAMLIB_PARAMS((double lon1,
449  double lat1,
450  double lon2,
451  double lat2,
452  double *distance,
453  double *azimuth));
454 
455 extern HAMLIB_EXPORT(double)
456 distance_long_path HAMLIB_PARAMS((double distance));
457 
458 extern HAMLIB_EXPORT(double)
459 azimuth_long_path HAMLIB_PARAMS((double azimuth));
460 
461 extern HAMLIB_EXPORT(int)
462 longlat2locator HAMLIB_PARAMS((double longitude,
463  double latitude,
464  char *locator_res,
465  int pair_count));
466 
467 extern HAMLIB_EXPORT(int)
468 locator2longlat HAMLIB_PARAMS((double *longitude,
469  double *latitude,
470  const char *locator));
471 
472 extern HAMLIB_EXPORT(double)
473 dms2dec HAMLIB_PARAMS((int degrees,
474  int minutes,
475  double seconds,
476  int sw));
477 
478 extern HAMLIB_EXPORT(int)
479 dec2dms HAMLIB_PARAMS((double dec,
480  int *degrees,
481  int *minutes,
482  double *seconds,
483  int *sw));
484 
485 extern HAMLIB_EXPORT(int)
486 dec2dmmm HAMLIB_PARAMS((double dec,
487  int *degrees,
488  double *minutes,
489  int *sw));
490 
491 extern HAMLIB_EXPORT(double)
492 dmmm2dec HAMLIB_PARAMS((int degrees,
493  double minutes,
494  double seconds,
495  int sw));
496 
498 
508 #define rot_debug rig_debug
509 
510 __END_DECLS
511 
512 #endif /* _ROTATOR_H */
513 
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
long token_t
configuration token
Definition: rig.h:652
int rot_reset_t
Type definition for rotator reset.
Definition: rotator.h:103
int rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation)
set the azimuth and elevation of the rotator
Definition: rotator.c:574
This is the master data structure, acting as a handle for the controlled rotator.
Definition: rotator.h:346
int dec2dmmm(double dec, int *degrees, double *minutes, int *sw)
Convert a decimal angle into D M.MMM notation.
Definition: locator.c:345
azimuth_t max_az
Definition: rotator.h:314
int rot_set_conf(ROT *rot, token_t token, const char *val)
set a rotator configuration parameter
Definition: rot_conf.c:632
serial_handshake_e
Serial handshake.
Definition: rig.h:238
Rotator data structure.
azimuth_t min_az
Definition: rotator.h:313
int rot_move(ROT *rot, int direction, int speed)
move the rotator in the specified direction
Definition: rotator.c:783
int south_zero
Definition: rotator.h:317
Hamlib rotator model definitions.
rig_status_e
Development status of the backend.
Definition: rig.h:292
int rot_model_t
Convenience type definition for rotator model.
Definition: rotlist.h:464
elevation_t el_offset
Definition: rotator.h:319
token_t rot_token_lookup(ROT *rot, const char *name)
Simple lookup returning token id associated with name.
Definition: rot_conf.c:601
float elevation_t
Type definition for elevation.
Definition: rotator.h:67
int rot_close(ROT *rot)
close the communication to the rot
Definition: rotator.c:450
int rot_get_conf(ROT *rot, token_t token, char *val)
get the value of a configuration parameter
Definition: rot_conf.c:684
rig_ptr_t obj
Definition: rotator.h:328
elevation_t max_el
Definition: rotator.h:316
int comm_state
Definition: rotator.h:326
token_t token
Definition: rig.h:692
double distance_long_path(double distance)
Calculate the long path distance between two points.
Definition: locator.c:676
elevation_t min_el
Definition: rotator.h:315
double dmmm2dec(int degrees, double minutes, double seconds, int sw)
Convert D M.MMM notation to decimal degrees.
Definition: locator.c:196
int rot_park(ROT *rot)
park the antenna
Definition: rotator.c:685
serial_parity_e
Serial parity.
Definition: rig.h:226
int longlat2locator(double longitude, double latitude, char *locator, int pair_count)
Convert longitude/latitude to Maidenhead grid locator.
Definition: locator.c:485
double dms2dec(int degrees, int minutes, double seconds, int sw)
Convert DMS to decimal degrees.
Definition: locator.c:141
Hamlib rig data structures.
const char * rot_get_info(ROT *rot)
get general information from the rotator
Definition: rotator.c:816
struct rot_caps * caps
Definition: rotator.h:347
double azimuth_long_path(double azimuth)
Calculate the long path bearing between two points.
Definition: locator.c:696
float azimuth_t
Type definition for azimuth.
Definition: rotator.h:79
int rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation)
get the azimuth and elevation of the rotator
Definition: rotator.c:634
Live data and customized fields.
Definition: rotator.h:309
int rot_stop(ROT *rot)
stop the rotator
Definition: rotator.c:718
azimuth_t az_offset
Definition: rotator.h:318
int locator2longlat(double *longitude, double *latitude, const char *locator)
Convert Maidenhead grid locator to Longitude/Latitude.
Definition: locator.c:397
int rot_reset(ROT *rot, rot_reset_t reset)
reset the rotator
Definition: rotator.c:752
struct rot_state state
Definition: rotator.h:348
rig_ptr_t priv
Definition: rotator.h:327
int rot_cleanup(ROT *rot)
release a rot handle and free associated memory
Definition: rotator.c:529
ROT * rot_init(rot_model_t rot_model)
allocate a new ROT handle
Definition: rotator.c:197
Configuration parameter structure.
Definition: rig.h:691
int dec2dms(double dec, int *degrees, int *minutes, double *seconds, int *sw)
Convert decimal degrees angle into DMS notation.
Definition: locator.c:252
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
rig_port_e
Port type.
Definition: rig.h:205
hamlib_port_t rotport
Definition: rotator.h:324
int rot_token_foreach(ROT *rot, int(*cfunc)(const struct confparams *, rig_ptr_t), rig_ptr_t data)
Executes cfunc on all the elements stored in the conf table.
Definition: rot_conf.c:490
int rot_open(ROT *rot)
open the communication to the rot
Definition: rotator.c:318

Generated by doxygen 1.8.15

Hamlib documentation for version 4.0~rc2 -- Thu Nov 12 2020 00:00:00
Project page: http://www.hamlib.org