if(ACDC_Ready_flag == 2) { ACDC_Ready_flag = 1; SPO2_range=ACDC_count; for(count = 0;countACDC_red[count+1]) { RED1[count7]=2000ACDC_red[count]*1000/ACDC_red[count+1]; g1=RED1[count7]; if(g1>0&&g1<=1000) { red_flag=1; } } else { RED1[count7]=2000ACDC_red[count+1]*1000/ACDC_red[count]; g1=RED1[count7]; if(g1>0&&g1<=1000) { red_flag=1; } } if(ACDC_ired[count]>ACDC_ired[count+1]) { IRED1[count7]=(double)(2000ACDC_ired[count]*1000/ACDC_ired[count+1]); g3=IRED1[count7]; if(g3>0&&g3<=1000) { ired_flag=1; } } else { IRED1[count7]=(double)(2000ACDC_ired[count+1]*1000/ACDC_ired[count]); g3=IRED1[count7]; if(g3>0&&g3<=1000) { ired_flag=1; } } if(red_flag==1&&ired_flag==1) { red_flag=0; ired_flag=0; RED_ADD=g1*g1; IRED_ADD=g3*g3; g2=g2+RED_ADD; g4=g4+IRED_ADD; } count7++; } RED_Q = (double)(count7*1000000-g2); IRED_Q = (double)(count7*1000000-g4); g2=0; g4=0; count7=0; /*计算Q值*/ if(Q_count<15) { Q_Value[Q_count] = (double)((IRED_Q)/(RED_Q)); PulseRate[Q_count] = (double)(15000/(ACDC_count)); Q_add = Q_add + Q_Value[Q_count];//Çó15¸öQÖµµÄºÍ Q_count++; } if(Q_count == 15) { PulseRate[0] = PulseRate[1]; PulseRate[1] = PulseRate[2]; PulseRate[2] = PulseRate[3]; PulseRate[3] = PulseRate[4]; PulseRate[4] = PulseRate[5]; PulseRate[5] = PulseRate[6]; PulseRate[6] = PulseRate[7]; PulseRate[7] = PulseRate[8]; PulseRate[8] = PulseRate[9]; PulseRate[9] = PulseRate[10]; PulseRate[10] = PulseRate[11]; PulseRate[11] = PulseRate[12]; PulseRate[12] = PulseRate[13]; PulseRate[13] = PulseRate[14]; PulseRate[14] = (double)(15000/(ACDC_count)); averagePulseRate=(uint8_t)((PulseRate[0]+PulseRate[1]+PulseRate[2]+PulseRate[3]+PulseRate[4]+PulseRate[5]+PulseRate[6]+PulseRate[7]+PulseRate[8]+PulseRate[9]+PulseRate[10]+PulseRate[11]+PulseRate[12]+PulseRate[13]+PulseRate[14])/15); value_count=15; Q_Value[0]=Q_Value[1]; Q_Value[1]=Q_Value[2]; Q_Value[2]=Q_Value[3]; Q_Value[3]=Q_Value[4]; Q_Value[4 =Q_Value[5]; Q_Value[5]=Q_Value[6]; Q_Value[6]=Q_Value[7]; Q_Value[7]=Q_Value[8]; Q_Value[8]=Q_Value[9]; Q_Value[9]=Q_Value[10]; Q_Value[10]=Q_Value[11]; Q_Value[11]=Q_Value[12]; Q_Value[12]=Q_Value[13]; Q_Value[13]=Q_Value[14]; Q_Value[14]=(double)((IRED_Q)/(RED_Q)); for(sort_count=0;sort_count<14;sort_count++) { if(Q_Value[sort_count]W_sigma) { value_count = value_count-1; sum_add = sum_add-W_Value1[max_site]; Q_average = sum_add/value_count-2; sum_square = sum_add*sum_add; square_sum = square_sum-Q_Value2[max_site]; Q_sigma = (double)sqrt((square_sum-sum_square_average)/value_count); W_sigma = 2.7* Q_sigma; max_site = max_site+1; max_test = Q_Value[max_site]- Q_average; max_flag=0; goto found; } else { max_flag=1; } if(min_test>W_sigma) { value_count = value_count-1; sum_add = sum_add-W_Value1[min_site]; Q_average = sum_add/value_count-2; sum_square=sum_add*sum_add; square_sum=square_sum-Q_Value2[min_site]; Q_sigma=(double)sqrt((square_sum-sum_square_average)/value_count); W_sigma=2.7* Q_sigma; min_site=min_site-1; min_test=Q_Value[min_site]- Q_average; min_flag=0; goto found; } else { min_flag=1; } if(max_flag==1&&min_flag==1) { Q_add=sum_add-value_count*2; Q=Q_add/value_count; max_flag=0; min_flag=0; sum_add=0; square_sum=0; } } /*血氧饱和度的计算*/ SPO2 = (uint8_t)((18.52)*Q+89.888); /*对血氧饱和度粗大误差的剔除*/ if(SPO2_flag==2) { if(89