Esempio n. 1
0
EXPORT gboolean ms1_tlogger_button_handler(GtkWidget * widget, gpointer data)
{
	gint handler = (GINT)OBJ_GET(widget, "handler");

	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
	{       /* It's pressed (or checked) */
		switch ((ToggleButton)handler)
		{

			case START_TOOTHMON_LOGGER:
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("triggerlogger_buttons_table")),FALSE);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				start_tickler(TOOTHMON_TICKLER);
				break;
			case START_TRIGMON_LOGGER:
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("toothlogger_buttons_table")),FALSE);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				start_tickler(TRIGMON_TICKLER);
				break;
			case STOP_TOOTHMON_LOGGER:
				stop_tickler(TOOTHMON_TICKLER);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("triggerlogger_buttons_table")),TRUE);
				break;
			case STOP_TRIGMON_LOGGER:
				stop_tickler(TRIGMON_TICKLER);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("toothlogger_buttons_table")),TRUE);
				break;
			default:
				break;
		}
	}
	return TRUE;
}
Esempio n. 2
0
/*!
  \brief logviewer generic button event handler
  \param widget is the pointer to button
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean logviewer_button_event(GtkWidget *widget, gpointer data)
{
	Lv_Handler handler;
	GtkWidget *tmpwidget = NULL;
	handler = (Lv_Handler)(GINT)OBJ_GET(widget,"handler");
	switch(handler)
	{
		case LV_GOTO_START:
			tmpwidget = lookup_widget("logviewer_log_position_hscale");
			if (GTK_IS_RANGE(tmpwidget))
				gtk_range_set_value(GTK_RANGE(tmpwidget),0.0);
			break;
		case LV_GOTO_END:
			tmpwidget = lookup_widget("logviewer_log_position_hscale");
			if (GTK_IS_RANGE(tmpwidget))
				gtk_range_set_value(GTK_RANGE(tmpwidget),100.0);
			break;
		case LV_PLAY:
			start_tickler(LV_PLAYBACK_TICKLER);
			break;
		case LV_STOP:
			stop_tickler(LV_PLAYBACK_TICKLER);
			break;
		case LV_REWIND:
			printf("rewind\n");
			break;
		case LV_FAST_FORWARD:
			printf("fast forward\n");
			break;
		default:
			break;

	}
	return TRUE;
}
Esempio n. 3
0
/*!
  \brief changes scroll speed for logviewer playback
  \param widget is the pointer to the range widget representing the scroll speed
  \param data is unused
  \returns TRUE to indicate the event is handled
  */
G_MODULE_EXPORT gboolean logviewer_scroll_speed_change(GtkWidget *widget, gpointer data)
{
	gfloat tmpf = 0.0;
	extern gconstpointer *global_data;

	tmpf = gtk_range_get_value(GTK_RANGE(widget));
	DATA_SET(global_data,"lv_scroll_delay", GINT_TO_POINTER((GINT)tmpf));
	if (DATA_GET(global_data,"playback_id"))
	{
		stop_tickler(LV_PLAYBACK_TICKLER);
		start_tickler(LV_PLAYBACK_TICKLER);
	}

	return TRUE;
}
Esempio n. 4
0
/*!
  \brief set_logviewer_mode() sets things up for playback mode
  \param mode Enumeration defining the logviewr mode (live or playback)
  */
G_MODULE_EXPORT void set_logviewer_mode(Lv_Mode mode)
{
	GtkWidget *widget = NULL;

	reset_logviewer_state();
	free_log_info(DATA_GET(global_data,"log_info"));
	if (mode == LV_PLAYBACK)
	{
		DATA_SET(global_data,"playback_mode",GINT_TO_POINTER(TRUE));
		gtk_widget_set_sensitive(lookup_widget("logviewer_select_logfile_button"), TRUE);
		gtk_widget_set_sensitive(lookup_widget("logviewer_select_params_button"), FALSE);
		gtk_widget_hide(lookup_widget("logviewer_rt_control_vbox1"));
		/* This one should NOT be enabled until at least 1 var is selected */
		gtk_widget_show(lookup_widget("logviewer_playback_control_vbox1"));
		gtk_widget_show(lookup_widget("scroll_speed_vbox"));

		widget = lookup_widget("logviewer_log_position_hscale");
		if (GTK_IS_RANGE(widget))
			gtk_range_set_value(GTK_RANGE(widget),0.0);
		hue = -60.0;
		col_sat = 1.0;
		col_val = 1.0;
	}
	else if (mode == LV_REALTIME)
	{
		enable_playback_controls(FALSE);

		stop_tickler(LV_PLAYBACK_TICKLER);
		DATA_SET(global_data,"playback_mode",GINT_TO_POINTER(FALSE));
		gtk_widget_set_sensitive(lookup_widget("logviewer_select_logfile_button"), FALSE);
		gtk_widget_set_sensitive(lookup_widget("logviewer_select_params_button"), TRUE);
		gtk_widget_show(lookup_widget("logviewer_rt_control_vbox1"));
		gtk_widget_hide(lookup_widget("logviewer_playback_control_vbox1"));
		gtk_widget_hide(lookup_widget("scroll_speed_vbox"));
		widget = lookup_widget("logviewer_log_position_hscale");
		if (GTK_IS_RANGE(widget))
			gtk_range_set_value(GTK_RANGE(widget),100.0);
		hue = -60.0;
		col_sat = 1.0;
		col_val = 1.0;
	}
}
Esempio n. 5
0
/*!
  \brief logviewer_log_position_change() gets called when the log position 
  slider is moved by the user to fast forware/rewind through a datalog
  \param widget is the widget that received the event
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean logviewer_log_position_change(GtkWidget * widget, gpointer data)
{
	gfloat val = 0.0;
	GtkWidget *darea = NULL;

	/* If we pass "TRUE" as the widget data we just ignore this signal as 
	 * the redraw routine wil have to adjsut the slider as it scrolls 
	 * through the data...
	 */
	if ((GBOOLEAN)data)
		return TRUE;
	if (blocked)
		return TRUE;

	val = gtk_range_get_value(GTK_RANGE(widget));
	darea = lookup_widget("logviewer_trace_darea");
	if (GTK_IS_WIDGET(darea))
		OBJ_SET(darea,"log_pos_x100",GINT_TO_POINTER((GINT)(val*100)));
	lv_configure_event(darea,NULL,NULL);
	scroll_logviewer_traces();
	if ((val >= 100.0) && (DATA_GET(global_data,"playback_mode")))
		stop_tickler(LV_PLAYBACK_TICKLER);
	return TRUE;
}
Esempio n. 6
0
gboolean lookuptable_change(GtkCellRenderer *renderer, gchar *path, gchar * new_text, gpointer data)
{
	GtkListStore *store = NULL;
	GtkTreeIter iter;
	GtkTreeModel *model = data;
	ConfigFile *cfgfile = NULL;
	gchar * int_name = NULL;
	gchar * old = NULL;
	gchar * new_name = NULL;
	gchar ** vector = NULL;
	gboolean restart_tickler = FALSE;
	extern gint realtime_id;
	extern GHashTable *lookuptables;
	extern GAsyncQueue *io_data_queue;
	extern Firmware_Details *firmware;
	gint count = 0;
	LookupTable *lookuptable = NULL;

	/* Get combo box model so we can set the combo to this new value */
	g_object_get(G_OBJECT(renderer),"model",&store,NULL);
	gtk_tree_model_get_iter_from_string(model,&iter,path);
	gtk_tree_model_get(model,&iter,INTERNAL_NAME_COL,&int_name,FILENAME_COL,&old,-1);
	if (g_strcasecmp(old,new_text) == 0) /* If no change, return */
		return TRUE;
	
	if (g_strcasecmp(new_text,"Personal") == 0)
		return TRUE;
	if (g_strcasecmp(new_text,"System") == 0)
		return TRUE;
	if (realtime_id)
	{
		restart_tickler = TRUE;
		stop_tickler(RTV_TICKLER);
		count = 0;
		while ((g_async_queue_length(io_data_queue) > 0) && (count < 30))
		{
			dbg_func(CRITICAL,g_strdup_printf(__FILE__": LEAVE() draining I/O Queue,  current length %i\n",g_async_queue_length(io_data_queue)));
			while (gtk_events_pending())
				gtk_main_iteration();
			count++;
		}

	}
	lookuptable = (LookupTable *)g_hash_table_lookup(lookuptables,int_name);
	if (!lookuptable)
		printf(_("No lookuptable found! expect a crash!!\n"));
	g_free(lookuptable->array); /* Free the old one */
	g_free(lookuptable->filename); /* Free the old one */
	g_free(lookuptable); /* Free the old one */
	get_table(int_name,new_text,NULL); /* Load the new one in it's place */
	gtk_list_store_set(GTK_LIST_STORE(model),&iter, FILENAME_COL, new_text,-1);
	if (restart_tickler)
		start_tickler(RTV_TICKLER);

		cfgfile = cfg_open_file(firmware->profile_filename);
		if (!cfgfile)
			return FALSE;
		g_hash_table_foreach(lookuptables,update_lt_config,cfgfile);
	if (g_strrstr(firmware->profile_filename,".MegaTunix"))
		cfg_write_file(cfgfile, firmware->profile_filename);
	else
	{
		vector = g_strsplit(firmware->profile_filename,PSEP,-1);
		new_name = g_build_filename(HOME(),".MegaTunix",INTERROGATOR_DATA_DIR,"Profiles",vector[g_strv_length(vector)-1],NULL);
		g_strfreev(vector);
		cfg_write_file(cfgfile, new_name);
		g_free(firmware->profile_filename);
		firmware->profile_filename=g_strdup(new_name);
		g_free(new_name);
	}
	cfg_free(cfgfile);
		
	/*printf("internal name %s, old table %s, new table %s\n",int_name,old,new_text);*/
	return TRUE;

}
Esempio n. 7
0
/*!
  \brief trace_update() updates a trace onscreen,  this is run for EACH 
  individual trace (yeah, not very optimized)
  \param redraw_all flag to redraw all or just recent data
  */
G_MODULE_EXPORT void trace_update(gboolean redraw_all)
{
	GdkPixmap * pixmap = NULL;
	gint w = 0;
	gint h = 0;
	gfloat val = 0.0;
	gfloat last_val = 0.0;
	gfloat percent = 0.0;
	gfloat last_percent = 0.0;
	gint len = 0;
	gint lo_width;
	gint total = 0;
	guint last_index = 0;
	guint i = 0;
	gint j = 0;
	gint x = 0;
	gfloat log_pos = 0.0;
	gfloat newpos = 0.0;
	GArray *array = NULL;
	GdkPoint pts[2048]; /* Bad idea as static...*/
	Viewable_Value *v_value = NULL;
	gint lv_zoom;
	/*static gulong sig_id = 0;*/
	static GtkWidget *scale = NULL;
	GtkAllocation allocation;

	gtk_widget_get_allocation(lv_data->darea,&allocation);

	pixmap = lv_data->pixmap;

	lv_zoom = (GINT)DATA_GET(global_data,"lv_zoom");
	/*
	if (sig_id == 0)
		sig_id = g_signal_handler_find(lookup_widget("logviewer_log_position_hscale"),G_SIGNAL_MATCH_FUNC,0,0,NULL,(gpointer)logviewer_log_position_change,NULL);
		*/

	if (!scale)
		scale = lookup_widget("logviewer_log_position_hscale");
	w = allocation.width;
	h = allocation.height;

	log_pos = (gfloat)((GINT)OBJ_GET(lv_data->darea,"log_pos_x100"))/100.0;
	/*printf("log_pos is %f\n",log_pos);*/
	/* Full screen redraw, only with configure events (usually) */
	if ((GBOOLEAN)redraw_all)
	{
		lo_width = allocation.width-lv_data->info_width;
		for (i=0;i<g_list_length(lv_data->tlist);i++)
		{
			v_value = (Viewable_Value *)g_list_nth_data(lv_data->tlist,i);
			array = DATA_GET(v_value->object,v_value->data_source);
			len = array->len;
			if (len == 0)	/* If empty */
			{
				return;
			}
			/*printf("length is %i\n", len);*/
			len *= (log_pos/100.0);
			/*printf("length after is  %i\n", len);*/
			/* Determine total number of points 
			 * that'll fit on the window
			 * taking into account the scroll amount
			 */
			total = len < lo_width/lv_zoom ? len : lo_width/lv_zoom;


			/* Draw is reverse order, from right to left, 
			 * easier to think out in my head... :) 
			 */
			for (x=0;x<total;x++)
			{
				val = g_array_index(array,gfloat,len-1-x);
				percent = 1.0-(val/(float)(v_value->upper-v_value->lower));
				pts[x].x = w-(x*lv_zoom)-1;
				pts[x].y = (GINT) (percent*(h-2))+1;
			}
			gdk_draw_lines(pixmap,
					v_value->trace_gc,
					pts,
					total);
			if (v_value->highlight)
			{
				for (j=0;j<total;j++)	
					pts[j].y -= 1;
				gdk_draw_lines(pixmap,
						gtk_widget_get_style(lv_data->darea)->white_gc,
						pts,
						total);
				for (j=0;j<total;j++)	
					pts[j].y += 2;
				gdk_draw_lines(pixmap,
						gtk_widget_get_style(lv_data->darea)->white_gc,
						pts,
						total);
			}

			v_value->last_y = pts[0].y;
			v_value->last_index = len-1;

			/*printf ("last index displayed was %i from %i,%i to %i,%i\n",v_value->last_index,pts[1].x,pts[1].y, pts[0].x,pts[0].y );*/
		}
		draw_valtext(TRUE);
		/*printf("redraw complete\n");*/
		return;
	}
	/* Playback mode, playing from logfile.... */
	if (DATA_GET(global_data,"playback_mode"))
	{
		for (i=0;i<g_list_length(lv_data->tlist);i++)
		{
			v_value = (Viewable_Value *)g_list_nth_data(lv_data->tlist,i);
			array = DATA_GET(v_value->object,v_value->data_source);
			last_index = v_value->last_index;
			if(last_index >= array->len)
				return;

			/*printf("got data from array at index %i\n",last_index+1);*/
			val = g_array_index(array,gfloat,last_index+1);
			percent = 1.0-(val/(float)(v_value->upper-v_value->lower));
			if (val > (v_value->max))
				v_value->max = val;
			if (val < (v_value->min))
				v_value->min = val;

			gdk_draw_line(pixmap,
					v_value->trace_gc,
					w-lv_zoom-1,v_value->last_y,
					w-1,(GINT)(percent*(h-2))+1);
			/*printf("drawing from %i,%i to %i,%i\n",w-lv_zoom-1,v_value->last_y,w-1,(GINT)(percent*(h-2))+1);*/

			v_value->last_y = (GINT)((percent*(h-2))+1);

			v_value->last_index = last_index + 1;
			if (adj_scale)
			{
				newpos = 100.0*((gfloat)(v_value->last_index)/(gfloat)array->len);
				blocked=TRUE;
				gtk_range_set_value(GTK_RANGE(scale),newpos);
				blocked=FALSE;
				OBJ_SET(lv_data->darea,"log_pos_x100",GINT_TO_POINTER((GINT)(newpos*100.0)));
				adj_scale = FALSE;
				if (newpos >= 100)
					stop_tickler(LV_PLAYBACK_TICKLER);
				/*	printf("playback reset slider to position %i\n",(GINT)(newpos*100.0));*/
			}
			if (v_value->highlight)
			{
				gdk_draw_line(pixmap,
						gtk_widget_get_style(lv_data->darea)->white_gc,
						w-lv_zoom-1,v_value->last_y-1,
						w-1,(GINT)(percent*(h-2)));
				gdk_draw_line(pixmap,
						gtk_widget_get_style(lv_data->darea)->white_gc,
						w-lv_zoom-1,v_value->last_y+1,
						w-1,(GINT)(percent*(h-2))+2);
			}
		}
		draw_valtext(FALSE);
		return;
	}

	/* REALTIME mode... all traces updated at once.. */
	for (i=0;i<g_list_length(lv_data->tlist);i++)
	{
		v_value = (Viewable_Value *)g_list_nth_data(lv_data->tlist,i);
		array = DATA_GET(v_value->object,v_value->data_source);
		val = g_array_index(array,gfloat, array->len-1);

		if (val > (v_value->max))
			v_value->max = val;
		if (val < (v_value->min))
			v_value->min = val;

		if (v_value->last_y == -1)
			v_value->last_y = (GINT)((percent*(h-2))+1);

		/* If watching at the edge (full realtime) */
		if (log_pos >= 100)
		{
			v_value->last_index = array->len-1;
			percent = 1.0-(val/(float)(v_value->upper-v_value->lower));
			gdk_draw_line(pixmap,
					v_value->trace_gc,
					w-lv_zoom-1,v_value->last_y,
					w-1,(GINT)(percent*(h-2))+1);
		}
		else
		{	/* Watching somewhat behind realtime... */
			last_index = v_value->last_index;

			last_val = g_array_index(array,gfloat,last_index);
			last_percent = 1.0-(last_val/(float)(v_value->upper-v_value->lower));
			val = g_array_index(array,gfloat,last_index+1);
			percent = 1.0-(val/(float)(v_value->upper-v_value->lower));

			v_value->last_index = last_index + 1;
			gdk_draw_line(pixmap,
					v_value->trace_gc,
					w-lv_zoom-1,(last_percent*(h-2))+1,
					w-1,(GINT)(percent*(h-2))+1);
			if (adj_scale)
			{
				newpos = 100.0*((gfloat)v_value->last_index/(gfloat)array->len);
				blocked = TRUE;
				gtk_range_set_value(GTK_RANGE(scale),newpos);
				blocked = FALSE;
				OBJ_SET(lv_data->darea,"log_pos_x100",GINT_TO_POINTER((GINT)(newpos*100.0)));
				adj_scale = FALSE;
			}
		}
		/* Draw the data.... */
		v_value->last_y = (GINT)((percent*(h-2))+1);
		if (v_value->highlight)
		{
			gdk_draw_line(pixmap,
					gtk_widget_get_style(lv_data->darea)->white_gc,
					w-lv_zoom-1,v_value->last_y-1,
					w-1,(GINT)(percent*(h-2)));
			gdk_draw_line(pixmap,
					gtk_widget_get_style(lv_data->darea)->white_gc,
					w-lv_zoom-1,v_value->last_y+1,
					w-1,(GINT)(percent*(h-2))+2);
		}
	}
	/* Update textual data */
	draw_valtext(FALSE);
}
Esempio n. 8
0
//G_MODULE_EXPORT gboolean lookuptable_changed(GtkCellRendererCombo *renderer, gchar *path, gchar * new_text, gpointer data)
G_MODULE_EXPORT gboolean lookuptable_changed(GtkCellRendererCombo *renderer, gchar *path, GtkTreeIter *new_iter, gpointer data)
{
	GtkTreeModel *combostore = NULL;
	GtkTreeIter iter;
	GtkTreeModel *model = (GtkTreeModel *)data;
	ConfigFile *cfgfile = NULL;
	gchar * new_text = NULL;
	gchar * int_name = NULL;
	gchar * old = NULL;
	gchar * new_name = NULL;
	gchar ** vector = NULL;
	const gchar * project = NULL;
	gboolean restart_tickler = FALSE;
	GAsyncQueue *io_data_queue = NULL;
	Firmware_Details *firmware = NULL;

	ENTER();
	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");
	io_data_queue = (GAsyncQueue *)DATA_GET(global_data,"io_data_queue");

	/* Get combo box model so we can set the combo to this new value */
	g_object_get(G_OBJECT(renderer),"model",&combostore,NULL);
	gtk_tree_model_get(combostore,new_iter,0,&new_text,-1);

	/* Get combo box model so we can set the combo to this new value */
	gtk_tree_model_get_iter_from_string(model,&iter,path);
	gtk_tree_model_get(model,&iter,INTERNAL_NAME_COL,&int_name,FILENAME_COL,&old,-1);
	//printf("New text is %s, int name associated %s, filename %s\n",new_text,int_name,old);
	if (g_ascii_strcasecmp(old,new_text) == 0) /* If no change, return */
	{
		g_free(int_name);
		g_free(old);
		EXIT();
		return TRUE;
	}

	if (g_ascii_strcasecmp(new_text,"Personal") == 0)
	{
		g_free(int_name);
		g_free(old);
		EXIT();
		return TRUE;
	}
	if (g_ascii_strcasecmp(new_text,"System") == 0)
	{
		g_free(int_name);
		g_free(old);
		EXIT();
		return TRUE;
	}
	if (DATA_GET(global_data,"realtime_id"))
	{
		gint count = 0;
		restart_tickler = TRUE;
		stop_tickler(RTV_TICKLER);
		while ((g_async_queue_length(io_data_queue) > 0) && (count < 30))
		{
			MTXDBG(CRITICAL,_("Draining I/O Queue, current length %i\n"),g_async_queue_length(io_data_queue));
			count++;
		}

	}
	get_table(int_name,new_text,NULL); /* Load the new one in it's place */
	gtk_list_store_set(GTK_LIST_STORE(model),&iter, FILENAME_COL, new_text,-1);
	if (restart_tickler)
		start_tickler(RTV_TICKLER);

	cfgfile = cfg_open_file(firmware->profile_filename);
	if (!cfgfile)
	{
		g_free(int_name);
		g_free(old);
		EXIT();
		return FALSE;
	}
	g_hash_table_foreach((GHashTable *)DATA_GET(global_data,"lookuptables"),update_lt_config,cfgfile);
	if (g_strrstr(firmware->profile_filename,"mtx"))
		cfg_write_file(cfgfile, firmware->profile_filename);
	else
	{
		project = (const gchar *)DATA_GET(global_data,"project_name");
		vector = g_strsplit(firmware->profile_filename,PSEP,-1);
		if (!project)
			project = DEFAULT_PROJECT;
		new_name = g_build_filename(HOME(),"mtx",project,INTERROGATOR_DATA_DIR,"Profiles",vector[g_strv_length(vector)-2],vector[g_strv_length(vector)-1],NULL);
		g_strfreev(vector);
		cfg_write_file(cfgfile, new_name);
		g_free(firmware->profile_filename);
		firmware->profile_filename=g_strdup(new_name);
		g_free(new_name);
	}
	cfg_free(cfgfile);

	/*printf("internal name %s, old table %s, new table %s\n",int_name,old,new_text);*/
	g_free(int_name);
	g_free(old);
	EXIT();
	return TRUE;
}