|
|
|
@ -178,8 +178,7 @@ gboolean mbcli_thread_cb_net(gpointer data) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *statusbar = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_statusbar"));
|
|
|
|
mbcli_statusline ((char*)"got data");
|
|
|
|
gtk_label_set_label(GTK_LABEL(statusbar), (char*)"got data");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free (res);
|
|
|
|
free (res);
|
|
|
|
return FALSE;
|
|
|
|
return FALSE;
|
|
|
|
@ -216,16 +215,49 @@ void displayerror (std::string error) {
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* display last four lines of error message
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define STATUS_LEN 1024
|
|
|
|
|
|
|
|
#define STATUS_LINES 2
|
|
|
|
|
|
|
|
void mbcli_statusline(char *txt) {
|
|
|
|
|
|
|
|
char *oldoldtext, *oldtext;
|
|
|
|
|
|
|
|
char *p[STATUS_LINES], *l;
|
|
|
|
|
|
|
|
char newtext[STATUS_LEN];
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < STATUS_LINES; i++) p[i] = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *statusbarold = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_statusbarold"));
|
|
|
|
|
|
|
|
GtkWidget *statusbar = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_statusbar"));
|
|
|
|
|
|
|
|
oldoldtext = (char*) gtk_label_get_text(GTK_LABEL(statusbarold));
|
|
|
|
|
|
|
|
oldtext = (char*) gtk_label_get_text(GTK_LABEL(statusbar));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (l = oldoldtext; l != NULL; l = strchr(l+1, '\n')) {
|
|
|
|
|
|
|
|
for (i = 1; i < STATUS_LINES; i++) p[i-1] = p[i];
|
|
|
|
|
|
|
|
p[STATUS_LINES-1] = l;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (p[0] != NULL) {
|
|
|
|
|
|
|
|
snprintf (newtext, STATUS_LEN, "%s\n%s", p[0]+1, oldtext);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
snprintf (newtext, STATUS_LEN, "%s\n%s", oldoldtext, oldtext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gtk_label_set_label(GTK_LABEL(statusbarold), (char*)newtext);
|
|
|
|
|
|
|
|
gtk_label_set_label(GTK_LABEL(statusbar), (char*)txt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* network thread callback
|
|
|
|
* network thread callback
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
gboolean mbcli_thread_cb_status(gpointer data) {
|
|
|
|
gboolean mbcli_thread_cb_status(gpointer data) {
|
|
|
|
GtkWidget *statusbar = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_statusbar"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mbcli_connect_btn_sensitive (netthread.GetState() == NWT_nothing);
|
|
|
|
mbcli_connect_btn_sensitive (netthread.GetState() == NWT_nothing);
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
gtk_label_set_label(GTK_LABEL(statusbar), (char*)data);
|
|
|
|
mbcli_statusline ((char*)data);
|
|
|
|
free (data);
|
|
|
|
free (data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -353,8 +385,8 @@ void mbcli_set_update (int active) {
|
|
|
|
* returns status of the dont_use_FC1516 button
|
|
|
|
* returns status of the dont_use_FC1516 button
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int mbcli_get_FC1516 () {
|
|
|
|
int mbcli_get_FC1516 () {
|
|
|
|
GtkWidget *tb_update = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_dontuse_FC1516"));
|
|
|
|
// GtkWidget *tb_update = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_dontuse_FC1516"));
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tb_update))) return 1;
|
|
|
|
// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tb_update))) return 1;
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -386,28 +418,22 @@ gboolean mbcli_refreshtimeout(gpointer data) {
|
|
|
|
int unitid = mbcli_get_unitid();
|
|
|
|
int unitid = mbcli_get_unitid();
|
|
|
|
int state = netthread.GetState();
|
|
|
|
int state = netthread.GetState();
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *statusbar = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_statusbar"));
|
|
|
|
|
|
|
|
GtkWidget *rate = GTK_WIDGET (gtk_builder_get_object (_builder_, "cli_rate"));
|
|
|
|
|
|
|
|
char txt[255];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
|
|
if (state == NWT_running) {
|
|
|
|
if (state == NWT_running) {
|
|
|
|
num_requests++;
|
|
|
|
num_requests++;
|
|
|
|
if (netthread.SendRequestRead(unitid, fc, reg, num) == 0) {
|
|
|
|
if (netthread.SendRequestRead(unitid, fc, reg, num) == 0) {
|
|
|
|
num_errors++;
|
|
|
|
num_errors++;
|
|
|
|
gtk_label_set_label(GTK_LABEL(statusbar), "busy, another request in progress");
|
|
|
|
mbcli_statusline ((char*)"Busy, another request in progress. Close connection.");
|
|
|
|
|
|
|
|
netthread.Disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
gtk_label_set_label(GTK_LABEL(statusbar), "request send");
|
|
|
|
mbcli_statusline ((char*)"request send");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snprintf (txt, 255, "%d / %d", num_errors, num_requests);
|
|
|
|
|
|
|
|
gtk_label_set_label(GTK_LABEL(rate), txt);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
gtk_label_set_label(GTK_LABEL(rate), "- / -");
|
|
|
|
|
|
|
|
if (mbcli_get_autoconnect()) mbcli_cb_connect(NULL, NULL); // reconnect if needed
|
|
|
|
if (mbcli_get_autoconnect()) mbcli_cb_connect(NULL, NULL); // reconnect if needed
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|