SMC_AvoidLoop (FB)¶
FUNCTION_BLOCK SMC_AvoidLoop
The SMC_AvoidLoop
function block can be used for path-preprocessing.
It will copy a defined path, but cut out the loops contained therein.
If an intersection is detected within the original path,
the path will be cut at the intersection point, the loop will be removed
and the path will be continued with the rest of the curve.
Thus, a continuous path free of loops will result.

For a typical application see the description of the SMC_ToolCorr module.
The module passes all SMC_GEOINFO objects found in the
input SMC_OUTQUEUE structure. If in one of these objects Bit7
of the variable Intern_Mark
is set, the avoid-loop-functionality
will be activated. This functionality is able to check, whether there is
an intersection point of the current object with any of the subsequent
SMC_GEOINFO objects preceding the next SMC_GEOINFO Object,
in which Bit6 of the variable Intern_Mark
is set.
This bit being raised will terminate the avoid-loop-functionality.
If no intersections are found, the object will be copied unchanged
to the Output SMC_OUTQUEUE .
Otherwise the first of the intersecting objects will be cut at the
intersection point, the SMC_GEOINFO objects positioned between the
intersecting objects will be removed, and the new path will be continued
with the second of the two intersecting objects. The SMC_NCDecoder will
set the Bits 6 and 7 of Intern_Mark
as reaction on the instructions G61/G60.
Note
The efficiency of SMC_AvoidLoop depends on the appropriate size of input SMC_OUTQUEUE. A loop, containing more objects than can be stored in SMC_OUTQUEUE, cannot be detected! On the other hand: For each object an intersection check is executed with all following objects of the queue. If it is a large queue, then it takes long time for completing the check.
- InOut:
Scope
Name
Type
Initial
Comment
Input
bExecute
BOOL
FALSE
Execution starts on the rising edge.
bAbort
BOOL
FALSE
If
TRUE
, the current processing of this function block is abortedbAppend
BOOL
FALSE
As long as this input remains
FALSE
,DataOutQueue
will be cleared at each reset. As long as it remainsTRUE
, newly incoming data will be written to the end ofDataOutQueue
.poqDataIn
POINTER TO SMC_OUTQUEUE
NULL
This variable points to the SMC_OUTQUEUE structure object, which contains the SMC_GEOINFO objects of the path; typically it points on the output
DataOut
of the preceding module (e.g. the SMC_NCDecoder ). SMC_OUTQUEUE should be dimensioned in an appropriate size (seenSizeOutQueue
) !nSizeOutQueue
UDINT
0
This variable contains the size of the data buffer, the list of SMC_GEOINFO structure objects will be written to. This buffer must be able to hold at least five SMC_GEOINFO objects. Otherwise, SMC_NCDecoder will not execute any actions at all. Its size may be predefined, but may be modified later only during a reset. It is recommended to create the buffer as described by the example below.
ExampleBuf: Array[ 1..50] of SMC_GeoInfo
The appropriate buffer size will then be retrieved by use of the operator
sizeof(ExampleBuf)
.pbyBufferOutQueue
POINTER TO ARRAY [0..0] OF SMC_GEOINFO
NULL
This input must point to the first byte of the memory area that is allocated for the SMC_OUTQUEUE structure. This area must be at least as big as defined in
nSizeOutQueue
. Typically the allocation of the memory buffer is done in the declaration part of the IEC-program by defining an array of SMC_GEOINFO e.g.BUF: ARRAY[1..50] OF SMC_GEOINFO
; for a buffer that can store 50 path elements). The value may be predefined, but may be modified later on only during a reset.Output
bDone
BOOL
FALSE
This variable will be set to
TRUE
as soon as the input data of …DataIn has been processed completely. Thereafter the module will not perform any further actions until it will be reset. If inputbExecute
isFALSE
,bDone
will be reset toFALSE
.bBusy
BOOL
FALSE
TRUE
, while execution of function block is not finishedbError
BOOL
FALSE
Signals, that an error has occurred within the function block
wErrorID
SMC_ERROR
SMC_NO_ERROR
Error identification
poqDataOut
POINTER TO SMC_OUTQUEUE
NULL
This variable points to a SMC_OUTQUEUE structure, which manages the SMC_GEOINFO objects of the loopless path.
iStatus
0
This enum variable shows the current state of the module. Possible states:
AL_OFF: 0
; Avoid-Loop-functionality switched offAL_ON: 1
; Avoid-Loop-functionality switched onAL_END: 2
; Processing of the objects terminated
SMC_AL_STATUS (ENUM)
Structure: