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

📄 server3.cpp

📁 DCOM 上位机和嵌入式系统通信
💻 CPP
📖 第 1 页 / 共 5 页
字号:
STDMETHODIMP Crjinteface::getTrace(short typ, short *count, short *wno, short *idno, short *rno, DATE *dt, short *addrn)
{
	// TODO: Add your implementation code here
	int i;

	if(typ==1)
	{
      *count=rj_ct;
  	 for(i=0;i<rj_ct;i++)
	 {
       wno[i]=trclst[i].workno;
	   idno[i]=trclst[i].personID;
	   rno[i]=trclst[i].reno;
	   dt[i]=trclst[i].dt;
	   addrn[i]=trclst[i].addrno;
	 }
	}else{
      *count=almct;
  	 for(i=0;i<almct;i++)
	 {
       wno[i]=almtjb[i].workno;
	   idno[i]=almtjb[i].personID;
	   rno[i]=almtjb[i].reno;
	   dt[i]=almtjb[i].dt;
	   addrn[i]=almtjb[i].addrno;
	 }
	}
	return S_OK;
}

STDMETHODIMP Crjinteface::getRenoTrace(short rno,short *count, short *wno, short *idno, DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;
     j=0;
     for(i=0;i<rj_ct;i++)
	 {
	    if(trclst[i].reno==rno)
		{
         wno[j]=trclst[i].workno;
	     idno[j]=trclst[i].personID;
	     dt[j]=trclst[i].dt;
//	     addrn[i]=trclst[i].addrno;
		 j++;
		}
	 }
	 *count=j;
	return S_OK;
}
STDMETHODIMP Crjinteface::getupdown(short *count, short *wno, short *idno, DATE *downdt, DATE *updt,short *dw_rno, short *up_rno,short *tag)
{
	// TODO: Add your implementation code here
    int i;

	  *count=upct;
	  for(i=0;i<upct;i++)
	  {
		  wno[i]=uptjb[i].workno;

		  idno[i]=uptjb[i].personID;
		  downdt[i]=uptjb[i].downdtm;
		  updt[i]=uptjb[i].updtm;
		  dw_rno[i]=uptjb[i].dw_rno;
		  up_rno[i]=uptjb[i].up_rno;
		  tag[i]=uptjb[i].tag;
	  }
	return S_OK;
}
STDMETHODIMP Crjinteface::getFiledPersonCT(short addr, short *count)
{
	// TODO: Add your implementation code here
  int i,j;

    j=0;
    for(i=0;i<prst.count;i++)
	{
       if(addr!=0)
	   {
	      if(perstmb[prst.pl[i].rfid].addrno==addr)
		     j++;
	      if((perstmb[prst.pl[i].rfidbak].addrno==addr)&&(prst.pl[i].rfidbak!=0))
		     j++;
	   }else{
	      if((perstmb[prst.pl[i].rfid].entrytm!=0)&&(checklocal(prst.pl[i].rfid)==0))
		     j++;
	      if((perstmb[prst.pl[i].rfidbak].entrytm!=0)&&(prst.pl[i].rfidbak!=0)&&(checklocal(prst.pl[i].rfidbak)==0))
		     j++;
	   }
	}
	*count=j;
	return S_OK;
}
short Crjinteface::checklocal(short rid)
{
   int i;
   for(i=0;i<adlst.count;i++)
   {
	  if(perstmb[rid].addrno==adlst.addr[i].addrno)
		  return adlst.addr[i].addtyp;
   }
   return 1;
}

