Hamlib  3.3
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 struct rot_caps {
221  const char *model_name;
222  const char *mfg_name;
223  const char *version;
224  const char *copyright;
227  int rot_type;
239  int timeout;
240  int retry;
242  /*
243  * Movement range, az is relative to North
244  * negative values allowed for overlap
245  */
254  const struct confparams *cfgparams;
255  const rig_ptr_t priv;
257  /*
258  * Rot Admin API
259  *
260  */
261 
262  int (*rot_init)(ROT *rot);
263  int (*rot_cleanup)(ROT *rot);
264  int (*rot_open)(ROT *rot);
265  int (*rot_close)(ROT *rot);
266 
267  int (*set_conf)(ROT *rot, token_t token, const char *val);
268  int (*get_conf)(ROT *rot, token_t token, char *val);
269 
270  /*
271  * General API commands, from most primitive to least.. :()
272  * List Set/Get functions pairs
273  */
274 
275  int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
276  int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
277 
278  int (*stop)(ROT *rot);
279  int (*park)(ROT *rot);
280  int (*reset)(ROT *rot, rot_reset_t reset);
281  int (*move)(ROT *rot, int direction, int speed);
282 
283  /* get firmware info, etc. */
284  const char * (*get_info)(ROT *rot);
285 
286  /* more to come... */
287 };
288 
289 
301 struct rot_state {
302  /*
303  * overridable fields
304  */
310  /*
311  * non overridable fields, internal use
312  */
316  rig_ptr_t priv;
317  rig_ptr_t obj;
319  /* etc... */
320 };
321 
322 
335 struct rot {
336  struct rot_caps *caps;
337  struct rot_state state;
338 };
339 
340 
341 /* --------------- API function prototypes -----------------*/
342 
343 extern HAMLIB_EXPORT(ROT *)
344 rot_init HAMLIB_PARAMS((rot_model_t rot_model));
345 
346 extern HAMLIB_EXPORT(int)
347 rot_open HAMLIB_PARAMS((ROT *rot));
348 
349 extern HAMLIB_EXPORT(int)
350 rot_close HAMLIB_PARAMS((ROT *rot));
351 
352 extern HAMLIB_EXPORT(int)
353 rot_cleanup HAMLIB_PARAMS((ROT *rot));
354 
355 extern HAMLIB_EXPORT(int)
356 rot_set_conf HAMLIB_PARAMS((ROT *rot,
357  token_t token,
358  const char *val));
359 extern HAMLIB_EXPORT(int)
360 rot_get_conf HAMLIB_PARAMS((ROT *rot,
361  token_t token,
362  char *val));
363 
364 /*
365  * General API commands, from most primitive to least.. )
366  * List Set/Get functions pairs
367  */
368 extern HAMLIB_EXPORT(int)
369 rot_set_position HAMLIB_PARAMS((ROT *rot,
370  azimuth_t azimuth,
371  elevation_t elevation));
372 extern HAMLIB_EXPORT(int)
373 rot_get_position HAMLIB_PARAMS((ROT *rot,
374  azimuth_t *azimuth,
375  elevation_t *elevation));
376 
377 extern HAMLIB_EXPORT(int)
378 rot_stop HAMLIB_PARAMS((ROT *rot));
379 
380 extern HAMLIB_EXPORT(int)
381 rot_park HAMLIB_PARAMS((ROT *rot));
382 
383 extern HAMLIB_EXPORT(int)
384 rot_reset HAMLIB_PARAMS((ROT *rot,
385  rot_reset_t reset));
386 
387 extern HAMLIB_EXPORT(int)
388 rot_move HAMLIB_PARAMS((ROT *rot,
389  int direction,
390  int speed));
391 
392 extern HAMLIB_EXPORT(const char *)
393 rot_get_info HAMLIB_PARAMS((ROT *rot));
394 
395 extern HAMLIB_EXPORT(int)
396 rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
397 
398 extern HAMLIB_EXPORT(int)
399 rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
400 
401 extern HAMLIB_EXPORT(int)
402 rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps *,
403  rig_ptr_t),
404  rig_ptr_t data));
405 
406 extern HAMLIB_EXPORT(int)
407 rot_load_backend HAMLIB_PARAMS((const char *be_name));
408 
409 extern HAMLIB_EXPORT(int)
410 rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
411 
412 extern HAMLIB_EXPORT(int)
413 rot_load_all_backends HAMLIB_PARAMS((void));
414 
415 extern HAMLIB_EXPORT(rot_model_t)
416 rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
417 
418 extern HAMLIB_EXPORT(int)
419 rot_token_foreach HAMLIB_PARAMS((ROT *rot,
420  int (*cfunc)(const struct confparams *,
421  rig_ptr_t),
422  rig_ptr_t data));
423 
424 extern HAMLIB_EXPORT(const struct confparams *)
425 rot_confparam_lookup HAMLIB_PARAMS((ROT *rot,
426  const char *name));
427 
428 extern HAMLIB_EXPORT(token_t)
429 rot_token_lookup HAMLIB_PARAMS((ROT *rot,
430  const char *name));
431 
432 extern HAMLIB_EXPORT(const struct rot_caps *)
433 rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
434 
435 extern HAMLIB_EXPORT(int)
436 qrb HAMLIB_PARAMS((double lon1,
437  double lat1,
438  double lon2,
439  double lat2,
440  double *distance,
441  double *azimuth));
442 
443 extern HAMLIB_EXPORT(double)
444 distance_long_path HAMLIB_PARAMS((double distance));
445 
446 extern HAMLIB_EXPORT(double)
447 azimuth_long_path HAMLIB_PARAMS((double azimuth));
448 
449 extern HAMLIB_EXPORT(int)
450 longlat2locator HAMLIB_PARAMS((double longitude,
451  double latitude,
452  char *locator_res,
453  int pair_count));
454 
455 extern HAMLIB_EXPORT(int)
456 locator2longlat HAMLIB_PARAMS((double *longitude,
457  double *latitude,
458  const char *locator));
459 
460 extern HAMLIB_EXPORT(double)
461 dms2dec HAMLIB_PARAMS((int degrees,
462  int minutes,
463  double seconds,
464  int sw));
465 
466 extern HAMLIB_EXPORT(int)
467 dec2dms HAMLIB_PARAMS((double dec,
468  int *degrees,
469  int *minutes,
470  double *seconds,
471  int *sw));
472 
473 extern HAMLIB_EXPORT(int)
474 dec2dmmm HAMLIB_PARAMS((double dec,
475  int *degrees,
476  double *minutes,
477  int *sw));
478 
479 extern HAMLIB_EXPORT(double)
480 dmmm2dec HAMLIB_PARAMS((int degrees,
481  double minutes,
482  int sw));
483 
484 
494 #define rot_debug rig_debug
495 
496 __END_DECLS
497 
498 #endif /* _ROTATOR_H */
499 
rig_port_e
rig_port_e
Port type.
Definition: rig.h:176
rot_caps::model_name
const char * model_name
Definition: rotator.h:221
hamlib_port
Port definition.
Definition: rig.h:1463
rot_get_info
const char * rot_get_info(ROT *rot)
get general information from the rotator
Definition: rotator.c:779
rot_stop
int rot_stop(ROT *rot)
stop the rotator
Definition: rotator.c:681
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:697
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:335
rig_status_e
rig_status_e
Development status of the backend.
Definition: rig.h:261
rot_caps::priv
const char * priv
Definition: rotator.h:255
rot_state::max_az
azimuth_t max_az
Definition: rotator.h:306
rot_caps::serial_rate_max
int serial_rate_max
Definition: rotator.h:231
rot_state::priv
char * priv
Definition: rotator.h:316
rot_caps::serial_data_bits
int serial_data_bits
Definition: rotator.h:232
rot_caps::port_type
enum rig_port_e port_type
Definition: rotator.h:228
rot_caps::write_delay
int write_delay
Definition: rotator.h:237
rot_reset
int rot_reset(ROT *rot, rot_reset_t reset)
reset the rotator
Definition: rotator.c:715
confparams
Configuration parameter structure.
Definition: rig.h:579
rot_caps::min_el
elevation_t min_el
Definition: rotator.h:249
rot_caps::serial_stop_bits
int serial_stop_bits
Definition: rotator.h:233
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:477
rot_caps::rot_type
int rot_type
Definition: rotator.h:227
rot_park
int rot_park(ROT *rot)
park the antenna
Definition: rotator.c:648
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:667
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:531
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:520
serial_handshake_e
serial_handshake_e
Serial handshake.
Definition: rig.h:209
rot_reset_t
int rot_reset_t
Type definition for rotator reset.
Definition: rotator.h:103
rot_caps
Rotator data structure.
Definition: rotator.h:219
rot_caps::min_az
azimuth_t min_az
Definition: rotator.h:246
rot_caps::copyright
const char * copyright
Definition: rotator.h:224
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:613
rot::state
struct rot_state state
Definition: rotator.h:337
rot_caps::serial_handshake
enum serial_handshake_e serial_handshake
Definition: rotator.h:235
rig.h
Hamlib rig data structures.
rot_state::min_az
azimuth_t min_az
Definition: rotator.h:305
rot_caps::serial_parity
enum serial_parity_e serial_parity
Definition: rotator.h:234
rot_caps::timeout
int timeout
Definition: rotator.h:239
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:308
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:565
rot_caps::status
enum rig_status_e status
Definition: rotator.h:225
longlat2locator
int longlat2locator(double longitude, double latitude, char *locator, int pair_count)
Convert longitude/latitude to Maidenhead grid locator.
Definition: locator.c:486
rot_caps::max_az
azimuth_t max_az
Definition: rotator.h:247
rot_caps::cfgparams
const struct confparams * cfgparams
Definition: rotator.h:254
rot_caps::version
const char * version
Definition: rotator.h:223
rot_move
int rot_move(ROT *rot, int direction, int speed)
move the rotator in the specified direction
Definition: rotator.c:746
rot_state::min_el
elevation_t min_el
Definition: rotator.h:307
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:240
rot_open
int rot_open(ROT *rot)
open the communication to the rot
Definition: rotator.c:319
ROT_FLAG_AZIMUTH
@ ROT_FLAG_AZIMUTH
Definition: rotator.h:110
rot_caps::max_el
elevation_t max_el
Definition: rotator.h:251
serial_parity_e
serial_parity_e
Serial parity.
Definition: rig.h:197
confparams::token
token_t token
Definition: rig.h:580
rot_state::comm_state
int comm_state
Definition: rotator.h:315
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:558
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:584
rot_model_t
int rot_model_t
Convenience type definition for rotator model.
Definition: rotlist.h:369
elevation_t
float elevation_t
Type definition for elevation.
Definition: rotator.h:67
rotlist.h
Hamlib rotator model definitions.
token_t
long token_t
configuration token
Definition: rig.h:546
rot_caps::mfg_name
const char * mfg_name
Definition: rotator.h:222
rot_state
Live data and customized fields.
Definition: rotator.h:301
rot_caps::rot_model
rot_model_t rot_model
Definition: rotator.h:220
rot::caps
struct rot_caps * caps
Definition: rotator.h:336
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:677
rot_close
int rot_close(ROT *rot)
close the communication to the rot
Definition: rotator.c:441
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:230
rot_caps::post_write_delay
int post_write_delay
Definition: rotator.h:238
rot_type_t
rot_type_t
Rotator type flags.
Definition: rotator.h:109
rot_state::obj
char * obj
Definition: rotator.h:317
rot_set_conf
int rot_set_conf(ROT *rot, token_t token, const char *val)
set a rotator configuration parameter
Definition: rot_conf.c:615
rot_state::rotport
hamlib_port_t rotport
Definition: rotator.h:313

Generated by doxygen 1.8.17

Hamlib documentation for version 3.3 -- Wed Jan 29 2020 00:00:00
Project page: http://www.hamlib.org