feat: 시리얼 데이터 처리에 딜레이 추가로 무게 측정 안정성 개선
- QWSerialPort_DataReceived에 100ms Thread.Sleep 추가
This commit is contained in:
parent
ecadd4c180
commit
8decb0c43d
@ -77,7 +77,7 @@ Public Class weightForm
|
|||||||
playTimer.Enabled = False
|
playTimer.Enabled = False
|
||||||
|
|
||||||
If AutoMeasureScale() Then
|
If AutoMeasureScale() Then
|
||||||
lbNowWeight.Text = weightResult2 ' 실제 측정값 표시
|
lbNowWeight.Text = weightResult2
|
||||||
|
|
||||||
If weight_compare() Then
|
If weight_compare() Then
|
||||||
lbWeight.BackColor = Color.Green
|
lbWeight.BackColor = Color.Green
|
||||||
@ -158,6 +158,9 @@ Public Class weightForm
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
ElseIf mainForm.rdbWeightQW.Checked = True Then
|
ElseIf mainForm.rdbWeightQW.Checked = True Then
|
||||||
|
|
||||||
|
lbNowWeight.Text = weightResult2
|
||||||
|
|
||||||
' 실제 시리얼 데이터 직접 사용
|
' 실제 시리얼 데이터 직접 사용
|
||||||
If weightResult2 <= 0 Then ' 1g 이하면 비어있음
|
If weightResult2 <= 0 Then ' 1g 이하면 비어있음
|
||||||
statusTimer.Enabled = True
|
statusTimer.Enabled = True
|
||||||
@ -168,7 +171,7 @@ Public Class weightForm
|
|||||||
lbWeight.BackColor = Color.White
|
lbWeight.BackColor = Color.White
|
||||||
Else
|
Else
|
||||||
ZeroTimer.Enabled = False
|
ZeroTimer.Enabled = False
|
||||||
lbWeight.Text = "저울을 비워주세요 (현재: " & weightResult2.ToString("F0") & "g)"
|
lbWeight.Text = "저울을 비워주세요."
|
||||||
lbWeight.BackColor = Color.Red
|
lbWeight.BackColor = Color.Red
|
||||||
ZeroTimer.Enabled = True
|
ZeroTimer.Enabled = True
|
||||||
End If
|
End If
|
||||||
@ -210,8 +213,9 @@ Public Class weightForm
|
|||||||
Application.DoEvents()
|
Application.DoEvents()
|
||||||
Loop
|
Loop
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function MeasureScale2(timeout As Integer) As String
|
Private Function MeasureScale2(timeout As Integer) As String
|
||||||
'Return "US,GS, " & weightResult.ToString("F3") & " kg"
|
'Return "US,GS, " & weightResult2.ToString("F3") & " kg"
|
||||||
Return "US,GS, " & (weightResult2 * 1000).ToString("F0") & " g"
|
Return "US,GS, " & (weightResult2 * 1000).ToString("F0") & " g"
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@ -282,6 +286,8 @@ Public Class weightForm
|
|||||||
|
|
||||||
Private Sub QWSerialPort_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles QWSerialPort.DataReceived
|
Private Sub QWSerialPort_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles QWSerialPort.DataReceived
|
||||||
Try
|
Try
|
||||||
|
System.Threading.Thread.Sleep(100) ' 100ms 딜레이
|
||||||
|
|
||||||
Dim incoming As String = QWSerialPort.ReadExisting()
|
Dim incoming As String = QWSerialPort.ReadExisting()
|
||||||
'Debug.Print("수신 데이터: " & incoming)
|
'Debug.Print("수신 데이터: " & incoming)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user