STDMETHODIMP Crjinteface::getFieldPerson(short addr, short *count, short *wno, short *idno, short *rno,DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;

    j=0;
    for(i=0;i<prst.count;i++)
	{
       if(addr!=0)
	   {
	      if(perstmb[prst.pl[i].rfid].addrno==addr)
		  {
             wno[j]=prst.pl[i].workno;
		     idno[j]=prst.pl[i].rfid;
		     dt[j]=perstmb[prst.pl[i].rfid].localtm;
		     rno[j]=perstmb[prst.pl[i].rfid].lastreno;
		     j++;
		  }
	      if((perstmb[prst.pl[i].rfidbak].addrno==addr)&&(prst.pl[i].rfidbak!=0))
		  {
             wno[j]=prst.pl[i].workno;
		     idno[j]=prst.pl[i].rfidbak;
		     dt[j]=perstmb[prst.pl[i].rfidbak].localtm;
		     rno[j]=perstmb[prst.pl[i].rfidbak].lastreno;
		     j++;
		  }
	   }else{
	      if((perstmb[prst.pl[i].rfid].entrytm!=0)&&(checklocal(prst.pl[i].rfid)==0))
		  {
             wno[j]=prst.pl[i].workno;
		     idno[j]=prst.pl[i].rfid;
		     dt[j]=perstmb[prst.pl[i].rfid].localtm;
		     rno[j]=perstmb[prst.pl[i].rfid].lastreno;
		     j++;
		  }
	      if((perstmb[prst.pl[i].rfidbak].entrytm!=0)&&(prst.pl[i].rfidbak!=0)&&(checklocal(prst.pl[i].rfidbak)==0))
		  {
             wno[j]=prst.pl[i].workno;
		     idno[j]=prst.pl[i].rfidbak;
		     dt[j]=perstmb[prst.pl[i].rfidbak].localtm;
		     rno[j]=perstmb[prst.pl[i].rfidbak].lastreno;
		     j++;
		  }
	   }
	}
	*count=j;
	return S_OK;
}

