예제 #1
0
static GtkWidget * ad9739a_init(struct osc_plugin *plugin, GtkWidget *notebook, const char *ini_fn)
{
	GtkBuilder *builder;
	GtkWidget *ad9739a_panel;
	GtkWidget *dds_container;

	ctx = osc_create_context();
	if (!ctx)
		return NULL;

	dac = iio_context_find_device(ctx, DAC_DEVICE);
	dac_tx_manager = dac_data_manager_new(dac, NULL, ctx);
	if (!dac_tx_manager) {
		osc_destroy_context(ctx);
		return NULL;
	}

	builder = gtk_builder_new();
	if (osc_load_glade_file(builder, "ad9739a") < 0)
		return NULL;

	ad9739a_panel = GTK_WIDGET(gtk_builder_get_object(builder, "ad9739a_panel"));
	dds_container = GTK_WIDGET(gtk_builder_get_object(builder, "dds_transmit_block"));
	gtk_container_add(GTK_CONTAINER(dds_container), dac_data_manager_get_gui_container(dac_tx_manager));
	gtk_widget_show_all(dds_container);

	/* Bind the IIO device files to the GUI widgets */

	iio_combo_box_init_from_builder(&tx_widgets[num_tx++],
		dac, NULL, "operation_mode", "operation_modes_available",
		 builder, "operation_modes_combo", NULL);

	iio_spin_button_int_init_from_builder(&tx_widgets[num_tx++],
		dac, NULL, "full_scale_current", builder,
		"full_scale_spin", NULL);

	if (ini_fn)
		load_profile(NULL, ini_fn);

	/* Update all widgets with current values */
	update_widgets();

	make_widget_update_signal_based(tx_widgets, num_tx);
	g_builder_connect_signal(builder, "ad9739a_settings_reload", "clicked",
		G_CALLBACK(reload_button_clicked), NULL);

	dac_data_manager_freq_widgets_range_update(dac_tx_manager, 2E15 / 2);

	dac_data_manager_update_iio_widgets(dac_tx_manager);

	dac_data_manager_set_buffer_chooser_current_folder(dac_tx_manager, OSC_WAVEFORM_FILE_PATH);

	can_update_widgets = true;

	return ad9739a_panel;
}
예제 #2
0
static void context_destroy(struct osc_plugin *plugin, const char *ini_fn)
{
	save_profile(NULL, ini_fn);

	if (dac_tx_manager) {
		dac_data_manager_free(dac_tx_manager);
		dac_tx_manager = NULL;
	}

	osc_destroy_context(ctx);
}
예제 #3
0
static void context_destroy(const char *ini_fn)
{
	save_profile(ini_fn);

	if (dac_tx_manager) {
		dac_data_manager_free(dac_tx_manager);
		dac_tx_manager = NULL;
	}

	osc_destroy_context(ctx);
}
예제 #4
0
static bool pr_config_identify(void)
{
	/* Use the OSC's IIO context just to detect the devices */
	struct iio_context *osc_ctx = get_context_from_osc();

	if (!iio_context_find_device(osc_ctx, PHY_DEVICE) ||
		!iio_context_find_device(osc_ctx, DEVICE_NAME_ADC) ||
		!iio_context_find_device(osc_ctx, DEVICE_NAME_DAC))
		return false;

	ctx = osc_create_context();
	phy = iio_context_find_device(ctx, PHY_DEVICE);
	adc = iio_context_find_device(ctx, DEVICE_NAME_ADC);
	dac = iio_context_find_device(ctx, DEVICE_NAME_DAC);

	context_is_local = !strncmp(iio_context_get_name(ctx), "local", strlen("local"));

	int id;
	bool init = true;

	if (!phy || !adc || !dac) {
		init = false;
	} else {
		id = getPrId();
		if ((id != PR_LOGIC_DEFAULT_ID) &&
				(id != PR_LOGIC_BIST_ID) &&
				(id != PR_LOGIC_QPSK_ID))
			init = false;
	}
	if (phy && !iio_device_get_debug_attrs_count(phy))
		init = false;
	if (!init)
		osc_destroy_context(ctx);

	return init;
}
예제 #5
0
static void context_destroy(struct osc_plugin *plugin, const char *ini_fn)
{
	g_source_remove_by_user_data(ctx);
	osc_destroy_context(ctx);
}
예제 #6
0
static void context_destroy(const char *ini_fn)
{
	save_profile(ini_fn);
	osc_destroy_context(ctx);
}
예제 #7
0
static GtkWidget * daq2_init(GtkWidget *notebook, const char *ini_fn)
{
	GtkBuilder *builder;
	GtkWidget *daq2_panel;
	GtkWidget *dds_container;
	GtkTextBuffer *adc_buff, *dac_buff;
	struct iio_channel *ch0, *ch1;

	ctx = osc_create_context();
	if (!ctx)
		return NULL;

	dac = iio_context_find_device(ctx, DAC_DEVICE);
	adc = iio_context_find_device(ctx, ADC_DEVICE);

	dac_tx_manager = dac_data_manager_new(dac, NULL, ctx);
	if (!dac_tx_manager) {
		osc_destroy_context(ctx);
		return NULL;
	}

	builder = gtk_builder_new();

	if (!gtk_builder_add_from_file(builder, "daq2.glade", NULL))
		gtk_builder_add_from_file(builder, OSC_GLADE_FILE_PATH "daq2.glade", NULL);

	daq2_panel = GTK_WIDGET(gtk_builder_get_object(builder, "daq2_panel"));
	dds_container = GTK_WIDGET(gtk_builder_get_object(builder, "dds_transmit_block"));
	gtk_container_add(GTK_CONTAINER(dds_container), dac_data_manager_get_gui_container(dac_tx_manager));
	gtk_widget_show_all(dds_container);

	if (ini_fn)
		load_profile(ini_fn);

	/* Bind the IIO device files to the GUI widgets */

	char attr_val[256];
	long long val;
	double tx_sampling_freq;

	/* Rx Widgets */

	ch0 = iio_device_find_channel(adc, "voltage0", false);
	ch1 = iio_device_find_channel(adc, "voltage1", false);

	if (iio_channel_attr_read_longlong(ch0, "sampling_frequency", &val) == 0)
		snprintf(attr_val, sizeof(attr_val), "%.2f", (double)(val / 1000000ul));
	else
		snprintf(attr_val, sizeof(attr_val), "%s", "error");

	adc_buff = gtk_text_buffer_new(NULL);
	gtk_text_buffer_set_text(adc_buff, attr_val, -1);
	gtk_text_view_set_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(builder, "text_view_adc_freq")), adc_buff);

	iio_combo_box_init_from_builder(&rx_widgets[num_rx++],
		adc, ch0, "test_mode", "test_mode_available", builder,
		"ch0_test_mode", NULL);
	iio_combo_box_init_from_builder(&rx_widgets[num_rx++],
		adc, ch1, "test_mode", "test_mode_available", builder,
		"ch1_test_mode", NULL);

	/* Tx Widgets */
	ch0 = iio_device_find_channel(dac, "altvoltage0", true);

	if (iio_channel_attr_read_longlong(ch0, "sampling_frequency", &val) == 0) {
		tx_sampling_freq = (double)(val / 1000000ul);
		snprintf(attr_val, sizeof(attr_val), "%.2f", tx_sampling_freq);
	} else {
		snprintf(attr_val, sizeof(attr_val), "%s", "error");
		tx_sampling_freq = 0;
	}

	dac_buff = gtk_text_buffer_new(NULL);
	gtk_text_buffer_set_text(dac_buff, attr_val, -1);
	gtk_text_view_set_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(builder, "text_view_dac_freq")), dac_buff);

	make_widget_update_signal_based(rx_widgets, num_rx);
	make_widget_update_signal_based(tx_widgets, num_tx);

	dac_data_manager_freq_widgets_range_update(dac_tx_manager, tx_sampling_freq / 2);

	tx_update_values();
	rx_update_values();
	dac_data_manager_update_iio_widgets(dac_tx_manager);

	dac_data_manager_set_buffer_chooser_current_folder(dac_tx_manager, OSC_WAVEFORM_FILE_PATH);

	block_diagram_init(builder, 4,
			"AD9680_11752-001.svg", "AD9144_11675-002.svg",
			"AD9523_09278-020.svg", "AD-FMCDAQ2-EBZ.jpg");

	can_update_widgets = true;

	return daq2_panel;
}