Revert "fix: 오차 계산 방법 고정 방식으로 수정"
This reverts commit 085aec7b6c9ddcc14f1e280c0d7083116f4342af.
This commit is contained in:
parent
085aec7b6c
commit
53bd4fd889
@ -18,13 +18,13 @@ Public Class weightForm
|
|||||||
|
|
||||||
Private weight(2)
|
Private weight(2)
|
||||||
|
|
||||||
'Dim weights As New List(Of Double)() ' 실측 측정값 저장용
|
Dim weights As New List(Of Double)() ' 실측 측정값 저장용
|
||||||
'Dim avg As Double = 0.0 ' 평균
|
Dim avg As Double = 0.0 ' 평균
|
||||||
'Dim stdDev As Double = 0.0 ' 표준편차
|
Dim stdDev As Double = 0.0 ' 표준편차
|
||||||
'Dim k As Double = 2.0 ' 오차 계수
|
Dim k As Double = 2.0 ' 오차 계수
|
||||||
'Dim errorRate As Double = 0.0 ' 허용 오차 비율
|
Dim errorRate As Double = 0.0 ' 허용 오차 비율
|
||||||
'Dim weightErrorPlus As Double = 0.0 ' 허용 오차 상한
|
Dim weightErrorPlus As Double = 0.0 ' 허용 오차 상한
|
||||||
'Dim weightErrorMinus 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
|
||||||
@ -157,31 +157,19 @@ Public Class weightForm
|
|||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'Private Sub UpdateErrorRange()
|
Private Sub UpdateErrorRange()
|
||||||
' If mainForm.rdbWeightAuto.Checked = True Then
|
If weights.Count >= 2 Then
|
||||||
' ' 자동 모드: 오차 계수(k)로 오차 범위 산출
|
avg = weights.Average()
|
||||||
' Dim autoErrorRate As Double = 0.02 ' 예: 2% 오차
|
stdDev = Math.Sqrt(weights.Select(Function(x) (x - avg) ^ 2).Average())
|
||||||
' weightErrorPlus = weightSum * autoErrorRate
|
errorRate = (k * stdDev) / avg
|
||||||
' weightErrorMinus = weightSum * autoErrorRate
|
|
||||||
|
|
||||||
' 'If lbNowWeight.Text >= weightSum - weightErrorMinus And
|
weightErrorPlus = weightSum * errorRate
|
||||||
' ' lbNowWeight.Text <= weightSum + weightErrorPlus Then
|
weightErrorMinus = weightSum * errorRate
|
||||||
' 'End If
|
|
||||||
|
|
||||||
' Else
|
' 폼에 오차 범위 표시
|
||||||
' ' 수동 모드: 평균, 표준편차 기반 오차 범위 산출
|
lbError.Text = "(오차: +" & weightErrorPlus.ToString() & ", -" & weightErrorMinus.ToString() & ")"
|
||||||
' If weights.Count >= 2 Then
|
End If
|
||||||
' avg = weights.Average()
|
End Sub
|
||||||
' stdDev = Math.Sqrt(weights.Select(Function(x) (x - avg) ^ 2).Average())
|
|
||||||
' errorRate = (k * stdDev) / avg
|
|
||||||
' weightErrorPlus = weightSum * errorRate
|
|
||||||
' weightErrorMinus = weightSum * errorRate
|
|
||||||
|
|
||||||
' '폼에 오차 범위 표시
|
|
||||||
' lbError.Text = "(오차: +" & weightErrorPlus.ToString() & ", -" & weightErrorMinus.ToString() & ")"
|
|
||||||
' End If
|
|
||||||
' End If
|
|
||||||
'End Sub
|
|
||||||
|
|
||||||
'Private Function weight_compare() As Boolean
|
'Private Function weight_compare() As Boolean
|
||||||
' If lbNowWeight.Text >= weightSum - weightErrorMinus And lbNowWeight.Text <= weightSum + weightErrorPlus Then
|
' If lbNowWeight.Text >= weightSum - weightErrorMinus And lbNowWeight.Text <= weightSum + weightErrorPlus Then
|
||||||
@ -191,22 +179,18 @@ Public Class weightForm
|
|||||||
' End If
|
' End If
|
||||||
'End Function
|
'End Function
|
||||||
|
|
||||||
|
|
||||||
Private Function weight_compare() As Boolean
|
Private Function weight_compare() As Boolean
|
||||||
Dim nowWeight As Double = Double.Parse(lbNowWeight.Text)
|
Dim nowWeight As Double = Double.Parse(lbNowWeight.Text)
|
||||||
Dim autoErrorRate As Double = 0.02 ' 예: 2% 오차
|
|
||||||
|
|
||||||
Dim weightError As Double = weightSum * autoErrorRate
|
' 기준 무게 기반 허용 오차 범위 계산 완료된 상태에서 비교
|
||||||
|
Dim upperBound As Double = weightSum + weightErrorPlus
|
||||||
Dim upperBound As Double = weightSum + weightError
|
Dim lowerBound As Double = weightSum - weightErrorMinus
|
||||||
Dim lowerBound As Double = weightSum - weightError
|
|
||||||
|
|
||||||
' 폼에 오차 범위 표시
|
|
||||||
lbError.Text = "(오차: ±" & weightError.ToString("F2") & ", 허용구간: " & lowerBound.ToString("F2") & " ~ " & upperBound.ToString("F2") & ")"
|
|
||||||
|
|
||||||
Return (nowWeight >= lowerBound) AndAlso (nowWeight <= upperBound)
|
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
|
||||||
@ -230,9 +214,9 @@ Public Class weightForm
|
|||||||
Next
|
Next
|
||||||
Loop
|
Loop
|
||||||
|
|
||||||
'weights.Add(Double.Parse(weight(0)))
|
weights.Add(Double.Parse(weight(0)))
|
||||||
'weights.Add(Double.Parse(weight(1)))
|
weights.Add(Double.Parse(weight(1)))
|
||||||
'UpdateErrorRange()
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user