Add Header and Footer when output data via the serial interface

Overview

This Sample add Header and Footer when output data via the serial interface.

Specification of this example


Behavior
This Sample Add Header and Footer when output data via the serial interface.

Output Image


How to try this example
1.Click the link below, then the folder containing zip file automatically opens.
refFile

2.Right-click and hold on the zip file, and drop it on working window of FJ system. The images and scene data in zip file are loaded on the program automatically.

3.Re-measure the image. Then System automatically outputs Header, the result of [Search], and Footer via the serial interface.

How to implement

Scene data
Unit No.
Processing Item
0.
Camera Image Input
1.
Search
2.
Macro
The Macro Program below segment is to be set in '2.Macro'.
Macro Program
*MCRINIT
    'Initialize                                 '(1)
    UNITNO&=1
    HEAD$="Search Result Start"
    TAIL$="Search Result End"
Return

*MEASUREPROC
    GetUnitData UNITNO&,  6, SRCHX#         '(2)
    GetUnitData UNITNO&,  7, SRCHY#
    GetUnitData UNITNO&, 14, COUNT#

    If COUNT# = 0 Then
        RESULT$="No Result is found."
    Else
        RESULT$="Position X = " + Str$(SRCHX#) + ", Position Y = " + Str$(SRCHY#)
    EndIf

    SendString "SerialNormal", HEAD$         '(3)
    SendString "SerialNormal", RESULT$
    SendString "SerialNormal", TAIL$
Return

The macro program is in refthis link.
Explanation
(1)Initialize parameters(ex.header and footer format) when initialize measurement.
(2)Get the result of [Search] and make output data.
(3)Output header, output data, and footer via the serial interface.