📄 devicebase03.cpp
字号:
{
char xxinfo[100];
wsprintf(xxinfo,"ID=%ld\n",*KnID);
MessageBox( NULL,xxinfo,"写入数据显示窗口",0);
}
//设置为加密方式
errno=Set_modecode(modejmzc);
if(errno!=0) return errcase(errno);
//告之读卡密码
zhuansz=faxingmm;
numtostr(&zhuansz,zhuanzf);
errno=Set_pass(zhuanzf);
if(errno!=0) return errcase(errno);
//读卡
errno=rd_dat(1,7,rdbuff);
if(errno!=0) return errcase(errno);
Set_pass(mm_clear);
Set_modecode(modezc);
//校验卡密码
if(*(unsigned int *)&rdbuff[24]!=*(unsigned int *)zhuanzf)
return errcase(0x10); //卡未加密
if(rdbuff[0]!=0xf4) return 10; //不是检查卡
//* KnID=0;
*nDrvID=0;
errno=JckFenXi(rdbuff,jcsj);
if(errno==0) *nDrvID=jcsj->blbNum;
return(errno);
}
//读功能卡
int CDeviceBase03::DKxRdjckEx(long * KnCs, //返回功能卡控制码
long * nDrvID, //返回表版本号
struct JCCZSJ * jcsj //返回表内数据
)
{
BYTE zhuanzf[10];
int errno,zhuansz;
//设置为加密方式
errno=Set_modecode(modejmzc);
if(errno!=0) return errcase(errno);
//告之读卡密码
zhuansz=faxingmm;
numtostr(&zhuansz,zhuanzf);
errno=Set_pass(zhuanzf);
if(errno!=0) return errcase(errno);
//读卡
errno=rd_dat(1,7,rdbuff);
if(errno!=0) return errcase(errno);
Set_pass(mm_clear);
Set_modecode(modezc);
//校验卡密码
if(*(unsigned int *)&rdbuff[24]!=*(unsigned int *)zhuanzf)
return errcase(0x10); //卡未加密
if(rdbuff[0]!=0xf4) return 10; //不是功能卡
* KnCs=rdbuff[1]*256+rdbuff[2];
errno=JckFenXi(rdbuff,jcsj);
if(errno==0) *nDrvID=jcsj->blbNum;
return(errno);
}
//翻译表内特征码
int CDeviceBase03::DKxGetDrvErrMsg(long DrvID, //表版本号
long * cwdm, //错误代码
long * cwdj, //错误等级
BYTE * cwmsg //错误信息
)
{
char sTemp[500]={0x00,0x00};
BYTE ncwdj[20],sDrvMsg[20][30];
int i,errno;
for(i=0;i<nEnableNumGs;i++)
{
if(nEnableNum[i]==DrvID) break;
}
if(i==nEnableNumGs) return 0x102; //设备不存在
for(i=0;i<20;i++)
{
ncwdj[i]=0;
strcpy((char *)sDrvMsg[i],"");
}
/**********************************
错误等级意义
0:没有出现错误信息
1:可忽略和不显示的错误信息
2:较严重的错误信息
***********************************/
switch(DrvID)
{
case 430001001: //气表
case 430001002:
ncwdj[0]=2;
strcpy((char *)sDrvMsg[0],"余额值<=0标志。");
ncwdj[1]=2;
strcpy((char *)sDrvMsg[1],"干扰标志。");
ncwdj[2]=2;
strcpy((char *)sDrvMsg[2],"失电标志。");
ncwdj[3]=2;
strcpy((char *)sDrvMsg[3],"计量开关错标志。");
ncwdj[4]=2;
strcpy((char *)sDrvMsg[4],"读过换表卡。");
ncwdj[5]=2;
strcpy((char *)sDrvMsg[5],"读过检测卡。");
ncwdj[6]=1;
strcpy((char *)sDrvMsg[6],"计量标志。");
ncwdj[8]=1;
strcpy((char *)sDrvMsg[8],"应缴费标志。");
ncwdj[9]=2;
strcpy((char *)sDrvMsg[9],"消费次数错标志。");
break;
case 430002001: //电表
ncwdj[0]=2;
strcpy((char *)sDrvMsg[0],"余额值<=0标志。");
ncwdj[1]=2;
strcpy((char *)sDrvMsg[1],"窃电标志。");
ncwdj[2]=2;
strcpy((char *)sDrvMsg[2],"计量开关错标志。");
ncwdj[3]=2;
strcpy((char *)sDrvMsg[3],"反转标志。");
ncwdj[4]=1;
strcpy((char *)sDrvMsg[4],"10度报警关阀标志。");
ncwdj[5]=1;
strcpy((char *)sDrvMsg[5],"常显标志。");
ncwdj[6]=1;
strcpy((char *)sDrvMsg[6],"计量标志。");
ncwdj[7]=2;
strcpy((char *)sDrvMsg[7],"校验标志。");
ncwdj[8]=1;
strcpy((char *)sDrvMsg[8],"三相电表开关反向标志。");
ncwdj[9]=2;
strcpy((char *)sDrvMsg[9],"消费次数错。");
break;
case 430003001: //水表
ncwdj[0]=2;
strcpy((char *)sDrvMsg[0],"余额值<=0标志。");
ncwdj[1]=2;
strcpy((char *)sDrvMsg[1],"干扰标志。");
ncwdj[2]=2;
strcpy((char *)sDrvMsg[2],"失电标志。");
ncwdj[4]=2;
strcpy((char *)sDrvMsg[4],"读过换表卡。");
ncwdj[5]=2;
strcpy((char *)sDrvMsg[5],"读过检测卡。");
ncwdj[8]=1;
strcpy((char *)sDrvMsg[8],"应缴费标志。");
ncwdj[9]=2;
strcpy((char *)sDrvMsg[9],"消费次数错标志。");
break;
case 430004001: //计时表
ncwdj[0]=2;
strcpy((char *)sDrvMsg[0],"余额值<=0标志。");
ncwdj[2]=2;
strcpy((char *)sDrvMsg[2],"失电标志。");
ncwdj[9]=2;
strcpy((char *)sDrvMsg[9],"消费次数错标志。");
break;
}
//特征码分析
errno=1;
for(i=0;i<15;i++)
{
if((*cwdm & errno) && (ncwdj[i]>0 && ncwdj[i]>=*cwdj))
{
wsprintf(sTemp,"%s\n%s",sTemp,sDrvMsg[i]);
}
errno*=2;
}
for (i=0;i<256;i++)
{
if(sTemp[i]==0)
{
cwmsg[i]=0;
break;
}
else
cwmsg[i]=sTemp[i];
}
if(i>=255) cwmsg[255]=0;
return 0;
}
int CDeviceBase03::DKxLockXfk(long KnID, long yhmm)
{
return 1;
/*
char xxinfo[200];
BYTE zhuanzf[10],modezc[10]={0x00,0x08,0x8c,0xe8},modejmzc[10]={0x00,0x08,0x8e,0xf8};
int errno,zhuansz;
wsprintf(xxinfo,"KnID=%ld,mima=%ld",KnID,yhmm);
if(testview)
MessageBox( NULL,xxinfo,"写入数据显示窗口",0);
zhuansz=m_YhmmCoding(yhmm);
numtostr(&zhuansz,zhuanzf);
errno=Set_modecode(modejmzc);
if (errno!=0)
return errcase(errno);
errno=Set_pass(zhuanzf);
if (errno!=0)
return errcase(errno);
errno=wr_lock(0);
if (errno!=0)
return errcase(errno);
errno=wr_lock(7);
if (errno!=0)
return errcase(errno);
// Set_pass(mm_clear);
Set_modecode(modezc);
return 0;
*/
}
int CDeviceBase03::DKxResetXfk(long KnID, long yhmm)
{
return 1;
/*
char xxinfo[200];
BYTE wrbuff[100],rdbuff[100],zhuanzf[10],modezc[10]={0x00,0x08,0x8c,0xe8},modejmzc[10]={0x00,0x08,0x8e,0xf8};
int errno,zhuansz,ii;
wsprintf(xxinfo,"KnID=%ld,mima=%ld",KnID,yhmm);
if(testview)
MessageBox( NULL,xxinfo,"写入数据显示窗口",0);
for(ii=0;ii<50;ii++)
wrbuff[ii]=0x00;
wrbuff[0]=0x13;
wrbuff[1]=0x13;
wrbuff[2]=0x13;
wrbuff[3]=0x13;
wrbuff[07]=0x00;
wrbuff[11]=0x00;
wrbuff[15]=0x00;
wrbuff[19]=0x00;
zhuansz=m_YhmmCoding(yhmm);
numtostr(&zhuansz,zhuanzf);
errno=Set_modecode(modejmzc);
if (errno!=0)
return errcase(errno);
errno=Set_pass(zhuanzf);
if (errno!=0)
return errcase(errno);
errno=wr_dat(1,6,wrbuff);
if (errno!=0)
return errcase(errno);
errno=rd_dat(1,6,rdbuff);
if (errno!=0)
return 1;
for(ii=0;ii<24;ii++)
{
if(wrbuff[ii]!=rdbuff[ii])
return 1;
}
// Set_pass(mm_clear);
Set_modecode(modezc);
return 0;
*/
}
int CDeviceBase03::DKxGetCardDate(long * carddate)
{
return 6;
/*
char xxinfo[200];
BYTE rdbuff[100],zhuanzf[10],modezc[10]={0x00,0x08,0x8c,0xe8},modejmzc[10]={0x00,0x08,0x8e,0xf8};
int errno,zhuansz,bcdyear,bcdmonth,bcdday;
wsprintf(xxinfo,"Date=%ld\n", *carddate);
if(testview)
MessageBox( NULL,xxinfo,"写入数据显示窗口",0);
errno=Set_modecode(modejmzc);
if (errno!=0)
return errcase(errno);
zhuansz=faxingmm;
numtostr(&zhuansz,zhuanzf);
errno=Set_pass(zhuanzf);
if (errno!=0)
return errcase(errno);
errno=rd_dat(1,7,rdbuff);
if (errno!=0)
return errcase(errno);
bcdyear=(rdbuff[20]/16)*10+rdbuff[20]%16;
bcdmonth=(rdbuff[10]/16)*10+rdbuff[10]%16;
bcdday=(rdbuff[11]/16)*10+rdbuff[11]%16;
*carddate=bcdyear*0x10000+bcdmonth*0x100+bcdday;
return 0;
*/
}
int CDeviceBase03::DKxSetCardDate(long * carddate)
{
return 1;
/*
char xxinfo[200];
BYTE wrbuff[100],rdbuff[100],zhuanzf[10],modezc[10]={0x00,0x08,0x8c,0xe8},modejmzc[10]={0x00,0x08,0x8e,0xf8};
int ii,errno,zhuansz,nCheckNum;
wsprintf(xxinfo,"Date=%ld\n", *carddate);
if(testview)
MessageBox( NULL,xxinfo,"写入数据显示窗口",0);
errno=Set_modecode(modejmzc);
if (errno!=0)
return errcase(errno);
zhuansz=faxingmm;
numtostr(&zhuansz,zhuanzf);
errno=Set_pass(zhuanzf);
if (errno!=0)
return errcase(errno);
errno=rd_dat(1,7,wrbuff);
if (errno!=0)
return errcase(errno);
nCheckNum=0;
for(ii=0;ii<23;ii++)
{
nCheckNum+=wrbuff[ii];
}
if(!((wrbuff[0]==0xf1)||(wrbuff[1]==0xf1)||(wrbuff[2]==0xf1)||(wrbuff[3]==0xf1)))
return 10; //卡标志错误
if((nCheckNum % 0x100)!=wrbuff[23])
return 12; //读卡校验和错
wrbuff[11]= (*carddate)%0x100;
wrbuff[10]=(*carddate/0x100)%0x100;
wrbuff[20]=(*carddate/0x10000)%0x100;
wrbuff[11]=(wrbuff[11]/10)%10*16+wrbuff[11]%10;
wrbuff[10]=(wrbuff[10]/10)%10*16+wrbuff[10]%10;
wrbuff[20]=(wrbuff[20]/10)%10*16+wrbuff[20]%10;
nCheckNum=0;
for(ii=0;ii<23;ii++)
{
nCheckNum+=wrbuff[ii];
}
wrbuff[23]=nCheckNum%256;
errno=wr_dat(1,6,wrbuff);
if (errno!=0)
return errcase(errno);
errno=rd_dat(1,6,rdbuff);
if (errno!=0)
return 1;
for(ii=0;ii<24;ii++)
{
if(wrbuff[ii]!=rdbuff[ii])
return 1;
}
Set_pass(mm_clear);
Set_modecode(modezc);
return errcase(errno);
*/
}
//制作换表卡
int CDeviceBase03::DKxZhbc(void)
{
BYTE zhuanzf[10];
int i,errno,zhuansz;
//准备写卡数据
wrbuff[0]=0xE3;
wrbuff[1]=0x00;
wrbuff[2]=0x00;
wrbuff[3]=0xE3;
for(i=4;i<50;i++) wrbuff[i]=0x00;
zhuansz=faxingmm;
numtostr(&zhuansz,zhuanzf);
for(i=0;i<4;i++) wrbuff[24+i]=zhuanzf[i];
//将空卡新制成加密卡
errno=makenewcard(wrbuff);
return errno;
}
//卡检测
int CDeviceBase03::testcard(void)
{
int i,j,errno;
BYTE testdata[4]={0x00,0x55,0xAA,0xFF};
BYTE mm[4];
for(j=0;j<4;j++)
{
for(i=0;i<28;i++) wrbuff[i]=testdata[j];
for(i=0;i<4;i++) mm[i]=testdata[j];
//将空卡新制成加密卡,数据存储在wrbuff[]中
errno=makenewcard(wrbuff);
if(errno!=0) return errno;
//将加密卡清空,参数:卡密码
errno=clearjmcard(mm);
if(errno!=0) return errno;
}
return 0;
}
//清空卡检测失败后的卡
int CDeviceBase03::cleartestcard(void)
{
int i,j,errno;
BYTE testdata[4]={0x00,0x55,0xAA,0xFF};
BYTE mm[4];
for(j=0;j<4;j++)
{
for(i=0;i<4;i++) mm[i]=testdata[j];
//将加密卡清空,参数:卡密码
errno=clearjmcard(mm);
if(errno==0) return 0;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -