Hi Igor, thanks for following up!
So, I gave your description a bit of thought; I'd like to point you at the fact that it's not guaranteed that a block of items handed to a general_work-call ends with a "0", so don't forget to keep your count if your last input item is a 1! For me, this boils down to a state machine, which transitions states for every input item between the three possible states "IN ZERO PERIOD", "COUNTING ONES" and "EMITTING THE COUNT, BECAUSE THIS IS THE FIRST 0 AFTER 1s". Regarding your forecast() implementation: it's totally OK to "underestimate" the number of samples you need to produce a given number of output samples (in your case, that is noutput_items * 2, because even a single 1 needs to be followed by a 0). If you can't produce any output with what GNU Radio offered you, that's OK – you'll be called again if there's new input. Best regards, Marcus On 28.01.2017 22:02, Igor Volodin wrote: > Hi Marcus, > > Thanks for reply. > I have rechecked offical documentation about forecast() method, and > found that you were right. All i think about forecast() behaviour was > my miscomprehension. > > I just want count a number of consecutive samples that have a value of > "1". > If my block will get on input the following sequence [0, 1, 1, 1, 0], > it should send to output a value 3. > If on input will be [1, 1, 0, 1, 0, 0] output should present 2 integer > values: "2" and "1" > > > > Best regards, > Igor > > _______________________________________________ > Discuss-gnuradio mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio _______________________________________________ Discuss-gnuradio mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
