void ReadFromCircularBuffer(TVec Buffer, TVec Dst, ref TCircularBufferState State, Int32 ForwardStep)
Copy data from circular buffer.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Buffer | TVec | source TVec |
| 2 | Dst | TVec | source TVec |
| 3 | State | TCircularBufferState (ref) | |
| 4 | ForwardStep | Int32 |
Result: stored in self (calling object)
Remarks:
Copies Dst.Length samples from Buffer to Dst. If there is not Dst.Length samples available, the BufferUnderflow flag will be set in the State variable. The routine advances ReadPosition of the buffer to the position where the next data is to be read from. ForwardStep defines the number of samples to advance the read cursor. If the ForwardStep is -1, the read cursor is advanced Dst.Length samples.
Examples
using Dew.Math;
using Dew.Math.Editors;
using Dew.Math.Units;
using Dew.Signal;
using Dew.Signal.Units;
using Dew.Math.Tee;
using Dew.Signal.Tee;
private void button1_Click(object sender, EventArgs e)
{
Vector b = new Vector(0);
Vector c = new Vector(0);
Vector h = new Vector(0);
int n = 6;
int i;
TCircularBufferState State = new TCircularBufferState();
Vector h1 = MtxExpr.Ramp(30, TMtxFloatPrecision.mvDouble, 0,1);
c.Size(h1);
c.SetZero();
h.Size(h1);
h.SetZero();
SignalUtils.InitCircularBuffer(11,2,ref State);
int h1Length = h1.Length/n;
for (i = 0; i < h1Length; i++)
{
h1.SetSubRange(i * n, n);
h.SetSubRange(i * n, n);
c.SetSubRange(i * n, n);
SignalUtils.WriteToCircularBuffer(b, h1, ref State,false);
n = SignalUtils.PeekCircularBuffer(State);
SignalUtils.MonitorCircularBuffer(b, h, ref State);
SignalUtils.ReadFromCircularBuffer(b, c, ref State, -1);
}
h1.SetFullRange();
h.SetFullRange();
c.SetFullRange();
MtxVecTee.DrawIt(new TVec[3] {h1,h,c}, new string[3] {"Original","Monitored","Read"},"Circular buffering",false);
}