Ejemplo n.º 1
0
    void Update()
    {
        if (bufferClient.errorReturned != BufferClient.BUFFER_READ_ERROR && bufferIsConnected)
        {
            SamplesEventsCount count = bufferClient.wait(latestCapturedSample + 1, lastNumberOfEvents + 1, timeout);
            latestNumebrOfEventsInBuffer = count.nEvents;
            latestBufferSample           = count.nSamples;

            while (lastNumberOfEvents < latestNumebrOfEventsInBuffer)
            {
                bufferEvents.Add(bufferClient.getEvents(lastNumberOfEvents, lastNumberOfEvents)[0]);
                lastNumberOfEvents += 1;
                if (bufferEvents.Count > bufferEventsMaxCapacity)
                {
                    bufferEvents.RemoveAt(0);
                }
                OnNewEventsAdded(EventArgs.Empty);                //This notifies anyone who's listening that there had been an extra event added in the buffer
            }

            if (latestBufferSample > latestCapturedSample)
            {
                nSamples             = latestBufferSample - latestCapturedSample;
                data                 = bufferClient.getFloatData(latestCapturedSample, latestBufferSample - 1); //TO DO: The getFloat needs to change according to the buffers type of data
                latestCapturedSample = latestBufferSample;
                OnNewDataCaptured(EventArgs.Empty);                                                             //That notifies anyone who's listening that data have been updated in the buffer
                if (newDataIn)
                {
                    dataPacketsLost += 1;
                }
                else
                {
                    newDataIn = true;
                }
            }
        }
    }