def\uu init_Uu(self,*args,**kwargs):引发AttributeError(“未定义构造函数”)AttributeError:未定义构造函数

2024-10-01 09:25:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用gr在gnuradio中创建一个新的DSP块_修改工具.py. gnuradio版本是3.3.0。 我在include文件夹的abc.h文件中有以下代码

 ifndef INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H
 #define INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H
 #include <gr_block.h>

 namespace gr {
   namespace energydetector {
 class ENERGYDETECTOR_API local_sensing_ff : virtual public gr_block
 {
  private:

  public:
    typedef boost::shared_ptr<local_sensing_ff> sptr;
    float d_pfa; int d_L; int d_samples;    
    static sptr make(float pfa=0.01,int L=16,int samples=1000);
    virtual void set_pfa(float input_a) { d_pfa = input_a; }  
    virtual int get_pfa() { return d_pfa; } 
    virtual void set_L(int input_b) { d_L = input_b; }  
    virtual int get_L() { return d_L; } 
    virtual void set_samples(int input_c) { d_samples = input_c; }  
   virtual int get_samples() { return d_samples; } 
     };
    } // namespace energydetector
  } // namespace gr
  #endif /* INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H */

上述头文件的实现类为:

^{pr2}$

SWIG文件是abc.i as

 #define ENERGY_DETECTOR_API
 %include "gnuradio.i"          // the common stuff
 %include "energydetector_swig_doc.i"
 %{
    #include "energydetector/local_sensing_ff.h"
  %}

  %include "energydetector/local_sensing_ff.h"
  GR_SWIG_BLOCK_MAGIC2(energydetector, local_sensing_ff);

它成功构建,但在执行时,我得到以下错误:

def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
AttributeError: No constructor defined

请帮我调试一下。在


Tags: inputincludelocalvirtualnamespaceintsamplesff
3条回答

最后我知道这是由于版本不受支持。 gr公司_修改工具.py只有GNURadio 3.6或更高版本支持。在

虽然我们可以构建块并在GRC中使用它,但不确定它为什么不能工作。 它必须是gr生成的代码结构_修改工具.py不适用于3.3.0版

所以任何来问这个问题的人都要确保你有GNURadio 3.6及更高版本。 但是如果有人解决了这个问题_修改工具.py或者任何代码,那么请在这个问题中告诉我们。在

当我从gnuradio.gr.公司import*“从我的代码中可以解决这个问题

SWIG不会为没有公共构造函数或抽象的类生成构造函数。在

http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nn9

相关问题 更多 >