📄 test.frm
字号:
End
End If
'all_stop 0
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(pos(0).Text, pos(1).Text, pos(2).Text, 0, 0, AddressOf MyProc)
Else
result = work_inp3(pos(0).Text, pos(1).Text, pos(2).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 And ChkZ.value <> 1 And ChkW.value <> 1 Then
If Mode.value = 1 Then
result = work_inp2(1, pos(0).Text, 2, pos(1).Text, 0, 0, AddressOf MyProc)
Else
result = work_inp2(1, pos(0).Text, 2, pos(1).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkZ.value = 1 And ChkW.value = 1 And ChkX.value <> 1 And ChkY.value <> 1 Then
If Mode.value = 1 Then
result = work_inp2(3, pos(2).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_inp2(3, pos(2).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
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 = 0 Then
MsgBox "人为终止!"
ElseIf result = 1 Then
MsgBox "驱动成功!"
End If
g_WorkStatus = 0
End Sub
Private Sub CmdNeg_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If g_WorkStatus = 1 Then Exit Sub
If ChkX.value = 1 Then
axis = 1
ElseIf ChkY.value = 1 Then
axis = 2
ElseIf ChkZ.value = 1 Then
axis = 3
ElseIf ChkW.value = 1 Then
axis = 4
Else
axis = 0
End If
g_WorkStatus = 1
ifHand = True
If Button = 1 And axis <> 0 Then
hand_move axis, 1, AddressOf MyProc
End If
g_WorkStatus = 0
ifHand = False
End Sub
Private Sub CmdNeg_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
If ifHand = False Then Exit Sub
all_stop 0
g_WorkStatus = 0
ifHand = False
End If
End Sub
Private Sub CmdPmove_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_move4(pos(0).Text, pos(1).Text, pos(2).Text, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move4(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_move3(1, pos(0).Text, 2, pos(1).Text, 3, pos(2).Text, 0, 0, AddressOf MyProc)
Else
result = work_move3(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_move3(1, pos(0).Text, 2, pos(1).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move3(1, pos(0).Text, 2, pos(1).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_move3(1, pos(0).Text, 3, pos(2).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move3(1, pos(0).Text, 3, pos(2).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 And ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_move3(2, pos(1).Text, 3, pos(2).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move3(2, pos(1).Text, 3, pos(2).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkY.value = 1 Then
If Mode.value = 1 Then
result = work_move2(1, pos(0).Text, 2, pos(1).Text, 0, 0, AddressOf MyProc)
Else
result = work_move2(1, pos(0).Text, 2, pos(1).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkZ.value = 1 Then
If Mode.value = 1 Then
result = work_move2(1, pos(0).Text, 3, pos(2).Text, 0, 0, AddressOf MyProc)
Else
result = work_move2(1, pos(0).Text, 3, pos(2).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_move2(1, pos(0).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move2(1, pos(0).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 And ChkZ.value = 1 Then
If Mode.value = 1 Then
result = work_move2(2, pos(1).Text, 3, pos(2).Text, 0, 0, AddressOf MyProc)
Else
result = work_move2(2, pos(1).Text, 3, pos(2).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_move2(2, pos(1).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move2(2, pos(1).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkZ.value = 1 And ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_move2(3, pos(2).Text, 4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move2(3, pos(2).Text, 4, pos(3).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkX.value = 1 Then
If Mode.value = 1 Then
result = work_move1(1, pos(0).Text, 0, 0, AddressOf MyProc)
Else
result = work_move1(1, pos(0).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkY.value = 1 Then
If Mode.value = 1 Then
result = work_move1(2, pos(1).Text, 0, 0, AddressOf MyProc)
Else
result = work_move1(2, pos(1).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkZ.value = 1 Then
If Mode.value = 1 Then
result = work_move1(3, pos(2).Text, 0, 0, AddressOf MyProc)
Else
result = work_move1(3, pos(2).Text, 1, 0, AddressOf MyProc)
End If
ElseIf ChkW.value = 1 Then
If Mode.value = 1 Then
result = work_move1(4, pos(3).Text, 0, 0, AddressOf MyProc)
Else
result = work_move1(4, pos(3).Text, 1, 0, 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 CmdPos_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If g_WorkStatus = 1 Then Exit Sub
If ChkX.value = 1 Then
axis = 1
ElseIf ChkY.value = 1 Then
axis = 2
ElseIf ChkZ.value = 1 Then
axis = 3
ElseIf ChkW.value = 1 Then
axis = 4
Else
axis = 0
End If
g_WorkStatus = 1
ifHand = True
If Button = 1 And axis <> 0 Then
hand_move axis, 0, AddressOf MyProc
End If
g_WorkStatus = 0
ifHand = False
End Sub
Private Sub CmdPos_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
If ifHand = False Then Exit Sub
all_stop 0
g_WorkStatus = 0
ifHand = False
End If
End Sub
Private Sub CmdStop_Click()
all_stop 0
End Sub
Private Sub Form_Load()
For i = 0 To 3
pos(i).Text = 10
Next i
g_WorkStatus = 0
ifHand = False
End Sub
Private Sub Mode_Click()
If Mode.value = 0 Then
Mode.Caption = "绝对模式"
ElseIf Mode.value = 1 Then
Mode.Caption = "相对模式"
End If
End Sub
Private Sub Timer1_Timer()
For i = 1 To 4
LogPos(i - 1).Caption = get_logical_pos(i, 0)
ActPos(i - 1).Caption = get_fact_pos(i, 0)
Speed(i - 1).Caption = get_move_speed(i, 0)
If get_input((i - 1) * 8) = 0 Then
ChkP(i - 1).value = 1
Else
ChkP(i - 1).value = 0
End If
If get_input((i - 1) * 8 + 1) = 0 Then
ChkN(i - 1).value = 1
Else
ChkN(i - 1).value = 0
End If
If get_input((i - 1) * 8 + 2) = 0 Then
ChkHome(i - 1).value = 1
Else
ChkHome(i - 1).value = 0
End If
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -