def __init __ (self, * args, ** kwargs): повышение AttributeError (& quot; конструктор не определен & quot;) AttributeError: конструктор не определено

Я пытаюсь создать новый блок DSP в gnuradio, используя gr_modtool.py. Версия gnuradio — 3.3.0.
У меня есть следующий код в файле abc.h в папке include

 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 */

Класс реализации для заголовочного файла выше:

 #ifndef INCLUDED_ENERGY-DETECTOR_LOCAL_SENSING_FF_IMPL_H
#define INCLUDED_ENERGY-DETECTOR_LOCAL_SENSING_FF_IMPL_H

#include <energy-detector/local_sensing_ff.h>

namespace gr {
namespace energydetector {
class local_sensing_ff_impl : public local_sensing_ff
{
private:
float d_pfa; int d_L; int d_samples;
public:
local_sensing_ff_impl(float pfa,int L,int samples);
~local_sensing_ff_impl();
void set_pfa(float input_a) { d_pfa = input_a; }
int get_pfa() { return d_pfa; }
void set_L(int input_b) { d_L = input_b; }
int get_L() { return d_L; }
void set_samples(int input_c) { d_samples = input_c; }
int get_samples() { return d_samples; }
int general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
} // namespace energy-detector
} // namespace gr
#endif /* INCLUDED_ENERGY-DETECTOR_LOCAL_SENSING_FF_IMPL_H */

И SWIG файл abc.i как

 #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

Пожалуйста, помогите мне отладить это.

1

Решение

Наконец я узнал, что это произошло из-за не поддерживаемой версии.
gr_modtool.py поддерживается только GNURadio 3.6 или выше.

Хотя мы можем построить блок и использовать его в GRC, но не уверены, почему он не может работать.
Это должна быть структура кода, сгенерированная gr_modtool.py, не работает с версией 3.3.0

поэтому любой, кто приходил на этот вопрос, должен убедиться, что у вас GNURadio 3.6 и выше.
Но если кто-то решил эту проблему, изменив gr_modtool.py или любой другой код, пожалуйста, сообщите нам об этом.

0

Другие решения

когда я удаляю «из gnuradio.gr import *» из моего кода, эта проблема исчезает

0

SWIG не будет создавать конструктор для класса, который не имеет публичного конструктора или является абстрактным.

Увидеть http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nn9

-1
По вопросам рекламы [email protected]