hexagon logo

How to wait end of program on Automation code.

I made some automation program.

I want to run 4 programs with on button click.

I can run 4 programs.

But, program close before end of first program.

How can i wait for end of program.

This is parts of my code.






Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

If RB_M.Checked = True Then

PCDMISapplication = New PCDLRN.Application
AppEvents = PCDMISapplication.ApplicationEvents


PCDMISprograms = PCDMISapplication.PartPrograms
PCDMISapplication.Visible = True

Dim F_List As String = Dir("C:\JoyAutomation_TCK\List")
Dim L_Data As String
Dim P_P_C = 0

If F_List = "" Then
Else
If Mid(Trim(F_List.ToString()), 1, Len(Trim(F_List.ToString())) - 4) = Combo_Part_Name.SelectedItem Then

FileOpen(1, "C:\JoyAutomation_TCK\List" & Combo_Part_Name.SelectedItem & ".txt", OpenMode.Input)
While Not EOF(1)
L_Data = LineInput(1)
If L_Data = "" Then
Else
P_P_C += 1
If P_P_C <= CInt(Combo_Part_Count.SelectedItem) + 1 Then
PCDpartPrg = PCDMISprograms.Open("C:\Users\Robert Eom\Desktop\TCK 개발\K3T001215 1매\MiniRoutine\1_K3T001215-00 SiC INSERT,SMOD,2.8 STEP.prg", "Offline")
Threading.Thread.Sleep(2000) ' Wait while program opens
PCDMISapplication.WaitUntilReady(200)
PCDpartPrg.Visible = True
PCDpartPrg.EXECUTE()
PCDpartPrg.Close()
End If

End If
End While
FileClose(1)
End If

Do Until F_List = ""
F_List = Dir()
If F_List = "" Then
Else
If Mid(Trim(F_List.ToString()), 1, Len(Trim(F_List.ToString())) - 4) = Combo_Part_Name.SelectedItem Then
FileOpen(2, "C:\JoyAutomation_TCK\List" & Combo_Part_Name.SelectedItem & ".txt", OpenMode.Input)
While Not EOF(2)
L_Data = LineInput(2)
If L_Data = "" Then
Else
P_P_C += 1
If P_P_C <= CInt(Combo_Part_Count.SelectedItem) + 1 Then
PCDpartPrg = PCDMISprograms.Open("C:\Users\Robert Eom\Desktop\TCK 개발\K3T001215 1매\MiniRoutine\1_K3T001215-00 SiC INSERT,SMOD,2.8 STEP.prg", "Offline")
Threading.Thread.Sleep(2000) ' Wait while program opens
PCDMISapplication.WaitUntilReady(200)
PCDpartPrg.Visible = True
PCDpartPrg.EXECUTE()
PCDpartPrg.Close()
End If
End If
End While
FileClose(2)
End If

End If
Loop
End If


End If




'PCDMISapplication = New PCDLRN.Application
'PCDMISprograms = PCDMISapplication.PartPrograms
'PCDMISapplication.Visible = True
'PCDpartPrg = PCDMISprograms.Open("C:\Users\Robert Eom\Desktop\TCK 개발\K3T001215 1매\MiniRoutine\1_K3T001215-00 SiC INSERT,SMOD,2.8 STEP.prg", "Offline")
'Threading.Thread.Sleep(2000) ' Wait while program opens
'PCDMISapplication.WaitUntilReady(200)
'PCDpartPrg.Visible = True
'PCDpartPrg.EXECUTE()
'PCDpartPrg.Close()

End Sub
Parents
  • I made some automation program.
    How can i wait for end of program.


    I see that you've got Application Events setup. I'd use the AppEvents.OnEndExecution event. When this event fires, close the running program, open and execute the next one.

    The code to do this would be in the OnEndExecution event sub.

    Thanks for the indents
Reply
  • I made some automation program.
    How can i wait for end of program.


    I see that you've got Application Events setup. I'd use the AppEvents.OnEndExecution event. When this event fires, close the running program, open and execute the next one.

    The code to do this would be in the OnEndExecution event sub.

    Thanks for the indents
Children
No Data