|
From: | Marcus Müller |
Subject: | Re: [Discuss-gnuradio] Sharing variable |
Date: | Tue, 26 May 2015 09:15:39 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
I'm a bit confused; Luis and Anil, are the two of you working on the
same project? I might have oversimplified when I said it's a python concept: GRC variables are actually quite a handy tool that GRC brings, and GNU Radio contains quite some blocks to make use of it. However, I would like to do something like the block "variable" or the "probe signal" block that shares a variable will all blocks in GNUradioThere is no such thing as "sharing"; if you change something for example in a QT GUI range slider, and that changes the parametrization of another block, then there's an underlying callback/signalling architecture that will, when the slider changes, call the appropriate setter on the other block. In fact, this depends on the GUI framework you're using, if I'm not mistaken (i.e. QT offers the callback/slot signalling functionality, and GRC just "connects" QT slots to functions of the top block). The function probe block is a terrible, terrible thing in production: if really just polls the function and consumes CPU for nothing; I like it for debugging purposes, and nothing else, since it's asynchronous, gives no guarantees on actual update rate, is CPU-hungry... You can get a call-on-event behaviour by giving your block something like the following: class Luis_class ... .... def set_callback(self, callable): self._callme = callable def work(...): ... if condition: self._callme(newvalue) and doing something like myblock = Luis_class(...) multiply = blocks.multiply_const_ff(1.0); ... myblock.set_callback(lambda x: multiply.set_k(x)) in your top_block (or wherever you set up your flow graph) However, I'd strongly discourage you to do that! Seriously, that's ignoring core functionality of GNU Radio, breaking what I consider contracts, will be hard to debug, have terrible multithreading issues, undetermined sample-time timing... I want to do a block that changes the samp_rate or the center frequency automatically if a condition is true inside my block.That doesn't sound like you should be using the GRC variable mechanism at all. Just use message passing or stream tags, both of which were invented for exactly this kind of thing. Best regards, Marcus On 05/26/2015 08:52 AM, Luis urday
wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |