//--------------------------------------------------------------------------- #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::btnReadAIClick(TObject *Sender) { char strErr[32] ; float fAIValue; bool bRet=pac_ReadAI(hPort,PAC_REMOTE_IO(StrToInt(etAddr->Text)),StrToInt(etReadCh->Text ) ,StrToInt(etTotalChs->Text ),&fAIValue); if(bRet==false) { pac_GetErrorMessage(pac_GetLastError(), strErr); MessageBox(NULL,strErr,"Read AI error",MB_OK); } else etAIValue->Text =FloatToStr(fAIValue); } //---------------------------------------------------------------------------