⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.~cp

📁 数据采集
💻 ~CP
📖 第 1 页 / 共 5 页
字号:
          if(which_tm==1) tmp=data_j1(offset-i+ab_cnt)-data_j1(offset-i);
          else            tmp=data_j2(offset-i+ab_cnt)-data_j2(offset-i);
        }else tmp= ( data_j1(offset-i+ab_cnt)-data_j1(offset-i) +
                     data_j2(offset-i+ab_cnt)-data_j2(offset-i) )/2 ;

        if(ab_cnt>KK_XX && data_jz(which_tm,offset-i)>ref &&
               tmp>high_bt &&  i-ab_cnt>zhou_jv ){
          ret_offset=offset-i+ab_cnt;
          found_flag=true;
          break;
        }
        ab_cnt=0;
      }
    }
    if(found_flag==true)*dx=ab_cnt;
    else{ *dx=0;}
    return ret_offset;
  }


  else if(bd.hq_mode==HQ_NEWCPZ){
    long i,ret_offset=offset,ab_cnt=0;
    bool found_flag=false;
    int tmp;

    for(i=0;i<dlt;i++){
      int which_j=get_which_j_up(which_tm_newcpz);
      if(get_kk(which_j,offset-i)>0) {ab_cnt++;}
      else{
        tmp=get_high_bt(which_j,offset-i+ab_cnt,offset-i);

        /*
        if(ab_cnt>0){
          if(which_tm_newcpz==3){
            char msg[100];
            sprintf(msg,"tm:%d high_bt:%d  ab_cnt:%d",which_tm_newcpz,tmp,ab_cnt);
            err(msg);
          }
        } */

        if(ab_cnt>KK_XX && data_jz(which_tm_newcpz,offset-i)>ref &&
               tmp>high_bt &&  i-ab_cnt>zhou_jv ){
          ret_offset=offset-i+ab_cnt;
          found_flag=true;
          break;
        }
        ab_cnt=0;
      }
    }
    if(found_flag==true) *dx=ab_cnt;
    else{ *dx=0;err(" find_up_qin: not found ");}
    return ret_offset;
  }


  else{
    long i,ret_offset=offset,line_count=0;
    int found_flag=FALSE;

    for(i=0;i<dlt;i++){
      if(get_rr(offset-i)) {line_count++;}
      else{
        if(line_count>RR_XX && data_jz(which_tm,offset-i)>ref){
          if( (float)(data_jz(which_tm,offset-i)-zero)/(float)(data_jz(which_tm,offset-i+line_count)-zero)<kk ){
            ret_offset=offset-i+line_count;
            found_flag=TRUE;
            break;
          }
        }
        line_count=0;
      }
    }
    if(found_flag==TRUE)*dx=line_count;
    else *dx=0;
    return ret_offset;
  }

  }catch(...){err("find_up_qin");}
  return offset;
}

