// sample1Dlg.cpp : implementation file // #include "stdafx.h" #include "sample1.h" #include "sample1Dlg.h" #include #include "AIOWDM.h" //WDM Driver #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define PI 3.141593 #define SLIDER 1 #define TIMER_DELAY 200 //Global card interface function prototypes: int ReadChanData_7766(int chan); void Init_7766(int CardNum); //void resetCount_7766(int channel); ///////////////////////////////////////////////////////////////////////////// // CSample1Dlg dialog CSample1Dlg::CSample1Dlg(CWnd* pParent /*=NULL*/) : CDialog(CSample1Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CSample1Dlg) m_currentRPM0 = _T(""); m_currentRPM1 = _T(""); m_currentRPM2 = _T(""); m_currentRPM3 = _T(""); m_currentRPM4 = _T(""); m_currentRPM5 = _T(""); m_currentRPM6 = _T(""); m_currentRPM7 = _T(""); m_maxRpmBarLabel0 = _T(""); m_maxRpmBarLabel1 = _T(""); m_maxRpmBarLabel2 = _T(""); m_maxRpmBarLabel3 = _T(""); m_maxRpmBarLabel4 = _T(""); m_maxRpmBarLabel5 = _T(""); m_maxRpmBarLabel6 = _T(""); m_maxRpmBarLabel7 = _T(""); m_sliderLabel0 = _T(""); m_sliderLabel1 = _T(""); m_sliderLabel2 = _T(""); m_sliderLabel3 = _T(""); m_sliderLabel4 = _T(""); m_sliderLabel5 = _T(""); m_sliderLabel6 = _T(""); m_sliderLabel7 = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); //It is possible to write arrays of controls in VC6, but it must be done entirely by hand //and breaks the Class Wizard when it is done. So, we will just stuff all the member variables //into the proper arrays. progressBars[0] = &m_bar0; progressBars[1] = &m_bar1; progressBars[2] = &m_bar2; progressBars[3] = &m_bar3; progressBars[4] = &m_bar4; progressBars[5] = &m_bar5; progressBars[6] = &m_bar6; progressBars[7] = &m_bar7; currentRPMs[0] = &m_currentRPM0; currentRPMs[1] = &m_currentRPM1; currentRPMs[2] = &m_currentRPM2; currentRPMs[3] = &m_currentRPM3; currentRPMs[4] = &m_currentRPM4; currentRPMs[5] = &m_currentRPM5; currentRPMs[6] = &m_currentRPM6; currentRPMs[7] = &m_currentRPM7; maxRPMs[0] = &m_maxRpmBarLabel0; maxRPMs[1] = &m_maxRpmBarLabel1; maxRPMs[2] = &m_maxRpmBarLabel2; maxRPMs[3] = &m_maxRpmBarLabel3; maxRPMs[4] = &m_maxRpmBarLabel4; maxRPMs[5] = &m_maxRpmBarLabel5; maxRPMs[6] = &m_maxRpmBarLabel6; maxRPMs[7] = &m_maxRpmBarLabel7; paintBoxes[0] = &m_paintBox0; paintBoxes[1] = &m_paintBox1; paintBoxes[2] = &m_paintBox2; paintBoxes[3] = &m_paintBox3; paintBoxes[4] = &m_paintBox4; paintBoxes[5] = &m_paintBox5; paintBoxes[6] = &m_paintBox6; paintBoxes[7] = &m_paintBox7; readings[0] = &m_reading0; readings[1] = &m_reading1; readings[2] = &m_reading2; readings[3] = &m_reading3; readings[4] = &m_reading4; readings[5] = &m_reading5; readings[6] = &m_reading6; readings[7] = &m_reading7; resolutions[0] = &m_resolution0; resolutions[1] = &m_resolution1; resolutions[2] = &m_resolution2; resolutions[3] = &m_resolution3; resolutions[4] = &m_resolution4; resolutions[5] = &m_resolution5; resolutions[6] = &m_resolution6; resolutions[7] = &m_resolution7; resetBtns[0] = &m_rst0; resetBtns[1] = &m_rst1; resetBtns[2] = &m_rst2; resetBtns[3] = &m_rst3; resetBtns[4] = &m_rst4; resetBtns[5] = &m_rst5; resetBtns[6] = &m_rst6; resetBtns[7] = &m_rst7; setBtns[0] = &m_set0; setBtns[1] = &m_set1; setBtns[2] = &m_set2; setBtns[3] = &m_set3; setBtns[4] = &m_set4; setBtns[5] = &m_set5; setBtns[6] = &m_set6; setBtns[7] = &m_set7; sliders[0] = &m_slider0; sliders[1] = &m_slider1; sliders[2] = &m_slider2; sliders[3] = &m_slider3; sliders[4] = &m_slider4; sliders[5] = &m_slider5; sliders[6] = &m_slider6; sliders[7] = &m_slider7; sliderLabels[0] = &m_sliderLabel0; sliderLabels[1] = &m_sliderLabel1; sliderLabels[2] = &m_sliderLabel2; sliderLabels[3] = &m_sliderLabel3; sliderLabels[4] = &m_sliderLabel4; sliderLabels[5] = &m_sliderLabel5; sliderLabels[6] = &m_sliderLabel6; sliderLabels[7] = &m_sliderLabel7; timerRunning = false; m_CardName = _T(""); m_StatusString = _T(""); } void CSample1Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSample1Dlg) DDX_Control(pDX, IDC_SET7, m_set7); DDX_Control(pDX, IDC_SET6, m_set6); DDX_Control(pDX, IDC_SET5, m_set5); DDX_Control(pDX, IDC_SET4, m_set4); DDX_Control(pDX, IDC_SET3, m_set3); DDX_Control(pDX, IDC_SET2, m_set2); DDX_Control(pDX, IDC_SET1, m_set1); DDX_Control(pDX, IDC_SET0, m_set0); DDX_Control(pDX, IDC_RPM_SLIDER7, m_slider7); DDX_Control(pDX, IDC_RPM_SLIDER6, m_slider6); DDX_Control(pDX, IDC_RPM_SLIDER5, m_slider5); DDX_Control(pDX, IDC_RPM_SLIDER4, m_slider4); DDX_Control(pDX, IDC_RPM_SLIDER3, m_slider3); DDX_Control(pDX, IDC_RPM_SLIDER2, m_slider2); DDX_Control(pDX, IDC_RPM_SLIDER1, m_slider1); DDX_Control(pDX, IDC_RPM_SLIDER0, m_slider0); DDX_Control(pDX, IDC_RPM_BAR7, m_bar7); DDX_Control(pDX, IDC_RPM_BAR6, m_bar6); DDX_Control(pDX, IDC_RPM_BAR5, m_bar5); DDX_Control(pDX, IDC_RPM_BAR4, m_bar4); DDX_Control(pDX, IDC_RPM_BAR3, m_bar3); DDX_Control(pDX, IDC_RPM_BAR2, m_bar2); DDX_Control(pDX, IDC_RPM_BAR1, m_bar1); DDX_Control(pDX, IDC_RPM_BAR0, m_bar0); DDX_Control(pDX, IDC_RESOLUTION7, m_resolution7); DDX_Control(pDX, IDC_RESOLUTION6, m_resolution6); DDX_Control(pDX, IDC_RESOLUTION5, m_resolution5); DDX_Control(pDX, IDC_RESOLUTION4, m_resolution4); DDX_Control(pDX, IDC_RESOLUTION3, m_resolution3); DDX_Control(pDX, IDC_RESOLUTION2, m_resolution2); DDX_Control(pDX, IDC_RESOLUTION1, m_resolution1); DDX_Control(pDX, IDC_RESOLUTION0, m_resolution0); DDX_Control(pDX, IDC_RESET7, m_rst7); DDX_Control(pDX, IDC_RESET6, m_rst6); DDX_Control(pDX, IDC_RESET5, m_rst5); DDX_Control(pDX, IDC_RESET4, m_rst4); DDX_Control(pDX, IDC_RESET3, m_rst3); DDX_Control(pDX, IDC_RESET2, m_rst2); DDX_Control(pDX, IDC_RESET1, m_rst1); DDX_Control(pDX, IDC_RESET0, m_rst0); DDX_Control(pDX, IDC_READING7, m_reading7); DDX_Control(pDX, IDC_READING6, m_reading6); DDX_Control(pDX, IDC_READING5, m_reading5); DDX_Control(pDX, IDC_READING4, m_reading4); DDX_Control(pDX, IDC_READING3, m_reading3); DDX_Control(pDX, IDC_READING2, m_reading2); DDX_Control(pDX, IDC_READING1, m_reading1); DDX_Control(pDX, IDC_READING0, m_reading0); DDX_Control(pDX, IDC_PAINT_BOX7, m_paintBox7); DDX_Control(pDX, IDC_PAINT_BOX6, m_paintBox6); DDX_Control(pDX, IDC_PAINT_BOX5, m_paintBox5); DDX_Control(pDX, IDC_PAINT_BOX4, m_paintBox4); DDX_Control(pDX, IDC_PAINT_BOX3, m_paintBox3); DDX_Control(pDX, IDC_PAINT_BOX2, m_paintBox2); DDX_Control(pDX, IDC_PAINT_BOX1, m_paintBox1); DDX_Control(pDX, IDC_PAINT_BOX0, m_paintBox0); DDX_Control(pDX, IDC_INIT_BTN, m_initBtn); DDX_Control(pDX, IDC_GO_BTN, m_goBtn); // DDX_Control(pDX, IDC_ADDR, m_addr); DDX_Text(pDX, IDC_CURRENT_RPM0, m_currentRPM0); DDX_Text(pDX, IDC_CURRENT_RPM1, m_currentRPM1); DDX_Text(pDX, IDC_CURRENT_RPM2, m_currentRPM2); DDX_Text(pDX, IDC_CURRENT_RPM3, m_currentRPM3); DDX_Text(pDX, IDC_CURRENT_RPM4, m_currentRPM4); DDX_Text(pDX, IDC_CURRENT_RPM5, m_currentRPM5); DDX_Text(pDX, IDC_CURRENT_RPM6, m_currentRPM6); DDX_Text(pDX, IDC_CURRENT_RPM7, m_currentRPM7); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL0, m_maxRpmBarLabel0); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL1, m_maxRpmBarLabel1); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL2, m_maxRpmBarLabel2); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL3, m_maxRpmBarLabel3); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL4, m_maxRpmBarLabel4); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL5, m_maxRpmBarLabel5); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL6, m_maxRpmBarLabel6); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL7, m_maxRpmBarLabel7); DDX_Text(pDX, IDC_SLIDER_LABEL0, m_sliderLabel0); DDX_Text(pDX, IDC_SLIDER_LABEL1, m_sliderLabel1); DDX_Text(pDX, IDC_SLIDER_LABEL2, m_sliderLabel2); DDX_Text(pDX, IDC_SLIDER_LABEL3, m_sliderLabel3); DDX_Text(pDX, IDC_SLIDER_LABEL4, m_sliderLabel4); DDX_Text(pDX, IDC_SLIDER_LABEL5, m_sliderLabel5); DDX_Text(pDX, IDC_SLIDER_LABEL6, m_sliderLabel6); DDX_Text(pDX, IDC_SLIDER_LABEL7, m_sliderLabel7); //}}AFX_DATA_MAP // DDX_Control(pDX, IDC_EDIT_STATUS, m_StatusEdit); DDX_Text(pDX, IDC_STATIC_CARD_NAME, m_CardName); DDX_Control(pDX, IDC_EDIT_STATUS, m_StatusControl); DDX_Text(pDX, IDC_EDIT_STATUS, m_StatusString); } BEGIN_MESSAGE_MAP(CSample1Dlg, CDialog) //{{AFX_MSG_MAP(CSample1Dlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_INIT_BTN, OnInitBtn) ON_BN_CLICKED(IDC_GO_BTN, OnGoBtn) ON_WM_TIMER() ON_BN_CLICKED(IDC_SET0, OnSet0) ON_BN_CLICKED(IDC_SET1, OnSet1) ON_BN_CLICKED(IDC_SET2, OnSet2) ON_BN_CLICKED(IDC_SET3, OnSet3) ON_BN_CLICKED(IDC_SET4, OnSet4) ON_BN_CLICKED(IDC_SET5, OnSet5) ON_BN_CLICKED(IDC_SET6, OnSet6) ON_BN_CLICKED(IDC_SET7, OnSet7) ON_BN_CLICKED(IDC_RESET0, OnReset0) ON_BN_CLICKED(IDC_RESET1, OnReset1) ON_BN_CLICKED(IDC_RESET2, OnReset2) ON_BN_CLICKED(IDC_RESET3, OnReset3) ON_BN_CLICKED(IDC_RESET4, OnReset4) ON_BN_CLICKED(IDC_RESET5, OnReset5) ON_BN_CLICKED(IDC_RESET6, OnReset6) ON_BN_CLICKED(IDC_RESET7, OnReset7) //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON_REVERSE, &CSample1Dlg::OnBnClickedButtonReverse) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSample1Dlg message handlers BOOL CSample1Dlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here for(int i = 0; i < 8; i++ ) { directionFlag[i] = false; // init flag to match check box state } m_goBtn.EnableWindow(false); for (int count = 0; count < 8; count++) { resetBtns[count]->EnableWindow(false); setBtns[count]->EnableWindow(false); resolutions[count]->SetWindowText("300"); sliders[count]->SetTicFreq(5); sliders[count]->SetPos(20); sliders[count] -> SetRange(1, 150, false); *sliderLabels[count] = "20"; *maxRPMs[count] = "20"; *currentRPMs[count] = "-"; readings[count]->SetWindowText("0"); previous_readings[count] = currentReadings[count] = 0; progressBars[count] -> SetRange(0, 20); currentRes[count] = 300; } // Ping the driver AIOWDM.SYS: if (InPortB(0x61) == 0xAA55) { AfxMessageBox(_T("AIOWDM.SYS not detected.\n Please copy AIOWDM.SYS into [Windows]/system32/drivers and re-run this sample.\n Ensure that a board is installed properly.")); } FindCardsWDM(); m_StatusString = _T("This sample reads and displays data from up to 8 quadrature encoder channels."); UpdateData(false); return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CSample1Dlg::OnPaint() { for (int count = 0; count < 8; count++) doPaintBox(count); if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CSample1Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } BOOL CSample1Dlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { // TODO: Add your specialized code here and/or call the base class int controlType; int controlIndex; switch (wParam) //it's nice to know some things haven't changed since Windows 3.11 { case IDC_RPM_SLIDER0: controlIndex = 0; controlType = SLIDER; break; case IDC_RPM_SLIDER1: controlIndex = 1; controlType = SLIDER; break; case IDC_RPM_SLIDER2: controlIndex = 2; controlType = SLIDER; break; case IDC_RPM_SLIDER3: controlIndex = 3; controlType = SLIDER; break; case IDC_RPM_SLIDER4: controlIndex = 4; controlType = SLIDER; break; case IDC_RPM_SLIDER5: controlIndex = 5; controlType = SLIDER; break; case IDC_RPM_SLIDER6: controlIndex = 6; controlType = SLIDER; break; case IDC_RPM_SLIDER7: controlIndex = 7; controlType = SLIDER; break; } switch (controlType) { case SLIDER: UpdateData(true); sliderLabels[controlIndex]->Format("%d", sliders[controlIndex]->GetPos()); maxRPMs[controlIndex]-> Format("%d", sliders[controlIndex]->GetPos()); progressBars[controlIndex] -> SetRange(0, sliders[controlIndex] -> GetPos()); UpdateData(false); break; } return CDialog::OnNotify(wParam, lParam, pResult); } void CSample1Dlg::OnInitBtn() { UpdateData(true); Init_7766(CardNum); // Init board and chip for acquisition m_initBtn.EnableWindow(false); m_goBtn.EnableWindow(true); UpdateData(false); } void CSample1Dlg::OnGoBtn() { CString displayString; if (timerRunning == false) { // init data collection start timer: for (int count = 0; count < 8; count++) { setBtns[count]->EnableWindow(true); resetBtns[count]->EnableWindow(true); previous_readings[count] = ReadChanData_7766(count); currentReadings[count] = previous_readings[count]; displayString.Format("%d", previous_readings[count]); readings[count]->SetWindowText(displayString); } m_goBtn.SetWindowText("Stop"); timerRunning = true; SetTimer(0, TIMER_DELAY, NULL); } else { KillTimer(0); timerRunning = false; m_goBtn.SetWindowText("Go"); // reenable init: m_initBtn.EnableWindow(true); } } void CSample1Dlg::OnTimer(UINT nIDEvent) { // Read data update UI if needed: bool change = false; CString readString; UpdateData(true); for (int count = 0; count < 8; count++) { RelOutPortB(0,Offset + 6 + (count * 8) , 0x04); // load ODR from CNTR // dont need this for some mode(s) see Spec previous_readings[count] = currentReadings[count]; currentReadings[count] = ReadChanData_7766(count); if (currentReadings[count] != previous_readings[count]) { change = true; readString.Format("%d", currentReadings[count]); readings[count]->SetWindowText(readString); } } if (change == true) Invalidate(false); CDialog::OnTimer(nIDEvent); } void CSample1Dlg::Init_7766(int CardNum) { UpdateData(true); // See spec for control register options etc // MCR0 and MCR1 == 0xA001 == 1010 000 000 0001 == MCR1 B7........MCR0 B0 // Init all 8 channels the same way for free running count mode acquisition: for(int count = 0; count < 8; count++) { //RelOutPort(CardNum, Offset + 0 + (count * 8), 0xA821); // init PCI board mode see spec (reset CNTR at index) RelOutPort(CardNum, Offset + 0 + (count * 8), 0xA001); // init PCI board mode see spec (reset CNTR at index) RelOutPortB(CardNum, Offset + 7 + (count * 8), 0x01); // swap inA and inB reverse direction value: (optional) (CPLD) RelOutPortB(CardNum, Offset + 6 + (count * 8) , 0x09); // reset all flags and counters } // for the loop in this mode not needed for other mode setup //RelOutPortB(CardNum, Offset + 6 + (count * 8) , 0x04); // load ODR from CNTR // Another optional test setting for sigle rotation index pulse: /* for(int count = 0; count < 8; count++) { RelOutPort(CardNum, Offset + 0 + (count * 8) , 0xA431); // init PCI board mode see spec (load ODR at index) RelOutPort(CardNum, Offset + 2 + (count * 8) , 0x1fff); // set IDR LSWord RelOutPort(CardNum, Offset + 4 + (count * 8) , 0x0000); // set IDR MSWord RelOutPortB(CardNum, Offset + 7 + (count * 8) , 0x02); RelOutPortB(CardNum, Offset + 6 + (count * 8) , 0x09); // reset all flags and counters } */ } void CSample1Dlg::resetCount_7766(int channel) { // See spec for control register options // Reset the counters for one channel: RelOutPortB(CardNum, Offset + 6 + (channel * 8), 0x09); // reset all flags and counters } int CSample1Dlg::ReadChanData_7766(int chan) { // See spec for control register options // The Channel data starts at base address offset 0x02 // See the LS7766 spec int data = 0; RelOutPortB(CardNum, Offset + 6 + (chan * 8), 0x04); // load ODR from CNTR // Read up to 8 channels 32 bits per channel: unsigned int baseOffset = 0x02; unsigned int chanOffset = chan * 0x08; data = RelInPortL(CardNum, (Offset + baseOffset + chanOffset) ); return data; } void CSample1Dlg::OnBnClickedButtonReverse() { // Reverse all channels however you can also reverse individual channels: // Note: this is for demo purposes you probably should only do this on startup initialization UpdateData(true); for(int count = 0; count < 8; count++) { if(directionFlag[count]) { RelOutPortB(CardNum, Offset + 7 + (count * 8) , 0x01); // swap inA and inB reverse direction (optional) directionFlag[count] = false; } else { RelOutPortB(CardNum, Offset + 7 + (count * 8) , 0x00); // swap inA and inB reverse direction (optional) directionFlag[count] = true; } } UpdateData(false); } void CSample1Dlg::doPaintBox(int channel) { CDC *pDC; CBrush pBrush; CPen pPen; double rpm, angle; int maxRpm, resolution, mult; CString resString; pDC = paintBoxes[channel]->GetDC(); // Must release this later or eventually it will return NULL (4 max) if(pDC == NULL) { return; } maxRpm = sliders[channel]->GetPos(); resolution = currentRes[channel]; mult = 0; // The board supports x1 x2 x4 switch (mult) { case 0: mult = 1; break; case 1: mult = 2; break; case 2: mult = 4; break; }; rpm = currentReadings[channel] - previous_readings[channel]; rpm = rpm / (resolution * mult); rpm = rpm * 60 / (TIMER_DELAY * .001); rpm = fabs(rpm); if (rpm != 0) { currentRPMs[channel]->Format("%.2f", rpm); } else { currentRPMs[channel]->Format("-"); } progressBars[channel]->SetPos(rpm); if (rpm >= maxRpm) { pBrush.CreateSolidBrush(RGB(0xFF, 0, 0)); } else { pBrush.CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF)); } pDC->SelectObject(&pBrush); // Will throw exception if pDC is NULL pDC->SelectStockObject(BLACK_PEN); pDC->Ellipse(5, 5, 85, 85); pDC->MoveTo(45, 45); pDC->LineTo (45, 85); pDC->MoveTo(45, 45); angle = currentReadings[channel]; angle = 2 * angle * PI; angle = angle / (resolution * mult) - 0.5 * PI; pPen.CreatePen(PS_SOLID, 0, RGB(0, 0xFF, 0)); pDC->SelectObject(&pPen); pDC->LineTo(45 - 40 * cos(angle), 45 - 40 * sin(angle)); ReleaseDC(pDC); // Must release DC and its resources after use or else (4 max DC's) pDC = NULL; UpdateData(false); } void CSample1Dlg::changeResolution(int channel) { CString resString; char *buf; int newRes; resolutions[channel]->GetWindowText(resString); buf = resString.GetBuffer(0); sscanf_s(buf, "%d", &newRes); resString.ReleaseBuffer(-1); if (newRes > 0) currentRes[channel] = newRes; else { resString.Format("%d", currentRes[channel]); resolutions[channel]->SetWindowText(resString); } } void CSample1Dlg::OnSet0() { changeResolution(0); } void CSample1Dlg::OnSet1() { changeResolution(1); } void CSample1Dlg::OnSet2() { changeResolution(2); } void CSample1Dlg::OnSet3() { changeResolution(3); } void CSample1Dlg::OnSet4() { changeResolution(4); } void CSample1Dlg::OnSet5() { changeResolution(5); } void CSample1Dlg::OnSet6() { changeResolution(6); } void CSample1Dlg::OnSet7() { changeResolution(7); } void CSample1Dlg::OnReset0() { resetCount_7766(0); } void CSample1Dlg::OnReset1() { resetCount_7766(1); } void CSample1Dlg::OnReset2() { resetCount_7766(2); } void CSample1Dlg::OnReset3() { resetCount_7766(3); } void CSample1Dlg::OnReset4() { resetCount_7766(4); } void CSample1Dlg::OnReset5() { resetCount_7766(5); } void CSample1Dlg::OnReset6() { resetCount_7766(6); } void CSample1Dlg::OnReset7() { resetCount_7766(7); } void CSample1Dlg::FindCardsWDM(void) { bool found = false; // Vars for QueryCardInfo() : unsigned long DeviceID, Base; unsigned long NameSize; UCHAR Name[256]; CString strname; // Init: RunFlag = true; NumCards = 0; CardNum = 0; // 0 is the first card found int DataIndex = 0; Offset =0; // Set CardData to 0 as needed: CardData.IsValid = false; CardData.IsSelected = false; CardData.DeviceID = 0; CardData.Base = 0; // Get the total number of cards installed: NumCards = GetNumCards(); if (NumCards == 0) // no cards present { m_CardName = "No Card Found"; m_StatusString = "No cards were found!"; m_StatusString += "This may mean the card is not installed. "; m_StatusString += "Check Device Manager for a card and its status"; m_StatusString += "You may consider rebooting your system."; m_StatusControl.LineScroll(999); RunFlag = false; } else { // validate and store card data: NameSize = 256; QueryCardInfo(CardNum, &DeviceID, &Base, &NameSize, Name); // only need to do this once: CardData.DeviceID = DeviceID; CardData.Base = Base; CardData.IsValid = true; // Populate list box with addresses found set flags: switch (DeviceID) { case 0x2230: // PCI-QUAD-8 m_CardName = Name; found = true; break; default: m_CardName = Name; //temp break; }//end switch }//end else card present // If card(s) are present but no valid cards were found: if ((NumCards != 0) && (found == false) ) { m_CardName = "No Valid Card Found."; m_StatusString = "No valid card was found!"; m_StatusString += "This may mean the card is not installed. "; m_StatusString += "Check Device Manager for a card and its status"; m_StatusString += "You may consider rebooting your system."; m_StatusControl.LineScroll(999); RunFlag = false; } UpdateData(false); if (RunFlag) { UpdateData(true); // This is the result setting the active address offset to be used: Offset = 0; //default to fist valid CardData.IsSelected = true; } }