STDMETHODIMP Crjinteface::getPassRecord(short reno, short *count, short *wno, short *idno,short *addr, DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;
    
    j=0;
    for(i=0;i<rj_ct;i++)
	{
	  if(trclst[i].reno==reno)
	  {
		  wno[j]=trclst[i].workno;
		  idno[j]=trclst[i].personID;
		  dt[j]=trclst[i].dt;
		  addr[j]=trclst[i].addrno;
		  j++;
	  }
	}
	*count=j;
	return S_OK;
}
STDMETHODIMP Crjinteface::getdowntime(short typ, short t, short *count, short *wno, short *idno, DATE *downdt,  short *dw_rno, short *addrno, DATE *dt, short *rno)
//STDMETHODIMP Crjinteface::getdowntime(short typ, short t, short *count, short *wno, short *idno, DATE *downdt, short *addrno, DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;
  SYSTEMTIME pdt;
  DATE currentdt;
  short rfid,rfidbak;

    j=0;
   	GetLocalTime(&pdt);
	currentdt=dateCal(pdt.wYear,pdt.wMonth,pdt.wDay,pdt.wHour,pdt.wMinute,pdt.wSecond);
    for(i=0;i<prst.count;i++)
	{
	   rfid=prst.pl[i].rfid;
	   rfidbak=prst.pl[i].rfidbak;
	   if(perstmb[rfid].entrytm!=0)
	   {
		  double ddt=currentdt-perstmb[rfid].entrytm;
		  if(typ==0)
		  {
			if(ddt<(double)t/24.0)
			{
				wno[j]=prst.pl[i].workno;
				idno[j]=rfid;
				downdt[j]=perstmb[rfid].entrytm;
				dw_rno[j]=perstmb[rfid].dw_rno;
				addrno[j]=perstmb[rfid].addrno;
				rno[j]=perstmb[rfid].lastreno;
				dt[j]=perstmb[rfid].localtm;
				j++;
			}
		  }else{
			if(ddt>=(double)t/24.0)
			{
				wno[j]=prst.pl[i].workno;
				idno[j]=rfid;
				downdt[j]=perstmb[rfid].entrytm;
				dw_rno[j]=perstmb[rfid].dw_rno;
				addrno[j]=perstmb[rfid].addrno;
				rno[j]=perstmb[rfid].lastreno;
				dt[j]=perstmb[rfid].localtm;
				j++;
			}
		  }
	   }
	   if((perstmb[rfidbak].entrytm!=0)&&(rfidbak!=0))
	   {
		  double ddt=currentdt-perstmb[rfidbak].entrytm;
		  if(typ==0)
		  {
			if(ddt<(double)t/24.0)
			{
				wno[j]=prst.pl[i].workno;
				idno[j]=rfidbak;
				downdt[j]=perstmb[rfidbak].entrytm;
				dw_rno[j]=perstmb[rfidbak].dw_rno;
				addrno[j]=perstmb[rfidbak].addrno;
				rno[j]=perstmb[rfidbak].lastreno;
				dt[j]=perstmb[rfidbak].localtm;
				j++;
			}
		  }else{
			if(ddt>=(double)t/24.0)
			{
				wno[j]=prst.pl[i].workno;
				idno[j]=rfidbak;
				downdt[j]=perstmb[rfidbak].entrytm;
				dw_rno[j]=perstmb[rfidbak].dw_rno;
				addrno[j]=perstmb[rfidbak].addrno;
				rno[j]=perstmb[rfidbak].lastreno;
				dt[j]=perstmb[rfidbak].localtm;
				j++;
			}
		  }
	   }
	}
	*count=j;
	return S_OK;
}
STDMETHODIMP Crjinteface::getPasstime(short *count, short *wno, short *idno, DATE *downdt, short *dw_rno, short *addrno,DATE *dt, short *rno)
//STDMETHODIMP Crjinteface::getPasstime(short *count, short *wno, short *idno, DATE *downdt, short *addrno, DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;
  SYSTEMTIME pdt;
  DATE currentdt;
  short rfid,rfidbak;

    j=0;
   	GetLocalTime(&pdt);
	currentdt=dateCal(pdt.wYear,pdt.wMonth,pdt.wDay,pdt.wHour,pdt.wMinute,pdt.wSecond);
    for(i=0;i<prst.count;i++)
	{
	   rfid=prst.pl[i].rfid;
	   rfidbak=prst.pl[i].rfidbak;
	   if(perstmb[rfid].entrytm!=0)
	   {
		   double ddt=currentdt-perstmb[rfid].entrytm;
		   if(ddt>=(double)prst.pl[i].validtime/24.0)
		   {
				wno[j]=prst.pl[i].workno;
				idno[j]=rfid;
				downdt[j]=perstmb[rfid].entrytm;
				dw_rno[j]=perstmb[rfid].dw_rno;
				addrno[j]=perstmb[rfid].addrno;
				rno[j]=perstmb[rfid].lastreno;
				dt[j]=perstmb[rfid].localtm;
				j++;
		   }
	   }
	   if((perstmb[rfidbak].entrytm!=0)&&(rfidbak!=0))
	   {
		   double ddt=currentdt-perstmb[rfidbak].entrytm;
		   if(ddt>=(double)prst.pl[i].validtime/24.0)
		   {
				wno[j]=prst.pl[i].workno;
				idno[j]=rfidbak;
				downdt[j]=perstmb[rfidbak].entrytm;
				dw_rno[j]=perstmb[rfidbak].dw_rno;
				addrno[j]=perstmb[rfidbak].addrno;
				rno[j]=perstmb[rfidbak].lastreno;
				dt[j]=perstmb[rfidbak].localtm;
				j++;
		   }
	   }
	}
	*count=j;
	passtmct=j;
	return S_OK;
}
STDMETHODIMP Crjinteface::getPasstimeCT(short *count)
//STDMETHODIMP Crjinteface::getPasstime(short *count, short *wno, short *idno, DATE *downdt, short *addrno, DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;
  SYSTEMTIME pdt;
  DATE currentdt;
  short rfid,rfidbak;

    j=0;
   	GetLocalTime(&pdt);
	currentdt=dateCal(pdt.wYear,pdt.wMonth,pdt.wDay,pdt.wHour,pdt.wMinute,pdt.wSecond);
    for(i=0;i<prst.count;i++)
	{
	   rfid=prst.pl[i].rfid;
	   rfidbak=prst.pl[i].rfidbak;
	   if(perstmb[rfid].entrytm!=0)
	   {
		   double ddt=currentdt-perstmb[rfid].entrytm;
		   if(ddt>=(double)prst.pl[i].validtime/24.0)
				j++;
	   }
	   if((perstmb[rfidbak].entrytm!=0)&&(rfidbak!=0))
	   {
		   double ddt=currentdt-perstmb[rfidbak].entrytm;
		   if(ddt>=(double)prst.pl[i].validtime/24.0)
				j++;
	   }
	}
	*count=j;
	passtmct=j;
	return S_OK;
}