long __fastcall find_up_hou(long offset,long dlt,float kk,long ref,int *dx)
{
  if(bd.hq_mode==HQ_STMBDG || bd.hq_mode==HQ_BDG|| bd.hq_mode==HQ_CPZ||bd.hq_mode==HQ_BDG3){
    long i,ret_offset=offset,ab_cnt=0,below_zero_cnt=0;
    int found_flag=FALSE;
    int tmp;

    for(i=0;(below_zero_cnt<80)&&(i<dlt);){ // !! below_zero_cnt<80,如果回零则退出,不影响其他车
      if(don_susp==TRUE) break; // Esc
      if(offset+i<offset_buf-10){ // 后架可能要等数据
        if(get_kk(which_tm,offset+i)>0) {ab_cnt++;}
        else{
          if(bd.hq_mode==HQ_BDG) tmp=data_j1(offset+i)-data_j1(offset+i-ab_cnt);
          else if(bd.hq_mode==HQ_STMBDG||bd.hq_mode==HQ_BDG3){
            if(which_tm==1) tmp=data_j1(offset+i)-data_j1(offset+i-ab_cnt);
            else            tmp=data_j2(offset+i)-data_j2(offset+i-ab_cnt);
          }else tmp= ( data_j1(offset+i)-data_j1(offset+i-ab_cnt) +
                       data_j2(offset+i)-data_j2(offset+i-ab_cnt) )/2 ;

          if(ab_cnt>KK_XX && data_jz(which_tm,offset+i)>ref && tmp>high_bt){
            ret_offset=offset+i;
            found_flag=TRUE;
            break;
          }
          ab_cnt=0;
        }
        if(data_jz(which_tm,offset+i)<zero+500) below_zero_cnt++; //如果回零,返回
        else below_zero_cnt=0;
        i++;
      }else WaitForSingleObject(g_hEvent,10);
    }
    if(found_flag==TRUE) *dx=ab_cnt;
    else *dx=0;
    return ret_offset;
  }

  ////////////////// NEWCPZ
  else if(bd.hq_mode==HQ_NEWCPZ){
    long i,ret_offset=offset,ab_cnt=0,below_zero_cnt=0;
    int found_flag=FALSE;
    int tmp;

    for(i=0;(below_zero_cnt<5000)&&(i<dlt);){ // !! below_zero_cnt<80,如果回零则退出,不影响其他车
      if(don_susp==TRUE) break; // Esc
      if(offset+i<offset_buf-10){ // 后架可能要等数据

        int which_j=get_which_j_up(which_tm_newcpz);
        if(get_kk(which_j,offset+i)>0) {ab_cnt++;}
        else{
          tmp=get_high_bt(which_j,offset+i,offset+i-ab_cnt);
          if(ab_cnt>KK_XX && tmp>high_bt){//data_jz(which_tm_newcpz,offset+i)>ref &&
            ret_offset=offset+i;
            found_flag=TRUE;
            break;
          }
          ab_cnt=0;
        }
        if(data_jz(which_tm,offset+i)<zero+500) below_zero_cnt++; //如果回零,返回
        else below_zero_cnt=0;
        i++;
      }else WaitForSingleObject(g_hEvent,10);
    }
    if(found_flag==TRUE) *dx=ab_cnt;
    else{ *dx=0; err("find_up_hou:not found");}
    return ret_offset;
  }

  else{
    long i,ret_offset=offset,line_count=0,below_zero_cnt=0;
    int found_flag=FALSE;

    for(i=0;(below_zero_cnt<80)&&(i<dlt);){// !! below_zero_cnt<80,如果回零则退出,不影响其他车
      if(don_susp==TRUE) break; // Esc
      if(offset+i<offset_buf-10){ // 后架可能要等数据
        if(get_rr(offset+i)) {line_count++;}
        else{
          if(line_count>RR_XX && data_jz(which_tm,offset+i)>ref){
            if( (float)(data_jz(which_tm,offset+i-line_count)-zero)/(float)(data_jz(which_tm,offset+i)-zero)<kk ){
              ret_offset=offset+i;
              found_flag=TRUE;
              break;
            }
          }
          line_count=0;
        }
        if(data_jz(which_tm,offset+i)<zero+500) below_zero_cnt++; //如果回零,返回
        else below_zero_cnt=0;
        i++;
      }else WaitForSingleObject(g_hEvent,10);
    }
    if(found_flag==TRUE)*dx=line_count;
    else *dx=0;
    return ret_offset;
  }
}

