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

📄 cpzsetup.cpp

📁 数据采集
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    }
  }
  pzc=(int)tmp;
  pzl_q /= (bzz+pzc)/2;
  pzl_h /= (bzz-pzc)/2;
  if(pzl_q<0.0001) pzl_q=0.0;
  if(pzl_h<0.0001) pzl_h=0.0;

  e_pzc->Text=pzc;
  e_pzlq->Text=ftos(pzl_q,7,4);
  e_pzlh->Text=ftos(pzl_h,7,4);

/*
  int pzc;
  float pzl_q=0.0,pzl_h=0.0;
  double d=0.0;

  for(int j=0;j<LIE;j++){
    for(int i=0;i<HAN;i++){
      m[j][i]=StrToInt( ((TEdit *)( ((TList *)(ll->Items[j])) ->Items[i] ))->Text );
      d+= (double)m[j][i]*(x[j][i]-5820)/4350.0;
    }
  }
  pzc=(int)d;


  int bzz=StrToInt(e_bzz->Text);
  if(bzz<=0){
      Application->MessageBox("  标准值 <= 0   ", NULL, MB_OK);
      return;
  }

  for(int j=0;j<LIE;j++){
    for(int i=0;i<HAN;i++){
      pzl_q+=(double)m[j][i]*(x[j][i]-1470.0) /8700.0*(y[j][i]-1250.0)/746.5;
      pzl_h+=(double)m[j][i]*(10170.0-x[j][i])/8700.0*(y[j][i]-1250.0)/746.5;
    }
  }
  pzl_q /= (bzz+pzc)/2;
  pzl_h /= (bzz-pzc)/2;

  l_pzc->Caption=pzc;
  l_pzl_q->Caption=FloatToStrF( pzl_q,ffGeneral	,4,7);
  l_pzl_h->Caption=FloatToStrF( pzl_h,ffGeneral	,4,7);
  */

}
//---------------------------------------------------------------------------



void __fastcall Tform_cpzsetup::get_mxy(int& m,int& x,int& y,String s)
{
  int i=s.Pos(",");
  if(i==0){ m=0,x=0,y=0;return;}
  String sm=s.SubString(0,i-1);

  s=s.SubString(i+1,s.Length()-i);
  if((i=s.Pos(","))==0){ m=0,x=0,y=0;return;}
  String sx=s.SubString(0,i-1);
  String sy=s.SubString(i+1,s.Length()-i);
  
  m=StrToInt(sm);
  x=StrToInt(sx);
  y=StrToInt(sy);
}


void __fastcall Tform_cpzsetup::e_colsExit(TObject *Sender)
{
  sg_jsnew->ColCount=StrToInt(e_cols->Text);
  sg_jsnew2->ColCount=sg_jsnew->ColCount;
  for(int i=0;i<sg_jsnew->ColCount;i++){
    sg_jsnew2->Cells[i][0]=i+1;
    sg_jsnew->ColWidths[i]=(sg_jsnew->Width-10)/sg_jsnew->ColCount;
    sg_jsnew2->ColWidths[i]=sg_jsnew->ColWidths[i] ;
  }
        
        
}
//---------------------------------------------------------------------------



