00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ROTATOR_H
00024 #define _ROTATOR_H 1
00025
00026 #include <hamlib/rig.h>
00027 #include <hamlib/rotlist.h>
00028
00043 __BEGIN_DECLS
00044
00045
00046
00047 struct rot;
00048 struct rot_state;
00049
00053 typedef struct rot ROT;
00054
00055
00072 typedef float elevation_t;
00073 typedef float azimuth_t;
00074
00076 #define NETROTCTL_RET "RPRT "
00077
00082 #define ROT_RESET_ALL 1
00083
00090 typedef int rot_reset_t;
00091
00092
00099 #define ROT_FLAG_AZIMUTH (1<<1)
00100 #define ROT_FLAG_ELEVATION (1<<2)
00101
00102 #define ROT_TYPE_OTHER 0
00103
00104
00155 #define ROT_MOVE_UP (1<<1)
00156 #define ROT_MOVE_DOWN (1<<2)
00157 #define ROT_MOVE_LEFT (1<<3)
00158 #define ROT_MOVE_CCW ROT_MOVE_LEFT
00159 #define ROT_MOVE_RIGHT (1<<4)
00160 #define ROT_MOVE_CW ROT_MOVE_RIGHT
00161
00162
00163
00164
00165
00166
00167
00184 struct rot_caps {
00185 rot_model_t rot_model;
00186 const char *model_name;
00187 const char *mfg_name;
00188 const char *version;
00189 const char *copyright;
00190 enum rig_status_e status;
00192 int rot_type;
00193 enum rig_port_e port_type;
00195 int serial_rate_min;
00196 int serial_rate_max;
00197 int serial_data_bits;
00198 int serial_stop_bits;
00199 enum serial_parity_e serial_parity;
00200 enum serial_handshake_e serial_handshake;
00202 int write_delay;
00203 int post_write_delay;
00204 int timeout;
00205 int retry;
00207
00208
00209
00210
00211 azimuth_t min_az;
00212 azimuth_t max_az;
00213 elevation_t min_el;
00214 elevation_t max_el;
00217 const struct confparams *cfgparams;
00218 const rig_ptr_t priv;
00220
00221
00222
00223
00224
00225 int (*rot_init)(ROT *rot);
00226 int (*rot_cleanup)(ROT *rot);
00227 int (*rot_open)(ROT *rot);
00228 int (*rot_close)(ROT *rot);
00229
00230 int (*set_conf)(ROT *rot, token_t token, const char *val);
00231 int (*get_conf)(ROT *rot, token_t token, char *val);
00232
00233
00234
00235
00236
00237
00238 int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation);
00239 int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
00240
00241 int (*stop)(ROT *rot);
00242 int (*park)(ROT *rot);
00243 int (*reset)(ROT *rot, rot_reset_t reset);
00244 int (*move)(ROT *rot, int direction, int speed);
00245
00246
00247 const char* (*get_info)(ROT *rot);
00248
00249
00250 };
00251
00252
00264 struct rot_state {
00265
00266
00267
00268 azimuth_t min_az;
00269 azimuth_t max_az;
00270 elevation_t min_el;
00271 elevation_t max_el;
00273
00274
00275
00276 hamlib_port_t rotport;
00278 int comm_state;
00279 rig_ptr_t priv;
00280 rig_ptr_t obj;
00282
00283 };
00284
00297 struct rot {
00298 struct rot_caps *caps;
00299 struct rot_state state;
00300 };
00301
00302
00303
00304 extern HAMLIB_EXPORT(ROT *) rot_init HAMLIB_PARAMS((rot_model_t rot_model));
00305 extern HAMLIB_EXPORT(int) rot_open HAMLIB_PARAMS((ROT *rot));
00306 extern HAMLIB_EXPORT(int) rot_close HAMLIB_PARAMS((ROT *rot));
00307 extern HAMLIB_EXPORT(int) rot_cleanup HAMLIB_PARAMS((ROT *rot));
00308
00309 extern HAMLIB_EXPORT(int) rot_set_conf HAMLIB_PARAMS((ROT *rot, token_t token, const char *val));
00310 extern HAMLIB_EXPORT(int) rot_get_conf HAMLIB_PARAMS((ROT *rot, token_t token, char *val));
00311
00312
00313
00314
00315 extern HAMLIB_EXPORT(int) rot_set_position HAMLIB_PARAMS((ROT *rot, azimuth_t azimuth, elevation_t elevation));
00316 extern HAMLIB_EXPORT(int) rot_get_position HAMLIB_PARAMS((ROT *rot, azimuth_t *azimuth, elevation_t *elevation));
00317 extern HAMLIB_EXPORT(int) rot_stop HAMLIB_PARAMS((ROT *rot));
00318 extern HAMLIB_EXPORT(int) rot_park HAMLIB_PARAMS((ROT *rot));
00319 extern HAMLIB_EXPORT(int) rot_reset HAMLIB_PARAMS((ROT *rot, rot_reset_t reset));
00320 extern HAMLIB_EXPORT(int) rot_move HAMLIB_PARAMS((ROT *rot, int direction, int speed));
00321 extern HAMLIB_EXPORT(const char*) rot_get_info HAMLIB_PARAMS((ROT *rot));
00322
00323 extern HAMLIB_EXPORT(int) rot_register HAMLIB_PARAMS((const struct rot_caps *caps));
00324 extern HAMLIB_EXPORT(int) rot_unregister HAMLIB_PARAMS((rot_model_t rot_model));
00325 extern HAMLIB_EXPORT(int) rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps*, rig_ptr_t), rig_ptr_t data));
00326 extern HAMLIB_EXPORT(int) rot_load_backend HAMLIB_PARAMS((const char *be_name));
00327 extern HAMLIB_EXPORT(int) rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model));
00328 extern HAMLIB_EXPORT(int) rot_load_all_backends HAMLIB_PARAMS((void));
00329 extern HAMLIB_EXPORT(rot_model_t) rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
00330
00331 extern HAMLIB_EXPORT(int) rot_token_foreach HAMLIB_PARAMS((ROT *rot, int (*cfunc)(const struct confparams *, rig_ptr_t), rig_ptr_t data));
00332 extern HAMLIB_EXPORT(const struct confparams*) rot_confparam_lookup HAMLIB_PARAMS((ROT *rot, const char *name));
00333 extern HAMLIB_EXPORT(token_t) rot_token_lookup HAMLIB_PARAMS((ROT *rot, const char *name));
00334
00335 extern HAMLIB_EXPORT(const struct rot_caps *) rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model));
00336
00337 extern HAMLIB_EXPORT(int) qrb HAMLIB_PARAMS((double lon1, double lat1,
00338 double lon2, double lat2,
00339 double *distance, double *azimuth));
00340 extern HAMLIB_EXPORT(double) distance_long_path HAMLIB_PARAMS((double distance));
00341 extern HAMLIB_EXPORT(double) azimuth_long_path HAMLIB_PARAMS((double azimuth));
00342
00343 extern HAMLIB_EXPORT(int) longlat2locator HAMLIB_PARAMS((double longitude,
00344 double latitude, char *locator_res, int pair_count));
00345 extern HAMLIB_EXPORT(int) locator2longlat HAMLIB_PARAMS((double *longitude,
00346 double *latitude, const char *locator));
00347
00348 extern HAMLIB_EXPORT(double) dms2dec HAMLIB_PARAMS((int degrees, int minutes,
00349 double seconds, int sw));
00350 extern HAMLIB_EXPORT(int) dec2dms HAMLIB_PARAMS((double dec, int *degrees,
00351 int *minutes, double *seconds, int *sw));
00352
00353 extern HAMLIB_EXPORT(int) dec2dmmm HAMLIB_PARAMS((double dec, int *degrees,
00354 double *minutes, int *sw));
00355 extern HAMLIB_EXPORT(double) dmmm2dec HAMLIB_PARAMS((int degrees,
00356 double minutes, int sw));
00357
00366 #define rot_debug rig_debug
00367
00368 __END_DECLS
00369
00370 #endif
00371