Use Printer

Overview

Print by the printer.

Specification of this example


Behavior
Count the measurement result by Macro. When click the button on the PanDA form, print the result.

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, then the demo-tool automatically starts.

3.Click "Start PanDA Form" button in the program, then the PanDA form will start.

4.Click "Re-Measure" button, then system remeasures example image files.
Count the number of OK/NG, print the result at clicking the button on the form.

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
In regard to Macro, Refer to refMacro Sample:Count the number of mesurement results OK/NG and display.
Process of UI unit
Public Class Macro_VB_UsePrinter

    Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageButton1.Click
        PrintDocument1.Print()
        Me.Close()
    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim total, cntok, cntng, rateok, rateng As Double              '(1)
        FZ_PanDAForm.FZ_PanDAForm.GetUnitData(2, "CNT_TOT&", total)
        FZ_PanDAForm.FZ_PanDAForm.GetUnitData(2, "CNT_OK&", cntok)
        FZ_PanDAForm.FZ_PanDAForm.GetUnitData(2, "CNT_NG&", cntng)
        FZ_PanDAForm.FZ_PanDAForm.GetUnitData(2, "RATE_OK#", rateok)
        FZ_PanDAForm.FZ_PanDAForm.GetUnitData(2, "RATE_NG#", rateng)

        Dim f As New Font("arial", 11, FontStyle.Bold)                 '(2)
        Dim LineHeight As Single = f.GetHeight(e.Graphics)
        Dim Y As Integer = 10
        e.Graphics.DrawString("Total :" + total.ToString(), f, Brushes.Black, 10, Y)
        e.Graphics.DrawString(" OK   :" + cntok.ToString(), f, Brushes.Black, 10, Y + LineHeight)
        e.Graphics.DrawString(" NG   :" + cntng.ToString(), f, Brushes.Black, 10, Y + LineHeight * 2)
        e.Graphics.DrawString("Rate(percent)", f, Brushes.Black, 10, Y + LineHeight * 3)
        e.Graphics.DrawString(" OK   :" + rateok.ToString("F4"), f, Brushes.Black, 10, Y + LineHeight * 4)
        e.Graphics.DrawString(" NG   :" + rateng.ToString("F4"), f, Brushes.Black, 10, Y + LineHeight * 5)
    End Sub
End Class

Explanation
(1)Get the result of Macro.
(2)Format the data to print.

Source codes

Total source codes can be get from refhere.