*ole1:MSCOMM32控件;
*SuperTracker:是一个接在串口上的设备;
*chr()中的值是该设备的指令。
Para nnnserr=0
Thisform.ole1.Output=Chr(2)+Chr(6)+Chr(3)
ltime=Datetime()
Do Whil Thisform.ole1.InBufferCount=0
If Datetime()-ltime>12
=msg("警告","得不到SuperTracker的控制信号。","!O")
Thisform.ole1.portopen=.F.
serr=1
Retu
Endif
Enddo
mscomm=Thisform.ole1.Input
If Str(mscomm(1),1)+Str(mscomm(2),1)+Str(mscomm(3),1)<>'263'
=msg("警告","得不到SuperTracker的控制信号。","!O")
Thisform.ole1.portopen=.F.
serr=1
Retu
Endif
Do Case
Case nnn=1
Thisform.ole1.Output=Chr(2)+Chr(35)+Chr(83)+Chr(3)
Case nnn=2
Thisform.ole1.Output=Chr(2)+Chr(35)+Chr(85)+Chr(3)
Case nnn=3
Thisform.ole1.Output=Chr(2)+Chr(35)+Chr(66)+Chr(3)
Endcase
ltime=Datetime()
Do Whil Thisform.ole1.InBufferCount=0
If Datetime()-ltime>20
=msg("警告","得不到SuperTracker的控制信号。","!O")
Thisform.ole1.portopen=.F.
serr=1
Retu
Endif
Enddo
mscomm=Thisform.ole1.Input
If Str(mscomm(1),1)+Str(mscomm(2),1)+Str(mscomm(3),1)<>'263'
Do Case
Case nnn=1
=msg("警告","SuperTracker无法进卡。","!O")
Case nnn=2
=msg("警告","SuperTracker卡在里面。","!O")
Case nnn=3
=msg("警告","SuperTracker卡在出口处。","!O")
Endcase
Thisform.ole1.portopen=.F.
serr=1
Retu
Endif