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

📄 hmican_usbdlg.cpp

📁 面板显示程序
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			for(int i=0;i<28;i++)
			{
				if(theApp.alarm[i])
					pList->AddString(theApp.almlist[i]);
			}
		}
		else
		{
			for(int i=0;i<28;i++)
			{
				if(theApp.alarm[i])
					pList->AddString(theApp.almlist[i]);
			}		
		}
	}
//////
	CDialog::OnTimer(nIDEvent);
}

void CHMIcan_usbDlg::show()
{
//	for(int i=0;i<=500;i++)
//	{
		PeekAndPump();
		m_cProgress1.SetPos(prog1);
		m_cProgress2.SetPos(prog2);
		m_cProgress3.SetPos(prog3);
//	}
}

BOOL PeekAndPump()
{
	static MSG msg;
	while(::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
	{
		if(!AfxGetApp()->PumpMessage()){
			::PostQuitMessage(0);
			return FALSE;
		}
	}
	return TRUE;
}

UINT CHMIcan_usbDlg::ReceiveThread(void *param)
{
	CHMIcan_usbDlg *dlg=(CHMIcan_usbDlg*)param;
	
	VCI_CAN_OBJ frameinfo[50];
	int k;
	VCI_ERR_INFO errinfo;
	int len=1;
	CString showstr;
	CString str,tmpstr,frameid;
		
	while(1)
	{
		///////////////////

		//人工触发数组
		bool man[17];
		for(int jj=0;jj<17;jj++)
		{
			man[jj] = false;
		}
		/////////////////
		Sleep(3);
		if(theApp.m_connect==0)
			break;
		len=VCI_Receive(theApp.m_devtype,theApp.m_devind,theApp.m_cannum,frameinfo,50,200);
    /*		dlg->m_speed="N/A";
		dlg->m_torque="N/A";	
		dlg->m_high="N/A";
		dlg->m_ingastemp="N/A";
		dlg->m_ingaspress="N/A";
		dlg->m_outtemp="N/A";
		dlg->m_nh3temp="N/A";
		dlg->m_watertemp="N/A";
		dlg->m_intemp="N/A";
		dlg->m_pumpdose="N/A";
		dlg->m_pumpstate="N/A";*/
	if(len<=0)
		{
			//注意:如果没有读到数据则必须调用此函数来读取出当前的错误码,
			//千万不能省略这一步(即使你可能不想知道错误码是什么)
			VCI_ReadErrInfo(theApp.m_devtype,theApp.m_devind,theApp.m_cannum,&errinfo);
		}
		else
		{
			for(k=0;k<len;k++)
			{
				int tempid=0;
				frameid.Format("%08x",frameinfo[k].ID);
				frameid.MakeLower();
				tempid = atoi(frameid);
				str="帧ID:"+frameid;
				///////////////////////////////////////////////////////////////////////
				str+="  数据:";
				if(frameinfo[k].DataLen>8)
					frameinfo[k].DataLen=8;
				for(int j=0;j<frameinfo[k].DataLen;j++)
				{
					tmpstr.Format("%02x ",frameinfo[k].Data[j]);
					str+=tmpstr;						
				}
																			
				///////////////////////////////////////////////////////////////////////	
				//0x01000000	控制权
				if(tempid == 1000000 )
				{
					//[63   ]位代表控制权:0表示ACU,1表示BCU
					/////7是最低位   0是最高位
					theApp.SndRevChar0.c7 = frameinfo[k].Data[0];
					theApp.SndRevChar0.c6 = frameinfo[k].Data[1];
					theApp.SndRevChar0.c5 = frameinfo[k].Data[2];
					theApp.SndRevChar0.c4 = frameinfo[k].Data[3];
					theApp.SndRevChar0.c3 = frameinfo[k].Data[4];
					theApp.SndRevChar0.c2 = frameinfo[k].Data[5];
					theApp.SndRevChar0.c1 = frameinfo[k].Data[6];
					theApp.SndRevChar0.c0 = frameinfo[k].Data[7];
					//////收集到第一条信息
					if(!dlg->GetAll)
					{
						dlg->GetInfo[0] = true;
					}
					////////解码
					if(theApp.ID0.ID0_63 == 0)
					{						
						//ACU为主控
						theApp.ACUisMain=true;
						dlg->GetDlgItem(IDC_ACU_BCU)->SetWindowText("ACU IN CONTROL");
						theApp.Temp = theApp.ID0.ID0_0_7;
						theApp.Load = theApp.ID0.ID0_8_15;
						theApp.Speed = theApp.ID0.ID0_16_23;
					/*	if(theApp.ACUisMain)
						{
							//赋值显示
							showstr.Format("%d",theApp.Speed);
							dlg->GetDlgItem(IDC_N_NUM)->SetWindowText(showstr);
							dlg->GetDlgItem(IDC_EDIT_N)->SetWindowText(showstr);
							showstr.Format("%d",theApp.Load);
							dlg->GetDlgItem(IDC_POIL_NUM)->SetWindowText(showstr);
							dlg->GetDlgItem(IDC_EDIT_INC)->SetWindowText(showstr);
							showstr.Format("%d",theApp.Temp);
							dlg->GetDlgItem(IDC_MEP_NUM)->SetWindowText(showstr);
							dlg->GetDlgItem(IDC_EDIT_TOIL)->SetWindowText(showstr);
						}	
						*/
					}
					else
					{
						//BCU为主控
						theApp.ACUisMain=false;
						dlg->GetDlgItem(IDC_ACU_BCU)->SetWindowText("BCU IN CONTROL");
						theApp.TempB = theApp.ID0.ID0_0_7;
						theApp.LoadB = theApp.ID0.ID0_8_15;
						theApp.SpeedB = theApp.ID0.ID0_16_23;
					/*	if(!theApp.ACUisMain)
						{
							//赋值显示
							showstr.Format("%d",theApp.SpeedB);
							dlg->GetDlgItem(IDC_N_NUM)->SetWindowText(showstr);
							dlg->GetDlgItem(IDC_EDIT_N)->SetWindowText(showstr);
							showstr.Format("%d",theApp.LoadB);
							dlg->GetDlgItem(IDC_POIL_NUM)->SetWindowText(showstr);
							dlg->GetDlgItem(IDC_EDIT_INC)->SetWindowText(showstr);
							showstr.Format("%d",theApp.TempB);
							dlg->GetDlgItem(IDC_MEP_NUM)->SetWindowText(showstr);
							dlg->GetDlgItem(IDC_EDIT_TOIL)->SetWindowText(showstr);
						}	
						*/
					}
				}
				//ACU发来的帧
				else if(tempid>=1000001 && tempid<=1000007) 
				{
					    switch (tempid) 
						{ 
							
							//报警
							//[63:28]位为保留位 [27: 0]位分别代表ALRM1-28报警代码有无报警,0有无报警,1为有报警

						case 1000001: 
							{ 
								/*for(int m=0;m<8;m++)
								{
									BYTE tmp = 1 << m;
									dlg->alarm[m] = tmp & frameinfo[k].Data[7];
								}
								for(int l=8;l<16;l++)
								{
									BYTE tmp = 1 << l-8;
									dlg->alarm[l] = tmp & frameinfo[k].Data[6];
								}
								for(int p=16;p<24;p++)
								{
									BYTE tmp = 1 << p-16;
									dlg->alarm[p] = tmp & frameinfo[k].Data[5];
								}
								for(int n=24;n<29;n++)
								{
									BYTE tmp = 1 << n-24;
									dlg->alarm[n] = tmp & frameinfo[k].Data[4];
								}*/
								/////7是最低位   0是最高位
								theApp.SndRevChar1.c7 = frameinfo[k].Data[0];
								theApp.SndRevChar1.c6 = frameinfo[k].Data[1];
								theApp.SndRevChar1.c5 = frameinfo[k].Data[2];
								theApp.SndRevChar1.c4 = frameinfo[k].Data[3];
								theApp.SndRevChar1.c3 = frameinfo[k].Data[4];
								theApp.SndRevChar1.c2 = frameinfo[k].Data[5];
								theApp.SndRevChar1.c1 = frameinfo[k].Data[6];
								theApp.SndRevChar1.c0 = frameinfo[k].Data[7];
								if(theApp.ID1.ID1_0 == 1)
								{
									//0有报警
									theApp.alarm[0] = true;
								}
								if(theApp.ID1.ID1_1 == 1)
								{
									//1有报警
									theApp.alarm[1] = true;
								}
								if(theApp.ID1.ID1_2 == 1)
								{
									//2有报警
									theApp.alarm[2] = true;
								}
								if(theApp.ID1.ID1_3 == 1)
								{
									//3有报警
									theApp.alarm[3] = true;
								}
								if(theApp.ID1.ID1_4 == 1)
								{
									//4有报警
									theApp.alarm[4] = true;
								}
								if(theApp.ID1.ID1_5 == 1)
								{
									//5有报警
									theApp.alarm[5] = true;
								}
								if(theApp.ID1.ID1_6 == 1)
								{
									//6有报警
									theApp.alarm[6] = true;
								}
								if(theApp.ID1.ID1_7 == 1)
								{
									//7有报警
									theApp.alarm[7] = true;
								}
								if(theApp.ID1.ID1_8 == 1)
								{
									//8有报警
									theApp.alarm[8] = true;
								}
								if(theApp.ID1.ID1_9 == 1)
								{
									//9有报警
									theApp.alarm[9] = true;
								}
								if(theApp.ID1.ID1_10 == 1)
								{
									//10有报警
									theApp.alarm[10] = true;
								}
								if(theApp.ID1.ID1_11 == 1)
								{
									//11有报警
									theApp.alarm[11] = true;
								}
								if(theApp.ID1.ID1_12 == 1)
								{
									//12有报警
									theApp.alarm[12] = true;
								}
								if(theApp.ID1.ID1_13 == 1)
								{
									//13有报警
									theApp.alarm[13] = true;
								}
								if(theApp.ID1.ID1_14 == 1)
								{
									//14有报警
									theApp.alarm[14] = true;
								}
								if(theApp.ID1.ID1_15 == 1)
								{
									//15有报警
									theApp.alarm[15] = true;
								}
								if(theApp.ID1.ID1_16 == 1)
								{
									//16有报警
									theApp.alarm[16] = true;
								}
								if(theApp.ID1.ID1_17 == 1)
								{
									//17有报警
									theApp.alarm[17] = true;
								}
								if(theApp.ID1.ID1_18 == 1)
								{
									//18有报警
									theApp.alarm[18] = true;
								}
								if(theApp.ID1.ID1_19 == 1)
								{
									//19有报警
									theApp.alarm[19] = true;
								}
								if(theApp.ID1.ID1_20 == 1)
								{
									//20有报警
									theApp.alarm[20] = true;
								}
								if(theApp.ID1.ID1_21 == 1)
								{
									//21有报警
									theApp.alarm[21] = true;
								}
								if(theApp.ID1.ID1_22 == 1)
								{
									//22有报警
									theApp.alarm[22] = true;
								}
								if(theApp.ID1.ID1_23 == 1)
								{
									//23有报警
									theApp.alarm[23] = true;
								}
								if(theApp.ID1.ID1_24 == 1)
								{
									//24有报警
									theApp.alarm[24] = true;
								}
								if(theApp.ID1.ID1_25 == 1)
								{
									//25有报警
									theApp.alarm[25] = true;
								}
								if(theApp.ID1.ID1_26 == 1)
								{
									//26有报警
									theApp.alarm[26] = true;
								}
								if(theApp.ID1.ID1_27 == 1)
								{
									//27有报警
									theApp.alarm[27] = true;
								}
								
								break; 
							} 
							//缸的总注油次数
							//[63:60]位代表缸号(0~15) [59:28]位表示对应缸的总注油次数 [27: 0]位为保留位
						case 1000002: 
							{
								/////7是最低位   0是最高位
								theApp.SndRevChar2.c7 = frameinfo[k].Data[0];
								theApp.SndRevChar2.c6 = frameinfo[k].Data[1];
								theApp.SndRevChar2.c5 = frameinfo[k].Data[2];
								theApp.SndRevChar2.c4 = frameinfo[k].Data[3];
								theApp.SndRevChar2.c3 = frameinfo[k].Data[4];
								theApp.SndRevChar2.c2 = frameinfo[k].Data[5];
								theApp.SndRevChar2.c1 = frameinfo[k].Data[6];
								theApp.SndRevChar2.c0 = frameinfo[k].Data[7];
								//缸号
								int cno = theApp.ID2.ID2_60_63;
								//对应缸的总注油次数
								float hvalue = theApp.ID2.ID2_32_38/10.0;
								int inoilcount = theApp.ID2.ID2_0_31;
								theApp.ICount[cno] = inoilcount;
								
								for(int a=0;a<16;a++)
								{
									if(a == cno )
									{
										theApp.InOil[a] = inoilcount;     ////累加对应缸总注油次数
										theApp.h[a] = hvalue;
									}
								}
								theApp.InOilAllCount = 0;
								for(int i = 0;i<16;i++)
								{
									theApp.InOilAllCount = theApp.InOilAllCount+theApp.InOil[i];
								}
								
								showstr.Format("%d",theApp.InOilAllCount);
								dlg->GetDlgItem(IDC_EDIT_SPM)->SetWindowText(showstr);
								
								
								break; 
							} 
							//缸动作延迟时间 [63   ]位代表缸号范围:0表示(0~7)缸,1表示(8~15)缸
						case 1000003: 
							{
								
								/////7是最低位   0是最高位
								theApp.SndRevChar3.c7 = frameinfo[k].Data[0];
								theApp.SndRevChar3.c6 = frameinfo[k].Data[1];
								theApp.SndRevChar3.c5 = frameinfo[k].Data[2];
								theApp.SndRevChar3.c4 = frameinfo[k].Data[3];
								theApp.SndRevChar3.c3 = frameinfo[k].Data[4];
								theApp.SndRevChar3.c2 = frameinfo[k].Data[5];
								theApp.SndRevChar3.c1 = frameinf

⌨️ 快捷键说明

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