//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TSample1Form *Sample1Form; //--------------------------------------------------------------------------- __fastcall TSample1Form::TSample1Form(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TSample1Form::ExitButtonClick(TObject *Sender) { exit(0); } //--------------------------------------------------------------------------- void __fastcall TSample1Form::TestButtonClick(TObject *Sender) { if (TestTimer->Enabled) { TestTimer->Enabled = false; BeginSample->Caption = "Abort Test"; } else { TestTimer->Enabled = true; BeginSample->Caption = "Start Test"; } } //--------------------------------------------------------------------------- void __fastcall TSample1Form::TestTimerTimer(TObject *Sender) { // Read the first 8 input channels of current port data = inportb(Address + ofs[2*port]); /* Check the status of each bit field and display result */ mask = 1; for (input = 0; input < 8; input++) { gotoxy(32,5+input); if (mask & data) printf("%3u%12s\n", input, " ON"); else printf("%3u%12s\n", input, "OFF"); mask <<= 1; } // end for // Read second 8 input channels for current port data = inportb(Address + ofs[(2*port)+1]); // Check the status of each bit field and display result mask = 1; for (input = 0; input < 8; input++) { gotoxy(32,13+input); if (mask & data) printf("%3u%12s\n", input+8, " ON"); else printf("%3u%12s\n", input+8, "OFF"); mask <<= 1; } // end for } // end TestTimerTimer //---------------------------------------------------------------------------