long __fastcall find_down_hou(long offset,long dlt,float kk,long ref,int *dx)
{
  if(bd.hq_mode==HQ_STMBDG || bd.hq_mode==HQ_BDG|| bd.hq_mode==HQ_CPZ||bd.hq_mode==HQ_BDG3){
    long i,ret_offset=offset,bl_cnt=0,below_zero_cnt=0;
    int found_flag=FALSE;
    int tmp;

    for(i=0;(below_zero_cnt<5000)&&(i<dlt);){// !! below_zero_cnt<80,如果回零则退出,不影响其他车
      if(don_susp==TRUE) break;   // Esc
      if(offset+i<offset_buf-10){ /*后架可能要等数据*/
        if(get_kk(which_tm,offset+i)<0) {bl_cnt++;}
        else{
          if(bd.hq_mode==HQ_BDG) tmp=data_j1(offset+i-bl_cnt)-data_j1(offset+i);
          else if(bd.hq_mode==HQ_STMBDG||bd.hq_mode==HQ_BDG3){
            if(which_tm==1) tmp=data_j1(offset+i-bl_cnt)-data_j1(offset+i);
            else            tmp=data_j2(offset+i-bl_cnt)-data_j2(offset+i);
          }else tmp= ( data_j1(offset+i-bl_cnt)-data_j1(offset+i) +
                       data_j2(offset+i-bl_cnt)-data_j2(offset+i) )/2 ;

          if(bl_cnt>KK_XX && data_jz(which_tm,offset+i)>ref &&
                tmp>high_bt && i-bl_cnt>zhou_jv){
            ret_offset=offset+i-bl_cnt;
            found_flag=TRUE;
            break;
          }
          bl_cnt=0;
        }
        if(data_jz(which_tm,offset+i)<zero+500) below_zero_cnt++;  //如果回零,返回
        else below_zero_cnt=0;
        i++;
      }else WaitForSingleObject(g_hEvent,10);
    }
    if(found_flag==TRUE)*dx=bl_cnt;
    else *dx=0;
    return ret_offset;
  }

  ///////////////////NEWCPZ
  if(bd.hq_mode==HQ_NEWCPZ){
    long i,ret_offset=offset,bl_cnt=0,below_zero_cnt=0;
    int found_flag=FALSE;
    int tmp;

    for(i=0;(below_zero_cnt<80)&&(i<dlt);){// !! below_zero_cnt<80,如果回零则退出,不影响其他车
      if(don_susp==TRUE) break;   // Esc
      if(offset+i<offset_buf-10){ /*后架可能要等数据*/
        int which_j=get_which_j_down(which_tm_newcpz);
        if(get_kk(which_j,offset+i)<0) {bl_cnt++;}
        else{
          tmp=get_high_bt(which_j,offset+i-bl_cnt,offset+i);
          if(bl_cnt>KK_XX && data_jz(which_tm,offset+i)>ref &&
                tmp>high_bt && i-bl_cnt>zhou_jv){
            ret_offset=offset+i-bl_cnt;
            found_flag=TRUE;
            break;
          }
          bl_cnt=0;
        }
        if(data_jz(which_tm,offset+i)<zero+500) below_zero_cnt++;  //如果回零,返回
        else below_zero_cnt=0;
        i++;
      }else WaitForSingleObject(g_hEvent,10);
    }
    if(found_flag==TRUE)*dx=bl_cnt;
    else *dx=0;
    return ret_offset;
  }


  else{
    long i,ret_offset=offset,line_count=0,below_zero_cnt=0;
    int found_flag=FALSE;

    for(i=0;(below_zero_cnt<80)&&(i<dlt);){// !! below_zero_cnt<80,如果回零则退出,不影响其他车
      if(don_susp==TRUE) break;   // Esc
      if(offset+i<offset_buf-10){ /*后架可能要等数据*/
        if(get_rr(offset+i)) {line_count++;}
        else{
          if(line_count>RR_XX && data_jz(which_tm,offset+i)>ref){
            if( (float)(data_jz(which_tm,offset+i)-zero)/(float)(data_jz(which_tm,offset+i-line_count)-zero)<kk  ){
              ret_offset=offset+i-line_count;
              found_flag=TRUE;
              break;
            }
          }
          line_count=0;
        }
        if(data_jz(which_tm,offset+i)<zero+500) below_zero_cnt++;  //如果回零,返回
        else below_zero_cnt=0;
        i++;
      }else WaitForSingleObject(g_hEvent,10);
    }
    if(found_flag==TRUE)*dx=line_count;
    else *dx=0;
    return ret_offset;
  }
}

