Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

rotator.h

Go to the documentation of this file.
00001 /*
00002  *  Hamlib Interface - Rotator API header
00003  *  Copyright (c) 2000-2005 by Stephane Fillod
00004  *
00005  *      $Id: rotator.h,v 1.13 2005/04/03 12:27:15 fillods Exp $
00006  *
00007  *   This library is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU Library General Public License as
00009  *   published by the Free Software Foundation; either version 2 of
00010  *   the License, or (at your option) any later version.
00011  *
00012  *   This program is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU Library General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU Library General Public
00018  *   License along with this library; if not, write to the Free Software
00019  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  *
00021  */
00022 
00023 #ifndef _ROTATOR_H
00024 #define _ROTATOR_H 1
00025 
00026 #include <hamlib/rig.h>
00027 #include <hamlib/rotlist.h>
00028 
00029 
00040 __BEGIN_DECLS
00041 
00042 /* Forward struct references */
00043 
00044 struct rot;
00045 struct rot_state;
00046 
00050 typedef struct rot ROT;
00051 
00052 
00069 typedef float elevation_t;
00070 typedef float azimuth_t;
00071 
00076 #define ROT_RESET_ALL   1
00077 
00084 typedef int rot_reset_t;
00085 
00086 
00093 #define ROT_FLAG_AZIMUTH                (1<<1)
00094 #define ROT_FLAG_ELEVATION              (1<<2)
00095 
00096 #define ROT_TYPE_OTHER              0
00097 
00098 
00149 #define ROT_MOVE_UP             (1<<1)
00150 #define ROT_MOVE_DOWN           (1<<2)
00151 #define ROT_MOVE_LEFT           (1<<3)
00152 #define ROT_MOVE_CCW            ROT_MOVE_LEFT
00153 #define ROT_MOVE_RIGHT          (1<<4)
00154 #define ROT_MOVE_CW             ROT_MOVE_RIGHT
00155 
00156 /* Basic rot type, can store some useful
00157  * info about different rotators. Each lib must
00158  * be able to populate this structure, so we can make
00159  * useful enquiries about capablilities.
00160  */
00161 
00178 struct rot_caps {
00179   rot_model_t rot_model;                         
00180   const char *model_name;                        
00181   const char *mfg_name;                          
00182   const char *version;                           
00183   const char *copyright;                         
00184   enum rig_status_e status;                      
00186   int rot_type;                                  
00187   enum rig_port_e port_type;                     
00189   int serial_rate_min;                           
00190   int serial_rate_max;                           
00191   int serial_data_bits;                          
00192   int serial_stop_bits;                          
00193   enum serial_parity_e serial_parity;            
00194   enum serial_handshake_e serial_handshake;      
00196   int write_delay;                               
00197   int post_write_delay;                          
00198   int timeout;                                   
00199   int retry;                                     
00201   /*
00202    * Movement range, az is relative to North
00203    * negative values allowed for overlap
00204    */
00205   azimuth_t min_az;                              
00206   azimuth_t max_az;                              
00207   elevation_t min_el;                            
00208   elevation_t max_el;                            
00211   const struct confparams *cfgparams;            
00212   const rig_ptr_t priv;                          
00214   /*
00215    * Rot Admin API
00216    *
00217    */
00218 
00219   int (*rot_init)(ROT *rot);
00220   int (*rot_cleanup)(ROT *rot);
00221   int (*rot_open)(ROT *rot);
00222   int (*rot_close)(ROT *rot);
00223 
00224   int (*set_conf)(ROT *rot, token_t token, const char *val);
00225   int (*get_conf)(ROT *rot, token_t token, char *val);
00226 
00227   /*
00228    *  General API commands, from most primitive to least.. :()
00229    *  List Set/Get functions pairs
00230    */
00231 
00232   int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
00233   int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
00234 
00235   int (*stop)(ROT *rot);
00236   int (*park)(ROT *rot);
00237   int (*reset)(ROT *rot, rot_reset_t reset);
00238   int (*move)(ROT *rot, int direction, int speed);
00239 
00240   /* get firmware info, etc. */
00241   const char* (*get_info)(ROT *rot);
00242 
00243   /* more to come... */
00244 };
00245 
00246 
00258 struct rot_state {
00259         /*
00260          * overridable fields
00261          */
00262   azimuth_t min_az;            
00263   azimuth_t max_az;            
00264   elevation_t min_el;          
00265   elevation_t max_el;          
00267         /*
00268          * non overridable fields, internal use
00269          */
00270   hamlib_port_t rotport;             
00272   int comm_state;             
00273   rig_ptr_t priv;             
00274   rig_ptr_t obj;              
00276   /* etc... */
00277 };
00278 
00291 struct rot {
00292         struct rot_caps *caps;      
00293         struct rot_state state;     
00294 };
00295 
00296 /* --------------- API function prototypes -----------------*/
00297 
00298 extern HAMLIB_EXPORT(ROT *) rot_init HAMLIB_PARAMS((rot_model_t rot_model));
00299 extern HAMLIB_EXPORT(int) rot_open HAMLIB_PARAMS((ROT *rot));
00300 extern HAMLIB_EXPORT(int) rot_close HAMLIB_PARAMS((ROT *rot));
00301 extern HAMLIB_EXPORT(int) rot_cleanup HAMLIB_PARAMS((ROT *rot));
00302 
00303 extern HAMLIB_EXPORT(int) rot_set_conf HAMLIB_PARAMS((ROT *rot, token_t token, const char *val));
00304 extern HAMLIB_EXPORT(int) rot_get_conf HAMLIB_PARAMS((ROT *rot, token_t token, char *val));
00305   /*
00306    *  General API commands, from most primitive to least.. )
00307    *  List Set/Get functions pairs
00308    */
00309 extern HAMLIB_EXPORT(int) rot_set_position HAMLIB_PARAMS((ROT *rot, azimuth_t azimuth, elevation_t elevation));
00310 extern HAMLIB_EXPORT(int) rot_get_position HAMLIB_PARAMS((ROT *rot, azimuth_t *azimuth, elevation_t *elevation));
00311 extern HAMLIB_EXPORT(int) rot_stop HAMLIB_PARAMS((ROT *rot));
00312 extern HAMLIB_EXPORT(int) rot_park HAMLIB_PARAMS((ROT *rot));
00313 extern HAMLIB_EXPORT(int) rot_reset HAMLIB_PARAMS((ROT *rot, rot_reset_t reset));
00314 extern HAMLIB_EXPORT(int) rot_move HAMLIB_PARAMS((ROT *rot, int direction, int speed));
00315 extern HAMLIB_EXPORT(const char*) rot_get_info HAMLIB_PARAMS((ROT *rot));
00316 
00317 extern HAMLIB_EXPORT(int) rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
00318 extern HAMLIB_EXPORT(int) rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
00319 extern HAMLIB_EXPORT(int) rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps*, rig_ptr_t), rig_ptr_t data));
00320 extern HAMLIB_EXPORT(int) rot_load_backend HAMLIB_PARAMS((const char *be_name));
00321 extern HAMLIB_EXPORT(int) rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
00322 extern HAMLIB_EXPORT(int) rot_load_all_backends HAMLIB_PARAMS((void));
00323 extern HAMLIB_EXPORT(rot_model_t) rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
00324 
00325 extern HAMLIB_EXPORT(int) rot_token_foreach HAMLIB_PARAMS((ROT *rot, int (*cfunc)(const struct confparams *, rig_ptr_t), rig_ptr_t data));
00326 extern HAMLIB_EXPORT(const struct confparams*) rot_confparam_lookup HAMLIB_PARAMS((ROT *rot, const char *name));
00327 extern HAMLIB_EXPORT(token_t) rot_token_lookup HAMLIB_PARAMS((ROT *rot, const char *name));
00328 
00329 extern HAMLIB_EXPORT(const struct rot_caps *) rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
00330 
00331 extern HAMLIB_EXPORT(int) qrb HAMLIB_PARAMS((double lon1, double lat1, 
00332                                                 double lon2, double lat2, 
00333                                                 double *distance, double *azimuth));
00334 extern HAMLIB_EXPORT(double) distance_long_path HAMLIB_PARAMS((double distance));
00335 extern HAMLIB_EXPORT(double) azimuth_long_path HAMLIB_PARAMS((double azimuth));
00336 
00337 extern HAMLIB_EXPORT(int) longlat2locator HAMLIB_PARAMS((double longitude,
00338                                                 double latitude, char *locator, int pair_count));
00339 extern HAMLIB_EXPORT(int) locator2longlat HAMLIB_PARAMS((double *longitude, 
00340                                                 double *latitude, const char *locator));
00341 
00342 extern HAMLIB_EXPORT(double) dms2dec HAMLIB_PARAMS((int degrees, int minutes,
00343                                                 double seconds, int sw));
00344 extern HAMLIB_EXPORT(int) dec2dms HAMLIB_PARAMS((double dec, int *degrees,
00345                                                 int *minutes, double *seconds, int *sw));
00346 
00347 extern HAMLIB_EXPORT(int) dec2dmmm HAMLIB_PARAMS((double dec, int *degrees,
00348                                                 double *minutes, int *sw));
00349 extern HAMLIB_EXPORT(double) dmmm2dec HAMLIB_PARAMS((int degrees,
00350                                                      double minutes, int sw));
00351 
00360 #define rot_debug rig_debug
00361 
00362 __END_DECLS
00363 
00364 #endif /* _ROTATOR_H */
00365 

Generated on Sat Sep 30 15:49:37 2006 for Hamlib - the C library reference by  doxygen 1.4.4