GNU Radio 3.6.4.2 C++ API
gr_test Class Reference

Test class for testing runtime system (setting up buffers and such.)This block does not do any usefull actual data processing. It just exposes setting all standard block parameters using the contructor or public methods. More...

#include <gr_test.h>

Inheritance diagram for gr_test:
gr_block

Public Member Functions

 ~gr_test ()
 
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 More...
 
void forecast (int noutput_items, gr_vector_int &ninput_items_required)
 Estimate input requirements given output request. More...
 
void set_check_topology (bool check_topology)
 Force check topology to return true or false. More...
 
bool check_topology (int ninputs, int noutputs)
 Confirm that ninputs and noutputs is an acceptable combination. More...
 
int fixed_rate_ninput_to_noutput (int ninput)
 Given ninput samples, return number of output samples that will be produced. N.B. this is only defined if fixed_rate returns true. Generally speaking, you don't need to override this. More...
 
int fixed_rate_noutput_to_ninput (int noutput)
 Given noutput samples, return number of input samples required to produce noutput. N.B. this is only defined if fixed_rate returns true. More...
 
void set_fixed_rate_public (bool fixed_rate)
 Set if fixed rate should return true. N.B. This is normally a private method but we make it available here as public. More...
 
void set_consume_type (gr_consume_type_t cons_type)
 Set the consume pattern. More...
 
void set_consume_limit (unsigned int limit)
 Set the consume limit. More...
 
void set_produce_type (gr_produce_type_t prod_type)
 Set the produce pattern. More...
 
void set_produce_limit (unsigned int limit)
 Set the produce limit. More...
 
- Public Member Functions inherited from gr_block
 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 void forecast (int, std::vector< int > &)
 Overload me! I am the forecast. More...
 
virtual bool start (void)
 
virtual bool stop (void)
 
void consume_each (const int how_many_items)
 Call during work to consume items. More...
 
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. More...
 
uint64_t nitems_written (const size_t which_output=0)
 Get absolute count of all items produced on the given output port. More...
 
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. More...
 
void set_relative_rate (const double relative_rate)
 
double relative_rate (void) const
 Get the relative rate setting. More...
 
void set_output_multiple (const size_t multiple)
 
size_t output_multiple (void) const
 Get the output multiple setting. More...
 
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. More...
 
pmt::pmt_t message_ports_out ()
 Get output message port names. More...
 
bool empty_p (pmt::pmt_t which_port)
 is the queue empty? More...
 
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. More...
 
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. More...
 
void unset_processor_affinity ()
 Remove processor affinity to a specific core. More...
 
std::vector< int > processor_affinity ()
 Get the current processor affinity. More...
 
void work (const InputItems &, const OutputItems &)
 implements work -> calls general work More...
 
void notify_topology (const size_t, const size_t)
 notifications of new topological commits More...
 
void notify_active (void)
 start notification More...
 
void notify_inactive (void)
 stop notification More...
 
virtual void propagate_tags (const size_t, const gras::TagIter &)
 implements tag_propagation_policy() More...
 
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 &)
 

Protected Member Functions

 gr_test (const std::string &name, int min_inputs, int max_inputs, unsigned int sizeof_input_item, int min_outputs, int max_outputs, unsigned int sizeof_output_item, unsigned int history, unsigned int output_multiple, double relative_rate, bool fixed_rate, gr_consume_type_t cons_type, gr_produce_type_t prod_type)
 

Protected Attributes

unsigned int d_sizeof_input_item
 
unsigned int d_sizeof_output_item
 
bool d_check_topology
 
char d_temp
 
gr_consume_type_t d_consume_type
 
int d_min_consume
 
int d_max_consume
 
gr_produce_type_t d_produce_type
 
int d_min_produce
 
int d_max_produce
 

Friends

GR_CORE_API gr_test_sptr gr_make_test (const std::string &name, int min_inputs, int max_inputs, unsigned int sizeof_input_item, int min_outputs, int max_outputs, unsigned int sizeof_output_item, unsigned int history, unsigned int output_multiple, double relative_rate, bool fixed_rate, gr_consume_type_t cons_type, gr_produce_type_t prod_type)
 

Additional Inherited Members

- Public Types inherited from gr_block
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_tmsg_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 Attributes inherited from gr_block
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
 

Detailed Description

Test class for testing runtime system (setting up buffers and such.)

This block does not do any usefull actual data processing. It just exposes setting all standard block parameters using the contructor or public methods.

This block can be usefull when testing the runtime system. You can force this block to have a large history, decimation factor and/or large output_multiple. The runtime system should detect this and create large enough buffers all through the signal chain.