int __fastcall get_ad_jin(long *ad_j1,long *ad_j2,long *ad_z1,long *ad_z2)
{
  int i;

  for(*ad_j1=*ad_j2=*ad_z1=*ad_z2=0,i=0;i<JIN_SIZE;i++){
    *ad_j1+=jin_j1[i];  *ad_j2+=jin_j2[i];
    *ad_z1+=jin_z1[i];  *ad_z2+=jin_z2[i];
  }

  *ad_j1/=JIN_SIZE;  *ad_j2/=JIN_SIZE;
  *ad_z1/=JIN_SIZE;  *ad_z2/=JIN_SIZE;
  return 0;
}

int __fastcall get_ad_jin_newcpz(long& ad_j1,long& ad_j2,long& ad_z1,long& ad_z2,
                                 long& ad_j3,long& ad_j4,long& ad_z3,long& ad_z4,
                                 long& ad_j5,long& ad_j6,long& ad_j7,long& ad_j8 )
{
  int i;

  for(ad_j1=ad_j2=ad_z1=ad_z2=ad_j3=ad_j4=ad_z3=ad_z4=ad_j5=ad_j6=ad_j7=ad_j8=0,
                     i=0;i<JIN_SIZE;i++){
    ad_j1+=jin_j1[i];  ad_j2+=jin_j2[i];
    ad_z1+=jin_z1[i];  ad_z2+=jin_z2[i];
    ad_j3+=jin_j3[i];  ad_j4+=jin_j4[i];
    ad_z3+=jin_z3[i];  ad_z4+=jin_z4[i];
    ad_j5+=jin_j5[i];  ad_j6+=jin_j6[i];
    ad_j7+=jin_j7[i];  ad_j8+=jin_j8[i];
  }

  ad_j1/=JIN_SIZE;  ad_j2/=JIN_SIZE;
  ad_z1/=JIN_SIZE;  ad_z2/=JIN_SIZE;
  ad_j3/=JIN_SIZE;  ad_j4/=JIN_SIZE;
  ad_z3/=JIN_SIZE;  ad_z4/=JIN_SIZE;
  ad_j5/=JIN_SIZE;  ad_j6/=JIN_SIZE;
  ad_j7/=JIN_SIZE;  ad_j8/=JIN_SIZE;
  return 0;
}

/*
int __fastcall get_ad_jin_cpz24( long& j1,long& j2,long& j3,long& j4, long& j5,long& j6,long& j7,long& j8,
                                 long& j9,long& j10,long& j11,long& j12, long& j13,long& j14,long& j15,long& j16,
                                 long& z1,long& z2,long& z3,long& z4, long& z5,long& z6,long& z7,long& z8)
{
  int i;

  for(j1=j2=j3=j4=j5=j6=j7=j8=j9=j10=j11=j12=j13=j14=j15=j16=z1=z2=z3=z4=z5=z6=z7=z8=0,
                     i=0;i<JIN_SIZE;i++){
    j1+=jin_j1[i];  j2+=jin_j2[i];
    j3+=jin_j3[i];  j4+=jin_j4[i];
    j5+=jin_j5[i];  j6+=jin_j6[i];
    j7+=jin_j7[i];  j8+=jin_j8[i];
    j9+=jin_j9[i];  j10+=jin_j10[i];
    j11+=jin_j11[i]; j12+=jin_j12[i];
    j13+=jin_j13[i]; j14+=jin_j14[i];
    j15+=jin_j15[i]; j16+=jin_j16[i];
    z1+=jin_z1[i];  z2+=jin_z2[i];
    z3+=jin_z3[i];  z4+=jin_z4[i];
    z5+=jin_z5[i];  z6+=jin_z6[i];
    z7+=jin_z7[i];  z8+=jin_z8[i];
  }

  j1/=JIN_SIZE;  j2/=JIN_SIZE;
  j3/=JIN_SIZE;  j4/=JIN_SIZE;
  j5/=JIN_SIZE;  j6/=JIN_SIZE;
  j7/=JIN_SIZE;  j8/=JIN_SIZE;
  j9/=JIN_SIZE;  j10/=JIN_SIZE;
  j11/=JIN_SIZE; j12/=JIN_SIZE;
  j13/=JIN_SIZE; j14/=JIN_SIZE;
  j15/=JIN_SIZE; j16/=JIN_SIZE;
  z1/=JIN_SIZE;  z2/=JIN_SIZE;
  z3/=JIN_SIZE;  z4/=JIN_SIZE;
  z5/=JIN_SIZE;  z6/=JIN_SIZE;
  z7/=JIN_SIZE;  z8/=JIN_SIZE;
  return 0;
} */


int __fastcall get_ad_jin_cpz24(long* adj,long* adz)
{
  int i,j;

  for(j=0;j<16;j++){
    for(i=0,adj[j]=0;i<JIN_SIZE;i++){
      adj[j]+=jin_j[j][i];
    }
    adj[j]/=JIN_SIZE;
  }
  for(j=0;j<8;j++){
    for(i=0,adz[j]=0;i<JIN_SIZE;i++){
      adz[j]+=jin_z[j][i];
    }
    adz[j]/=JIN_SIZE;
  }
  return 0;
}

// 从静态数组里取台面当前AD值,动态称重时用
int __fastcall get_ad_don(long *p_addon)
{
  static long bak_ofst=0;
  long tmp_ofst;

  if(bak_ofst==jin_ofst) return -1; //新数据没有到
  else{
    bak_ofst=jin_ofst;
    if(bak_ofst==0) tmp_ofst=JIN_SIZE-1;
    else tmp_ofst=bak_ofst-1;
    if(bd.hq_mode==HQ_CPZ){
      *p_addon=(((long)jin_j1[tmp_ofst]+(long)jin_j2[tmp_ofst])*bd.k_j_z
                +(long)jin_z1[tmp_ofst]+(long)jin_z2[tmp_ofst])/2;
    }else if(bd.hq_mode==HQ_BDG){
      *p_addon=(long)jin_j1[tmp_ofst]*bd.k_j_z +
               (long)jin_z1[tmp_ofst];
    }else if(bd.hq_mode==HQ_DG){
      *p_addon=(long)jin_z1[tmp_ofst];
    }else if(bd.hq_mode==HQ_STMDG){
      *p_addon=(long)jin_z1[tmp_ofst]+(long)jin_z2[tmp_ofst];
    }else if(bd.hq_mode==HQ_STMBDG||bd.hq_mode==HQ_BDG3){
      *p_addon=((long)jin_j1[tmp_ofst]+(long)jin_j2[tmp_ofst])*bd.k_j_z
               +(long)jin_z1[tmp_ofst]+(long)jin_z2[tmp_ofst];
    }else if(bd.hq_mode==HQ_NEWCPZ){
      *p_addon=((long)jin_j1[tmp_ofst]+(long)jin_j2[tmp_ofst]+
                (long)jin_j3[tmp_ofst]+(long)jin_j4[tmp_ofst]+
                (long)jin_j5[tmp_ofst]+(long)jin_j6[tmp_ofst]+
                (long)jin_j7[tmp_ofst]+(long)jin_j8[tmp_ofst])/8*bd.k_j_z
               +((long)jin_z1[tmp_ofst]+(long)jin_z2[tmp_ofst]+
                 (long)jin_z3[tmp_ofst]+(long)jin_z4[tmp_ofst])/4;
    }else if(bd.hq_mode==HQ_CPZ24){
      long tj=0,tz=0;
      for(int i=0;i<16;i++) tj+=(long)jin_j[i][tmp_ofst];
      for(int i=0;i<8;i++)  tz+=(long)jin_z[i][tmp_ofst];
      *p_addon=tj/16*bd.k_j_z+tz/8;
    }else if(bd.hq_mode==HQ_CPZGZ){
      long tj=0,tz=0;
      for(int i=0;i<4;i++) tj+=(long)jin_j[i][tmp_ofst];
      for(int i=0;i<2;i++)  tz+=(long)jin_z[i][tmp_ofst];
      *p_addon=tj/2*bd.k_j_z+tz;
    }else if(bd.hq_mode==HQ_NEWBDG){
      long tj=0,tz=0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -