162 lines
3.7 KiB
VB.net
162 lines
3.7 KiB
VB.net
''' <summary>
|
|
''' 生产统计类(当前类线程仅限同步中使用)
|
|
''' </summary>
|
|
Public Class Statistics
|
|
''' <summary>
|
|
''' 校验总数,包含有效校验与无效检验
|
|
''' </summary>
|
|
Private _checkCount As Integer
|
|
|
|
''' <summary>
|
|
''' 检验有效总数中无效总数
|
|
''' </summary>
|
|
Private _invalidCount As Integer
|
|
|
|
''' <summary>
|
|
''' 检验总数中有效总数
|
|
''' </summary>
|
|
Private _validCount As Integer
|
|
|
|
''' <summary>
|
|
''' 检验有效总数中失败总数
|
|
''' </summary>
|
|
Private _failCount As Integer
|
|
''' <summary>
|
|
''' 检验有效总数中通过总数
|
|
''' </summary>
|
|
Private _passCount As Integer
|
|
|
|
''' <summary>
|
|
''' 产品运行时良品率,通过总数除以有效总数
|
|
''' </summary>
|
|
Private _yield As Double
|
|
|
|
Private ReadOnly _observerList As List(Of IStatisticsObserver)
|
|
|
|
Sub New()
|
|
_checkCount = 0
|
|
_failCount = 0
|
|
_passCount = 0
|
|
|
|
_observerList = New List(Of IStatisticsObserver)()
|
|
End Sub
|
|
|
|
Public ReadOnly Property CheckCount() As Integer
|
|
Get
|
|
Return _checkCount
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InvalidCount() As Integer
|
|
Get
|
|
Return _invalidCount
|
|
End Get
|
|
End Property
|
|
|
|
|
|
Public ReadOnly Property FailCount() As Integer
|
|
Get
|
|
Return _failCount
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PassCount() As Integer
|
|
Get
|
|
Return _passCount
|
|
End Get
|
|
End Property
|
|
|
|
|
|
|
|
|
|
Public Sub AddFailCount()
|
|
_failCount += 1
|
|
UpdateFailCount(_failCount)
|
|
|
|
_validCount +=1
|
|
UpdateValidCount(_validCount)
|
|
|
|
_checkCount += 1
|
|
UpdateSumCount(_checkCount)
|
|
|
|
|
|
_yield = (_passCount / _validCount) * 100
|
|
UpdateYield(_yield)
|
|
End Sub
|
|
|
|
Public Sub AddPassCount()
|
|
_passCount += 1
|
|
UpdatePassCount(_passCount)
|
|
|
|
_validCount +=1
|
|
UpdateValidCount(_validCount)
|
|
|
|
_checkCount += 1
|
|
UpdateSumCount(_checkCount)
|
|
|
|
_yield = (_passCount / _validCount) * 100
|
|
UpdateYield(_yield)
|
|
End Sub
|
|
|
|
Public Sub AddInvalidCount()
|
|
_invalidCount += 1
|
|
UpdateInvalidCount(_invalidCount)
|
|
|
|
_checkCount += 1
|
|
UpdateSumCount(_checkCount)
|
|
End Sub
|
|
|
|
|
|
Public Sub AddStatisticsObserver(observer As IStatisticsObserver)
|
|
_observerList.Add(observer)
|
|
End Sub
|
|
|
|
Public Sub RemoveStatisticsObserver(observer As IStatisticsObserver)
|
|
_observerList.Remove(observer)
|
|
End Sub
|
|
|
|
Public Sub ClearStatisticsObserver()
|
|
_observerList.Clear()
|
|
End Sub
|
|
|
|
|
|
Private Sub UpdateFailCount(count As Integer)
|
|
For Each observer As IStatisticsObserver In _observerList
|
|
observer.UpdateFailCount(count)
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub UpdatePassCount(count As Integer)
|
|
For Each observer As IStatisticsObserver In _observerList
|
|
observer.UpdatePassCount(count)
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Private Sub UpdateValidCount(count As Integer)
|
|
For Each observer As IStatisticsObserver In _observerList
|
|
observer.UpdateValidCount(count)
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub UpdateInvalidCount(count As Integer)
|
|
For Each observer As IStatisticsObserver In _observerList
|
|
observer.UpdateInvalidCount(count)
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Private Sub UpdateSumCount(count As Integer)
|
|
For Each observer As IStatisticsObserver In _observerList
|
|
observer.UpdateSumCount(count)
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub UpdateYield(yield As Double)
|
|
For Each observer As IStatisticsObserver In _observerList
|
|
observer.UpdateYield(yield)
|
|
Next
|
|
End Sub
|
|
|
|
End Class
|