STDMETHODIMP Crjinteface::getOneInfo(short wno, short *idno, short *addr, short *rno, DATE *dt, DATE *downdt, DATE *updt)
{
	// TODO: Add your implementation code here
  int i;
  short id;

 	 *idno=0;
	 *addr=0;
    for(i=0;i<prst.count;i++)
	 {
        if(prst.pl[i].workno==wno)
		{
			id=prst.pl[i].rfid;
			if(prst.pl[i].rfidbak!=0)
			{
			  if(perstmb[prst.pl[i].rfidbak].entrytm!=0)
			      id=prst.pl[i].rfidbak;
			  else if((perstmb[id].entrytm==0)&&(perstmb[prst.pl[i].rfidbak].exittm>perstmb[id].exittm))
					        id=prst.pl[i].rfidbak;
			}
			*idno=id;
			*addr=perstmb[id].addrno;
			*dt=perstmb[id].localtm;
			*downdt=perstmb[id].entrytm;
			*updt=perstmb[id].exittm;
			*rno=perstmb[id].lastreno;
	        break;
		}
	 }
	return S_OK;
}

STDMETHODIMP Crjinteface::getOnetrace(short wno, short *count, short *idno, short *reno, short *addrno, DATE *dt)
{
	// TODO: Add your implementation code here
  int i,j;
//  short id;

 	j=0;
    for(i=0;i<rj_ct;i++)
	 {
        if(trclst[i].workno==wno)
		{
			idno[j]=trclst[i].personID;
			reno[j]=trclst[i].reno;
			addrno[j]=trclst[i].addrno;
            dt[j]=trclst[i].dt;
			j++;
		}
	 }
	*count=j;
	return S_OK;

	return S_OK;
}

STDMETHODIMP Crjinteface::personTab_add(LPSTR name,LPSTR depart,short wno,
										short rfid,int lampno,
										short rfidbak,int lampnobak,
										short prioty,short monthct,
										short validt,short *rb)
{
	// TODO: Add your implementation code here
    int j,i=0;
	  *rb=1;
      while((i<prst.count)&&(prst.pl[i].workno!=wno))
		  i++;
	  if((i>=prst.count)&&(i<4096))
	  {
		  prst.pl[i].workno=wno;
		  prst.pl[i].rfid=rfid;
		  prst.pl[i].workno=wno;
		  prst.pl[i].lampno=lampno;
		  prst.pl[i].rfidbak=rfidbak;
		  prst.pl[i].lampnobak=lampnobak;
		  prst.pl[i].monthct=monthct;
		  prst.pl[i].validtime=validt;
		  for(j=0;j<16;j++)
             prst.pl[i].name[j]=name[j];
		  for(j=0;j<16;j++)
             prst.pl[i].depart[j]=depart[j];
		  prst.count++;
		  *rb=0;
	  }

	return S_OK;
}

