恭喜,你发布的帖子
发布于 2015-09-10 18:47:53
47楼
我喜欢用SCL做数据的处理,一些参数的传递和批量数据的处理,用SCL写还是相当方便的。下面是我写的一段参数传递的小程序:跟大家一起交流交流。
接口表:
Input
DB_NO_So Block_DB 0.0 DB 1 False False 源DB(存有I点的DB号)
INI_ADD_So Int 2.0 0 False False 源起始地址(I点的起始地址)
DB_NO_De Block_DB 4.0 DB 1 False False 目标DB(存有I点的DB号)
INI_ADD_De Int 6.0 0 False False 目标起始地址(I点的起始地址)
Para0 Word 8.0 16#0 False False 偏移参数1(低低字)
Para1 Word 10.0 16#0 True False 偏移参数2(中低字)
Para2 Word 12.0 16#0 True False 偏移参数3(中高字)
Para3 Word 14.0 16#0 True False 偏移参数4(高高字)
Output
DataIO Word 16.0 16#0 False False
InOut
Static
I1 Int 18.0 0 True False
I2 Int 20.0 0 True False
I3 Int 22.0 0 True False
I5 Int 24.0 0 True False
I7 Int 26.0 0 True False
T_Para0 Word 28.0 16#0 True False
ArrayPara0 Array[0..15] of Bool 28.0 False False
T_Para1 Word 30.0 16#0 True False
ArrayPara1 Array[0..15] of Bool 30.0 False False
T_Para2 Word 32.0 16#0 True False
ArrayPara2 Array[0..15] of Bool 32.0 False False
T_Para3 Word 34.0 16#0 True False
ArrayPara3 Array[0..15] of Bool 34.0 False False
DataIn0 Word 36.0 16#0 True False
ArrayDataIn0 Array[0..15] of Bool 36.0 False False
DataIn1 Word 38.0 16#0 True False
ArrayDataIn1 Array[0..15] of Bool 38.0 False False
DataIn2 Word 40.0 16#0 True False
ArrayDataIn2 Array[0..15] of Bool 40.0 False False
DataIn3 Word 42.0 16#0 True False
ArrayDataIn3 Array[0..15] of Bool 42.0 False False
DataOut0 Word 44.0 16#0 True False
ArrayDataOut0 Array[0..15] of Bool 44.0 False False
程序:
#DataIn0 := #DB_NO_So.DW(#INI_ADD_So);
#DataIn1 := #DB_NO_So.DW(#INI_ADD_So+2);
#DataIn2 := #DB_NO_So.DW(#INI_ADD_So+4);
#DataIn3 := #DB_NO_So.DW(#INI_ADD_So+6);
#T_Para0 := #Para0;
#T_Para1 := #Para1;
#T_Para2 := #Para2;
#T_Para3 := #Para3;
FOR #I1 := 0 TO 15 BY 1 DO
IF #I1 = 0 THEN
#I2 := 0;
END_IF;
IF #ArrayPara0[#I1] THEN
#ArrayDataOut0[#I2] := #ArrayDataIn0[#I1];
#I2 := #I2 + 1;
END_IF;
END_FOR;
FOR #I3 := 0 TO 15 BY 1 DO
IF #ArrayPara1[#I3] THEN
#ArrayDataOut0[#I2] := #ArrayDataIn1[#I3];
#I2 := #I2 + 1;
END_IF;
END_FOR;
FOR #I5 := 0 TO 15 BY 1 DO
IF #ArrayPara2[#I5] THEN
#ArrayDataOut0[#I2] := #ArrayDataIn2[#I5];
#I2 := #I2 + 1;
END_IF;
END_FOR;
FOR #I7 := 0 TO 15 BY 1 DO
IF #ArrayPara3[#I7] THEN
#ArrayDataOut0[#I2] := #ArrayDataIn3[#I5];
#I2 := #I2 + 1;
END_IF;
END_FOR;
#DB_NO_De.DW(#INI_ADD_De) := #DataOut0;
#DataIO:=#DataOut0;
请填写推广理由:
分享
只看
楼主