Count the number of mesurement results OK/NG and display it in Text Window

Overview

Calculate OK, NG and total measurement counts, and percentage of OK and NG products.
And display them in Text Window.

Specification of this example


Behavior
At the end of measurement, calculate the number of OK/NG/Total and the percentage of OK/NG which is the judgement result of specified processing unit ([1.Search]).
And display them in Text Window.

Screenshot


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 displays the number of OK/NG in Text Window.

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
*MEASUREPROC

    MYUNIT& = UnitNo

    RECGJDG& = UnitData(MYUNIT& - 1, "JG")                     '(1)

    If RECGJDG& = JUDGE_NG Then                                '(2)
        CNT_NG& = CNT_NG& + 1
    Elseif RECGJDG& = JUDGE_OK Then
        CNT_OK& = CNT_OK& + 1
    EndIf
    CNT_TOT& =  CNT_NG& +  CNT_OK&

    If CNT_TOT& <> 0 Then                                      '(3)
        RATE_OK# = CNT_OK& / CNT_TOT& * 100
        RATE_NG# = CNT_NG& / CNT_TOT& * 100
    Else
        RATE_OK# = 0
        RATE_NG# = 0
    EndIf

Return

*MEASUREDISPT
    DrawText "Total  :" + Str2$(CNT_TOT&,5,0,0,0), 1, 1        '(4)
    DrawText "  OK   :" + Str2$(CNT_OK&,5,0,0,0), 1, 1
    DrawText "  NG   :" + Str2$(CNT_NG&,5,0,0,0), 1, 1
    DrawText "Rate(percent)", 1, 1
    DrawText "  OK   :" + Str2$(RATE_OK#,5,4,0,0), 1, 1
    DrawText "  NG   :" + Str2$(RATE_NG#,5,4,0,0), 1, 1
Return

The macro program is in refthis link.
Explanation
(1)Get measurement results of forward unit via external reference data.
(2)Count the number of OK/NG/Total.
(3)Calculate the percentage of OK/NG.
(4)Display it in Text Window.