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

646 lines
15 KiB

// DIOOnePointDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DIOOnePoint.h"
#include "DIOOnePointDlg.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()
// CDIOOnePointDlg dialog
CDIOOnePointDlg::CDIOOnePointDlg(I16 hCard, CWnd* pParent /*=NULL*/)
: CDialog(CDIOOnePointDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hCard = hCard;
m_nTimer = -1;
m_dwInData = 0x00000000;
}
void CDIOOnePointDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_DI_PORT, m_cbPortDI);
DDX_Control(pDX, IDC_ICON_DI00, m_Icon_DI00);
DDX_Control(pDX, IDC_ICON_DI01, m_Icon_DI01);
DDX_Control(pDX, IDC_ICON_DI02, m_Icon_DI02);
DDX_Control(pDX, IDC_ICON_DI03, m_Icon_DI03);
DDX_Control(pDX, IDC_ICON_DI04, m_Icon_DI04);
DDX_Control(pDX, IDC_ICON_DI05, m_Icon_DI05);
DDX_Control(pDX, IDC_ICON_DI06, m_Icon_DI06);
DDX_Control(pDX, IDC_ICON_DI07, m_Icon_DI07);
DDX_Control(pDX, IDC_ICON_DI08, m_Icon_DI08);
DDX_Control(pDX, IDC_ICON_DI09, m_Icon_DI09);
DDX_Control(pDX, IDC_ICON_DI10, m_Icon_DI10);
DDX_Control(pDX, IDC_ICON_DI11, m_Icon_DI11);
DDX_Control(pDX, IDC_ICON_DI12, m_Icon_DI12);
DDX_Control(pDX, IDC_ICON_DI13, m_Icon_DI13);
DDX_Control(pDX, IDC_ICON_DI14, m_Icon_DI14);
DDX_Control(pDX, IDC_ICON_DI15, m_Icon_DI15);
DDX_Control(pDX, IDC_ICON_DI16, m_Icon_DI16);
DDX_Control(pDX, IDC_ICON_DI17, m_Icon_DI17);
DDX_Control(pDX, IDC_ICON_DI18, m_Icon_DI18);
DDX_Control(pDX, IDC_ICON_DI19, m_Icon_DI19);
DDX_Control(pDX, IDC_ICON_DI20, m_Icon_DI20);
DDX_Control(pDX, IDC_ICON_DI21, m_Icon_DI21);
DDX_Control(pDX, IDC_ICON_DI22, m_Icon_DI22);
DDX_Control(pDX, IDC_ICON_DI23, m_Icon_DI23);
DDX_Control(pDX, IDC_ICON_DI24, m_Icon_DI24);
DDX_Control(pDX, IDC_ICON_DI25, m_Icon_DI25);
DDX_Control(pDX, IDC_ICON_DI26, m_Icon_DI26);
DDX_Control(pDX, IDC_ICON_DI27, m_Icon_DI27);
DDX_Control(pDX, IDC_ICON_DI28, m_Icon_DI28);
DDX_Control(pDX, IDC_ICON_DI29, m_Icon_DI29);
DDX_Control(pDX, IDC_ICON_DI30, m_Icon_DI30);
DDX_Control(pDX, IDC_ICON_DI31, m_Icon_DI31);
}
BEGIN_MESSAGE_MAP(CDIOOnePointDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_WM_TIMER()
ON_WM_DESTROY()
ON_CBN_SELCHANGE(IDC_COMBO_DI_PORT, &CDIOOnePointDlg::OnDIPortSelchange)
END_MESSAGE_MAP()
// CDIOOnePointDlg message handlers
BOOL CDIOOnePointDlg::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_wInPort = P7443_CH0;
m_cbPortDI.SetCurSel( 0 );
m_nTimer = SetTimer( 1, 200, NULL );
return TRUE; // return TRUE unless you set the focus to a control
}
void CDIOOnePointDlg::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 CDIOOnePointDlg::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 CDIOOnePointDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CDIOOnePointDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
if( m_nTimer != -1 )
{
KillTimer( m_nTimer );
m_nTimer = -1;
}
}
void CDIOOnePointDlg::OnDIPortSelchange()
{
// TODO: Add your control notification handler code here
int nIndex;
nIndex = m_cbPortDI.GetCurSel();
switch( nIndex )
{
case 0:
m_wInPort = P7443_CH0;
break;
case 1:
m_wInPort = P7443_CH1;
break;
case 2:
m_wInPort = P7443_CH2;
break;
case 3:
m_wInPort = P7443_CH3;
break;
}
}
void CDIOOnePointDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
U32 dwPortData, dwChangeMask;
DI_ReadPort(m_hCard, m_wInPort ,&dwPortData);
dwChangeMask = dwPortData ^ m_dwInData;
if( dwChangeMask != 0x00 ) // Input had been changed
{
m_dwInData = dwPortData; // update the DI data
if( (dwChangeMask & 0x01) == 0x01 ) // if the target bit is changed
{
if( (dwPortData & 0x01) == 0x01 )
{
m_Icon_DI00.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI00.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x02) == 0x02 ) // if the target bit is changed
{
if( (dwPortData & 0x02) == 0x02 )
{
m_Icon_DI01.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI01.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x04) == 0x04 ) // if the target bit is changed
{
if( (dwPortData & 0x04) == 0x04 )
{
m_Icon_DI02.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI02.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x08) == 0x08 ) // if the target bit is changed
{
if( (dwPortData & 0x08) == 0x08 )
{
m_Icon_DI03.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI03.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x10) == 0x10 ) // if the target bit is changed
{
if( (dwPortData & 0x10) == 0x10 )
{
m_Icon_DI04.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI04.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x20) == 0x20 ) // if the target bit is changed
{
if( (dwPortData & 0x20) == 0x20 )
{
m_Icon_DI05.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI05.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x40) == 0x40 ) // if the target bit is changed
{
if( (dwPortData & 0x40) == 0x40 )
{
m_Icon_DI06.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI06.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x80) == 0x80 ) // if the target bit is changed
{
if( (dwPortData & 0x80) == 0x80 )
{
m_Icon_DI07.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI07.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x100) == 0x100 ) // if the target bit is changed
{
if( (dwPortData & 0x100) == 0x100 )
{
m_Icon_DI08.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI08.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x200) == 0x200 ) // if the target bit is changed
{
if( (dwPortData & 0x200) == 0x200 )
{
m_Icon_DI09.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI09.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x400) == 0x400 ) // if the target bit is changed
{
if( (dwPortData & 0x400) == 0x400 )
{
m_Icon_DI10.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI10.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x800) == 0x800 ) // if the target bit is changed
{
if( (dwPortData & 0x800) == 0x800 )
{
m_Icon_DI11.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI11.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x1000) == 0x1000 ) // if the target bit is changed
{
if( (dwPortData & 0x1000) == 0x1000 )
{
m_Icon_DI12.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI12.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x2000) == 0x2000 ) // if the target bit is changed
{
if( (dwPortData & 0x2000) == 0x2000 )
{
m_Icon_DI13.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI13.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x4000) == 0x4000 ) // if the target bit is changed
{
if( (dwPortData & 0x4000) == 0x4000 )
{
m_Icon_DI14.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI14.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x8000) == 0x8000 ) // if the target bit is changed
{
if( (dwPortData & 0x8000) == 0x8000 )
{
m_Icon_DI15.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI15.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x10000) == 0x10000 ) // if the target bit is changed
{
if( (dwPortData & 0x10000) == 0x10000 )
{
m_Icon_DI16.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI16.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x20000) == 0x20000 ) // if the target bit is changed
{
if( (dwPortData & 0x20000) == 0x20000 )
{
m_Icon_DI17.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI17.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x40000) == 0x40000 ) // if the target bit is changed
{
if( (dwPortData & 0x40000) == 0x40000 )
{
m_Icon_DI18.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI18.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x80000) == 0x80000 ) // if the target bit is changed
{
if( (dwPortData & 0x80000) == 0x80000 )
{
m_Icon_DI19.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI19.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x100000) == 0x100000 ) // if the target bit is changed
{
if( (dwPortData & 0x100000) == 0x100000 )
{
m_Icon_DI20.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI20.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x200000) == 0x200000 ) // if the target bit is changed
{
if( (dwPortData & 0x200000) == 0x200000 )
{
m_Icon_DI21.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI21.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x400000) == 0x400000 ) // if the target bit is changed
{
if( (dwPortData & 0x400000) == 0x400000 )
{
m_Icon_DI22.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI22.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x800000) == 0x800000 ) // if the target bit is changed
{
if( (dwPortData & 0x800000) == 0x800000 )
{
m_Icon_DI23.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI23.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x1000000) == 0x1000000 ) // if the target bit is changed
{
if( (dwPortData & 0x1000000) == 0x1000000 )
{
m_Icon_DI24.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI24.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x2000000) == 0x2000000 ) // if the target bit is changed
{
if( (dwPortData & 0x2000000) == 0x2000000 )
{
m_Icon_DI25.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI25.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x4000000) == 0x4000000 ) // if the target bit is changed
{
if( (dwPortData & 0x4000000) == 0x4000000 )
{
m_Icon_DI26.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI26.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x8000000) == 0x8000000 ) // if the target bit is changed
{
if( (dwPortData & 0x8000000) == 0x8000000 )
{
m_Icon_DI27.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI27.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x10000000) == 0x10000000 ) // if the target bit is changed
{
if( (dwPortData & 0x10000000) == 0x10000000 )
{
m_Icon_DI28.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI28.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x20000000) == 0x20000000 ) // if the target bit is changed
{
if( (dwPortData & 0x20000000) == 0x20000000 )
{
m_Icon_DI29.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI29.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x40000000) == 0x40000000 ) // if the target bit is changed
{
if( (dwPortData & 0x40000000) == 0x40000000 )
{
m_Icon_DI30.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI30.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
if( (dwChangeMask & 0x80000000) == 0x80000000 ) // if the target bit is changed
{
if( (dwPortData & 0x80000000) == 0x80000000 )
{
m_Icon_DI31.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_RED) ) ;
}
else
{
m_Icon_DI31.SetIcon( AfxGetApp()->LoadIcon(IDI_ICON_BLACK) ) ;
}
}
}
CDialog::OnTimer(nIDEvent);
}