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();
				 } 
		  
		  
}
相关推荐
悄悄敲敲敲4 小时前
C++:dfs习题四则
c++·算法·深度优先
安於宿命5 小时前
【Linux】进程间通信——进程池
linux·c++
南郁10 小时前
001-监控你的文件-FSWatch-C++开源库108杰
c++·开源·文件系统·文件监控·fswatch·文件变动信息·libfswatch
linux开发之路11 小时前
C++Linux进阶项目分析-仿写Redis之Qedis
linux·c++·redis·多线程·后端开发
EPSDA11 小时前
Linux线程库与线程库封装
linux·运维·服务器·开发语言·c++
孤独得猿11 小时前
排序算法复习——包括插入排序、希尔排序、冒泡排序、快排(包括霍尔法、挖坑法、快慢指针法)、堆排、选择排序、归并排序等 (代码采用c/c++混编)
c语言·数据结构·c++·笔记·算法·排序算法
编程探索者小陈11 小时前
【C++】智能指针的使用及其原理
开发语言·c++
半桔13 小时前
贪吃蛇解析
c语言·开发语言·数据结构·c++·算法
Pan_peter13 小时前
零基础学QT、C++(一)安装QT
c++·qt
万能的小裴同学14 小时前
MFC 自定义十六进制显示控件
开发语言·c++·mfc