MFC工控项目实例三十实现一个简单的流程

启动按钮夹紧 密闭,时间0到平衡 进气,时间1到进气关,时间2到平衡关 检测,时间3到平衡 排气,时间4到夹紧开、密闭开、排气关。

相关代码

cpp 复制代码
void CSEAL_PRESSUREDlg::OnTimer_2(UINT nIDEvent_2)
{

           
		  // if (nIDEvent_2==1 && t_time_2<=theApp.m_sys_data.m_fMaxTime*10)
     if (nIDEvent_2==1 )
		{
		     t_time_1++;			

                   YRandom = rand()%3; // Generate Random data  
                    m_ctrlPlot_1.GetChannel(0).AddXY(t_time_1/10, YRandom );
					
					 	
	 } 
         
	
	       if (nIDEvent_2==1 && t_time_2<theApp.m_edit_time0*10)
		  {
			   t_time_2++;
			  DO6408Bit(theApp.nAddr_1,theApp.O_1[0],1);//夹紧		
			  DO6408Bit(theApp.nAddr_1,theApp.O_1[1],1);//密闭
                
			 
			  SetDlgItemText(IDC_EDIT_MESSAGE,"夹紧\密闭");
	       	
		 } 
	     else if ( t_time_2<theApp.m_edit_time1)
		  {
			   t_time_2++;
			  DO6408Bit(theApp.nAddr_1,theApp.O_1[3],1);//平衡开
			  DO6408Bit(theApp.nAddr_1,theApp.O_1[2],1);//进气			  
			  SetDlgItemText(IDC_EDIT_MESSAGE,"夹紧\密闭\r\n平衡\进气");
           
	       	
		 }
			else if ( t_time_2<theApp.m_edit_time2)
			{ 
				  t_time_2++;
				 DO6408Bit(theApp.nAddr_1,theApp.O_1[2],0);//进气关
			     SetDlgItemText(IDC_EDIT_MESSAGE,"夹紧\密闭\r\n平衡\进气\r\n进气关");
			     
			}
			  else if (t_time_2<theApp.m_edit_time3)
			  {
				   t_time_2++;
				  DO6408Bit(theApp.nAddr_1,theApp.O_1[3],0);//平衡关\检测
				 SetDlgItemText(IDC_EDIT_MESSAGE,"夹紧\密闭\r\n平衡\进气\r\n进气关\r\n平衡关\检测");
                
			  }
			    else if (t_time_2<theApp.m_edit_time4)
			  {
				 t_time_2++;
				    DO6408Bit(theApp.nAddr_1,theApp.O_1[3],1);//平衡开
			    	DO6408Bit(theApp.nAddr_1,theApp.O_1[4],1);//排气开
                 SetDlgItemText(IDC_EDIT_MESSAGE,"夹紧\密闭\r\n平衡\进气\r\n进气关\r\n平衡关\检测\r\n平衡\排气");
			  }
                 else 
				 {
                  DO6408Bit(theApp.nAddr_1,theApp.O_1[4],0);//排气关
				  DO6408Bit(theApp.nAddr_1,theApp.O_1[3],0);//排气关
				  DO6408Bit(theApp.nAddr_1,theApp.O_1[0],0);//夹紧松
				  DO6408Bit(theApp.nAddr_1,theApp.O_1[1],0);//密闭松
				 SetDlgItemText(IDC_EDIT_MESSAGE,"结束");
				 
    theApp.m_edit_time1= theApp.m_allPara[theApp.m_nProductSel].m_edit_time1;
	theApp.m_edit_time2= theApp.m_allPara[theApp.m_nProductSel].m_edit_time2;
	theApp.m_edit_time3= theApp.m_allPara[theApp.m_nProductSel].m_edit_time3;
	theApp.m_edit_time4= theApp.m_allPara[theApp.m_nProductSel].m_edit_time4;
				   DestroyTimer();
				   DestroyTimer_2();
				 } 
		  
		  
}
相关推荐
小破农9 分钟前
C++篇——继承
c++·笔记
努力学习的小廉44 分钟前
我爱学算法之—— 二分查找(上)
开发语言·c++·算法
wqfhenanxc2 小时前
Mixing C++ and Rust for Fun and Profit 阅读笔记
c++·笔记·rust
R-G-B2 小时前
【MFC】 VS2022打开低版本的MFC,双击.rc文件,DIalog加载失败,页面弹窗fatal error RC***:cannot open*****
c++·mfc·vs打开较早版本mfc·双击.rc文件·dialog加载失败·fatal error rc·cannot open
敲上瘾2 小时前
基于Tcp协议的应用层协议定制
linux·运维·服务器·网络·c++·网络协议·tcp/ip
莹莹学编程—成长记3 小时前
string的模拟实现
服务器·c++·算法
喵先生!6 小时前
C++中的vector和list的区别与适用场景
开发语言·c++
xMathematics7 小时前
计算机图形学实践:结合Qt和OpenGL实现绘制彩色三角形
开发语言·c++·qt·计算机图形学·cmake·opengl
yuanManGan9 小时前
C++入门小馆: 深入了解STLlist
开发语言·c++
梁下轻语的秋缘9 小时前
每日c/c++题 备战蓝桥杯(P1049 [NOIP 2001 普及组] 装箱问题)
c语言·c++·学习·蓝桥杯