Hi all:

I want to know something about the forecast().

I have already known that forcast() can tell scheduler how

many input items are required for each output item.

1.But now i have read two example:

The first one:

void your_block::forecast(int

noutput_items,gr_vector_int &ninput_items_required){

ninput_items_required[0]=100 *

noutput_items;

```
ninput_items_required[1]=100 *
```

noutput_items; }

I have already understand it.

But the second one:

void forecast (int noutput_items,

gr_vector_int &ninput_items_required)

{

unsigned ninputs =

ninput_items_required.size ();

for (unsigned i = 0; i < ninputs; i++)

ninput_items_required[i] = 1;}

I can’t understand since we can’t know how many

input items we required,why use ninput_items_required.size ().Can

someone help me?

2.I want to know if we use the general_work().Is it means

that we must use the forcast()?Thanks.

Best regards

Hi Xianda,

Easiest answer first:

- You need to write a forecast if, and only if, you’re using

general_work. I generally try to avoid doing that.

Then:

1.

ninput_items_required is, as you can see in the function signature, a

reference to a vector.

The size of the vector is the number of input ports.

Compare to

http://gnuradio.org/doc/doxygen/classgr_1_1block.html#a5bc118d94944d2ff71e378f807fb8d28

Greetings,

Marcus

On Wed, Jun 4, 2014 at 2:22 PM, xianda [email protected] wrote:

```
ninput_items_required[1]=100 *
```

noutput_items; }

In your first example above, you have exactly two input ports.

That’s why you need to specify “ninput_items_required[0]” and

“ninput_items_required[1]”, there are in total 2 ports.

In fact in this example the value of “ninput_items_required.size()” is

2.

In alternative, you could also replace above two lines with:

```
for (unsigned i=0; i < 2; i++)
ninput_items_required[i] = 100 * noutput_items;
```

Or, to be more generic, you could also use this:

for (unsigned i=0; i < ninput_items_required.size(); i++)

ninput_items_required[i] = 100 * noutput_items;

```
2.I want to know if we use the general_work().Is it means that we
```

must use the forcast()?Thanks.

Best regards

If you use “general” block, you need to specify “forecast()”.

“General” block has “general_work()” function but not “general()”

function.

If you use sync block, decim, interpolation block etc, you have “work()”

but not “general_work()”, and you don’t need to write “forecast()”.

This is very straight-forward.

Hi Xianda,

the io_signature specifies a minimum and a maximum number of inputs, so

this might be 1,2 or 3.

Greetings,

Marcus