1

What is the recommended method(s) for accessing data from a previous or upcoming block of data from a bulkio input stream? Edit: I am using c++.

For example, if I wanted to perform convolution on a stream of incoming data where each calculation is dependent on some number of values forward/backward in the stream how would I reach into the "next" block of data or "previous" block of data to perform the convolution calculations at the block boundaries? Or temporarily store this information somewhere within the component so it can be used from one block to the next?

Or a simpler example, if I send a repeating vector of 8 octet values into my component, I want the component to simply flip from 0 to 1 or vice versa whenever a 1 is received (dependent on last index of the previous block of data to calculate the first index of the next block of data).

Desired:


in: [0,0,0,1,0,0,0] [0,0,0,1,0,0,0] [0,0,0,1,0,0,0] ->

out: [1,1,1,0,0,0,0] [0,0,0,1,1,1,1] [1,1,1,0,0,0,0]

What I have been able to achieve:


in: [0,0,0,1,0,0,0] [0,0,0,1,0,0,0] [0,0,0,1,0,0,0] ->

out: [1,1,1,0,0,0,0] [1,1,1,0,0,0,0] [1,1,1,0,0,0,0]

I've thought to store the relevant information from the previously processed block in a variable somewhere inside the component code serviceFunction() although I haven't found a way to do this without the value being reinitialized (is each block of data a new call to serviceFunction()?).

Alternatively, I thought to make a read-only property to hold the values I care about but I suspect there may be a better approach I am unaware of.

Thanks,
-Mark

Mark
  • 11
  • 2
  • So, I was able to achieve the "desired" output stream from my question above via a read-only property on the component then manipulate as-needed in the serviceFunction(). For the more complicated convolution case, I imagine this could be done with a read-only sequence in a similar way. I suppose my only remaining question then, is whether this approach is recommended or might there be a better method? – Mark Oct 31 '17 at 21:45

1 Answers1

0

If you need to retain some number of samples between reads, BulkIO input streams support data overlapping. You provide both a number of samples to read, and a number of samples to consume (which is necessarily less than or equal to the read size), and the next read will start at the first sample that was not consumed. Refer to the REDHAWK manual section on the BulkIO Stream API (5.7.3 in the 2.0.8 manual) for further details. You can also maintain history by simply keeping the last data block read as a member variable of your component class.

Your simple example suggests a state machine rather than the contents of the last read. In general, if there is information you want to store between iterations of your serviceFunction(), you are free to add your own member variables to your component class (e.g., "MyComponent_i"). It is not necessary to declare a property to add members. Only the base class (e.g., "MyComponent_base") is intended to be regenerated as you modify the properties or ports of the component, so any changes you make to the component class are preserved.

Justin Irwin
  • 161
  • 4