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

📄 comm.cpp

📁 波峰焊后台控制软件-英文版
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  MakeFrame1(1);
  SendFrame1();
}

void Ccomm::AskVfds0Status()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(2);
  SendFrame1();
}

void Ccomm::DownPidPara()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(3);
  SendFrame1();
}

void Ccomm::DownPara()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(4);
  SendFrame1();
}

void Ccomm::ResetWarn()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(5);
  SendFrame1();
}

void Ccomm::Config4018()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(6);
  SendFrame1();
}

void Ccomm::Config4012()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(7);
  SendFrame1();
}

void Ccomm::Config4021()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;
  MakeFrame1(8);
  SendFrame1();
}


void Ccomm::GetTime()
{
  Com1_Repeate = 0;
  Com1_TimeOut = 0;

  MakeFrame1(1);
  SendFrame1();
  //DayTime *TheTime = (DayTime far *)GlobalLock(hRtuTime);
  //_fmemset(TheTime,0,sizeof(DayTime));
  //GlobalUnlock(hRtuTime);
}

BOOL Ccomm::Test()
{   
	MessageBox(NULL,_T("TEST OK!"),_T("test"),MB_OK);
	ReceiveFrame1();
    return(1);
}


DWORD CALLBACK PidThread(LPVOID param)
{
	unsigned char ch,chh;
    int    newsecond,oldsecond,ten,i;
	ten=0;


	while(PidRun)
	{//---------------------------------------------------
	    if(theApp.SETRSCASE!=0)
		{
		   theApp.RSCASE=theApp.SETRSCASE;
           theApp.SETRSCASE=0;
		}

	    switch(theApp.RSCASE)
		{//串口1
		case 0x00:  theApp.comm.ScanData();
				    Sleep(240);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=1;
					break;
        case 0x01:  theApp.comm.AskTemperPara();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=2;
					break;
		case 0x02:  theApp.comm.ScanData();
				    Sleep(240);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=3;
					break;
		case 0x03:  theApp.comm.AskVfds0Status();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=4;
					break;
		case 0x04:  theApp.comm.ScanData();
				    Sleep(240);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=5;
					break;
		case 0x05:  theApp.comm.DownPidPara();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=6;
					break;
		case 0x06:  theApp.comm.ScanData();
				    Sleep(240);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=7;
					break;
		case 0x07:  theApp.comm.DownPara();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=0;
					break;
		case 0x08  :theApp.comm.ResetWarn();			        
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=0;
					break;
		case 0x09:  theApp.comm.Config4018();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=0;
					break;
		case 0x0a:  theApp.comm.Config4012();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=0;
					break;
		case 0x0b:  theApp.comm.Config4021();
				    Sleep(200);
					theApp.comm.ReceiveFrame1();
					theApp.RSCASE=0;
					break;
		 default:   theApp.RSCASE=0;
				    Sleep(240);
			        break;
		}


//  CTime current_time=CTime::GetCurrentTime();
//  newsecond=(double)current_time.GetSecond();
//	if(newsecond!=oldsecond)
//	{
//	   if(ten>=9)
//	   {
//		  if((theApp.suw_value&0x20)!=0)
//		  {
//		      theApp.templib[theApp.samplecount]=theApp.TemperValue;//温度显示
//			  theApp.flowlib[theApp.samplecount]=theApp.FlowValue;//流量显示
//			  theApp.powerlib[theApp.samplecount]=theApp.PairValue;//压力显示
//              theApp.samplecount++;
//			  if(theApp.samplecount>=399)theApp.samplecount=399;
//		  }else 
//		  {
//			  if(theApp.samplecount!=0)
//			  {
//			      theApp.samplecount=0;
//                for(i=0;i<400;i++)
//			  {
//					theApp.templib[theApp.samplecount]=0;
//					theApp.powerlib[theApp.samplecount]=0;
//					theApp.flowlib[theApp.samplecount]=0;
//				  }
//			  }
//        }
//        ten=0;
//	   }else ten++;
//	   oldsecond=newsecond;
//	}

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

BOOL  BeginPid()
{
	if (PidRun == FALSE)
	{

	  PidRun = TRUE;
	  PidThreadHandle = CreateThread(
							(LPSECURITY_ATTRIBUTES)NULL,	// pointer to thread security attributes  
							0,	    // initial thread stack size, in bytes 
							(LPTHREAD_START_ROUTINE)PidThread,	// pointer to thread function 
							NULL,	// argument for new thread 
							0,	    // creation flags 
							&PidThreadId 	// pointer to returned thread identifier 
							);
	}
	return TRUE;
}

BOOL  EndPid()
{
	if(PidRun == TRUE)
	{
		PidRun = FALSE;
		Sleep(100);
		CloseHandle(PidThreadHandle);
	}
	return TRUE;
}


DWORD CALLBACK WarnThread(LPVOID param)
{
    int   i,j,k,m,n,once,newsecond,oldsecond;
//  CTime tt;
//	SYSTEMTIME timeDest;
	unsigned char  ch,chh;
	unsigned char OldWarn[10];
	double  dx,dy;
	CString   string;

    OldWarn[0]=0;
    OldWarn[1]=0;
    OldWarn[2]=0;
    OldWarn[3]=0;
    theApp.snum=0;
	once=0;
    theApp.oldyxbuf00=theApp.yxbuf00;
    theApp.oldyxbuf01=theApp.yxbuf01;


	while(WarnRun)
	{//---------------------------------------------------
		  theApp.comm.ScanDataPlc();
		  theApp.Com2_Txd_Flag++;
		  if(theApp.Com2_Txd_Flag>=1000)
		  {
			if(theApp.Com2_Rxd_Flag<=2)
			{
				theApp.Com2_Status = 0xff;
			}else
			{
				theApp.Com2_Status = 0;
			}
			theApp.Com2_Txd_Flag = 0;
			theApp.Com2_Rxd_Flag = 0;
		  }


		  Sleep(200);
		  theApp.comm.ReceiveFrame2();


/*		newsecond=theApp.Second;
		if(newsecond!=oldsecond)
		{//运行时间
			if(theApp.TestYkOut(YK_TRANS_ACON)) 
			{
				theApp.second_run++;
			}
		}
		oldsecond=newsecond;*/

        if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,20))
		{//红色
				theApp.ysfg_board=1;
		}else
		{//绿色
			   if(theApp.ysfg_board!=0)
			   {
				  theApp.BoardInCount++;
				  theApp.ysfg_board=0;
			   }
		}  

	    if( (theApp.yxbuf00 & 0x01)==0 )
		{
            theApp.board_infg=1;
		}else
		{
			if(theApp.board_infg!=0)
			{
				theApp.BoardInCount++;				
				theApp.board_infg=0;
			}
		}


        theApp.snum=theApp.snum+1;
  	    if(theApp.snum>=4)
		{//COM1巡检
			if(theApp.ComCount==0)
			{
				theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,71);
			}else
			{
			    theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,71);
			}
			theApp.ComCount=0;
            theApp.snum=0;
		}

        j=0;
		for(i=0;i<4;i++)
		{//-----超温报警--------------
			if(theApp.WarnSetPM[i]!=0)
			{
				  switch(i)
				  {
				  case 0:dx=theApp.temper_value[1];
				         dy=theApp.WarnSetON[i]+theApp.rh1_temper_set;
					     break;
				  case 1:dx=theApp.temper_value[2];
				         dy=theApp.WarnSetON[i]+theApp.rh2_temper_set;
					     break;
				  case 2:dx=theApp.temper_value[3];
				         dy=theApp.WarnSetON[i]+theApp.rh3_temper_set;
					     break;
				  case 3:dx=theApp.temper_value[0];
				         dy=theApp.WarnSetON[i]+theApp.sl_temper_set;
					     break;
				  }  
				  if(dx>=dy) 
				  {//超温报警
					  theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,96+i);
					  j++;
				  }else 
				  {
					  theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,96+i);
				  }
			}else
			{
				  theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,96+i);
			}
		}//for

		for(i=0;i<4;i++)
		{//-----低温报警----------------------
			if(theApp.WarnSetPM[i]!=0)
			{
				  switch(i)
				  {
				  case 0:dx=theApp.temper_value[1];
				         dy=theApp.rh1_temper_set-theApp.WarnSetOF[i];
					     break;
				  case 1:dx=theApp.temper_value[2];
				         dy=theApp.rh2_temper_set-theApp.WarnSetOF[i];
					     break;
				  case 2:dx=theApp.temper_value[3];
				         dy=theApp.rh3_temper_set-theApp.WarnSetOF[i];
					     break;
				  case 3:dx=theApp.temper_value[0];
				         dy=theApp.sl_temper_set-theApp.WarnSetOF[i];
					     break;
				  }  
				  if(dx<dy) 
				  {//低温报警

				          if(theApp.pid_switch!=0) 
						  {
							  switch(i)
							  {
								  case  0://30分
										  if(theApp.rh1_count>=1800)
										  {
											  theApp.low_temp_sw[0]++;
											  if(theApp.low_temp_sw[0]>=100)
											  {
												theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,100+i);
												theApp.low_temp_sw[0]=101;
											    j++;
											  }
										  }
										  break;
								  case  1://30分
										  if(theApp.rh2_count>=1800)
										  {
											  theApp.low_temp_sw[1]++;
											  if(theApp.low_temp_sw[1]>=100)
											  {
												  theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,100+i);
												  theApp.low_temp_sw[1]=101;
												  j++;
											  }
										  }
										  break;
								  case  2://30分
										  if(theApp.rh3_count>=1800)
										  {
											  theApp.low_temp_sw[2]++;
											  if(theApp.low_temp_sw[2]>=100)
											  {
												  theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,100+i);
												  theApp.low_temp_sw[2]=101;
												  j++;
											  }
										  }
										  break;
								  case  3://2小时30分  theApp.sl_count
									      //ts=theApp.hour_run;
										  //ts=ts*60+theApp.minute_run;
										  if(theApp.sl_count>=9000)
										  {
											  theApp.low_temp_sw[3]++;
											  if(theApp.low_temp_sw[3]>=100)
											  {
												  theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,100+i);
												  theApp.low_temp_sw[3]=101;
												  j++;
											  }
										  }
										  break;
							  }

						  }

//					  theApp.yxtask.BitSetChar(theApp.yxtask.krbuf,100+i);
//					  j++;
				  }else 
				  {
					  theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,100+i);
					  theApp.low_temp_sw[i]=0;
				  }
			}else
			{
				  theApp.yxtask.BitClrChar(theApp.yxtask.krbuf,100+i);
			}
		}//for

       
        j=0;
		for(i=0;i<4;i++)
		{//超温状态
			      switch(i)

⌨️ 快捷键说明

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