User manual

Programmer’s Guide Page 46 of 64
bool finished = false;
while(!finished)
{
memoryBank = (memoryBank + 1)&0x1;// switch to other bank
AcqrsD1_configMode(instrID, 3, 0, memoryBank);
AcqrsD1_acquire(instrID); // start new acquisition
AcqrsD1_processData(instrID, 0, 0);// start processing
AcqrsD1_waitForEndOfProcessing(instrID, timeout);
// At this point, you should check the return value!
readParams.dataType = ReadReal64;
readParams.readMode = ReadModePeak;
readParams.nbrSegments = 1;
readParams.firstSampleInSeg = 0;
readParams.segmentOffset = 0;
readParams.firstSegment = 0; // Read first segment
readParams.nbrSamplesInSeg = 2* nbrPeaks; // pos and neg peak
readParams.dataArraySize = 2 * sizeof(double) * nbrPeaks;
readParams.segDescArraySize = 0;
readParams.flags = 0;
readParams.reserved = 0;
readParams.reserved2 = 0.0;
readParams.reserved3 = 0.0;
AcqrsD1_readData(instrID, channel, &readParams, waveformArray,
&dataDesc, NULL);
//... analyze and store data
AcqrsD1_waitForEndOfAcquisition(instrID, timeout);
//...read original data if desired
//...check on loop termination conditions and set ‘finished’
}
The returned waveformArray contains exactly 2*nbrGates peaks, each of which is described by 2 double precision
floating-point values. The first pair of doubles contains the positive peak position, within the gate (in units of
samples), and the amplitude (in codes). The second pair of doubles contains the negative peak position and its
amplitude. The peak amplitude is a signed number in the range
[–128.0, +127.0] with the two extreme values indicating underflow/overflow conditions. The peak position is
normally positive. Negative values are used for warnings. In particular, the value DBL_MAX indicates that no peak
was found. The #define of DBL_MAX can be found in the float.h include file. Each peak contains the following two
words:
0 63
Peak Position (in samples from start of gate)
0 63
Peak Amplitude (in ADC units)
Use the following code to obtain the peak positions for the i'th gate:
double *positivePeakPos = &waveformArray[0+8*i];
double *negativePeakPos = &waveformArray[4+8*i];