//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" #include "PACSDK.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //For AO modules: //The general SDK, XPacSDK_CE.dll, supports only 87K and 7K series. //8K series AO modules have their own libraries. //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { cbbSlot->ItemIndex = 0; cbbChannel->ItemIndex = 0; int total_ch = StrToInt(cbbChannel->Items->Strings[cbbChannel->ItemIndex]); addItems2cbbSingleCh(Sender, total_ch); cbbSingleCh->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TForm1::addItems2cbbSingleCh(TObject *Sender, int total_ch) { cbbSingleCh->Items->Clear(); for (int i = 0; i < total_ch; i++) { cbbSingleCh->Items->Add(IntToStr(i)); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) //Write AO { int slot = cbbSlot->ItemIndex + 1; int total_ch = StrToInt(cbbChannel->Items->Strings[cbbChannel->ItemIndex]); int ch = StrToInt(cbbSingleCh->Items->Strings[cbbSingleCh->ItemIndex]); float AO_fValue = StrToFloat(Edit1->Text); HANDLE h = uart_Open(""); pac_WriteAO(h, slot, ch, total_ch, AO_fValue); uart_Close(h); } //--------------------------------------------------------------------------- void __fastcall TForm1::cbbChannelChange(TObject *Sender) { int total_ch = StrToInt(cbbChannel->Items->Strings[cbbChannel->ItemIndex]); addItems2cbbSingleCh(Sender, total_ch); cbbSingleCh->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) //read AO back { int slot = cbbSlot->ItemIndex + 1; int total_ch = StrToInt(cbbChannel->Items->Strings[cbbChannel->ItemIndex]); int ch = StrToInt(cbbSingleCh->Items->Strings[cbbSingleCh->ItemIndex]); float AO_fValue = 0; HANDLE h = uart_Open(""); pac_ReadAO(h, slot, ch, total_ch, &AO_fValue); Edit2->Text = FloatToStr(AO_fValue); uart_Close(h); } //---------------------------------------------------------------------------