feat: 오차 계산 기능 추가
- 측정값 리스트에 저장 - 평균, 표준편차 계산으로 동적 허용 오차 산출 - 실측 무게와 기준 무게 비교하여 판정 기능 추가
This commit is contained in:
parent
0e9dc6a9a3
commit
d8ac2b984b
@ -55,6 +55,11 @@
|
|||||||
<HintPath>..\..\..\..\..\..\..\..\Program Files\Brother bPAC3 SDK\Samples\VBNET\Badge\bin\Release\Interop.bpac.DLL</HintPath>
|
<HintPath>..\..\..\..\..\..\..\..\Program Files\Brother bPAC3 SDK\Samples\VBNET\Badge\bin\Release\Interop.bpac.DLL</HintPath>
|
||||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Ivi.Visa.Interop, Version=5.11.0.0, Culture=neutral, PublicKeyToken=a128c98f1d7717c1, processorArchitecture=AMD64">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
<HintPath>..\..\..\..\..\..\Windows\assembly\GAC_64\Ivi.Visa.Interop\5.11.0.0__a128c98f1d7717c1\Ivi.Visa.Interop.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
Binary file not shown.
@ -4,8 +4,8 @@ Public Class weightForm
|
|||||||
Private weightSum As Integer
|
Private weightSum As Integer
|
||||||
Private switchMotion As Boolean = False
|
Private switchMotion As Boolean = False
|
||||||
|
|
||||||
Private weightErrorPlus As Integer
|
'Private weightErrorPlus As Integer
|
||||||
Private weightErrorMinus As Integer
|
'Private weightErrorMinus As Integer
|
||||||
|
|
||||||
|
|
||||||
Private weightMode As Boolean
|
Private weightMode As Boolean
|
||||||
@ -16,8 +16,16 @@ Public Class weightForm
|
|||||||
Private weightResult As Integer
|
Private weightResult As Integer
|
||||||
Private zeroSet As Boolean = True
|
Private zeroSet As Boolean = True
|
||||||
|
|
||||||
|
|
||||||
Private weight(2)
|
Private weight(2)
|
||||||
|
|
||||||
|
Dim weights As New List(Of Double)() ' 실측 측정값 저장용
|
||||||
|
Dim avg As Double = 0.0 ' 평균
|
||||||
|
Dim stdDev As Double = 0.0 ' 표준편차
|
||||||
|
Dim k As Double = 2.0 ' 오차 계수
|
||||||
|
Dim errorRate As Double = 0.0 ' 허용 오차 비율
|
||||||
|
Dim weightErrorPlus As Double = 0.0 ' 허용 오차 상한
|
||||||
|
Dim weightErrorMinus As Double = 0.0 ' 허용 오차 하한
|
||||||
|
|
||||||
Private Sub weightForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub weightForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
ZeroTimer.Enabled = True
|
ZeroTimer.Enabled = True
|
||||||
lbNowWeight.Text = Nothing
|
lbNowWeight.Text = Nothing
|
||||||
@ -26,11 +34,12 @@ Public Class weightForm
|
|||||||
lbNowWeight.Refresh()
|
lbNowWeight.Refresh()
|
||||||
lbWeightEX.Refresh()
|
lbWeightEX.Refresh()
|
||||||
|
|
||||||
weightErrorPlus = Val(mainForm.txbWeightPlus.Text)
|
'weightErrorPlus = Val(mainForm.txbWeightPlus.Text)
|
||||||
weightErrorMinus = Val(mainForm.txbWeightMinus.Text)
|
'weightErrorMinus = Val(mainForm.txbWeightMinus.Text)
|
||||||
|
|
||||||
lbError.Text = "(오차: +" & weightErrorPlus & ", -" & weightErrorMinus & ")"
|
'lbError.Text = "(오차: +" & weightErrorPlus & ", -" & weightErrorMinus & ")"
|
||||||
|
|
||||||
|
lbError.Text = "(자동 오차 계산 중...)"
|
||||||
|
|
||||||
weightResult = 0
|
weightResult = 0
|
||||||
zeroSet = True
|
zeroSet = True
|
||||||
@ -148,14 +157,37 @@ Public Class weightForm
|
|||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function weight_compare() As Boolean
|
Private Sub UpdateErrorRange()
|
||||||
If lbNowWeight.Text >= weightSum - weightErrorMinus And lbNowWeight.Text <= weightSum + weightErrorPlus Then
|
If weights.Count >= 2 Then
|
||||||
Return True
|
avg = weights.Average()
|
||||||
Else
|
stdDev = Math.Sqrt(weights.Select(Function(x) (x - avg) ^ 2).Average())
|
||||||
Return False
|
errorRate = (k * stdDev) / avg
|
||||||
|
|
||||||
|
weightErrorPlus = weightSum * errorRate
|
||||||
|
weightErrorMinus = weightSum * errorRate
|
||||||
End If
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Private Function weight_compare() As Boolean
|
||||||
|
' If lbNowWeight.Text >= weightSum - weightErrorMinus And lbNowWeight.Text <= weightSum + weightErrorPlus Then
|
||||||
|
' Return True
|
||||||
|
' Else
|
||||||
|
' Return False
|
||||||
|
' End If
|
||||||
|
'End Function
|
||||||
|
|
||||||
|
Private Function weight_compare() As Boolean
|
||||||
|
Dim nowWeight As Double = Double.Parse(lbNowWeight.Text)
|
||||||
|
|
||||||
|
' 기준 무게 기반 허용 오차 범위 계산 완료된 상태에서 비교
|
||||||
|
Dim upperBound As Double = weightSum + weightErrorPlus
|
||||||
|
Dim lowerBound As Double = weightSum - weightErrorMinus
|
||||||
|
|
||||||
|
Return (nowWeight >= lowerBound) AndAlso (nowWeight <= upperBound)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Public Sub delay(ByVal milliSecond As Double)
|
Public Sub delay(ByVal milliSecond As Double)
|
||||||
Dim delayTime As Date = Now.AddSeconds(milliSecond / 1000)
|
Dim delayTime As Date = Now.AddSeconds(milliSecond / 1000)
|
||||||
Do Until Now > delayTime
|
Do Until Now > delayTime
|
||||||
@ -179,6 +211,10 @@ Public Class weightForm
|
|||||||
Next
|
Next
|
||||||
Loop
|
Loop
|
||||||
|
|
||||||
|
weights.Add(Double.Parse(weight(0)))
|
||||||
|
weights.Add(Double.Parse(weight(1)))
|
||||||
|
UpdateErrorRange()
|
||||||
|
|
||||||
If weight(0) - weight(1) < 10 And weight(0) - weight(1) > -10 Then
|
If weight(0) - weight(1) < 10 And weight(0) - weight(1) > -10 Then
|
||||||
Return True
|
Return True
|
||||||
Else
|
Else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user