void __fastcall Tform_cpzsetup::FormCreate(TObject *Sender)
{
  create_edit_label();
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::FormClose(TObject *Sender,
      TCloseAction &Action)
{
  delete_edit_label();
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::create_edit_label()
{
  for(int j=0;j<LIE;j++){
    y[j][0]=2188;
    y[j][1]=1562;
    y[j][2]=938;
    y[j][3]=312;
  }
  for(int i=0;i<HAN;i++){
    if(is_13==0){// 换长1.2
      x[0][i]=613;
      x[1][i]=1840;
      x[2][i]=3066;
      x[3][i]=4540;
      x[4][i]=5820;
      x[5][i]=7100;
      x[6][i]=8574;
      x[7][i]=9800;
      x[8][i]=11027;
    }else if(is_13==1){// 换长1.3A
      x[0][i]=2300;
      x[1][i]=3510;
      x[2][i]=4720;
      x[3][i]=5930;
      x[4][i]=0;   // 没用
      x[5][i]=7130;
      x[6][i]=8340;
      x[7][i]=9550;
      x[8][i]=10760;
    }else if(is_13==2){// 换长1.3B
      x[0][i]=1050; // 600+450
      x[1][i]=2275;
      x[2][i]=3500;
      x[3][i]=5000;
      x[4][i]=6250;
      x[5][i]=7500;
      x[6][i]=9000;
      x[7][i]=10225;
      x[8][i]=11450;
    }else{
      err("   没有该换长  ");
    }
  }

  const int W=62,H=22;
  ll= new TList;
  ll2=new TList;
  ll3=new TList;
  for(int j=0;j<LIE;j++){
      l  = new TList;
      l2 = new TList;
      l3 = new TList;
      for (int i=0;i<HAN;i++){
            TEdit *edit=new TEdit(this);
            edit->Parent=T_js_pzcpzl;//指定父控件
            edit->Text=IntToStr(0);
            edit->Width=W;
            edit->Height=H;
            if(j<4){
              edit->Left=W*j+30 ;
            }else if(j==4){
              edit->Left=W*j+30*2 ;
            }else{
              edit->Left=W*j+30*3 ;
            }
            edit->Top =H*i+50;
            l->Add(edit);//list[]是一个TList的指针

            TLabel *label=new TLabel(this);
            label->Parent=T_js_pzcpzl;//指定父控件
            label->Caption=IntToStr(x[j][i])+","+IntToStr(y[j][i]);
            label->Width=W;
            label->Height=H;
            if(j<4){
              label->Left=W*j+30 ;
            }else if(j==4){
              label->Left=W*j+30*2 ;
            }else{
              label->Left=W*j+30*3 ;
            }
            label->Top =H*i+50+H*(HAN+1);
            l2->Add(label);//list[]是一个TList的指针

            // for dlt_x
            edit=new TEdit(this);
            edit->Parent=T_js_pzcpzl;//指定父控件
            edit->Text=IntToStr(0);
            edit->Width=W*2/3;
            edit->Height=H;
            if(j<4){
              edit->Left=W*j+30 ;
            }else if(j==4){
              edit->Left=W*j+30*2 ;
            }else{
              edit->Left=W*j+30*3 ;
            }
            edit->Top =H*i+250;
            l3->Add(edit);//list[]是一个TList的指针
      }
      ll ->Add(l);
      ll2->Add(l2);
      ll3->Add(l3);
  }
}

void __fastcall Tform_cpzsetup::delete_edit_label()
{
  for(int j=0;j<LIE;j++){
    for(int i=0;i<HAN;i++){
            delete (TEdit  *)( ((TList *)(ll ->Items[j])) ->Items[i] );
            delete (TLabel *)( ((TList *)(ll2->Items[j])) ->Items[i] );
            delete (TEdit  *)( ((TList *)(ll3->Items[j])) ->Items[i] );
    }
    delete (TList *)ll ->Items[j];
    delete (TList *)ll2->Items[j];
    delete (TList *)ll3->Items[j];
  }
  delete ll;
  delete ll2;
  delete ll3;
}

void __fastcall Tform_cpzsetup::send_setupClick(TObject *Sender)
{
  memo_status->Lines->Clear();
  send_cpzsetup(e_host->Text,"DELL");
}

void __fastcall Tform_cpzsetup::send_cpzsetup(const String& host,const String& from)
{
  if( FileExists(CPZSETUP) ){
    TFileStream *MyFStream;
    MyFStream = new TFileStream(CPZSETUP, fmOpenRead);
    try{
      NMStrm1->Host = host;
      NMStrm1->FromName = from;
      NMStrm1->PostIt(MyFStream);
    }catch(...){ }
    MyFStream->Free();
  }
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrmServ1MSG(TComponent *Sender,
      const AnsiString sFrom, TStream *strm)
{
  bool reci_ok=false;
  char CPZSETUP_OLD[100]="c:\\cb4\\wingdh\\wk\\cpzsetup_old";
  if (FileExists(CPZSETUP)){
    DeleteFile(CPZSETUP_OLD);
    rename(CPZSETUP,CPZSETUP_OLD);
    DeleteFile(CPZSETUP);
  }

  TFileStream *MyFStream;
  MyFStream = new TFileStream(CPZSETUP, fmCreate);
  try{
    if(strm->Size!=sizeof(cpz_setup)){
      MyFStream->Free();

      lock_flag=false;
      cpz_setup.lock_flag=false;
      write_cpz_setup();
      return;
    }

    MyFStream->CopyFrom(strm, strm->Size);
    MyFStream->Free();
    if(read_cpz_setup(CPZSETUP)){
      lock_flag=cpz_setup.lock_flag;
      reci_ok=true;
    }else{
      lock_flag=false;
      cpz_setup.lock_flag=false;
      write_cpz_setup();
    }
  }
  catch(...)
  {
     MyFStream->Free();

     lock_flag=false;
     cpz_setup.lock_flag=false;
     write_cpz_setup();
  }

  try{
    if(reci_ok==true){
      if(is_debug){T_js_pzcpzlShow(NULL);} // 显示
      memo_status->Lines->Add("reci_OK!!");

      if(sFrom=="DELL"){
        send_cpzsetup("192.168.0.222","cpz"); // 回复,DELL:192.168.0.222
      }
    }
  }catch(...){ }
}
//---------------------------------------------------------------------------


void __fastcall Tform_cpzsetup::NMStrm1Status(TComponent *Sender,
      AnsiString Status)
{
  memo_status->Lines->Add(Status);
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrm1Connect(TObject *Sender)
{
   memo_status->Lines->Add("connected");
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrm1ConnectionFailed(TObject *Sender)
{
  memo_status->Lines->Add("connect failed");
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrm1Disconnect(TObject *Sender)
{
  memo_status->Lines->Add("disconnected");
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrm1HostResolved(TComponent *Sender)
{
  memo_status->Lines->Add("host resolved");
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrm1InvalidHost(bool &Handled)
{
  memo_status->Lines->Add("invalid host");
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::NMStrm1MessageSent(TObject *Sender)
{
  memo_status->Lines->Add("stream send");
}
//---------------------------------------------------------------------------



void __fastcall Tform_cpzsetup::Button3Click(TObject *Sender)
{
  OSVERSIONINFO v; // version information
  v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
  GetVersionEx(&v);
  Edit11->Text=v.dwMajorVersion ;
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::cb_by_weiClick(TObject *Sender)
{
  show_edit6_10(!cb_by_wei->Checked);
}

void __fastcall Tform_cpzsetup::show_edit6_10(bool visible)
{
  Edit6->Visible=visible;
  Edit7->Visible=visible;
  Edit8->Visible=visible;
  Edit9->Visible=visible;
  Edit10->Visible=visible;
}

//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::TabSheet1Show(TObject *Sender)
{
   for(int i=0;i<5;i++){
     StringGrid1->Cells[0][i]=bd2.ad_lr[i];
     StringGrid1->Cells[1][i]=bd2.ad_rl[i];
     StringGrid1->Cells[2][i]=bd2.wei[i];
   }
}
//---------------------------------------------------------------------------

void __fastcall Tform_cpzsetup::save_bd2Click(TObject *Sender)
{
  try{
    for(int i=0;i<5;i++){
      String s[3];
      for(int j=0;j<3;j++)  s[j]=StringGrid1->Cells[j][i].Trim();
      if(s[0]!="") bd2.ad_lr[i]=StrToInt(s[0]);else bd2.ad_lr[i]=0;
      if(s[1]!="") bd2.ad_rl[i]=StrToInt(s[1]);else bd2.ad_rl[i]=0;
      if(s[2]!="") bd2.wei[i]=StrToInt(s[2]);  else bd2.wei[i]=0;
    }

    if(write_bd2()) { err( "save bd2 OK OK " ); }
    else            { err( "save bd2 failed !!! " ); }
  }catch(Exception &e){ err("  has error!  "); }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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