how to make GladeVCP button execute ordered lines of code?

More
17 Feb 2022 03:09 #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
17 Feb 2022 04:48 #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
17 Feb 2022 23:17 #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:
GLADEVCP = -u ./hitcounter.py ./dbotos_laser_2_8_vcp.ui

Also, the INI currently calls a HAL file for the panel with this line:
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.
Attachments:

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

More
18 Feb 2022 18:08 - 18 Feb 2022 18:08 #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: 18 Feb 2022 18:08 by dbotos.

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

More
18 Feb 2022 22:24 #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
19 Feb 2022 07:10 #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.

More
20 Feb 2022 14:14 #235385 by dbotos
Now I'm curious what the Machine --> Homing --> Home Joint 1 (or Home Joint 3) items do command-wise when clicked.  It seems like they would have to go into joint mode first and then back into world mode as the last thing they do.  But what about in between?  If you have joints with a linked home sequence, can you just call homing for one of them and it will automatically do both?

 
Attachments:

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

More
20 Feb 2022 16:18 #235393 by tommylight

If you have joints with a linked home sequence, can you just call homing for one of them and it will automatically do both?

Yes, if set correctly.

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

More
22 Feb 2022 17:08 #235542 by dbotos
Maybe I'll mess around with it in a sim config at some point and see if I can get it to work as an exercise in curiosity.

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

Moderators: mhaberler
Time to create page: 0.155 seconds
Powered by Kunena Forum