承接专栏《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);
	
}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部