[Gpredict-svn] SF.net SVN: gpredict:[501] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2009-10-25 21:23:48
|
Revision: 501 http://gpredict.svn.sourceforge.net/gpredict/?rev=501&view=rev Author: csete Date: 2009-10-25 21:23:39 +0000 (Sun, 25 Oct 2009) Log Message: ----------- Applied patch 2881367 from Charles Suprin AA1VS. Modified Paths: -------------- trunk/ChangeLog trunk/src/gtk-rig-ctrl.c trunk/src/gtk-rig-ctrl.h trunk/src/gtk-rot-ctrl.c trunk/src/gtk-rot-ctrl.h trunk/src/gtk-sat-module-popup.c trunk/src/gtk-sat-module.c trunk/src/gtk-sat-module.h trunk/src/main.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/ChangeLog 2009-10-25 21:23:39 UTC (rev 501) @@ -1,3 +1,16 @@ +2009-10-25 Alexandru Csete <oz9aec at gmail.com> + + * src/gtk-sat-module-popup.c: + * src/gtk-rig-ctrl.c: + * src/gtk-rig-ctrl.h: + * src/main.c: + * src/gtk-sat-module.c: + * src/gtk-sat-module.h: + * src/gtk-rot-ctrl.c: + * src/gtk-rot-ctrl.h: + Applied patch 2881367 from Charles Suprin AA1VS. + + 2009-10-13 Alexandru Csete <oz9aec at gmail.com> * src/tle-update.c: Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-rig-ctrl.c 2009-10-25 21:23:39 UTC (rev 501) @@ -41,6 +41,7 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <math.h> +#include <glib.h> #include "compat.h" #include "sat-log.h" #include "predict-tools.h" @@ -186,7 +187,7 @@ ctrl->trsplist = NULL; ctrl->trsplock = FALSE; ctrl->tracking = FALSE; - ctrl->busy = FALSE; + g_static_mutex_init(&(ctrl->busy)); ctrl->engaged = FALSE; ctrl->delay = 1000; ctrl->timerid = 0; @@ -199,7 +200,7 @@ gtk_rig_ctrl_destroy (GtkObject *object) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (object); - + /* stop timer */ if (ctrl->timerid > 0) g_source_remove (ctrl->timerid); @@ -1260,14 +1261,12 @@ GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); - if (ctrl->busy) { + if (g_static_mutex_trylock(&(ctrl->busy))==FALSE) { sat_log_log (SAT_LOG_LEVEL_ERROR,_("%s missed the deadline"),__FUNCTION__); return TRUE; } - ctrl->busy = TRUE; - - if (ctrl->conf2 != NULL) { + if (ctrl->conf2 != NULL) { exec_dual_rig_cycle (ctrl); } else { @@ -1315,7 +1314,7 @@ //g_print (" WROPS = %d\n", ctrl->wrops); - ctrl->busy = FALSE; + g_static_mutex_unlock(&(ctrl->busy)); return TRUE; } Modified: trunk/src/gtk-rig-ctrl.h =================================================================== --- trunk/src/gtk-rig-ctrl.h 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-rig-ctrl.h 2009-10-25 21:23:39 UTC (rev 501) @@ -98,7 +98,7 @@ guint timerid; /*!< Timer ID */ gboolean tracking; /*!< Flag set when we are tracking a target. */ - gboolean busy; /*!< Flag set when control algorithm is busy. */ + GStaticMutex busy;/*!< Flag set when control algorithm is busy. */ gboolean engaged; /*!< Flag indicating that rig device is engaged. */ gint errcnt; /*!< Error counter. */ Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-rot-ctrl.c 2009-10-25 21:23:39 UTC (rev 501) @@ -155,7 +155,7 @@ ctrl->plot = NULL; ctrl->tracking = FALSE; - ctrl->busy = FALSE; + g_static_mutex_init(&(ctrl->busy)); ctrl->engaged = FALSE; ctrl->delay = 1000; ctrl->timerid = 0; @@ -180,7 +180,7 @@ g_free (ctrl->conf); ctrl->conf = NULL; } - + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -800,13 +800,11 @@ gboolean error = FALSE; - if (ctrl->busy) { + if (g_static_mutex_trylock(&(ctrl->busy))==FALSE) { sat_log_log (SAT_LOG_LEVEL_ERROR,_("%s missed the deadline"),__FUNCTION__); return TRUE; } - ctrl->busy = TRUE; - /* If we are tracking and the target satellite is within range, set the rotor position controller knob values to the target values. If the target satellite is out of range @@ -924,7 +922,7 @@ gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->ElSet))); } - ctrl->busy = FALSE; + g_static_mutex_unlock(&(ctrl->busy)); return TRUE; } Modified: trunk/src/gtk-rot-ctrl.h =================================================================== --- trunk/src/gtk-rot-ctrl.h 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-rot-ctrl.h 2009-10-25 21:23:39 UTC (rev 501) @@ -89,7 +89,7 @@ gdouble tolerance; /*!< Error tolerance */ gboolean tracking; /*!< Flag set when we are tracking a target. */ - gboolean busy; /*!< Flag set when control algorithm is busy. */ + GStaticMutex busy; /*!< Flag set when control algorithm is busy. */ gboolean engaged; /*!< Flag indicating that rotor device is engaged. */ gint errcnt; /*!< Error counter. */ Modified: trunk/src/gtk-sat-module-popup.c =================================================================== --- trunk/src/gtk-sat-module-popup.c 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-sat-module-popup.c 2009-10-25 21:23:39 UTC (rev 501) @@ -833,11 +833,9 @@ g_free (buff); /* if module is busy wait until done then go on */ - while (module->busy) - g_usleep (1000); + g_mutex_lock(module->busy); /* create sky at a glance widget */ - module->busy = TRUE; if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { skg = gtk_sky_glance_new (module->satellites, module->qth, 0.0); @@ -846,7 +844,7 @@ skg = gtk_sky_glance_new (module->satellites, module->qth, module->tmgCdnum); } - module->busy = FALSE; + g_mutex_unlock(module->busy); gtk_container_set_border_width (GTK_CONTAINER (window), 10); gtk_container_add (GTK_CONTAINER (window), skg); Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-sat-module.c 2009-10-25 21:23:39 UTC (rev 501) @@ -174,7 +174,7 @@ module->rigctrlwin = NULL; module->state = GTK_SAT_MOD_STATE_DOCKED; - module->busy = FALSE; + module->busy = g_mutex_new(); module->layout = GTK_SAT_MOD_LAYOUT_1; module->view_1 = GTK_SAT_MOD_VIEW_MAP; @@ -766,18 +766,7 @@ gdouble delta; - if (mod->busy) { - - sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Previous cycle missed it's deadline."), - __FUNCTION__); - - return TRUE; - - } - - - /* in docked state, update only if tab is visible */ + /* in docked state, update only if tab is visible */ switch (mod->state) { case GTK_SAT_MOD_STATE_DOCKED: @@ -801,9 +790,16 @@ if (needupdate) { - mod->busy = 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 */ @@ -879,11 +875,9 @@ } + g_mutex_unlock(mod->busy); - mod->busy = FALSE; - } - return TRUE; } @@ -1488,8 +1482,8 @@ g_return_if_fail (IS_GTK_SAT_MODULE (module)); /* lock module */ - module->busy = TRUE; - + g_mutex_lock(module->busy); + sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Reloading satellites for module %s"), __FUNCTION__, module->name); @@ -1516,8 +1510,7 @@ /* FIXME: radio and rotator controller */ /* unlock module */ - module->busy = FALSE; - + g_mutex_unlock(module->busy); } Modified: trunk/src/gtk-sat-module.h =================================================================== --- trunk/src/gtk-sat-module.h 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/gtk-sat-module.h 2009-10-25 21:23:39 UTC (rev 501) @@ -132,7 +132,7 @@ gtk_sat_mod_view_t view_3; guint timerid; /*!< The timeout ID (FIXME: REMOVE) */ - gboolean busy; /*!< Flag indicating whether timeout has + GMutex *busy; /*!< Flag indicating whether timeout has finished or not. Also used for blocking the module during TLE update. */ Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-10-24 11:12:33 UTC (rev 500) +++ trunk/src/main.c 2009-10-25 21:23:39 UTC (rev 501) @@ -102,6 +102,9 @@ /* start logger first, so that we can catch error messages if any */ sat_log_init (); + + if (!g_thread_supported ()) + g_thread_init (NULL); /* check that user settings are ok */ error = first_time_check_run (); @@ -421,8 +424,6 @@ _("%s: Starting new update thread."), __FUNCTION__); - if (!g_thread_supported ()) - g_thread_init (NULL); g_thread_create (update_tle_thread, NULL, FALSE, &err); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |