diff options
-rw-r--r-- | gnuradio-core/src/lib/general/gri_agc2_cc.i | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gri_agc2_ff.i | 10 | ||||
-rw-r--r-- | gr-qtgui/src/lib/highResTimeFunctions.h | 185 | ||||
-rw-r--r-- | gr-wxgui/src/python/plotter/gltext.py | 2 | ||||
-rw-r--r-- | grc/blocks/gr_agc2_xx.xml | 5 |
5 files changed, 168 insertions, 39 deletions
diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.i b/gnuradio-core/src/lib/general/gri_agc2_cc.i index e7d6da97f..0f97f1d8e 100644 --- a/gnuradio-core/src/lib/general/gri_agc2_cc.i +++ b/gnuradio-core/src/lib/general/gri_agc2_cc.i @@ -39,4 +39,9 @@ class gri_agc2_cc { float reference (); float gain (); float max_gain (); + void set_decay_rate (float rate); + void set_attack_rate (float rate); + void set_reference (float reference); + void set_gain (float gain); + void set_max_gain(float max_gain); }; diff --git a/gnuradio-core/src/lib/general/gri_agc2_ff.i b/gnuradio-core/src/lib/general/gri_agc2_ff.i index 3825ce225..d04b638a6 100644 --- a/gnuradio-core/src/lib/general/gri_agc2_ff.i +++ b/gnuradio-core/src/lib/general/gri_agc2_ff.i @@ -34,4 +34,14 @@ class gri_agc2_ff { public: gri_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); + float attack_rate (); + float decay_rate (); + float reference (); + float gain (); + float max_gain (); + void set_attack_rate (float rate); + void set_decay_rate (float rate); + void set_reference (float reference); + void set_gain (float gain); + void set_max_gain (float max_gain); }; diff --git a/gr-qtgui/src/lib/highResTimeFunctions.h b/gr-qtgui/src/lib/highResTimeFunctions.h index b85b1acad..251bbad8b 100644 --- a/gr-qtgui/src/lib/highResTimeFunctions.h +++ b/gr-qtgui/src/lib/highResTimeFunctions.h @@ -8,41 +8,74 @@ static const long NSEC_PER_SEC = 1000000000L; -static inline bool timespec_greater(const struct timespec* t1, const struct timespec* t0){ - return ((t1->tv_sec > t0->tv_sec) || ((t1->tv_sec == t0->tv_sec) && (t1->tv_nsec > t0->tv_nsec))); +static inline bool +timespec_greater(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec > t0->tv_sec) || + ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec > t0->tv_nsec))); } -static inline bool timespec_greater(const struct timespec t1, const struct timespec t0){ - return ((t1.tv_sec > t0.tv_sec) || ((t1.tv_sec == t0.tv_sec) && (t1.tv_nsec > t0.tv_nsec))); +static inline bool +timespec_greater(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec > t0.tv_sec) || + ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec > t0.tv_nsec))); } -static inline bool timespec_less(const struct timespec* t1, const struct timespec* t0){ - return ((t1->tv_sec < t0->tv_sec) || ((t1->tv_sec == t0->tv_sec) && (t1->tv_nsec < t0->tv_nsec))); +static inline bool +timespec_less(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec < t0->tv_sec) || + ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec < t0->tv_nsec))); } -static inline bool timespec_less(const struct timespec t1, const struct timespec t0){ - return ((t1.tv_sec < t0.tv_sec) || ((t1.tv_sec == t0.tv_sec) && (t1.tv_nsec < t0.tv_nsec))); +static inline bool +timespec_less(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec < t0.tv_sec) || + ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec < t0.tv_nsec))); } -static inline bool timespec_equal(const struct timespec* t1, const struct timespec* t0){ - return ((t1->tv_sec == t0->tv_sec) && (t1->tv_nsec == t0->tv_nsec)); +static inline bool +timespec_equal(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec == t0->tv_nsec)); } -static inline bool timespec_equal(const struct timespec t1, const struct timespec t0){ - return ((t1.tv_sec == t0.tv_sec) && (t1.tv_nsec == t0.tv_nsec)); +static inline bool +timespec_equal(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec == t0.tv_nsec)); } -static inline void timespec_reset(struct timespec* ret){ +static inline void +timespec_reset(struct timespec* ret) +{ ret->tv_sec = 0; ret->tv_nsec = 0; } -static inline void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec){ - while (nsec > NSEC_PER_SEC){ +static inline void +set_normalized_timespec(struct timespec *ts, + time_t sec, long nsec) +{ + while (nsec > NSEC_PER_SEC) { nsec -= NSEC_PER_SEC; ++sec; } - while(nsec < 0){ + while(nsec < 0) { nsec += NSEC_PER_SEC; --sec; } @@ -50,10 +83,13 @@ static inline void set_normalized_timespec(struct timespec *ts, time_t sec, long ts->tv_nsec = nsec; } -static inline struct timespec convert_to_timespec(const double timeValue){ +static inline struct timespec +convert_to_timespec(const double timeValue) +{ struct timespec ret; double seconds = 0; - long nsec = static_cast<long>(modf(timeValue, &seconds) * static_cast<double>(NSEC_PER_SEC)); + long nsec = static_cast<long>(modf(timeValue, &seconds) * + static_cast<double>(NSEC_PER_SEC)); time_t sec = static_cast<time_t>(seconds); set_normalized_timespec(&ret, sec, nsec); @@ -61,28 +97,46 @@ static inline struct timespec convert_to_timespec(const double timeValue){ return ret; } -static inline double convert_from_timespec(const timespec actual){ - return (static_cast<double>(actual.tv_sec) + (static_cast<double>(actual.tv_nsec) / static_cast<double>(NSEC_PER_SEC))); +static inline double +convert_from_timespec(const timespec actual) +{ + return (static_cast<double>(actual.tv_sec) + + (static_cast<double>(actual.tv_nsec) / + static_cast<double>(NSEC_PER_SEC))); } -static inline void timespec_add(struct timespec *ret, const struct timespec* t1, const struct timespec* t0){ +static inline void +timespec_add(struct timespec *ret, + const struct timespec* t1, + const struct timespec* t0) +{ time_t sec = t1->tv_sec + t0->tv_sec; long nsec = t1->tv_nsec + t0->tv_nsec; set_normalized_timespec(ret, sec, nsec); } -static inline void timespec_add(struct timespec *ret, const struct timespec t1, const struct timespec t0){ +static inline void +timespec_add(struct timespec *ret, + const struct timespec t1, + const struct timespec t0) +{ return timespec_add(ret, &t1, &t0); } -static inline struct timespec timespec_add(const struct timespec t1, const struct timespec t0){ +static inline struct timespec +timespec_add(const struct timespec t1, + const struct timespec t0) +{ struct timespec ret; timespec_add(&ret, &t1, &t0); return ret; } -static inline struct timespec timespec_add(const struct timespec t1, const double time0){ +static inline struct timespec +timespec_add(const struct timespec t1, + const double time0) +{ struct timespec ret; struct timespec t0; t0 = convert_to_timespec(time0); @@ -92,24 +146,38 @@ static inline struct timespec timespec_add(const struct timespec t1, const doubl return ret; } -static inline void timespec_subtract(struct timespec *ret, const struct timespec* t1, const struct timespec* t0){ +static inline void +timespec_subtract(struct timespec *ret, + const struct timespec* t1, + const struct timespec* t0) +{ time_t sec = t1->tv_sec - t0->tv_sec; long nsec = t1->tv_nsec - t0->tv_nsec; set_normalized_timespec(ret, sec, nsec); } -static inline void timespec_subtract(struct timespec *ret, const struct timespec t1, const struct timespec t0){ +static inline void +timespec_subtract(struct timespec *ret, + const struct timespec t1, + const struct timespec t0) +{ return timespec_subtract(ret, &t1, &t0); } -static inline struct timespec timespec_subtract(const struct timespec t1, const struct timespec t0){ +static inline struct timespec +timespec_subtract(const struct timespec t1, + const struct timespec t0) +{ struct timespec ret; timespec_subtract(&ret, &t1, &t0); return ret; } -static inline struct timespec timespec_subtract(const struct timespec t1, const double time0){ +static inline struct timespec +timespec_subtract(const struct timespec t1, + const double time0) +{ struct timespec ret; struct timespec t0; t0 = convert_to_timespec(time0); @@ -119,7 +187,11 @@ static inline struct timespec timespec_subtract(const struct timespec t1, const return ret; } -static inline double diff_timespec(struct timespec* ret, const struct timespec *t1, const struct timespec* t0){ +static inline double +diff_timespec(struct timespec* ret, + const struct timespec *t1, + const struct timespec* t0) +{ struct timespec actual; time_t sec = 0; long nsec = 0; @@ -141,7 +213,8 @@ static inline double diff_timespec(struct timespec* ret, const struct timespec * sec = t0->tv_sec - t1->tv_sec; nsec = t0->tv_nsec - t1->tv_nsec; - // Do nothing with the ret value as the ret value would have to store a negative, which it can't. + // Do nothing with the ret value as the ret value + // would have to store a negative, which it can't. set_normalized_timespec(&actual, sec, nsec); @@ -149,23 +222,39 @@ static inline double diff_timespec(struct timespec* ret, const struct timespec * } } -static inline double diff_timespec(struct timespec* ret, const struct timespec t1, const struct timespec t0){ +static inline double +diff_timespec(struct timespec* ret, + const struct timespec t1, + const struct timespec t0) +{ return diff_timespec(ret, &t1, &t0); } -static inline double diff_timespec(const struct timespec t1, const struct timespec t0){ +static inline double +diff_timespec(const struct timespec t1, + const struct timespec t0) +{ return diff_timespec(NULL, &t1, &t0); } -static inline double diff_timespec(const struct timespec* t1, const struct timespec* t0){ +static inline double +diff_timespec(const struct timespec* t1, + const struct timespec* t0) +{ return diff_timespec(NULL, t1, t0); } -static inline void get_highres_clock(struct timespec* ret){ +#ifdef CLOCK_REALTIME +// If we can use clock_gettime, use it; +// otherwise, use gettimeofday +static inline void +get_highres_clock(struct timespec* ret) +{ if(clock_gettime(CLOCK_REALTIME, ret) != 0){ - // Unable to get high resolution time - fail over to low resolution time + // Unable to get high resolution time - + // fail over to low resolution time timeval lowResTime; gettimeofday(&lowResTime, NULL); ret->tv_sec = lowResTime.tv_sec; @@ -173,17 +262,37 @@ static inline void get_highres_clock(struct timespec* ret){ } } -static inline struct timespec get_highres_clock(){ +#else + +// Trick timer functions into thinking it has an nsec timer +// but only use the low resolution (usec) timer. +static inline void +get_highres_clock(struct timespec* ret) +{ + timeval lowResTime; + gettimeofday(&lowResTime, NULL); + ret->tv_sec = lowResTime.tv_sec; + ret->tv_nsec = lowResTime.tv_usec*1000; +} +#endif + +static inline struct timespec +get_highres_clock() +{ struct timespec ret; get_highres_clock(&ret); return ret; } -static inline bool timespec_empty(const struct timespec* ret){ +static inline bool +timespec_empty(const struct timespec* ret) +{ return ( (ret->tv_sec == 0 ) && (ret->tv_nsec == 0) ); } -static inline bool timespec_empty(const struct timespec ret){ +static inline bool +timespec_empty(const struct timespec ret) +{ return timespec_empty(&ret); } diff --git a/gr-wxgui/src/python/plotter/gltext.py b/gr-wxgui/src/python/plotter/gltext.py index 67f62ca56..1b3c047dc 100644 --- a/gr-wxgui/src/python/plotter/gltext.py +++ b/gr-wxgui/src/python/plotter/gltext.py @@ -193,7 +193,7 @@ class TextElement(object): img = wx.ImageFromBitmap(bmp)
alpha = img.GetData()
- if isinstance(self._foreground, wx.Color):
+ if isinstance(self._foreground, wx.Colour):
"""
If we have a static color...
"""
diff --git a/grc/blocks/gr_agc2_xx.xml b/grc/blocks/gr_agc2_xx.xml index fb3ae5704..55b20d4e8 100644 --- a/grc/blocks/gr_agc2_xx.xml +++ b/grc/blocks/gr_agc2_xx.xml @@ -9,6 +9,11 @@ <key>gr_agc2_xx</key> <import>from gnuradio import gr</import> <make>gr.agc2_$(type.fcn)($attack_rate, $decay_rate, $reference, $gain, $max_gain)</make> + <callback>set_attack_rate($attack_rate)</callback> + <callback>set_decay_rate($decay_rate)</callback> + <callback>set_reference($reference)</callback> + <callback>set_gain($gain)</callback> + <callback>set_max_gain($max_gain)</callback> <param> <name>Type</name> <key>type</key> |