From ccca4c7d043bd5e14e48c67880da498c7d578734 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 6 Oct 2009 18:00:21 -0700 Subject: moved grc examples to gnuradio-examples/grc --- gnuradio-examples/grc/xmlrpc/.gitignore | 2 + gnuradio-examples/grc/xmlrpc/readme.txt | 18 + gnuradio-examples/grc/xmlrpc/xmlrpc_client.grc | 312 +++++++++++++++++ .../grc/xmlrpc/xmlrpc_client_script.py | 23 ++ gnuradio-examples/grc/xmlrpc/xmlrpc_server.grc | 384 +++++++++++++++++++++ 5 files changed, 739 insertions(+) create mode 100644 gnuradio-examples/grc/xmlrpc/.gitignore create mode 100644 gnuradio-examples/grc/xmlrpc/readme.txt create mode 100644 gnuradio-examples/grc/xmlrpc/xmlrpc_client.grc create mode 100644 gnuradio-examples/grc/xmlrpc/xmlrpc_client_script.py create mode 100644 gnuradio-examples/grc/xmlrpc/xmlrpc_server.grc (limited to 'gnuradio-examples/grc/xmlrpc') diff --git a/gnuradio-examples/grc/xmlrpc/.gitignore b/gnuradio-examples/grc/xmlrpc/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gnuradio-examples/grc/xmlrpc/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gnuradio-examples/grc/xmlrpc/readme.txt b/gnuradio-examples/grc/xmlrpc/readme.txt new file mode 100644 index 000000000..c1f87c1cb --- /dev/null +++ b/gnuradio-examples/grc/xmlrpc/readme.txt @@ -0,0 +1,18 @@ +################################################## +# XMLRPC example +################################################## + +XMLRPC allows software to make remote function calls over http. +In the case of GRC, one can use XMLRPC to modify variables in a running flow graph. +See http://www.xmlrpc.com/ + +--- Server Example --- +Place an "XMLRPC Server" block inside of any flow graph. +The server will provide set functions for every variable in the flow graph. +If a variable is called "freq", the server will provide a function set_freq(new_freq). +Run the server example and experiment with the example client script. + +-- Client Example -- +The "XMLRPC Client" block will give a variable control over one remove function. +In the example client, there is one client block and gui control per variable. +This technique can be used to remotely control a flow graph, perhaps running on a non-gui machine. diff --git a/gnuradio-examples/grc/xmlrpc/xmlrpc_client.grc b/gnuradio-examples/grc/xmlrpc/xmlrpc_client.grc new file mode 100644 index 000000000..3bb4e7ed3 --- /dev/null +++ b/gnuradio-examples/grc/xmlrpc/xmlrpc_client.grc @@ -0,0 +1,312 @@ + + + Thu Jul 24 14:27:44 2008 + + options + + id + client_block + + + _enabled + True + + + title + XMLRPC Client + + + author + Example + + + description + example flow graph + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + xmlrpc_client + + id + xmlrpc_client0 + + + _enabled + True + + + addr + localhost + + + port + 1234 + + + callback + set_ampl + + + variable + ampl + + + _coordinate + (409, 35) + + + _rotation + 0 + + + + xmlrpc_client + + id + xmlrpc_client + + + _enabled + True + + + addr + localhost + + + port + 1234 + + + callback + set_freq + + + variable + freq + + + _coordinate + (222, 34) + + + _rotation + 0 + + + + variable_slider + + id + freq + + + _enabled + True + + + label + Frequency (Hz) + + + value + 1000 + + + min + 0 + + + max + 5000 + + + num_steps + 100 + + + slider_type + horizontal + + + grid_pos + 0, 0, 1, 2 + + + _coordinate + (207, 162) + + + _rotation + 0 + + + + variable_slider + + id + ampl + + + _enabled + True + + + label + Amplitude + + + value + 1 + + + min + 0 + + + max + 2 + + + num_steps + 100 + + + slider_type + horizontal + + + grid_pos + 1, 0, 1, 2 + + + _coordinate + (397, 167) + + + _rotation + 0 + + + + variable_chooser + + id + offset + + + _enabled + True + + + label + Offset + + + value_index + 1 + + + choices + [-1, 0, 1] + + + labels + ["neg", "zero", "pos"] + + + chooser_type + radio_buttons_horizontal + + + grid_pos + 2, 0, 1, 2 + + + _coordinate + (596, 177) + + + _rotation + 0 + + + + xmlrpc_client + + id + xmlrpc_client1 + + + _enabled + True + + + addr + localhost + + + port + 1234 + + + callback + set_offset + + + variable + offset*ampl + + + _coordinate + (608, 39) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 32000 + + + _coordinate + (13, 172) + + + _rotation + 0 + + + \ No newline at end of file diff --git a/gnuradio-examples/grc/xmlrpc/xmlrpc_client_script.py b/gnuradio-examples/grc/xmlrpc/xmlrpc_client_script.py new file mode 100644 index 000000000..956fa07fb --- /dev/null +++ b/gnuradio-examples/grc/xmlrpc/xmlrpc_client_script.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import time +import random +import xmlrpclib + +#create server object +s = xmlrpclib.Server("http://localhost:1234") + +#randomly change parameters of the sinusoid +for i in range(10): + #generate random values + new_freq = random.uniform(0, 5000) + new_ampl = random.uniform(0, 2) + new_offset = random.uniform(-1, 1) + #set new values + time.sleep(1) + s.set_freq(new_freq) + time.sleep(1) + s.set_ampl(new_ampl) + time.sleep(1) + s.set_offset(new_offset) + diff --git a/gnuradio-examples/grc/xmlrpc/xmlrpc_server.grc b/gnuradio-examples/grc/xmlrpc/xmlrpc_server.grc new file mode 100644 index 000000000..dc539ef1b --- /dev/null +++ b/gnuradio-examples/grc/xmlrpc/xmlrpc_server.grc @@ -0,0 +1,384 @@ + + + Thu Jul 24 14:27:42 2008 + + options + + id + server_block + + + _enabled + True + + + title + XMLRPC Server + + + author + Example + + + description + example flow graph + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x + + + _enabled + True + + + type + float + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + freq + + + amp + ampl + + + offset + offset + + + _coordinate + (162, 200) + + + _rotation + 0 + + + + variable + + id + offset + + + _enabled + True + + + value + 0 + + + _coordinate + (12, 390) + + + _rotation + 0 + + + + xmlrpc_server + + id + xmlrpc_server + + + _enabled + True + + + addr + localhost + + + port + 1234 + + + _coordinate + (395, 240) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle + + + _enabled + True + + + type + float + + + samples_per_second + samp_rate + + + vlen + 1 + + + _coordinate + (386, 93) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2 + + + _enabled + True + + + type + float + + + title + Scope Plot + + + samp_rate + samp_rate + + + frame_decim + 15 + + + v_scale + 0 + + + t_scale + .001 + + + marker + set_format_line + + + num_inputs + 1 + + + grid_pos + 0, 0, 2, 4 + + + _coordinate + (623, 28) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2 + + + _enabled + True + + + type + float + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + 0 + + + y_per_div + 10 + + + y_divs + 8 + + + ref_level + 50 + + + fft_size + 512 + + + fft_rate + 15 + + + avg_alpha + 0 + + + average + False + + + peak_hold + False + + + grid_pos + 2, 0, 2, 4 + + + _coordinate + (630, 233) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 32000 + + + _coordinate + (11, 160) + + + _rotation + 0 + + + + variable + + id + freq + + + _enabled + True + + + value + 1000 + + + _coordinate + (11, 237) + + + _rotation + 0 + + + + variable + + id + ampl + + + _enabled + True + + + value + 1 + + + _coordinate + (13, 315) + + + _rotation + 0 + + + + gr_sig_source_x + gr_throttle + 0 + 0 + + + gr_throttle + wxgui_scopesink2 + 0 + 0 + + + gr_throttle + wxgui_fftsink2 + 0 + 0 + + \ No newline at end of file -- cgit From 29fed0b4e92d862f43d75f364aa028b6658e76c3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 6 Oct 2009 18:04:38 -0700 Subject: removed unused git ignores --- gnuradio-examples/grc/xmlrpc/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 gnuradio-examples/grc/xmlrpc/.gitignore (limited to 'gnuradio-examples/grc/xmlrpc') diff --git a/gnuradio-examples/grc/xmlrpc/.gitignore b/gnuradio-examples/grc/xmlrpc/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/grc/xmlrpc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in -- cgit