SignalProcessingブロックの作成:C++

「SignalProcessingブロックの作成:C++」の編集履歴(バックアップ)一覧はこちら

SignalProcessingブロックの作成:C++ - (2011/06/12 (日) 00:21:45) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

*Pythonとの切り分けは? From the Python point of view, GNU Radio provides a data flow abstraction. パイソンはデータフロウの概要を提供する。 From the high level point-of-view, infinite streams of data flow through the ports. At the C++ level, streams are dealt with in convenient sized pieces, represented as contiguous arrays of the underlying type. C++ブロックは潜在に潜む配列によって切り分けられたストリームが扱われる。 *3つのファイルが必要 -xxx.h, xxx.cc #新しいクラスを定義するのに必要。 -xxx.i, SwigにどうやってクラスをPythonにインポートさせるかを教えるのに必要。 *型の指定 入力出力という順で以下のpreffix定義の元クラス名に慣例的に使われる。 -f - single precision floating point -c - complex<float> -s - short (16-bit integer) -i - integer (32-bit integer) *データの流れはgr_vector_XXX(配列)が基本! gr.vector_source_f :source of float's that gets its data from a vector floatのソースをベクトルから取得する。 gr.vector_source_b :source of unsined char's that gets its data from a vector unsined char'sのベクトルをソースから取得する。 14 def test_001_square_ff (self): 15 src_data = (-3, 4, -5.5, 2, 3) 16 expected_result = (9, 16, 30.25, 4, 9) 17 src = gr.vector_source_f (src_data) 18 sqr = howto.square_ff () 19 dst = gr.vector_sink_f () 20 self.fg.connect (src, sqr) 21 self.fg.connect (sqr, dst) 22 self.fg.run () 23 result_data = dst.data () 24 self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6) 79 int howto_square_ff::general_work (int noutput_items, 80 gr_vector_int &ninput_items, 81 gr_vector_const_void_star &input_items, //input_items(gr_vector_const_void_star)はポインタのポインタ 82 gr_vector_void_star &output_items) 83 { 84 const float *in = (const float *) input_items[0]; //gr_vector_const_void_starを(const float *)にキャスト 85 float *out = (float *) output_items[0]; //gr_vector_void_starを(float *)にキャスト 86 87 for (int i = 0; i < noutput_items; i++){ //noutput_itemsの数だけ配列に格納 88 out[i] = in[i] * in[i]; 89 } 90 91 // Tell runtime system how many input items we consumed on 92 // each input stream. 93 94 consume_each (noutput_items); 95 96 // Tell runtime system how many output items we produced. 97 return noutput_items; 98 } gr_vector_XXXは配列のポインタのポインタ? *ブロックが止まるのはEOF gr.vector_source_f(src_data) will source the elements of src_data and then say that it's finished. The returned value of general_work() is the number of items actually written to each output stream, or -1 on EOF. *[[How to make a signal processing block>http://www.snowymtn.ca/GNURadio/GNURAdioDoc-10.pdf]] -noutput_items is the number of output items to write on each output stream. -ninput_items gives the number of input items available on each input stream. -A block may have x input streams and y output streams. -ninput_items is an integer `vector' of length x, the ith element of which gives the number of available items on the ith input stream. -input_items is a vector of pointers to the input items, one entry per input stream. -output_items is a vector of pointers to the output items, one entry per output stream. - ----
*Pythonとの切り分けは? From the Python point of view, GNU Radio provides a data flow abstraction. パイソンはデータフロウの概要を提供する。 From the high level point-of-view, infinite streams of data flow through the ports. At the C++ level, streams are dealt with in convenient sized pieces, represented as contiguous arrays of the underlying type. C++ブロックは潜在に潜む配列によって切り分けられたストリームが扱われる。 *3つのファイルが必要 -xxx.h, xxx.cc #新しいクラスを定義するのに必要。 -xxx.i, SwigにどうやってクラスをPythonにインポートさせるかを教えるのに必要。 *型の指定 入力出力という順で以下のpreffix定義の元クラス名に慣例的に使われる。 -f - single precision floating point -c - complex<float> -s - short (16-bit integer) -i - integer (32-bit integer) *データの流れはgr_vector_XXX(配列)が基本! gr.vector_source_f :source of float's that gets its data from a vector floatのソースをベクトルから取得する。 gr.vector_source_b :source of unsined char's that gets its data from a vector unsined char'sのベクトルをソースから取得する。 14 def test_001_square_ff (self): 15 src_data = (-3, 4, -5.5, 2, 3) 16 expected_result = (9, 16, 30.25, 4, 9) 17 src = gr.vector_source_f (src_data) 18 sqr = howto.square_ff () 19 dst = gr.vector_sink_f () 20 self.fg.connect (src, sqr) 21 self.fg.connect (sqr, dst) 22 self.fg.run () 23 result_data = dst.data () 24 self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6) 79 int howto_square_ff::general_work (int noutput_items, 80 gr_vector_int &ninput_items, 81 gr_vector_const_void_star &input_items, //input_items(gr_vector_const_void_star)はポインタのポインタ 82 gr_vector_void_star &output_items) 83 { 84 const float *in = (const float *) input_items[0]; //gr_vector_const_void_starを(const float *)にキャスト 85 float *out = (float *) output_items[0]; //gr_vector_void_starを(float *)にキャスト 86 87 for (int i = 0; i < noutput_items; i++){ //noutput_itemsの数だけ配列に格納 88 out[i] = in[i] * in[i]; 89 } 90 91 // Tell runtime system how many input items we consumed on 92 // each input stream. 93 94 consume_each (noutput_items); 95 96 // Tell runtime system how many output items we produced. 97 return noutput_items; 98 } gr_vector_XXXは配列のポインタのポインタ? *ブロックが止まるのはEOF gr.vector_source_f(src_data) will source the elements of src_data and then say that it's finished. The returned value of general_work() is the number of items actually written to each output stream, or -1 on EOF. *[[How to make a signal processing block>http://www.snowymtn.ca/GNURadio/GNURAdioDoc-10.pdf]] -noutput_items is the number of output items to write on each output stream. -ninput_items gives the number of input items available on each input stream. -A block may have x input streams and y output streams. -ninput_items is an integer `vector' of length x, the ith element of which gives the number of available items on the ith input stream. -input_items is a vector of pointers to the input items, one entry per input stream. -output_items is a vector of pointers to the output items, one entry per output stream. *[[すべこべ言わずにコンパイルしよう>URL]] ----

表示オプション

横に並べて表示:
変化行の前後のみ表示: