Skip to content

Commit 523710e

Browse files
committed
qtdragon/hd -use spindle at speed if available to lower spindle
id spindle.0.at-speed is connected to a writting pin, then er should use it to decide when to lower the spindle. Otherwise use the dialog.
1 parent 7b67105 commit 523710e

2 files changed

Lines changed: 52 additions & 13 deletions

File tree

share/qtvcp/screens/qtdragon/qtdragon_handler.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(self, halcomp, widgets, paths):
7070
KEYBIND.add_call('Key_Less','on_keycall_angular_jograte',0)
7171

7272
# some global variables
73+
self._spindle_wait = False
7374
self.probe = None
7475
self.default_setup = os.path.join(PATH.CONFIGPATH, "default_setup.html")
7576
self.docs = os.path.join(PATH.SCREENDIR, PATH.BASEPATH,'docs/getting_started.html')
@@ -117,7 +118,7 @@ def __init__(self, halcomp, widgets, paths):
117118
STATUS.connect('file-loaded', self.file_loaded)
118119
STATUS.connect('all-homed', self.all_homed)
119120
STATUS.connect('not-all-homed', self.not_all_homed)
120-
STATUS.connect('periodic', lambda w: self.update_runtimer())
121+
STATUS.connect('periodic', lambda w: self.periodic_update())
121122
STATUS.connect('command-stopped', lambda w: self.stop_timer())
122123
STATUS.connect('progress', lambda w,p,t: self.updateProgress(p,t))
123124
STATUS.connect('override-limits-changed', lambda w, state, data: self._check_override_limits(state, data))
@@ -692,10 +693,16 @@ def disable_pause_buttons(self, state):
692693
else:
693694
self.h['spindle-inhibit'] = False
694695
self.add_status('Spindle re-started')
695-
# instantiate warning box
696-
info = "Wait for spindle at speed signal before resuming"
697-
mess = {'NAME':'MESSAGE', 'ICON':'WARNING', 'ID':'_wait_resume_', 'MESSAGE':'CAUTION', 'MORE':info, 'TYPE':'OK'}
698-
ACTION.CALL_DIALOG(mess)
696+
# If spindle at speed is connected use it lower spindle
697+
if self.h.hal.pin_has_writer('spindle.0.at-speed'):
698+
self._spindle_wait=True
699+
return
700+
else:
701+
# or wait for dialog to close before lowering spindle
702+
# instantiate warning box
703+
info = "Wait for spindle at speed signal before resuming"
704+
mess = {'NAME':'MESSAGE', 'ICON':'WARNING', 'ID':'_wait_resume_', 'MESSAGE':'CAUTION', 'MORE':info, 'TYPE':'OK'}
705+
ACTION.CALL_DIALOG(mess)
699706

700707
# override frame
701708
def slow_button_clicked(self, state):
@@ -1142,6 +1149,18 @@ def update_rpm(self, speed):
11421149
self.w.lbl_spindle_set.style().unpolish(self.w.lbl_spindle_set)
11431150
self.w.lbl_spindle_set.style().polish(self.w.lbl_spindle_set)
11441151

1152+
def periodic_update(self):
1153+
# if waiting and up to speed, lower spindle
1154+
if self._spindle_wait:
1155+
if bool(self.h.hal.get_value('spindle.0.at-speed')):
1156+
self.h['eoffset-spindle-count'] = 0
1157+
self.h['eoffset-clear'] = True
1158+
self.add_status('Spindle lowered')
1159+
self.h['eoffset-clear'] = False
1160+
self._spindle_wait = False
1161+
1162+
self.update_runtimer()
1163+
11451164
def update_runtimer(self):
11461165
if not self.timer_on or STATUS.is_auto_paused():
11471166
return
@@ -1155,6 +1174,7 @@ def update_runtimer(self):
11551174
minutes, seconds = divmod(remainder, 60)
11561175
self.w.lbl_runtime.setText("{:02d}:{:02d}:{:02d}".format(hours, minutes, seconds))
11571176

1177+
11581178
def start_timer(self):
11591179
self.run_time = 0
11601180
self.timer_on = True

share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def __init__(self, halcomp, widgets, paths):
7373

7474
# some global variables
7575
self.factor = 1.0
76+
self._spindle_wait = False
7677
self.probe = None
7778
self.default_setup = os.path.join(PATH.CONFIGPATH, "default_setup.html")
7879
self.docs = os.path.join(PATH.SCREENDIR, PATH.BASEPATH,'docs/getting_started.html')
@@ -115,7 +116,7 @@ def __init__(self, halcomp, widgets, paths):
115116
STATUS.connect('file-loaded', self.file_loaded)
116117
STATUS.connect('all-homed', self.all_homed)
117118
STATUS.connect('not-all-homed', self.not_all_homed)
118-
STATUS.connect('periodic', lambda w: self.update_runtimer())
119+
STATUS.connect('periodic', lambda w: self.periodic_update())
119120
STATUS.connect('interp-idle', lambda w: self.stop_timer())
120121
STATUS.connect('actual-spindle-speed-changed',self.update_spindle)
121122
STATUS.connect('requested-spindle-speed-changed',self.update_spindle_requested)
@@ -703,13 +704,19 @@ def btn_pause_spindle_clicked(self, state):
703704
# turn spindle back on
704705
self.h['spindle-inhibit'] = False
705706
self.add_status('Spindle re-started')
706-
# wait for dialog to close before lowering spindle
707-
if STATUS.is_auto_running():
708-
info = "Wait for spindle at speed signal before resuming"
709-
mess = {'NAME':'MESSAGE', 'ICON':'WARNING',
710-
'ID':'_wait_resume_', 'MESSAGE':'CAUTION',
711-
'NONBLOCKING':'True', 'MORE':info, 'TYPE':'OK'}
712-
ACTION.CALL_DIALOG(mess)
707+
708+
# If spindle at speed is connected use it lower spindle
709+
if self.h.hal.pin_has_writer('spindle.0.at-speed'):
710+
self._spindle_wait=True
711+
return
712+
else:
713+
# or wait for dialog to close before lowering spindle
714+
if STATUS.is_auto_running():
715+
info = "Wait for spindle at speed signal before resuming"
716+
mess = {'NAME':'MESSAGE', 'ICON':'WARNING',
717+
'ID':'_wait_resume_', 'MESSAGE':'CAUTION',
718+
'NONBLOCKING':'True', 'MORE':info, 'TYPE':'OK'}
719+
ACTION.CALL_DIALOG(mess)
713720

714721
def btn_enable_comp_clicked(self, state):
715722
if state:
@@ -1193,6 +1200,18 @@ def do_file_copy(self):
11931200
except Exception as e:
11941201
self.add_status("Unable to copy file. %s" %e, WARNING)
11951202

1203+
def periodic_update(self):
1204+
# if waiting and up to speed, lower spindle
1205+
if self._spindle_wait:
1206+
if bool(self.h.hal.get_value('spindle.0.at-speed')):
1207+
self.h['eoffset-spindle-count'] = 0
1208+
self.h['eoffset-clear'] = True
1209+
self.add_status('Spindle lowered')
1210+
self.h['eoffset-clear'] = False
1211+
self._spindle_wait = False
1212+
1213+
self.update_runtimer()
1214+
11961215
def update_runtimer(self):
11971216
if not self.timer_on or STATUS.is_auto_paused():
11981217
return

0 commit comments

Comments
 (0)