[QTDragon] blocking in hal_manualtoolchange dialog

More
19 Aug 2024 17:06 #308149 by Aciera
The point is that you cannot inject MDI commands when in auto mode.
My approach would be to use a custom mcode.
Have a look at this
forum.linuxcnc.org/38-general-linuxcnc-q...iable?start=10#57149

It's a bit dated but should still work. You could also use python instead of tcl.

Please Log in or Create an account to join the conversation.

More
19 Aug 2024 19:13 #308157 by Aciera
So here is an example using a python remap.

To setup python remap in your config you will need to:
1. In your config folder create a folder named 'python'
2. save this to the 'python' folder as 'toplevel.py':
import remap
3. save this to the 'python' folder as 'remap.py'
import sys
import traceback
from interpreter import *
import emccanon
from util import lineno, call_pydevd
import hal
from tkinter import *
from tkinter import messagebox

    
def g69_core(self):
    global coordinates
    if self.task == 1:
        try:
            def button_pressed(value):
                global coordinates
                coordinates = value
                ws.destroy()
                
            ws = Tk()
            # Tkinter way to find the screen resolution
            screen_width = ws.winfo_screenwidth()
            screen_height = ws.winfo_screenheight()
            size = tuple(int(_) for _ in ws.geometry().split('+')[0].split('x'))
            x = screen_width/2 - size[0]/2
            y = screen_height/2 - size[1]/2
            ws.geometry("400x120+%d+%d" % (x, y))
            ws.title('LinuxCNC')
            #ws.geometry('200x110')
            Label(ws, text=("Some text here\n")).pack()
            b1 = Button(ws, text=('Move to X1'), padx=10, pady=5, command=lambda: button_pressed('X1'))
            b1.pack(pady=5)
            b2 = Button(ws, text=('Move to X-2'), padx=10, pady=5, command=lambda: button_pressed('X-2'))
            b2.pack(padx=5)
            ws.mainloop()
        except Exception as e:
            print('ERROR: show_operator_message: ', e)

        self.execute('G0' + coordinates, lineno())

    yield INTERP_EXECUTE_FINISH
    return INTERP_OK

4. save this as 'g69remap.ngc' to a folder listed in your ini file under [RS274NGC] SUBROUTINE_PATH
; this is the wrapper remap for G69
o<g69remap>sub
M66 L0 E0       ; force sync, stop read ahead
M469            ; call the python G69_core code     
M66 L0 E0       ; force sync, stop read ahead
o<g69remap>endsub
m2

5. Add this to your ini file (if not already included)
[PYTHON]
# where to find the Python code:
# code specific for this configuration
PATH_APPEND = ./python
# import the following Python module
TOPLEVEL = ./python/toplevel.py
# the higher the more verbose tracing of the Python plugin
LOG_LEVEL = 3

6. Add this to the [RS274NGC] section of your ini file
          REMAP = G69   modalgroup=1   ngc=g69remap
          REMAP = M469  modalgroup=10  python3=g69_core

This should give you a new GCode 'G69' which should then open a popup window and give you two options to move:
 

Upon pressing a button the machine will move to the selected position and the program will continue.
 
Attachments:

Please Log in or Create an account to join the conversation.

More
19 Aug 2024 21:25 #308168 by chernogorsky
Thank you
Have done initial  setup with Qt (still need more work on bells and whistels)
and it looks like working

File attached +
one change in qt_auto_probe_tool.ngc (right before M6)

M66 E0 L0
o250 do
    M101 P#<tool>
    M66 E0 L0
    
    ; cancel pressed
    o260 if [#5399 EQ 2]
        (MSG, Cancel has been pressed )
        G43 ;turn back on tool offset mode before returning
    o260 return [3] ; indicate no tool measurement 
    o260 endif

    o270 if [#5399 EQ 10]
    ;(MSG, ToolChange has been pressed )
    o<pnc_tc_manual> call
    O270 endif

; anything other than OK button
o250 while [#5399 NE 1] 

M6


And it works close to how I want it for now

Current TODO - check if I can do the window it modal and top of all for all the time, but its minor
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.171 seconds
Powered by Kunena Forum