PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
private unsafe void get_overview_buffers (short **overviewbuffers, short overflow, uint triggeredAt, short triggered, short auto_stop,
uint nValues)
{
for (int x = 0; x < nValues; x++)
{
ChannelA.Add((_max_voltage * (double)overviewbuffers[0][x]) / PicoScopeLibrary.Imports.MaxValue);
ChannelB.Add((_max_voltage * (double)overviewbuffers[2][x]) / PicoScopeLibrary.Imports.MaxValue);
}
_num_new_data_points_a = Convert.ToInt32(nValues);
_num_new_data_points_b = Convert.ToInt32(nValues);
}
Code: Select all
private unsafe void get_overview_buffers (short **overviewbuffers, short overflow, uint triggeredAt, short triggered, short auto_stop,
uint nValues)
{
for (int x = 0; x < nValues; x++)
{
var j = overviewbuffers[0][x];
}
}
Code: Select all
private unsafe void get_overview_buffers (short **overviewbuffers, short overflow, uint triggeredAt, short triggered, short auto_stop,
uint nValues)
{
for (int x = 0; x < nValues; x++)
{
//empty
}
}
Code: Select all
short auto_stop = 0;
short result = PicoScopeLibrary.Imports.ps2000_run_streaming_ns(ScopeHandle, 5, PicoScopeLibrary.Imports.ReportedTimeUnits.MicroSeconds,
15000, auto_stop, 1, 15000);
Code: Select all
while (true)
{
unsafe
{
//Grab values from the oscilloscope
PicoScopeLibrary.Imports.ps2000_get_streaming_last_values(ScopeHandle, get_overview_buffers);
}
}
Code: Select all
private unsafe void get_overview_buffers (short **overviewbuffers, short overflow, uint triggeredAt, short triggered, short auto_stop,
uint nValues)
{
StreamWriter k = new StreamWriter("debug.txt", true);
k.WriteLine(nValues.ToString());
k.Close();
for (int x = 0; x < nValues; x++)
{
var j = overviewbuffers[0][x];
}
}
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;
}
I would suggest copying the data for each channel into a larger corresponding array, placing each chunk of data at the next position in the large array as you continue to collect data.Your callback function should do nothing more than copy the data to another buffer
within your application. To maintain the best application performance, the function
should return as quickly as possible without attempting to process or display the data.