⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yxscantask.cpp

📁 波峰焊后台控制软件-中文版
💻 CPP
📖 第 1 页 / 共 2 页
字号:
														break;
												case  1:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][1]))//取内部遥信值
														{
															if(Arg->con_in[i].B.u1_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u1_kgbf!=0) m++;  //取反
														}
														break;
												case  2:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][2]))
														{
															if(Arg->con_in[i].B.u2_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u2_kgbf!=0) m++;  //取反
														}
														break;
												case  3:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][3]))
														{
															if(Arg->con_in[i].B.u3_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u3_kgbf!=0) m++;  //取反
														}
														break;
												case  4:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][4]))
														{
															if(Arg->con_in[i].B.u4_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u4_kgbf!=0) m++;  //取反
														}
														break;
												case  5:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][5]))
														{
															if(Arg->con_in[i].B.u5_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u5_kgbf!=0) m++;  //取反
														}
														break;
												case  6:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][6]))
														{
															if(Arg->con_in[i].B.u6_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u6_kgbf!=0) m++;  //取反
														}
														break;
												case  7:if(Arg->BitTestChar(Arg->yxbuf,Arg->us[i][7]))
														{
															if(Arg->con_in[i].B.u7_kgbf==0) m++;  //不取反
														}else
														{
															if(Arg->con_in[i].B.u7_kgbf!=0) m++;  //取反
														}
														break;
											}
										}//或运算
					                    if(m==0)   Arg->BitClrChar(Arg->newkr,i);
				                         else      Arg->BitSetChar(Arg->newkr,i);
									    break;
								case  2://4:设置
										Arg->BitSetChar(Arg->newkr,i);
									    break;
								case  3://5:清零
										Arg->BitClrChar(Arg->newkr,i);
									    break;
							  }//switch(Arg->con_in[i].B.log_enable)
					          break;
				   case  0x01://1:时间型
					          if(dt>=Arg->etime[i]) Arg->BitSetChar(Arg->newkr,i);
							        else            Arg->BitClrChar(Arg->newkr,i);
					          break;
				   case  0x02:// 2:脉冲型
					          if(Arg->ms_count[i]>=Arg->up_time[i])   Arg->BitClrChar(Arg->newkr,i);
							            else                          Arg->BitSetChar(Arg->newkr,i);
                              Arg->ms_count[i]=Arg->ms_count[i]+ms_dx;
							  if(Arg->ms_count[i]>=(Arg->up_time[i]+Arg->dn_time[i])) Arg->ms_count[i]=0;
					          break;
				}//switch(Arg->con_in[i].B.type)
		}//for(i=0;i<(MAXKRNUM);i++)


        for(i=0;i<(MAXKRNUM/8);i++)
		{
            Arg->chgkr[i].Value=Arg->newkr[i].Value ^ Arg->oldkr[i].Value;
		}

        for(i=0;i<(MAXKRNUM);i++)
		{//--------------------------------------------------------------------------------
			  if(Arg->BitTestChar(Arg->ysfg,i))//抖动标志是否为零
			  {//有抖动
					Arg->jgtm[i]=Arg->jgtm[i]+ms_dx;//抖动持续时间
					if(Arg->BitTestChar(Arg->chgkr,i))
					{//复归
					   Arg->jgtm[i]=0;
					   Arg->BitClrChar(Arg->ysfg,i);
					}else
					{//静止
							if(Arg->jgtm[i]>=Arg->bvtm[i])
							{//产生变位
								   Arg->yscon[i]++;
								   buf[0] =0xAA;
								   buf[1] =0x55;
								   buf[2] =0x00;    //CMD
								   buf[3] =15;		//长度
								   buf[4] =Arg->year[i];		//年
								   buf[5] =Arg->month[i];		//月
								   buf[6] =Arg->date[i];		//日
								   buf[7] =Arg->hour[i];		//时
								   buf[8] =Arg->minute[i];		//分
								   buf[9] =Arg->second[i];		//秒
								   ms.Value=Arg->Milliseconds[i];
								   buf[10] =ms.VB.LowB0; //毫秒低
								   buf[11] =ms.VB.LowB1; //毫秒高
								   temp.Value=(unsigned int)i;
								   buf[12]=temp.VB.LowB0; //开关序号低字节
								   buf[13]=temp.VB.LowB1; //开关序号高字节

                                   if(Arg->con_in[i].B.kgbf!=0)  
								   {//取反
										   if(Arg->BitTestChar(Arg->newkr,i))
										   {
												Arg->BitClrChar(Arg->yxbuf,i);
												buf[14]=0; //0:负跳变
												if(Arg->con_in[i].B.dnm_enable!=0)Arg->mulse[i]++;
										   }else
										   {
												Arg->BitSetChar(Arg->yxbuf,i);
												buf[14]=1; // 1:正跳变
												if(Arg->con_in[i].B.upm_enable!=0)Arg->mulse[i]++;

										   }
								   }else
								   {
										   if(Arg->BitTestChar(Arg->newkr,i))
										   {
												Arg->BitSetChar(Arg->yxbuf,i);
												buf[14]=1; // 1:正跳变
												if(Arg->con_in[i].B.upm_enable!=0)Arg->mulse[i]++;
										   }else
										   {
												Arg->BitClrChar(Arg->yxbuf,i);
												buf[14]=0; //0:负跳变
												if(Arg->con_in[i].B.dnm_enable!=0)Arg->mulse[i]++;
										   }
								   }
							       if(Arg->pWnd!=NULL)
								   {
									    theApp.flash_plc_flag=0xff;
//										(Arg->pWnd)->PostMessage(WM_TIMER);
								   }							   
								   if(Arg->con_in[i].B.soe_enable!=0) 
								   {
									   theApp.WarnWrite(buf);
									   theApp.SaveWarn(buf);
								   }
								   Arg->jgtm[i]=0;
								   Arg->BitClrChar(Arg->ysfg,i);
							}//------------------------------------------------------
					}
			  }else
			  {//无抖动
					if(Arg->BitTestChar(Arg->chgkr,i))
					{//记录时间 设置抖动标志
					    Arg->jgtm[i]=0;
					    Arg->BitSetChar(Arg->ysfg,i);
						Arg->year[i]		 =Arg->mYear;
						Arg->month[i]		 =Arg->mMonth;
						Arg->date[i]		 =Arg->mDay;
						Arg->hour[i]		 =Arg->mHour;
						Arg->minute[i]		 =Arg->mMinute;
						Arg->second[i]		 =Arg->mSecond;
						Arg->Milliseconds[i] =Arg->mMilliseconds;
					}
			  }
		}//----------------------------------------------------------------------


	    n=Arg->con_out[i].B.out_enable;
		for(i=0;i<(int)n;i++)
		{//遥控交叉表
			if(Arg->BitTestChar(Arg->yxbuf,i))   Arg->BitSetChar(Arg->outbuf,i);
			        else                         Arg->BitClrChar(Arg->outbuf,i);
			switch(k)
			{
				case  0:if(Arg->con_out[i].B.out0_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
				case  1:if(Arg->con_out[i].B.out1_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
				case  2:if(Arg->con_out[i].B.out2_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
				case  3:if(Arg->con_out[i].B.out3_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
				case  4:if(Arg->con_out[i].B.out4_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
				case  5:if(Arg->con_out[i].B.out5_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
				case  6:if(Arg->con_out[i].B.out6_kgbf!=0)Arg->BitXorChar(Arg->outbuf,i);//取反
					    break;
			}
		}

       for(i=0;i<(MAXKRNUM/8);i++)  Arg->oldkr[i].Value=Arg->newkr[i].Value;



       //--------毫秒计数器---------------------------------------
	   new_dms=GetTickCount();
	   dms=new_dms-last_dms;
	   last_dms=new_dms;
	   mss=mss+dms;
	   mx=mss % 500;
	   if(mx<oldmx)
	   {
                oldmx=mx;
		    	if(theApp.TSamplefg!=0)
				{//每0.5秒采样一个点
						   if(theApp.TTCount<600)
						   {
							   for(i=0;i<3;i++)
							   {
									if(theApp.test_flag[i]!=0)
									{
										theApp.TEMT[i][theApp.TTCount]=theApp.temper_value[i+5];
/*										switch(i)
										{
										case 0:theApp.TEMT[i][theApp.TTCount]=193.0;//theApp.temper_value[i+5];
											   break;
										case 1:theApp.TEMT[i][theApp.TTCount]=182.0;//theApp.temper_value[i+5];
											   break;
										case 2:theApp.TEMT[i][theApp.TTCount]=171.0;//theApp.temper_value[i+5];
											   break;

										}*/
										
									}else
									{
										theApp.TEMT[i][theApp.TTCount]=0;
									}
							   }
							   theApp.TTCount++;
						   }else  theApp.TTCount=599;
				}else  theApp.TTCount=0;
	 }else  oldmx=mx;

	 newsecond=Arg->mSecond;
	 if(newsecond!=oldsecond)
	 {//运行时间
            if(theApp.rh1_switch!=0) theApp.rh1_count++;
			        else             theApp.rh1_count=0;


            if(theApp.rh2_switch!=0) theApp.rh2_count++;
			        else             theApp.rh2_count=0;

            if(theApp.rh3_switch!=0) theApp.rh3_count++;
			        else             theApp.rh3_count=0;

            if(theApp.sl_switch!=0)
			{//锡炉开
				theApp.second_run++;
				theApp.second_sl_run++;
				theApp.sl_count++;
				if(theApp.second_run>=60)
				{
						  theApp.second_run=0;
						  if(theApp.minute_run>=60)
						  {
							  theApp.minute_run=0;
							  if(theApp.hour_run>=24)
							  {
								theApp.hour_run=0;
								theApp.date_run++;
							  }
							  theApp.hour_run++;
						  }
						  theApp.minute_run++;
				}



				if(theApp.rlscale>=100)
				{
					theApp.sl_wave_flag=0xff;
				}			
			    if(theApp.second_sl_run>=theApp.SL_Timer)
				{// 锡炉底部加热时间到
                    if(theApp.sl_wave_flag==0)
					{
				       theApp.YKOUTPUT(YK_SL_TIMER,YKON);
					}
				}
				if(theApp.sl_wave_flag!=0)
				{
					theApp.YKOUTPUT(YK_SL_TIMER,YKOFF);
				}
			}else
			{//锡炉关
				theApp.second_sl_run=0;
				theApp.sl_wave_flag=0;
				theApp.sl_count=0;
                theApp.YKOUTPUT(YK_SL_TIMER,YKOFF);
			}
	 }
	 oldsecond=newsecond;

	dx=theApp.temper_value[0]; //锡炉温度
	dy=theApp.RLSet;           //熔锡温度
	if(dx<dy)
	{
           theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,127);
           theApp.ws1_switch=0x00;
           theApp.ws2_switch=0x00;
           theApp.YKOUTPUT(YK_WS1_JON,YKOFF);
           theApp.YKOUTPUT(YK_WS2_JON,YKOFF);
           if(theApp.sl_up_count>0) theApp.sl_up_count--;
		       else                 theApp.sl_up_count=0; 

	}else
	{
           theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,127);
           theApp.sl_up_count++;
		   if(theApp.sl_up_count>=3000) theApp.sl_up_count=3000;
	}

    if(theApp.sl_up_count>2000)
	{
		theApp.YKOUTPUT(YK_FON_RIGHT,YKON);
	}else
	{
	    if(theApp.sl_up_timer==0)
		{
		     theApp.YKOUTPUT(YK_FON_RIGHT,YKOFF);
		}else
		{
			theApp.YKOUTPUT(YK_FON_RIGHT,YKON);
		}
	}
	if(theApp.sl_up_timer!=0) theApp.sl_up_timer--;


	if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,134))// 1:开 0:关
	{//波峰一开/波峰一关
		     theApp.test_ws[0]++;
			 if(theApp.WorkMode!=0)
			 {//经济运行
				     theApp.YKOUTPUT(YK_SHIFT,YKON);//经济运行
					 if(theApp.pw_type==0)//助焊方法
					 {//喷雾
							theApp.test_ws[1]++;
							dx=theApp.temper_value[0]; //锡炉温度
							dy=theApp.RLSet;           //熔锡温度
							if(dx>dy)
							{
								theApp.test_ws[2]++;
								if((theApp.plc_con_ret[0] & 0x01)==0)
								{
									theApp.test_ws[3]++;
									theApp.YKOUTPUT(YK_WS1_JON,YKOFF);
								}else
								{
									theApp.YKOUTPUT(YK_WS1_JON,YKON);
									theApp.test_ws[4]++;
								}
							}
					 }else
					 {//发泡
                    	  theApp.YKOUTPUT(YK_WS1_JON,YKON);
                    	  theApp.YKOUTPUT(YK_SPOOT,YKON); 
					 }
			 }else
			 {//正常运行

					if(theApp.pw_type==0)//助焊方法
					{//喷雾
				        theApp.YKOUTPUT(YK_WS1_JON,YKON);
					    theApp.YKOUTPUT(YK_SHIFT,YKOFF);
					}else
					{// 发泡
				        theApp.YKOUTPUT(YK_WS1_JON,YKON);
					}

			 }
		}else 
		{
			theApp.YKOUTPUT(YK_WS1_JON,YKOFF);
		}




		if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,135))// 1:开 0:关
		{//波峰二开/波峰二关
			 if(theApp.WorkMode!=0)
			 {//经济运行
				     theApp.YKOUTPUT(YK_SHIFT,YKON);//经济运行
					 if(theApp.pw_type==0)//助焊方法
					 {//喷雾
						dx=theApp.temper_value[0]; //锡炉温度
						dy=theApp.RLSet;           //熔锡温度
						if(dx>dy)
						{
							if((theApp.plc_con_ret[1] & 0x01)==0)
							{
								theApp.YKOUTPUT(YK_WS2_JON,YKOFF);
							}else
							{
								theApp.YKOUTPUT(YK_WS2_JON,YKON);
							}
						}
					 }else
					 {//发泡
                    	  theApp.YKOUTPUT(YK_WS2_JON,YKON);
                    	  theApp.YKOUTPUT(YK_SPOOT,YKON); 
					 }
			 }else
			 {
					if(theApp.pw_type==0)//助焊方法
					{// 喷雾
						theApp.YKOUTPUT(YK_WS2_JON,YKON);
						theApp.YKOUTPUT(YK_SHIFT,YKOFF);
					}else
					{// 发泡
						theApp.YKOUTPUT(YK_WS2_JON,YKON);
					}
			 }
		}else 	theApp.YKOUTPUT(YK_WS2_JON,YKOFF);


		dx=theApp.temper_value[0];
		dy=theApp.RLSet;
		if(dy>20)
		{
			theApp.rlscale=dx/dy;;
		}else
		{
			theApp.rlscale=0;
		}

		theApp.rlscale=theApp.rlscale*100;

	    if((theApp.plc_con_ret[1] & 0x02)!=0)
		{//R381		切断预热点红灯
//	        if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,136))
		    if(theApp.Contrans_Soe_Flag!=0)
			{
				if( theApp.Contrans_Count>=120 )
				{
					theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,130);
					theApp.YKOUTPUT(YK_RH1_ACON,YKOFF);/* 预热接触器1      */
					theApp.rh1_switch=0x00;

					theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,131);
					theApp.YKOUTPUT(YK_RH2_ACON,YKOFF);/* 预热接触器2      */
					theApp.rh2_switch=0x00;

					theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,132);
					theApp.YKOUTPUT(YK_RH3_ACON,YKOFF);/* 预热接触器2      */
					theApp.rh3_switch=0x00;
					theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,134);
					theApp.YKOUTPUT(YK_WS1_JON,YKOFF);
					theApp.ws1_switch=0x00;
					theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,135);
					theApp.YKOUTPUT(YK_WS2_JON,YKOFF);
					theApp.ws2_switch=0x00;	
				}
			}
		}

        if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,136))
		{
				theApp.Contrans_Count++;
				if( theApp.Contrans_Count>=120 )
				{
				    theApp.Contrans_Count = 120;
				}
		}


	    if((theApp.plc_con_ret[1] & 0x04)!=0)
		{// R382		切断运输
	        if(Arg->BitTestChar(Arg->yxbuf,136))
			{
				if( theApp.Contrans_Count>=120 )
				{
				    theApp.Contrans_Soe_Flag=0xff;
					Arg->BitSetChar(Arg->krbuf,73);
					theApp.TransOff();
					Arg->BitClrChar(Arg->krbuf,136);
					theApp.YKOUTPUT(YK_TRANS_ACON,YKOFF);
				}
			}
		}

        if(theApp.Com2_Status!=0)
		{
			if( theApp.pw_type == 0 )
			{
				Arg->BitSetChar(Arg->krbuf,72);
			}else
			{
				Arg->BitClrChar(Arg->krbuf,72);
			}
		}else
		{
			Arg->BitClrChar(Arg->krbuf,72);
		}


/*	
		if(theApp.Contrans_Soe_Flag!=0)
		{
			theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,73);
		}else
		{
			theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,73);
		}
*/
        Sleep(199);

		if(theApp.m_UserPower.KeepTime>0)
		{
			theApp.m_UserPower.KeepTime=theApp.m_UserPower.KeepTime-0.00333;
		}else
		{
			theApp.m_UserPower.KeepTime=0;
		}



		dx=theApp.temper_value[0];
		dy=theApp.RLFanSet;
		if(dx>=dy)
		{
			if(theApp.RLFanCount>=300)
			{
				theApp.RLFanCount=300;
				theApp.YKOUTPUT(YK_JUST_WATER,YKON);
			}else
			{
				theApp.YKOUTPUT(YK_JUST_WATER,YKOFF);
				theApp.RLFanCount++;
			}
		}else
		{
			theApp.RLFanCount=0;
			theApp.YKOUTPUT(YK_JUST_WATER,YKOFF);
		}




  	}//while(1)---------------------------------------------------
    return 0;
}







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -