Display the measurement value (measurement count, OK count, NG count) graphically
Overview
Display the measurement value (measurement count, OK count, NG count) graphically.
Specification of this example
Behavior
Count the measurement value (measurement count, OK count, NG count) of selected processing unit, and display bar chart of them in MDI child window.
Screenshot
How to try this example
1.Click the link below, then the folder containing zip file automatically opens.
File
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 MDI Child Window" button in the program, then MDI Child window will be added to the screen.
4.Click "Re-Measure" button, then system remeasures example image files.
System counts the measurement value (measurement count, OK count, NG count) of selected processing unit, and display bar chart of them in MDI child window.
IMPORTANT
This sample uses Microsoft Chart Controls for Microsoft .NET Framework 3.5.
Refer to link below for installing it.
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&displaylang=en
How to implement
Scene data
Unit No.
|
Processing Item
|
0.
|
Camera Image Input
|
1.
|
Search
|
Process of UI unit
Public Class Macro_VB_DisplayBarChart
'**********************************************************************
' Definition of setting data.
'**********************************************************************
Public Class DataDef
' Code example :
Public unitNo As Integer
End Class
Private Shared sumMeasurement As Integer
Private Shared sumOK As Integer
Private Shared sumNG As Integer
'**********************************************************************
' Definition of default value of setting data.
'**********************************************************************
Public Shared Shadows ReadOnly Property DefaultSetting() As String
Get
Dim dataSet As New DataDef
'(1)
dataSet.unitNo = 0
sumMeasurement = 0
sumOK = 0
sumNG = 0
Return ObjToString(dataSet)
End Get
End Property
'**********************************************************************
' title : Measurement display procedure
' function name : MeasureDispProc
' parameters : none
' description :
' This subroutine is called on each measurement display time.
'**********************************************************************
Public Overrides Sub MeasureDispProc()
MyBase.MeasureDispProc()
'(2)
Call DispGraph()
End Sub
Private Sub DispGraph()
Dim dataSet As DataDef = StringToObj(Me.SettingData)
Dim result As Integer
'(3)
result = FZ_FormBase.FZ_FormBase.GetUnitJudge(dataSet.unitNo)
sumMeasurement = sumMeasurement + 1
'(4)
If result = 1 Then
sumOK = sumOK + 1
ElseIf result = -1 Then
sumNG = sumNG + 1
End If
With Chart1
'(5)
.Series.Clear()
'(6)
Dim ChartName As String
ChartName = "Total"
.Series.Add(ChartName)
ChartName = "OK"
.Series.Add(ChartName)
ChartName = "NG"
.Series.Add(ChartName)
.Series(0).Points.Add(sumMeasurement)
.Series(1).Points.Add(sumOK)
.Series(2).Points.Add(sumNG)
'(7)
.ChartAreas(0).RecalculateAxesScale()
End With
End Sub
End Class
Explanation
(1)Set initial values.
(2)Display bar chart when execute measurement.
(3)Get the judgement result of selected processing unit, and increment measurement count.
(4)Increment OK count or NG count by the judgement result.
(5)Clear the setting of chart control.
(6)Set the measurement value (measurement count, OK count, NG count) to chart control.
(7)Refresh scales of x-axis and y-axis of the chart.
Source codes
Total source codes can be get from
here.