📄 dioview.cpp
字号:
m_Button_In14.SetWindowText("开关14 (开)");
m_Button_In14.SetCheck(1);
}
else
{ // 关
m_Button_In14.SetState(FALSE);
m_Button_In14.SetWindowText("开关14 (关)");
m_Button_In14.SetCheck(0);
}
if(ParaDI.DI15) // 开
{
m_Button_In15.SetState(TRUE);
m_Button_In15.SetWindowText("开关15 (开)");
m_Button_In15.SetCheck(1);
}
else
{ // 关
m_Button_In15.SetState(FALSE);
m_Button_In15.SetWindowText("开关15 (关)");
m_Button_In15.SetCheck(0);
}
}
OldDI = ParaDI;
}
void CDIOView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(Flag) {
SetSwitchStatus();
Flag = false;
}
CFormView::OnTimer(nIDEvent);
}
void CDIOView::SetSwitchOut(void)
{
if(!bCreateDevice) return;
PCI2006_PARA_DO ParaDO;
ParaDO.DO0 = m_bDO0; ParaDO.DO8 = m_bDO8;
ParaDO.DO1 = m_bDO1; ParaDO.DO9 = m_bDO9;
ParaDO.DO2 = m_bDO2; ParaDO.DO10 = m_bDO10;
ParaDO.DO3 = m_bDO3; ParaDO.DO11 = m_bDO11;
ParaDO.DO4 = m_bDO4; ParaDO.DO12 = m_bDO12;
ParaDO.DO5 = m_bDO5; ParaDO.DO13 = m_bDO13;
ParaDO.DO6 = m_bDO6; ParaDO.DO14 = m_bDO14;
ParaDO.DO7 = m_bDO7; ParaDO.DO15 = m_bDO15;
Flag =true;
// 输出各路开关量状态
PCI2006_SetDeviceDO( hDevice, &ParaDO);
}
void CDIOView::OnCheckDo0()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO0)
{
m_Check_DO0.SetWindowText("开关0 (开)");
}
else
{
m_Check_DO0.SetWindowText("开关0 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO1)
{
m_Check_DO1.SetWindowText("开关1 (开)");
}
else
{
m_Check_DO1.SetWindowText("开关1 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO2)
{
m_Check_DO2.SetWindowText("开关2 (开)");
}
else
{
m_Check_DO2.SetWindowText("开关2 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo3()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO3)
{
m_Check_DO3.SetWindowText("开关3 (开)");
}
else
{
m_Check_DO3.SetWindowText("开关3 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo4()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO4)
{
m_Check_DO4.SetWindowText("开关4 (开)");
}
else
{
m_Check_DO4.SetWindowText("开关4 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo5()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO5)
{
m_Check_DO5.SetWindowText("开关5 (开)");
}
else
{
m_Check_DO5.SetWindowText("开关5 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo6()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO6)
{
m_Check_DO6.SetWindowText("开关6 (开)");
}
else
{
m_Check_DO6.SetWindowText("开关6 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo7()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO7)
{
m_Check_DO7.SetWindowText("开关7 (开)");
}
else
{
m_Check_DO7.SetWindowText("开关7 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo8()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO8)
{
m_Check_DO8.SetWindowText("开关8 (开)");
}
else
{
m_Check_DO8.SetWindowText("开关8 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo9()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO9)
{
m_Check_DO9.SetWindowText("开关9 (开)");
}
else
{
m_Check_DO9.SetWindowText("开关9 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo10()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO10)
{
m_Check_DO10.SetWindowText("开关10 (开)");
}
else
{
m_Check_DO10.SetWindowText("开关10 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo11()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO11)
{
m_Check_DO11.SetWindowText("开关11 (开)");
}
else
{
m_Check_DO11.SetWindowText("开关11 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo12()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO12)
{
m_Check_DO12.SetWindowText("开关12 (开)");
}
else
{
m_Check_DO12.SetWindowText("开关12 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo13()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO13)
{
m_Check_DO13.SetWindowText("开关13 (开)");
}
else
{
m_Check_DO13.SetWindowText("开关13 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo14()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO14)
{
m_Check_DO14.SetWindowText("开关14 (开)");
}
else
{
m_Check_DO14.SetWindowText("开关14 (关)");
}
SetSwitchOut();
}
void CDIOView::OnCheckDo15()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bDO15)
{
m_Check_DO15.SetWindowText("开关15 (开)");
}
else
{
m_Check_DO15.SetWindowText("开关15 (关)");
}
SetSwitchOut();
}
void CDIOView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CSysApp *pApp=(CSysApp *)AfxGetApp();
DeviceID = pApp->m_CurrentDeviceID; // 取得当前应用程序使用的设备ID号
Flag = true;
if(pApp->m_hDevice!=INVALID_HANDLE_VALUE)
{
hDevice = pApp->m_hDevice;
bCreateDevice = TRUE;
SetTimer(1, 250, NULL); // 启动定时器,查询开关量输入状态
}
}
void CDIOView::OnDestroy()
{
CFormView::OnDestroy();
// TODO: Add your message handler code here
}
void CDIOView::OnTestIO()
{
// TODO: Add your command handler code here
CSysApp *pApp=(CSysApp *)AfxGetApp();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -