1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| _declspec(dllexport) long Filter_Data_Array(long *NoError,
double Filter_Coef_A[], double Filter_Coef_B[], long Filter_Order,
double Filter_Gain, double Sensor_Data_A[], double Sensor_Data_B[],
long Array_Length, double Output_A[], double Output_B[])
{
double *memory_1,*memory_2;
long i;
int Error=ERR_NONE;
long num_coefs;
if((!(*NoError)) && (Array_Length!=0))
{
// Error = read_filter_coefs(Coeff_File);
// if(Error) {goto End;}
order = Filter_Order;
gain = Filter_Gain;
num_coefs = 3 * ((order + 1)/2);
a_coefs = new double[num_coefs * sizeof(double)];
if (!a_coefs) { return ERR_ALLOC;}
b_coefs = new double[num_coefs * sizeof(double)];
if (!b_coefs) { return ERR_ALLOC;}
for(i=0; i<num_coefs; i++)
{
a_coefs[i] = Filter_Coef_A[i];
b_coefs[i] = Filter_Coef_B[i];
}
ivec_length = Array_Length;
a_value = new float[ivec_length-1];
if(!a_value) {return ERR_ALLOC;}
b_value = new float[ivec_length-1];
if(!b_value) {return ERR_ALLOC;}
for (i=0;i<(ivec_length-1);i++)
{
a_value[i] = (float)Sensor_Data_A[i];
b_value[i] = (float)Sensor_Data_B[i];
}
numb_quads = (order + 1)/2;
a_out = new float[ivec_length-1];
b_out = new float[ivec_length-1];
memory_1 =(double *)calloc(numb_quads,sizeof(double));
memory_2 =(double *)calloc(numb_quads,sizeof(double));
filter_pwv_data(a_value,a_out,memory_1,memory_2);
filter_pwv_data(b_value,b_out,memory_1,memory_2);
free(memory_1);
free(memory_2);
// out_file = fopen((const char*)Output_File,"w");
// if(!out_file)
// {
// Error = ERR_FILE;
// goto End;
// }
//fprintf(out_file,"%.3f %.3f\n",samp_rate_a,samp_rate_b);
//
for(i=0; i<(ivec_length-1); i++)
{
// fprintf(out_file,"%.3f %.3f\n",a_out[i],b_out[i]);
Output_A[i] = a_out[i];
Output_B[i] = b_out[i];
}
// fclose(out_file);
// End:
delete(a_out);
delete(b_out);
delete(a_value);
delete(b_value);
fcloseall();
return Error;
}
else
{
return ERR_BEVORE;
}
}[/quote] |