How to load and run program in QtPyVCP

More
22 May 2021 10:33 #209828 by aleksamc
I created some visual screen in QtPyVCP for standart machine that will do 1 operation with different parameters.
Now I need to do 2-d operation. I can build new program in my old (1-st operation) but there is so many o-words and o-calls.

I think it's better to make some new button to load another g-code and to run it, after finishing program - to load previous or default program.

I tried to use remapped M-code but I see that it's not run, I don't know why, I cloned it from previous program.

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

More
22 May 2021 17:09 #209848 by aleksamc

File Attachment:

File Name: m204.ngc
File Size:3 KB


I've made such program I try to run it from MDIButton as remapped m-code.
But it doesn't run or run partly.

If I open this file as default g-code program, It works fine.
Attachments:

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

More
22 May 2021 22:17 #209860 by chris@cnc
I'm stuck in similar problem. I wrote one M code to go my a axis home after turning mode. In MDI doesn't start axis moving. But if i command all lines one by one in terminal works fine.
So i guess there is something different in MDI, auto or jog mode.
Usually i start now to trigger missing signal but i have no idea what i'm looking for. And after 20min reading of motion.c and homing.c i got big headache. So my road ends.
But i'am pretty sure we have to set one signal to simulate automode or somthing like that.

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

More
22 May 2021 22:30 #209863 by Joco
So are you essentially trying to have a button that loads then runs a ngc prog? Treating that prog from the user’s point of view as a canned cycle. Ie. “ push button X and machine will do the Y series of operations”?

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

More
23 May 2021 13:02 - 23 May 2021 13:03 #209902 by aleksamc

So are you essentially trying to have a button that loads then runs a ngc prog? Treating that prog from the user’s point of view as a canned cycle. Ie. “ push button X and machine will do the Y series of operations”?


Yes, you are right about that.

Button that makes such macros:
1) loaf g-code program (.ngc)
2) run loaded g-code program (.ngc)

But i'am pretty sure we have to set one signal to simulate automode or somthing like that.

Currently in QtPyVCP is very easy to change working modes:
- actionButton with sets: machine.mode.manual (auto, mdi), so on.
It's not working.
Other remaped M-codes are work fine.
I suspect that problem could be in setting "modalgroup=10" in .ini file when I remap m-code or some G-codes can't run in M-codes.
I think I have few methods to solve this problem but to make special button would be more beautiful.
Last edit: 23 May 2021 13:03 by aleksamc.

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

More
24 May 2021 05:30 - 24 May 2021 05:30 #210019 by Joco
if you are a little comfortable with python it would actually be quite easy to do all this with the existing framework. But you will need a python method with a @Slot annotation on it to allow the signal linking in QTDesigner, do the file load, set the machine mode and, if desired, run the loaded prog.

there is the subcall button type that may be of use. But if the operation you want is material and you want to see it all happening in the plot like a proper loaded prog then automaitng load/mode/run will be likely be cleaner.

J.
Last edit: 24 May 2021 05:30 by Joco.

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

More
24 May 2021 22:25 #210123 by andypugh
If you are using MDI_COMMAND then, yes, it only really works when MDI is valid. ie never in "Auto" mode (ie when G-code is running) And not always in "Manual" mode. I have a suspicion that this is annoyingly UI dependent.

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

More
27 May 2021 21:11 #210465 by aleksamc

andypugh wrote: If you are using MDI_COMMAND then, yes, it only really works when MDI is valid. ie never in "Auto" mode (ie when G-code is running) And not always in "Manual" mode. I have a suspicion that this is annoyingly UI dependent.

I have a lot of buttons that use remapped M-codes, they are work fine in default mode (I don't know if it MDI mode, but auto mode is for sure).

... But if the operation you want is material and you want to see it all happening in the plot like a proper loaded prog then automating load/mode/run will be likely be cleaner.


Unfortunately I'm not good in python, but I hope that I have chance to solve this probrlem))
I need to study Python Interface to anderstand this.
But I didn't anderstand 2 things:
- how to use @Slot, can you show some example of using it?
- how to connect my "program" to the main program? It's enaugh using "import"?

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

More
28 May 2021 00:08 #210481 by Joco
aleksamc - a quick clarification:
your "program" is just an ngc file - yes?


If so I will see if I can find some time over the next couple of days to make a very quick example that you can look at. It should be super simple but these things are always easier to understand when looking at a simple working example than snippets posted without context.

Cheers - J.

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

More
02 Jun 2021 01:21 - 02 Jun 2021 02:21 #210930 by Joco
aleksamc - simple example attached. It's not necessarily elegant but hopefully it should make sense.


The axis.ngc file in the archive needs to be in your: linuxcnc/nc_files directory.

Look at the mainwindow.py file.

The line:
self.btn_loadrun.clicked.connect(self.load_then_run)

is what makes he signal connection between the actionbutton named "btn_loadrun" and the method in this code file called "load_then_run".
import os

from qtpyvcp.widgets.form_widgets.main_window import VCPMainWindow

# Load in the methods needed to load and run a ngc prog
from qtpyvcp.actions.program_actions import load, run
from qtpyvcp.utilities.info import Info


# Setup logging
from qtpyvcp.utilities import logger
LOG = logger.getLogger('qtpyvcp.' + __name__)

class MyMainWindow(VCPMainWindow):
    """Main window class for the VCP."""
    def __init__(self, *args, **kwargs):
        super(MyMainWindow, self).__init__(*args, **kwargs)

	# add custom signal connections here
	self.btn_loadrun.clicked.connect(self.load_then_run)

    # add any custom methods here
    def load_then_run(self):
        # now we load the prog
        print "btn run and load clicked"
        info = Info()
        nc_files_dir = info.getProgramPrefix()
        path = os.path.expanduser(nc_files_dir)
        load(path + "/axis.ngc")
        run()
Attachments:
Last edit: 02 Jun 2021 02:21 by Joco.
The following user(s) said Thank You: aleksamc

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

Moderators: KCJLcvette
Time to create page: 0.151 seconds
Powered by Kunena Forum