Software Environments: SIEMENS TIA V15.1
Hardware Environments: SIEMENS S7-1200 / 1215C
FB Block name: FB_FIFO_POINTER(FB20) (指针 先进先出队列)
Reference from EISENMAN E-PASS-Lib
Interface Parameter description:
Overview:
IvarInput: input element for FIFO queue(can be to define UDT type)
QiError : Error Code
QxInsertDone: Insert Operation Done ( Insert a element to the queue)
QxCarryOutDone: Carry Out Operation Done (take out a element from queue)
QxDisplayDone: take out a element to show Operation ( store to IQvarDisplay parameter)
QxDeleteDone: to clear all of they done (Param IQvarBuffer to pointer buffer area)
QiOcc: current insert/ append element to count in the queue
IQxDelete: active a delete all element of the queue operation
IQiInsert: Insert / append operation, to pointer a position for Insert / append. If IQiInsert <> 0,and QiOcc < element array Max
IQiCarryOut: CarryOut operation, to pointer a position for Carry Out element. If IQiCarryOut<>0, and QiOcc >0
IQiDisplay: Display element. to pointer a position for show element. Copy data to IQvarDisplay
If IQiDisplay <>0, and IQiDisplay >0, IQiDisplay< element array Max;
IQvarDisplay: pointer type, pointer to a memory area(DB,M L etc..) for show element
IQvarBuffer:pointer type. pointer to a memory area(DB,M L etc..) for store a element Array.
IQvarPointerOcc: pointer type. pointer to a memory area(DB,M L etc..) for store a Index Array of FIFI queue
IQvarFillEmpty: pointer type. pointer to a memory area(DB,M L etc..) for clear element( fill a empty element)
STATIC area
iNextFree: pointer to index for next free position in the queue
iOcc: current exist element count
aiPointerOcc: Array[#ilo..#ihi] of Int
current exist element array index list, 当前已存在的元素索引 数组列表. FIFO 队列索引(链式队列)
aiPointerEmpty: Array[#ilo..#ihi] of Int
current exist free array index list. 当前存在的空元素索引 数组列表. FIFO 队列空元素索引(链式队列)
Insert / append operation (插入,添加操作)
第一次调用,通过获取 IQvarBuffer 数组元素长度获取元素缓冲区大小。例如Array[0..19] of UDT
初始化 aiPointerEmpty 空元素指针数组., 如下图:
初始化 aiPointerOcc元素指针数组., 如下图:
当IQiInsert 参数赋值 大于0, 小于IQvarBuffer 缓存区最大元素位置 ,执行插入/添加元素操作。
aiPointerEmpty 空队列中,第一个空指针指向的 IQvarBuffer 缓存区数组下标位置,添加IvarInput 指向的新的元素。
如果IQiInsert > QiOcc , 添加操作会把新的元素内容添加到 QiOcc 位置的下一个(缓存区数组的上一个下标)位置。
注意:IvarInput 数据类型,必须与 IQvarBuffer 数组元素 类型一致。
取出元素操作,
QxCarryOutDone 参数,赋值大于0,小于IQvarBuffer 缓存区最大元素位置和 QiOcc 计数位置。 执行取出元素操作。
取出 QxCarryOutDone 参数 指向的IQvarBuffer 数组下标位置的元素内容,并保存到IQvarDisplay 指向的变量。 并删除IQvarBuffer 数组下标位置的元素内容。
同时在aiPointerEmpty 指针数字 索引的 下标位置,赋值0, 表示这个指针指向的IQvarBuffer 数组下标内容被清空,下一次添加元素,可添加到这个位置。FIFO队列空出一个位置,
每一次添加元素都是 优先添加 aiPointerEmpty 指针数组 最后一个元素指向的 IQvarBuffer 数组下标位置。



