ГОСТ Р ИСО/МЭК10373-7— 2011
float pi;/* pi=3.14.... */
/* Array for time and sense сой voltage vd V
float vtime(MAX
_
SAMPLES]; Г time array V
float vd[MAX
_
SAMPLESJ; Г Array for different coil voltage */
Read CSV File Function
/...
/***
/...
/***
/...
/***
/...
Description: ” 4
This function reads the table of time and sense coil ••V
voltage from а Рве in CSV Format — /
**•/
Input: filename •*V
**•/
Return: Number of samples (sample Count) •*V
0 if an error occurred **•/
/...
/...
/...
/...
/...
/***
/...
......
Displays Statistics: •••/
•••/
Filename. SampleCounl. Sample rate. Max/Min Voltage•••/
int readcsv(char’ fname)
{
float a.b;
float max
_
vd,min
_
vd:
int i;
FILE ‘sample
_
file:
Open File ..................................... .
...........
••**/
if (!strchr(fname. 7)) strcat(fname. ”.csv”):
if ((sample
_
file = fopen(fname. V )) == NULL)
{
prin»f(*Cannot open input file %s.\n"tfname):
return 0;
}
r .......................................................................................
r
Read CSV FileV
.....................
.
..............
.
.....
.
..............,
max
_
vd=-1e-9F,
min
_
vd=-max
_
vd;
i=0;
while (!feof(sample
_
file))
{
if(i>=MAX
_
SAf.1PLES)
{
printf("Waming: File truncated !!!\n"):
printffTo much samples in file %s\b\n".fname);
break;
}
fscanf(sample
_
file.*%f.%fin*. &a. &b);
vtime(i) = a;
vd[i] = b;
if (vd[i]>max
_
vd) max
_
vd=vd[i];
if (vd[i]<min
_
vd) min
_
vd=vdfi];
i++;
}
fclose(sampfe
_
file);
/*’**.......... Displays Statistics •*«••*•••*••••••*•••••••/
printf(’,\л*•••••**•******..........
...........
.....................,***,\n");
printf(’ViStatistics: \л*);
printff Filename : %s\n".fname);
21