K
KingSoft
Unregistered / Unconfirmed
GUEST, unregistred user!
***********通讯接口表单,在WINDOWS系统目录下须有MSCOMM32。OCX控件************
CLOSE ALL
RELEASE ALL
_CGH=thisform.jgsj.value
if _cgh>60.OR._cgh<1
thisform.TX.caption="间隔时间应在1-60分钟之间"
return
endif
if file('timetzk.dbf')
use timetzk
replace time with _cgh,gh with thisform.khcode.value
use
endif
thiscom=thisform.combo1.value
&&**********从串口或采集器采集数据*************
&&******通讯端口初始化*********
thisform.com.commport=thiscom
thisform.com.settings="9600,N,8,2"
thisform.com.inputlen=1
thisform.com.portopen=.T.
if thisform.com.portopen=.F.
thisform.TX.caption="通讯口错误,请到控制面板检查存在的通讯口"
return
endif
thisform.com.outbuffercount=0
thisform.com.inbuffercount=0
thisform.TX.caption="开始传送间隔时间"
for i=1 to 100
thisform.com.inbuffercount=0
thisform.com.output=createb(chr(249)+chr(249))
if thisform.kgetc(40)=1
exit
endif
endfor
if i=101
thisform.TX.caption='通讯错误,考勤机是否开启或考勤机无此功能!'
else
kps=chr(_cgh)+chr(_cgh)
thisform.com.output=createb(kps)
kgc=thisform.kgetc(1000)
if kgc#_cgh
thisform.TX.caption="传送不正常,请重操作!"
thisform.com.portopen=.f.
thisform._kcomrev=2
close all
return
endif
thisform.TX.caption='打卡间隔时间传送正常!'
endif
=inkey(2)
thisform.TX.caption='现传送时间调整卡号!'
_CGH=thisform.khcode.value
=inkey(1)
for i=1 to 100
thisform.com.inbuffercount=0
thisform.com.output=createb(chr(246)+chr(246))
if thisform.kgetc(40)=1
exit
endif
endfor
if i=101
thisform.TX.caption='通讯错误,考勤机是否开启或考勤机无此功能!'
else
knum=0
for i=1 to 6
kpc=asc(subs(_cgh,i,1))
knum=(knum+kpc)%256
endfor
kps=_cgh+chr(242)+chr(knum)
thisform.com.output=createb(kps)
kgc=thisform.kgetc(1000)
if kgc#knum
thisform.TX.caption="传送不正常,请重操作!"
thisform.com.portopen=.f.
thisform._kcomrev=2
close all
return
endif
thisform.TX.caption="时间调整卡号传送正常完成!"
endif
=inkey(2)
thisform.TX.caption='传送完成!'
thisform._kcomrev=1
thisform.com.portopen=.f.
close all
return
function kgetc(_kgetwms)
para _kgetwms
if thisform.com.inbuffercount>0
kgetins=thisform.com.input
return kgetins
endif
_kgetns=secon()+_kgetwms/1000
do while _kgetns>seco()
if thisform.com.inbuffercount>0
kgetins=thisform.com.input
return kgetins
endif
enddo
return -1
CLOSE ALL
RELEASE ALL
_CGH=thisform.jgsj.value
if _cgh>60.OR._cgh<1
thisform.TX.caption="间隔时间应在1-60分钟之间"
return
endif
if file('timetzk.dbf')
use timetzk
replace time with _cgh,gh with thisform.khcode.value
use
endif
thiscom=thisform.combo1.value
&&**********从串口或采集器采集数据*************
&&******通讯端口初始化*********
thisform.com.commport=thiscom
thisform.com.settings="9600,N,8,2"
thisform.com.inputlen=1
thisform.com.portopen=.T.
if thisform.com.portopen=.F.
thisform.TX.caption="通讯口错误,请到控制面板检查存在的通讯口"
return
endif
thisform.com.outbuffercount=0
thisform.com.inbuffercount=0
thisform.TX.caption="开始传送间隔时间"
for i=1 to 100
thisform.com.inbuffercount=0
thisform.com.output=createb(chr(249)+chr(249))
if thisform.kgetc(40)=1
exit
endif
endfor
if i=101
thisform.TX.caption='通讯错误,考勤机是否开启或考勤机无此功能!'
else
kps=chr(_cgh)+chr(_cgh)
thisform.com.output=createb(kps)
kgc=thisform.kgetc(1000)
if kgc#_cgh
thisform.TX.caption="传送不正常,请重操作!"
thisform.com.portopen=.f.
thisform._kcomrev=2
close all
return
endif
thisform.TX.caption='打卡间隔时间传送正常!'
endif
=inkey(2)
thisform.TX.caption='现传送时间调整卡号!'
_CGH=thisform.khcode.value
=inkey(1)
for i=1 to 100
thisform.com.inbuffercount=0
thisform.com.output=createb(chr(246)+chr(246))
if thisform.kgetc(40)=1
exit
endif
endfor
if i=101
thisform.TX.caption='通讯错误,考勤机是否开启或考勤机无此功能!'
else
knum=0
for i=1 to 6
kpc=asc(subs(_cgh,i,1))
knum=(knum+kpc)%256
endfor
kps=_cgh+chr(242)+chr(knum)
thisform.com.output=createb(kps)
kgc=thisform.kgetc(1000)
if kgc#knum
thisform.TX.caption="传送不正常,请重操作!"
thisform.com.portopen=.f.
thisform._kcomrev=2
close all
return
endif
thisform.TX.caption="时间调整卡号传送正常完成!"
endif
=inkey(2)
thisform.TX.caption='传送完成!'
thisform._kcomrev=1
thisform.com.portopen=.f.
close all
return
function kgetc(_kgetwms)
para _kgetwms
if thisform.com.inbuffercount>0
kgetins=thisform.com.input
return kgetins
endif
_kgetns=secon()+_kgetwms/1000
do while _kgetns>seco()
if thisform.com.inbuffercount>0
kgetins=thisform.com.input
return kgetins
endif
enddo
return -1