GNU Radio 3.6.4.2 C++ API
|
#include <gr_block.h>
Public Types | |
enum | { WORK_CALLED_PRODUCE = -2, WORK_DONE = -1 } |
Return options for the work call. More... | |
enum | tag_propagation_policy_t { TPP_DONT = 0, TPP_ALL_TO_ALL = 1, TPP_ONE_TO_ONE = 2 } |
typedef std::deque< pmt::pmt_t > | msg_queue_t |
typedef std::map< pmt::pmt_t, msg_queue_t, pmt::pmt_comperator > | msg_queue_map_t |
typedef std::map< pmt::pmt_t, msg_queue_t, pmt::pmt_comperator > ::iterator | msg_queue_map_itr |
typedef boost::function< void(pmt::pmt_t)> | msg_handler_t |
typedef std::map< pmt::pmt_t, msg_handler_t, pmt::pmt_comperator > | d_msg_handlers_t |
Public Member Functions | |
gr_block (void) | |
gr_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature) | |
long | unique_id (void) const |
std::string | name (void) const |
virtual | ~gr_block (void) |
gr_io_signature_sptr | input_signature (void) const |
gr_io_signature_sptr | output_signature (void) const |
void | set_input_signature (gr_io_signature_sptr sig) |
void | set_output_signature (gr_io_signature_sptr sig) |
virtual bool | check_topology (int ninputs, int noutputs) |
virtual void | forecast (int, std::vector< int > &) |
Overload me! I am the forecast. | |
virtual int | general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) |
compute output items from input items | |
virtual bool | start (void) |
virtual bool | stop (void) |
void | consume_each (const int how_many_items) |
Call during work to consume items. | |
void | consume (const size_t i, const int how_many_items) |
void | produce (const size_t o, const int how_many_items) |
uint64_t | nitems_read (const size_t which_input=0) |
Get absolute count of all items consumed on the given input port. | |
uint64_t | nitems_written (const size_t which_output=0) |
Get absolute count of all items produced on the given output port. | |
void | add_item_tag (const size_t which_output, const gr_tag_t &tag) |
void | add_item_tag (const size_t which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, const pmt::pmt_t &srcid=pmt::PMT_F) |
void | get_tags_in_range (std::vector< gr_tag_t > &tags, const size_t which_input, uint64_t abs_start, uint64_t abs_end, const pmt::pmt_t &key=pmt::pmt_t()) |
void | set_alignment (const size_t alignment) |
bool | is_unaligned (void) |
size_t | fixed_rate_noutput_to_ninput (const size_t noutput_items) |
size_t | interpolation (void) const |
void | set_interpolation (const size_t) |
size_t | decimation (void) const |
void | set_decimation (const size_t) |
int | max_noutput_items (void) const |
void | set_max_noutput_items (int) |
void | unset_max_noutput_items (void) |
bool | is_set_max_noutput_items (void) const |
unsigned | history (void) const |
void | set_history (unsigned history) |
void | set_fixed_rate (const bool fixed_rate) |
bool | fixed_rate (void) const |
Get the fixed rate setting. | |
void | set_relative_rate (const double relative_rate) |
double | relative_rate (void) const |
Get the relative rate setting. | |
void | set_output_multiple (const size_t multiple) |
size_t | output_multiple (void) const |
Get the output multiple setting. | |
tag_propagation_policy_t | tag_propagation_policy (void) |
void | set_tag_propagation_policy (tag_propagation_policy_t p) |
void | set_max_output_buffer (long) |
void | set_max_output_buffer (int, long) |
long | max_output_buffer (size_t) |
void | set_min_output_buffer (long) |
void | set_min_output_buffer (int, long) |
long | min_output_buffer (size_t) |
std::string | symbol_name () const |
bool | alias_set () |
std::string | alias () |
pmt::pmt_t | alias_pmt () |
void | set_block_alias (std::string name) |
template<typename T > | |
void | set_msg_handler (pmt::pmt_t which_port, T msg_handler) |
void | message_port_register_in (pmt::pmt_t) |
void | message_port_register_out (pmt::pmt_t) |
void | message_port_pub (pmt::pmt_t, pmt::pmt_t) |
void | message_port_sub (pmt::pmt_t, pmt::pmt_t) |
void | message_port_unsub (pmt::pmt_t, pmt::pmt_t) |
virtual bool | message_port_is_hier (pmt::pmt_t port_id) |
virtual bool | message_port_is_hier_in (pmt::pmt_t port_id) |
virtual bool | message_port_is_hier_out (pmt::pmt_t port_id) |
pmt::pmt_t | message_ports_in () |
Get input message port names. | |
pmt::pmt_t | message_ports_out () |
Get output message port names. | |
bool | empty_p (pmt::pmt_t which_port) |
is the queue empty? | |
bool | empty_p () |
void | insert_tail (pmt::pmt_t, pmt::pmt_t) |
pmt::pmt_t | delete_head_nowait (pmt::pmt_t) |
pmt::pmt_t | delete_head_blocking (pmt::pmt_t) |
msg_queue_t::iterator | get_iterator (pmt::pmt_t which_port) |
void | erase_msg (pmt::pmt_t which_port, msg_queue_t::iterator it) |
virtual bool | has_msg_port (pmt::pmt_t which_port) |
bool | has_msg_handler (pmt::pmt_t which_port) |
Tests if there is a handler attached to port which_port . | |
virtual void | dispatch_msg (pmt::pmt_t which_port, pmt::pmt_t msg) |
void | set_processor_affinity (const std::vector< int > &mask) |
Set the thread's affinity to processor core n . | |
void | unset_processor_affinity () |
Remove processor affinity to a specific core. | |
std::vector< int > | processor_affinity () |
Get the current processor affinity. | |
void | work (const InputItems &, const OutputItems &) |
implements work -> calls general work | |
void | notify_topology (const size_t, const size_t) |
notifications of new topological commits | |
void | notify_active (void) |
start notification | |
void | notify_inactive (void) |
stop notification | |
virtual void | propagate_tags (const size_t, const gras::TagIter &) |
implements tag_propagation_policy() | |
void | _update_input_reserve (void) |
gras::BufferQueueSptr | input_buffer_allocator (const size_t, const gras::SBufferConfig &) |
gras::BufferQueueSptr | output_buffer_allocator (const size_t, const gras::SBufferConfig &) |
Public Attributes | |
long | _unique_id |
std::string | _name |
std::string | d_symbol_alias |
std::string | d_symbol_name |
msg_queue_map_t | msg_queue |
pmt::pmt_t | message_subscribers |
d_msg_handlers_t | d_msg_handlers |
gruel::mutex | d_setlock |
std::vector< int > | d_affinity |
gr_vector_int | _work_ninput_items |
gr_vector_int | _fcast_ninput_items |
size_t | _num_outputs |
ptrdiff_t | _work_io_ptr_mask |
size_t | _output_multiple_items |
double | _relative_rate |
bool | _enable_fixed_rate |
size_t | _input_history_items |
tag_propagation_policy_t | _tag_prop_policy |
size_t | _interp |
size_t | _decim |
gr_io_signature_sptr | _in_sig |
gr_io_signature_sptr | _out_sig |
typedef std::map<pmt::pmt_t , msg_handler_t, pmt::pmt_comperator> gr_block::d_msg_handlers_t |
typedef boost::function<void(pmt::pmt_t)> gr_block::msg_handler_t |
typedef std::map<pmt::pmt_t, msg_queue_t, pmt::pmt_comperator>::iterator gr_block::msg_queue_map_itr |
typedef std::map<pmt::pmt_t, msg_queue_t, pmt::pmt_comperator> gr_block::msg_queue_map_t |
typedef std::deque<pmt::pmt_t> gr_block::msg_queue_t |
gr_block::gr_block | ( | const std::string & | name, |
gr_io_signature_sptr | input_signature, | ||
gr_io_signature_sptr | output_signature | ||
) |
virtual gr_block::~gr_block | ( | void | ) | [virtual] |
void gr_block::add_item_tag | ( | const size_t | which_output, |
const gr_tag_t & | tag | ||
) |
Referenced by gr_block_gateway::gr_block__add_item_tag().
void gr_block::add_item_tag | ( | const size_t | which_output, |
uint64_t | abs_offset, | ||
const pmt::pmt_t & | key, | ||
const pmt::pmt_t & | value, | ||
const pmt::pmt_t & | srcid = pmt::PMT_F |
||
) |
std::string gr_block::alias | ( | ) | [inline] |
pmt::pmt_t gr_block::alias_pmt | ( | ) | [inline] |
References pmt::pmt_intern().
bool gr_block::alias_set | ( | ) | [inline] |
virtual bool gr_block::check_topology | ( | int | ninputs, |
int | noutputs | ||
) | [virtual] |
Reimplemented in gr_pfb_clock_sync_ccf, gr_pfb_clock_sync_fff, gr_test, comedi_source_s, comedi_sink_s, gr_align_on_samplenumbers_ss, gr_oscope_sink_f, gr_deinterleave, gr_interleave, gr_copy, gr_kludge_copy, gr::blocks::deinterleave_impl, and gr::blocks::interleave_impl.
Referenced by gr_test::set_check_topology().
GRAS_FORCE_INLINE void gr_block::consume | ( | const size_t | i, |
const int | how_many_items | ||
) |
Referenced by consume_each(), and gr_block_gateway::gr_block__consume().
GRAS_FORCE_INLINE void gr_block::consume_each | ( | const int | how_many_items | ) |
Call during work to consume items.
References consume().
Referenced by gr_sync_block::general_work(), and gr_block_gateway::gr_block__consume_each().
GRAS_FORCE_INLINE size_t gr_block::decimation | ( | void | ) | const |
References _decim.
Referenced by gr_sync_block::general_work().
pmt::pmt_t gr_block::delete_head_blocking | ( | pmt::pmt_t | ) | [inline] |
References pmt::PMT_NIL.
pmt::pmt_t gr_block::delete_head_nowait | ( | pmt::pmt_t | ) | [inline] |
References pmt::PMT_NIL.
virtual void gr_block::dispatch_msg | ( | pmt::pmt_t | which_port, |
pmt::pmt_t | msg | ||
) | [inline, virtual] |
Reimplemented in gr_block_gateway.
Referenced by gr_block_gateway::dispatch_msg().
bool gr_block::empty_p | ( | pmt::pmt_t | which_port | ) | [inline] |
is the queue empty?
bool gr_block::empty_p | ( | ) | [inline] |
void gr_block::erase_msg | ( | pmt::pmt_t | which_port, |
msg_queue_t::iterator | it | ||
) | [inline] |
bool gr_block::fixed_rate | ( | void | ) | const |
Get the fixed rate setting.
Referenced by gr_block_gateway::gr_block__fixed_rate().
size_t gr_block::fixed_rate_noutput_to_ninput | ( | const size_t | noutput_items | ) |
virtual void gr_block::forecast | ( | int | , |
std::vector< int > & | |||
) | [virtual] |
Overload me! I am the forecast.
virtual int gr_block::general_work | ( | int | noutput_items, |
gr_vector_int & | ninput_items, | ||
gr_vector_const_void_star & | input_items, | ||
gr_vector_void_star & | output_items | ||
) | [virtual] |
compute output items from input items
noutput_items | number of output items to write on each output stream |
ninput_items | number of input items available on each input stream |
input_items | vector of pointers to the input items, one entry per input stream |
output_items | vector of pointers to the output items, one entry per output stream |
general_work must call consume or consume_each to indicate how many items were consumed on each input stream.
Reimplemented in gr_pfb_clock_sync_ccf, gr_pfb_clock_sync_fff, gr_pfb_channelizer_ccf, gr_pfb_arb_resampler_ccf, gr_pfb_arb_resampler_fff, qtgui_sink_c, qtgui_sink_f, gr_simple_correlator, gr_align_on_samplenumbers_ss, gr_stream_mux, gr::filter::pfb_arb_resampler_ccf_impl, gr::filter::pfb_arb_resampler_fff_impl, gr_ofdm_bpsk_demapper, gr_test, gr::filter::pfb_channelizer_ccf_impl, gr_copy, gr_keep_m_in_n, gr_delay, gr_skiphead, gr_keep_one_in_n, gr_squelch_base_cc, gr_squelch_base_ff, gr_nop, gr_simple_framer, gr::blocks::delay_impl, gr::filter::fractional_interpolator_cc_impl, gr::filter::fractional_interpolator_ff_impl, gr_fractional_interpolator_cc, gr_fractional_interpolator_ff, gr::blocks::stream_mux_impl, gr::blocks::keep_m_in_n_impl, gr_sync_block, gr::blocks::keep_one_in_n_impl, and gr::blocks::patterned_interleaver_impl.
msg_queue_t::iterator gr_block::get_iterator | ( | pmt::pmt_t | which_port | ) | [inline] |
void gr_block::get_tags_in_range | ( | std::vector< gr_tag_t > & | tags, |
const size_t | which_input, | ||
uint64_t | abs_start, | ||
uint64_t | abs_end, | ||
const pmt::pmt_t & | key = pmt::pmt_t() |
||
) |
Referenced by gr_block_gateway::gr_block__get_tags_in_range().
bool gr_block::has_msg_handler | ( | pmt::pmt_t | which_port | ) | [inline] |
Tests if there is a handler attached to port which_port
.
virtual bool gr_block::has_msg_port | ( | pmt::pmt_t | which_port | ) | [inline, virtual] |
References pmt::pmt_dict_has_key().
unsigned gr_block::history | ( | void | ) | const |
gras::BufferQueueSptr gr_block::input_buffer_allocator | ( | const size_t | , |
const gras::SBufferConfig & | |||
) |
void gr_block::insert_tail | ( | pmt::pmt_t | , |
pmt::pmt_t | |||
) | [inline] |
GRAS_FORCE_INLINE size_t gr_block::interpolation | ( | void | ) | const |
References _interp.
Referenced by gr_sync_block::general_work().
bool gr_block::is_set_max_noutput_items | ( | void | ) | const |
GRAS_FORCE_INLINE bool gr_block::is_unaligned | ( | void | ) |
References _work_io_ptr_mask.
int gr_block::max_noutput_items | ( | void | ) | const |
long gr_block::max_output_buffer | ( | size_t | ) | [inline] |
virtual bool gr_block::message_port_is_hier | ( | pmt::pmt_t | port_id | ) | [inline, virtual] |
References void().
virtual bool gr_block::message_port_is_hier_in | ( | pmt::pmt_t | port_id | ) | [inline, virtual] |
References void().
virtual bool gr_block::message_port_is_hier_out | ( | pmt::pmt_t | port_id | ) | [inline, virtual] |
References void().
void gr_block::message_port_pub | ( | pmt::pmt_t | , |
pmt::pmt_t | |||
) | [inline] |
Referenced by gr_block_gateway::gr_block__message_port_pub().
void gr_block::message_port_register_in | ( | pmt::pmt_t | ) | [inline] |
Referenced by gr_block_gateway::gr_block__message_port_register_in().
void gr_block::message_port_register_out | ( | pmt::pmt_t | ) | [inline] |
Referenced by gr_block_gateway::gr_block__message_port_register_out().
void gr_block::message_port_sub | ( | pmt::pmt_t | , |
pmt::pmt_t | |||
) | [inline] |
Referenced by gr_block_gateway::gr_block__message_port_sub().
void gr_block::message_port_unsub | ( | pmt::pmt_t | , |
pmt::pmt_t | |||
) | [inline] |
Referenced by gr_block_gateway::gr_block__message_port_unsub().
pmt::pmt_t gr_block::message_ports_in | ( | ) | [inline] |
Get input message port names.
Returns the available input message ports for a block. The return object is a PMT vector that is filled with PMT symbols.
References pmt::PMT_NIL.
Referenced by gr_block_gateway::gr_block__message_ports_in().
pmt::pmt_t gr_block::message_ports_out | ( | ) | [inline] |
Get output message port names.
Returns the available output message ports for a block. The return object is a PMT vector that is filled with PMT symbols.
References pmt::PMT_NIL.
Referenced by gr_block_gateway::gr_block__message_ports_out().
long gr_block::min_output_buffer | ( | size_t | ) | [inline] |
std::string gr_block::name | ( | void | ) | const [inline] |
Referenced by gr_block_gateway::gr_block__name().
GRAS_FORCE_INLINE uint64_t gr_block::nitems_read | ( | const size_t | which_input = 0 | ) |
Get absolute count of all items consumed on the given input port.
Referenced by gr_block_gateway::gr_block__nitems_read().
GRAS_FORCE_INLINE uint64_t gr_block::nitems_written | ( | const size_t | which_output = 0 | ) |
Get absolute count of all items produced on the given output port.
Referenced by gr_block_gateway::gr_block__nitems_written().
start notification
stop notification
void gr_block::notify_topology | ( | const size_t | , |
const size_t | |||
) |
notifications of new topological commits
gras::BufferQueueSptr gr_block::output_buffer_allocator | ( | const size_t | , |
const gras::SBufferConfig & | |||
) |
size_t gr_block::output_multiple | ( | void | ) | const |
Get the output multiple setting.
Referenced by gr_block_gateway::gr_block__output_multiple().
std::vector<int> gr_block::processor_affinity | ( | ) | [inline] |
Get the current processor affinity.
GRAS_FORCE_INLINE void gr_block::produce | ( | const size_t | o, |
const int | how_many_items | ||
) |
Referenced by gr_block_gateway::gr_block__produce().
virtual void gr_block::propagate_tags | ( | const size_t | , |
const gras::TagIter & | |||
) | [virtual] |
implements tag_propagation_policy()
double gr_block::relative_rate | ( | void | ) | const |
Get the relative rate setting.
Referenced by gr_test::fixed_rate_ninput_to_noutput(), gr_test::fixed_rate_noutput_to_ninput(), gr_test::forecast(), and gr_block_gateway::gr_block__relative_rate().
void gr_block::set_alignment | ( | const size_t | alignment | ) |
void gr_block::set_block_alias | ( | std::string | name | ) | [inline] |
void gr_block::set_decimation | ( | const size_t | ) |
void gr_block::set_fixed_rate | ( | const bool | fixed_rate | ) |
Enable fixed rate logic. When enabled, relative rate is assumed to be set, and forecast is automatically called. Also, consume will be called automatically.
Referenced by gr_block_gateway::gr_block__set_fixed_rate(), and gr_test::set_fixed_rate_public().
void gr_block::set_history | ( | unsigned | history | ) |
Referenced by gr_block_gateway::gr_block__set_history().
void gr_block::set_interpolation | ( | const size_t | ) |
void gr_block::set_max_noutput_items | ( | int | ) |
void gr_block::set_max_output_buffer | ( | long | ) | [inline] |
void gr_block::set_max_output_buffer | ( | int | , |
long | |||
) | [inline] |
void gr_block::set_min_output_buffer | ( | long | ) | [inline] |
void gr_block::set_min_output_buffer | ( | int | , |
long | |||
) | [inline] |
void gr_block::set_msg_handler | ( | pmt::pmt_t | which_port, |
T | msg_handler | ||
) | [inline] |
void gr_block::set_output_multiple | ( | const size_t | multiple | ) |
The output multiple setting controls work output buffer sizes. Buffers will be number of items modulo rounted to the multiple.
Referenced by gr_block_gateway::gr_block__set_output_multiple().
void gr_block::set_processor_affinity | ( | const std::vector< int > & | mask | ) | [inline] |
Set the thread's affinity to processor core n
.
mask | a vector of unsigned ints of the core numbers available to this block. |
void gr_block::set_relative_rate | ( | const double | relative_rate | ) |
The relative rate can be thought of as interpolation/decimation. In other words, relative rate is the ratio of output items to input items.
Referenced by gr_block_gateway::gr_block__set_relative_rate(), gr_pfb_arb_resampler_fff::set_rate(), and gr_pfb_arb_resampler_ccf::set_rate().
Referenced by gr_block_gateway::gr_block__set_tag_propagation_policy().
virtual bool gr_block::start | ( | void | ) | [virtual] |
Reimplemented in gr_random_pdu.
virtual bool gr_block::stop | ( | void | ) | [virtual] |
std::string gr_block::symbol_name | ( | ) | const [inline] |
Referenced by gr_block_gateway::gr_block__tag_propagation_policy().
long gr_block::unique_id | ( | void | ) | const [inline] |
Referenced by gr_block_gateway::gr_block__unique_id().
void gr_block::unset_processor_affinity | ( | ) | [inline] |
Remove processor affinity to a specific core.
void gr_block::work | ( | const InputItems & | , |
const OutputItems & | |||
) |
implements work -> calls general work
size_t gr_block::_decim |
Referenced by decimation().
gr_vector_int gr_block::_fcast_ninput_items |
size_t gr_block::_interp |
Referenced by interpolation().
std::string gr_block::_name |
size_t gr_block::_num_outputs |
double gr_block::_relative_rate |
long gr_block::_unique_id |
ptrdiff_t gr_block::_work_io_ptr_mask |
Referenced by is_unaligned().
gr_vector_int gr_block::_work_ninput_items |
std::vector<int> gr_block::d_affinity |
Used by block's setters and work functions to make setting/resetting of parameters thread-safe.
Used by calling gruel::scoped_lock l(d_setlock);
std::string gr_block::d_symbol_alias |
std::string gr_block::d_symbol_name |