Vector Source: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
mNo edit summary
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Block Docs]]
[[Category:Block Docs]]
Source that streams T items based on the input vector. This block produces a stream of samples based on an input vector. In C++, this is a std::vector<T>, and in Python, this is either a list or tuple. The data can repeat infinitely until the flowgraph is terminated by some other event or, the default, run the data once and stop.
This block produces a stream of samples based on an input vector. In C++, this is a std::vector<T>, and in Python, this is either a list or tuple. The data can repeat indefinitely until the flowgraph is terminated by some other event or, the default, run the data once and stop.


The vector source can also produce stream tags with the data. Pass in a vector of gr::tag_t objects and they will be emitted based on the specified offset of the tag.
The vector source can also produce stream tags with the data. Pass in a vector of gr::tag_t objects and they will be emitted based on the specified offset of the tag.
Line 8: Line 8:
== 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>
; Output Type
: Output data type of data, possible values are complex, float, int, short, byte
: Default value = complex


; Vector (''R'')
; Vector (''R'')
: Vector to be generated
: Vector to be generated
: Default value = (0, 0, 0)


; Tags (''R'')
; Tags (''R'')
: We can create tags as Python lists (or tuples) using the list structure [int offset, pmt key, pmt value, pmt srcid]. It is important to define the list/tuple with the values in the correct order and with the correct data type. A python dictionary can also be used using the keys: "offset", "key", "value", and "srcid" with the same data types as for the lists.
: In Python, we can create tags as Python lists (or tuples) using the list structure [int offset, pmt key, pmt value, pmt srcid]. It is important to define the list/tuple with the values in the correct order and with the correct data type. A python dictionary can also be used using the keys: "offset", "key", "value", and "srcid" with the same data types as for the lists.
: When given a list of tags, the vector source will emit the tags repeatedly by updating the offset relative to the vector stream length. That is, if the vector has 500 items and a tag has an offset of 0, that tag will be placed on item 0, 500, 1000, 1500, etc.
: When given a list of tags, the vector source will emit the tags repeatedly by updating the offset relative to the vector stream length. That is, if the vector has 500 items and a tag has an offset of 0, that tag will be placed on item 0, 500, 1000, 1500, etc.
: In gnuradio-companion, make sure to define a "Tag Object" block for each tag. Your input to the "Tags" parameter will be a list of block ids, like seen below in the screenshots. The offset in the vector is decided by the tag object.
: Default value = []


; Repeat
; Repeat
Line 20: Line 27:


; Vec Length
; Vec Length
: Length of the '''output''' vector
: Length of the '''output''' vector, i.e. if set to 1 then it will output just a normal stream.


== Example Flowgraph ==
== Example Flowgraph ==
The following example uses a 0 and a 1 output in a stream to control another block.
[[File:Vector_source_with_tags.png]]


Insert description of flowgraph here, then show a screenshot of the flowgraph and the output if there is an interesting GUI. Currently we have no standard method of uploading the actual flowgraph to the wiki or git repo, unfortunately.  The 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.
[[File:Tag_object_block_properties_box.png]][[File:Vector_source_with_tags_properties_box.png]]


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


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


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


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


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

Latest revision as of 18:44, 14 May 2024

This block produces a stream of samples based on an input vector. In C++, this is a std::vector<T>, and in Python, this is either a list or tuple. The data can repeat indefinitely until the flowgraph is terminated by some other event or, the default, run the data once and stop.

The vector source can also produce stream tags with the data. Pass in a vector of gr::tag_t objects and they will be emitted based on the specified offset of the tag.

GNU Radio provides a utility Python module in gr.tag_utils to convert between tags and Python objects: gr.tag_utils.python_to_tag.

Parameters

(R): Run-time adjustable

Output Type
Output data type of data, possible values are complex, float, int, short, byte
Default value = complex
Vector (R)
Vector to be generated
Default value = (0, 0, 0)
Tags (R)
In Python, we can create tags as Python lists (or tuples) using the list structure [int offset, pmt key, pmt value, pmt srcid]. It is important to define the list/tuple with the values in the correct order and with the correct data type. A python dictionary can also be used using the keys: "offset", "key", "value", and "srcid" with the same data types as for the lists.
When given a list of tags, the vector source will emit the tags repeatedly by updating the offset relative to the vector stream length. That is, if the vector has 500 items and a tag has an offset of 0, that tag will be placed on item 0, 500, 1000, 1500, etc.
In gnuradio-companion, make sure to define a "Tag Object" block for each tag. Your input to the "Tags" parameter will be a list of block ids, like seen below in the screenshots. The offset in the vector is decided by the tag object.
Default value = []
Repeat
Whether or not to repeat the vector when it's done
Vec Length
Length of the output vector, i.e. if set to 1 then it will output just a normal stream.

Example Flowgraph

The following example uses a 0 and a 1 output in a stream to control another block.

Vector source with tags.png


Tag object block properties box.pngVector source with tags properties box.png

Source Files

C++ files
vector_source_impl.cc
Header files
vector_source_impl.h
Public header files
vector_source.h
Block definition
blocks_vector_source_x.block.yml