fix: 종료 시도시 여러 번 시도하여 종료할수 있게 수정

This commit is contained in:
kje97 2025-06-25 17:43:47 +09:00
parent 36c8c427b3
commit 0fb6973e93

View File

@ -2605,14 +2605,82 @@ SettingFail:
End Function End Function
'Private Sub Jig_End()
' If EndTest() Then
' txbWindow.AppendText("JIG Serial Test End : FAIL" & vbCrLf)
' Exit Sub
' End If
' txbWindow.AppendText("JIG Serial Test End : Success" & vbCrLf)
'End Sub
Private Sub Jig_End() Private Sub Jig_End()
If EndTest() Then For retryCount As Integer = 0 To 2
txbWindow.AppendText("JIG Serial Test End : FAIL" & vbCrLf) txbWindow.AppendText($"JIG 종료 시도 {retryCount + 1}/3" & vbCrLf)
Exit Sub
End If If EndTest() Then
txbWindow.AppendText("JIG Serial Test End : Success" & vbCrLf) txbWindow.AppendText($"JIG Serial Test End : FAIL (시도 {retryCount + 1})" & vbCrLf)
If retryCount < 2 Then
Threading.Thread.Sleep(1000)
If JigSerial IsNot Nothing AndAlso JigSerial.IsOpen Then
JigSerial.DiscardInBuffer()
JigSerial.DiscardOutBuffer()
Threading.Thread.Sleep(200)
End If
Continue For
Else
txbWindow.AppendText("JIG 정상 종료 실패 - 강제 종료 실행" & vbCrLf)
ForceJigShutdown()
Exit Sub
End If
Else
txbWindow.AppendText("JIG Serial Test End : Success" & vbCrLf)
Exit For
End If
Next
End Sub End Sub
Private Sub ForceJigShutdown()
Try
txbWindow.AppendText("강제 JIG 종료 시작" & vbCrLf)
If JigSerial IsNot Nothing AndAlso JigSerial.IsOpen Then
Dim shutdownCommands() As String = {"[endmft]"}
For Each cmd In shutdownCommands
Try
SendData(cmd)
Threading.Thread.Sleep(500)
txbWindow.AppendText($"강제 종료 명령 전송: {cmd}" & vbCrLf)
Catch
End Try
Next
Try
Dim portName As String = JigSerial.PortName
Dim baudRate As Integer = JigSerial.BaudRate
JigSerial.Close()
Threading.Thread.Sleep(1000)
JigSerial.PortName = portName
JigSerial.BaudRate = baudRate
JigSerial.Open()
txbWindow.AppendText("시리얼 포트 재연결 완료" & vbCrLf)
Catch serialEx As Exception
txbWindow.AppendText($"시리얼 포트 재연결 실패: {serialEx.Message}" & vbCrLf)
End Try
End If
Catch ex As Exception
txbWindow.AppendText($"강제 종료 중 오류: {ex.Message}" & vbCrLf)
End Try
End Sub
Public Function EPTestRun() As Boolean Public Function EPTestRun() As Boolean
Dim ForCnt As Int16 = 0 Dim ForCnt As Int16 = 0
Try Try
@ -4488,12 +4556,32 @@ ErrorEnd:
End Function End Function
Private Sub InitializeDeviceState()
Try
txbWindow.AppendText("기기 상태 초기화 시작..." & vbCrLf)
Try
TestMode_On(0) ' MFT 모드를 0으로 초기화
Threading.Thread.Sleep(300)
Catch
End Try
txbWindow.AppendText("기기 상태 초기화 완료" & vbCrLf)
Catch ex As Exception
txbWindow.AppendText("기기 초기화 중 오류 (무시하고 계속): " & ex.Message & vbCrLf)
End Try
End Sub
Private Sub rfFunction() Private Sub rfFunction()
Try Try
StartTime = MeasureTimeAll(MeasStart) StartTime = MeasureTimeAll(MeasStart)
TestData.Test_Serial = txbBarcode.Text TestData.Test_Serial = txbBarcode.Text
InitializeDeviceState()
If StartSwitch = True Then If StartSwitch = True Then
If JigSerial.IsOpen = True Then If JigSerial.IsOpen = True Then
@ -4625,6 +4713,19 @@ ProcessEnd:
Jig_End() Jig_End()
NormalEnd: NormalEnd:
myscope.IO.Clear() myscope.IO.Clear()
'txbWindow.AppendText("[" & MeasureTimeAll(MeasEnd) & "ms] Test Play" & vbCrLf)
Try
If TestError = False Then
Jig_End() ' 지그 전원 차단
TestMode_On(0) ' MFT 모드 초기화
txbWindow.AppendText("비정상 종료로 인한 전원 차단" & vbCrLf)
End If
Catch normalEx As Exception
txbWindow.AppendText("정상 종료 처리 중 오류: " & normalEx.Message & vbCrLf)
End Try
'myscope.IO.Clear()
txbWindow.AppendText("[" & MeasureTimeAll(MeasEnd) & "ms] Test Play" & vbCrLf) txbWindow.AppendText("[" & MeasureTimeAll(MeasEnd) & "ms] Test Play" & vbCrLf)
End Sub End Sub
@ -5260,6 +5361,29 @@ ProcessEnd:
txbOkCount.Text = Val(txbOkCount.Text) + 1 txbOkCount.Text = Val(txbOkCount.Text) + 1
End Sub End Sub
'Private Sub RFReCount()
' If dupDATA = 0 Then
' txbDayCount.Text = Val(txbDayCount.Text) + 1
' If processNum = TestStepList.RF_NewSuc Or processNum = TestStepList.Rf_ReSuc Then
' txbOkCount.Text = Val(txbOkCount.Text) + 1
' Else
' txbNgCount.Text = Val(txbNgCount.Text) + 1
' End If
' Else
' If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then
' If processNum = TestStepList.HF_NewSuc Or processNum = TestStepList.HF_ReSuc Then
' txbOkCount.Text = Val(txbOkCount.Text) + 1
' txbNgCount.Text = Val(txbNgCount.Text) - 1
' End If
' Else
' If processNum = TestStepList.HF_NEWFail Or processNum = TestStepList.HF_ReFail Then
' txbOkCount.Text = Val(txbOkCount.Text) - 1
' txbNgCount.Text = Val(txbNgCount.Text) + 1
' End If
' End If
' End If
'End Sub
Private Sub RFReCount() Private Sub RFReCount()
If dupDATA = 0 Then If dupDATA = 0 Then
txbDayCount.Text = Val(txbDayCount.Text) + 1 txbDayCount.Text = Val(txbDayCount.Text) + 1
@ -5269,20 +5393,38 @@ ProcessEnd:
txbNgCount.Text = Val(txbNgCount.Text) + 1 txbNgCount.Text = Val(txbNgCount.Text) + 1
End If End If
Else Else
If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then ' formType에 따라 다른 로직 적용
If processNum = TestStepList.HF_NewSuc Or processNum = TestStepList.HF_ReSuc Then If formType = formTypeList.altoPD Then
txbOkCount.Text = Val(txbOkCount.Text) + 1 ' Alto PD의 경우 Alto 관련 TestStep 사용
txbNgCount.Text = Val(txbNgCount.Text) - 1 If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then
If processNum = TestStepList.HF_NewSuc Or processNum = TestStepList.HF_ReSuc Then
txbOkCount.Text = Val(txbOkCount.Text) + 1
txbNgCount.Text = Val(txbNgCount.Text) - 1
End If
Else
If processNum = TestStepList.HF_NEWFail Or processNum = TestStepList.HF_ReFail Then
txbOkCount.Text = Val(txbOkCount.Text) - 1
txbNgCount.Text = Val(txbNgCount.Text) + 1
End If
End If End If
Else Else
If processNum = TestStepList.HF_NEWFail Or processNum = TestStepList.HF_ReFail Then ' 일반 RF의 경우 RF 관련 TestStep 사용
txbOkCount.Text = Val(txbOkCount.Text) - 1 If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then
txbNgCount.Text = Val(txbNgCount.Text) + 1 If processNum = TestStepList.RF_NewSuc Or processNum = TestStepList.Rf_ReSuc Then
txbOkCount.Text = Val(txbOkCount.Text) + 1
txbNgCount.Text = Val(txbNgCount.Text) - 1
End If
Else
If processNum = TestStepList.Rf_NewFail Or processNum = TestStepList.RF_ReFail Then
txbOkCount.Text = Val(txbOkCount.Text) - 1
txbNgCount.Text = Val(txbNgCount.Text) + 1
End If
End If End If
End If End If
End If End If
End Sub End Sub
Private Function CountUpdate() As Boolean Private Function CountUpdate() As Boolean
If rdbAltoPD.Checked = True Then If rdbAltoPD.Checked = True Then
DBCmd = "UPDATE " & pd1CntTableNow & " SET PD1_AltoCnt = '" & txbDayCount.Text & "', PD1_AltoOkCnt = '" & txbOkCount.Text & "', PD1_AltoNgCnt = '" & txbNgCount.Text & "' WHERE PD1_Date = '" & NowDate & "'" DBCmd = "UPDATE " & pd1CntTableNow & " SET PD1_AltoCnt = '" & txbDayCount.Text & "', PD1_AltoOkCnt = '" & txbOkCount.Text & "', PD1_AltoNgCnt = '" & txbNgCount.Text & "' WHERE PD1_Date = '" & NowDate & "'"