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

📄 instrumentdlg.cpp

📁 这个是无线网卡WirelessLAN 测试程序NDIS
💻 CPP
字号:
// InstrumentDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ZDUSBMP_DUT.h"
#include "InstrumentDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CInstrumentDlg dialog


CInstrumentDlg::CInstrumentDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInstrumentDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInstrumentDlg)
	m_GPIB = _T("");
	m_SA = _T("");
	m_GPIB_Radio = 0;
	//}}AFX_DATA_INIT
}


void CInstrumentDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInstrumentDlg)
	DDX_Control(pDX, IDC_LIST1, m_TestResult);
	DDX_Text(pDX, IDC_GPIB_EDIT, m_GPIB);
	DDV_MaxChars(pDX, m_GPIB, 2);
	DDX_Text(pDX, IDC_SA_EDIT, m_SA);
	DDV_MaxChars(pDX, m_SA, 2);
	DDX_Radio(pDX, IDC_GPIB_RADIO, m_GPIB_Radio);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInstrumentDlg, CDialog)
	//{{AFX_MSG_MAP(CInstrumentDlg)
	ON_BN_CLICKED(IDC_GPIB_RADIO, OnGpibRadio)
	ON_BN_CLICKED(IDC_TEST_BUTTON, OnTestButton)
	ON_BN_CLICKED(IDC_RADIO2, OnGpibRadio)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInstrumentDlg message handlers

void CInstrumentDlg::OnGpibRadio() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);

	pParent->mGPIBCtrl.SetIFace(m_GPIB_Radio);
}

BOOL CInstrumentDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

	m_GPIB_Radio = pParent->mGPIBCtrl.GetIFace();
	m_GPIB.Format("%d", pParent->mGPIBCtrl.GetGPIB());
	m_SA.Format("%d", pParent->mGPIBCtrl.GetSA());

	bRun = FALSE;

	UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CInstrumentDlg::OnTestButton() 
{
	int i;

	// TODO: Add your control notification handler code here
	UpdateData(true);

	if(bRun) return;

	pParent->bInstrumentPresent = FALSE;
	bRun = true;

	m_TestResult.AddString("---------------------------------------");
	m_TestResult.AddString("Detecting...");

	for (i=0; i<m_GPIB.GetLength(); i++){
		if( (m_GPIB.GetAt(i) > '9') || (m_GPIB.GetAt(i) < '0') ){
			m_TestResult.AddString("The GPIB value is invalid!!!");
			return;
		}
	}
	for (i=0; i<m_SA.GetLength(); i++){
		if( (m_SA.GetAt(i) > '9') || (m_SA.GetAt(i) < '0') ){
			m_TestResult.AddString("The SA address is invalid!!!");
			return;
		}
	}

	pParent->mGPIBCtrl.SetGPIB(strtol(m_GPIB, NULL, 10));
	pParent->mGPIBCtrl.SetSA(strtol(m_SA, NULL, 10));

	if (!pParent->mGPIBCtrl.CheckInstrument()){
		m_TestResult.AddString("Can't find instrument for test!!!");
	}else{
		pParent->bInstrumentPresent = true;
		m_TestResult.AddString("Finding");
	}

	bRun = FALSE;
}

void CInstrumentDlg::OnOK() 
{
	// TODO: Add extra validation here
	int i;

	UpdateData(true);

	if(bRun) return;

	for (i=0; i<m_GPIB.GetLength(); i++){
		if( (m_GPIB.GetAt(i) > '9') || (m_GPIB.GetAt(i) < '0') ){
			AfxMessageBox("The GPIB value is invalid!!!");
			return;
		}
	}
	for (i=0; i<m_SA.GetLength(); i++){
		if( (m_SA.GetAt(i) > '9') || (m_SA.GetAt(i) < '0') ){
			AfxMessageBox("The SA address is invalid!!!");
			return;
		}
	}
	
	pParent->mGPIBCtrl.SetGPIB(strtol(m_GPIB, NULL, 10));
	pParent->mGPIBCtrl.SetSA(strtol(m_SA, NULL, 10));

	//set process at idle
	pParent->ProcedureState = STATE_IDLE;

	CDialog::OnOK();
}

void CInstrumentDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	if(bRun) return;
	
	//set process at idle
	pParent->bInstrumentPresent = FALSE;
	pParent->ProcedureState = STATE_IDLE;

	CDialog::OnCancel();
}

⌨️ 快捷键说明

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