Trigger custom command with GladeVCP from python instruction and axis command

More
17 Jul 2017 01:46 #95867 by Nico2017
Nico2017 created the topic: Trigger custom command with GladeVCP from python instruction and axis command
Hi,
I am trying to add a standalone panel interface to the usual Axis GUI one in order to trigger some commands from another window which is remotely displayed on a different monitor. I managed to create a small gladeVCP.ui interface with one button based on the tutorial and was able to trigger some python instructions from the related .py file. I even managed to use a VCP action feature to toogle for exemple an Estop.

I would like to know if it is possible to define a button which triggers a specific action defined in /usr/bin/axis such as the task_run_line which makes linuxcnc runs a Gcode from the current underlined line.

In my python file linked to my gladeVCP I used:
import linuxcnc
s = linuxcnc.stat()
c = linuxcnc.command()

So I can for example do
c.auto(linuxcnc.AUTO_RUN, 10) to make linuxcnc starting the Gcodes file instruction at line 10. This works fine, however I would like to trigger a specific task defined in /usr/bin/axis such as task_run_line. I tried in my python file many instruction such as:
linuxcnc.command.task_run_line
linuxcnc.commands.task_run_line
linuxcnc.command.task_run_line()

The task_run_line definition is in the TclCommands class.

To make any progress on this, I was also wondering if there was an exhaustive list of command that can be send to linuxcnc with python script. I have been looking at linuxcnc.org/docs/devel/html/config/python-interface.html without finding what could be used in my case Another method would be to find out in which file the linuxcnc command are defined to maybe define my own one. So far none of my attempt have worked.

Thank you for your help.

Nicolas
More
17 Jul 2017 12:35 #95887 by cmorley
cmorley replied the topic: Trigger custom command with GladeVCP from python instruction and axis command
As you have discovered the tricky part is getting info from AXIS.
Your gladeVCP python code has no way to directly interact with AXIS.

Aside from modifying AXIS I don't think there is a way to get the current highlighted line.

Gmoccapy and Gscreen are much easier to modify in this way.

Chris M
More
19 Jul 2017 23:16 #96111 by Nico2017
Nico2017 replied the topic: Trigger custom command with GladeVCP from python instruction and axis command
Hi,

thank you for your reply. I was actually able to interact using a little hack without a direct interaction with Axis. I used a gladeVCP interface which triggers a keystroke send with a xdotool shell. The keystroke is directed to the Axis window where I associated the keystroke shortcut to the action I want to be executed.

That is unfortunate that the c = linuxcnc.command() capability cannot be associated to any action in the /user/bin/axis file.

Nicolas
More
25 Jul 2017 20:20 #96419 by Nico2017
Nico2017 replied the topic: Trigger custom command with GladeVCP from python instruction and axis command
Hi,

seems I found something more handy than the one I suggested. I used a USER_COMMAND_FILE = File.py in the [DISPLAY] section of the ini file. The python file is attached as text file. It generates an additional panel "Custom panel" with one or different buttons that can trigger direct actions in linuxcnc. In fact it can call any action of the file \usr\bin\axis. The file attached here for example print Overriding Limits in the terminal, clear off all notifications and error message and toggle the override limits.

I think this method is equivalent to modify or add commands directly to AXIS, in the \usr\bin\axis but seems a bit safer as it does not write directly into it and can be fastly removed commenting the USER_COMMAND_FILE in the ini file if you want to remove it. Moreover this Custom Panel is added to any other one generated so I actually have on my configuration two stand alone panels: one pyvcp and one to trigger directly action which cannot be triggered with the pyvcp or a gladevcp panel method.

Axis takes a bit longer to load and it might not be the initial use of the USER_COMMAND_FILE but it seems to work fine for me.

Nicolas
Attachments:
Moderators: mhaberler
Time to create page: 0.087 seconds
Powered by Kunena Forum