Thursday, July 12, 2018

[Discuss-gnuradio] Help With OOT - QA Test Ok - Flowgraph not Working

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2018 <+YOU OR YOUR COMPANY+>.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#

from gnuradio import gr, gr_unittest
from gnuradio import blocks
from fuzzy_mod_adap_ff_ff import fuzzy_mod_adap_ff_ff

class qa_fuzzy_mod_adap_ff_ff (gr_unittest.TestCase):

def setUp (self):
self.tb = gr.top_block ()

def tearDown (self):
self.tb = None

def test_001_t (self):
src_data1 = (20, 10, 20, 10 )
src_data2 = (1, 1, 0, 0 )
expected_result1 = (40, 40)
expected_result2 = (12, 12)
src1 = blocks.vector_source_f (src_data1)
src2 = blocks.vector_source_f (src_data2)
fuzzy1 = fuzzy_mod_adap_ff_ff ()
snk1 = blocks.vector_sink_f ()
snk2 = blocks.vector_sink_f ()
self.tb.connect (src1, (fuzzy1,0))
self.tb.connect (src2, (fuzzy1,1))
self.tb.connect ((fuzzy1,0), snk1)
self.tb.connect ((fuzzy1,1), snk2)
self.tb.run ()
result1_data = snk1.data ()
result2_data = snk2.data ()
#self.assertFloatTuplesAlmostEqual (expected_result1, result1_data, 6)
#self.assertFloatTuplesAlmostEqual (expected_result2, result2_data, 6)
print(result1_data)
print(result2_data)


if __name__ == '__main__':
gr_unittest.run(qa_fuzzy_mod_adap_ff_ff, "qa_fuzzy_mod_adap_ff_ff.xml")

Hello Everyone,

I am trying to build a controller which will allow to control output power of a signal according to some received variables.

I have build everything according to the tutorial:


The python code of my block is as follows:

#The "Init" part  is as follows:

class fuzzy_mod_adap_ff_ff(gr.sync_block):
    """
    docstring for block fuzzy_mod_adap_ff_ff
    """
    def __init__(self,):
        gr.sync_block.__init__(self,
            name="fuzzy_mod_adap_ff_ff",
            in_sig=[np.float32, np.float32],
            out_sig=[np.float32, np.float32])

.
.
.
.
#The  part of the work function of the code  is as follows:

 def work(self, input_items, output_items):
        in0 = input_items[0]
        in1 = input_items[1]
        out0 = output_items[0]
        out1 = output_items[1]

        for i in range(0, len(in0)):
                X1= in0[i]
                Act_Mod= in1[i]
                self.Normaliza(X1,Act_Mod)
                out1[i], out0[i] = self.Fuzzy()

        return len(output_items[0])

After this I ran the QA Test and the results are:

cecad@project-sistemasdifusossdn:~/Fuzzy_GNU_Blocks/gr-FuzzySyst/python$ python qa_fuzzy_mod_adap_ff_ff.py
(38.653770446777344, 61.346229553222656, 38.653770446777344, 61.346229553222656)
(61.346229553222656, 38.653770446777344, 61.346229553222656, 38.653770446777344)
(38.653770446777344, 61.346229553222656, 38.653770446777344, 61.346229553222656)
(61.346229553222656, 38.653770446777344, 61.346229553222656, 38.653770446777344)
.
----------------------------------------------------------------------
Ran 1 test in 0.021s

OK


The QA Python file is attached, just in case.

Nevertheless, when i try to run  the block in  the following  flowgraph:



The result when i run the Flowgraph is:



The New Mod and Power Out values shows first "0" and after 1 minute or more, change to the value in the previous image.

Nevertheless when i change the variables in the QT Gui, the outputs (New Mod and Poer Out") the don´t change, and if they do they do it after 3 minutes or more.

I dont know what could be the problem because the QA test runs perfect but in the flowgraph it does not.

Just for the record i put a "throttle block" and nothing changed.

I would appreciate all the help you can give me regarding this.

Kind regards.

No comments:

Post a Comment