예제 #1
0
/*!
 \brief Firmware specific function that backs up the ECU to a filename passed
 \param filename is the filename to backup the ECU to
 */
G_MODULE_EXPORT void backup_all_ecu_settings(gchar *filename)
{
	ConfigFile *cfgfile;
	gchar * section = NULL;
	gchar * tmpbuf = NULL;
	gint i = 0;
	gint locID = 0;
	gint x = 0;
	gint canID = 0;
	DataSize size = MTX_U08;	 /* <<<<< BAD BAD BAD >>>>> */
	GString *string = NULL;
	extern gconstpointer *global_data;
	Firmware_Details *firmware = NULL;

	firmware = DATA_GET(global_data,"firmware");
	g_return_if_fail(filename);
	g_return_if_fail(firmware);

	cfgfile = cfg_open_file(filename);
	if(!cfgfile)
		cfgfile = cfg_new();

	set_file_api_f(cfgfile,BACKUP_MAJOR_API,BACKUP_MINOR_API);

	update_logbar_f("tools_view",NULL,g_strdup_printf("%s %s\n",_("Full Backup Commencing to file:\n\t"),filename),FALSE,FALSE,TRUE);
	cfg_write_string(cfgfile,"Firmware","name",firmware->name);
	for(i=0;i<firmware->total_pages;i++)
	{
		if (firmware->page_params[i]->read_only)
			continue;
		string = g_string_sized_new(64);
		section = g_strdup_printf("page_%i",i);
		cfg_write_int(cfgfile,section,"num_variables",firmware->page_params[i]->length);
		for(x=0;x<firmware->page_params[i]->length;x++)
		{
			locID = firmware->page_params[i]->phys_ecu_page;
			g_string_append_printf(string,"%i",freeems_get_ecu_data(canID,locID,x,size));
			if (x < (firmware->page_params[i]->length-1))
				string = g_string_append(string,",");
		}
		cfg_write_string(cfgfile,section,"data",string->str);
		g_free(section);
		g_string_free(string,TRUE);
	}
	update_logbar_f("tools_view",NULL,_("Full Backup Complete...\n"),FALSE,FALSE,FALSE);
	cfg_write_file(cfgfile,filename);
	cfg_free(cfgfile);
}
예제 #2
0
void update_lt_config(gpointer key, gpointer value, gpointer data)
{
	ConfigFile *cfgfile = data;
	LookupTable *lookuptable = value;
	/*printf("updating %s, %s, %s\n",cfgfile->filename,(gchar *)key, lookuptable->filename);*/
	cfg_write_string(cfgfile,"lookuptables",(gchar *)key,lookuptable->filename);

}
예제 #3
0
/*!
  \brief updates the interrogation profile with the new default lookuptable
  \param key is the lookuptable name
  \param value is the pointer to LookupTable object
  \param data is the pointer to ConfigFile structure
  */
G_MODULE_EXPORT void update_lt_config(gpointer key, gpointer value, gpointer data)
{
	ENTER();
	ConfigFile *cfgfile = (ConfigFile *)data;
	LookupTable *lookuptable = (LookupTable *)value;
	/*printf("updating %s, %s, %s\n",cfgfile->filename,(gchar *)key, lookuptable->filename);*/
	cfg_write_string(cfgfile,"lookuptables",(gchar *)key,lookuptable->filename);
	EXIT();
	return;
}
예제 #4
0
/*!
  \brief write logviewer defaults to file
  \param cfgfile is the pointer to ConfigFile structure to save the settings to
  */
