Thread: [Gpredict-svn] SF.net SVN: gpredict:[92] trunk/src/gtk-rot-ctrl.c
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2008-09-06 18:41:52
|
Revision: 92 http://gpredict.svn.sourceforge.net/gpredict/?rev=92&view=rev Author: csete Date: 2008-09-06 18:42:03 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Fixed incorrect engaged logic. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-06 14:34:18 UTC (rev 91) +++ trunk/src/gtk-rot-ctrl.c 2008-09-06 18:42:03 UTC (rev 92) @@ -660,11 +660,11 @@ if (gtk_toggle_button_get_active (button)) { gtk_widget_set_sensitive (ctrl->DevSel, FALSE); - ctrl->engaged = FALSE; + ctrl->engaged = TRUE; } else { gtk_widget_set_sensitive (ctrl->DevSel, TRUE); - ctrl->engaged = TRUE; + ctrl->engaged = FALSE; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2008-09-15 23:26:00
|
Revision: 109 http://gpredict.svn.sourceforge.net/gpredict/?rev=109&view=rev Author: csete Date: 2008-09-15 23:26:11 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Implemented loading of rotator configuration. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-15 23:19:31 UTC (rev 108) +++ trunk/src/gtk-rot-ctrl.c 2008-09-15 23:26:11 UTC (rev 109) @@ -495,7 +495,7 @@ gtk_combo_box_set_active (GTK_COMBO_BOX (ctrl->DevSel), 0); g_signal_connect (ctrl->DevSel, "changed", G_CALLBACK (rot_selected_cb), ctrl); gtk_table_attach_defaults (GTK_TABLE (table), ctrl->DevSel, 1, 2, 0, 1); - + /* Engage button */ lock = gtk_toggle_button_new_with_label (_("Engage")); gtk_widget_set_tooltip_text (lock, _("Engage the selcted rotor device")); @@ -543,6 +543,8 @@ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 2, 3); + /* load initial rotator configuration */ + rot_selected_cb (ctrl->DevSel, ctrl); frame = gtk_frame_new (_("Settings")); gtk_container_add (GTK_CONTAINER (frame), table); @@ -688,9 +690,39 @@ { GtkRotCtrl *ctrl = GTK_ROT_CTRL (data); - /* TODO: update device */ + /* free previous configuration */ + if (ctrl->conf != NULL) { + g_free (ctrl->conf->name); + g_free (ctrl->conf->host); + g_free (ctrl->conf); + } - /* TODO: update ranges */ + ctrl->conf = g_try_new (rotor_conf_t, 1); + if (ctrl->conf == NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to allocate memory for rotator config"), + __FILE__, __LINE__); + return; + } + + /* load new configuration */ + ctrl->conf->name = gtk_combo_box_get_active_text (box); + if (rotor_conf_read (ctrl->conf)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("Loaded new rotator configuration %s"), + ctrl->conf->name); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to load rotator configuration %s"), + __FILE__, __LINE__, ctrl->conf->name); + + g_free (ctrl->conf->name); + if (ctrl->conf->host) + g_free (ctrl->conf->host); + g_free (ctrl->conf); + ctrl->conf = NULL; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2008-09-15 23:28:59
|
Revision: 110 http://gpredict.svn.sourceforge.net/gpredict/?rev=110&view=rev Author: csete Date: 2008-09-15 23:29:11 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Added check to ensure that we have a proper device configuration before engaging. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-15 23:26:11 UTC (rev 109) +++ trunk/src/gtk-rot-ctrl.c 2008-09-15 23:29:11 UTC (rev 110) @@ -742,6 +742,13 @@ ctrl->engaged = TRUE; } else { + if (ctrl->conf == NULL) { + /* we don't have a working configuration */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Controller does not have a valid configuration"), + __FUNCTION__); + return; + } gtk_widget_set_sensitive (ctrl->DevSel, TRUE); ctrl->engaged = FALSE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2008-09-16 01:31:01
|
Revision: 113 http://gpredict.svn.sourceforge.net/gpredict/?rev=113&view=rev Author: csete Date: 2008-09-16 01:31:09 +0000 (Tue, 16 Sep 2008) Log Message: ----------- Implemented rotator position readback Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-16 00:31:28 UTC (rev 112) +++ trunk/src/gtk-rot-ctrl.c 2008-09-16 01:31:09 UTC (rev 113) @@ -48,6 +48,13 @@ # include <build-config.h> #endif +/* NETWORK */ +//#include <sys/types.h> +#include <sys/socket.h> /* socket(), connect(), send() */ +#include <netinet/in.h> /* struct sockaddr_in */ +#include <arpa/inet.h> /* htons() */ +#include <netdb.h> /* gethostbyname() */ +/* END */ #define FMTSTR "%7.2f\302\260" @@ -74,6 +81,8 @@ static gboolean rot_ctrl_timeout_cb (gpointer data); static void update_count_down (GtkRotCtrl *ctrl, gdouble t); +static void get_pos (GtkRotCtrl *ctrl, gdouble *az, gdouble *el); +static void set_pos (GtkRotCtrl *ctrl, gdouble az, gdouble el); static GtkVBoxClass *parent_class = NULL; @@ -316,13 +325,18 @@ gtk_container_add (GTK_CONTAINER (frame), table); ctrl->AzSet = gtk_rot_knob_new (0.0, 360.0, 180.0); - gtk_table_attach_defaults (GTK_TABLE (table), ctrl->AzSet, 1, 2, 0, 1); + gtk_table_attach_defaults (GTK_TABLE (table), ctrl->AzSet, 0, 2, 0, 1); label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), _("Read:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_SHRINK, GTK_SHRINK, 10, 0); + ctrl->AzRead = gtk_label_new (" --- "); + gtk_misc_set_alignment (GTK_MISC (ctrl->AzRead), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), ctrl->AzRead, 1, 2, 1, 2); + return frame; } @@ -350,13 +364,17 @@ gtk_container_add (GTK_CONTAINER (frame), table); ctrl->ElSet = gtk_rot_knob_new (0.0, 90.0, 45.0); - gtk_table_attach_defaults (GTK_TABLE (table), ctrl->ElSet, 1, 2, 0, 1); + gtk_table_attach_defaults (GTK_TABLE (table), ctrl->ElSet, 0, 2, 0, 1); label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), _("Read:")); + gtk_label_set_markup (GTK_LABEL (label), _("Read: ")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_SHRINK, GTK_SHRINK, 10, 0); + ctrl->ElRead = gtk_label_new (" --- "); + gtk_misc_set_alignment (GTK_MISC (ctrl->ElRead), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), ctrl->ElRead, 1, 2, 1, 2); return frame; } @@ -544,7 +562,7 @@ gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 2, 3); /* load initial rotator configuration */ - rot_selected_cb (ctrl->DevSel, ctrl); + rot_selected_cb (GTK_COMBO_BOX (ctrl->DevSel), ctrl); frame = gtk_frame_new (_("Settings")); gtk_container_add (GTK_CONTAINER (frame), table); @@ -751,6 +769,9 @@ } gtk_widget_set_sensitive (ctrl->DevSel, TRUE); ctrl->engaged = FALSE; + + gtk_label_set_text (GTK_LABEL (ctrl->AzRead), "---"); + gtk_label_set_text (GTK_LABEL (ctrl->ElRead), "---"); } } @@ -763,7 +784,10 @@ rot_ctrl_timeout_cb (gpointer data) { GtkRotCtrl *ctrl = GTK_ROT_CTRL (data); + gdouble rotaz=0.0, rotel=0.0; + gchar *text; + if (ctrl->busy) { sat_log_log (SAT_LOG_LEVEL_ERROR,_("%s missed the deadline"),__FUNCTION__); return TRUE; @@ -795,10 +819,21 @@ /* TODO: Update controller thread on polar plot */ } - if (ctrl->engaged) { + if ((ctrl->engaged) && (ctrl->conf != NULL)) { + + /* read back current value from device */ + get_pos (ctrl, &rotaz, &rotel); + + /* update display widgets */ + text = g_strdup_printf ("%.2f\302\260", rotaz); + gtk_label_set_text (GTK_LABEL (ctrl->AzRead), text); + g_free (text); + text = g_strdup_printf ("%.2f\302\260", rotel); + gtk_label_set_text (GTK_LABEL (ctrl->ElRead), text); + g_free (text); + /* if tolerance exceeded */ /* TODO: send controller values to rotator device */ - /* TODO: read back current position from device */ /* TODO: update polar plot */ } @@ -809,7 +844,126 @@ } +/** \brief Read rotator position from device. + * \param ctrl Pointer to the GtkRotCtrl widget. + * \param az The current Az as read from the device + * \param el The current El as read from the device + */ +static void get_pos (GtkRotCtrl *ctrl, gdouble *az, gdouble *el) +{ + gchar *buff,**vbuff; + gint written,size; + gint status; + struct hostent *h; + struct sockaddr_in ServAddr; + gint sock; /*!< Network socket */ + + if ((az == NULL) || (el == NULL)) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s:%d: NULL storage."), + __FILE__, __LINE__); + return; + } + + /* create socket */ + sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (sock < 0) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to create socket"), + __FILE__, __LINE__); + return; + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d Network socket created successfully"), + __FILE__, __LINE__); + } + + memset(&ServAddr, 0, sizeof(ServAddr)); /* Zero out structure */ + ServAddr.sin_family = AF_INET; /* Internet address family */ + h = gethostbyname(ctrl->conf->host); + memcpy((char *) &ServAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length); + ServAddr.sin_port = htons(ctrl->conf->port); /* Server port */ + + /* establish connection */ + status = connect(sock, (struct sockaddr *) &ServAddr, sizeof(ServAddr)); + if (status < 0) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to connect to %s:%d"), + __FILE__, __LINE__, ctrl->conf->host, ctrl->conf->port); + return; + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Connection opened to %s:%d"), + __FILE__, __LINE__, ctrl->conf->host, ctrl->conf->port); + } + + /* send command */ + buff = g_strdup_printf ("p\n"); + + /* number of bytes to write depends on platform (EOL) */ +#ifdef G_OS_WIN32 + size = 3; +#else + size = 2; +#endif + written = send(sock, buff, size, 0); + if (written != size) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: SIZE ERROR %d / %d"), + __FILE__, __LINE__, written, size); + } + g_free (buff); + + + /* try to read answer */ + buff = g_try_malloc (128); + if (buff == NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Failed to allocate 128 bytes (yes, this means trouble)"), + __FILE__, __FUNCTION__); + shutdown (sock, SHUT_RDWR); + close (sock); + return; + } + + size = read (sock, buff, 127); + if (size == 0) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Got 0 bytes from rotctld"), + __FILE__, __FUNCTION__); + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%s: Read %d bytes from rotctld"), + __FILE__, __FUNCTION__, size); + + buff[size] = 0; + vbuff = g_strsplit (buff, "\n", 3); + *az = g_strtod (vbuff[0], NULL); + *el = g_strtod (vbuff[1], NULL); + + g_free (buff); + g_strfreev (vbuff); + } + + shutdown (sock, SHUT_RDWR); + close (sock); + + +} + + +static void set_pos (GtkRotCtrl *ctrl, gdouble az, gdouble el) +{ + +} + + + + /** \brief Update count down label. * \param[in] ctrl Pointer to the RotCtrl widget. * \param[in] t The current time. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2008-09-17 10:51:21
|
Revision: 117 http://gpredict.svn.sourceforge.net/gpredict/?rev=117&view=rev Author: csete Date: 2008-09-17 10:51:31 +0000 (Wed, 17 Sep 2008) Log Message: ----------- Removed unused var. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-17 10:48:52 UTC (rev 116) +++ trunk/src/gtk-rot-ctrl.c 2008-09-17 10:51:31 UTC (rev 117) @@ -460,7 +460,6 @@ create_conf_widgets (GtkRotCtrl *ctrl) { GtkWidget *frame,*table,*label,*timer,*toler; - GtkWidget *lock; GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ gchar *cfgdir; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2008-09-18 12:03:49
|
Revision: 137 http://gpredict.svn.sourceforge.net/gpredict/?rev=137&view=rev Author: csete Date: 2008-09-18 19:04:00 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Removed newline from the end of hamlib commands. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-18 18:52:52 UTC (rev 136) +++ trunk/src/gtk-rot-ctrl.c 2008-09-18 19:04:00 UTC (rev 137) @@ -986,14 +986,9 @@ } /* send command */ - buff = g_strdup_printf ("p\n"); + buff = g_strdup_printf ("p"); - /* number of bytes to write depends on platform (EOL) */ -#ifdef G_OS_WIN32 - size = 3; -#else - size = 2; -#endif + size = 1; written = send(sock, buff, size, 0); if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, @@ -1102,14 +1097,9 @@ /* send command */ g_ascii_formatd (azstr, 8, "%7.2f", az); g_ascii_formatd (elstr, 8, "%7.2f", el); - buff = g_strdup_printf ("P %s %s\n", azstr, elstr); + buff = g_strdup_printf ("P %s %s", azstr, elstr); - /* number of bytes to write depends on platform (EOL) */ -#ifdef G_OS_WIN32 - size = 19; -#else - size = 18; -#endif + size = 17; written = send(sock, buff, size, 0); if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-04-13 00:29:36
|
Revision: 264 http://gpredict.svn.sourceforge.net/gpredict/?rev=264&view=rev Author: csete Date: 2009-04-13 00:29:32 +0000 (Mon, 13 Apr 2009) Log Message: ----------- Increased tolerance. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2009-04-12 23:52:30 UTC (rev 263) +++ trunk/src/gtk-rot-ctrl.c 2009-04-13 00:29:32 UTC (rev 264) @@ -98,48 +98,48 @@ GType gtk_rot_ctrl_get_type () { - static GType gtk_rot_ctrl_type = 0; + static GType gtk_rot_ctrl_type = 0; - if (!gtk_rot_ctrl_type) { + if (!gtk_rot_ctrl_type) { - static const GTypeInfo gtk_rot_ctrl_info = { - sizeof (GtkRotCtrlClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_rot_ctrl_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkRotCtrl), - 5, /* n_preallocs */ - (GInstanceInitFunc) gtk_rot_ctrl_init, - }; + static const GTypeInfo gtk_rot_ctrl_info = { + sizeof (GtkRotCtrlClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_rot_ctrl_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkRotCtrl), + 5, /* n_preallocs */ + (GInstanceInitFunc) gtk_rot_ctrl_init, + }; - gtk_rot_ctrl_type = g_type_register_static (GTK_TYPE_VBOX, - "GtkRotCtrl", - >k_rot_ctrl_info, - 0); - } + gtk_rot_ctrl_type = g_type_register_static (GTK_TYPE_VBOX, + "GtkRotCtrl", + >k_rot_ctrl_info, + 0); + } - return gtk_rot_ctrl_type; + return gtk_rot_ctrl_type; } static void gtk_rot_ctrl_class_init (GtkRotCtrlClass *class) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; - gobject_class = G_OBJECT_CLASS (class); - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - container_class = (GtkContainerClass*) class; + gobject_class = G_OBJECT_CLASS (class); + object_class = (GtkObjectClass*) class; + widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); + parent_class = g_type_class_peek_parent (class); - object_class->destroy = gtk_rot_ctrl_destroy; + object_class->destroy = gtk_rot_ctrl_destroy; } @@ -159,7 +159,7 @@ ctrl->engaged = FALSE; ctrl->delay = 1000; ctrl->timerid = 0; - ctrl->tolerance = 1.0; + ctrl->tolerance = 5.0; ctrl->errcnt = 0; } @@ -255,7 +255,7 @@ rot_ctrl_timeout_cb, GTK_ROT_CTRL (widget)); - return widget; + return widget; } @@ -552,7 +552,7 @@ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3); - toler = gtk_spin_button_new_with_range (0.01, 10.0, 0.01); + toler = gtk_spin_button_new_with_range (0.01, 50.0, 0.01); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (toler), 2); gtk_widget_set_tooltip_text (toler, _("This parameter controls the tolerance between "\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-10-12 22:15:52
|
Revision: 490 http://gpredict.svn.sourceforge.net/gpredict/?rev=490&view=rev Author: csete Date: 2009-10-12 22:15:44 +0000 (Mon, 12 Oct 2009) Log Message: ----------- Fixed memory leak (thanks to Charles Suprin AA1VS for patch). Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2009-10-12 16:37:19 UTC (rev 489) +++ trunk/src/gtk-rot-ctrl.c 2009-10-12 22:15:44 UTC (rev 490) @@ -1028,10 +1028,11 @@ *az = g_strtod (vbuff[0], NULL); *el = g_strtod (vbuff[1], NULL); - g_free (buff); g_strfreev (vbuff); } - + + g_free (buff); + shutdown (sock, SHUT_RDWR); close (sock); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-10-02 16:36:31
|
Revision: 660 http://gpredict.svn.sourceforge.net/gpredict/?rev=660&view=rev Author: aa1vs Date: 2010-10-02 16:36:25 +0000 (Sat, 02 Oct 2010) Log Message: ----------- Catch null value in rot_ctrl_timeout_cb that caused crash Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-10-02 14:39:11 UTC (rev 659) +++ trunk/src/gtk-rot-ctrl.c 2010-10-02 16:36:25 UTC (rev 660) @@ -916,17 +916,18 @@ } /* update controller circle on polar plot */ - if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && (rotaz < 0.0)) { - gtk_polar_plot_set_ctrl_pos (GTK_POLAR_PLOT (ctrl->plot), - gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->AzSet))+360.0, - gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->ElSet))); + if (ctrl->conf !=NULL){ + if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && (rotaz < 0.0)) { + gtk_polar_plot_set_ctrl_pos (GTK_POLAR_PLOT (ctrl->plot), + gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->AzSet))+360.0, + gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->ElSet))); + } + else { + gtk_polar_plot_set_ctrl_pos (GTK_POLAR_PLOT (ctrl->plot), + gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->AzSet)), + gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->ElSet))); + } } - else { - gtk_polar_plot_set_ctrl_pos (GTK_POLAR_PLOT (ctrl->plot), - gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->AzSet)), - gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->ElSet))); - } - g_static_mutex_unlock(&(ctrl->busy)); return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-10-27 16:01:43
|
Revision: 693 http://gpredict.svn.sourceforge.net/gpredict/?rev=693&view=rev Author: aa1vs Date: 2010-10-27 16:01:35 +0000 (Wed, 27 Oct 2010) Log Message: ----------- Remove return from void function Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-10-27 15:53:53 UTC (rev 692) +++ trunk/src/gtk-rot-ctrl.c 2010-10-27 16:01:35 UTC (rev 693) @@ -783,8 +783,6 @@ g_free (ctrl->conf); ctrl->conf = NULL; } - - return TRUE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-05 11:24:45
|
Revision: 706 http://gpredict.svn.sourceforge.net/gpredict/?rev=706&view=rev Author: aa1vs Date: 2010-11-05 11:24:39 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Update is_flipped_pass to handle pass with no details Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-11-05 11:23:27 UTC (rev 705) +++ trunk/src/gtk-rot-ctrl.c 2010-11-05 11:24:39 UTC (rev 706) @@ -1341,20 +1341,22 @@ last_az+=360; } - for (i = 1; i < num-1; i++) { - detail = PASS_DETAIL(g_slist_nth_data (pass->details, i)); - caz=detail->az; - while (caz>max_az) { - caz-=360; - } - while (caz<min_az) { - caz+=360; + if (num>1) { + for (i = 1; i < num-1; i++) { + detail = PASS_DETAIL(g_slist_nth_data (pass->details, i)); + caz=detail->az; + while (caz>max_az) { + caz-=360; + } + while (caz<min_az) { + caz+=360; + } + if (fabs(caz-last_az)>180) { + retval=TRUE; + } + last_az=caz; + } - if (fabs(caz-last_az)>180) { - retval=TRUE; - } - last_az=caz; - } caz=pass->los_az; while (caz>max_az) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-06 13:35:16
|
Revision: 707 http://gpredict.svn.sourceforge.net/gpredict/?rev=707&view=rev Author: aa1vs Date: 2010-11-06 13:35:09 +0000 (Sat, 06 Nov 2010) Log Message: ----------- Added checks on g_strsplit in get_pos Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-11-05 11:24:39 UTC (rev 706) +++ trunk/src/gtk-rot-ctrl.c 2010-11-06 13:35:09 UTC (rev 707) @@ -1019,8 +1019,15 @@ } else { vbuff = g_strsplit (buffback, "\n", 3); - *az = g_strtod (vbuff[0], NULL); - *el = g_strtod (vbuff[1], NULL); + if ((vbuff[0] !=NULL) && (vbuff[1]!=NULL)){ + *az = g_strtod (vbuff[0], NULL); + *el = g_strtod (vbuff[1], NULL); + } else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: rotctld returned bad response (%s)"), + __FILE__, __LINE__,buffback); + retcode=FALSE; + } g_strfreev (vbuff); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-21 20:51:37
|
Revision: 716 http://gpredict.svn.sourceforge.net/gpredict/?rev=716&view=rev Author: aa1vs Date: 2010-11-21 20:51:31 +0000 (Sun, 21 Nov 2010) Log Message: ----------- Change error checking in set_pos Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-11-11 19:20:31 UTC (rev 715) +++ trunk/src/gtk-rot-ctrl.c 2010-11-21 20:51:31 UTC (rev 716) @@ -1085,6 +1085,7 @@ gchar buffback[128]; gchar azstr[8],elstr[8]; gboolean retcode; + gint retval; /* send command */ g_ascii_formatd (azstr, 8, "%7.2f", az); @@ -1095,14 +1096,25 @@ g_free (buff); - if (retcode==TRUE) - if (strncmp(buffback,"RPRT 0",6)!=0) { + if (retcode==TRUE){ + retval=(gint)g_strtod(buffback+4,NULL); + switch(retval) { + + case 0: + /*no error case*/ + break; + + default: + /*any other case*/ + /*not sure what is a hard error or soft error*/ sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: rotctld returned error (%s)"), - __FILE__, __LINE__,buffback); + _("%s:%d: rotctld returned error %d (%s)"), + __FILE__, __LINE__, retval, buffback); - retcode=FALSE; + //retcode=FALSE; + break; } + } return (retcode); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-23 13:23:33
|
Revision: 717 http://gpredict.svn.sourceforge.net/gpredict/?rev=717&view=rev Author: aa1vs Date: 2010-11-23 13:23:27 +0000 (Tue, 23 Nov 2010) Log Message: ----------- Close socket in gtk-rot-ctrl when window closes if applicable Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-11-21 20:51:31 UTC (rev 716) +++ trunk/src/gtk-rot-ctrl.c 2010-11-23 13:23:27 UTC (rev 717) @@ -90,8 +90,8 @@ static gboolean set_pos (GtkRotCtrl *ctrl, gdouble az, gdouble el); static gboolean send_rotctld_command(GtkRotCtrl *ctrl, gchar *buff, gchar *buffout, gint sizeout); -static gboolean open_rotctld_socket (GtkRotCtrl *ctrl, gint *sock); -static gboolean close_rotctld_socket (gint sock); +static gboolean open_rotctld_socket (GtkRotCtrl *ctrl); +static gboolean close_rotctld_socket (gint *sock); static gboolean have_conf (void); static gint sat_name_compare (sat_t* a,sat_t*b); @@ -166,7 +166,8 @@ ctrl->pass = NULL; ctrl->qth = NULL; ctrl->plot = NULL; - + ctrl->sock = 0; + ctrl->tracking = FALSE; g_static_mutex_init(&(ctrl->busy)); ctrl->engaged = FALSE; @@ -194,6 +195,11 @@ ctrl->conf = NULL; } + /*close the socket if it is still open*/ + if (ctrl->sock!=0) { + close_rotctld_socket(&(ctrl->sock)); + } + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -831,7 +837,7 @@ if (!gtk_toggle_button_get_active (button)) { gtk_widget_set_sensitive (ctrl->DevSel, TRUE); ctrl->engaged = FALSE; - close_rotctld_socket(ctrl->sock); + close_rotctld_socket(&(ctrl->sock)); gtk_label_set_text (GTK_LABEL (ctrl->AzRead), "---"); gtk_label_set_text (GTK_LABEL (ctrl->ElRead), "---"); } @@ -845,7 +851,7 @@ } gtk_widget_set_sensitive (ctrl->DevSel, FALSE); ctrl->engaged = TRUE; - open_rotctld_socket(ctrl,&(ctrl->sock)); + open_rotctld_socket(ctrl); ctrl->wrops = 0; ctrl->rdops = 0; } @@ -1230,7 +1236,7 @@ /** \brief open the rotcld socket. return true if successful false otherwise.*/ -static gboolean open_rotctld_socket (GtkRotCtrl * ctrl, gint *sock) { +static gboolean open_rotctld_socket (GtkRotCtrl * ctrl) { struct sockaddr_in ServAddr; struct hostent *h; gint status; @@ -1240,6 +1246,7 @@ sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create socket"), __FUNCTION__); + ctrl->sock = 0; return FALSE; } else { @@ -1260,6 +1267,7 @@ sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to connect to %s:%d"), __FUNCTION__, ctrl->conf->host, ctrl->conf->port); + ctrl->sock = 0; return FALSE; } else { @@ -1273,18 +1281,20 @@ /*close a rotcld socket. First send a q command to cleanly shut down rotctld*/ -static gboolean close_rotctld_socket (gint sock) { +static gboolean close_rotctld_socket (gint *sock) { gint written; /*shutdown the rigctld connect*/ - written = send(sock, "q\x0a", 2, 0); + written = send(*sock, "q\x0a", 2, 0); #ifndef WIN32 - shutdown (sock, SHUT_RDWR); + shutdown (*sock, SHUT_RDWR); #else - shutdown (sock, SD_BOTH); + shutdown (*sock, SD_BOTH); #endif - close (sock); + close (*sock); + + *sock=0; return TRUE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-26 00:48:16
|
Revision: 722 http://gpredict.svn.sourceforge.net/gpredict/?rev=722&view=rev Author: aa1vs Date: 2010-11-26 00:48:09 +0000 (Fri, 26 Nov 2010) Log Message: ----------- Move rotor to end of pass if below horizon and after current pass Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2010-11-24 20:47:25 UTC (rev 721) +++ trunk/src/gtk-rot-ctrl.c 2010-11-26 00:48:09 UTC (rev 722) @@ -870,6 +870,8 @@ gdouble setaz,setel; gchar *text; gboolean error = FALSE; + gboolean update_flag=FALSE; + sat_t sat_working, *sat; if (g_static_mutex_trylock(&(ctrl->busy))==FALSE) { @@ -881,34 +883,29 @@ range, set the rotor position controller knob values to the target values. If the target satellite is out of range set the rotor controller to 0 deg El and to the Az where the - target sat is expected to come up + target sat is expected to come up or where it last went down */ if (ctrl->tracking && ctrl->target) { if (ctrl->target->el < 0.0) { - gdouble aosaz = 0.0; - gdouble aosel = 0.0; - if (ctrl->pass != NULL) { - aosaz = ctrl->pass->aos_az; - /* if this is a flipped pass and the rotor supports it*/ - if ((ctrl->flipped)&&(ctrl->conf->maxel>=180.0)){ - aosel=180; - if (aosaz>180) - aosaz-=180; - else - aosaz+=180; + if (ctrl->t < ctrl->pass->aos) { + setaz=ctrl->pass->aos_az; + setel=0; + update_flag=TRUE; + } else if (ctrl->t > ctrl->pass->los) { + setaz=ctrl->pass->los_az; + setel=0; + update_flag=TRUE; } - - if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && (aosaz > 180.0)) { - aosaz -= 360.0; - } } - gtk_rot_knob_set_value (GTK_ROT_KNOB (ctrl->AzSet), aosaz); - gtk_rot_knob_set_value (GTK_ROT_KNOB (ctrl->ElSet), aosel); } - else { + else { setaz=ctrl->target->az; setel=ctrl->target->el; + update_flag=TRUE; + } + if (update_flag){ + /* if this is a flipped pass and the rotor supports it*/ if ((ctrl->flipped)&&(ctrl->conf->maxel>=180.0)){ setel=180-setel; if (setaz>180) @@ -916,17 +913,15 @@ else setaz+=180; } - - if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && - (setaz > 180.0)) { + + if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && (setaz > 180.0)) { gtk_rot_knob_set_value (GTK_ROT_KNOB (ctrl->AzSet), setaz- 360.0); } else { gtk_rot_knob_set_value (GTK_ROT_KNOB (ctrl->AzSet), setaz); } - gtk_rot_knob_set_value (GTK_ROT_KNOB (ctrl->ElSet), setel); + gtk_rot_knob_set_value (GTK_ROT_KNOB (ctrl->ElSet), setel); } - } if ((ctrl->engaged) && (ctrl->conf != NULL)) { @@ -962,6 +957,7 @@ setel = gtk_rot_knob_get_value (GTK_ROT_KNOB (ctrl->ElSet)); if ((fabs(setaz-rotaz) > ctrl->tolerance) || (fabs(setel-rotel) > ctrl->tolerance)) { + /* send controller values to rotator device */ if (!set_pos (ctrl, setaz, setel)) { error = TRUE; @@ -1310,9 +1306,9 @@ size = strlen(buff); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%s: Sending %d bytes as %s."), - __FILE__, __FUNCTION__, size, buff); + //sat_log_log (SAT_LOG_LEVEL_DEBUG, + // _("%s:%s: Sending %d bytes as %s."), + // __FILE__, __FUNCTION__, size, buff); /* send command */ @@ -1346,9 +1342,9 @@ __FILE__, __FUNCTION__); } else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%s: Read %d bytes as %s from rotctld"), - __FILE__, __FUNCTION__, size, buffout); + //sat_log_log (SAT_LOG_LEVEL_DEBUG, + // _("%s:%s: Read %d bytes as %s from rotctld"), + // __FILE__, __FUNCTION__, size, buffout); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-01-27 00:36:10
|
Revision: 746 http://gpredict.svn.sourceforge.net/gpredict/?rev=746&view=rev Author: aa1vs Date: 2011-01-27 00:36:02 +0000 (Thu, 27 Jan 2011) Log Message: ----------- Fixed typo bug in rot controller. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-01-26 23:16:18 UTC (rev 745) +++ trunk/src/gtk-rot-ctrl.c 2011-01-27 00:36:02 UTC (rev 746) @@ -1001,7 +1001,7 @@ else sat->az += 180.0; } - if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && (setaz > 180.0)) { + if ((ctrl->conf->aztype == ROT_AZ_TYPE_180) && (sat->az > 180.0)) { sat->az = sat->az - 360.0; } if ((sat->el < 0.0)||(sat->el > 180.0)|| This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-01-27 17:21:17
|
Revision: 750 http://gpredict.svn.sourceforge.net/gpredict/?rev=750&view=rev Author: aa1vs Date: 2011-01-27 17:21:11 +0000 (Thu, 27 Jan 2011) Log Message: ----------- Cleanup code. Ensure satellite position refined. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-01-27 02:50:50 UTC (rev 749) +++ trunk/src/gtk-rot-ctrl.c 2011-01-27 17:21:11 UTC (rev 750) @@ -867,10 +867,9 @@ { GtkRotCtrl *ctrl = GTK_ROT_CTRL (data); gdouble rotaz=0.0, rotel=0.0; - gdouble setaz=0.0, setel=0.0; + gdouble setaz=0.0, setel=45.0; gchar *text; gboolean error = FALSE; - gboolean update_flag=FALSE; sat_t sat_working, *sat; /*parameters for path predictions*/ gdouble time_delta; @@ -894,18 +893,15 @@ if (ctrl->t < ctrl->pass->aos) { setaz=ctrl->pass->aos_az; setel=0; - update_flag=TRUE; } else if (ctrl->t > ctrl->pass->los) { setaz=ctrl->pass->los_az; setel=0; - update_flag=TRUE; } } } else { setaz=ctrl->target->az; setel=ctrl->target->el; - update_flag=TRUE; } /* if this is a flipped pass and the rotor supports it*/ if ((ctrl->flipped)&&(ctrl->conf->maxel>=180.0)){ @@ -981,7 +977,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; /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-02-16 12:31:48
|
Revision: 766 http://gpredict.svn.sourceforge.net/gpredict/?rev=766&view=rev Author: aa1vs Date: 2011-02-16 12:31:41 +0000 (Wed, 16 Feb 2011) Log Message: ----------- Remove Hamlib error checking from rotator to allow ST-1 to work Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-02-15 02:57:39 UTC (rev 765) +++ trunk/src/gtk-rot-ctrl.c 2011-02-16 12:31:41 UTC (rev 766) @@ -1114,7 +1114,8 @@ /* try to read answer */ if (retcode) { if (strncmp(buffback,"RPRT",4)==0){ - retcode=FALSE; + //retcode=FALSE; + g_strstrip (buffback); sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: rotctld returned error (%s)"), __FILE__, __LINE__,buffback); @@ -1125,10 +1126,11 @@ *az = g_strtod (vbuff[0], NULL); *el = g_strtod (vbuff[1], NULL); } else { + g_strstrip (buffback); sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: rotctld returned bad response (%s)"), __FILE__, __LINE__,buffback); - retcode=FALSE; + //retcode=FALSE; } g_strfreev (vbuff); @@ -1177,56 +1179,14 @@ case 0: /*no error case*/ break; - case -1: - /*RIG_EINVAL error*/ - /* - Returned by gs232 (-m 601) driver when value sent to - rotator outside configured range. - Based on author's experiment. - */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: rotctld returned error %d (%s). Check the limits in your configuration."), - __FILE__, __LINE__, retval, buffback); - - - retcode=FALSE; - break; - - case -5: - /*RIG_ETIMEOUT error*/ - /* - Returned by ea4tx interface when stuck - Based on comments on hamlib-discussion list. - */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: rotctld returned error %d (%s)."), - __FILE__, __LINE__, retval, buffback); - - - retcode=FALSE; - break; - - - case -8: - /*RIG_EPROTO error*/ - /* - Returned by gs232 (-m 601) driver when interface is turned off - Based on author's experiment. - */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: rotctld returned error %d (%s). Check that interface power on."), - __FILE__, __LINE__, retval, buffback); - - - retcode=FALSE; - break; - default: /*any other case*/ /*not sure what is a hard error or soft error*/ + /*over time a database of this is needed*/ + g_strstrip (buffback); sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: rotctld returned error %d (%s)"), - __FILE__, __LINE__, retval, buffback); + _("%s:%d: rotctld returned error %d with az %f el %f(%s)"), + __FILE__, __LINE__, retval, az, el, buffback); //retcode=FALSE; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-10-05 00:41:58
|
Revision: 916 http://gpredict.svn.sourceforge.net/gpredict/?rev=916&view=rev Author: aa1vs Date: 2011-10-05 00:41:52 +0000 (Wed, 05 Oct 2011) Log Message: ----------- Eliminate compiler warning. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-10-03 10:27:48 UTC (rev 915) +++ trunk/src/gtk-rot-ctrl.c 2011-10-05 00:41:52 UTC (rev 916) @@ -1444,7 +1444,7 @@ /** \brief Compute if a pass is flipped or not. this is a function of the rotator and the particular pass. */ static gboolean is_flipped_pass (pass_t * pass,rot_az_type_t type){ - gdouble max_az,min_az; + gdouble max_az = 0,min_az = 0; gdouble caz,last_az=pass->aos_az; guint num,i; pass_detail_t *detail; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |