//--------------------------------------------------------------------------- #include #include "Acces32.h" #pragma hdrstop #include "sample0u.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TSample0Form *Sample0Form; //--------------------------------------------------------------------------- __fastcall TSample0Form::TSample0Form(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TSample0Form::ExitButtonClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TSample0Form::TestButtonClick(TObject *Sender) { int x; if (TestTimer->Enabled == True) { TestTimer->Enabled = False; for (x = 0;x<=15;x++) ((TLabel *)(ChannelBox->Controls[x]))->Caption = " Channel "+IntToHex(x,1)+" 0"; ErrorStatus->SimpleText = ""; TestButton->Caption = "Start Test"; } // end if else { TestTimer->Enabled = True; TestButton->Caption = "Abort Test"; } // end else } // end TestButtonClick //--------------------------------------------------------------------------- void __fastcall TSample0Form::TestTimerTimer(TObject *Sender) { int base; int channel, timeout; double data, counts; base = StrToInt("0x" + BaseEdit->Text); for (channel=0; channel<=15; channel++) { timeout = 1000; OutPortB(base+2, channel); /*counts = GetTickCount(); while (counts < GetTickCount()) counts++; */ Sleep(2); OutPortB(base+3, 0); while (!((InPortB(base+2) & 0x80) == 0) & (timeout > 0)) timeout--; if (timeout<=0) ErrorStatus->SimpleText = "A/D timeout on Channel "+IntToHex(channel,1); data=InPort(base+6) >> 4; ((TLabel *)(ChannelBox->Controls[channel]))->Caption = " Channel "+IntToHex(channel,1)+" "+FloatToStrF(data,ffGeneral,15,0); } // end for } // end TestTimerTimer //--------------------------------------------------------------------------- void __fastcall TSample0Form::FormCreate(TObject *Sender) { if (InPortB(0x61) == 0xAA55) { Application->MessageBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", "Warning", IDOK); } } //---------------------------------------------------------------------------