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
|
||||
|
||||
If AutoMeasureScale() Then
|
||||
lbNowWeight.Text = weightResult2 ' 실제 측정값 표시
|
||||
lbNowWeight.Text = weightResult2
|
||||
|
||||
If weight_compare() Then
|
||||
lbWeight.BackColor = Color.Green
|
||||
@ -158,6 +158,9 @@ Public Class weightForm
|
||||
End If
|
||||
|
||||
ElseIf mainForm.rdbWeightQW.Checked = True Then
|
||||
|
||||
lbNowWeight.Text = weightResult2
|
||||
|
||||
' 실제 시리얼 데이터 직접 사용
|
||||
If weightResult2 <= 0 Then ' 1g 이하면 비어있음
|
||||
statusTimer.Enabled = True
|
||||
@ -168,7 +171,7 @@ Public Class weightForm
|
||||
lbWeight.BackColor = Color.White
|
||||
Else
|
||||
ZeroTimer.Enabled = False
|
||||
lbWeight.Text = "저울을 비워주세요 (현재: " & weightResult2.ToString("F0") & "g)"
|
||||
lbWeight.Text = "저울을 비워주세요."
|
||||
lbWeight.BackColor = Color.Red
|
||||
ZeroTimer.Enabled = True
|
||||
End If
|
||||
@ -210,8 +213,9 @@ Public Class weightForm
|
||||
Application.DoEvents()
|
||||
Loop
|
||||
End Sub
|
||||
|
||||
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"
|
||||
End Function
|
||||
|
||||
@ -282,6 +286,8 @@ Public Class weightForm
|
||||
|
||||
Private Sub QWSerialPort_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles QWSerialPort.DataReceived
|
||||
Try
|
||||
System.Threading.Thread.Sleep(100) ' 100ms 딜레이
|
||||
|
||||
Dim incoming As String = QWSerialPort.ReadExisting()
|
||||
'Debug.Print("수신 데이터: " & incoming)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user