[Gpredict-svn] SF.net SVN: gpredict:[788] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <aa...@us...> - 2011-03-20 15:05:16
|
Revision: 788
http://gpredict.svn.sourceforge.net/gpredict/?rev=788&view=rev
Author: aa1vs
Date: 2011-03-20 15:05:07 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
Merged gpsd_testing branch into trunk.
Modified Paths:
--------------
trunk/ChangeLog
trunk/NEWS
trunk/configure.ac
trunk/src/config-keys.h
trunk/src/gtk-polar-view.c
trunk/src/gtk-rot-ctrl.c
trunk/src/gtk-sat-map.c
trunk/src/gtk-sat-module.c
trunk/src/gtk-sat-module.h
trunk/src/mod-mgr.c
trunk/src/predict-tools.c
trunk/src/predict-tools.h
trunk/src/qth-data.c
trunk/src/qth-data.h
trunk/src/qth-editor.c
trunk/src/sat-pref-qth-data.h
trunk/src/sat-pref-qth-editor.c
trunk/src/sat-pref-qth.c
Property Changed:
----------------
trunk/
trunk/data/satdata/scripts/convert.py
trunk/data/trsp/20439.trsp
trunk/data/trsp/20442.trsp
trunk/data/trsp/22825.trsp
trunk/data/trsp/22826.trsp
trunk/data/trsp/23439.trsp
trunk/data/trsp/24278.trsp
trunk/data/trsp/24786.trsp
trunk/data/trsp/25338.trsp
trunk/data/trsp/25397.trsp
trunk/data/trsp/25544.trsp
trunk/data/trsp/26352.trsp
trunk/data/trsp/26536.trsp
trunk/data/trsp/26871.trsp
trunk/data/trsp/26931.trsp
trunk/data/trsp/27453.trsp
trunk/data/trsp/27607.trsp
trunk/data/trsp/27844.trsp
trunk/data/trsp/27848.trsp
trunk/data/trsp/27939.trsp
trunk/data/trsp/28375.trsp
trunk/data/trsp/28650.trsp
trunk/data/trsp/28654.trsp
trunk/data/trsp/28895.trsp
trunk/data/trsp/32785.trsp
trunk/data/trsp/32787.trsp
trunk/data/trsp/32789.trsp
trunk/data/trsp/32791.trsp
trunk/data/trsp/33493.trsp
trunk/data/trsp/33498.trsp
trunk/data/trsp/33499.trsp
trunk/data/trsp/7530.trsp
trunk/src/gtk-rig-ctrl.c
trunk/src/gtk-rig-ctrl.h
trunk/src/gtk-rot-ctrl.c
trunk/src/gtk-rot-ctrl.h
Property changes on: trunk
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/gpsd_testing:728-787
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/ChangeLog 2011-03-20 15:05:07 UTC (rev 788)
@@ -1,3 +1,25 @@
+2011-03-20 Charles Suprin <hamaa1vs at gmail.com>
+
+ Merged gpsd_testing branch into trunk.
+
+2011-03-20 Charles Suprin <hamaa1vs at gmail.com>
+
+ * doc/man/gpredict.1.in
+ Update Copyright to 2011
+
+2011-03-13 Charles Suprin <hamaa1vs at gmail.com>
+
+ * data/locations.dat
+ Added more locations to locations.dat
+
+ * configure.ac
+ Changed version to 1.4svn
+
+2011-03-12 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/predict-tools.c
+ Added check for slope of elevation in find_los.
+
2011-03-01 Alexandru Csete <oz9aec at gmail.com>
* data/satdata:
@@ -2,6 +24,6 @@
Updated satellite data.
-
+
* po:
Synchronised with translations from launchpad.net
-
+
* configure.ac:
@@ -96,7 +118,115 @@
Fix bug where tle file suffix compare is case dependent.
<https://bugs.launchpad.net/bugs/706452>
+ * ChangeLog
+ * src/gtk-sat-map.c
+ * src/gtk-sat-module.c
+ * src/gtk-polar-view.c
+ Code cleanup and comments.
+ Update Changelog
+2011-01-21 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/predict-tools.c
+ Eliminate segfault if pass being returned is NULL in get_pass routines.
+
+2011-01-20 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-sat-module.c
+ Convert gps update time to seconds.
+
+2011-01-19 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-sat-module.c
+ * src/qth-data.c
+ * src/qth-data.h
+ * src/sat-pref-qth-editor.c
+ * src/sat-pref-qth.c
+ Added initial GPSD API version 5 support.
+ Added engineering gui support for GPSD.
+
+2011-01-16 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/qth-data.c
+ Added more QTH validation
+
+2011-01-14 Charles Suprin <hamaa1vs at gmail.com>
+
+ * NEWS
+ * src/config-keys.h
+ * src/gtk-polar-view.c
+ * src/gtk-rot-ctrl.c
+ * src/gtk-sat-map.c
+ * src/gtk-sat-module.c
+ * src/gtk-sat-module.h
+ * src/mod-mgr.c
+ * src/predict-tools.c
+ * src/predict-tools.h
+ * src/qth-data.c
+ * src/qth-data.h
+ * src/sat-pref-qth-data.h
+ * src/sat-pref-qth.c
+ Updated copyright information.
+ Added handling for new QTH fields into saving and loading routines.
+ Updated qth preference guis. (Still not complete)
+ Conditioned gpsd calls on GPSD_API_MAJOR_VERSION as requested in libgps man page.
+ Update NEWS and Changelog in anticipation of merge with trunk.
+ Corrected minor typos in comments.
+
+2011-01-11 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-rot-ctrl.c
+ Add support for changing qth to gtk-rot-ctrl.c to update pass in polar view
+
+2011-01-09 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-polar-view.c
+ * src/gtk-sat-module.c
+ * src/gtk-sat-module.h
+ Add position based updates for sky-at-a-glance.
+ Move qth updates so they occur all the time.
+
+2011-01-08 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-polar-view.c
+ * src/predict-tools.c
+ * src/predict-tools.h
+ * src/qth-data.c
+ * src/gtk-sat-map.c
+ * src/gtk-sat-module.c
+ * src/gtk-sat-module.h
+ * src/qth-data.h
+ Make gpsd code safer for multiple modules.
+ Add position comparison for event updates.
+ Fix segfault when gpsd not connected.
+ Make gtk-polar-view update pass if qth has moved significantly.
+ Add qth_small_t element to pass to check if pass data is old.
+
+2011-01-05 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-sat-module.c
+ * src/qth-data.c
+ * src/qth-data.h
+ Update AOS information when qth changes and make distinction between qth_data and qth_data_update in function names
+
+ 2011-01-02 Charles Suprin <hamaa1vs at gmail.com>
+ * configure.ac
+ * src/config-keys.h
+ * src/gtk-sat-module.c
+ * src/gtk-sat-module.h
+ * src/qth-data.c
+ * src/qth-data.h
+ * src/sat-pref-qth-editor.c
+ Second version of qpsd qth moved things into qth-data.c and started working on the qth editing gui to support these new interfaces
+
+2010-12-30 Charles Suprin <hamaa1vs at gmail.com>
+
+ * configure.ac
+ * src/gtk-sat-map.c
+ * src/gtk-sat-module.c
+ * src/gtk-sat-module.h
+ Initial GPSD hack.
+
2010-12-26 Charles Suprin <hamaa1vs at gmail.com>
* src/gtk-rot-ctrl.c
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/NEWS 2011-03-20 15:05:07 UTC (rev 788)
@@ -1,3 +1,7 @@
+Changes in version 1.4 (TBD)
+
+- Feature request 3141555: gpsd support.
+
Changes in version 1.3 (1 Mar 2011)
- Feature request 2873824: Flip Passes.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/configure.ac 2011-03-20 15:05:07 UTC (rev 788)
@@ -29,7 +29,18 @@
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)
+dnl optional check for libgps
+PKG_CHECK_MODULES(LIBGPS, [ libgps >= 2.90 ], [
+ CFLAGS="$CFLAGS $LIBGPS_CFLAGS";
+ LIBS="$LIBS $LIBGPS_LIBS";
+ havelibgps=true;
+ AC_DEFINE(HAS_LIBGPS, 1, [Define if libgps is available])
+ ], [
+ havelibgps=false;
+ AC_DEFINE(HAS_LIBGPS, 0, [Define if libgps is unvailable])
+])
+
dnl Hamlib not needed if we go for the TCP based I/F
dnl check for hamlib
dnl PKG_CHECK_MODULES(HAMLIB, hamlib, [
@@ -75,6 +86,9 @@
GTK_V=`pkg-config --modversion gtk+-2.0`
GOOC_V=`pkg-config --modversion goocanvas`
CURL_V=`pkg-config --modversion libcurl`
+if test "$havelibgps" = true ; then
+ GPS_V=`pkg-config --modversion libgps`
+fi
dnl SQL_V=`pkg-config --modversion sqlite3`
dnl if test "$havehamlib" = true ; then
dnl HAML_V=`pkg-config --modversion hamlib`
@@ -113,7 +127,10 @@
echo Gdk version........ : $GDK_V
echo Gtk+ version....... : $GTK_V
echo GooCanvas version.. : $GOOC_V
-echo Liburl version..... : $CURL_V
+echo Libcurl version..... : $CURL_V
+if test "$havelibgps" = true ; then
+ echo Libgps version..... : $GPS_V
+fi
dnl echo SQLite version..... : $SQL_V
dnl if test "$havehamlib" = true ; then
dnl echo Hamlib version..... : $HAML_V
Property changes on: trunk/data/satdata/scripts/convert.py
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/20439.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/20442.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/22825.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/22826.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/23439.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/24278.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/24786.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/25338.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/25397.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/25544.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/26352.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/26536.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/26871.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/26931.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/27453.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/27607.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/27844.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/27848.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/27939.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/28375.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/28650.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/28654.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/28895.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/32785.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/32787.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/32789.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/32791.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/33493.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/33498.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/33499.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/data/trsp/7530.trsp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Modified: trunk/src/config-keys.h
===================================================================
--- trunk/src/config-keys.h 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/config-keys.h 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -56,8 +57,10 @@
#define QTH_CFG_LAT_KEY "LAT"
#define QTH_CFG_LON_KEY "LON"
#define QTH_CFG_ALT_KEY "ALT"
+#define QTH_CFG_GPSD_SERVER_KEY "GPSDSERVER"
+#define QTH_CFG_GPSD_PORT_KEY "GPSDPORT"
+#define QTH_CFG_TYPE_KEY "QTH_TYPE"
-
/* Module files (.mod) */
/* global */
Modified: trunk/src/gtk-polar-view.c
===================================================================
--- trunk/src/gtk-polar-view.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/gtk-polar-view.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -685,6 +686,7 @@
}
/* check refresh rate and refresh sats if time */
+ /* FIXME need to add location based update*/
if (polv->counter < polv->refresh) {
polv->counter++;
}
@@ -846,6 +848,7 @@
/* free pass info */
free_pass (obj->pass);
+ obj->pass=NULL;
/* if this was the selected satellite we need to
clear the info text
@@ -914,8 +917,42 @@
g_free (text);
}
+ /*check if pass was computed near current qth otherwise update*/
+ if (obj->pass) {
+ /* FIXME once again threshold should be user configurable*/
+ if (qth_small_dist(polv->qth,(obj->pass->qth_comp))>1.0){
+
+ root = goo_canvas_get_root_item_model (GOO_CANVAS (polv->canvas));
+ /* remove sky track */
+ if (obj->showtrack) {
+ idx = goo_canvas_item_model_find_child (root, obj->track);
+ if (idx != -1)
+ goo_canvas_item_model_remove_child (root, idx);
+
+ for (i = 0; i < TRACK_TICK_NUM; i++) {
+ idx = goo_canvas_item_model_find_child (root, obj->trtick[i]);
+ if (idx != -1)
+ goo_canvas_item_model_remove_child (root, idx);
+ }
+ }
+
+ /* free pass info */
+ free_pass (obj->pass);
+ obj->pass=NULL;
+
+ /*compute new pass */
+ obj->pass = get_current_pass (sat, polv->qth, now);
+
+ /* Finally, create the sky track if necessary */
+ if (obj->showtrack)
+ create_track (polv, obj, sat);
+
+ }
+ }
g_free (losstr);
g_free (catnum); // FIXME: why free here, what about else?
+
+
}
else {
/* add sat to canvas */
Property changes on: trunk/src/gtk-rig-ctrl.c
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/continuous_network/src/gtk-rig-ctrl.c:655-689
+ /branches/continuous_network/src/gtk-rig-ctrl.c:655-689
/branches/gpsd_testing/src/gtk-rig-ctrl.c:728-787
Property changes on: trunk/src/gtk-rig-ctrl.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/continuous_network/src/gtk-rig-ctrl.h:655-689
+ /branches/continuous_network/src/gtk-rig-ctrl.h:655-689
/branches/gpsd_testing/src/gtk-rig-ctrl.h:728-787
Modified: trunk/src/gtk-rot-ctrl.c
===================================================================
--- trunk/src/gtk-rot-ctrl.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/gtk-rot-ctrl.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2010 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -303,8 +304,20 @@
g_free (buff);
update_count_down (ctrl, t);
+
+ /*if the current pass is too far away*/
+ if ((ctrl->pass!=NULL)&& (ctrl->qth!=NULL))
+ if (qth_small_dist(ctrl->qth,ctrl->pass->qth_comp)>1.0){
+ free_pass (ctrl->pass);
+ ctrl->pass=NULL;
+ ctrl->pass = get_pass (ctrl->target, ctrl->qth, t, 3.0);
+ if (ctrl->pass) {
+ set_flipped_pass(ctrl);
+ /* update polar plot */
+ gtk_polar_plot_set_pass (GTK_POLAR_PLOT (ctrl->plot), ctrl->pass);
+ }
+ }
-
/* update next pass if necessary */
if (ctrl->pass != NULL) {
/*if we are not in the current pass*/
@@ -977,14 +990,12 @@
/* otherwise look 20 minutes into the future*/
time_delta=1.0/72.0;
}
+
/* have a minimum time delta*/
- if (time_delta<(ctrl->delay/1000.0/secday)){
- time_delta=ctrl->delay/1000.0/secday;
+ step_size = time_delta / 2.0;
+ if (step_size<ctrl->delay/1000.0/(secday)){
+ step_size=ctrl->delay/1000.0/(secday);
}
-
-
- step_size = time_delta / 2.0;
-
/*
find a time when satellite is above horizon and at the
edge of tolerance. the final step size needs to be smaller
@@ -1024,6 +1035,7 @@
setaz = sat->az;
}
}
+
/* send controller values to rotator device */
/* this is the newly computed value which should be ahead of the current position */
if (!set_pos (ctrl, setaz, setel)) {
Property changes on: trunk/src/gtk-rot-ctrl.c
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/continuous_network/src/gtk-rot-ctrl.c:655-689
+ /branches/continuous_network/src/gtk-rot-ctrl.c:655-689
/branches/gpsd_testing/src/gtk-rot-ctrl.c:728-787
Property changes on: trunk/src/gtk-rot-ctrl.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/continuous_network/src/gtk-rot-ctrl.h:655-689
+ /branches/continuous_network/src/gtk-rot-ctrl.h:655-689
/branches/gpsd_testing/src/gtk-rot-ctrl.h:728-787
Modified: trunk/src/gtk-sat-map.c
===================================================================
--- trunk/src/gtk-sat-map.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/gtk-sat-map.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -4,9 +4,11 @@
Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
Copyright (C) 2006-2007 William J Beksi, KC2EXL.
+ Copyright (C) 2011 Charles Suprin, AA1VS.
Authors: Alexandru Csete <oz...@gm...>
William J Beksi <wj...@us...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -608,12 +610,44 @@
gint *catnr;
guint h, m, s;
gchar *ch, *cm, *cs;
+ gfloat x,y;
+ gdouble oldx,oldy;
+
/* check whether there are any pending resize requests */
if (satmap->resize)
update_map_size (satmap);
- /* check refresh rate and refresh sats if time */
+ /* check if qth has moved significantly if so move it*/
+ lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y);
+ g_object_get (satmap->qthmark,
+ "x", &oldx,
+ "y", &oldy,
+ NULL);
+
+ if ((fabs (oldx-x) >= 2*MARKER_SIZE_HALF) ||
+ (fabs (oldy-y) >= 2*MARKER_SIZE_HALF)) {
+
+ /* update qth mark */
+ g_object_set (satmap->qthmark,
+ "x", x - MARKER_SIZE_HALF,
+ "y", y - MARKER_SIZE_HALF,
+ NULL);
+ g_object_set (satmap->qthlabel,
+ "x", x,
+ "y", y+2,
+ NULL);
+
+ /* QTH info */
+ g_object_set (satmap->locnam,
+ "x", (gdouble) satmap->x0 + 2,
+ "y", (gdouble) satmap->y0 + 1,
+ NULL);
+ satmap->counter=satmap->refresh;
+ }
+
+ /* check refresh rate and refresh sats/qth if time */
+ /* FIXME add location check*/
if (satmap->counter < satmap->refresh) {
satmap->counter++;
}
@@ -622,6 +656,25 @@
satmap->counter = 1;
satmap->naos = 2458849.5;
+ /* QTH */
+ /*update for accuracy*/
+ lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y);
+ g_object_set (satmap->qthmark,
+ "x", x - MARKER_SIZE_HALF,
+ "y", y - MARKER_SIZE_HALF,
+ NULL);
+ g_object_set (satmap->qthlabel,
+ "x", x,
+ "y", y+2,
+ NULL);
+
+ /* QTH info */
+ g_object_set (satmap->locnam,
+ "x", (gdouble) satmap->x0 + 2,
+ "y", (gdouble) satmap->y0 + 1,
+ NULL);
+
+
/* update sats */
g_hash_table_foreach (satmap->sats, update_sat, satmap);
Modified: trunk/src/gtk-sat-module.c
===================================================================
--- trunk/src/gtk-sat-module.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/gtk-sat-module.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -4,7 +4,9 @@
Copyright (C) 2001-2010 Alexandru Csete, OZ9AEC.
+
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -159,9 +161,7 @@
module->win = NULL;
module->qth = g_try_new0 (qth_t, 1);
- module->qth->lat = 0.0;
- module->qth->lon = 0.0;
- module->qth->alt = 0;
+ qth_init(module->qth);
module->satellites = g_hash_table_new_full (g_int_hash,
g_int_equal,
@@ -179,6 +179,10 @@
module->state = GTK_SAT_MOD_STATE_DOCKED;
module->busy = g_mutex_new();
+ /* open the gpsd device */
+ module->gps_data = NULL;
+
+
module->grid = NULL;
module->views = NULL;
module->nviews = 0;
@@ -282,16 +286,18 @@
/* load configuration; note that this will also set the module name */
gtk_sat_module_read_cfg_data (GTK_SAT_MODULE (widget), cfgfile);
-
- /*check that we loaded some reasonable data*/
- if (GTK_SAT_MODULE(widget)->cfgdata==NULL){
- sat_log_log (SAT_LOG_LEVEL_ERROR,
+
+ /*check that we loaded some reasonable data*/
+ if (GTK_SAT_MODULE(widget)->cfgdata==NULL){
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
_("%s: Module %s has problems."),
__FUNCTION__, cfgfile);
-
+
return NULL;
- }
-
+ }
+ /*initialize the qth engine and get position*/
+ qth_data_update_init(GTK_SAT_MODULE(widget)->qth);
+
/* module state */
if ((g_key_file_has_key (GTK_SAT_MODULE (widget)->cfgdata,
MOD_CFG_GLOBAL_SECTION,
@@ -564,11 +570,7 @@
__FUNCTION__, buffer);
/* settings are really screwed up; we need some safe values here */
- module->qth->name = g_strdup (_("Error"));
- module->qth->loc = g_strdup (_("Error"));
- module->qth->lat = 0.0;
- module->qth->lon = 0.0;
- module->qth->alt = 0;
+ qth_safe(module->qth);
}
}
@@ -748,8 +750,9 @@
GdkWindowState state;
gdouble delta;
guint i;
+ /*update the qth position*/
+ qth_data_update(mod->qth,mod->tmgCdnum);
-
/* in docked state, update only if tab is visible */
switch (mod->state) {
@@ -773,19 +776,19 @@
}
if (needupdate) {
-
- if (g_mutex_trylock(mod->busy)==FALSE) {
-
- sat_log_log (SAT_LOG_LEVEL_WARN,
- _("%s: Previous cycle missed it's deadline."),
- __FUNCTION__);
-
- return TRUE;
-
- }
-
+
+ if (g_mutex_trylock(mod->busy)==FALSE) {
+
+ sat_log_log (SAT_LOG_LEVEL_WARN,
+ _("%s: Previous cycle missed it's deadline."),
+ __FUNCTION__);
+
+ return TRUE;
+
+ }
+
mod->rtNow = get_current_daynum ();
-
+
/* Update time if throttle != 0 */
if (mod->throttle) {
@@ -799,7 +802,7 @@
/* time to update header? */
mod->head_count++;
- if (mod->head_count == mod->head_timeout) {
+ if (mod->head_count >= mod->head_timeout) {
/* reset counter */
mod->head_count = 0;
@@ -815,7 +818,19 @@
*/
mod->event_count = 0;
}
-
+ /*only trigger an update if adequate movement has occurred*/
+ /*FIXME position threshhold should be configurable*/
+ if (qth_small_dist(mod->qth,mod->qth_event)>1.0) {
+ /* reset counter, this will make gtk_sat_module_update_sat
+ recalculate events
+ */
+ mod->event_count = 0;
+ }
+
+ /*if the events are going to be recalculated store the position*/
+ if (mod->event_count == 0){
+ qth_small_save(mod->qth,&(mod->qth_event));
+ }
/* update satellite data */
g_hash_table_foreach (mod->satellites,
gtk_sat_module_update_sat,
@@ -939,6 +954,7 @@
sat = SAT(val);
module = GTK_SAT_MODULE (data);
+
/* get current time (real or simulated */
@@ -965,7 +981,7 @@
}
- /*** FIXME: we don't need to do this every time! */
+ /*data may have been updated by gpsd*/
obs_geodetic.lon = module->qth->lon * de2ra;
obs_geodetic.lat = module->qth->lat * de2ra;
obs_geodetic.alt = module->qth->alt / 1000.0;
@@ -1029,7 +1045,7 @@
/** \brief Module options
*
* Invoke module-wide popup menu
- */
+ */
static void
gtk_sat_module_popup_cb (GtkWidget *button, gpointer data)
{
@@ -1334,9 +1350,9 @@
time_t t;
guint size;
gchar buff[TIME_FORMAT_MAX_LENGTH+1];
+ gchar *buff2;
-
t = (module->tmgCdnum - 2440587.5)*86400.;
fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT);
@@ -1351,8 +1367,17 @@
buff[size]='\0';
else
buff[TIME_FORMAT_MAX_LENGTH]='\0';
+
+ if (module->qth->type==QTH_GPSD_TYPE) {
+ buff2=g_strdup_printf("%s GPS %0.3f seconds old", buff,fabs(module->tmgCdnum-module->qth->gpsd_update)*(24*3600));
+ gtk_label_set_text (GTK_LABEL (module->header), buff2);
+ g_free(buff2);
+ }
+ else
+ gtk_label_set_text (GTK_LABEL (module->header), buff);
+
- gtk_label_set_text (GTK_LABEL (module->header), buff);
+
g_free (fmtstr);
if (module->tmgActive)
@@ -1487,8 +1512,12 @@
/** \brief Update GtkSkyGlance view
* \param module Pointer to the GtkSatModule widget
*
- * This function checks how long ago the GtkSkyGlance widget has been updated
- * and performs an update if necessary. The current timeout is set to 60 sec.
+ * This function checks to see if the sky-at-a-glance display needs to be updated
+ * due to time or qth moving. It checks how long ago the GtkSkyGlance widget was
+ * updated and performs an update if necessary. The current timeout is set to 60 sec.
+ * It also checks how far away the qth is from where the GtkSkyGlance
+ * widget was last updated and triggers an update if necessary. The current
+ * distance is set to 1km.
*
* This is a cheap/lazy implementation of automatic update. Instead of
* performing a real update by "moving" the objects on the GtkSkyGlance canvas,
@@ -1501,9 +1530,18 @@
*/
static void update_skg (GtkSatModule *module)
{
-
+ gboolean update_needed=FALSE;
/* threshold is ~60 seconds */
- if G_UNLIKELY(fabs(module->tmgCdnum - module->lastSkgUpd) > 7.0e-4) {
+ if (G_UNLIKELY(fabs(module->tmgCdnum - module->lastSkgUpd) > 7.0e-4)) {
+ update_needed=TRUE;
+ }
+ /* threshold is 1km */
+ if (G_UNLIKELY(qth_small_dist(module->qth, module->lastSkgUpdqth) >1.0)) {
+ update_needed=TRUE;
+ }
+
+
+ if (G_UNLIKELY(update_needed==TRUE)) {
sat_log_log (SAT_LOG_LEVEL_MSG,
_("%s: Updating GtkSkyGlance for %s"),
@@ -1515,5 +1553,6 @@
gtk_widget_show_all (module->skg);
module->lastSkgUpd = module->tmgCdnum;
+ qth_small_save(module->qth,&(module->lastSkgUpdqth));
}
}
Modified: trunk/src/gtk-sat-module.h
===================================================================
--- trunk/src/gtk-sat-module.h 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/gtk-sat-module.h 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2010 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -103,6 +104,7 @@
GtkWidget *skgwin; /*!< Sky at glance window */
GtkWidget *skg; /*!< Sky at glance widget */
gdouble lastSkgUpd; /*!< Daynum of last GtkSkyGlance update */
+ qth_small_t lastSkgUpdqth; /*!< QTH information for last GtkSkyGlance update. */
GtkWidget *header;
guint head_count;
@@ -117,7 +119,7 @@
GKeyFile *cfgdata; /*!< Configuration data. */
qth_t *qth; /*!< QTH information. */
-
+ qth_small_t qth_event; /*!< QTH information for last AOS/LOS update. */
GHashTable *satellites; /*!< Satellites. */
guint32 timeout; /*!< Timeout value [msec] */
@@ -152,6 +154,9 @@
GtkWidget *tmgState; /*!< Status label indicating RT/SRT/MAN */
gboolean reset; /*!< Flag indicating whether time reset is in progress */
+
+ /* location structure */
+ struct gps_data_t* gps_data; /*!< GPSD data structure */
};
struct _GtkSatModuleClass
Modified: trunk/src/mod-mgr.c
===================================================================
--- trunk/src/mod-mgr.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/mod-mgr.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -82,7 +83,7 @@
static void create_module_window (GtkWidget *module);
-/** \brief Create and initialise module manger.
+/** \brief Create and initialise module manager.
* \return The main module container widget (GtkNotebook).
*
* This function creates and initialises the module manager widget, which
@@ -209,13 +210,13 @@
/* send message to logger */
sat_log_log (SAT_LOG_LEVEL_MSG,
- _("%s: Added %s to module manger (page %d)."),
+ _("%s: Added %s to module manager (page %d)."),
__FUNCTION__, GTK_SAT_MODULE (module)->name, page);
}
else {
/* send message to logger */
sat_log_log (SAT_LOG_LEVEL_MSG,
- _("%s: Added %s to module manger (NOT DOCKED)."),
+ _("%s: Added %s to module manager (NOT DOCKED)."),
__FUNCTION__, GTK_SAT_MODULE (module)->name);
}
retcode = 0;
Modified: trunk/src/predict-tools.c
===================================================================
--- trunk/src/predict-tools.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/predict-tools.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,11 +2,12 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Parts are Copyright John A. Magliacane, KD2BD 1991-2003 (indicated below)
Authors: Alexandru Csete <oz...@gm...>
John A. Magliacane, KD2BD.
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -524,6 +525,8 @@
pass->vis[3] = 0;
pass->satname = g_strdup (sat->nickname);
pass->details = NULL;
+ /*copy qth data into the pass for later comparisons*/
+ qth_small_save(qth,&(pass->qth_comp));
/* iterate over each time step */
for (t = pass->aos; t <= pass->los; t += step) {
@@ -617,7 +620,7 @@
iter++;
}
}
-
+
return pass;
}
@@ -954,6 +957,8 @@
pass->vis[3] = 0;
pass->satname = g_strdup (sat->nickname);
pass->details = NULL;
+ /*copy qth data into the pass for later comparisons*/
+ qth_small_save(qth,&(pass->qth_comp));
/* iterate over each time step */
for (t = pass->aos; t <= pass->los; t += step) {
@@ -1034,7 +1039,7 @@
pass->tca = tca;
}
-
+
return pass;
}
Modified: trunk/src/predict-tools.h
===================================================================
--- trunk/src/predict-tools.h 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/predict-tools.h 2011-03-20 15:05:07 UTC (rev 788)
@@ -5,6 +5,7 @@
Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -49,6 +50,7 @@
gdouble maxel_az; /*!< Azimuth at maximum elevation */
gchar vis[4]; /*!< Visibility string, e.g. VSE, -S-, V-- */
GSList *details; /*!< List of pass_detail_t entries */
+ qth_small_t qth_comp; /*!< Short version of qth at time computed */
} pass_t;
Modified: trunk/src/qth-data.c
===================================================================
--- trunk/src/qth-data.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/qth-data.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -28,17 +29,24 @@
#include <glib.h>
#include <glib/gi18n.h>
+#ifdef HAVE_CONFIG_H
+# include <build-config.h>
+#endif
+
#include "sgpsdp/sgp4sdp4.h"
#include "qth-data.h"
#include "sat-log.h"
#include "config-keys.h"
-#ifdef HAVE_CONFIG_H
-# include <build-config.h>
-#endif
#include "orbit-tools.h"
#include "time-tools.h"
+#include "locator.h"
+#if HAS_LIBGPS
+#include <gps.h>
+#endif
+void qth_validate(qth_t*qth);
+
/** \brief Read QTH data from file.
* \param filename The file to read from.
* \param qth Pointer to a qth_t data structure where the data will be stored.
@@ -202,6 +210,55 @@
else {
}
+
+ /* QTH Type */
+ qth->type = g_key_file_get_integer (qth->data,
+ QTH_CFG_MAIN_SECTION,
+ QTH_CFG_TYPE_KEY,
+ &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading QTH type (%s)."),
+ __FUNCTION__, error->message);
+
+ g_clear_error (&error);
+
+
+ qth->type = QTH_STATIC_TYPE;
+ }
+
+ /*GPSD Port*/
+ qth->gpsd_port = g_key_file_get_integer (qth->data,
+ QTH_CFG_MAIN_SECTION,
+ QTH_CFG_GPSD_PORT_KEY,
+ &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading QTH type (%s)."),
+ __FUNCTION__, error->message);
+
+ g_clear_error (&error);
+
+ /*if not set put it on the default port*/
+ qth->gpsd_port = 2947;
+ }
+
+ /* GPSD Server */
+ qth->gpsd_server = g_key_file_get_string (qth->data,
+ QTH_CFG_MAIN_SECTION,
+ QTH_CFG_GPSD_SERVER_KEY,
+ &error);
+ if ((qth->gpsd_server == NULL) || (error != NULL)) {
+ sat_log_log (SAT_LOG_LEVEL_MSG,
+ _("%s: QTH has no GPSD Server."),
+ __FUNCTION__);
+
+ qth->gpsd_server = g_strdup ("");
+ g_clear_error (&error);
+ }
+
+ qth_validate(qth);
+
/* Now, send debug message and return */
sat_log_log (SAT_LOG_LEVEL_MSG,
_("%s: QTH data: %s, %.4f, %.4f, %d"),
@@ -291,6 +348,25 @@
qth->wx);
}
+ /* qth type */
+ /* static, gpsd...*/
+ g_key_file_set_integer (qth->data,
+ QTH_CFG_MAIN_SECTION,
+ QTH_CFG_TYPE_KEY,
+ qth->type);
+ /* gpsd server */
+ if (qth->gpsd_server && (g_utf8_strlen (qth->gpsd_server, -1) > 0)) {
+ g_key_file_set_string (qth->data,
+ QTH_CFG_MAIN_SECTION,
+ QTH_CFG_GPSD_SERVER_KEY,
+ qth->gpsd_server);
+ }
+ /*gpsd port*/
+ g_key_file_set_integer (qth->data,
+ QTH_CFG_MAIN_SECTION,
+ QTH_CFG_GPSD_PORT_KEY,
+ qth->gpsd_port);
+
/* saving code */
/* convert configuration data struct to charachter string */
@@ -366,6 +442,9 @@
void
qth_data_free (qth_t *qth)
{
+ /*stop any updating*/
+ qth_data_update_stop(qth);
+
if (qth->name) {
g_free (qth->name);
qth->name = NULL;
@@ -399,3 +478,361 @@
g_free (qth);
}
+/** \brief Update the qth data by whatever method is appropriate.
+ * \param qth the qth data structure to update
+ * \param qth the time at which the qth is to be computed. this may be ignored by gps updates.
+ */
+gboolean qth_data_update(qth_t * qth, gdouble t) {
+ gboolean retval = FALSE;
+ guint num_loops=0;
+ switch (qth->type) {
+ case QTH_STATIC_TYPE:
+ /*never changes*/
+ break;
+ case QTH_GPSD_TYPE:
+ if (((t-qth->gpsd_update)>30.0/86400.0)&&(t-qth->gpsd_connected>30.0/86400.0)){
+ /*if needed restart the gpsd interface*/
+ qth_data_update_stop(qth);
+ qth_data_update_init(qth);
+ qth->gpsd_connected=t;
+
+ }
+
+ if (qth->gps_data!=NULL) {
+#if HAS_LIBGPS
+ switch (GPSD_API_MAJOR_VERSION){
+ case 4:
+#if GPSD_API_MAJOR_VERSION==4
+ while(gps_waiting(qth->gps_data) == TRUE) {
+ /* this is a watchdog in case there is a problem with the gpsd code.*/
+ /* if the server was up and has failed then gps_waiting in 2.92 confirmed */
+ /* will return 1 (supposedly fixed in later versions.)*/
+ /* if we do not do this as a while loop, the gpsd packets can backup */
+ /* and no longer be in sync with the gps receiver*/
+ num_loops++;
+ if (num_loops>1000){
+ retval=FALSE;
+ break;
+ }
+ if(gps_poll(qth->gps_data) == 0){
+ /*handling packet_set inline with
+ http://gpsd.berlios.de/client-howto.html
+ */
+ if (qth->gps_data->set&PACKET_SET) {
+ if (qth->gps_data->fix.mode >= MODE_2D) {
+ if (qth->lat != qth->gps_data->fix.latitude) {
+ qth->lat = qth->gps_data->fix.latitude;
+ retval = TRUE;
+ }
+ if (qth->lon!=qth->gps_data->fix.longitude) {
+ qth->lon = qth->gps_data->fix.longitude;
+ retval = TRUE;
+ }
+ }
+
+ if (qth->gps_data->fix.mode == MODE_3D) {
+ if (qth->alt != qth->gps_data->fix.altitude) {
+ qth->alt = qth->gps_data->fix.altitude;
+ retval = TRUE;
+ }
+ } else {
+ if (qth->alt != 0) {
+ qth->alt = 0;
+ retval = TRUE;
+ }
+ }
+ }
+ }
+ }
+#endif
+ break;
+ case 5:
+#if GPSD_API_MAJOR_VERSION==5
+ while(gps_waiting(qth->gps_data) == 1) {
+ /*see comment from above*/
+ /*hopefully not needed but does not hurt anything.*/
+ num_loops++;
+ if (num_loops>1000){
+ retval=FALSE;
+ break;
+ }
+ if(gps_read(qth->gps_data) == 0){
+ /*handling packet_set inline with
+ http://gpsd.berlios.de/client-howto.html
+ */
+ if (qth->gps_data->set&PACKET_SET) {
+ if (qth->gps_data->fix.mode >= MODE_2D) {
+ if (qth->lat != qth->gps_data->fix.latitude) {
+ qth->lat = qth->gps_data->fix.latitude;
+ retval = TRUE;
+ }
+ if (qth->lon!=qth->gps_data->fix.longitude) {
+ qth->lon = qth->gps_data->fix.longitude;
+ retval = TRUE;
+ }
+ }
+
+ if (qth->gps_data->fix.mode == MODE_3D) {
+ if (qth->alt != qth->gps_data->fix.altitude) {
+ qth->alt = qth->gps_data->fix.altitude;
+ retval = TRUE;
+ }
+ } else {
+ if (qth->alt != 0) {
+ qth->alt = 0;
+ retval = TRUE;
+ }
+ }
+ }
+ }
+ }
+#endif
+ break;
+ default:
+ break;
+ }
+#endif
+ if (retval == TRUE){
+ qth->gpsd_update = t;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ /*check that data is valid*/
+ qth_validate(qth);
+ return retval;
+}
+
+/** \brief Initialize whatever structures inside the qth_t stucture for later updates.
+ * \param qth the qth data structure to update
+ *
+ *Initial intention of this is to open sockets and ports to gpsd
+ *and other like services to update the qth position.
+ */
+gboolean qth_data_update_init(qth_t * qth) {
+ char *port;
+ gboolean retval=FALSE;
+
+ switch (qth->type){
+
+ case QTH_STATIC_TYPE:
+ /*nothing to do. the data never updates*/
+ break;
+ case QTH_GPSD_TYPE:
+#if HAS_LIBGPS
+ switch (GPSD_API_MAJOR_VERSION) {
+ case 4:
+#if GPSD_API_MAJOR_VERSION==4
+ /* open the connection to gpsd and start the stream */
+ qth->gps_data = g_try_new0(struct gps_data_t,1);
+ port=g_strdup_printf("%d",qth->gpsd_port);
+ if (gps_open_r(qth->gpsd_server,port,qth->gps_data)==-1) {
+ free(qth->gps_data);
+ qth->gps_data = NULL;
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Could not open gpsd at %s:%d"),
+ __FUNCTION__, qth->gpsd_server, qth->gpsd_port);
+ retval = FALSE;
+ } else {
+ (void)gps_stream(qth->gps_data, WATCH_ENABLE, NULL);
+ retval = TRUE;
+ }
+ g_free(port);
+#endif
+ break;
+ case 5:
+#if GPSD_API_MAJOR_VERSION==5
+ /* open the connection to gpsd and start the stream */
+ qth->gps_data = g_try_new0(struct gps_data_t,1);
+ port=g_strdup_printf("%d",qth->gpsd_port);
+ if (gps_open(qth->gpsd_server,port,qth->gps_data)==-1) {
+ free(qth->gps_data);
+ qth->gps_data = NULL;
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Could not open gpsd at %s:%d"),
+ __FUNCTION__, qth->gpsd_server, qth->gpsd_port);
+ retval = FALSE;
+ } else {
+ (void)gps_stream(qth->gps_data, WATCH_ENABLE, NULL);
+ retval = TRUE;
+ }
+ g_free(port);
+#endif
+ break;
+ default:
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Unsupported gpsd api major version (%d)"),
+ __FUNCTION__, GPSD_API_MAJOR_VERSION);
+
+
+ return FALSE;
+ break;
+ }
+#else
+ return FALSE;
+#endif
+ break;
+
+ default:
+ break;
+ }
+ return retval;
+}
+
+/** \brief Shutdown and free structures inside the qth_t stucture were used for updates.
+ * \param qth the qth data structure to update
+ *
+ *Initial intention of this is to open sockets and ports to gpsd
+ *and other like services to update the qth position.
+ */
+void qth_data_update_stop (qth_t *qth) {
+ switch (qth->type) {
+ case QTH_STATIC_TYPE:
+ /*nothing to do. the data never updates*/
+ break;
+ case QTH_GPSD_TYPE:
+
+ /* close gpsd socket */
+ if (qth->gps_data !=NULL){
+#if HAS_LIBGPS
+ switch (GPSD_API_MAJOR_VERSION) {
+ case 4:
+ gps_close(qth->gps_data);
+ break;
+ case 5:
+ gps_close(qth->gps_data);
+ break;
+ default:
+ break;
+ }
+#endif
+ qth->gps_data = NULL;
+ }
+
+ break;
+ default:
+ break;
+ }
+}
+
+/** \brief Load initial values into the qth_t data structure
+ * \param qth the qth data structure to update
+ */
+void qth_init(qth_t* qth) {
+ qth->lat=0;
+ qth->lon=0;
+ qth->alt=0;
+ qth->type=QTH_STATIC_TYPE;
+ qth->gps_data=NULL;
+ qth->name=NULL;
+ qth->loc=NULL;
+ qth->gpsd_port=0;
+ qth->gpsd_server=NULL;
+ qth->gpsd_update=0.0;
+ qth->gpsd_connected=0.0;
+}
+
+/** \brief Load safe values into the qth_t data structure
+ * \param qth the qth data structure to update
+ * This can be used if some operation is suspected of corrupting the structure or entering invalid data. Originally it is based on code that reset values if a load/read of a .qth failed.
+ */
+void qth_safe(qth_t* qth) {
+ qth->name = g_strdup (_("Error"));
+ qth->loc = g_strdup (_("Error"));
+ qth->type=QTH_STATIC_TYPE;
+ qth->lat=0;
+ qth->lon=0;
+ qth->alt=0;
+ qth->gps_data=NULL;
+}
+
+/** \brief Copy values from qth structure to qth_small structure
+ * \param qth the qth data structure to backup
+ * \param qth_small the data structure to store values
+ * This is intended for copying only the minimal qth data to a structure for tagging and later comparison.
+ */
+void qth_small_save(qth_t*qth,qth_small_t *qth_small){
+ qth_small->lat=qth->lat;
+ qth_small->lon=qth->lon;
+ qth_small->alt=qth->alt;
+}
+
+/** \brief Validate the contents of a qth structure and correct if neccessary
+ * \param qth the qth data structure to cleanup
+ */
+void qth_validate(qth_t*qth){
+ /*check that the values are not set to nonsense such as nan or inf. if so error it and set to zero.*/
+ if (!isnormal(qth->lat)){
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: QTH data had bogus lat %f"),
+ __FUNCTION__,qth->lat);
+ qth->lat=0.0;
+
+ }
+ if (!isnormal(qth->lon)){
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: QTH data had bogus lon %f"),
+ __FUNCTION__,qth->lon);
+ qth->lon=0.0;
+ }
+ if (!isnormal(qth->alt)){
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: QTH data had bogus alt %f"),
+ __FUNCTION__,qth->alt);
+ qth->alt=0.0;
+ }
+
+ /*check that qth->lat and qth->lon are in a reasonable range and if not wrap them back*/
+ if (fabs(qth->lat)>90.0||fabs(qth->lon)>180.0) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: File contained bogus QTH data. Correcting: %s, %.4f, %.4f, %d"),
+ __FUNCTION__,
+ qth->name,
+ qth->lat,
+ qth->lon,
+ qth->alt);
+
+ qth->lat=fmod(qth->lat,360.0);
+ while ((qth->lat)>180.0){
+ qth->lat=qth->lat-180.0;
+ qth->lon=qth->lon+180.0;
+ }
+
+ while ((qth->lat)<-180.0){
+ qth->lat=qth->lat+180.0;
+ qth->lon=qth->lon+180.0;
+ }
+ if (qth->lat>90.0){
+ qth->lat=180.0-qth->lat;
+ qth->lon=qth->lon+180.0;
+ }
+
+ if (qth->lat<-90.0){
+ qth->lat=-180.0-qth->lat;
+ qth->lon=qth->lon+180.0;
+ }
+
+ qth->lon=fmod(qth->lon+180.0,360.0)-180;
+ if (qth->lon<-180.0) {
+ qth->lon+=360.0;
+ } else if (qth->lon>180.0) {
+ qth->lon-=360.0;
+ }
+
+ }
+}
+
+/** \brief Compute the distance between a location in a qth_t structure and qth_small_t structure.
+ * \param qth the qth data structure
+ * \param qth_small the data structure
+ * This is intended for measuring distance between the current qth and the position that tagged some data in qth_small.
+ */
+double qth_small_dist(qth_t *qth,qth_small_t qth_small){
+ double distance,azimuth;
+ /* FIXME Is this the right coordinate system to use? */
+ /* a 3d coordinate system might make more sense long term */
+ qrb(qth->lon,qth->lat,qth_small.lon,qth_small.lat,&distance,&azimuth);
+ return(distance);
+}
Modified: trunk/src/qth-data.h
===================================================================
--- trunk/src/qth-data.h 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/qth-data.h 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,9 +2,10 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
+ Charles Suprin <ham...@gm...>
Comments, questions and bugreports should be submitted via
http://sourceforge.net/projects/gpredict/
@@ -35,22 +36,46 @@
/** \brief QTH data structure in human readable form. */
typedef struct {
- gchar *name; /*!< Name, eg. callsign. */
- gchar *loc; /*!< Location, eg City, Country. */
- gchar *desc; /*!< Short description. */
+ gchar *name; /*!< Name, eg. callsign. */
+ gchar *loc; /*!< Location, eg City, Country. */
+ gchar *desc; /*!< Short description. */
+ gdouble lat; /*!< Latitude in dec. deg. North. */
+ gdouble lon; /*!< Longitude in dec. deg. East. */
+ gint alt; /*!< Altitude above sea level in meters. */
+ gchar *qra; /*!< QRA locator */
+ gchar *wx; /*!< Weather station code (4 chars). */
+ gint type; /*!< QTH type (static,gpsd). */
+ gchar *gpsd_server; /*!< GPSD Server name. */
+ gint gpsd_port; /*!< GPSD Server port. */
+ gdouble gpsd_update; /*!< Time last GPSD update was received. */
+ gdouble gpsd_connected; /*!< Time last GPSD update was last attempted to connect. */
+ struct gps_data_t *gps_data; /*!< gpsd data structure. */
+ GKeyFile *data; /*!< Raw data from cfg file. */
+} qth_t;
+
+/** \brief Compact QTH data structure for tagging data and comparing. */
+typedef struct {
gdouble lat; /*!< Latitude in dec. deg. North. */
gdouble lon; /*!< Longitude in dec. deg. East. */
gint alt; /*!< Altitude above sea level in meters. */
- gchar *qra; /*!< QRA locator */
- gchar *wx; /*!< Weather station code (4 chars). */
+} qth_small_t;
- GKeyFile *data; /*!< Raw data from cfg file. */
-} qth_t;
+enum {
+ QTH_STATIC_TYPE=0,
+ QTH_GPSD_TYPE
+} qth_data_type;
+
+
gint qth_data_read (const gchar *filename, qth_t *qth);
gint qth_data_save (const gchar *filename, qth_t *qth);
void qth_data_free (qth_t *qth);
-
-
+gboolean qth_data_update(qth_t *qth, gdouble t);
+gboolean qth_data_update_init(qth_t *qth);
+void qth_data_update_stop(qth_t *qth);
+double qth_small_dist(qth_t *qth,qth_small_t qth_small);
+void qth_small_save(qth_t *qth,qth_small_t *qth_small);
+void qth_init(qth_t* qth);
+void qth_safe(qth_t* qth);
#endif
Modified: trunk/src/qth-editor.c
===================================================================
--- trunk/src/qth-editor.c 2011-03-19 18:44:47 UTC (rev 787)
+++ trunk/src/qth-editor.c 2011-03-20 15:05:07 UTC (rev 788)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -73,6 +73,9 @@
static GtkWidget *location; /* QTH location */
static GtkWidget *desc; /* QTH description */
static GtkWidget *lat,*lon,*alt; /* LAT, LON and ALT */
+static GtkWidget *type; /* GPSD type */
+static GtkWidget *server; /* GPSD Server */
+static GtkWidget *port; /* GPSD Port */
static GtkWidget *ns,*ew;
static GtkWidget *qra; /* QRA locator */
@@ -373,7 +376,46 @@
GUINT_TO_POINTER (SELECTION_MODE_WX));
gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8);
+ /* GPSD enabled*/
+ label = gtk_label_new (_("QTH Type"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 8, 9);
+ type = gtk_combo_box_new_text();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type), "Static");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type), "GPSD");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (type), 0);
+ gtk_tooltips_set_tip (tooltips, type,
+ _("A qth can be static, ie. it does not change, or gpsd based for computers with gps attached."),
+ NULL);
+ gtk_table_attach_defaults (GTK_TABLE (table), type, 1, 2, 8, 9);
+ /* GPSD Server */
+ label = gtk_label_new (_("GPSD Server"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 9, 10);
+
+ server = gtk_entry_new ();
+ gtk_entry_set_max_length (GTK_ENTRY (server), 6000);
+ tooltips = gtk_tooltips_new ();
+ gtk_tooltips_set_tip (tooltips, server,
+ _("GPSD Server."),
+ NULL);
+ gtk_table_attach_defaults (GTK_TABLE (table), server, 1, 2, 9, 10);
+
+ /* GPSD Port*/
+ label = gtk_label_new (_("GPSD Port"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 10, 11);
+
+ port = gtk_spin_button_new_with_range (0, 32768, 1);
+ gtk_spin_button_set_increments (GTK_SPIN_BUTTON (port), 1, 100);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (port), TRUE);
+ gtk_tooltips_set_tip (tooltips, port,
+ _("Set the port for GPSD to use. Default for gpsd is 2947."),
+ NULL);
+ gtk_table_attach_defaults (GTK_TABLE (table), port, 1, 2, 10, 11);
+
+
if (qth->name != NULL)
update_widgets (qth);
@@ -463,6 +505,9 @@
const gchar *qthdesc = NULL;
const gchar *qthwx = NULL;
const gchar *qthqra= NULL;
+ const gchar *gpsdserver= NULL;
+ guint gpsdport;
+ guint gpsdenabled;
gdouble qthlat;
gdouble qthlon;
guint qthalt;
@@ ...
[truncated message content] |