承接专栏《MFC工控项目实例之十八手动测试界面输入信号实时检测》
根据板卡设置界面组合框选项设定的输出信号,通过读取文件中保存的键值,用单选按钮切换输出信号接通、关闭。
1、在Data_1.h文件中添加代码
CString COMB_Data_O_1[]={"夹紧","密闭","进气","平衡","排气","黄灯","绿灯","红灯"};
int COMB_Data_O_Number_1;
unsigned char b_O_1[16];
CString b_str_O_1[16];
unsigned short O_1[16];
2、在JogTest.cpp中添加代码
CJogTest::CJogTest(CWnd* pParent /*=NULL*/)
: CDialog(CJogTest::IDD, pParent)
{
...
COMB_Data_O_Number_1=(sizeof(COMB_Data_O_1) / sizeof(COMB_Data_O_1[1]));
}
BOOL CJogTest::OnInitDialog()
{
CDialog::OnInitDialog();
...
for( i=0;i<=COMB_Data_O_Number_1;i++)
{
GetPrivateProfileString("输出信号",COMB_Data_O_1[i],NULL,b_str_O_1[i].GetBuffer(20),20,strFilePath);
O_1[i]=_ttoi(b_str_O_1[i]);
}
void CJogTest::OnRadio3()
{
DO6408Bit(nAddr_1,O_1[1],0);
}
void CJogTest::OnRadio4()
{
DO6408Bit(nAddr_1,O_1[1],1);
}
void CJogTest::OnRadio5()
{
DO6408Bit(nAddr_1,O_1[2],0);
}
void CJogTest::OnRadio6()
{
DO6408Bit(nAddr_1,O_1[2],1);
}
void CJogTest::OnRadio7()
{
DO6408Bit(nAddr_1,O_1[3],0);
}
void CJogTest::OnRadio8()
{
DO6408Bit(nAddr_1,O_1[3],1);
}
void CJogTest::OnRadio9()
{
DO6408Bit(nAddr_1,O_1[4],0);
}
void CJogTest::OnRadio10()
{
DO6408Bit(nAddr_1,O_1[4],1);
}
void CJogTest::OnRadio11()
{
DO6408Bit(nAddr_1,O_1[5],0);
DO6408Bit(nAddr_1,O_1[6],0);
DO6408Bit(nAddr_1,O_1[7],0);
}
void CJogTest::OnRadio12()
{
DO6408Bit(nAddr_1,O_1[5],1);
DO6408Bit(nAddr_1,O_1[6],0);
DO6408Bit(nAddr_1,O_1[7],0);
}
void CJogTest::OnRadio13()
{
DO6408Bit(nAddr_1,O_1[6],1);
DO6408Bit(nAddr_1,O_1[5],0);
DO6408Bit(nAddr_1,O_1[7],0);
}
void CJogTest::OnRadio14()
{
DO6408Bit(nAddr_1,O_1[7],1);
DO6408Bit(nAddr_1,O_1[5],0);
DO6408Bit(nAddr_1,O_1[6],0);
}
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » MFC工控项目实例之十九手动测试界面输出信号切换
发表评论 取消回复