www.vtiinstruments.com
EX1200-1538: Programming the Instrument
41
//send a software trigger for transferring data to get a snap short of
totalize count
mfunction->Measurement->SendSoftwareTrigger();
fifocount = mfunction->Measurement->FifoCount;
} while (fifocount < 10);
//No. of enabled channels(here it is two. Channel 1 and channel 2)
int no_of_channels_enabled = 2;
/*For each trigger all channels data will be stored. In our case 2
channels is enabled and 10 readings are taken.
So we will get 20 data points in the data array*/
SAFEARRAY *data = NULL;
SAFEARRAY *time = NULL;
SAFEARRAY *time_fraction = NULL;
//Read the measurements
mfunction->Measurement->ReadFifo(0, fifocount, &data, &time,
&time_fraction);
for (long scan = 0; scan<fifocount; scan++)
{
double dSecond, dFraction;
SafeArrayGetElement(time, &scan, (void *)&dSecond);
SafeArrayGetElement(time_fraction, &scan, (void *)&dFraction);
fprintf(stderr, "@Time = %f\n", d dFraction);
for (int channel = 0; channel < no_of_channels_enabled; +)
{
long dataindex = scan * no_of_channels_e channel;
double dData;
SafeArrayGetElement(data, &dataindex, (void *)&dData);
fprintf(stderr, "Channel = %d, Totalize = %f\n", 1,
dData);
//Channel 1 is measuring time interval and channel 2 is measuring
Frequency
}
}
//Abort the measurement.
mfunction->Measurement->Abort();
}
catch (_com_error& e)
{
::MessageBox(NULL, e.Description(), e.ErrorMessage(), MB_ICONERROR);
}
if (mfunction != NULL && mfunction->Initialized)
{
// Close driver
mfunction->Close();
}
}
catch (_com_error& e)
{
::MessageBox(NULL, e.Description(), e.ErrorMessage(), MB_ICONERROR);
}
::CoUninitialize();
printf("\nDone - Press Enter to Exit");
getchar();
return 0;
}