//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "COSThrd.h" #include "ACCES32.h" #include "Win32COS.h" #include "COSSAMPc.h" #pragma package(smart_init) __fastcall COSThread::COSThread(bool CreateSuspended) : TThread(CreateSuspended) { } //--------------------------------------------------------------------------- void __fastcall COSThread::UpdateIRQCaption(void) { Form1->CountLabel->Caption = "IRQ Count: " + IntToStr(Form1->IRQ_Count); Form1->DataLabel->Caption = IntToHex(Data[0], 2) + IntToHex(Data[1], 2) + IntToHex(Data[2], 2) + " " + IntToHex(Data[3], 2) + IntToHex(Data[4], 2) + IntToHex(Data[5], 2); } //--------------------------------------------------------------------------- void __fastcall COSThread::UpdateStatusCaption(void) { Form1->StatusLabel->Caption = "Waiting...Generate IRQs now"; } //--------------------------------------------------------------------------- void __fastcall COSThread::Execute() { bool IRQ_Occurred; unsigned long Base; sscanf(Form1->BaseEdit->Text.c_str(), "%lx", &Base); Synchronize(UpdateStatusCaption); // set all input OutPortB(Base + 0x03, 0x9B); OutPortB(Base + 0x07, 0x9B); // clear cos latch OutPortB(Base + 0x0f, 0); // enable cos interrupts OutPortB(Base + 0x0b, 0); Data[0] = 0; Data[1] = 0; Data[2] = 0; Data[3] = 0; Data[4] = 0; Data[5] = 0; do { IRQ_Occurred = GetCOSData(Data); if (IRQ_Occurred) { Form1->IRQ_Count++; Synchronize(UpdateIRQCaption); } } while (!Terminated); } //---------------------------------------------------------------------------