⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intcmdtab.cpp

📁 国半usbn9604芯片开发办的源码
💻 CPP
字号:
/*----------------------------------------------------------------------------
 *  Copyright (c) 2001 by National Semiconductor Corporation
 *  National Semiconductor Corporation
 *  2900 Semiconductor Drive
 *  Santa Clara, California 95051
 *
 *  All rights reserved
 *
 *<<<-------------------------------------------------------------------------
 * File Contents:
 *	intCmdTab.cppb - this class defines Interrupt test GUI tab. The Interrupt tests settings
 *					 are received from the user and are transfered to the IntFunc class.
 *
 *  Project: USB Demo Application
 *  Author : Yan Nosovitsky
 *  Date   : Dec 2001
 *----------------------------------------------------------------------->>>*/

// intCmdTab.cpp : implementation file
//

#include "stdafx.h"
#include "Demo.h"
#include "intCmdTab.h"
#include <afxtempl.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// intCmdTab dialog


intCmdTab::intCmdTab(CWnd* pParent /*=NULL*/)
	: CDialog(intCmdTab::IDD, pParent)
{
	//{{AFX_DATA_INIT(intCmdTab)
	//}}AFX_DATA_INIT

	intFunc = new IntFunc(this);
	isUnderTest = FALSE;
}


void intCmdTab::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(intCmdTab)
	DDX_Control(pDX, IDC_ARRIVED_INT, m_arrivedInt);
	DDX_Control(pDX, IDC_PROGRES_BAR, m_progresBar);
	DDX_Control(pDX, IDC_INTERVAL, m_interval);
	DDX_Control(pDX, IDC_INTERVAL_SLIDER, m_intervalSlider);
	DDX_Control(pDX, IDC_INT_NUM_EDIT, m_intNum);
	DDX_Control(pDX, IDC_INT_PIPES_LIST, m_pipesList);
	DDX_Control(pDX, IDC_DETAILS_BUTTON, m_buttonDet);
	DDX_Control(pDX, IDC_GO_BUTTON, m_buttonGo);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(intCmdTab, CDialog)
	//{{AFX_MSG_MAP(intCmdTab)
	ON_LBN_SELCHANGE(IDC_INT_PIPES_LIST, OnSelchangeIntPipesList)
	ON_BN_CLICKED(IDC_GO_BUTTON, OnGoButton)
	ON_BN_CLICKED(IDC_DETAILS_BUTTON, OnDetailsButton)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_INTERVAL_SLIDER, OnCustomdrawIntervalSlider)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void intCmdTab::UpdatePipes()
{
	int i;
	int numOfPipes =  intFunc->CheckPipes() ;


	if (!isUnderTest)
	{
		/* clean previous pipes and choise*/
		m_pipesList.ResetContent();
		for (i = 0; i < numOfPipes; i++)
			m_pipesList.AddString(intFunc->getPipeInfo(i));
	}
	else
	{
		/* restore previos choise */

	}
}
/////////////////////////////////////////////////////////////////////////////
// intCmdTab message handlers

void intCmdTab::OnSelchangeIntPipesList() 
{
	int num;
	CArray<int,int> selectedItems;

	num = m_pipesList.GetSelCount();

	selectedItems.SetSize(num);
	
	m_pipesList.GetSelItems(num,selectedItems.GetData());

	if (num == 1)
	{
		selPipe = selectedItems.GetAt(0);
	}
	
	if (num == 2)
	{
		selPipe = -1; /* Loopback test */
	}

	m_buttonGo.EnableWindow(TRUE);
	m_intNum.EnableWindow(TRUE);
	m_intervalSlider.EnableWindow(TRUE);
	m_buttonDet.EnableWindow(FALSE);

	
}

void intCmdTab::OnGoButton() 
{
	CString intNumStr;
	int	intNumber;

	m_intNum.GetWindowText(intNumStr);
	if (intNumStr.IsEmpty())
	{
		MessageBox("Interrupt number value is not specified.","Error",MB_ICONERROR | MB_OK);
		return;
	}
	
	sscanf(intNumStr.GetBuffer(intNumStr.GetLength()),"%d",&intNumber);
			
	if ((intNumber > 255)||(intNumber < 1))
	{
		MessageBox("Interrupt number must be an integer between 1 and 255.","Error",MB_ICONERROR | MB_OK);
		return;
	}
	m_arrivedInt.SetWindowText("0");
	m_progresBar.SetRange(0,intNumber);
	m_progresBar.SetPos(0);
	if (!intFunc->ProcessIntTest(intNumber, m_intervalSlider.GetPos() + 1,selPipe))
		return;
	m_buttonGo.EnableWindow(FALSE);
	m_buttonDet.EnableWindow(FALSE);
	m_pipesList.EnableWindow(FALSE);
	m_intervalSlider.EnableWindow(FALSE);
	isUnderTest = TRUE;	
}

void intCmdTab::OnDetailsButton() 
{
	MessageBox((LPCTSTR)intFunc->GetDetails(),"Interrupt Test",MB_ICONINFORMATION | MB_OK);	
}

void intCmdTab::processStoped()
{
//	m_buttonGo.SetWindowText("GO !");
	m_buttonGo.EnableWindow(TRUE);
	m_buttonDet.EnableWindow(TRUE);
	m_pipesList.EnableWindow(TRUE);
	m_intervalSlider.EnableWindow(TRUE);
	m_progresBar.SetPos(0);
	m_arrivedInt.SetWindowText(" ");
	isUnderTest = FALSE;
}





void intCmdTab::OnCustomdrawIntervalSlider(NMHDR* pNMHDR, LRESULT* pResult) 
{
	int pos = m_intervalSlider.GetPos();
	CString inter;
	inter.Format(_T("%d"),pos+1);
	m_interval.SetWindowText(inter);	
	*pResult = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -