早期的dt900源码

来源:互联网 发布:淘宝拍卖的和田玉 编辑:程序博客网 时间:2024/06/10 03:39

 #include /<stdio.h/>
#include /<stdlib.h/>
#include /<itron.h/>
#include /<string.h/>
#include /<CMNDEF.H/>
/*#include /<machine.h/>*/
#include /<bios1mac.h/>
#include /<math.h/>
/*#include /<hashlib.h/> */
#include "casio.h"

void main_menu(void);
void main_jy(void);

ER sjmpd(UB *pinpai1,UB *sctime1,UB *sjm1,UB *spcode1);
ER xhpd(UB *xhfw,UB *xh,UB *spcode);
ER shijianpd(UB *pftime,UB *sctime,UB *spcode);
void trim(char *str);
void buling(char *str);
ER find(UB *scc,UB *pinpai,UB *sctime,UB *xsd,UB *xh,UB *pftime);
ap_start ( )
{
SysInit(0);
main_menu();

/* exit(0); */
}
void main_menu(void)
{ char kind;

static const UB *menu[]={" 烟 草 ",
" 1. 检验",
" 2.下载文件",
" 3.下载信息文件",
" 4.上传文件"
};
while(1)
{
cls();
Dsp_str(menu[0],1,0);
Dsp_str(menu[1],3,0);
Dsp_str(menu[2],5,0);
Dsp_str(menu[3],7,0);
Dsp_str(menu[4],9,0);

kind=getkey();
switch(kind)
{ case '1':
if(Is_file("pp.txt")==0 && Is_file("item.txt")==0)
{
main_jy();
break;
}

case '2': { B *file_list2[]={"item.txt",0};
lcd_cls();

Dsp_str("ENT 下载",5,3);
Dsp_str("任意键 取消",7,3);
kind=getkey();
if(kind==13)
{


rece_n_file(file_list2);
break;
}

}
case '3': { B *file_list2[]={"pp.txt","sccs.txt","xsd.txt",0};
lcd_cls();

Dsp_str("ENT 下载",5,3);
Dsp_str("任意键 取消",7,3);
kind=getkey();
if(kind==13)

rece_n_file(file_list2);
break;}


case '4': { B *file_list2[]={"stock.txt",0};
lcd_cls();

Dsp_str("ENT 上传",5,3);
Dsp_str("任意键 取消",7,3);
kind=getkey();
if(kind==13)
{


send_n_file(file_list2);
break;
}

}

/*case 12:exit(0);*/
}
}
}
void main_jy(void)
{
UB scc[4],pinpai[5],scriqi[7],xsd[4],xhfw[9],pfriqi[7],xh[5];
UB csname[21],csdata[25],pinpainame[21],pinpaidata[26],xsdname[21],xsddata[26];
UB spcode[31],dxtm[31],jxd[6];
UB scyear[5],scmonth[3],scday[3],pfyear[5],pfmonth[3],pfday[3];
UB sctime[7],pftime[7];
UB sjm[11],iil[7],data[17],reco[33],code[40];
ER ret,ret1;
long ii;
W pos,fpos;

while(1)
{
cls();
Dsp_str("输入经销点代码",1,0);
memset(jxd,0x00,sizeof(jxd));
ret=read_s(3,0,0,jxd,5,NONE); /* 经 销 点 */
if(ret==CLS) return;
while(1)
{
cls();
Dsp_str("扫描",1,0);
memset(spcode,0x00,sizeof(spcode));
ret=read_s(3,0,0,spcode,30,NONE);
if(ret==CLS) break;

memset(scc,0x00,sizeof(scc)); /* 生 产 厂 */
memset(pinpai,0x00,sizeof(pinpai)); /* 品 牌 */
memset(xsd,0x00,sizeof(xsd)); /* 销 售 地 */

memset(sctime,0x00,sizeof(sctime)); /* 生 产 日 期 */
memset(pftime,0x00,sizeof(pftime)); /* 批 发 日 期 */
memset(sjm,0x00,sizeof(sjm)); /* 随 机 码 */
memset(iil,0x00,sizeof(iil));
memset(xh,0x00,sizeof(xh));

memcpy(scc,spcode,3); /* 生 产 厂 */
memcpy(pinpai,spcode+3,4); /* 品 牌 */
memcpy(sctime,spcode+7,6); /* 生 产 日 期 */
memcpy(xsd,spcode+13,3); /* 销 售 地 */
memcpy(xh,spcode+16,4); /* 序 号 */
memcpy(sjm,spcode+20,10); /* 随 机 码 */

memset(data,0x00,sizeof(data)); /* 基 础 信 息 */
memcpy(data,spcode,16);

 


ret=search("item.txt",0,32,0,16,data,reco,&pos);
if(ret!=0)
{
cls();
Dsp_str("不 存 在!",5,0);
WAIT
continue;
}
memset(xhfw,0x00,sizeof(xhfw));
memset(pftime,0x00,sizeof(pftime));

memcpy(xhfw,reco+16,8);
memcpy(pftime,reco+24,6);
ret=sjmpd(pinpai,sctime,sjm,spcode); /*判断随机号*/
if(ret!=0)
{
cls();
Dsp_str("伪码!!",5,0);
WAIT
continue;
}
ret=xhpd(xhfw,xh,spcode); /*判断序号*/
if(ret!=0)
{
cls();
Dsp_str("伪码!!",5,0);
WAIT
continue;
}
ret=shijianpd(pftime,sctime,spcode); /*时间判断*/
if(ret!=0)
{
ret1= find(scc,pinpai,sctime,xsd,xh,pftime);
Dsp_str("伪码",9,0);
WAIT
continue;
}
else
{
ret1= find(scc,pinpai,sctime,xsd,xh,pftime);
Dsp_str("真",9,0);
WAIT
memset(code,0x00,sizeof(code));
memcpy(code,jxd,5);
memcpy(code+5,spcode,30);
code[35]=0x0d;
code[36]=0x0a;
dat_F_Write("stock.txt",1,0,code,37);
s_sound(2500,7);
s_sound(3000,4);
continue;
}

 

} /* end while */


} /* end while*/
}