STDMETHODIMP Crjinteface::personTab_del(short wno, short *rb)
{
	// TODO: Add your implementation code here
    int j,i=0;
	  *rb=1;
      while((i<prst.count)&&(prst.pl[i].workno!=wno))
		  i++;
	  if(i<prst.count)
	  {
  	      Server2::setEventRecord(10,prst.pl[i].workno,prst.pl[i].rfid);
          for(j=i;j<prst.count;j++)
			  prst.pl[j]=prst.pl[j+1];
		  prst.count--;
		  *rb=0;
	  }

	return S_OK;
}

STDMETHODIMP Crjinteface::personTab_mod(short wno,LPSTR name,LPSTR depart,
										short rfid,int lampno,
										short rfidbak,int lampnobak,
										short prioty,short monthct,
										short validt,short *rb)
{   //prioty为修改前的人员工号
	// TODO: Add your implementation code here
    int j,i=0;
	  *rb=1;
      while((i<prst.count)&&(prst.pl[i].workno!=prioty))
		  i++;
	  if(i<prst.count)
	  {
		  prst.pl[i].rfid=rfid;
		  prst.pl[i].workno=wno;
		  prst.pl[i].lampno=lampno;
		  prst.pl[i].rfidbak=rfidbak;
		  prst.pl[i].lampnobak=lampnobak;
		  prst.pl[i].monthct=monthct;
		  prst.pl[i].validtime=validt;
		  for(j=0;j<16;j++)
             prst.pl[i].name[j]=name[j];
		  for(j=0;j<16;j++)
             prst.pl[i].depart[j]=depart[j];
  	      Server2::setEventRecord(9,wno,rfid);
		  *rb=0;
	  }
	return S_OK;
}

STDMETHODIMP Crjinteface::sensorTab_add(LPSTR name, short reno, short stype, short alarm, short state, short stno, short dirc, short ref, short *rb)
{
	// TODO: Add your implementation code here
  int i,j;

	  i=0;
      *rb=1;
      while((i<rtinfo.count)&&(rtinfo.st[i].reno!=reno))
		  i++;
	  if((i>=rtinfo.count)&&(i<200))
	  {
		  rtinfo.st[i].reno=reno;
		  rtinfo.st[i].stype=stype;
		  rtinfo.st[i].alarm=alarm;
		  rtinfo.st[i].state=state;
		  rtinfo.st[i].stno=stno;
		  rtinfo.st[i].dirc=dirc-1;
		  rtinfo.st[i].reflg=ref;
		  for(j=0;j<16;j++)
             rtinfo.st[i].name[j]=name[j];
		  rtinfo.count++;
         for(i=0;i<rtinfo.count;i++)
	        File4.flag[rtinfo.st[i].stno]=4;
		  *rb=0;
	  }	
	  return S_OK;
}

STDMETHODIMP Crjinteface::sensorTab_del(short reno, short *rb)
{
	// TODO: Add your implementation code here
	int i,j;
	  i=0;
      *rb=1;
      while((i<rtinfo.count)&&(rtinfo.st[i].reno!=reno))
		  i++;
	  if(i<rtinfo.count)
	  {
  	      Server2::setEventRecord(15,rtinfo.st[i].stno,rtinfo.st[i].dirc);
		  for(j=i;j<rtinfo.count;j++)
            rtinfo.st[j]=rtinfo.st[j+1];
          rtinfo.count--;
		  for(j=0;j<255;j++)
             if(File4.flag[j]==4)  File4.flag[j]=0xff;
          for(j=0;j<rtinfo.count;j++)
	        File4.flag[rtinfo.st[j].stno]=4;
		  *rb=0;
	  }

	return S_OK;
}

STDMETHODIMP Crjinteface::sensorTab_mod(short reno,LPSTR name, short stype, short alarm, short state, short stno, short dirc, short ref, short *rb)
{
	// TODO: Add your implementation code here
  int i,j;

	  i=0;
      *rb=1;
      while((i<rtinfo.count)&&(rtinfo.st[i].reno!=reno))
		  i++;
	  if(i<rtinfo.count)
	  {
		  rtinfo.st[i].stype=stype;

⌨️ 快捷键说明

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