Skip to content

Commit

Permalink
qtdragon -add ok/cancel HAL pins for dialogs
Browse files Browse the repository at this point in the history
user wished to use a external operator panel to aknowledge dialogs
  • Loading branch information
c-morley committed Oct 11, 2024
1 parent 18d4dbc commit 8bc4bde
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions share/qtvcp/screens/qtdragon/qtdragon_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(self, halcomp, widgets, paths):

# some global variables
self.factor = 1.0
self._dialog_message = None
self._spindle_wait = False
self.probe = None
self.default_setup = os.path.join(PATH.CONFIGPATH, "default_setup.html")
Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(self, halcomp, widgets, paths):
self.statusbar_reset_time = 10000 # ten seconds

STATUS.connect('general', self.dialog_return)
STATUS.connect('dialog-request', self.dialog_request)
STATUS.connect('state-on', lambda w: self.enable_onoff(True))
STATUS.connect('state-off', lambda w: self.enable_onoff(False))
STATUS.connect('mode-manual', lambda w: self.enable_auto(True))
Expand Down Expand Up @@ -351,6 +353,13 @@ def init_pins(self):
# total external offset
pin = QHAL.newpin("eoffset-value", QHAL.HAL_FLOAT, QHAL.HAL_IN)

pin = QHAL.newpin("dialog-ok", QHAL.HAL_BIT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.dialog_ext_control(p,v,1))
pin = QHAL.newpin("dialog-no", QHAL.HAL_BIT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.dialog_ext_control(p,v,2))
pin = QHAL.newpin("dialog-cancel", QHAL.HAL_BIT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.dialog_ext_control(p,v,0))

def init_preferences(self):
if not self.w.PREFS_:
txt = _translate("HandlerClass","No preference file found, enable preferences in screenoptions widget")
Expand Down Expand Up @@ -626,6 +635,11 @@ def dialog_return(self, w, message):
self.h['spindle-inhibit'] = False
self.add_status(_translate("HandlerClass",'Spindle lowered after machine stopped'))

self._dialog_message = None

def dialog_request(self,w, message):
self._dialog_message = message

def user_system_changed(self, data):
sys = self.system_list[int(data) - 1]
self.w.offset_table.selectRow(int(data) + 3)
Expand Down Expand Up @@ -1766,6 +1780,12 @@ def initiate_axis_dro(self, num, axis):
except Exception as e:
self.w['minus_jogbutton_{}'.format(num)].setProperty('text','{}-'.format(axis))

def dialog_ext_control(self, pin, value, answer):
if value:
if not self._dialog_message is None:
name = self._dialog_message.get('NAME')
STATUS.emit('dialog-update',{'NAME':name,'response':answer})

#####################
# KEY BINDING CALLS #
#####################
Expand Down

0 comments on commit 8bc4bde

Please sign in to comment.