You are here: Symbol Reference > Dew Namespace > Dew.Signal Namespace > Dew.Signal.Units Namespace > Classes > SignalUtils Class > SignalUtils Methods > SignalUtils.ReadFromCircularBuffer Method
Dew Signal for .NET
ContentsIndexHome
PreviousUpNext
SignalUtils.ReadFromCircularBuffer Method

Copy data from circular buffer.

Syntax
C#
Visual Basic
public static void ReadFromCircularBuffer(TVec Buffer, TVec Dst, ref TCircularBufferState State, int ForwardStep);

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.

Circular buffer test.

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); }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!