//--------------------------------------------------------------------------- #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::btnWriteAOClick(TObject *Sender) { char strErr[32] ; float fAOValue=StrToFloat( etAOValue->Text); bool bRet=pac_WriteAO(hPort,PAC_REMOTE_IO(StrToInt(etAddr->Text)),StrToInt(etWriteCh->Text ),StrToInt(etTotalChs->Text ),fAOValue); if(bRet==false) { pac_GetErrorMessage(pac_GetLastError(), strErr); MessageBox(NULL,strErr,"Write AO error",MB_OK); } } //---------------------------------------------------------------------------