public void waveformAiCtrl_DataReady(object sender, BfdAiEventArgs e) { Console.WriteLine(" Streaming AI data ready:count = {0},offset = {1} ", e.Count, e.Offset); Int32 returnedCount = 0; WaveformAiCtrl waveformAiCtrl = (WaveformAiCtrl)sender; Conversion conversion = waveformAiCtrl.Conversion; Record record = waveformAiCtrl.Record; int channelCountMax = waveformAiCtrl.Features.ChannelCountMax; int startChan = conversion.ChannelStart; int channelCount = conversion.ChannelCount; int sectionLengt = record.SectionLength; int getDataCount = sectionLengt * channelCount; // buffer section length, when 'DataReady' event been signaled, driver renew data count is e.count. if (e.Count > channelCount) { double[] sectionBuffers = new double[getDataCount]; getDataCount = Math.Min(getDataCount, e.Count); waveformAiCtrl.GetData(getDataCount, sectionBuffers, 0, out returnedCount); Console.Write("Streaming AI get data count is {0}", returnedCount); Console.WriteLine(" The first sample for each channel are:"); DoChart1update(sectionBuffers); DoChart2update(sectionBuffers); DoChart3update(sectionBuffers); // for (int j = 0; j < channelCount; ++j) //{ // Console.WriteLine(" channel {0}: {1}", (j % channelCount + startChan) % channelCountMax, sectionBuffer[j]); //} //Console.WriteLine(); //foreach (var sectionBuffer in sectionBuffers) //{ // Console.WriteLine(" channel {0}: {1}", (0 % channelCount + startChan) % channelCountMax, sectionBuffer); //} } }
public void waveformAiCtrl_DataReady(object sender, BfdAiEventArgs e) { try { Int32 returnedCount = 0; WaveformAiCtrl waveformAiCtrl = (WaveformAiCtrl)sender; Conversion conversion = waveformAiCtrl.Conversion; Record record = waveformAiCtrl.Record; int channelCountMax = waveformAiCtrl.Features.ChannelCountMax; int startChan = conversion.ChannelStart; int channelCount = conversion.ChannelCount; int sectionLengt = record.SectionLength; int getDataCount = sectionLengt * channelCount; // buffer section length, when 'DataReady' event been signaled, driver renew data count is e.count. if (e.Count > channelCount) { double[] sectionBuffers = new double[getDataCount]; getDataCount = Math.Min(getDataCount, e.Count); waveformAiCtrl.GetData(getDataCount, sectionBuffers, 0, out returnedCount); /* Filter * //sectionBuffers = SF.Bandpassfilter(sectionBuffers, convertClkRate, lowcutoff, highcutoff); * //sectionBuffers = SF.Butterworth(sectionBuffers, convertClkRate, 100); */ DoTimeChartupdate(sectionBuffers); DoFFTChartupdate(sectionBuffers); DoMaxChartupdate(sectionBuffers); } } catch (Exception err) { _log.Error("Failed to Data Collection---" + err.Message); MessageBox.Show(err.Message);; } }