Agilent Technologies 86100-90086 Sprinkler User Manual


 
2-22
Sample Programs
Listings of the Sample Programs
* Parameters: none
* Return value: none
* Description: This routine converts the waveform data to time/voltage
* information using the values that describe the waveform. These values are
* stored in global arrays for use by other routines.
*/
void convert_data ( )
{
int i;
for (i = 0; i < Acquired_length; i++)
{
time_value[i] = ((i - xref) * xinc) + xorg; /* calculate time info */
volts[i] = ((data[i] - yref) * yinc) + yorg; /* calculate volt info */
}
} /* end convert_data ( ) */
/*
* Function name: store_csv
* Parameters: none
* Return value: none
* Description: This routine stores the time and voltage information about
* the waveform as time/voltage pairs in a comma-separated variable file
* format.
*/
void store_csv ( )
{
FILE *fp;
int i;
fp = fopen ("pairs.csv","wb"); /* open file in binary mode - clear file if already exists */
if (fp != NULL)
{
for (i = 0; i < Acquired_length; i++)
{
/* write time,volt pairs to file */
fprintf ( fp,"%e,%lf\n",time_value[i],volts[i]);
}
fclose ( fp ); /* close file */
}
else
printf ("Unable to open file 'pairs.csv'\n");
} /* end store_csv ( ) */