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

📄 inputblockdata.~cpp

📁 RFID 读卡演示程序
💻 ~CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "InputBlockData.h"
#include "ISO15693.h"
//#include "Unit1.h"
#include "Unit1.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Edit_BlockCountValChange(TObject *Sender)
{
    //Table_Block_Data->RowCount=Edit_BlockCountVal->Text.ToInt();
    if(Edit_StartBlockVal->Text==""){
        Edit_StartBlockVal->Text="0";
    }
    if(Edit_BlockCountVal->Text==""){
        Edit_BlockCountVal->Text="0";
    }
    //Table_Block_Data->ColCount=Edit_StartBlockVal->Text.ToInt();
    Table_Block_Data->RowCount=Edit_BlockCountVal->Text.ToInt();
   
    for(int i=0;i<Table_Block_Data->RowCount;i++){
         Table_Block_Data->Cells[0][i]="Block"+AnsiString(Edit_StartBlockVal->Text.ToInt()+i);
         Table_Block_Data->Cells[1][i]="00";
         Table_Block_Data->Cells[2][i]="00";
         Table_Block_Data->Cells[3][i]="00";
         Table_Block_Data->Cells[4][i]="00";
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm3::Button1Click(TObject *Sender)
{
char   *temp;
BYTE Bval[500];
char* Str_temp_val;
int nStartBlock;
int  nLength;
String temp2;
DWORD nBytesRead ;//返回字节数
    if(Edit_StartBlockVal->Text==""){
        Edit_StartBlockVal->Text="0";
    }
    if(Edit_BlockCountVal->Text==""){
        Edit_BlockCountVal->Text="0";
    }
    for(int i=0;i<Table_Block_Data->RowCount;i++){
         Table_Block_Data->Cells[0][i]="Block"+AnsiString(Edit_StartBlockVal->Text.ToInt()+i);
         Table_Block_Data->Cells[1][i]="00";
         Table_Block_Data->Cells[2][i]="00";
         Table_Block_Data->Cells[3][i]="00";
         Table_Block_Data->Cells[4][i]="00";
   Bval[0+4*i]=strtol(("0x"+Table_Block_Data->Cells[1][i]).c_str(),   &temp,   16);
   Bval[1+4*i]=strtol(("0x"+Table_Block_Data->Cells[2][i]).c_str(),   &temp,   16);
   Bval[2+4*i]=strtol(("0x"+Table_Block_Data->Cells[3][i]).c_str(),   &temp,   16);
   Bval[3+4*i]=strtol(("0x"+Table_Block_Data->Cells[4][i]).c_str(),   &temp,   16);
    }
    Str_temp_val=("0x"+Edit_StartBlockVal->Text).c_str();
    nStartBlock   =   strtol(Str_temp_val,   &temp,   16);
                          Str_temp_val=("0x"+Edit_BlockCountVal->Text).c_str();
    nLength   =   strtol(Str_temp_val,   &temp,   16);
    //USEFORM("Unit1.cpp", Form1);
          Str_temp_val=("0x"+FlagVal).c_str();
    long flag   =   strtol(Str_temp_val,   &temp,   16);
    WriteMultiBlock(Sendval,retval,toUniteStr(temp,Tag_val->Text,2).c_str(),Bval,nStartBlock,nLength,flag,nBytesRead);
         Form1->ShowOperateInfo((char*)Sendval);
       // Form1->Memo_Tag_Info->Lines->Add(TimeToStr(Now())+":"+123);
temp2=(char*)retval;
           if(temp2==""){
       Form1->ShowOperateInfo("No Reply");
          Form3->Close();
       }
  //Form2->ShowOperateInfo((char*)Sendval);
  Form1->ShowOperateInfo((char*)retval);
  Form3->Close();
    //USEFORM("Unit1.cpp", Form2)
}
   /**
    * 将从s每charNum个字符合成一个字符,生成一个新串
    * @param s 将要处理的字符串
    * @param charNum 合并取的字符数:例如果s='1234' charNum=2 就是将12,34分别合并生成一个字符,长度为2
    * @return
    */
String __fastcall TForm3::toUniteStr(char   *temp,String s,int charNum){
String str;
	   if(s.Length()<=charNum){
            str=strtol(("0x"+s).c_str(),   &temp,   16);
		   return String((char)str.ToInt());
	   }

            //s.IntToHex(s.SubString(s.Length()-charNum,charNum).ToInt(),16);
           str= strtol(("0x"+s.SubString(s.Length()-charNum+1,charNum)).c_str(),   &temp,   16);
	   return String((char)str.ToInt())+toUniteStr(temp,s.SubString(0,s.Length()-charNum),charNum);
   }
//---------------------------------------------------------------------------


void __fastcall TForm3::Button2Click(TObject *Sender)
{
   Form3->Close();     
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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