Hamlib  3.0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
42 __BEGIN_DECLS
43 
44 /* Forward struct references */
45 
46 struct rot;
47 struct rot_state;
48 
52 typedef struct rot ROT;
53 
54 
71 typedef float elevation_t;
72 typedef float azimuth_t;
73 
75 #define NETROTCTL_RET "RPRT "
76 
81 #define ROT_RESET_ALL 1
82 
89 typedef int rot_reset_t;
90 
91 
93 typedef enum {
94  ROT_FLAG_AZIMUTH = (1<<1),
96 } rot_type_t;
97 
98 #define ROT_TYPE_MASK (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION)
99 
100 #define ROT_TYPE_OTHER 0
101 #define ROT_TYPE_AZIMUTH ROT_FLAG_AZIMUTH
102 #define ROT_TYPE_ELEVATION ROT_FLAG_ELEVATION
103 #define ROT_TYPE_AZEL (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION)
104 
105 
156 #define ROT_MOVE_UP (1<<1)
157 #define ROT_MOVE_DOWN (1<<2)
158 #define ROT_MOVE_LEFT (1<<3)
159 #define ROT_MOVE_CCW ROT_MOVE_LEFT
160 #define ROT_MOVE_RIGHT (1<<4)
161 #define ROT_MOVE_CW ROT_MOVE_RIGHT
162 
163 /* Basic rot type, can store some useful
164  * info about different rotators. Each lib must
165  * be able to populate this structure, so we can make
166  * useful enquiries about capablilities.
167  */
168 
185 struct rot_caps {
187  const char *model_name;
188  const char *mfg_name;
189  const char *version;
190  const char *copyright;
193  int rot_type;
205  int timeout;
206  int retry;
208  /*
209  * Movement range, az is relative to North
210  * negative values allowed for overlap
211  */
218  const struct confparams *cfgparams;
219  const rig_ptr_t priv;
221  /*
222  * Rot Admin API
223  *
224  */
225 
226  int (*rot_init)(ROT *rot);
227  int (*rot_cleanup)(ROT *rot);
228  int (*rot_open)(ROT *rot);
229  int (*rot_close)(ROT *rot);
230 
231  int (*set_conf)(ROT *rot, token_t token, const char *val);
232  int (*get_conf)(ROT *rot, token_t token, char *val);
233 
234  /*
235  * General API commands, from most primitive to least.. :()
236  * List Set/Get functions pairs
237  */
238 
239  int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
240  int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
241 
242  int (*stop)(ROT *rot);
243  int (*park)(ROT *rot);
244  int (*reset)(ROT *rot, rot_reset_t reset);
245  int (*move)(ROT *rot, int direction, int speed);
246 
247  /* get firmware info, etc. */
248  const char* (*get_info)(ROT *rot);
249 
250  /* more to come... */
251 };
252 
253 
265 struct rot_state {
266  /*
267  * overridable fields
268  */
274  /*
275  * non overridable fields, internal use
276  */
280  rig_ptr_t priv;
281  rig_ptr_t obj;
283  /* etc... */
284 };
285 
298 struct rot {
299  struct rot_caps *caps;
300  struct rot_state state;
301 };
302 
303 /* --------------- API function prototypes -----------------*/
304 
305 extern HAMLIB_EXPORT(ROT *) rot_init HAMLIB_PARAMS((rot_model_t rot_model));
306 extern HAMLIB_EXPORT(int) rot_open HAMLIB_PARAMS((ROT *rot));
307 extern HAMLIB_EXPORT(int) rot_close HAMLIB_PARAMS((ROT *rot));
308 extern HAMLIB_EXPORT(int) rot_cleanup HAMLIB_PARAMS((ROT *rot));
309 
310 extern HAMLIB_EXPORT(int) rot_set_conf HAMLIB_PARAMS((ROT *rot, token_t token, const char *val));
311 extern HAMLIB_EXPORT(int) rot_get_conf HAMLIB_PARAMS((ROT *rot, token_t token, char *val));
312  /*
313  * General API commands, from most primitive to least.. )
314  * List Set/Get functions pairs
315  */
316 extern HAMLIB_EXPORT(int) rot_set_position HAMLIB_PARAMS((ROT *rot, azimuth_t azimuth, elevation_t elevation));
317 extern HAMLIB_EXPORT(int) rot_get_position HAMLIB_PARAMS((ROT *rot, azimuth_t *azimuth, elevation_t *elevation));
318 extern HAMLIB_EXPORT(int) rot_stop HAMLIB_PARAMS((ROT *rot));
319 extern HAMLIB_EXPORT(int) rot_park HAMLIB_PARAMS((ROT *rot));
320 extern HAMLIB_EXPORT(int) rot_reset HAMLIB_PARAMS((ROT *rot, rot_reset_t reset));
321 extern HAMLIB_EXPORT(int) rot_move HAMLIB_PARAMS((ROT *rot, int direction, int speed));
322 extern HAMLIB_EXPORT(const char*) rot_get_info HAMLIB_PARAMS((ROT *rot));
323 
324 extern HAMLIB_EXPORT(int) rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
325 extern HAMLIB_EXPORT(int) rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
326 extern HAMLIB_EXPORT(int) rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps*, rig_ptr_t), rig_ptr_t data));
327 extern HAMLIB_EXPORT(int) rot_load_backend HAMLIB_PARAMS((const char *be_name));
328 extern HAMLIB_EXPORT(int) rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
329 extern HAMLIB_EXPORT(int) rot_load_all_backends HAMLIB_PARAMS((void));
330 extern HAMLIB_EXPORT(rot_model_t) rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
331 
332 extern HAMLIB_EXPORT(int) rot_token_foreach HAMLIB_PARAMS((ROT *rot, int (*cfunc)(const struct confparams *, rig_ptr_t), rig_ptr_t data));
333 extern HAMLIB_EXPORT(const struct confparams*) rot_confparam_lookup HAMLIB_PARAMS((ROT *rot, const char *name));
334 extern HAMLIB_EXPORT(token_t) rot_token_lookup HAMLIB_PARAMS((ROT *rot, const char *name));
335 
336 extern HAMLIB_EXPORT(const struct rot_caps *) rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
337 
338 extern HAMLIB_EXPORT(int) qrb HAMLIB_PARAMS((double lon1, double lat1,
339  double lon2, double lat2,
340  double *distance, double *azimuth));
341 extern HAMLIB_EXPORT(double) distance_long_path HAMLIB_PARAMS((double distance));
342 extern HAMLIB_EXPORT(double) azimuth_long_path HAMLIB_PARAMS((double azimuth));
343 
344 extern HAMLIB_EXPORT(int) longlat2locator HAMLIB_PARAMS((double longitude,
345  double latitude, char *locator_res, int pair_count));
346 extern HAMLIB_EXPORT(int) locator2longlat HAMLIB_PARAMS((double *longitude,
347  double *latitude, const char *locator));
348 
349 extern HAMLIB_EXPORT(double) dms2dec HAMLIB_PARAMS((int degrees, int minutes,
350  double seconds, int sw));
351 extern HAMLIB_EXPORT(int) dec2dms HAMLIB_PARAMS((double dec, int *degrees,
352  int *minutes, double *seconds, int *sw));
353 
354 extern HAMLIB_EXPORT(int) dec2dmmm HAMLIB_PARAMS((double dec, int *degrees,
355  double *minutes, int *sw));
356 extern HAMLIB_EXPORT(double) dmmm2dec HAMLIB_PARAMS((int degrees,
357  double minutes, int sw));
358 
367 #define rot_debug rig_debug
368 
369 __END_DECLS
370 
371 #endif /* _ROTATOR_H */
372 
azimuth_t max_az
Definition: rotator.h:213
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:355
struct rot_state state
Definition: rotator.h:300
int timeout
Definition: rotator.h:205
long token_t
configuration token
Definition: rig.h:501
int rot_reset_t
Type definition for rotator reset.
Definition: rotator.h:89
int retry
Definition: rotator.h:206
const struct confparams * cfgparams
Definition: rotator.h:218
const char * version
Definition: rotator.h:189
int rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation)
set the azimuth and elevation of the rotator
Definition: rotator.c:488
int dec2dmmm(double dec, int *degrees, double *minutes, int *sw)
Convert a decimal angle into D M.MMM notation.
Definition: locator.c:301
azimuth_t max_az
Definition: rotator.h:270
Definition: rotator.h:95
elevation_t max_el
Definition: rotator.h:215
int rot_set_conf(ROT *rot, token_t token, const char *val)
set a rotator configuration parameter
Definition: rot_conf.c:411
serial_handshake_e
Serial handshake.
Definition: rig.h:192
Rotator data structure.
Definition: rotator.h:185
const char * mfg_name
Definition: rotator.h:188
azimuth_t min_az
Definition: rotator.h:269
int rot_move(ROT *rot, int direction, int speed)
move the rotator in the specified direction
Definition: rotator.c:630
rot_model_t rot_model
Definition: rotator.h:186
int serial_rate_min
Definition: rotator.h:196
Hamlib rotator model definitions.
rig_status_e
Development status of the backend.
Definition: rig.h:242
int rot_model_t
Convenience type definition for rotator model.
Definition: rotlist.h:297
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:321
const char * model_name
Definition: rotator.h:187
token_t rot_token_lookup(ROT *rot, const char *name)
Simple lookup returning token id associated with name.
Definition: rot_conf.c:386
float elevation_t
Type definition for elevation.
Definition: rotator.h:71
int post_write_delay
Definition: rotator.h:204
int rot_close(ROT *rot)
close the communication to the rot
Definition: rotator.c:383
int rot_get_conf(ROT *rot, token_t token, char *val)
get the value of a configuration parameter
Definition: rot_conf.c:449
elevation_t max_el
Definition: rotator.h:272
int comm_state
Definition: rotator.h:279
token_t token
Definition: rig.h:533
double distance_long_path(double distance)
Calculate the long path distance between two points.
Definition: locator.c:571
elevation_t min_el
Definition: rotator.h:271
int write_delay
Definition: rotator.h:203
rot_type_t
Rotator type flags.
Definition: rotator.h:93
int rot_park(ROT *rot)
park the antenna
Definition: rotator.c:551
serial_parity_e
Serial parity.
Definition: rig.h:181
int longlat2locator(double longitude, double latitude, char *locator, int pair_count)
Convert longitude/latitude to Maidenhead grid locator.
Definition: locator.c:420
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:199
elevation_t min_el
Definition: rotator.h:214
Hamlib rig data structures.
const char * rot_get_info(ROT *rot)
get general information from the rotator
Definition: rotator.c:656
const char * priv
Definition: rotator.h:219
int serial_rate_max
Definition: rotator.h:197
int serial_data_bits
Definition: rotator.h:198
double azimuth_long_path(double azimuth)
Calculate the long path bearing between two points.
Definition: locator.c:588
float azimuth_t
Type definition for azimuth.
Definition: rotator.h:72
enum rig_port_e port_type
Definition: rotator.h:194
int rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation)
get the azimuth and elevation of the rotator
Definition: rotator.c:524
Live data and customized fields.
Definition: rotator.h:265
int rot_stop(ROT *rot)
stop the rotator
Definition: rotator.c:578
int rot_type
Definition: rotator.h:193
double dmmm2dec(int degrees, double minutes, int sw)
Convert D M.MMM notation to decimal degrees.
Definition: locator.c:181
int locator2longlat(double *longitude, double *latitude, const char *locator)
Convert Maidenhead grid locator to Longitude/Latitude.
Definition: locator.c:346
int rot_reset(ROT *rot, rot_reset_t reset)
reset the rotator
Definition: rotator.c:606
This is the master data structure, acting as a handle for the controlled rotator. ...
Definition: rotator.h:298
Definition: rotator.h:94
Port definition.
Definition: rig.h:1338
azimuth_t min_az
Definition: rotator.h:212
int rot_cleanup(ROT *rot)
release a rot handle and free associated memory
Definition: rotator.c:449
const char * copyright
Definition: rotator.h:190
ROT * rot_init(rot_model_t rot_model)
allocate a new ROT handle
Definition: rotator.c:177
Configuration parameter structure.
Definition: rig.h:532
enum serial_parity_e serial_parity
Definition: rotator.h:200
char * obj
Definition: rotator.h:281
int dec2dms(double dec, int *degrees, int *minutes, double *seconds, int *sw)
Convert decimal degrees angle into DMS notation.
Definition: locator.c:225
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:479
rig_port_e
Port type.
Definition: rig.h:163
struct rot_caps * caps
Definition: rotator.h:299
hamlib_port_t rotport
Definition: rotator.h:277
enum serial_handshake_e serial_handshake
Definition: rotator.h:201
enum rig_status_e status
Definition: rotator.h:191
char * priv
Definition: rotator.h:280
int rot_open(ROT *rot)
open the communication to the rot
Definition: rotator.c:289

Generated by doxygen 1.8.8

Hamlib documentation for version 3.0.1 -- Wed Jan 13 2016 15:05:23
Project page: http://www.hamlib.org