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

📄 loop3.cpp

📁 公路站超载检测系统上位机软件系统源程序!
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Pcom.h"
#include "loop3.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm3::Butt_CloseClick(TObject *Sender)
{
Close();        
}
//---------------------------------------------------------------------------


void __fastcall TForm3::Button1Click(TObject *Sender)
{
   int limp,ret,len,err_code,Chk;
   unsigned char Buffer[10],ibuf[7];

    sysInfoLbl->Caption="请进车称重";
  // allweight->Caption="";
   // Form1->ov=0;
    EditAG1->Text="";
    EditAG2->Text="";
    EditAG3->Text="";
    EditAG4->Text="";
    EditAG5->Text="";
    EditAG6->Text="";

    EditAT1->Text="";
    EditAT2->Text="";
    EditAT3->Text="";
    EditAT4->Text="";
    EditAT5->Text="";
    EditAT6->Text="";

    EditALi1->Text="";
    EditALi2->Text="";
    EditALi3->Text="";
    EditALi4->Text="";
    EditALi5->Text="";
    EditALi6->Text="";

    EditAO1->Text="";
    EditAO2->Text="";
    EditAO3->Text="";
    EditAO4->Text="";
    EditAO5->Text="";
    EditAO6->Text="";

    EditVT->Text="";
    EditVL->Text="";
    EditVO->Text="";
    
    StartoV();        //发送开始信号
}
//---------------------------------------------------------------------------


void __fastcall TForm3::TendTimer(TObject *Sender)
{
/*    Tend->Enabled=false;

  
    int limp,ret,help,len,err_code;
    err_code=0;
    AnsiString tc;
    int nows;
    unsigned  char temp[6];
    unsigned  char ibuf[6];
    AnsiString ss;
    int help1,help2;
    //end command start;
    help=0x00;
    temp[0]=0x55;
    help=help-0x55;

    temp[1]=0xca;
    help=help-0xca;

    temp[2]=0x01;
    help=help-0x01;

    temp[3]=0x00;
    help=help-0x00;

    temp[4]=0xaa;
    help=help-0xaa;

    temp[5]=help;
    ret = sio_flush ( com1, 2 );
    if (ret != SIO_OK)
     {
       ShowMessage("err_code=c203");
     };
    len = sio_write( com1, temp, 6);
    if (len!=6)
     {
      ShowMessage("err_code=c06");
      err_code=-49;
     };



     limp=0;
     do
     {
      limp++;
      Sleep(30);
      ret = sio_iqueue ( com1 );
      if(limp>500)
       {

         err_code=-20;
         break;
       }

     }while(ret<6);

     if(err_code==0)
      {
        ret=sio_read (com1,ibuf, 6);    // 接 收 数 据
        if(((ibuf[0]&0xff)==0x55)&&((ibuf[1]&0xff)==0xca)&&((ibuf[2]&0xff)==0x10)&&((ibuf[3]&0xff)==0x00)&&((ibuf[4]&0xff)==0xaa)&&((ibuf[5]&0xff)==0x27))
          err_code=0;
        else
          err_code=-43;
      }
     if(err_code!=0)
       ShowMessage(IntToStr(err_code));

      if(err_code==0)
      {
        int chelp;
        limp=0;
        while(1)
        {

          chelp=sio_getch(com1);
          if(chelp==SIO_NODATA)
           {
             limp++;
             Sleep(10);
             if(limp>500)
             {
              err_code=-20;
                
              }
           }
             //HAVENOT 0X55
          if(chelp==0x55) //DO NOT DISPLAY  AND NOT IN THIS CODE
            {
               limp=0;
               do
               {
                limp++;
                Sleep(10);
                help=sio_iqueue(com1);
                if(limp>1000)
                 break;
               }while(help<2);

               help=sio_read(com1,command,2);
               command[0]=(command[0]&0xff);
               command[1]=(command[1]&0xff);
                limp=0;
                do
                {
                 limp++;
                 Sleep(10);
                 number=sio_getch(com1);
                 if(limp>1000)
                 break;
                }while(number==SIO_NODATA);
               int zjj=number&0xff;
               limp=0;
               do
                {
                  limp++;
                  Sleep(10);
                  help=sio_iqueue(com1);
                  if(limp>1000)
                   break;

                }while(help<zjj+2);

                for(int ch=0;ch<50;ch++)
                 data_buf[ch]=0x00;

                help=sio_read(com1,data_buf,zjj);
                help=(sio_getch(com1)&0xff);
                help1=(sio_getch(com1)&0xff);
                help2=0x0-0x55-help-command[0]-command[1]-number;
                ss="";

                for (int i=0;i<zjj;i++)
                {
                  help2=help2-data_buf[i];
                };
                help2=help2&0xff;
                help1=help1&0xff;
               if((help!=SIO_NODATA)&&(help==0xAA)&&(help1==help2))
               {
                  //now we will do with the data_buf;and number;
                if(((command[0]&0xff)==0xca)&&((command[1]&0xff)==0x11))
                  {
                     //for vehic details
                       Axle_num=(data_buf[4]&0xff);
                       Ax=Axle_num;
                       Speed=((data_buf[2]&0xff)*256)+(data_buf[3]&0xff);
                       total_weigh=0x00;
                       ss=IntToStr(Axle_num)+"a";
                       for(int i=0;i<Axle_num;i++)
                       {
                        vehic[i].Axle_weigh=((data_buf[5+4*i]&0xff)*256)+(data_buf[6+i*4]&0xff);
                        ss=ss+IntToStr(vehic[i].Axle_weigh)+"a";
                        vehic[i].Axle_dis=((data_buf[7+4*i]&0xff)*256)+(data_buf[8+i*4]&0xff);
                        ss=ss+IntToStr(vehic[i].Axle_dis)+"a";
                        total_weigh=total_weigh+vehic[i].Axle_weigh;
                       };
                  //   Form7->Ls->Caption=IntToStr(Speed/10+2);//+"."+IntToStr((Speed%1000)/100);

                       //call the function for display the screen
                       //vehic type
                        for(int che=0;che<=10;che++)
                         vehic[che].Axle_type=0;
                         vehic[0].Axle_type=1;
                         vehic[1].Axle_type=2;
                         if(Axle_num>1)
                         {
                          for(int i=2;i<Axle_num;i++)
                          {
                           if(vehic[i].Axle_dis<150)
                             {
                             if(vehic[i-1].Axle_type==4)

⌨️ 快捷键说明

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