Hi David,
Making the parameter vary at runtime is simple and just needs some extra XML and python code. The parameter should be an argument to the __init__ method (constructor) of your block and should have a "" declaration in the matching XML file. Let's say the parameter name is "variable_param" with a declaration like:
Variable parameter
variable_param
42
int
Then you need to add the following in the XML file:
set_variable_param($variable_param)
And you need to implement the "set_variable_param" method in your python class to take whatever action is needed when the parameter value changes. This method will be called every time the value of the _expression_ in the underlined "Variable parameter" box in the GUI changes. The method will look like:
def set_variable_param(self, new_value):
whatever code
This should make GRC underline the variable_param in the GUI and it will be variable at runtime.
Thanks,
--Patrick
________________________________
> From: address@hidden
> Date: Thu, 24 Sep 2015 10:35:34 -0700
> To: address@hidden
> CC: address@hidden
> Subject: Re: [Discuss-gnuradio] Function Probe and OOT Blocks
>
> Hi David:
>
> I'm a relative newbie myself, but I can say that I had this same issue.
> I had a block with a static parameter that I wanted to be able to
> change dynamically at runtime.
>
> I looked at the block's source code, and also at a block that had a
> dynamically adjustable parameter.
>
> Basically, and with a little help from the list (Marcus Muller in
> particular) as I had to learn c++, I was able to use the code from the
> dynamic block as an example, and modify the static block to change the
> parameter to be dynamically changeable. It all came down to at most a
> couple dozen lines of code. The bigger challenge was learning about
> Gnuradio's architecture, to know what to do.
>
> I would suggest a similar approach. You will find the list members
> very helpful. I'd also look at the guided tutorials, there are good
> examples there under "how to write a c++ block".
>
> I will help if I can but alas, I am still quite a newbie, so others
> will be able to help much more efficiently!
>
> Kevin
>
> Sent from my iPad
>
> On Sep 23, 2015, at 4:12 AM, David Halls
>
>
> wrote:
>
>
> Hi guys,
>
>
> I am familiar with using function probes to update values to blocks.
> This is straightforward with built in blocks like Multiply Const, where
> the input is underline in the GRC dialogue box.
>
>
> How do I create a block, specifically a Python block, that allows me to
> update parameters in this fashion so that they are not fixed at
> runtime?
>
>
> Regards,
>
>
> David
>
> ________________________________
>
> NOTE: The information in this email and any attachments may be
> confidential and/or legally privileged. This message may be read,
> copied and used only by the intended recipient. If you are not the
> intended recipient, please destroy this message, delete any copies held
> on your system and notify the sender immediately.
>
> Toshiba Research Europe Limited, registered in England and Wales
> (2519556). Registered Office 208 Cambridge Science Park, Milton Road,
> Cambridge CB4 0GZ, England. Web:
> www.toshiba.eu/research/trl
>
>
>
> ________________________________
> This email has been scanned for email related threats and delivered
> safely by Mimecast.
> For more information please visit http://www.mimecast.com
> ________________________________
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
> _______________________________________________ Discuss-gnuradio
> mailing list address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio