From 0295a8193914b85ded979a61ca9bfe8f4c988690 Mon Sep 17 00:00:00 2001 From: Dnechita Date: Thu, 5 Jun 2014 08:14:20 +0000 Subject: [PATCH] Osc: Allow plugins to revert a cross-correlation within a plot --- datatypes.h | 1 + osc.c | 7 +++++-- osc.h | 4 +--- oscplot.c | 13 +++++++++++++ oscplot.h | 2 ++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/datatypes.h b/datatypes.h index 787738e9b..ecca6fafa 100644 --- a/datatypes.h +++ b/datatypes.h @@ -132,6 +132,7 @@ struct _constellation_settings { struct _cross_correlation_settings { unsigned int num_samples; + int revert_xcorr; fftw_complex *signal_a; fftw_complex *signal_b; fftw_complex *xcorr_data; diff --git a/osc.c b/osc.c index 21082be0b..4732da53e 100644 --- a/osc.c +++ b/osc.c @@ -476,7 +476,7 @@ void cross_correlation_transform_function(Transform *tr, gboolean init_transform settings->signal_b[i] = q_1[i] + I * i_1[i]; } - if (revert_xcorr) + if (settings->revert_xcorr) xcorr(settings->signal_b, settings->signal_a, settings->xcorr_data, axis_length); else xcorr(settings->signal_a, settings->signal_b, settings->xcorr_data, axis_length); @@ -939,8 +939,11 @@ int plugin_data_capture_bytes_per_sample(const char *device) return iio_device_get_sample_size(dev); } -void plugin_data_capture_revert_xcorr(int revert) +void plugin_data_capture_revert_xcorr(OscPlot *plot, int revert) { + if (!plot) + return; + revert_xcorr = revert; } diff --git a/osc.h b/osc.h index b9bcc7097..1e7ae5262 100644 --- a/osc.h +++ b/osc.h @@ -86,9 +86,7 @@ enum marker_types plugin_get_plot_marker_type(OscPlot *plot, const char *device) void plugin_set_plot_marker_type(OscPlot *plot, const char *device, enum marker_types type); gdouble plugin_get_plot_fft_avg(OscPlot *plot, const char *device); OscPlot * plugin_get_new_plot(void); - -void plugin_data_capture_revert_xcorr(int); - +void plugin_data_capture_revert_xcorr(OscPlot *, int); void capture_profile_save(const char *filename); void main_setup_before_ini_load(void); void main_setup_after_ini_load(void); diff --git a/oscplot.c b/oscplot.c index 84e0c79a9..5b02c35ad 100644 --- a/oscplot.c +++ b/oscplot.c @@ -573,6 +573,18 @@ void osc_plot_set_channel_state(OscPlot *plot, const char *dev, int channel, boo check_valid_setup(plot); } +void osc_plot_xcorr_revert (OscPlot *plot, int revert) +{ + TrList *tr_list = plot->priv->transform_list; + Transform *transform; + int i; + + for (i = 0; i < tr_list->size; i++) { + transform = tr_list->transforms[i]; + XCORR_SETTINGS(transform)->revert_xcorr = revert; + } +} + static void osc_plot_dispose(GObject *object) { G_OBJECT_CLASS(osc_plot_parent_class)->dispose(object); @@ -820,6 +832,7 @@ static void update_transform_settings(OscPlot *plot, Transform *transform, CONSTELLATION_SETTINGS(transform)->num_samples = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->sample_count_widget)); } else if (plot_type == XCORR_PLOT){ XCORR_SETTINGS(transform)->num_samples = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->sample_count_widget)); + XCORR_SETTINGS(transform)->revert_xcorr = 0; XCORR_SETTINGS(transform)->signal_a = NULL; XCORR_SETTINGS(transform)->signal_b = NULL; XCORR_SETTINGS(transform)->xcorr_data = NULL; diff --git a/oscplot.h b/oscplot.h index 8e41d38f8..bb9611d74 100644 --- a/oscplot.h +++ b/oscplot.h @@ -61,6 +61,8 @@ GMutex * osc_plot_get_marker_lock (OscPlot *plot); bool osc_plot_set_sample_count (OscPlot *plot, int sample_count); int osc_plot_get_sample_count (OscPlot *plot); void osc_plot_set_channel_state(OscPlot *plot, const char *dev, int channel, bool state); +void osc_plot_xcorr_revert (OscPlot *plot, int revert); + G_END_DECLS #endif /* __OSC_PLOT__ */