一、OSCATBasic介绍
- OSCATBasic是一个开源库,包含丰富的算法函数;
- 在CODESYS资源库里打开后,在库管理器里安装后,即可在程序中使用。
- 有对应的源码文件,可以学习其优秀的ST算法编程,提升能力;例如文中大量采用了指针操作,可以加深对指针的理解;
二、 内容介绍
包括一下三个文件:
- 库文件
- 库源码文件
-
使用教程文档
《教程文档.pdf》
《OSCATBasic库源码》
例如函数 _BUFFER_CLEAR,其代码如下
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/Buffer Management' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION _BUFFER_CLEAR : BOOL
VAR_INPUT
PT : POINTER TO BYTE;
SIZE : UINT;
END_VAR
VAR
ptw : POINTER TO DWORD;
temp: DWORD;
end, end32 : DWORD;
END_VAR
(*
version 1.2 31. oct. 2008
programmer hugo
tested by oscat
this function will initialize a given array of byte with 0.
the function needs to be called: _buffer_clear(adr("array"),sizeof("array"));
this function will manipulate a given array.
the function manipulates the original array, it rerturnes true when finished.
because this function works with pointers its very time efficient and it needs no extra memory.
*)
(* @END_DECLARATION := '0' *)
(* this routine uses 32 bit access to gain speed *)
(* first access bytes till pointer is aligned for 32 bit access *)
temp := pt;
end := temp + UINT_TO_DWORD(size);
end32 := end - 3;
WHILE (pt < end) AND ((temp AND 16#00000003) > 0) DO
pt^ := 0;
pt := pt + 1;
temp := temp + 1;
END_WHILE;
(* pointer is aligned, now copy 32 bits at a time *)
ptw := pt;
WHILE ptw < end32 DO (* *)
ptw^ := 0;
ptw := ptw + 4;
END_WHILE;
(* copy the remaining bytes in byte mode *)
pt := ptw;
WHILE pt < end DO
pt^ := 0;
pt := pt + 1;
END_WHILE;
_BUFFER_CLEAR := TRUE;
版权声明:本文为qq_30992795原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。