how to make GladeVCP button execute ordered lines of code?

More
4 years 8 months ago #235089 by dbotos
I currently have a GladeVCP button that is netted to two halui pins, so that when the button is pressed, those pins are changed to a value of 1.

But what if I want to change the value of certain pins in a certain order?  Does that require making the button execute a separate script?  I'd like to use the hal.set_p function to change the values of the following halui pins in the following order:

1) set halui.mode.joint to 1 to put LinuxCNC in joint mode
2) simultaneously set halui.joint.1.home and halui.joint.3.home to 1 to home my Y1 and Y2 joints
3) set halui.mode.teleop to 1 to put LinuxCNC in world mode

Thanks,
David

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

More
4 years 8 months ago #235094 by cmorley
When trying to do complicated sequenced processes, I would recommend using gladevcp's python script extensions - (usually referenced as python handler files).

I'm sure you could actually do this with HAL code but I think it would be painful.

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

More
4 years 8 months ago #235194 by dbotos
Chris - thanks.

I'm trying to figure out how everything should be linked together.  I get how LinuxCNC loads the custom panel -  I currently have the following line in my INI file to do that:
Code:
GLADEVCP = -u ./hitcounter.py ./dbotos_laser_2_8_vcp.ui

Also, the INI currently calls a HAL file for the panel with this line:
Code:
POSTGUI_HALFILE = ./dbotos_laser_2_8_vcp.hal

How do I go about replacing what's in the panel HAL file with the ordered sequence of HAL commands that I want to run when the button is pressed?  I see that the hitcounter.py script has a function called on_button_press.  I'm assuming I need to use that function somehow to say: when the home_y_button (defined in the UI file) is pressed, run some snippet of code or some separate script file.

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

More
4 years 8 months ago - 4 years 8 months ago #235256 by dbotos
It looks like that on_button_press function in hitcounter.py is currently set up to increment a variable (nhits) by one each time you press a button that has its "pressed" signal associated with that function.  And then it updates the "hits" label to display the value of that variable.

Can I replace the three action lines of the on_button_press function with hal.set_p function calls?  I'm assuming I need to comment out the line in my INI file starting with POSTGUI_HALFILE (so it doesn't try to do the netting that's called out in there) and also associate the "pressed" signal of my home_y_button in my UI with the on_button_press function.
Last edit: 4 years 8 months ago by dbotos.

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

More
4 years 8 months ago #235293 by dbotos
I did some reading up on Python today and I think I had this almost figured out (short of figuring out how to change the halui.joint.1.home and halui.joint.3.home pin values simultaneously) when I discovered a much easier was to accomplish what I was trying to:

forum.linuxcnc.org/49-basic-configuratio...tors?start=20#235291

I still might mess around and try to get that laser power meter working.

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

More
4 years 8 months ago #235312 by cmorley
Ya I suggest explaining what you want to accomplish rather then how to do something a specific way. You can get widely different answers :)

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

Moderators: HansU
Time to create page: 0.063 seconds
Powered by Kunena Forum