发布于 2013-11-16 16:59:52
11楼
这是ANY类型的结构,我也正在学,最近做了一台设备,程序是老外给的模板,他的数据转换和处理全是这种结构编的,程序读起来太费劲了,跟帖学习中!
//Generate Pointer to Drive Outputs
OPN #iDriveIntfcDB
L DBNO
T #tDriveIntfcDBNum
LAR1 P##tOutputsPointer
L B#16#10 // 10 hex = S7 Data Type
T LB [AR1,P#0.0] // Transfer to Source pointer byte 0
L B#16#2 // 2 hex = byte data type
T LB [AR1,P#1.0] // Transfer to Source pointer byte 1
L 24 // How many bytes to move
T LW [AR1,P#2.0] // Transfer to Source pointer bytes 2-3
L #tDriveIntfcDBNum // Load DB Number
T LW [AR1,P#4.0] // Transfer to Source pointer bytes 4-5
L 172 // Load start address of data
SLD 3 // Shift data in AR1 3 bits to the left
T LD [AR1,P#6.0] // Trasfer to Source Pointer bytes 6-9
L B#16#84 // 84 hex = DB memory area
T LB [AR1,P#6.0] // Transfer to Source pointer byte 6
//Transfer Outputs From Drive Interface DB To Local Copy
CALL SFC 20
SRCBLK :=#tOutputsPointer
RET_VAL:=#tRet
DSTBLK :=#tDriveIntfc.Output
//Generate Pointer to Drive Inputs In Drive Interface DB
LAR1 P##tInputsPointer
L B#16#10 // 10 hex = S7 Data Type
T LB [AR1,P#0.0] // Transfer to Source pointer byte 0
L B#16#2 // 2 hex = byte data type
T LB [AR1,P#1.0] // Transfer to Source pointer byte 1
L 14 // How many bytes to move
T LW [AR1,P#2.0] // Transfer to Source pointer bytes 2-3
L #tDriveIntfcDBNum // Load DB Number
T LW [AR1,P#4.0] // Transfer to Source pointer bytes 4-5
L 212 // Load start address of data
SLD 3 // Shift data in AR1 3 bits to the left
T LD [AR1,P#6.0] // Trasfer to Source Pointer bytes 6-9
L B#16#84 // 84 hex = DB memory area
T LB [AR1,P#6.0] // Transfer to Source pointer byte 6
//Transfer StaMDB Data to Local UDT Structure
CALL SFC 20
SRCBLK :=#tInputsPointer
RET_VAL:=#tRet
DSTBLK :=#tDriveIntfc.Inputs