Académique Documents
Professionnel Documents
Culture Documents
Automation Portal
LGF_FIFO
Name Data type Default value Retain Accessible Writ‐ Visible in Setpoint Supervi‐ Comment
from able HMI engi‐ sion
HMI/OPC from neering
UA HMI/
OPC
UA
Input
execute Bool false Non-retain True True True False The instruction is executed
when a positive signal edge
is detected at the "request"
parameter.
mode Bool false Non-retain True True True False 0 = The first entry in the ring
buffer is returned. 1 = An
entry is written at the last
position in the ring buffer.
initialValue Variant False False False False Value with which the ARRAY
of the ring buffer is initial‐
ized.
resetBuffer Bool false Non-retain True True True False
Output
done Bool false Non-retain True True True False
error Bool false Non-retain True True True False
statusID UInt 0 Non-retain True True True False
status Word 16#0 Non-retain True True True False Status information
InOut
item Variant False False False False The entry that is either re‐
turned from the ring buffer
or written to the ring buffer
buffer Variant False False False False An ARRAY that is used as a
ring buffer.
Static
statEdgeupm Bool false Non-retain True True True False Edge memory bit in which
the RLO of the previous
query is saved.
statFirstItemIndex Int -1 Non-retain True True True False Index of the oldest entry in
the ring buffer
statNextEmptyItemIndex Int 0 Non-retain True True True False Index of the next free entry
in the ring buffer
Temp
tempEdgeup Bool Result of edge evaluation
tempInternalError Int Error information
tempNewFirstItemIndex Int Variable index
tempNewNextEmptyItemIn‐ Int Variable index
dex
tempPufferSize UDInt Number of ARRAY elements
in the ring buffer
tempSizeCounter Int
Constant
NO_ERROR Word 16#0000
NO_CURRENT_JOBS Word 16#7000
BUFFER_EMPTY Word 16#8001
BUFFER_FULL Word 16#8002
NO_ARRAY Word 16#8200
WRONG_TYPE_1 Word 16#8201
WRONG_TYPE_2 Word 16#8202
INDEX_IN_ARRAY_LIMITS_1 Word 16#0
INDEX_IN_ARRAY_LIMITS_2 Word 16#0
ERROR_IN_THIS_BLOCK UInt 1
ERROR_MOVE_BLK_VARIANT UInt 2
NEXT_TASK_TO_EXECUTE Bool false
BUFFER_IS_EMPTY Int -1
BUFFER_CONTAINS_ARRAY Int 0
NO_INTERNAL_ERROR Int 0
BUFFER_INITIALIZED Int -1
RESET Bool true
0001 //=============================================================================
0002 // SIEMENS AG
0003 // (c)Copyright 2017
0004 //-----------------------------------------------------------------------------
0005 // Library: LGF (Library General Functions)
Totally Integrated
Automation Portal
0182 //this program code section checks whether the ring #buffer is full.
0183 //IF this is the CASE, program execution is terminated at this point
0184 //AND the error code "8002" is output. *)
0185
0186 IF (#statNextEmptyItemIndex = #statFirstItemIndex) THEN
0187 #error := true;
0188 #statusID := #ERROR_IN_THIS_BLOCK;
0189 #status := #BUFFER_FULL;
0190 RETURN;
0191 END_IF;
0192
0193 // This program code section writes the entry to the ring buffer.
0194 #tempInternalError := MOVE_BLK_VARIANT(SRC := #item,
0195 COUNT := 1,
0196 SRC_INDEX := 0,
0197 DEST_INDEX := #statNextEmptyItemIndex,
0198 DEST => #buffer);
0199
0200 IF (#tempInternalError = #NO_INTERNAL_ERROR) THEN
0201
0202 // This program code section increments the index by 1 and calculates the new empty entry index.
0203 #tempNewNextEmptyItemIndex := #statNextEmptyItemIndex + 1;
0204 #tempNewNextEmptyItemIndex := #tempNewNextEmptyItemIndex MOD UDINT_TO_INT(#tempPufferSize);
0205 #statNextEmptyItemIndex := #tempNewNextEmptyItemIndex;
0206
0207 //This program code section checks which index the "#firstItemIndex" tag has.
0208 //IF the number = -1, the ring buffer is initialized
0209 //AND the entry is written TO the ring #buffer.
0210 //Therefore, "0" must be assigned TO the tag.
0211
0212 IF (#statFirstItemIndex = #BUFFER_INITIALIZED) THEN
0213 #statFirstItemIndex := 0;
0214 END_IF;
0215 END_IF;
0216 END_IF;
0217
0218 //-------------------------Local error handling----------------------------
0219 //This program code section checks whether a "Local" #error has occurred.
0220 //IF This is the CASE, program execution is terminated at This point
0221 //AND the error code of MOV_BLK_VARIANT is output. *)
0222
0223 IF (#tempInternalError <> #NO_INTERNAL_ERROR) THEN
0224 #error := true;
0225 #statusID := #ERROR_MOVE_BLK_VARIANT;
0226 #status := INT_TO_WORD(#tempInternalError);
0227 RETURN;
0228 END_IF;
0229
0230 #done := true;
0231 #status := #NO_ERROR;