Constructor & Destructor Documentation

gr_test::~gr_test ( )
inline
gr_test::gr_test ( const std::string &  name,
int  min_inputs,
int  max_inputs,
unsigned int  sizeof_input_item,
int  min_outputs,
int  max_outputs,
unsigned int  sizeof_output_item,
unsigned int  history,
unsigned int  output_multiple,
double  relative_rate,
bool  fixed_rate,
gr_consume_type_t  cons_type,
gr_produce_type_t  prod_type 
)
protected

Member Function Documentation

bool gr_test::check_topology ( int  ninputs,
int  noutputs 
)
inlinevirtual

Confirm that ninputs and noutputs is an acceptable combination.

Parameters
ninputsnumber of input streams connected
noutputsnumber of output streams connected
Returns
true if this is a valid configuration for this block.

This function is called by the runtime system whenever the topology changes. Most classes do not need to override this. This check is in addition to the constraints specified by the input and output gr_io_signatures.

Reimplemented from gr_block.

int gr_test::fixed_rate_ninput_to_noutput ( int  ninput)
inline

Given ninput samples, return number of output samples that will be produced. N.B. this is only defined if fixed_rate returns true. Generally speaking, you don't need to override this.

References gr_block::relative_rate().

int gr_test::fixed_rate_noutput_to_ninput ( int  noutput)
inline

Given noutput samples, return number of input samples required to produce noutput. N.B. this is only defined if fixed_rate returns true.

References gr_block::relative_rate().

void gr_test::forecast ( int  noutput_items,
gr_vector_int &  ninput_items_required 
)
inline

Estimate input requirements given output request.

Parameters
noutput_itemsnumber of output items to produce
ninput_items_requirednumber of input items required on each input stream

Given a request to product noutput_items, estimate the number of data items required on each input stream. The estimate doesn't have to be exact, but should be close.

References gr_block::history(), and gr_block::relative_rate().

int gr_test::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

Parameters
noutput_itemsnumber of output items to write on each output stream
ninput_itemsnumber of input items available on each input stream
input_itemsvector of pointers to the input items, one entry per input stream
output_itemsvector of pointers to the output items, one entry per output stream
Returns
number of items actually written to each output stream, or -1 on EOF. It is OK to return a value less than noutput_items. -1 <= return value <= noutput_items

general_work must call consume or consume_each to indicate how many items were consumed on each input stream.

Reimplemented from gr_block.

void gr_test::set_check_topology ( bool  check_topology)
inline

Force check topology to return true or false.

Parameters
check_topologyvalue to return when check_topology is called (true or false) default check_topology returns true

References gr_block::check_topology().

void gr_test::set_consume_limit ( unsigned int  limit)
inline

Set the consume limit.

Parameters
limitmin or maximum items to consume (depending on consume_type)
void gr_test::set_consume_type ( gr_consume_type_t  cons_type)
inline

Set the consume pattern.

Parameters
cons_typewhich consume pattern to use
void gr_test::set_fixed_rate_public ( bool  fixed_rate)
inline

Set if fixed rate should return true. N.B. This is normally a private method but we make it available here as public.

References gr_block::set_fixed_rate().

void gr_test::set_produce_limit ( unsigned int  limit)
inline

Set the produce limit.

Parameters
limitmin or maximum items to produce (depending on produce_type)
void gr_test::set_produce_type ( gr_produce_type_t  prod_type)
inline

Set the produce pattern.

Parameters
prod_typewhich produce pattern to use

Friends And Related Function Documentation

GR_CORE_API gr_test_sptr gr_make_test ( const std::string &  name,
int  min_inputs,
int  max_inputs,
unsigned int  sizeof_input_item,
int  min_outputs,
int  max_outputs,
unsigned int  sizeof_output_item,
unsigned int  history,
unsigned int  output_multiple,
double  relative_rate,
bool  fixed_rate,
gr_consume_type_t  cons_type,
gr_produce_type_t  prod_type 
)
friend

Member Data Documentation

bool gr_test::d_check_topology
protected
gr_consume_type_t gr_test::d_consume_type
protected
int gr_test::d_max_consume
protected
int gr_test::d_max_produce
protected
int gr_test::d_min_consume
protected
int gr_test::d_min_produce
protected
gr_produce_type_t gr_test::d_produce_type
protected
unsigned int gr_test::d_sizeof_input_item
protected
unsigned int gr_test::d_sizeof_output_item
protected
char gr_test::d_temp
protected

The documentation for this class was generated from the following file: