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

📄 irdlg.cpp

📁 Evc 4.0写的
💻 CPP
📖 第 1 页 / 共 3 页
字号:
     if(GetParam_Write(tt,Bs,Bh,Len,nLen))
	 {
        AfxMessageBox(TEXT("Setting success!"));
	 }
	 else
	 {
        AfxMessageBox(TEXT("Setting failure!"));
		return;
	 }
/*
	 Bs[0]=0xc3;
     Bs[1]=0x4f;
     //xie canshu 

	 if (stuFile.Open(S_XL2FILEPATH,CFile::modeRead))
	 {
		
		dwRead = stuFile.Read(ttt,96);
		stuFile.Close();
	 }
	 else  
	 {
        AfxMessageBox(TEXT("Read file error!"));
		stuFile.Close();
		return;
	 }
     tt1=ttt;
     StrToChar(tt1,tt);
     
     Len=24,nLen=3;
     if(GetParam_Write(tt,Bs,Bh,Len,nLen))
	 {
        ;
	 }
	 else
	 {
        AfxMessageBox(TEXT("Setting failure!"));
		return;
	 }
     
     Bs[0]=0xc3;
     Bs[1]=0x21;
	 //xie canshu 
     for(i=0;i<9;i++) ttt[i]='\0';

	 if (stuFile.Open(TYPEFILEPATH,CFile::modeRead))
	 {
		
		dwRead = stuFile.Read(ttt,8);

		//关闭数据文件
		stuFile.Close();
	 }
	 else  
	 {
        AfxMessageBox(TEXT("Read file error!"));
		stuFile.Close();
		return;
	 }
     tt1=ttt;
     StrToChar(tt1,tt);
    
     Len=2,nLen=2;
     if(GetParam_Write(tt,Bs,Bh,Len,nLen))
	 {
        ;
	 }
	 else
	 {
        AfxMessageBox(TEXT("Setting failure!"));
		return;
	 }

	 Bs[0]=0xc3;
     Bs[1]=0x22;
//xie canshu 
     for(i=0;i<9;i++) ttt[i]='\0';

	 if (stuFile.Open(TYPE1FILEPATH,CFile::modeRead))
	 {
		
		dwRead = stuFile.Read(ttt,8);
	
		//关闭数据文件
		stuFile.Close();
	 }
	 else  
	 {
        AfxMessageBox(TEXT("Read file error!"));
		stuFile.Close();
		return;
	 }
     tt1=ttt;
     StrToChar(tt1,tt);
     
     Len=2,nLen=2;
     if(GetParam_Write(tt,Bs,Bh,Len,nLen))
	 {
        AfxMessageBox(TEXT("Setting success!"));
		return ;
	 }
	 else
	 {
        AfxMessageBox(TEXT("Setting failure!"));
		return;
	 }
*/

	}
	
	if(pButton2->GetCheck())//xunxian
	{
     Bs[0]=0xc1;
	 Bs[1]=0x1b;

     //xie canshu 
     CString tt1="";
	 unsigned char tt[12];
     TCHAR ttt[24];

     CFile stuFile;
     int dwRead;

	 if (stuFile.Open(XHFILEPATH,CFile::modeRead))
	 {
		
		dwRead = stuFile.Read(&ttt,48);
		stuFile.Close();
	 }
	 else  
	 {
        AfxMessageBox(TEXT("Read file error!"));
		stuFile.Close();
		return;
	 }

     tt1=ttt;
     StrToChar(tt1,tt);
     unsigned char Len,nLen;
     
     Len=12,nLen=12;
     if(GetParam_Write(tt,Bs,Bh,Len,nLen))
	 {
        AfxMessageBox(TEXT("Setting success!"));
		return ;
	 }
	 else
	 {
        AfxMessageBox(TEXT("Setting failure!"));
		return;
	 }


	}

	if(pButton3->GetCheck())
	{
	  
      
	  CEventR eventData ;
	  CFile stuFile;

	  int k=0;

	  Bs[0]=0xc5;
	  Bs[1]=0x12;

	  if(GetParam_Read(DATA,Bs,Bh))
	  {
      
	   CString strSave;
       UpdateData(FALSE);

	   k=0;
	   for(i=0;i<6;i++)
	   {
		recvbuf[k++]=((Bh[5-i])/16<0x0A)?((Bh[5-i])/16+'0'):((Bh[5-i])/16+'A'-0x0A);
		recvbuf[k++]=(((Bh[5-i])&0x0F)<0x0A)?((Bh[5-i])&0x0F)+'0':((Bh[5-i])&0x0F)+'A'-0x0A;
	   }
	   recvbuf[k]='\0';
	   strSave = (char*)recvbuf;
       m_Bh=strSave;
 
       k=0;
       for(int i=0;i<80;i++)
	   {
		 recvbuf[k++]=((DATA[79-i]-0x33)/16<0x0A)?((DATA[79-i]-0x33)/16+'0'):((DATA[79-i]-0x33)/16+'A'-0x0A);
		 recvbuf[k++]=(((DATA[79-i]-0x33)&0x0F)<0x0A)?((DATA[79-i]-0x33)&0x0F)+'0':((DATA[79-i]-0x33)&0x0F)+'A'-0x0A;
	   }
	   recvbuf[k]='\0';
	   strSave = (char*)recvbuf;
	   		  
	   ZeroMemory(&eventData,sizeof(eventData));

	   wcscpy(eventData.Bh,m_Bh);
	   wcscpy(eventData.cbTime,m_CbTime);

	   wcscpy(eventData.r1st,strSave.Mid(1,2)+"-"+strSave.Mid(3,2)+"-"+strSave.Mid(5,2)+" "+strSave.Mid(7,2));
	   wcscpy(eventData.r1nd,strSave.Mid(9,2)+"-"+strSave.Mid(11,2)+"-"+strSave.Mid(13,2)+" "+strSave.Mid(15,2));
       wcscpy(eventData.r2nd,strSave.Mid(17,2)+"-"+strSave.Mid(19,2)+"-"+strSave.Mid(21,2)+" "+strSave.Mid(23,2));
	   wcscpy(eventData.r2nd,strSave.Mid(25,2)+"-"+strSave.Mid(27,2)+"-"+strSave.Mid(29,2)+" "+strSave.Mid(31,2));
	   wcscpy(eventData.r3nd,strSave.Mid(33,2)+"-"+strSave.Mid(35,2)+"-"+strSave.Mid(37,2)+" "+strSave.Mid(39,2));
	   wcscpy(eventData.r3nd,strSave.Mid(41,2)+"-"+strSave.Mid(43,2)+"-"+strSave.Mid(45,2)+" "+strSave.Mid(47,2));
	   wcscpy(eventData.r4nd,strSave.Mid(49,2)+"-"+strSave.Mid(51,2)+"-"+strSave.Mid(53,2)+" "+strSave.Mid(55,2));
	   wcscpy(eventData.r4nd,strSave.Mid(57,2)+"-"+strSave.Mid(59,2)+"-"+strSave.Mid(61,2)+" "+strSave.Mid(63,2));
	   wcscpy(eventData.r5nd,strSave.Mid(65,2)+"-"+strSave.Mid(67,2)+"-"+strSave.Mid(69,2)+" "+strSave.Mid(71,2));
	   wcscpy(eventData.r5nd,strSave.Mid(73,2)+"-"+strSave.Mid(75,2)+"-"+strSave.Mid(77,2)+" "+strSave.Mid(79,2));
	   wcscpy(eventData.r6nd,strSave.Mid(81,2)+"-"+strSave.Mid(83,2)+"-"+strSave.Mid(85,2)+" "+strSave.Mid(87,2));
	   wcscpy(eventData.r6nd,strSave.Mid(89,2)+"-"+strSave.Mid(91,2)+"-"+strSave.Mid(93,2)+" "+strSave.Mid(95,2));
	   wcscpy(eventData.r7nd,strSave.Mid(97,2)+"-"+strSave.Mid(99,2)+"-"+strSave.Mid(101,2)+" "+strSave.Mid(103,2));
	   wcscpy(eventData.r7nd,strSave.Mid(105,2)+"-"+strSave.Mid(107,2)+"-"+strSave.Mid(109,2)+" "+strSave.Mid(111,2));
	   wcscpy(eventData.r8nd,strSave.Mid(113,2)+"-"+strSave.Mid(115,2)+"-"+strSave.Mid(117,2)+" "+strSave.Mid(119,2));
	   wcscpy(eventData.r8nd,strSave.Mid(121,2)+"-"+strSave.Mid(123,2)+"-"+strSave.Mid(125,2)+" "+strSave.Mid(127,2));
	   wcscpy(eventData.r9nd,strSave.Mid(129,2)+"-"+strSave.Mid(131,2)+"-"+strSave.Mid(133,2)+" "+strSave.Mid(135,2));
	   wcscpy(eventData.r9nd,strSave.Mid(137,2)+"-"+strSave.Mid(139,2)+"-"+strSave.Mid(141,2)+" "+strSave.Mid(143,2));
	   wcscpy(eventData.r10nd,strSave.Mid(145,2)+"-"+strSave.Mid(147,2)+"-"+strSave.Mid(149,2)+" "+strSave.Mid(151,2));
	   wcscpy(eventData.r10nd,strSave.Mid(153,2)+"-"+strSave.Mid(155,2)+"-"+strSave.Mid(157,2)+" "+strSave.Mid(159,2));
	   

	   stuFile.Open(EVENTRFILEPATH,CFile::modeRead | CFile::modeWrite);
	   stuFile.SeekToEnd();
	   stuFile.Write(&eventData,sizeof(eventData));
	   stuFile.Close();
	
	   //AfxMessageBox(TEXT("Communication Success!"));
     }
	 else
	 {
      AfxMessageBox(TEXT("Communication error!"));
	  
      char buffer[20];
	  CString tttttt;
      _itoa( (int)ACKFLAG, buffer, 10 );
      tttttt=(char *)buffer;
      AfxMessageBox(tttttt);

	  return;
	 }

    AfxMessageBox(TEXT("Communication Success!"));
/*
	  k=0;

	  Bs[0]=0xc5;
	  Bs[1]=0x13;

	  if(GetParam_Read(DATA,Bs,Bh))
	  {
      
	   CString strSave;
       UpdateData(FALSE);

	   k=0;
	   for(i=0;i<6;i++)
	   {
		recvbuf[k++]=((Bh[5-i])/16<0x0A)?((Bh[5-i])/16+'0'):((Bh[5-i])/16+'A'-0x0A);
		recvbuf[k++]=(((Bh[5-i])&0x0F)<0x0A)?((Bh[5-i])&0x0F)+'0':((Bh[5-i])&0x0F)+'A'-0x0A;
	   }
	   recvbuf[k]='\0';
	   strSave = (char*)recvbuf;
       m_Bh=strSave;
 
       k=0;
       for(int i=0;i<80;i++)
	   {
		 recvbuf[k++]=((DATA[79-i]-0x33)/16<0x0A)?((DATA[79-i]-0x33)/16+'0'):((DATA[79-i]-0x33)/16+'A'-0x0A);
		 recvbuf[k++]=(((DATA[79-i]-0x33)&0x0F)<0x0A)?((DATA[79-i]-0x33)&0x0F)+'0':((DATA[79-i]-0x33)&0x0F)+'A'-0x0A;
	   }
	   recvbuf[k]='\0';
	   strSave = (char*)recvbuf;
	   		  
	   ZeroMemory(&eventData,sizeof(eventData));

	   wcscpy(eventData.Bh,m_Bh);
	   wcscpy(eventData.cbTime,m_CbTime);

	   wcscpy(eventData.r1st,strSave.Mid(1,2)+"-"+strSave.Mid(3,2)+"-"+strSave.Mid(5,2)+" "+strSave.Mid(7,2));
	   wcscpy(eventData.r1nd,strSave.Mid(9,2)+"-"+strSave.Mid(11,2)+"-"+strSave.Mid(13,2)+" "+strSave.Mid(15,2));
       wcscpy(eventData.r2nd,strSave.Mid(17,2)+"-"+strSave.Mid(19,2)+"-"+strSave.Mid(21,2)+" "+strSave.Mid(23,2));
	   wcscpy(eventData.r2nd,strSave.Mid(25,2)+"-"+strSave.Mid(27,2)+"-"+strSave.Mid(29,2)+" "+strSave.Mid(31,2));
	   wcscpy(eventData.r3nd,strSave.Mid(33,2)+"-"+strSave.Mid(35,2)+"-"+strSave.Mid(37,2)+" "+strSave.Mid(39,2));
	   wcscpy(eventData.r3nd,strSave.Mid(41,2)+"-"+strSave.Mid(43,2)+"-"+strSave.Mid(45,2)+" "+strSave.Mid(47,2));
	   wcscpy(eventData.r4nd,strSave.Mid(49,2)+"-"+strSave.Mid(51,2)+"-"+strSave.Mid(53,2)+" "+strSave.Mid(55,2));
	   wcscpy(eventData.r4nd,strSave.Mid(57,2)+"-"+strSave.Mid(59,2)+"-"+strSave.Mid(61,2)+" "+strSave.Mid(63,2));
	   wcscpy(eventData.r5nd,strSave.Mid(65,2)+"-"+strSave.Mid(67,2)+"-"+strSave.Mid(69,2)+" "+strSave.Mid(71,2));
	   wcscpy(eventData.r5nd,strSave.Mid(73,2)+"-"+strSave.Mid(75,2)+"-"+strSave.Mid(77,2)+" "+strSave.Mid(79,2));
	   wcscpy(eventData.r6nd,strSave.Mid(81,2)+"-"+strSave.Mid(83,2)+"-"+strSave.Mid(85,2)+" "+strSave.Mid(87,2));
	   wcscpy(eventData.r6nd,strSave.Mid(89,2)+"-"+strSave.Mid(91,2)+"-"+strSave.Mid(93,2)+" "+strSave.Mid(95,2));
	   wcscpy(eventData.r7nd,strSave.Mid(97,2)+"-"+strSave.Mid(99,2)+"-"+strSave.Mid(101,2)+" "+strSave.Mid(103,2));
	   wcscpy(eventData.r7nd,strSave.Mid(105,2)+"-"+strSave.Mid(107,2)+"-"+strSave.Mid(109,2)+" "+strSave.Mid(111,2));
	   wcscpy(eventData.r8nd,strSave.Mid(113,2)+"-"+strSave.Mid(115,2)+"-"+strSave.Mid(117,2)+" "+strSave.Mid(119,2));
	   wcscpy(eventData.r8nd,strSave.Mid(121,2)+"-"+strSave.Mid(123,2)+"-"+strSave.Mid(125,2)+" "+strSave.Mid(127,2));
	   wcscpy(eventData.r9nd,strSave.Mid(129,2)+"-"+strSave.Mid(131,2)+"-"+strSave.Mid(133,2)+" "+strSave.Mid(135,2));
	   wcscpy(eventData.r9nd,strSave.Mid(137,2)+"-"+strSave.Mid(139,2)+"-"+strSave.Mid(141,2)+" "+strSave.Mid(143,2));
	   wcscpy(eventData.r10nd,strSave.Mid(145,2)+"-"+strSave.Mid(147,2)+"-"+strSave.Mid(149,2)+" "+strSave.Mid(151,2));
	   wcscpy(eventData.r10nd,strSave.Mid(153,2)+"-"+strSave.Mid(155,2)+"-"+strSave.Mid(157,2)+" "+strSave.Mid(159,2));
	   

	   stuFile.Open(EVENTQFILEPATH,CFile::modeRead | CFile::modeWrite);
	   stuFile.SeekToEnd();
	   stuFile.Write(&eventData,sizeof(eventData));
	   stuFile.Close();
	
	   //AfxMessageBox(TEXT("Communication Success!"));
     }
	 else
	 {
      AfxMessageBox(TEXT("Communication error!"));
	  return;
	 }



	  k=0;

	  Bs[0]=0xc5;
	  Bs[1]=0x14;

	  if(GetParam_Read(DATA,Bs,Bh))
	  {
      
	   CString strSave;
       UpdateData(FALSE);

	   k=0;
	   for(i=0;i<6;i++)
	   {
		recvbuf[k++]=((Bh[5-i])/16<0x0A)?((Bh[5-i])/16+'0'):((Bh[5-i])/16+'A'-0x0A);
		recvbuf[k++]=(((Bh[5-i])&0x0F)<0x0A)?((Bh[5-i])&0x0F)+'0':((Bh[5-i])&0x0F)+'A'-0x0A;
	   }
	   recvbuf[k]='\0';
	   strSave = (char*)recvbuf;
       m_Bh=strSave;
 
       k=0;
       for(int i=0;i<80;i++)
	   {
		 recvbuf[k++]=((DATA[79-i]-0x33)/16<0x0A)?((DATA[79-i]-0x33)/16+'0'):((DATA[79-i]-0x33)/16+'A'-0x0A);
		 recvbuf[k++]=(((DATA[79-i]-0x33)&0x0F)<0x0A)?((DATA[79-i]-0x33)&0x0F)+'0':((DATA[79-i]-0x33)&0x0F)+'A'-0x0A;
	   }
	   recvbuf[k]='\0';
	   strSave = (char*)recvbuf;
	   		  
	   ZeroMemory(&eventData,sizeof(eventData));

	   wcscpy(eventData.Bh,m_Bh);
	   wcscpy(eventData.cbTime,m_CbTime);

	   wcscpy(eventData.r1st,strSave.Mid(1,2)+"-"+strSave.Mid(3,2)+"-"+strSave.Mid(5,2)+" "+strSave.Mid(7,2));
	   wcscpy(eventData.r1nd,strSave.Mid(9,2)+"-"+strSave.Mid(11,2)+"-"+strSave.Mid(13,2)+" "+strSave.Mid(15,2));
       wcscpy(eventData.r2nd,strSave.Mid(17,2)+"-"+strSave.Mid(19,2)+"-"+strSave.Mid(21,2)+" "+strSave.Mid(23,2));
	   wcscpy(eventData.r2nd,strSave.Mid(25,2)+"-"+strSave.Mid(27,2)+"-"+strSave.Mid(29,2)+" "+strSave.Mid(31,2));
	   wcscpy(eventData.r3nd,strSave.Mid(33,2)+"-"+strSave.Mid(35,2)+"-"+strSave.Mid(37,2)+" "+strSave.Mid(39,2));
	   wcscpy(eventData.r3nd,strSave.Mid(41,2)+"-"+strSave.Mid(43,2)+"-"+strSave.Mid(45,2)+" "+strSave.Mid(47,2));
	   wcscpy(eventData.r4nd,strSave.Mid(49,2)+"-"+strSave.Mid(51,2)+"-"+strSave.Mid(53,2)+" "+strSave.Mid(55,2));
	   wcscpy(eventData.r4nd,strSave.Mid(57,2)+"-"+strSave.Mid(59,2)+"-"+strSave.Mid(61,2)+" "+strSave.Mid(63,2));
	   wcscpy(eventData.r5nd,strSave.Mid(65,2)+"-"+strSave.Mid(67,2)+"-"+strSave.Mid(69,2)+" "+strSave.Mid(71,2));
	   wcscpy(eventData.r5nd,strSave.Mid(73,2)+"-"+strSave.Mid(75,2)+"-"+strSave.Mid(77,2)+" "+strSave.Mid(79,2));
	   wcscpy(eventData.r6nd,strSave.Mid(81,2)+"-"+strSave.Mid(83,2)+"-"+strSave.Mid(85,2)+" "+strSave.Mid(87,2));
	   wcscpy(eventData.r6nd,strSave.Mid(89,2)+"-"+strSave.Mid(91,2)+"-"+strSave.Mid(93,2)+" "+strSave.Mid(95,2));
	   wcscpy(eventData.r7nd,strSave.Mid(97,2)+"-"+strSave.Mid(99,2)+"-"+strSave.Mid(101,2)+" "+strSave.Mid(103,2));
	   wcscpy(eventData.r7nd,strSave.Mid(105,2)+"-"+strSave.Mid(107,2)+"-"+strSave.Mid(109,2)+" "+strSave.Mid(111,2));
	   wcscpy(eventData.r8nd,strSave.Mid(113,2)+"-"+strSave.Mid(115,2)+"-"+strSave.Mid(117,2)+" "+strSave.Mid(119,2));
	   wcscpy(eventData.r8nd,strSave.Mid(121,2)+"-"+strSave.Mid(123,2)+"-"+strSave.Mid(125,2)+" "+strSave.Mid(127,2));
	   wcscpy(eventData.r9nd,strSave.Mid(129,2)+"-"+strSave.Mid(131,2)+"-"+strSave.Mid(133,2)+" "+strSave.Mid(135,2));
	   wcscpy(eventData.r9nd,strSave.Mid(137,2)+"-"+strSave.Mid(139,2)+"-"+strSave.Mid(141,2)+" "+strSave.Mid(143,2));
	   wcscpy(eventData.r10nd,strSave.Mid(145,2)+"-"+strSave.Mid(147,2)+"-"+strSave.Mid(149,2)+" "+strSave.Mid(151,2));
	   wcscpy(eventData.r10nd,strSave.Mid(153,2)+"-"+strSave.Mid(155,2)+"-"+strSave.Mid(157,2)+" "+strSave.Mid(159,2));
	   

	   stuFile.Open(EVENTKFILEPATH,CFile::modeRead | CFile::modeWrite);
	   stuFile.SeekToEnd();
	   stuFile.Write(&eventData,sizeof(eventData));
	   stuFile.Close();
	
	   AfxMessageBox(TEXT("Communication Success!"));
     }
	 else
	 {
      AfxMessageBox(TEXT("Communication error!"));
	 
	 }
*/

	}
	return;
}


BOOL CIRDlg::DestroyWindow() 
{
	if(!Disconnect()) AfxMessageBox(TEXT("Close serial port error"));
	return CDialog::DestroyWindow();
}

void CIRDlg::StrToChar(CString temp,unsigned char *tt)
{
 int  i;
 unsigned char temp1[48];
 int t=lstrlen(temp)/2;

 AfxMessageBox(temp);

 for(i=0;i<t;i++)
 { 

  if(temp[2*i]>=0x30&&temp[2*i]<0x3a)
  {
    temp1[2*i]=(temp[2*i]-0x30)*16;
  }
  else
   if(temp[2*i]>=0x41&&temp[2*i]<0x5C)
  {
    temp1[2*i]=(temp[2*i]-0x37)*16; 
  }
   else
   {
     temp1[2*i]=(temp[2*i]-0x57)*16; 
   }

  if(temp[2*i+1]>=0x30&&temp[2*i+1]<0x3a)
  {
    temp1[2*i+1]=temp[2*i+1]-0x30;
  }
  else
   if(temp[2*i+1]>=0x41&&temp[2*i+1]<0x5C)
  {
    temp1[2*i+1]=temp[2*i+1]-0x37; 
  }
   else
   {
     temp1[2*i+1]=temp[2*i+1]-0x57; 
   }

   tt[i]=temp1[2*i]+temp1[2*i+1];
 }
  /* 
   CString strSave;
   BYTE recvbuf[50];

   int k=0; 
   for(i=0;i<24;i++)
	{
		recvbuf[k++]=((tt[23-i])/16<0x0A)?((tt[23-i])/16+'0'):((tt[23-i])/16+'A'-0x0A);
		recvbuf[k++]=(((tt[23-i])&0x0F)<0x0A)?((tt[23-i])&0x0F)+'0':((tt[23-i])&0x0F)+'A'-0x0A;
   }
    recvbuf[k]='\0';
	strSave = (char*)recvbuf;
    AfxMessageBox(strSave);
*/
  
}

CString  CIRDlg::FormatTime(CString temp)
{
  int  i;
  unsigned char temp1[20];
  int t=lstrlen(temp);

  for(i=0;i<t;i++)
  { 
   if(temp[i]==' '&&i!=10)
   {
    temp1[i]='0';
   }
   else
   {
    temp1[i]=(unsigned char )temp[i];
   }
  }
  temp1[i]='\0';

  return temp1;
}

⌨️ 快捷键说明

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