diff --git a/SalesPacking_MES_API_Project/OrderPackingProcessor.vbproj b/SalesPacking_MES_API_Project/OrderPackingProcessor.vbproj index cd4580c..a594412 100644 --- a/SalesPacking_MES_API_Project/OrderPackingProcessor.vbproj +++ b/SalesPacking_MES_API_Project/OrderPackingProcessor.vbproj @@ -55,6 +55,11 @@ ..\..\..\..\..\..\..\..\Program Files\Brother bPAC3 SDK\Samples\VBNET\Badge\bin\Release\Interop.bpac.DLL True + + False + True + ..\..\..\..\..\..\Windows\assembly\GAC_64\Ivi.Visa.Interop\5.11.0.0__a128c98f1d7717c1\Ivi.Visa.Interop.dll + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll diff --git a/SalesPacking_MES_API_Project/bin/Debug/SalesPacking_MES_API_Project.exe b/SalesPacking_MES_API_Project/bin/Debug/SalesPacking_MES_API_Project.exe index ba3e546..edf915a 100644 Binary files a/SalesPacking_MES_API_Project/bin/Debug/SalesPacking_MES_API_Project.exe and b/SalesPacking_MES_API_Project/bin/Debug/SalesPacking_MES_API_Project.exe differ diff --git a/SalesPacking_MES_API_Project/weightForm.vb b/SalesPacking_MES_API_Project/weightForm.vb index c16092e..466bcb7 100644 --- a/SalesPacking_MES_API_Project/weightForm.vb +++ b/SalesPacking_MES_API_Project/weightForm.vb @@ -4,8 +4,8 @@ Public Class weightForm Private weightSum As Integer Private switchMotion As Boolean = False - Private weightErrorPlus As Integer - Private weightErrorMinus As Integer + 'Private weightErrorPlus As Integer + 'Private weightErrorMinus As Integer Private weightMode As Boolean @@ -16,8 +16,16 @@ Public Class weightForm Private weightResult As Integer Private zeroSet As Boolean = True - 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 ZeroTimer.Enabled = True lbNowWeight.Text = Nothing @@ -26,11 +34,12 @@ Public Class weightForm lbNowWeight.Refresh() lbWeightEX.Refresh() - weightErrorPlus = Val(mainForm.txbWeightPlus.Text) - weightErrorMinus = Val(mainForm.txbWeightMinus.Text) + 'weightErrorPlus = Val(mainForm.txbWeightPlus.Text) + 'weightErrorMinus = Val(mainForm.txbWeightMinus.Text) - lbError.Text = "(오차: +" & weightErrorPlus & ", -" & weightErrorMinus & ")" + 'lbError.Text = "(오차: +" & weightErrorPlus & ", -" & weightErrorMinus & ")" + lbError.Text = "(자동 오차 계산 중...)" weightResult = 0 zeroSet = True @@ -148,14 +157,37 @@ Public Class weightForm End Try End Sub - Private Function weight_compare() As Boolean - If lbNowWeight.Text >= weightSum - weightErrorMinus And lbNowWeight.Text <= weightSum + weightErrorPlus Then - Return True - Else - Return False + Private Sub UpdateErrorRange() + If weights.Count >= 2 Then + avg = weights.Average() + stdDev = Math.Sqrt(weights.Select(Function(x) (x - avg) ^ 2).Average()) + errorRate = (k * stdDev) / avg + + weightErrorPlus = weightSum * errorRate + weightErrorMinus = weightSum * errorRate 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 + + Public Sub delay(ByVal milliSecond As Double) Dim delayTime As Date = Now.AddSeconds(milliSecond / 1000) Do Until Now > delayTime @@ -179,6 +211,10 @@ Public Class weightForm Next 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 Return True Else