CollectData设备采集函数() as Void
dim Ta as integer
dim Tb as integer
dim Tc as string
dim Td as string
dim Te as string
dim Tf as string
dim Va(0) as byte
dim Vb(0) as byte
dim Vc(0) as byte
dim Tg as integer
dim Th as integer
dim Ti as single
dim Tj as integer
Ta= 0
Tb= 0
!ArrayResize( Va , 12)
Va[1]= 0
Va[2]= 1
Va[3]= 2
Va[4]= 3
Va[5]= 4
Va[6]= 5
Va[7]= 6
Va[8]= 7
Va[9]= 8
Va[10]= 9
Va[11]= 0
Va[12]= 0
!SvrGetIntFromByteArr( Va , 2 , Ta , 1)
!ArrayResize( Va , 8)
Va[1]= 设备属性00
Va[2]= 3
Va[3]= 0
Va[4]= 0
Va[5]= 0
Va[6]= 8
Tg= !SvrByteArrayModbusCRC( Va , 1 , 6)
Va[7]= !BitAnd( Tg , 255)
Th= !BitAnd( Tg , 65280)
Va[8]= !BitRShift( Th , 8)
!ArrayResize( Vb , 21)
Tg= !DevWriteAndReadByteArr( Va , 8 , Vb , 21 , 设备属性01)
IF Tg <> 21 THEN
!SetSingleChannelValueByName( "通讯状态" , 2)
EXIT
ENDIF
Ta= 0
!ArrayResize( Vc , 2)
IF Ta < 8 THEN
Vc[1]= Vb[Ta * 2 + 5]
Vc[2]= Vb[Ta * 2 + 4]
Tg= !SvrGetShortFromByteArr( Vc , 1 , Tj , 0)
Ti= Tj
!SetSingleChannelValueByNum( Ta + Tb + 2 , Ti)
Ta= Ta + 1
EndWhile ENDIF
Tb= Tb + Ta
!SetSingleChannelValueByName( "通讯状态" , 0)
EXIT