PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
unsafe void StreamingCallback(short **overviewBuffers, short overFlow, uint triggeredAt, short triggered, short auto_stop, uint nValues)
{
autostop = auto_stop != 0;
if ((nValues > 0) && (sample_count < buffer.Length))
{
int max = (int)nValues + sample_count;
if (max > buffer.Length)
max = buffer.Length;
for (int i = sample_count; i < max; i++)
buffer[i] = overviewBuffers[0][i - sample_count];
sample_count = max;
}
}
unsafe public bool StreamBuffer(uint num_samples, out double[] output_buffer, uint sample_interval_us)
{
output_buffer = null;
if (Imports.ps2000_run_streaming_ns(handle, sample_interval_us, Imports.ReportedTimeUnits.MicroSeconds, num_samples, 1, 1, num_samples) == 0)
return false;
autostop = false;
buffer = new short[num_samples];
sample_count = 0;
while (!autostop && (sample_count < num_samples))
{
Imports.ps2000_get_streaming_last_values(handle, StreamingCallback);
}
Imports.Stop(handle);
double multiplier = inputRanges[(int)range] * (1 / (double)Imports.MaxValue);
output_buffer = new double[num_samples];
for (int i = 0; i < num_samples; i++)
output_buffer[i] = (double)buffer[i] * multiplier;
return true;
}
Code: Select all
/****************************************************************************
* StreamingCallback
* used by data streaming collection calls, on receipt of data.
* used to set global flags etc checked by user routines
****************************************************************************/
unsafe void StreamingCallback(short** overviewBuffers,
short overFlow,
uint triggeredAt,
short triggered,
short auto_stop,
uint nValues)
{
// used for streaming
_autoStop = auto_stop != 0;
// flags to show if & where a trigger has occurred
_trig = triggered;
_trigAt = triggeredAt;
_nValues = nValues;
if (nValues > 0 && !_appBufferFull)
{
try
{
for (int i = (int)_totalSampleCount; i < nValues + _totalSampleCount; i++)
{
for (int channel = 0; channel < _channelCount; channel++)
{
if (Convert.ToBoolean(_channelSettings[channel].enabled))
{
_appBuffer[channel][i] = overviewBuffers[channel * 2][i - _totalSampleCount]; //Only copying max data from buffers
}
}
}
}
catch (Exception) // If trying to place data
{
_appBufferFull = true;
Console.WriteLine("Appbuffer full collection cancelled");
}
}
_totalSampleCount += nValues;
}