📄 iosingledlg.cpp
字号:
// IoSingleDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "HW_sigal.h"
#include "IoSingleDlg.h"
#include ".\iosingledlg.h"
#include ".\winio.h"
#include ".\HwReadWrite.h"
// CIoSingleDlg 对话框
IMPLEMENT_DYNAMIC(CIoSingleDlg, CDialog)
CIoSingleDlg::CIoSingleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CIoSingleDlg::IDD, pParent)
, m_strPortAddress(_T(""))
, m_strPortValue(_T(""))
, m_cDataSize(0)
{
}
CIoSingleDlg::~CIoSingleDlg()
{
}
void CIoSingleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_PORT_ADDR_SIG, m_strPortAddress);
DDX_Text(pDX, IDC_EDIT_PORT_VAL_SIG, m_strPortValue);
}
BEGIN_MESSAGE_MAP(CIoSingleDlg, CDialog)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BUTTON_READ, OnBnClickedButtonRead)
ON_BN_CLICKED(IDC_RADIO_SIZE1, OnBnClickedRadioSize1)
ON_BN_CLICKED(IDC_RADIO_SIZE2, OnBnClickedRadioSize2)
ON_BN_CLICKED(IDC_RADIO_SIZE3, OnBnClickedRadioSize3)
ON_BN_CLICKED(IDC_BUTTON_WRITE, OnBnClickedButtonWrite)
END_MESSAGE_MAP()
// CIoSingleDlg 消息处理程序
void CIoSingleDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: 在此处添加消息处理程序代码
}
void CIoSingleDlg::OnBnClickedRadioSize1()
{
// TODO: 在此添加控件通知处理程序代码
this->m_cDataSize = 1;
}
void CIoSingleDlg::OnBnClickedRadioSize2()
{
// TODO: 在此添加控件通知处理程序代码
this->m_cDataSize = 2;
}
void CIoSingleDlg::OnBnClickedRadioSize3()
{
// TODO: 在此添加控件通知处理程序代码
this->m_cDataSize = 4;
}
void CIoSingleDlg::OnBnClickedButtonRead()
{
// TODO: 在此添加控件通知处理程序代码
WORD portAddress;
DWORD portValue=0;
TCHAR szItem[256] = {0};
this->UpdateData(TRUE);
portAddress = _tcstoul(this->m_strPortAddress, 0, 16);
gpHwRw->GetPortVal(portAddress, &portValue, this->m_cDataSize);
//GetPortVal(portAddress, &portValue, this->m_cDataSize);
this->m_strPortValue = "";
for(int i=0; i<this->m_cDataSize*2; i++)
{
_stprintf(szItem+i, _T("%01x"), (portValue>>((this->m_cDataSize-i)*4))&0x0F );
}
this->m_strPortValue = CString(szItem);
this->UpdateData(FALSE);
}
void CIoSingleDlg::OnBnClickedButtonWrite()
{
// TODO: 在此添加控件通知处理程序代码
WORD portAddress;
DWORD portValue;
this->UpdateData(TRUE);
portAddress = _tcstoul(this->m_strPortAddress, 0, 16);
portValue = _tcstoul(this->m_strPortValue, 0, 16);
gpHwRw->SetPortVal(portAddress, portValue, 1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -