diff --git a/configs/sim/gmoccapy/gmoccapy.ini b/configs/sim/gmoccapy/gmoccapy.ini index 9aa8a90074e..edc432101f1 100644 --- a/configs/sim/gmoccapy/gmoccapy.ini +++ b/configs/sim/gmoccapy/gmoccapy.ini @@ -96,7 +96,11 @@ HALUI = halui # Trajectory planner section -------------------------------------------------- [HALUI] -#No Content +MDI_COMMAND = M6 T1 +MDI_COMMAND = M6 T2 +MDI_COMMAND = M61 Q1 +MDI_COMMAND = M61 Q2 +MDI_COMMAND = M6 T3 G4 P10 [TRAJ] COORDINATES = X Y Z diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.py b/src/emc/usr_intf/gmoccapy/gmoccapy.py index 950476bb6aa..bcbdf453ab0 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.py +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.py @@ -2655,7 +2655,8 @@ def on_hal_status_interp_idle(self, widget): else: self._change_kbd_image("img_macro_menu_stop") self.macro_dic["keyboard"].set_sensitive(False) - + + self._hide_abort_button() self.widgets.btn_run.set_sensitive(True) self.widgets.btn_stop.set_sensitive(False) @@ -2685,9 +2686,50 @@ def on_hal_status_interp_run(self, widget): self.widgets.btn_stop.set_sensitive(True) self._change_kbd_image("img_macro_menu_stop") + + self._show_abort_button() # Show only in MDI mode? self.macro_dic["keyboard"].set_sensitive(True) self.elapsed_time_run = 0 + # Goes through all buttonboxes in "ntb_button" and replaces the last button by an mdi abort button. + # It stores the removes buttons in a dict to be restored later. + def _show_abort_button(self): + self.saved_buttons = {} + for page_num in range(self.widgets.ntb_button.get_n_pages()): + buttonbox = self.widgets.ntb_button.get_nth_page(page_num) + buttons = buttonbox.get_children() + # Some buttonboxes does not contain buttons; don't replace for auto mode and mdi + if buttons and Gtk.Buildable.get_name(buttonbox) not in ["hbtb_auto", "hbtb_MDI"]: + button = buttons[-1] + self.saved_buttons[page_num] = button + buttonbox.remove(button) + # Copy image to pixbuf because one image cannot be used twice + pixbuf = self.widgets.img_macro_menu_stop.get_pixbuf() + image_abort = Gtk.Image.new_from_pixbuf(pixbuf) + button_abort = self._new_button_with_predefined_image(name="img_macro_menu_stop", + size=_DEFAULT_BB_SIZE, image=image_abort) + # TBD: add function. Also refactor self._change_kbd_image() + # new_button.connect("clicked", self._on_abort_mdi_clicked) + self.macro_dic["keyboard"].set_image(Gtk.Image.new_from_pixbuf(pixbuf)) + button_abort.show() + buttonbox.add(button_abort) + + # Goes through all buttonboxes in "ntb_button" and replaces the last button by the saved button from the dict. + def _hide_abort_button(self): + # Try block here because self.saved_buttons is first created in _show_abort_button() + try: + for page_num in range(self.widgets.ntb_button.get_n_pages()): + buttonbox = self.widgets.ntb_button.get_nth_page(page_num) + buttons = buttonbox.get_children() + # Some buttonboxes does not contain buttons; don't replace for auto mode and mdi + if buttons and Gtk.Buildable.get_name(buttonbox) not in ["hbtb_auto", "hbtb_MDI"]: + buttonbox.remove(buttons[-1]) + saved_button = self.saved_buttons[page_num] + buttonbox.add(saved_button) + saved_button.show() + except: + pass + def on_hal_status_tool_in_spindle_changed(self, object, new_tool_no): LOG.debug("hal signal tool changed") # need to save the tool in spindle as preference, to be able to reload it on startup @@ -2797,6 +2839,13 @@ def on_hal_status_mode_manual(self, widget): self.last_key_event = None, 0 def on_hal_status_mode_mdi(self, widget): + try: + if hal.get_value("halui.halui-mdi-is-running"): + LOG.debug("switch to MDI page is ignored, because halui MDI-command is running") + return + except: + pass + LOG.debug("MDI Mode, tool_change = {0}".format(self.tool_change)) # if the edit offsets button is active, we do not want to change