G_MODULE_EXPORT void write_logviewer_defaults(ConfigFile *cfgfile)
{
	GList * list = NULL;
	gint i = 0;
	gchar * name = NULL;
	GString *string = NULL;

	list = get_list("logviewer_defaults");
	if (list)
	{
		string = g_string_new(NULL);
		for (i=0;i<g_list_length(list);i++)
		{
			name = g_list_nth_data(list,i);
			g_string_append(string,name);
			if (i < (g_list_length(list)-1))
				g_string_append(string,",");
		}
		cfg_write_string(cfgfile,"Logviewer","defaults",string->str);
		g_string_free(string,TRUE);
	}
	else
		cfg_write_string(cfgfile,"Logviewer","defaults","");
}
예제 #5
0
void save_defaults()
{
	ConfigFile *cfgfile;
	gchar * filename = NULL;
	gchar * tmpbuf = NULL;
	filename = g_build_filename(HOME(),"mtx","default","config", NULL);
	cfgfile = cfg_open_file(filename);
	if (cfgfile)
	{
		tmpbuf = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtk_builder_get_object ((GtkBuilder *)DATA_GET(global_data,"builder"), "filechooser_button")));
		if (tmpbuf)
			cfg_write_string(cfgfile, (gchar *)"MTXLoader", (gchar *)"last_file", tmpbuf);
		g_free(tmpbuf);
		cfg_write_file(cfgfile,filename);
		cfg_free(cfgfile);
		g_free(filename);
	}
}
예제 #6
0
파일: init.c 프로젝트: UIKit0/eXtace
void save_config(GtkWidget *widget)
{
	gchar *filename;
	ConfigFile *cfgfile;
	gint x;
	gint y;
	filename = g_strconcat(g_get_home_dir(), "/.eXtace/config", NULL);
	cfgfile = cfg_open_file(filename);
	if (!cfgfile)
		cfgfile = cfg_new();

	cfg_write_int(cfgfile, "Global", "major_ver", _MAJOR_);
	cfg_write_int(cfgfile, "Global", "minor_ver", _MINOR_);
	cfg_write_int(cfgfile, "Global", "micro_ver", _MICRO_);
	if (Color_map.filename)
		cfg_write_string(cfgfile, "Global", "last_colormap", Color_map.filename);
	else
		cfg_write_string(cfgfile, "Global", "last_colormap",g_strconcat(g_get_home_dir(),"/.eXtace/ColorMaps/","Default",NULL));
	cfg_write_int(cfgfile, "Global", "mode", mode);
	cfg_write_int(cfgfile, "Global", "data_source", data_source);
	cfg_write_int(cfgfile, "Global", "decimation_factor", decimation_factor);
	cfg_write_int(cfgfile, "Global", "fft_signal_source", fft_signal_source);
	cfg_write_float(cfgfile, "Global", "scope_zoom", scope_zoom);
	cfg_write_int(cfgfile, "Global", "refresh_rate", refresh_rate);
	cfg_write_int(cfgfile, "Global", "landflip", landflip);
	cfg_write_int(cfgfile, "Global", "spikeflip", spikeflip);
	cfg_write_boolean(cfgfile, "Global", "outlined", outlined);
	cfg_write_int(cfgfile, "Global", "sub_mode_3D", sub_mode_3D);
	cfg_write_int(cfgfile, "Global", "scope_sub_mode", scope_sub_mode);
	cfg_write_boolean(cfgfile, "Global", "dir_win_present", dir_win_present);
	cfg_write_int(cfgfile, "Global", "nsamp", nsamp);
	cfg_write_int(cfgfile, "Global", "window_func", window_func);
	cfg_write_int(cfgfile, "Global", "win_width", win_width);
	cfg_write_int(cfgfile, "Global", "axis_type", axis_type);
	cfg_write_int(cfgfile, "Global", "bands", bands);
	cfg_write_int(cfgfile, "Global", "lag", lag);
	cfg_write_float(cfgfile, "Global", "noise_floor", noise_floor);
	cfg_write_int(cfgfile, "Global", "seg_height", seg_height);
	cfg_write_int(cfgfile, "Global", "seg_space", seg_space);
	cfg_write_boolean(cfgfile, "Global", "bar_decay", bar_decay);
	cfg_write_boolean(cfgfile, "Global", "peak_decay", peak_decay);
	cfg_write_boolean(cfgfile, "Global", "stabilized", stabilized);
	cfg_write_boolean(cfgfile, "Global", "show_graticule", show_graticule);
	cfg_write_int(cfgfile, "Global", "decay_speed", bar_decay_speed);
	cfg_write_int(cfgfile, "Global", "peak_decay_speed", peak_decay_speed);
	cfg_write_int(cfgfile, "Global", "peak_hold_time", peak_hold_time);
	cfg_write_int(cfgfile, "Global", "tape_scroll", tape_scroll);
	cfg_write_int(cfgfile, "Global", "xdet_scroll", xdet_scroll);
	cfg_write_int(cfgfile, "Global", "zdet_scroll", zdet_scroll);
	cfg_write_float(cfgfile, "Global", "xdet_start", xdet_start);
	cfg_write_float(cfgfile, "Global", "xdet_end", xdet_end);
	cfg_write_float(cfgfile, "Global", "ydet_start", ydet_start);
	cfg_write_float(cfgfile, "Global", "ydet_end", ydet_end);
	cfg_write_float(cfgfile, "Global", "x3d_start", x3d_start);
	cfg_write_float(cfgfile, "Global", "x3d_end", x3d_end);
	cfg_write_float(cfgfile, "Global", "y3d_start", y3d_start);
	cfg_write_float(cfgfile, "Global", "y3d_end", y3d_end);
	cfg_write_float(cfgfile, "Global", "multiplier", multiplier);
	cfg_write_int(cfgfile, "Global", "horiz_spec_start", horiz_spec_start);
	cfg_write_int(cfgfile, "Global", "vert_spec_start", vert_spec_start);
	cfg_write_int(cfgfile, "Global", "x3d_scroll", x3d_scroll);
	cfg_write_int(cfgfile, "Global", "z3d_scroll", z3d_scroll);
	cfg_write_boolean(cfgfile, "Global", "show_leader", show_leader);
	cfg_write_int(cfgfile, "Global", "scope_sync_source", scope_sync_source);
	cfg_write_boolean(cfgfile, "Global", "landtilt",landtilt);
	cfg_write_boolean(cfgfile, "Global", "spiketilt", spiketilt);
	cfg_write_float(cfgfile, "Global", "low_freq", low_freq);
	cfg_write_float(cfgfile, "Global", "high_freq", high_freq);
	cfg_write_int(cfgfile, "Window", "width", width);
	cfg_write_int(cfgfile, "Window", "height", height+22);
	gdk_window_get_root_origin(widget->window, &x, &y);
	cfg_write_int(cfgfile, "Window", "main_x_origin", x);
	cfg_write_int(cfgfile, "Window", "main_y_origin", y);
	//    cfg_write_boolean(cfgfile, "Window", "grad_win_present", grad_win_present);
	if (grad_win_present)
	{
		gdk_window_get_root_origin((gpointer) grad_win_ptr->window, &x, &y);
		cfg_write_int(cfgfile, "Window", "grad_x_origin", x);
		cfg_write_int(cfgfile, "Window", "grad_y_origin", y);
	}
	if (dir_win_present)
	{
		gdk_window_get_root_origin((gpointer) dir_win_ptr->window, &x, &y);
		cfg_write_int(cfgfile, "Window", "dir_x_origin", x);
		cfg_write_int(cfgfile, "Window", "dir_y_origin", y);
	}

	cfg_write_file(cfgfile, filename);
	cfg_free(cfgfile);

	g_free(filename);

}