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 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 
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 *mfg_name;
224  const char *version;
225  const char *copyright;
228  int rot_type;
240  int timeout;
241  int retry;
244  /*
245  * Movement range, az is relative to North
246  * negative values allowed for overlap
247  */
256  const struct confparams *cfgparams;
257  const rig_ptr_t priv;
259  /*
260  * Rot Admin API
261  *
262  */
263 
264  int (*rot_init)(ROT *rot);
265  int (*rot_cleanup)(ROT *rot);
266  int (*rot_open)(ROT *rot);
267  int (*rot_close)(ROT *rot);
268 
269  int (*set_conf)(ROT *rot, token_t token, const char *val);
270  int (*get_conf)(ROT *rot, token_t token, char *val);
271 
272  /*
273  * General API commands, from most primitive to least.. :()
274  * List Set/Get functions pairs
275  */
276 
277  int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
278  int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
279 
280  int (*stop)(ROT *rot);
281  int (*park)(ROT *rot);
282  int (*reset)(ROT *rot, rot_reset_t reset);
283  int (*move)(ROT *rot, int direction, int speed);
284 
285  /* get firmware info, etc. */
286  const char * (*get_info)(ROT *rot);
287 
288  const char *macro_name;
289  /* more to come... */
290 };
291 
292 
304 struct rot_state {
305  /*
306  * overridable fields
307  */
316  /*
317  * non overridable fields, internal use
318  */
322  rig_ptr_t priv;
323  rig_ptr_t obj;
325  /* etc... */
326 };
327 
328 
341 struct s_rot {
342  struct rot_caps *caps;
343  struct rot_state state;
344 };
345 
346 
347 /* --------------- API function prototypes -----------------*/
348 
349 extern HAMLIB_EXPORT(ROT *)
350 rot_init HAMLIB_PARAMS((rot_model_t rot_model));
351 
352 extern HAMLIB_EXPORT(int)
353 rot_open HAMLIB_PARAMS((ROT *rot));
354 
355 extern HAMLIB_EXPORT(int)
356 rot_close HAMLIB_PARAMS((ROT *rot));
357 
358 extern HAMLIB_EXPORT(int)
359 rot_cleanup HAMLIB_PARAMS((ROT *rot));
360 
361 extern HAMLIB_EXPORT(int)
362 rot_set_conf HAMLIB_PARAMS((ROT *rot,
363  token_t token,
364  const char *val));
365 extern HAMLIB_EXPORT(int)
366 rot_get_conf HAMLIB_PARAMS((ROT *rot,
367  token_t token,
368  char *val));
369 
370 /*
371  * General API commands, from most primitive to least.. )
372  * List Set/Get functions pairs
373  */
374 extern HAMLIB_EXPORT(int)
375 rot_set_position HAMLIB_PARAMS((ROT *rot,
376  azimuth_t azimuth,
377  elevation_t elevation));
378 extern HAMLIB_EXPORT(int)
379 rot_get_position HAMLIB_PARAMS((ROT *rot,
380  azimuth_t *azimuth,
381  elevation_t *elevation));
382 
383 extern HAMLIB_EXPORT(int)
384 rot_stop HAMLIB_PARAMS((ROT *rot));
385 
386 extern HAMLIB_EXPORT(int)
387 rot_park HAMLIB_PARAMS((ROT *rot));
388 
389 extern HAMLIB_EXPORT(int)
390 rot_reset HAMLIB_PARAMS((ROT *rot,
391  rot_reset_t reset));
392 
393 extern HAMLIB_EXPORT(int)
394 rot_move HAMLIB_PARAMS((ROT *rot,
395  int direction,
396  int speed));
397 
398 extern HAMLIB_EXPORT(const char *)
399 rot_get_info HAMLIB_PARAMS((ROT *rot));
400 
401 extern HAMLIB_EXPORT(int)
402 rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
403 
404 extern HAMLIB_EXPORT(int)
405 rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
406 
407 extern HAMLIB_EXPORT(int)
408 rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps *,
409  rig_ptr_t),
410  rig_ptr_t data));
411 
412 extern HAMLIB_EXPORT(int)
413 rot_load_backend HAMLIB_PARAMS((const char *be_name));
414 
415 extern HAMLIB_EXPORT(int)
416 rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
417 
418 extern HAMLIB_EXPORT(int)
419 rot_load_all_backends HAMLIB_PARAMS((void));
420 
421 extern HAMLIB_EXPORT(rot_model_t)
422 rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
423 
424 extern HAMLIB_EXPORT(int)
425 rot_token_foreach HAMLIB_PARAMS((ROT *rot,
426  int (*cfunc)(const struct confparams *,
427  rig_ptr_t),
428  rig_ptr_t data));
429 
430 extern HAMLIB_EXPORT(const struct confparams *)
431 rot_confparam_lookup HAMLIB_PARAMS((ROT *rot,
432  const char *name));
433 
434 extern HAMLIB_EXPORT(token_t)
435 rot_token_lookup HAMLIB_PARAMS((ROT *rot,
436  const char *name));
437 
438 extern HAMLIB_EXPORT(const struct rot_caps *)
439 rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
440 
441 extern HAMLIB_EXPORT(int)
442 qrb HAMLIB_PARAMS((double lon1,
443  double lat1,
444  double lon2,
445  double lat2,
446  double *distance,
447  double *azimuth));
448 
449 extern HAMLIB_EXPORT(double)
450 distance_long_path HAMLIB_PARAMS((double distance));
451 
452 extern HAMLIB_EXPORT(double)
453 azimuth_long_path HAMLIB_PARAMS((double azimuth));
454 
455 extern HAMLIB_EXPORT(int)
456 longlat2locator HAMLIB_PARAMS((double longitude,
457  double latitude,
458  char *locator_res,
459  int pair_count));
460 
461 extern HAMLIB_EXPORT(int)
462 locator2longlat HAMLIB_PARAMS((double *longitude,
463  double *latitude,
464  const char *locator));
465 
466 extern HAMLIB_EXPORT(double)
467 dms2dec HAMLIB_PARAMS((int degrees,
468  int minutes,
469  double seconds,
470  int sw));
471 
472 extern HAMLIB_EXPORT(int)
473 dec2dms HAMLIB_PARAMS((double dec,
474  int *degrees,
475  int *minutes,
476  double *seconds,
477  int *sw));
478 
479 extern HAMLIB_EXPORT(int)
480 dec2dmmm HAMLIB_PARAMS((double dec,
481  int *degrees,
482  double *minutes,
483  int *sw));
484 
485 extern HAMLIB_EXPORT(double)
486 dmmm2dec HAMLIB_PARAMS((int degrees,
487  double minutes,
488  int sw));
489 
490 
500 #define rot_debug rig_debug
501 
502 __END_DECLS
503 
504 #endif /* _ROTATOR_H */
505 
azimuth_t max_az
Definition: rotator.h:249
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
int timeout
Definition: rotator.h:240
long token_t
configuration token
Definition: rig.h:590
int rot_reset_t
Type definition for rotator reset.
Definition: rotator.h:103
int retry
Definition: rotator.h:241
const struct confparams * cfgparams
Definition: rotator.h:256
const char * version
Definition: rotator.h:224
int rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation)
set the azimuth and elevation of the rotator
Definition: rotator.c:564
Definition: rotator.h:341
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:309
Definition: rotator.h:111
elevation_t max_el
Definition: rotator.h:253
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:228
Rotator data structure.
Definition: rotator.h:220
const char * mfg_name
Definition: rotator.h:223
azimuth_t min_az
Definition: rotator.h:308
int rot_move(ROT *rot, int direction, int speed)
move the rotator in the specified direction
Definition: rotator.c:773
rot_model_t rot_model
Definition: rotator.h:221
int south_zero
Definition: rotator.h:312
int serial_rate_min
Definition: rotator.h:231
Hamlib amplifier model definitions.
rig_status_e
Development status of the backend.
Definition: rig.h:280
int rot_model_t
Convenience type definition for rotator model.
Definition: rotlist.h:406
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
elevation_t el_offset
Definition: rotator.h:314
const char * model_name
Definition: rotator.h:222
const char * macro_name
Definition: rotator.h:288
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 post_write_delay
Definition: rotator.h:239
int rot_close(ROT *rot)
close the communication to the rot
Definition: rotator.c:440
int rot_get_conf(ROT *rot, token_t token, char *val)
get the value of a configuration parameter
Definition: rot_conf.c:684
elevation_t max_el
Definition: rotator.h:311
int comm_state
Definition: rotator.h:321
token_t token
Definition: rig.h:626
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:310
int write_delay
Definition: rotator.h:238
rot_type_t
Rotator type flags.
Definition: rotator.h:109
int rot_park(ROT *rot)
park the antenna
Definition: rotator.c:675
serial_parity_e
Serial parity.
Definition: rig.h:216
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
int serial_stop_bits
Definition: rotator.h:234
elevation_t min_el
Definition: rotator.h:251
Hamlib rig data structures.
const char * rot_get_info(ROT *rot)
get general information from the rotator
Definition: rotator.c:806
const char * priv
Definition: rotator.h:257
int serial_rate_max
Definition: rotator.h:232
struct rot_caps * caps
Definition: rotator.h:342
int serial_data_bits
Definition: rotator.h:233
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
enum rig_port_e port_type
Definition: rotator.h:229
int rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation)
get the azimuth and elevation of the rotator
Definition: rotator.c:624
Live data and customized fields.
Definition: rotator.h:304
int rot_stop(ROT *rot)
stop the rotator
Definition: rotator.c:708
azimuth_t az_offset
Definition: rotator.h:313
int rot_type
Definition: rotator.h:228
double dmmm2dec(int degrees, double minutes, int sw)
Convert D M.MMM notation to decimal degrees.
Definition: locator.c:196
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:742
This is the master data structure, acting as a handle for the controlled rotator. ...
Definition: rotator.h:110
struct rot_state state
Definition: rotator.h:343
Port definition.
Definition: rig.h:1655
azimuth_t min_az
Definition: rotator.h:248
int rot_cleanup(ROT *rot)
release a rot handle and free associated memory
Definition: rotator.c:519
const char * copyright
Definition: rotator.h:225
ROT * rot_init(rot_model_t rot_model)
allocate a new ROT handle
Definition: rotator.c:197
Configuration parameter structure.
Definition: rig.h:625
enum serial_parity_e serial_parity
Definition: rotator.h:235
char * obj
Definition: rotator.h:323
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:195
hamlib_port_t rotport
Definition: rotator.h:319
enum serial_handshake_e serial_handshake
Definition: rotator.h:236
enum rig_status_e status
Definition: rotator.h:226
char * priv
Definition: rotator.h:322
int rot_open(ROT *rot)
open the communication to the rot
Definition: rotator.c:318

Generated by doxygen 1.8.14

Hamlib documentation for version 4.0~git -- Sat Apr 4 2020 16:42:11
Project page: http://www.hamlib.org