📄 test.frm
字号:
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim result As Long
Dim g_WorkStatus As Integer
Dim ifHand As Boolean
Private Sub CmdArc_Click()
If g_WorkStatus = 1 Then Exit Sub
Dim result As Integer
Dim xY(6) As Single
xY(0) = 5
xY(1) = 5
xY(2) = 15
xY(3) = 15
xY(4) = 5
xY(5) = 5
g_WorkStatus = 1
If ChkX.value = 1 And ChkY.value = 1 Then
result = work_arc(1, 2, xY(0), 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkZ.value = 1 Then
result = work_arc(1, 3, xY(0), 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkW.value = 1 Then
result = work_arc(1, 4, xY(0), 0, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkZ.value = 1 Then
result = work_arc(2, 3, xY(0), 0, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkW.value = 1 Then
result = work_arc(2, 4, xY(0), 0, AddressOf MyProc)
ElseIf ChkZ.value = 1 And ChkW.value = 1 Then
result = work_arc(3, 4, xY(0), 0, AddressOf MyProc)
Else
MsgBox "选取的轴不能进行插补!"
g_WorkStatus = 0
Exit Sub
End If
If result = -1 Then
MsgBox "有禁止轴参与运动,运动终止!"
ElseIf result = -2 Then
MsgBox "软限位报警,运动终止!"
ElseIf result = -3 Then
MsgBox "限位报警停止!"
ElseIf result = -4 Then
MsgBox "三点不能构成圆弧!"
ElseIf result = 0 Then
MsgBox "人为终止!"
ElseIf result = 1 Then
MsgBox "驱动成功!"
End If
g_WorkStatus = 0
End Sub
Private Sub CmdContinue_Click()
If g_WorkStatus = 1 Then Exit Sub
g_WorkStatus = 1
If ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
result = continue_move4(0, 1, 0, 1, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 Then
result = continue_move3(1, 0, 2, 0, 3, 0, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkW.value = 1 Then
result = continue_move3(1, 0, 2, 0, 4, 0, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
result = continue_move3(1, 0, 3, 0, 4, 0, 0, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
result = continue_move3(2, 0, 3, 0, 4, 0, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkY.value = 1 Then
result = continue_move2(1, 0, 2, 0, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkZ.value = 1 Then
result = continue_move2(1, 0, 3, 0, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkW.value = 1 Then
result = continue_move2(1, 0, 4, 0, 0, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkZ.value = 1 Then
result = continue_move2(2, 0, 3, 0, 0, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkW.value = 1 Then
result = continue_move2(2, 0, 4, 0, 0, AddressOf MyProc)
ElseIf ChkZ.value = 1 And ChkW.value = 1 Then
result = continue_move2(3, 0, 4, 0, 0, AddressOf MyProc)
ElseIf ChkX.value = 1 Then
result = continue_move1(1, 0, 0, AddressOf MyProc)
ElseIf ChkY.value = 1 Then
result = continue_move1(2, 0, 0, AddressOf MyProc)
ElseIf ChkZ.value = 1 Then
result = continue_move1(3, 0, 0, AddressOf MyProc)
ElseIf ChkW.value = 1 Then
result = continue_move1(4, 0, 0, AddressOf MyProc)
Else
Exit Sub
End If
If result = -1 Then
MsgBox "有禁止轴参与运动,运动终止!"
ElseIf result = -3 Then
MsgBox "限位报警停止!"
ElseIf result = 0 Then
MsgBox "人为终止!"
ElseIf result = 1 Then
MsgBox "驱动成功!"
End If
g_WorkStatus = 0
End Sub
Private Sub CmdFree_Click()
If g_WorkStatus = 1 Then Exit Sub
g_WorkStatus = 1
If ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move4(pos(0).Text, 5, 8, 0.2, pos(1).Text, 3, 5, 0.1, pos(2).Text, 6, 7, 0.1, pos(3).Text, 4, 5, 0.1, 0, AddressOf MyProc)
Else
result = free_move4(pos(0).Text, 5, 8, 0.2, pos(1).Text, 3, 5, 0.1, pos(2).Text, 6, 7, 0.1, pos(3).Text, 4, 5, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 Then
If Mode.value = 1 Then
result = free_move3(1, pos(0).Text, 5, 8, 0.2, 2, pos(1).Text, 3, 5, 0.1, 3, pos(2).Text, 6, 7, 0.1, 0, AddressOf MyProc)
Else
result = free_move3(1, pos(0).Text, 5, 8, 0.2, 2, pos(1).Text, 3, 5, 0.1, 3, pos(2).Text, 6, 7, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move3(1, pos(0).Text, 5, 8, 0.2, 2, pos(1).Text, 3, 5, 0.1, 4, pos(3).Text, 6, 7, 0.1, 0, AddressOf MyProc)
Else
result = free_move3(1, pos(0).Text, 5, 8, 0.2, 2, pos(1).Text, 3, 5, 0.1, 4, pos(3).Text, 6, 7, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move3(1, pos(0).Text, 5, 8, 0.2, 3, pos(2).Text, 3, 5, 0.1, 4, pos(3).Text, 6, 7, 0.1, 0, AddressOf MyProc)
Else
result = free_move3(1, pos(0).Text, 5, 8, 0.2, 3, pos(2).Text, 3, 5, 0.1, 4, pos(3).Text, 6, 7, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move3(2, pos(1).Text, 5, 8, 0.2, 3, pos(2).Text, 3, 5, 0.1, 4, pos(3).Text, 6, 7, 0.1, 0, AddressOf MyProc)
Else
result = free_move3(2, pos(1).Text, 5, 8, 0.2, 3, pos(2).Text, 3, 5, 0.1, 4, pos(3).Text, 6, 7, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 Then
If Mode.value = 1 Then
result = free_move2(1, pos(0).Text, 4, 5, 0.1, 2, pos(1).Text, 5, 6, 0.2, 0, AddressOf MyProc)
Else
result = free_move2(1, pos(0).Text, 4, 5, 0.1, 2, pos(1).Text, 5, 6, 0.2, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkZ.value = 1 Then
If Mode.value = 1 Then
result = free_move2(1, pos(0).Text, 4, 5, 0.1, 3, pos(2).Text, 5, 6, 0.2, 0, AddressOf MyProc)
Else
result = free_move2(1, pos(0).Text, 4, 5, 0.1, 3, pos(2).Text, 5, 6, 0.2, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move2(1, pos(0).Text, 4, 5, 0.1, 4, pos(3).Text, 5, 6, 0.2, 0, AddressOf MyProc)
Else
result = free_move2(1, pos(0).Text, 4, 5, 0.1, 4, pos(3).Text, 5, 6, 0.2, 1, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 And ChkZ.value = 1 Then
If Mode.value = 1 Then
result = free_move2(2, pos(1).Text, 4, 5, 0.1, 3, pos(2).Text, 5, 6, 0.2, 0, AddressOf MyProc)
Else
result = free_move2(2, pos(1).Text, 4, 5, 0.1, 3, pos(2).Text, 5, 6, 0.2, 1, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move2(2, pos(1).Text, 4, 5, 0.1, 4, pos(3).Text, 5, 6, 0.2, 0, AddressOf MyProc)
Else
result = free_move2(2, pos(1).Text, 4, 5, 0.1, 4, pos(3).Text, 5, 6, 0.2, 1, AddressOf MyProc)
End If
ElseIf ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move2(3, pos(2).Text, 4, 5, 0.1, 4, pos(3).Text, 5, 6, 0.2, 0, AddressOf MyProc)
Else
result = free_move2(3, pos(2).Text, 4, 5, 0.1, 4, pos(3).Text, 5, 6, 0.2, 1, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 Then
If Mode.value = 1 Then
result = free_move1(1, pos(0).Text, 4, 5, 0.1, 0, AddressOf MyProc)
Else
result = free_move1(1, pos(0).Text, 4, 5, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 Then
If Mode.value = 1 Then
result = free_move1(2, pos(1).Text, 4, 5, 0.1, 0, AddressOf MyProc)
Else
result = free_move1(2, pos(1).Text, 4, 5, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkZ.value = 1 Then
If Mode.value = 1 Then
result = free_move1(3, pos(2).Text, 4, 5, 0.1, 0, AddressOf MyProc)
Else
result = free_move1(3, pos(2).Text, 4, 5, 0.1, 1, AddressOf MyProc)
End If
ElseIf ChkW.value = 1 Then
If Mode.value = 1 Then
result = free_move1(4, pos(3).Text, 4, 5, 0.1, 0, AddressOf MyProc)
Else
result = free_move1(4, pos(3).Text, 4, 5, 0.1, 1, AddressOf MyProc)
End If
Else
Exit Sub
End If
If result = -1 Then
MsgBox "有禁止轴参与运动,运动终止!"
ElseIf result = -2 Then
MsgBox "软限位报警,运动终止!"
ElseIf result = -3 Then
MsgBox "限位报警停止!"
ElseIf result = 0 Then
MsgBox "人为终止!"
ElseIf result = 1 Then
MsgBox "驱动成功!"
End If
g_WorkStatus = 0
End Sub
Private Sub CmdHome_Click()
If g_WorkStatus = 1 Then Exit Sub
g_WorkStatus = 1
If ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
result = home4(AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 Then
result = home3(1, 2, 3, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkW.value = 1 Then
result = home3(1, 2, 4, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
result = home3(1, 3, 4, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
result = home3(2, 3, 4, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkY.value = 1 Then
result = home2(1, 2, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkZ.value = 1 Then
result = home2(1, 3, AddressOf MyProc)
ElseIf ChkX.value = 1 And ChkW.value = 1 Then
result = home2(1, 4, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkZ.value = 1 Then
result = home2(2, 3, AddressOf MyProc)
ElseIf ChkY.value = 1 And ChkW.value = 1 Then
result = home2(2, 4, AddressOf MyProc)
ElseIf ChkZ.value = 1 And ChkW.value = 1 Then
result = home2(3, 4, AddressOf MyProc)
ElseIf ChkX.value = 1 Then
result = home1(1, AddressOf MyProc)
ElseIf ChkY.value = 1 Then
result = home1(2, AddressOf MyProc)
ElseIf ChkZ.value = 1 Then
result = home1(3, AddressOf MyProc)
ElseIf ChkW.value = 1 Then
result = home1(4, AddressOf MyProc)
Else
Exit Sub
End If
If result = -1 Then
MsgBox "有禁止轴参与运动,回原点终止!"
ElseIf result = -2 Then
MsgBox "未找到原点信号,回原点失败!"
ElseIf result = 0 Then
MsgBox "回原点人为终止!"
ElseIf result = 1 Then
MsgBox "回原点成功!"
End If
g_WorkStatus = 0
End Sub
Private Sub CmdInit_Click()
result = adt8940_init_board
If result <= 0 Then
MsgBox "控制卡检测错误!"
End
End If
Dim g_cardVer As Integer
g_cardVer = get_hardware_ver(0)
hard.Caption = "硬件版本:V" + CStr(g_cardVer)
End Sub
Private Sub CmdInp_Click()
If g_WorkStatus = 1 Then Exit Sub
g_WorkStatus = 1
If ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_inp4(pos(0).Text, pos(1).Text, pos(2).Text, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_inp4(pos(0).Text, pos(1).Text, pos(2).Text, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkZ.value = 1 Then
If Mode.value = 1 Then
result = work_inp3(1, pos(0).Text, 2, pos(1).Text, 3, pos(2).Text, 0, 0, AddressOf MyProc)
Else
result = work_inp3(1, pos(0).Text, 2, pos(1).Text, 3, pos(2).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_inp3(1, pos(0).Text, 2, pos(1).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -