Agilent B1500 VXIplug&play Driver User’s Guide, Edition 3 4-43
Programming Examples for C++ Users
Sampling Measurement
ViInt32 i; /* 57 */
ViChar f_name[] = "C:\\Agilent\\ex\\data8.txt";
ViChar head1[] = "Index, I1 (mA), R1 (ohm), I2 (mA), R2 (ohm), Status";
ViChar msg1[] = "Saving data...";
ViChar msg2[] = "Data save completed.";
ViChar c = ’\n’;
printf(" Index, R1 (ohm), R2 (ohm)\n");
for (i = 0; i < nop; i++){
printf(" %2d, %6.3f, %6.3f \n", index[i], bias/value[2 * i], bias/value[2
* i + 1]);
}
FILE *stream; /* 69 */
if( ( stream = fopen( f_name, "w+" )) == NULL ){
printf( "Data file was not opened\n" );
}
else {
printf( "%s%c", msg1, c );
fprintf( stream, "%s%c", head1, c );
for (i = 0; i < nop; i++){
fprintf(stream,"%2d,%7.3f,%6.3f,%7.3f,%6.3f,%d\n", index[i], value[2 * i] *
1000, bias/value[2 * i], value[2 * i + 1] * 1000, bias/value[2 * i + 1], status[i]);
}
printf( "%s%c", msg2, c );
}
if( fclose( stream ) ){
printf( "Data file was not closed\n" );
}
ret = agb1500_clearSampleSync(vi); /* 87 */
ret = agb1500_setSwitch(vi, agb1500_CH_ALL, 0);
check_err (vi, ret);
}
Line Description
57 to 85 Displays the measurement result data, and saves the measurement results into a CSV file
specified by the f_name variable. The file name is defined in the line 58.
87 Clears the sampling source setting.
88 Disables all ports.
89 Calls the check_err subprogram (shown in Table 4-1) to check if an error status is
returned for the previous line.
90 End of the perform_meas subprogram.