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

📄 main.c

📁 这个是一个带有IC卡
💻 C
📖 第 1 页 / 共 4 页
字号:
							
							if((*pTermilogVAL).StoreProductNum<LNMAX)
							{
								(*pTermilogVAL).StoreProductNum++;
							}	
											
							//把阁子的属性的产品记录和使用标记进行更新
							(*pTermilogVAL).GeZiList[gezi_num].Use_Flg=1;////此阁子已经被使用了
							
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.TypeofCard=PROD_CARD;////表示此货物是用货物标识卡送进来的
							
							///////修改标记、、、、、
							
							
							for(i=0;i<16;i++)
							{
								DataBfr[i]=MI_ProCard_Block5[i];
							}
						
							//if(PiccAuthE2(KEYA,Card_Snr,0,5)!=OK)	continue;					//验证块5
							//if(PiccRead(5,DataBfr)!=OK)	continue;			
							//read BLOCK5
							
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.DeliveryPouintID=
							(((uint32)DataBfr[0])*256*256*256)+(DataBfr[1]*256*256)+(DataBfr[2]*256)+DataBfr[3];
							//得到发出的机具号码
							
							
							for(i=0;i<16;i++)
							{
								DataBfr[i]=MI_ProCard_Block6[i];
							}
						
							//if(PiccAuthE2(KEYA,Card_Snr,0,6)!=OK)	continue;					//验证块6
							//if(PiccRead(6,DataBfr)!=OK)	continue;			
							//read BLOCK6、、
							
							
							
						
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ReceiverCardID=
							(((uint32)DataBfr[0])*256*256*256)+(DataBfr[1]*256*256)+(DataBfr[2]*256)+DataBfr[3];
							//存入接收者号码
							
											

							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.DeliveryID=
							(((uint32)DataBfr[8])*256*256*256)+(DataBfr[9]*256*256)+(DataBfr[10]*256)+DataBfr[11];
							//此次投递的号码,存入
							
							
							for(i=0;i<16;i++)
							{
								DataBfr[i]=MI_ProCard_Block4[i];
							}
							
							//if(PiccAuthE2(KEYA,Card_Snr,0,4)!=OK)	continue;					//验证块4
							//if(PiccRead(4,DataBfr)!=OK)	continue;			
							//read BLOCK4、、
							
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductCardID=
							(((uint32)DataBfr[1])*256*256*256)+(DataBfr[2]*256*256)+(DataBfr[3]*256)+DataBfr[4];
							//存入此卡的ID号码
							
						
							
							for(i=0;i<16;i++)
							{
								DataBfr[i]=MI_ProCard_Block9[i];
							}
						
							//if(PiccAuthE2(KEYA,Card_Snr,0,9)!=OK)	continue;					//验证块9
							//if(PiccRead(9,DataBfr)!=OK)	continue;			
							//read BLOCK9//得到目标中专站
							


	
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ProductBarCode=
							(((uint32)DataBfr[0])*256*256*256)+(DataBfr[1]*256*256)+(DataBfr[2]*256)+DataBfr[3];
							
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.Weight=DataBfr[4];							
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.Height=DataBfr[5];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.Width=DataBfr[6];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.Depth=DataBfr[7];
						
							
							for(i=0;i<16;i++)
							{
								DataBfr[i]=MI_ProCard_Block10[i];
							}
						
						
							//if(PiccAuthE2(KEYA,Card_Snr,0,10)!=OK)	continue;					//验证块9
							//if(PiccRead(10,DataBfr)!=OK)	continue;			
							//read BLOCK10货物质量保证时间
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.StoreTime.year=DataBfr[0]*256+DataBfr[1];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.StoreTime.month=DataBfr[2];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.StoreTime.day=DataBfr[3];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.StoreTime.hour=DataBfr[4];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.StoreTime.minute=DataBfr[5];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.StoreTime.second=DataBfr[6];
							
							
							for(i=0;i<16;i++)
							{
								DataBfr[i]=MI_ProCard_Block12[i];
							}
							
							//if(PiccAuthE2(KEYA,Card_Snr,0,12)!=OK)	continue;					//验证块9
							//if(PiccRead(12,DataBfr)!=OK)	continue;			
							//read BLOCK12//得到目标中专站
							
							//对货物应该到达时间进行记录
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ArriveTime.year=DataBfr[0]*256+DataBfr[1];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ArriveTime.month=DataBfr[2];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ArriveTime.day=DataBfr[3];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ArriveTime.hour=DataBfr[4];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ArriveTime.minute=DataBfr[5];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ProductProperty.ArriveTime.second=DataBfr[6];
							
							
							
							
							//对到达时间进行记录													
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ArriveTime.year=2000+PCF8563_RdOut_databuf[6];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ArriveTime.month=PCF8563_RdOut_databuf[5];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ArriveTime.day=PCF8563_RdOut_databuf[3];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ArriveTime.hour=PCF8563_RdOut_databuf[2];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ArriveTime.minute=PCF8563_RdOut_databuf[1];
							(*pTermilogVAL).GeZiList[gezi_num].ProductRecord.ArriveTime.second=PCF8563_RdOut_databuf[0];
							
							
							
							//PiccHalt();	///让读卡模块执行挂起操作	
							
							
							
							//在液晶进行提示
							Lcdclear();
							wrzw16x16_string(0,0,"将货物放入:",6);
							wryw16x8_3wei(0,1,gezi_num+1);
							wrzw16x16_string(0,2,"号阁子",3);
							
							
							
							//Open_Door(gezi_num+1);
							Delay_n100MS(8);							
							//Close_ALL_Door();		
												
							//PlaySound_2wei(gezi_num+1);							
							Delay_n100MS(30);
							
													
							
							
						}
												
						if(flg_find==0)//
						{
							Lcdclear();
							wrzw16x16_string(2,1,"体积过大",4);
							wrzw16x16_string(2,2,"或阁子已满",5);
							Delay_n100MS(30);							
						}	
						
						
					}
					
				}
			}
		}
		else 		
			//如果此卡的标识和本系统不匹配,认为是无效卡
		{
			
			Lcdclear();
			wrzw16x16_string(0,1,"警告:",3);
			wrzw16x16_string(1,2,"此卡为无效卡!",7);
			wrzw16x16_string(0,3,"ERR-ID:",7);
			wryw16x8_2wei(14,3,BIAOSHI_ERR);//标识错误			
			
			Delay_n100MS(50);
			
		}		
		Lcdclear();
	}//while(ui8_flg==0)
	
	//EnablePCF8563_IIC_INT();//使能PCF8563的数据读取
	
}

