//--------------------------------------------------------------------------- #include #pragma hdrstop #include "IIRO16u.h" #include "ACCES32.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TMainForm::BeginSampleClick(TObject *Sender) { if (!RunFlag) Address = StrToInt("0x"+IsaEdit->Text); if (RunTimer->Enabled) { RunTimer->Enabled = False; BeginSample->Caption = "Perform I/O"; InPortB(Address+2); } else { RunTimer->Enabled = True; BeginSample->Caption = "Stop I/O"; OutPortB(Address+2,0x00); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ExitButtonClick(TObject *Sender) { MainForm->Close(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormActivate(TObject *Sender) { if (!RunFlag) FocusControl(IsaEdit); } //--------------------------------------------------------------------------- void __fastcall TMainForm::RunTimerTimer(TObject *Sender) { static long int value[4] = {0,0,0,0}; static int i=0; int j; unsigned y; AnsiString msg; if (i < 8) { value[1] = 0; value[0] = 1 << i; } else { value[0] = 0; value[1] = 1 << (i % 8); } if (i < 8) OutPortB(Address,value[0]); else OutPortB(Address+4,value[1]); y = GetTickCount() + 10; while (GetTickCount() < y) Application->ProcessMessages(); value[2] = InPortB(Address+1); value[3] = InPortB(Address+5); i++; i %= 16; msg = AnsiString::StringOfChar('0', 16); for (j = 0; j < 8; j++) if (value[0] & 1 << j) msg[16-j] = '1'; else msg[16-j] = '0'; for (j = 0; j < 8; j++) if (value[1] & 1 << j) msg[8-j] = '1'; else msg[8-j] = '0'; RelayOut->Caption = msg; for (j = 0; j < 8; j++) if (value[2] & 1 << j) msg[16-j] = '1'; else msg[16-j] = '0'; for (j = 0; j < 8; j++) if (value[3] & 1 << j) msg[8-j] = '1'; else msg[8-j] = '0'; OptoIn->Caption = msg; } //--------------------------------------------------------------------------- void __fastcall TMainForm::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); } } //---------------------------------------------------------------------------