194 SDA-OM-E Rev H
while(1)
{
int i = 0;
printf("Waiting for new data...\n");
// wait an infinite amount of time for data to be available
DWORD waitSuccess = WaitForSingleObject(m_hDataAvailable, INFINITE);
// print the first few bytes of the input waveform
CDescHeader *descHeader = (CDescHeader *) &m_lpMMFile[0];
short *m_lpWaveform = &m_lpMMFile[descHeader->headerSize / sizeof(short)];
for(i = 0; i < 4; ++i)
printf("%f ", (m_lpWaveform[i] * descHeader->verGain) + descHeader->verOffset);
// compute the mean of all data values, while computing the abs value of the waveform in-
place
double sum = 0.0;
for(i = 0; i < descHeader->numSamples; ++i)
{
sum += (m_lpWaveform[i] * descHeader->verGain) + descHeader->verOffset;
m_lpWaveform[i] = abs(m_lpWaveform[i]);
}
sum /= descHeader->numSamples;
// modify the output units, set to Amps
strcpy(descHeader->verUnit, "A");
// print the mean, numer of samples, trigger time in seconds, and the segment index
printf(" (%f) %d %d %d\n", sum, descHeader->numSamples, (int) (descHeader-
>trigTime / lecTimeStampOneSecond), descHeader->segmentIndex);
// use to flag that the output is not valid, increasing performance when
// it is not necessary to read data back into the DSO
//descHeader->flags &= ~FLAGS_OUTPUT_VALID;
// flag that processing is complete
SetEvent(m_hProcessingComplete);
}
return 0;
}
Header Description
int descVersion; // header version number
int flags; // misc. flags indicating the status of input, and how to treat the output
int headerSize; // size of the header, data starts immediately after the hdr.
int windowSize; // total size of the window (header + data)
int numSamples; // total number of samples in the input waveform
int segmentIndex; // index of this segment, usually zero when input waveform is not a sequence
int numSweeps;
int _dummy1; // not used
double verGain; // scale factor that relates integer sample data values to the vertical units of the
waveform.
double verOffset; // vertical offset (in vertical units, e.g. Volts) of the waveform