리크 테스트 gui
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
6.1 KiB

// SDK9524GPTCDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SDK9524GPTC.h"
#include "SDK9524GPTCDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define TIMEBASE 40000000.0
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CSDK9524GPTCDlg dialog
CSDK9524GPTCDlg::CSDK9524GPTCDlg(I16 hCard, CWnd* pParent /*=NULL*/)
: CDialog(CSDK9524GPTCDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bRunning1 = 0;
m_wPolCtrl = 0;
m_hCard = hCard;
m_dwLReg1_Val = 2000000;
m_dwLReg2_Val = 2000000;
m_dwPulseGenNum = 1000;
m_GPTCMode = P9524_PulseGen_CCW;
}
void CSDK9524GPTCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_GPTC, m_cbGPTCNo);
DDX_Control(pDX, IDC_COMBO_MODE1, m_cbMode1Option);
}
BEGIN_MESSAGE_MAP(CSDK9524GPTCDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_CBN_SELCHANGE(IDC_COMBO_GPTC, &CSDK9524GPTCDlg::OnGPTCNoSelchange)
ON_CBN_SELCHANGE(IDC_COMBO_MODE1, &CSDK9524GPTCDlg::OnComboMode1Selchange)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BT_MODE1, &CSDK9524GPTCDlg::OnStart)
END_MESSAGE_MAP()
// CSDK9524GPTCDlg message handlers
BOOL CSDK9524GPTCDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
m_wGPTCNo = 0;
m_cbGPTCNo.SetCurSel( (int) m_wGPTCNo );
m_cbMode1Option.SetCurSel( 3 );
SetDlgItemInt( IDC_EDIT_GPTC_REG1, (UINT)m_dwLReg1_Val );
SetDlgItemInt( IDC_EDIT_GPTC_REG2, (UINT)m_dwLReg2_Val );
SetDlgItemInt( IDC_EDIT_PULSE_NUM, (UINT)m_dwPulseGenNum );
return TRUE; // return TRUE unless you set the focus to a control
}
void CSDK9524GPTCDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CSDK9524GPTCDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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 function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSDK9524GPTCDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CSDK9524GPTCDlg::OnGPTCNoSelchange()
{
// TODO: Add your control notification handler code here
int nIndex;
nIndex = m_cbGPTCNo.GetCurSel();
switch( nIndex )
{
case 0:
m_wGPTCNo = 0;
break;
case 1:
m_wGPTCNo = 1;
break;
case 2:
m_wGPTCNo = 2;
break;
}
}
void CSDK9524GPTCDlg::OnComboMode1Selchange()
{
// TODO: Add your control notification handler code here
int nIndex;
nIndex = m_cbMode1Option.GetCurSel();
switch( nIndex )
{
case 0:
m_GPTCMode = P9524_PulseGen_OUTDIR_N;
break;
case 1:
m_GPTCMode = P9524_PulseGen_OUTDIR_R;
break;
case 2:
m_GPTCMode = P9524_PulseGen_CW;
break;
case 3:
m_GPTCMode = P9524_PulseGen_CCW;
break;
}
m_wSrcCtrl = GPTC_GATE_SRC_Ext; //Set External gate for measuring a pulse from GATED pin
}
void CSDK9524GPTCDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
}
void CSDK9524GPTCDlg::OnStart()
{
// TODO: Add your control notification handler code here
I16 err;
CString strTmp;
if( m_bRunning1 == 1 )
{
err = GPTC_Control(m_hCard, m_wGPTCNo, P9524_CTR_Enable, 0);
err = GPTC_Clear(m_hCard, m_wGPTCNo);
m_bRunning1 = 0;
SetDlgItemText( IDC_BT_MODE1, TEXT("Start") );
}
else
{
m_dwPulseGenNum = GetDlgItemInt( IDC_EDIT_PULSE_NUM );
m_dwLReg1_Val = GetDlgItemInt( IDC_EDIT_GPTC_REG1 );
m_dwLReg2_Val = GetDlgItemInt( IDC_EDIT_GPTC_REG2 );
strTmp.Format( TEXT("Generates %d pulse in %f HZ"), m_dwPulseGenNum, TIMEBASE/(m_dwLReg1_Val+m_dwLReg2_Val) );
SetDlgItemText( IDC_STATIC_INFO, strTmp );
/*Setup GPTC*/
err = GPTC_Setup(m_hCard, m_wGPTCNo, m_GPTCMode, 0, 0, m_dwLReg1_Val, m_dwLReg2_Val);
if(err<0)
{
strTmp.Format( TEXT("GPTC_Setup Error: %d"), err );
AfxMessageBox( strTmp );
return;
}
err = GPTC_9524_PG_Config(m_hCard, m_wGPTCNo, m_dwPulseGenNum);
if(err<0)
{
strTmp.Format( TEXT("GPTC_9524_PG_Config Error: %d"), err );
AfxMessageBox( strTmp );
return;
}
err = GPTC_Control(m_hCard, m_wGPTCNo, P9524_CTR_Enable, 1);
if(err<0)
{
strTmp.Format( TEXT("GPTC_Control Error: %d"), err );
AfxMessageBox( strTmp );
return;
}
m_bRunning1 = 1;
SetDlgItemText( IDC_BT_MODE1, TEXT("Stop") );
}
}