//--------------------------------------------------------------------------- #include #pragma hdrstop #include "PACSDK.h" #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- HANDLE hPort ; void __fastcall TForm1::btnOpenComClick(TObject *Sender) { char strErr[32] ; hPort=uart_Open(etComFormat->Text.c_str() ); if(hPort == INVALID_HANDLE_VALUE) { pac_GetErrorMessage(pac_GetLastError(), strErr); MessageBox(NULL,strErr,"Open COM error",MB_OK); } else { btnOpenCom->Enabled =false; btnCloseCom->Enabled =true; } } //--------------------------------------------------------------------------- void __fastcall TForm1::btnCloseComClick(TObject *Sender) { uart_Close(hPort); btnOpenCom->Enabled =true; btnCloseCom->Enabled =false; } //--------------------------------------------------------------------------- void __fastcall TForm1::btnReadDIClick(TObject *Sender) { char strErr[32] ; unsigned long DI_Value; int TotalChs= StrToInt(etTotalChs->Text ); bool bRet=pac_ReadDI(hPort,PAC_REMOTE_IO(StrToInt(etAddr->Text)),TotalChs,&DI_Value); if(bRet!=false) { etDIValue->Text =IntToHex((int)DI_Value,TotalChs/4); } else { pac_GetErrorMessage(pac_GetLastError(), strErr); MessageBox(NULL,strErr,"Read DI error",MB_OK); } } //---------------------------------------------------------------------------