ER sjmpd(UB *pinpai1,UB *sctime1,UB *sjm1,UB *spcode1)
{
UB temp[11],ymp[11],temp1[11],temp2[11];
ER ret;
W pos;
double ii,il;
int i;
ii=atof(pinpai1)*1024+atof(sctime1)*12.3;
memset(temp,0x00,sizeof(temp));
memset(temp1,0x00,sizeof(temp1));
memset(temp2,0x00,sizeof(temp2));
sprintf(temp,"%10.0f",ii);
sprintf(temp1,"%10.0f",atof(sctime1)*12.3);
sprintf(temp2,"%10.0f",atof(pinpai1)*1024);
/*trim((char*)temp1);
trim((char*)temp2);*/
trim((char*)temp);


cls();
/* Dsp_str(pinpai1,1,0);
Dsp_str(sctime1,1,10);
Dsp_str(temp1,3,0);
Dsp_str(temp2,5,0);
Dsp_str(temp,7,0);
WAIT*/
if(memcmp(temp,sjm1,10)==0)
{/* Dsp_str("asdfghj",9,0);
WAIT*/
return(0);
}
else
return(1);

 

}
void trim(char *str)
{ int i;
for(i=0;i if(str>'9' || str<'0')
str='1';
}
ER xhpd(UB *xhfw,UB *xh,UB *spcode)
{
UB maxxh[5],minxh[5];
memset(maxxh,0x00,sizeof(maxxh));
memset(minxh,0x00,sizeof(minxh));

memcpy(minxh,xhfw,4);
memcpy(maxxh,xhfw+4,4);
/*cls();
Dsp_str(maxxh,1,0);
Dsp_str(minxh,3,0);
Dsp_str(xh,5,0);
WAIT*/

if(atoi(xh)atoi(minxh))
return(0);
else
return(1);
}
ER shijianpd(UB *pftime,UB *sctime,UB *spcode)
{UB date1[10],time1[20];
UB datepf[10],datezf[10],datesc[10];
memset(date1,0x00,sizeof(date1));
memset(time1,0x00,sizeof(time1));
get_date_str(date1,time1);


memset(datepf,0x00,sizeof(datepf));
memset(datezf,0x00,sizeof(datezf));
memset(datesc,0x00,sizeof(datesc));

memcpy(datesc,"20",2);
memcpy(datesc+2,sctime,6);
memcpy(datepf,"20",2);
memcpy(datepf+2,pftime,6);
buling((char*)date1);
memcpy(datezf,date1,8);
/*cls();
Dsp_str(datepf,1,0);
Dsp_str(datesc,3,0);
Dsp_str(datezf,5,0);
WAIT*/

 


if(atof(datezf)>atof(datepf) && atof(datesc) return(0);
else
return(1);


}
void buling(char *str)
{ int i;
for(i=0;i if(str>'9' || str<'0')
str='0';
}

ER find(UB *scc,UB *pinpai,UB *sctime,UB *xsd,UB *xh,UB *pftime)
{ UB csname[21],csdata[25],pinpainame[21],pinpaidata[26],xsdname[21],xsddata[26];
UB pfyear[5],pfmonth[5],pfday[5];
UB scyear[5],scmonth[5],scday[5];
UB reco[30];
ER ret1;
W pos;
while(1)
{
memset(reco,0x00,sizeof(reco));
ret1=search("sccs.txt",0,25,0,3,scc,reco,&pos);
if(ret1==0)
memcpy(csname,reco+3,16);
else
memcpy(csname,"无",2);

memset(reco,0x00,sizeof(reco));
ret1=search("pp.txt",0,26,0,4,pinpai,reco,&pos);
if(ret1==0)
memcpy(pinpainame,reco+4,16);
else
memcpy(pinpainame,"无",2);

memset(reco,0x00,sizeof(reco));
ret1=search("xsd.txt",0,25,0,4,xsd,reco,&pos);
if(ret1==0)
memcpy(xsdname,reco+3,16);
else
memcpy(xsdname,"无",2);

memset(pfyear,0x00,sizeof(pfyear));
memset(pfmonth,0x00,sizeof(pfmonth));
memset(pfday,0x00,sizeof(pfday));

memcpy(pfyear,"20",2);
memcpy(pfyear+2,pftime,2);

memcpy(pfmonth,pftime+2,2);
memcpy(pfday,pftime+4,2);

cls();
Dsp_str("生产厂",1,0);
Dsp_str(csname,3,0);
Dsp_str("品牌",5,0);
Dsp_str(pinpainame,5,5);
Dsp_str("批发日期",7,0);
Dsp_str(pfyear,9,0);
Dsp_str("年",9,5);
Dsp_str(pfmonth,9,7);
Dsp_str("月",9,9);
Dsp_str(pfday,9,11);
Dsp_str("日",9,14);
WAIT
cls();
memset(scyear,0x00,sizeof(scyear));
memset(scmonth,0x00,sizeof(scmonth));
memset(scday,0x00,sizeof(scday));

memcpy(scyear,"20",2);
memcpy(scyear+2,sctime,2);

memcpy(scmonth,sctime+2,2);
memcpy(scday,sctime+4,2);
Dsp_str("销售地",1,0);
Dsp_str(xsdname,3,0);
Dsp_str("生产日期",5,0);
Dsp_str(scyear,7,0);
Dsp_str("年",7,5);
Dsp_str(scmonth,7,7);
Dsp_str("月",7,9);
Dsp_str(scday,7,11);
Dsp_str("日",7,14);
return(0);
}
}

原创粉丝点击