This commit is contained in:
Olaf Rempel 2008-03-16 00:39:37 +01:00
parent f5d8287cc6
commit 506f2f3d59
2 changed files with 23 additions and 7 deletions

View File

@ -6,6 +6,10 @@
#include "tcpsocket.h"
#include "sockaddr.h"
int tdc_parse_data(int fd);
void tdc_flush_vars(void);
void tdc_send_hello(int fd);
enum {
STAT_DISCONNECTED = 0,
STAT_CONNECTING,
@ -28,16 +32,13 @@ static void update_connect_button(void)
static void read_cb(gpointer data, gint source, GdkInputCondition condition)
{
char buf[64];
int len = read(source, buf, sizeof(buf));
if (len <= 0) {
if (tdc_parse_data(source) <= 0) {
g_warning("gtdc:read_cb:read:%s", g_strerror(errno));
connect_status = STAT_DISCONNECTED;
update_connect_button();
gdk_input_remove(socket_tag);
close(socket_fd);
close(source);
}
}
@ -54,8 +55,8 @@ static void connect_cb(gpointer data, gint source, GdkInputCondition condition)
connect_status = STAT_CONNECTED;
socket_tag = gdk_input_add(socket_fd, GDK_INPUT_READ, read_cb, NULL);
//TODO: clear variable data
//TODO: send TDC_HELLO
tdc_flush_vars();
tdc_send_hello(source);
}
update_connect_button();
@ -95,6 +96,16 @@ gint control_tab_init(GtkNotebook *notebook)
gtk_table_attach(GTK_TABLE(table), button_connect, 0, 1, 0, 1, 0, 0, 10, 10);
g_signal_connect(G_OBJECT(button_connect), "clicked", G_CALLBACK(connect_button_cb), NULL);
/*
* TODO:
* - address field
* - all_variable_refresh_timer
* - graph_variable_refresh_timer
* later:
* - board select
* - connection/protocol details/errors
*/
GtkWidget *label = gtk_label_new(" Control ");
return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
}

View File

@ -31,6 +31,11 @@ gint graph_tab_init(GtkNotebook *notebook)
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
gtk_databox_set_vruler(GTK_DATABOX(box), GTK_RULER(ruler));
/*
* TODO:
* komplette datenhaltung.. (wie skalieren?)
* legende der graphen
*/
GtkWidget *label = gtk_label_new(" Graph ");
return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);