diff options
author | tvoid <tvoid@lesaige.com> | 2008-04-07 17:50:59 -0600 |
---|---|---|
committer | tvoid <tvoid@lesaige.com> | 2008-04-07 17:50:59 -0600 |
commit | 7a6d8fc1da77e11decd341e81ab6d65e46ae2eed (patch) | |
tree | b719a9cc91cd347181ee4fc2ea855843beaaa9dc /gsm-tvoid/src | |
parent | 4047af29e93c40d46df88c0a76b158a083d6b630 (diff) |
working callback
Diffstat (limited to 'gsm-tvoid/src')
-rwxr-xr-x | gsm-tvoid/src/lib/gsm.i | 14 | ||||
-rwxr-xr-x | gsm-tvoid/src/lib/gsm_burst.cc | 78 | ||||
-rwxr-xr-x | gsm-tvoid/src/lib/gsm_burst.h | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | gsm-tvoid/src/lib/gsm_burst_cf.cc | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | gsm-tvoid/src/lib/gsm_burst_cf.h | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | gsm-tvoid/src/lib/gsm_burst_ff.cc | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | gsm-tvoid/src/lib/gsm_burst_ff.h | 6 | ||||
-rwxr-xr-x | gsm-tvoid/src/python/gsm_scan.py | 35 |
8 files changed, 44 insertions, 129 deletions
diff --git a/gsm-tvoid/src/lib/gsm.i b/gsm-tvoid/src/lib/gsm.i index a362421..3925d12 100755 --- a/gsm-tvoid/src/lib/gsm.i +++ b/gsm-tvoid/src/lib/gsm.i @@ -76,31 +76,27 @@ public: double mean_freq_offset(void); //Methods - //void set_tuner_callback(gsm_tuner_callback *); - //void set_tuner_callback(gr_feval_dd *); - void full_reset(void); protected: -// gsm_tuner_callback *p_tuner; - gsm_burst(gr_feval_dd *); + gsm_burst(gr_feval_ll *); }; GR_SWIG_BLOCK_MAGIC(gsm,burst_ff); -gsm_burst_ff_sptr gsm_make_burst_ff (gr_feval_dd *); +gsm_burst_ff_sptr gsm_make_burst_ff (gr_feval_ll *); class gsm_burst_ff : public gr_block, public gsm_burst { private: - gsm_burst_ff (gr_feval_dd *); + gsm_burst_ff (gr_feval_ll *); }; GR_SWIG_BLOCK_MAGIC(gsm,burst_cf); -gsm_burst_cf_sptr gsm_make_burst_cf (gr_feval_dd *,float); +gsm_burst_cf_sptr gsm_make_burst_cf (gr_feval_ll *,float); class gsm_burst_cf : public gr_block, public gsm_burst { private: - gsm_burst_cf (gr_feval_dd *,float); + gsm_burst_cf (gr_feval_ll *,float); }; diff --git a/gsm-tvoid/src/lib/gsm_burst.cc b/gsm-tvoid/src/lib/gsm_burst.cc index ff5fac1..6bec32c 100755 --- a/gsm-tvoid/src/lib/gsm_burst.cc +++ b/gsm-tvoid/src/lib/gsm_burst.cc @@ -12,75 +12,14 @@ #include "system.h" #include "gsmstack.h" -/* -void do_tuner_callback(gsm_tuner_callback *t, double f) -{ - if (t) t->do_tune(f); -} - -//this should be overridden by a python class -void gsm_tuner_callback::tune(double x) { - printf("t1: %f\n",x); -} - -void gsm_tuner_callback::do_tune(double x) { - printf("do_"); - tune(x); -} - - -void gsm_burst::set_tuner_callback(gsm_tuner_callback *f) { - printf("set_tuner_callback: %8.8x\n",(unsigned int)f); - p_tuner = f; -} -*/ - -/* -void gsm_burst::set_tuner_callback(gr_feval_dd *t) { - p_tuner = t; -} -*/ - -/* -void gsm_burst::set_status_callback(PSTAT_FUNC func, void *clientdata) { - p_stat_func = func; - stat_func_data = clientdata; -} - -void gsm_burst::py_set_status_callback(PyObject *pyfunc) { - //set_status_callback(PythonCallBack, (void *) pyfunc); - stat_func_data = (void *) pyfunc; - Py_INCREF(pyfunc); -} -*/ - - -/* -static void PythonCallBack(int a, void *clientdata) -{ - PyObject *func, *arglist, *result; -// long int dres = 0; - - func = (PyObject *) clientdata; // Get Python function - arglist = Py_BuildValue("(i)",a); // Build argument list - result = PyEval_CallObject(func,arglist); // Call Python - Py_DECREF(arglist); // Trash arglist -// if (result) { // If no errors, return double -// dres = PyInt_AsLong(result); -// } - Py_XDECREF(result); -// return dres; -} -*/ - -gsm_burst::gsm_burst (gr_feval_dd *t) : +gsm_burst::gsm_burst (gr_feval_ll *t) : d_clock_options(DEFAULT_CLK_OPTS), d_print_options(0), d_equalizer_type(EQ_FIXED_DFE) { - printf("gsm_burst: enter constructor (t=%8.8x)\n",(unsigned int)t); + fprintf(stderr,"gsm_burst: enter constructor (t=%8.8x)\n",(unsigned int)t); // M_PI = M_PI; //4.0 * atan(1.0); @@ -755,15 +694,12 @@ int gsm_burst::get_burst(void) if (got_burst) { d_total_count++; //do callback - //do_tuner_callback(p_tuner,1.0); - //if (p_callback) - if (p_tuner) + if (p_tuner) { //p_tuner->eval(1.0); - p_tuner->calleval(1.0); - //p_tuner->do_tune(1.0); - //PythonCallBack(STAT_GOT_BURST,stat_func_data); - //(*p_stat_func)(STAT_GOT_BURST,stat_func_data); - //p_callback->(1.0); + long in=1; + long out = -1; + out = p_tuner->calleval(in); + } //print info print_burst(); diff --git a/gsm-tvoid/src/lib/gsm_burst.h b/gsm-tvoid/src/lib/gsm_burst.h index b5313c4..f1b45a6 100755 --- a/gsm-tvoid/src/lib/gsm_burst.h +++ b/gsm-tvoid/src/lib/gsm_burst.h @@ -8,7 +8,6 @@ #include "gsm_constants.h" #include <gr_math.h> -//#include <Python.h> //for callback testing #include <gr_feval.h> #include "gsmstack.h" @@ -71,28 +70,13 @@ enum EQ_TYPE { EQ_VITERBI }; -//typedef void (*PSTAT_FUNC)(int, void *); -//#define STAT_GOT_BURST 1 -//double gr_feval_callback(gr_feval_dd *f, double x); - -/* -class gsm_tuner_callback { -protected: - virtual void tune(double x); - -public: - virtual void do_tune(double x); -}; -*/ -//void do_tuner_callback(gsm_tuner_callback *t, double f); - class gsm_burst; class gsm_burst { protected: - gsm_burst(gr_feval_dd *t); + gsm_burst(gr_feval_ll *t); //Burst Buffer: Storage for burst data float d_burst_buffer[BBUF_SIZE]; @@ -129,11 +113,7 @@ protected: double d_freq_off_sum; double d_freq_off_weight; - //PSTAT_FUNC p_stat_func; - //void *stat_func_data; - - gr_feval_dd *p_tuner; - //gsm_tuner_callback *p_tuner; + gr_feval_ll *p_tuner; //////// Methods int get_burst(void); @@ -164,7 +144,7 @@ public: //void py_set_status_callback(PyObject *pyfunc); //void set_status_callback(PSTAT_FUNC func, void *clientdata); - //void set_tuner_callback(gr_feval_dd *t); + //void set_tuner_callback(gr_feval_ll *t); //use swig directors to privide a python override //virtual void notify_status(int status); diff --git a/gsm-tvoid/src/lib/gsm_burst_cf.cc b/gsm-tvoid/src/lib/gsm_burst_cf.cc index f08424d..45b8e3a 100644..100755 --- a/gsm-tvoid/src/lib/gsm_burst_cf.cc +++ b/gsm-tvoid/src/lib/gsm_burst_cf.cc @@ -9,7 +9,7 @@ #include <stdio.h> #include <gri_mmse_fir_interpolator_cc.h> -gsm_burst_cf_sptr gsm_make_burst_cf (gr_feval_dd *t,float sample_rate) +gsm_burst_cf_sptr gsm_make_burst_cf (gr_feval_ll *t,float sample_rate) { return gsm_burst_cf_sptr (new gsm_burst_cf (t,sample_rate)); } @@ -19,7 +19,7 @@ static const int MAX_IN = 1; // maximum number of input streams static const int MIN_OUT = 1; // minimum number of output streams static const int MAX_OUT = 1; // maximum number of output streams -gsm_burst_cf::gsm_burst_cf (gr_feval_dd *t, float sample_rate) : +gsm_burst_cf::gsm_burst_cf (gr_feval_ll *t, float sample_rate) : gr_block ( "burst_cf", gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), gr_make_io_signature (MIN_OUT, MAX_OUT, USEFUL_BITS * sizeof (float))), diff --git a/gsm-tvoid/src/lib/gsm_burst_cf.h b/gsm-tvoid/src/lib/gsm_burst_cf.h index fe742c4..2b806e0 100644..100755 --- a/gsm-tvoid/src/lib/gsm_burst_cf.h +++ b/gsm-tvoid/src/lib/gsm_burst_cf.h @@ -8,7 +8,7 @@ class gsm_burst_cf; typedef boost::shared_ptr<gsm_burst_cf> gsm_burst_cf_sptr; -gsm_burst_cf_sptr gsm_make_burst_cf(gr_feval_dd *,float); +gsm_burst_cf_sptr gsm_make_burst_cf(gr_feval_ll *,float); class gri_mmse_fir_interpolator_cc; @@ -16,8 +16,8 @@ class gsm_burst_cf : public gr_block, public gsm_burst { private: - friend gsm_burst_cf_sptr gsm_make_burst_cf(gr_feval_dd *,float); - gsm_burst_cf(gr_feval_dd *,float); + friend gsm_burst_cf_sptr gsm_make_burst_cf(gr_feval_ll *,float); + gsm_burst_cf(gr_feval_ll *,float); //clocking parameters float d_relative_sample_rate; diff --git a/gsm-tvoid/src/lib/gsm_burst_ff.cc b/gsm-tvoid/src/lib/gsm_burst_ff.cc index 25f9421..57f104a 100644..100755 --- a/gsm-tvoid/src/lib/gsm_burst_ff.cc +++ b/gsm-tvoid/src/lib/gsm_burst_ff.cc @@ -9,7 +9,7 @@ #include <stdio.h> #include <gri_mmse_fir_interpolator_cc.h> -gsm_burst_ff_sptr gsm_make_burst_ff (gr_feval_dd *t) +gsm_burst_ff_sptr gsm_make_burst_ff (gr_feval_ll *t) { return gsm_burst_ff_sptr (new gsm_burst_ff(t)); } @@ -19,7 +19,7 @@ static const int MAX_IN = 1; // maximum number of input streams static const int MIN_OUT = 1; // minimum number of output streams static const int MAX_OUT = 1; // maximum number of output streams -gsm_burst_ff::gsm_burst_ff (gr_feval_dd *t) : +gsm_burst_ff::gsm_burst_ff (gr_feval_ll *t) : gr_block( "burst_ff", gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)), gr_make_io_signature (MIN_OUT, MAX_OUT, USEFUL_BITS * sizeof (float))), diff --git a/gsm-tvoid/src/lib/gsm_burst_ff.h b/gsm-tvoid/src/lib/gsm_burst_ff.h index 30047f2..8ca61ef 100644..100755 --- a/gsm-tvoid/src/lib/gsm_burst_ff.h +++ b/gsm-tvoid/src/lib/gsm_burst_ff.h @@ -8,14 +8,14 @@ class gsm_burst_ff; typedef boost::shared_ptr<gsm_burst_ff> gsm_burst_ff_sptr; -gsm_burst_ff_sptr gsm_make_burst_ff(gr_feval_dd *); +gsm_burst_ff_sptr gsm_make_burst_ff(gr_feval_ll *); class gsm_burst_ff : public gr_block, public gsm_burst { private: - friend gsm_burst_ff_sptr gsm_make_burst_ff(gr_feval_dd *); - gsm_burst_ff(gr_feval_dd *t); + friend gsm_burst_ff_sptr gsm_make_burst_ff(gr_feval_ll *); + gsm_burst_ff(gr_feval_ll *t); public: ~gsm_burst_ff (); diff --git a/gsm-tvoid/src/python/gsm_scan.py b/gsm-tvoid/src/python/gsm_scan.py index 432b16e..dc3894b 100755 --- a/gsm-tvoid/src/python/gsm_scan.py +++ b/gsm-tvoid/src/python/gsm_scan.py @@ -26,6 +26,23 @@ from math import pi import wx import gsm + +#class gsm_tuner(gsm.gsm_tuner_callback): +class tune(gr.feval_ll): + def __init__(self, fg): + gr.feval_dd.__init__(self) + self.fg = fg + + def eval(self, x): + try: + #print "tune: ", x, "\n"; + self.fg.cb_count += 1 + return 0 + + except Exception, e: + print "tune: Exception: ", e + + def pick_subdevice(u): if u.db[0][0].dbid() >= 0: return (0, 0) @@ -69,21 +86,6 @@ def get_freq_from_arfcn(chan,region): return freq * 1e6 -#class gsm_tuner(gsm.gsm_tuner_callback): -class gsm_tuner(gr.feval_dd): - def __init__(self, fg): - gr.feval_dd.__init__(self) - self.fg = fg - - def eval(self, x): - try: - print "tune: ", x, "\n"; - fg.cb_count += 1 - return 0.0 - - except Exception, e: - print "tune: Exception: ", e - class app_flow_graph(stdgui.gui_flow_graph): def __init__(self, frame, panel, vbox, argv): @@ -236,7 +238,8 @@ class app_flow_graph(stdgui.gui_flow_graph): self.connect(self.u, self.input_fft_scope) #create a tuner callback - self.tuner = gsm_tuner(self) + self.tuner = tune(self) + #self._tuner = tune() # Setup flow based on decoder selection if options.decoder.count("c"): |