discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Reading variable config at runtime


From: Murray Thomson
Subject: [Discuss-gnuradio] Reading variable config at runtime
Date: Thu, 12 Apr 2018 17:52:15 +0100

Hi,

My goal is to have a QT GUI chooser to change between a bunch of set configurations defining frequencies, amplitudes, filters...

I have tried 3 ways to do it but I'm open to suggestions if there is a better way to do this.

1) variable: id=list_a;value=(0,1,2,3);
    variable:   id=a;value;list_a[index];
    QT GUI Chooser: id=index;values 0 to 3;
This works but is not very clear when numbers grow.

Ideally I would like to use a variable config, with one section for each set of values.

2) variable id=var_sections;value=("zero","one","two");
    variable_config id=b;Section=var_sections[index]
    QT GUI Chooser: id=index;values 0 to 2;
And the config file reads:
[zero]
b = 0
[one]
b = 1
[two]
b = 2

This works for the first read. I can set the GUI Chooser default value to 0,1 or 2 and it will read the variable from the expected section. However, when I change the GUI Chooser, the writeback value gets overwritten, even if I set the writeback to None. That's not the problem though. I have created another version of the variable_config xml file, modifying the callback method to stop writing to the file (I don't need that) and trying to set the new value to the variable at runtime. This is the modified, non working version of the callback. Note that I don't create a new instance of ConfigParser (not sure if it's needed).

        <callback>self.set_$(id)($value)</callback>
        <callback>self._$(id)_config.read($config_file)
try: $(id) = self._$(id)_config.$(type.get)($section, $option)
except: $(id) = $value
self.$(id) = $(id)
self._$(id)_config.set($section, $option, $id)
print 'self._$(id)_config: ' + str(self._$(id)_config)
print 'section: ' + str($section)
print 'option: ' + str($option)
print 'value: ' + str($value)
print 'id: ' + str($id)
print 'self.$(id): ' + str(self.$(id))
print 'writeback: ' + str($writeback)</callback>

The output of the console is

self._b_config: <ConfigParser.ConfigParser instance at 0x7fee30cd23b0>
section: two
option: b
value: 1
id: 2
self.b: 2
writeback: 2

When I use this variable to change the amplitude of a sine wave at runtime, it doesn't change. What am I doing wrong?

3) I have tried changing the name of the configuration file in a similar way, but I had the same problem.

Cheers,
Murray


reply via email to

[Prev in Thread] Current Thread [Next in Thread]