// COSTHRD.cpp : implementation file // #include "stdafx.h" #include "COSSAMP.h" #include "COSTHRD.h" #include "CSSMPDlg.h" #include "ACCES32.h" #include "Win32COS.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCOSTHRD IMPLEMENT_DYNCREATE(CCOSTHRD, CWinThread) CCOSTHRD::CCOSTHRD() { } CCOSTHRD::~CCOSTHRD() { } BOOL CCOSTHRD::InitInstance() { // TODO: perform any per-thread initialization here return TRUE; } int CCOSTHRD::ExitInstance() { // TODO: perform any per-thread cleanup here return CWinThread::ExitInstance(); } BEGIN_MESSAGE_MAP(CCOSTHRD, CWinThread) //{{AFX_MSG_MAP(CCOSTHRD) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCOSTHRD message handlers int CCOSTHRD::Run() { bool IRQ_Occurred; unsigned long IRQCount = 0, Base; char text[255], temp[33]; unsigned char Buf[6]; ((CCOSSampDlg*)MainWnd)->m_StatusLabel = "Waiting...Generate IRQs now"; MainWnd->UpdateData(false); MainWnd->UpdateData(true); sscanf(((CCOSSampDlg*)MainWnd)->m_BaseAddress,"%lx",&Base); // 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); do { IRQ_Occurred = GetCOSData(Buf); if (IRQ_Occurred == true) { OutPortB(Base + 0x0f, 0); IRQCount++; sprintf(temp, "IRQ Count: %ld", IRQCount); ((CCOSSampDlg*)MainWnd)->m_IRQCount = temp; *text = 0; sprintf(temp, "%s", itoa(Buf[0],temp,16)); strcat(text, temp); sprintf(temp, "%s", itoa(Buf[1],temp,16)); strcat(text, temp); sprintf(temp, "%s", itoa(Buf[2],temp,16)); strcat(text, temp); strcat(text, " "); sprintf(temp, "%s", itoa(Buf[3],temp,16)); strcat(text, temp); sprintf(temp, "%s", itoa(Buf[4],temp,16)); strcat(text, temp); sprintf(temp, "%s", itoa(Buf[5],temp,16)); strcat(text, temp); int i=-1; while (text[++i] != 0) text[i] = toupper(text[i]); ((CCOSSampDlg*)MainWnd)->m_Data = text; MainWnd->UpdateData(false); } } while (!Terminated); return CWinThread::Run(); } void CCOSTHRD::InitWnd(HWND hWnd) { MainWnd = CWnd::FromHandlePermanent(hWnd); }