-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanual_control.py
84 lines (68 loc) · 2.61 KB
/
manual_control.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from PyQt5 import QtCore, QtGui, QtWidgets, uic, QtSvg
from PyQt5.QtCore import *
#from PyQt5.QtCore import Qt, QTimer, QThread
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
import queue
import manual_control_ui
MAX_TABLE_RECORDS = 500
class ManualControl():
active_axis = ""
short_jog = 0.5
long_jog = 5
def __init__(self, hw=None):
self.hw = hw
self.dialog = QtWidgets.QDialog()
self.dialog.ui = manual_control_ui.Ui_ManualControl()
self.dialog.ui.setupUi(self.dialog)
self.dialog.ui.push_manual_go.clicked.connect(self.push_manual_go_clicked)
self.dialog.ui.push_gcode_send.clicked.connect(self.push_gcode_send_clicked)
self.dialog.ui.push_fwd1.clicked.connect(self.push_fwd1_clicked)
self.dialog.ui.push_fwd2.clicked.connect(self.push_fwd2_clicked)
self.dialog.ui.push_back1.clicked.connect(self.push_back1_clicked)
self.dialog.ui.push_back2.clicked.connect(self.push_back2_clicked)
self.set_active_axis('X')
self.enable(False)
def enable(self, status):
if status:
self.dialog.setEnabled(True)
else:
self.dialog.setEnabled(False)
def set_active_axis(self, axis):
self.active_axis = axis
self.dialog.ui.label_active_axis.setText(axis)
def show_modal(self):
ret = self.dialog.exec_()
return ret
def show(self):
self.dialog.show()
def push_manual_go_clicked(self):
pos = self.dialog.ui.double_position.value()
speed = self.dialog.ui.double_speed.value()
if speed > 0:
cmd = "G1 "+self.active_axis+str(pos)
cmd += " F"+str(speed)
else:
cmd = "G0 "+self.active_axis+str(pos)
self.hw.send("G90\n") # ABS
self.hw.send(cmd + "\n")
def push_gcode_send_clicked(self):
cmd = self.dialog.ui.line_gcode_string.text()
self.hw.send(cmd+"\n")
def push_back1_clicked(self):
self.hw.send("G91\n") # ABS
cmd = "G0 " + self.active_axis + "-" + str(self.short_jog)
self.hw.send(cmd + "\n")
def push_back2_clicked(self):
self.hw.send("G91\n") # ABS
cmd = "G0 " + self.active_axis + "-" + str(self.long_jog)
self.hw.send(cmd + "\n")
def push_fwd1_clicked(self):
self.hw.send("G91\n") # ABS
cmd = "G0 " + self.active_axis + str(self.short_jog)
self.hw.send(cmd + "\n")
def push_fwd2_clicked(self):
self.hw.send("G91\n") # ABS
cmd = "G0 " + self.active_axis + str(self.long_jog)
self.hw.send(cmd + "\n")