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

📄 csh.cpp

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

#include <vcl.h>
#pragma hdrstop
#include "pcom.h"
#include "csh.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
char  LoopVal=0;
int   RadioVal=0;

TForm5 *Form5;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Button2Click(TObject *Sender)
{
   Close();        
}
//---------------------------------------------------------------------------








void __fastcall TForm5::CalVal()
{
 /* switch(LoopVal)
  {
   case 0x00:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L0-0.bmp");
        break;
   case 0x01:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L1-2.bmp");
        break;
   case 0x02:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L3-4.bmp");
        break;
   case 0x03:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L12-34.bmp");
        break;
   case 0x04:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L5-6.bmp");
        break;
   case 0x05:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L12-56.bmp");
        break;
   case 0x06:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L34-56.bmp");
        break;
   case 0x07:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L12-34-56.bmp");
        break;
   case 0x08:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L7-8.bmp");
        break;
   case 0x09:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L12-78.bmp");
        break;
   case 0x0a:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L34-78.bmp");
        break;
   case 0x0B:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L12-34-78.bmp");
        break;
   case 0x0c:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L56-78.bmp");
        break;
   case 0x0D:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L12-56-78.bmp");
        break;
   case 0x0E:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L34-56-78.bmp");
        break;
   case 0x0F:
        Img1->Picture->LoadFromFile("d:\\wxc1\\端子\\L1234-5678.bmp");
        break;
  }  */
}
void __fastcall TForm5::Shape1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
       Shape1->Visible=true; 
}
//---------------------------------------------------------------------------






void __fastcall TForm5::SpeedButton5Click(TObject *Sender)
{
    Close();    
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton2MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
      SBar->Panels->Items[0]->Text="发送自定义数据";  
}
//---------------------------------------------------------------------------


void __fastcall TForm5::SpeedButton1MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
     SBar->Panels->Items[0]->Text="计算校验位";      
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton5MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
      SBar->Panels->Items[0]->Text="退出本窗体";    
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton4MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
   SBar->Panels->Items[0]->Text="发送请求信息";       
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Shape2MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
   SBar->Panels->Items[0]->Text="";       
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Shape4MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
      SBar->Panels->Items[0]->Text="";    
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Memo1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
     SBar->Panels->Items[0]->Text="";          
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Memo2MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    SBar->Panels->Items[0]->Text="";          
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton4Click(TObject *Sender)
{
   switch(RadioVal)
   {
    case 0:
         AutoLoop();
         Memo1->Lines->Add(disStr);
         break;
    case 1:
         AutoIO();
         Memo1->Lines->Add(disStr);
         break;
    case 2:
         StartoV();
         Memo1->Lines->Add(disStr);
         break;
    case 3:
         EndoV();
         Memo1->Lines->Add(disStr);
         break;
    case 4:
         DynMode();
         Memo1->Lines->Add(disStr);
         break;
    case 5:
         StaMode();
         Memo1->Lines->Add(disStr);
         break;
    case 6:
         ZeroSet();
         Memo1->Lines->Add(disStr);
         break;
   }

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

void __fastcall TForm5::RB1Click(TObject *Sender)
{
   RadioVal=0;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB2Click(TObject *Sender)
{
   RadioVal=1;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB3Click(TObject *Sender)
{
   RadioVal=2;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB4Click(TObject *Sender)
{
   RadioVal=3;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB5Click(TObject *Sender)
{
   RadioVal=4;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB6Click(TObject *Sender)
{
   RadioVal=5;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB7Click(TObject *Sender)
{
   RadioVal=6;        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton3Click(TObject *Sender)
{
    Memo1->Lines->Clear();        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton6Click(TObject *Sender)
{
   Memo2->Lines->Clear();        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton7Click(TObject *Sender)
{
    Memo1->Lines->Clear();
    Memo2->Lines->Clear();     
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton1Click(TObject *Sender)
{
    AnsiString s,buf;
    int temp,temp1;
    Byte Chk;
    Chk=Byte(0x00);

     buf=Edit1->Text;
     if (Edit1->Text.Length()%2!=0)
           ShowMessage("输入错误!请重新输入。");
           else
           for(int i=0;i<buf.Length()/2;i++)
           {
             s=buf.SubString(2*i+1,2);
             char *buf1=s.c_str();
             temp=(buf1[0]&0xff);
                if (temp==0x30)
                 temp1=0;
                else if (temp==0x31)
                 temp1=1*16;
                else if (temp==0x32)
                 temp1=2*16;
                else if (temp==0x33)
                 temp1=3*16;
                else if (temp==0x34)
                 temp1=4*16;
                else if (temp==0x35)
                 temp1=5*16;
                else if (temp==0x36)
                 temp1=6*16;
                else if (temp==0x37)
                 temp1=7*16;
                else if (temp==0x38)
                 temp1=8*16;
                else if (temp==0x39)
                 temp1=9*16;
                else if(temp==0x61)
                 temp1=10*16;
                else if (temp==0x62)
                 temp1=11*16;
                else if (temp==0x63)
                 temp1=12*16;
                else if (temp==0x64)
                 temp1=13*16;
                else if (temp==0x65)
                 temp1=14*16;
                else if (temp==0x66)
                 temp1=15*16;

             temp=(buf1[1]&0xff);///16;//*16;//+(buf1[1]&0xff)%16;
              if (temp==0x30)
                 temp1+=0;
                else if (temp==0x31)
                 temp1+=1;
                else if (temp==0x32)
                 temp1+=2;
                else if (temp==0x33)
                 temp1+=3;
                else if (temp==0x34)
                 temp1+=4;
                else if (temp==0x35)
                 temp1+=5;
                else if (temp==0x36)
                 temp1+=6;
                else if (temp==0x37)
                 temp1+=7;
                else if (temp==0x38)
                 temp1+=8;
                else if (temp==0x39)
                 temp1+=9;
                else if (temp==0x61)
                 temp1+=10;
                else if (temp==0x62)
                 temp1+=11;
                else if (temp==0x63)
                 temp1+=12;
                else if (temp==0x64)
                 temp1+=13;
                else if (temp==0x65)
                 temp1+=14;
                else if (temp==0x66)
                 temp1+=15;
                Chk-=temp1;

           }

          s="";
             temp=(Chk&0xff)/16;
                 if(temp==10)
                  s+="A";
                  else
                  if(temp==11)
                   s+="B";
                  else
                  if(temp==12)
                  s+="C";
                  else
                  if(temp==13)
                  s+="D";
                  else
                  if(temp==14)
                  s+="E";
                  else
                  if(temp==15)
                  s+="F";
                  else
                  s+=IntToStr(temp);
                   temp=(Chk&0xff)%16;
                 if(temp==10)
                  s+="A";
                  else
                  if(temp==11)
                   s+="B";
                  else
                  if(temp==12)
                  s+="C";
                  else
                  if(temp==13)
                  s+="D";
                  else
                  if(temp==14)
                  s+="E";
                  else
                  if(temp==15)
                  s+="F";
                  else
                  s+=IntToStr(temp);
                  s+="  ";
                  s=Edit1->Text+ s;
           Edit1->Text=Trim(s);
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton2Click(TObject *Sender)
{
  AnsiString buf;
  int len;
  len=Edit1->Text.Length();
  if (len>0)
  {
  buf=Edit1->Text;
  Memo1->Lines->Add(Edit1->Text);
  SendBuf(buf,len);
  }
  else
  MessageDlg("请填写发送的数据",mtError,TMsgDlgButtons() << mbOK, 0);
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    SBar->Panels->Items[0]->Text="发送线圈初始化信号:55 04 02 00 AA FB";
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB2MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
     SBar->Panels->Items[0]->Text="发送I/O初始化信号:55 B1 02 00 AA 4E";
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB3MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    SBar->Panels->Items[0]->Text="发送开始信号:55 C8 01 00 AA 38";
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB4MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
   SBar->Panels->Items[0]->Text="发送结束信号:55 CA 01 00 AA 36";        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB5MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    SBar->Panels->Items[0]->Text="发送动态模式信号:55 C4 01 00 AA 3C";        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB6MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
   SBar->Panels->Items[0]->Text="发送静态模式信号:55 C5 01 00 AA 3B";        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::RB7MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    SBar->Panels->Items[0]->Text="发送零点设置信号:55 C6 01 00 AA 3A";        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton3MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
  SBar->Panels->Items[0]->Text="清空发送区数据";        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton6MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
    SBar->Panels->Items[0]->Text="清空接收区数据";    
}
//---------------------------------------------------------------------------

void __fastcall TForm5::SpeedButton7MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
   SBar->Panels->Items[0]->Text="同时清空发送区和接收区数据";        
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Edit1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    SBar->Panels->Items[0]->Text="自定义数据区";    
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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