forecast() function is our way to tell the scheduler about our estimate of input elements that will be needed to create an output element.

For example a decimating filter of order 5 requires 5 inputs to give an output.

Definition of forecast() in gr_block.h is as follows :

virtual void forecast (int noutput_items,

gr_vector_int &ninput_items_required);

The key is argument ninput_items_required which tells number of input items required at each input stream to produce noutput_items number of output items at each output stream

Mostly this quantity can be estimated but there may happen some cases where we cannot estimate this quantity exactly

When the scheduler determines that it is ready to handle noutput_items number of more items on the output streams, it invokes the forecast function to determine whether or not we have enough input items to call general_work()

For example an 10-to-1 decimatorwill requires 10 inputs to produce one output but if only 9 inputs are available it will not call the general_work() if the forecast function is correctly implemented

But the case of of a moving average filter is a bit different. Say we have a moving average filter of length 5, it does not require 5 new inputs to create the single output, it still takes only one input to produce a new output

But our forecast() function would still call for a one to one relation of noutput_items to ninput_items_required

In this case, the fact that we need five most recent inputs would be specified to the GNU Radio via the set_history(5) function call

Its definition is given in gr_block.h as follows :

void set_history (unsigned history) { d_history = history; }

Reference : http://www.dtic.mil/cgi-bin/GetTRDoc?AD=ADA556803

For example a decimating filter of order 5 requires 5 inputs to give an output.

Definition of forecast() in gr_block.h is as follows :

virtual void forecast (int noutput_items,

gr_vector_int &ninput_items_required);

The key is argument ninput_items_required which tells number of input items required at each input stream to produce noutput_items number of output items at each output stream

Mostly this quantity can be estimated but there may happen some cases where we cannot estimate this quantity exactly

When the scheduler determines that it is ready to handle noutput_items number of more items on the output streams, it invokes the forecast function to determine whether or not we have enough input items to call general_work()

For example an 10-to-1 decimatorwill requires 10 inputs to produce one output but if only 9 inputs are available it will not call the general_work() if the forecast function is correctly implemented

But the case of of a moving average filter is a bit different. Say we have a moving average filter of length 5, it does not require 5 new inputs to create the single output, it still takes only one input to produce a new output

But our forecast() function would still call for a one to one relation of noutput_items to ninput_items_required

In this case, the fact that we need five most recent inputs would be specified to the GNU Radio via the set_history(5) function call

Its definition is given in gr_block.h as follows :

void set_history (unsigned history) { d_history = history; }

Reference : http://www.dtic.mil/cgi-bin/GetTRDoc?AD=ADA556803

## No comments:

## Post a Comment