Selector: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(Created page with "Category:Block Docs Category:Stub Docs This is the template for the "Page-per-block Docs". This first section should describe what the block...")
 
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Block Docs]]
[[Category:Block Docs]]
[[Category:Stub Docs]]
Connect the sink at input index to the source at output indexSamples from other input ports are consumed and dumpedOther output ports produce no samples.
This is the template for the [[:Category:Block_Docs|"Page-per-block Docs"]]This first section should describe what the block does and how to use it, using however many paragraphs necessaryNote that the title of the wiki page should match the block's name in GRC, i.e. the one defined in the block's .grc file.  Look at the [[FFT]] Block for a good example.


As this is a basic template, it's also in the [[:Category:Stub_Docs|"Stub Docs category"]]. Please improve it.
output[output_index][i] = input[input_index][i]


== Parameters ==
== Parameters ==
(''R''): <span class="plainlinks">[https://wiki.gnuradio.org/index.php/GNURadioCompanion#Variable_Controls ''Run-time adjustable'']</span>
(''R''): <span class="plainlinks">[https://wiki.gnuradio.org/index.php/GNURadioCompanion#Variable_Controls ''Run-time adjustable'']</span>


; Param 1 (''R'')
; Enabled (''R'')
: Description of parameter, provide any tips or recommended values. Note that the name of the parameter above should match the param's label that shows up in grc (e.g. Sample Rate).
: Whether or not input gets copied to output.
: NOTE: Selector block prior to GR 3.8 does not have Enabled parameter


; Param 2
; Number of Inputs
: blah blah blah
: Number of input streams
 
; Number of Outputs
: Number of output streams
 
; Input Index (''R'')
: Used to choose which input stream gets used.  It is typical for this to be changed in realtime using e.g. a [[QT GUI Chooser]]
 
; Output Index (''R'')
: Used to choose which output stream gets the input copied to it.  It is typical for this to be changed in realtime using e.g. a [[QT GUI Chooser]]
 
== Messages ==
 
; Enable
: The 'en' message port accepts only <b>raw</b> PMT messages of the form <code>pmt.to_pmt(False)</code> or <code>pmt.to_pmt(True)</code>
 
; Input index
: The 'iindex' message port accepts a PMT message pair such as <code>pmt.cons(pmt.PMT_NIL, pmt.from_long(iindex))</code>
 
; Output index
: The 'oindex' message port accepts a PMT message pair such as <code>pmt.cons(pmt.PMT_NIL, pmt.from_long(oindex))</code>


== Example Flowgraph ==
== Example Flowgraph ==


Insert description of flowgraph here, then show a screenshot of the flowgraph and the output if there is an interesting GUICurrently we have no standard method of uploading the actual flowgraph to the wiki or git repo, unfortunatelyThe plan is to have an example flowgraph showing how the block might be used, for every block, and the flowgraphs will live in the git repo.
=== Using Parameters ===
This example flowgraph is located in [https://github.com/gnuradio/gnuradio/blob/master/gr-blocks/examples/selector.grc]
 
[[File:Selector_example_flowgraph.png|800px]]
 
In this example, there are three input signals, which can be directed by the parameters of the selector block to one of two of the output ports.  In the case where the input is set to 0 and the output is set to 0, we get the cosine signal passing from input 0 to Output 0In this case Output 1 produces no samples.
 
[[File:Selector_output_1.png|800px]]
 
If we change the output index to 1, and the input index to 1, we see the triangle wave produced at output 1Output 0 in this case is producing no output samples, but the QT GUI Time sink does not update the display.
 
[[File:Selector_output_2.png|800px]]
 
=== Using Messages ===
Messages can be used to enable the block and to select the input and output ports. Here is a snippet of a flowgraph to illustrate:
 
[[File:Selector_demo_fg.png|800px]]


== Source Files ==
== Source Files ==


; C++ files
; C++ files
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-blocks/lib/selector_impl.cc]


; Header files
; Header files
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-blocks/lib/selector_impl.h]


; Public header files
; Public header files
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-blocks/include/gnuradio/blocks/selector.h]


; Block definition
; Block definition
: [https://github.com/gnuradio/gnuradio TODO]
: [https://github.com/gnuradio/gnuradio/blob/master/gr-blocks/grc/blocks_selector.block.yml]

Latest revision as of 10:52, 19 June 2024

Connect the sink at input index to the source at output index. Samples from other input ports are consumed and dumped. Other output ports produce no samples.

output[output_index][i] = input[input_index][i]

Parameters

(R): Run-time adjustable

Enabled (R)
Whether or not input gets copied to output.
NOTE: Selector block prior to GR 3.8 does not have Enabled parameter
Number of Inputs
Number of input streams
Number of Outputs
Number of output streams
Input Index (R)
Used to choose which input stream gets used. It is typical for this to be changed in realtime using e.g. a QT GUI Chooser
Output Index (R)
Used to choose which output stream gets the input copied to it. It is typical for this to be changed in realtime using e.g. a QT GUI Chooser

Messages

Enable
The 'en' message port accepts only raw PMT messages of the form pmt.to_pmt(False) or pmt.to_pmt(True)
Input index
The 'iindex' message port accepts a PMT message pair such as pmt.cons(pmt.PMT_NIL, pmt.from_long(iindex))
Output index
The 'oindex' message port accepts a PMT message pair such as pmt.cons(pmt.PMT_NIL, pmt.from_long(oindex))

Example Flowgraph

Using Parameters

This example flowgraph is located in [1]

Selector example flowgraph.png

In this example, there are three input signals, which can be directed by the parameters of the selector block to one of two of the output ports. In the case where the input is set to 0 and the output is set to 0, we get the cosine signal passing from input 0 to Output 0. In this case Output 1 produces no samples.

Selector output 1.png

If we change the output index to 1, and the input index to 1, we see the triangle wave produced at output 1. Output 0 in this case is producing no output samples, but the QT GUI Time sink does not update the display.

Selector output 2.png

Using Messages

Messages can be used to enable the block and to select the input and output ports. Here is a snippet of a flowgraph to illustrate:

Selector demo fg.png

Source Files

C++ files
[2]
Header files
[3]
Public header files
[4]
Block definition
[5]