리크 테스트 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.
 
 
 
 
 
 

424 lines
8.4 KiB

// pci7250Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "pci7250.h"
#include "pci7250Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 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()
// Cpci7250Dlg dialog
Cpci7250Dlg::Cpci7250Dlg(I16 hCard, CWnd* pParent /*=NULL*/)
: CDialog(Cpci7250Dlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hCard = hCard;
m_dwOutData = 0x00;
m_nTimer = -1;
}
void Cpci7250Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ICON_DI0, m_DI0_ON);
DDX_Control(pDX, IDC_ICON_DI1, m_DI1_ON);
DDX_Control(pDX, IDC_ICON_DI2, m_DI2_ON);
DDX_Control(pDX, IDC_ICON_DI3, m_DI3_ON);
DDX_Control(pDX, IDC_ICON_DI4, m_DI4_ON);
DDX_Control(pDX, IDC_ICON_DI5, m_DI5_ON);
DDX_Control(pDX, IDC_ICON_DI6, m_DI6_ON);
DDX_Control(pDX, IDC_ICON_DI7, m_DI7_ON);
}
BEGIN_MESSAGE_MAP(Cpci7250Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_WM_TIMER()
ON_BN_CLICKED(IDC_CHECK_DO0, &Cpci7250Dlg::OnDO0Clicked)
ON_BN_CLICKED(IDC_CHECK_DO1, &Cpci7250Dlg::OnDO1Clicked)
ON_BN_CLICKED(IDC_CHECK_DO2, &Cpci7250Dlg::OnDO2Clicked)
ON_BN_CLICKED(IDC_CHECK_DO3, &Cpci7250Dlg::OnDO3Clicked)
ON_BN_CLICKED(IDC_CHECK_DO4, &Cpci7250Dlg::OnDO4Clicked)
ON_BN_CLICKED(IDC_CHECK_DO5, &Cpci7250Dlg::OnDO5Clicked)
ON_BN_CLICKED(IDC_CHECK_DO6, &Cpci7250Dlg::OnDO6Clicked)
ON_BN_CLICKED(IDC_CHECK_DO7, &Cpci7250Dlg::OnDO7Clicked)
ON_WM_DESTROY()
END_MESSAGE_MAP()
// Cpci7250Dlg message handlers
BOOL Cpci7250Dlg::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
m_nTimer = SetTimer( 1, 1000, NULL );
return TRUE; // return TRUE unless you set the focus to a control
}
void Cpci7250Dlg::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 Cpci7250Dlg::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 Cpci7250Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void Cpci7250Dlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
U32 dwPortData;
DI_ReadPort( m_hCard, 0, &dwPortData);
if( (dwPortData & 0x01) == 0x01 )
{
m_DI0_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI0_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x02) == 0x02 )
{
m_DI1_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI1_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x04) == 0x04 )
{
m_DI2_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI2_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x08) == 0x08 )
{
m_DI3_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI3_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x10) == 0x10 )
{
m_DI4_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI4_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x20) == 0x20 )
{
m_DI5_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI5_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x40) == 0x40 )
{
m_DI6_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI6_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
if( (dwPortData & 0x80) == 0x80 )
{
m_DI7_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_DI7_ON.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
CDialog::OnTimer(nIDEvent);
}
void Cpci7250Dlg::OnDO0Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO0 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x01;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x01);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO1Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO1 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x02;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x02);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO2Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO2 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x04;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x04);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO3Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO3 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x08;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x08);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO4Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO4 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x10;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x10);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO5Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO5 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x20;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x20);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO6Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO6 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x40;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x40);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDO7Clicked()
{
// TODO: Add your control notification handler code here
int CheckSts;
CheckSts = ((CButton*)GetDlgItem( IDC_CHECK_DO7 ))->GetCheck();
if( CheckSts == BST_CHECKED )
{
m_dwOutData |= 0x80;
}
else if( CheckSts == BST_UNCHECKED )
{
m_dwOutData &= (~0x80);
}
DO_WritePort( m_hCard, 0, m_dwOutData );
}
void Cpci7250Dlg::OnDestroy()
{
CDialog::OnDestroy();
if( m_nTimer != -1 )
KillTimer( m_nTimer );
// TODO: Add your message handler code here
}