void EnablePCF8563_IIC_INT(void)
{
	
	VICIntEnable = 0x0200;           // 使能I2C中断
}

void DisablePCF8563_IIC_INT(void)
{
	VICIntEnClr = 0x0200;           //禁止I2C中断
}



void Modify_pin(uint32 id,uint8 * p)
{//得到密码放到缓存中
	uint32 tmp32;
	tmp32=((uint32)id)/2+PINBASE;
	*(p+0)=(tmp32%1000000)/100000;
	*(p+1)=(tmp32%100000)/10000;
	*(p+2)=(tmp32%10000)/1000;
	*(p+3)=(tmp32%1000)/100;
	*(p+4)=(tmp32%100)/10;
	*(p+5)=(tmp32%10)/1;
}
void ClrPinBuf(uint8 * p)
{ //清除密码缓存区
	uint8 i;
	for(i=0;i<6;i++)
	{
		*(p+i)=0;
	}	

}



uint8 Check_Pin(uint8 x,uint8 y,uint8 * p)
{//密码正确的时候 返回1,不正确或者 异常退出时都为0
	uint8 i;
	uint8 KEY_rtn;//键盘的返回的值
	uint8 pro_rtn;//本函数的返回的值
	uint8 ucPIN_TMP_BUF[6];
	i=0;
	for(i=0;i<6;i++)
	{
		ucPIN_TMP_BUF[i]=0;
	}
	pro_rtn=0;
	Lcdclear();
	wrzw16x16_string(0,0,"请输入密码",5);
	wryw16x8(10,0,":");	
	wrzw16x16_string(x,y,"------",6);
	KEY_rtn=0xff;
	for(i=0;i<6;i++)//输入六位密码
	{
		while(KEY_rtn==0xff)//当键盘没有任何键按下时
		{
			KEY_rtn=ScanKey();
		}
		if(KEY_rtn==KEY_CANCELL)
		{
			pro_rtn=0;
			break;
		}
		ucPIN_TMP_BUF[i]=KEY_rtn;
		KEY_rtn=0xff;
		wrzw16x16_string(x+i,y,"*",1);
		Delay_n100MS(5);
	}
	if(
		(ucPIN_TMP_BUF[0])==(*(p+0))&&
		(ucPIN_TMP_BUF[1])==(*(p+1))&&
		(ucPIN_TMP_BUF[2])==(*(p+2))&&
		(ucPIN_TMP_BUF[3])==(*(p+3))&&
		(ucPIN_TMP_BUF[4])==(*(p+4))&&
		(ucPIN_TMP_BUF[5])==(*(p+5))
	   )//如果这里比较的结果相等的话
	{
		pro_rtn=1;
	}
	return(pro_rtn);
}

void  MaoPaoPaiXu(uint8 * p,uint8 Count)
{
	uint8 i,j,iTemp;
	for(i=1;i<Count;i++)
	{
		for(j=Count-1;j>i;j--)
		{
			if(p[j]<p[j-1])
			{
				iTemp=p[j-1];
				p[j-1]=p[j];
				p[j]=iTemp;			
			}
		}
	}
}

uint8 Compare_vol(uint8 G_a,uint8 G_b,uint8 G_c,uint8 P_x,uint8 P_y,uint8 P_z)
{//如果柜子的体积比产品的体积大的话返回真值1
//前面的表示柜子的大小,后面的为产品的大小
	uint8 gui_vol[3];
	uint8 pro_vol[3];
	uint8 rtn_val;

	rtn_val=0;

	gui_vol[0]=G_a;
	gui_vol[1]=G_b;
	gui_vol[2]=G_c;

	pro_vol[0]=P_x;
	pro_vol[1]=P_y;
	pro_vol[2]=P_z;

	MaoPaoPaiXu(gui_vol,3);
	MaoPaoPaiXu(pro_vol,3);
	
	if(	(gui_vol[0]>pro_vol[0])&&
		(gui_vol[1]>pro_vol[1])&&
		(gui_vol[2]>pro_vol[2])
	  )
	  {
	  	rtn_val=1;
	  }
	  else
	  {
	  	rtn_val=0;
	  }
	return(rtn_val);	
}


/*******************************************************************************
函数名:Delay_n100MS
功能:延时
作者:潘江长
说明:这个函数以及经过实际测试,i<11000的情况下,基本上为0.1秒  
********************************************************************************/
void  Delay_n100MS(uint32  dly)
{  uint32  i;

   for(; dly>0; dly--) 
      for(i=0; i<11000; i++);
    
}

void  Delay_n10MS(uint32  dly)
{  uint32  i;

   for(; dly>0; dly--) 
      for(i=0; i<1100; i++);
    
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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