Various questions about GladeVCP

More
20 Apr 2012 12:34 - 20 Apr 2012 12:36 #19397 by labmaster
I'm in the middle of the learning curve for GladeVCP and need some help in various issues.

I manage to get my UI up and running and even bind some HAL pins to LEDs and other object in .hal scrip. I also manage to find a workaround for setting default values to hal_spinbuttons (8.6 FAQ in the GladeVCP manual).

As I mentioned, I need help with a few different things but let me start with some of them.

I am running my UI by using the commad "linuxcnc myui.ini"

Where will the result be displayed when I using print in Python?
def on_button_press(gtkobj,data=None):
    print "Button pressed"

How can I access HAL pins found using "Hal Meter" from Python. For instance halui.axis.2.pos-relative?

I have manage to figure out how to access pins in the UI like this:
def on_setToolChangePosition_pressed(self,widget,data=none):
       self.builder.get_object('toolChangePositionValues').hal_pin.set(1);

Where can I find documentation for different functions like "self.builder.get_object().hal_pin.set()" and other functions used in Python for GladeVCP?

By the way, my experience from Python and Gtk is rather pore but I have lots of programming knowledge and is very familiar using different kind of documentation. Don't hesitate pointing me out where and what I should read to get information so that I can manage to succeed with my UI-project.

I also let you know that I have downloaded the configs/gladevcp

I hope there is someone out there who can help me sort things out when I have problems along my learning curve.
Last edit: 20 Apr 2012 12:36 by labmaster.

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

More
20 Apr 2012 12:57 #19398 by mhaberler
labmaster wrote:

I'm in the middle of the learning curve for GladeVCP and need some help in various issues.

I manage to get my UI up and running and even bind some HAL pins to LEDs and other object in .hal scrip. I also manage to find a workaround for setting default values to hal_spinbuttons (8.6 FAQ in the GladeVCP manual).

As I mentioned, I need help with a few different things but let me start with some of them.

I am running my UI by using the commad "linuxcnc myui.ini"

Where will the result be displayed when I using print in Python?

def on_button_press(gtkobj,data=None):
    print "Button pressed"

This goes to stdout if not redirected. To see those print statements, start a terminal session and run 'linuxcnc myconfig.ini' . They should appear in the terminal window.

You can redirect a python file descriptor to a log window in gladevcp, eg in a tab, using a ScrolledText widget, and redirecting it like here: git.mah.priv.at/gitweb/emc-mill.git/blob...M19:/python/panel.py (see the LogText class and use).

How can I access HAL pins found using "Hal Meter" from Python. For instance halui.axis.2.pos-relative?

I'm unsure what you mean by that. I assume you want to link halui.axis.2.pos-relative to a HAL Meter widget. To do so, just net those pins in the gladevcp HAL file (usually the one given with POSTGUI_HALFILE):

net pos-rel halui.axis.2.pos-relative gladevcp.hal-meter-pin

You can programmatically access HAL pins like below, but you dont need to do this for the simple case of just displaying some HAL pin with a widget. Just link them as above.

I have manage to figure out how to access pins in the UI like this:
def on_setToolChangePosition_pressed(self,widget,data=none):
       self.builder.get_object('toolChangePositionValues').hal_pin.set(1);

This I dont get. Why dont you use a HAL_Button for setToolChangePosition and link its hal pin?


Where can I find documentation for different functions like "self.builder.get_object().hal_pin.set()" and other functions used in Python for GladeVCP?

Really only by reading the code in lib/python/gladevcp. I'd say the set(), get(), and occasionally the update() method are the only ones I see use for.

- Michael

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

More
20 Apr 2012 14:50 #19399 by labmaster
Hi Michael, thanks for your quick reply.

"This goes to stdout if not redirected. To see those print statements, start a terminal session and run 'linuxcnc myconfig.ini' . They should appear in the terminal window."

That is what I though also but it did not happens for some reason and I could not figure out why.

It would be nice to know how to fix this problem but I will also take a look at your link how to use a ScrolledText widget.

"I'm unsure what you mean by that. I assume you want to link halui.axis.2.pos-relative to a HAL Meter widget. To do so, just net those pins in the gladevcp HAL file (usually the one given with POSTGUI_HALFILE):

net pos-rel halui.axis.2.pos-relative gladevcp.hal-meter-pin"


No I already know how to do this. I want to learn how to read/write (get/set), at least read, a value from HAL pins using Python like any of them displayed with "Hal Meter". halui.axis.2.pos-relative was just an example.

"This I dont get. Why dont you use a HAL_Button for setToolChangePosition and link its hal pin?"

I can understand why you asking this question but I mite do stupid things due to my short experience of GladeVCP (I only been there for 8 hours) :).

"Really only by reading the code in lib/python/gladevcp. I'd say the set(), get(), and occasionally the update() method are the only ones I see use for."

Oh, thanks. Then it will be easy. Can you give me the full path to lib/python/gladevcp because I have tried to find it but did not succeed using the command "find" in my filesystem.

By the way, can you give me a peas of Python code that access HAL pins using get(), ie halui.axis.2.pos-relative?

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

More
20 Apr 2012 15:18 #19401 by mhaberler

Oh, thanks. Then it will be easy. Can you give me the full path to lib/python/gladevcp because I have tried to find it but did not succeed using the command "find" in my filesystem.


Since I do not know what you have installed - some package, or from source, I cannot just guess it. The relevant files are online in
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...863a2d7df923766651eb

'sudo updatedb' and 'locate hal_widgets.py' might give you a hint where they are on your system.

By the way, can you give me a peas of Python code that access HAL pins using get(), ie halui.axis.2.pos-relative?



You do not 'access' a foreign HAL pin - you define your own HAL pin, and link it to that foreign HAL pin in the POSTGUI_HALFILE, then access your own HAL pin.

See the examples in the manual, which is always an excellent and rich source of information B)

www.linuxcnc.org/docs/devel/html/gui/gla...evcp:Adding_HAL_pins
www.linuxcnc.org/docs/devel/html/gui/gla...ies_programmatically
www.linuxcnc.org/docs/devel/html/gui/gla...l-pin-changed_signal

Generally I'd advise a event-driven programming style - use events like value-changed or hal-pin-changed and do stuff in the event handler.

- Michael

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

More
20 Apr 2012 15:44 #19402 by labmaster
Thanks again Michael, you have sorted out my questions except that I have no solution for print to stdout on the terminal window.

I know for sure that the manual is a very good start and I have read them a lot the last few hours. But I did not understand that I need to define my own HAL pin and link them to the foreign HAL pins in the POSTGUI_HALFILE. But now it's clear thanks to your good advice.

By the way, I have another issue that mite be resolvable with your help. When I do linuxcnc myui.ini I get this:

(gladevcp: 14983): libglade-WARNING **: Expected <glade-interface>. Got <interface>.
(gladevcp: 14983): libglade-WARNING **: did not finfsh in PARSER_FINISH state
**** GLADE VCP INFO: Not a libglade project, trying to load as GTK builder project
/usr/bin/gladevcp:191: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is depricated
builder.add_from_file(xmlname)
Xlib.protocol.request.QueryExtension
Xlib.protocol.request.QueryExtension
Emit interp-run
Emit interp-run
Emit interp-run

Any advice?

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

More
20 Apr 2012 18:03 #19407 by mhaberler
labmaster wrote:

...
By the way, I have another issue that mite be resolvable with your help. When I do linuxcnc myui.ini I get this:

(gladevcp: 14983): libglade-WARNING **: Expected <glade-interface>. Got <interface>.
(gladevcp: 14983): libglade-WARNING **: did not finfsh in PARSER_FINISH state
**** GLADE VCP INFO: Not a libglade project, trying to load as GTK builder project
/usr/bin/gladevcp:191: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is depricated
builder.add_from_file(xmlname)
Xlib.protocol.request.QueryExtension
Xlib.protocol.request.QueryExtension
Emit interp-run
Emit interp-run
Emit interp-run

Any advice?


This is not an issue but just superfluous log messages.

Re your print output problem: post the python handler file so we can see whats in out, the crystal ball is dark over the weekend B)

- Michael

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

More
20 Apr 2012 19:06 #19409 by labmaster
How stupid, now it's working. I was pretty sure that I did not get anything on the terminal on print but I'm the lucky guy now. I have even found hal_widgets.py and also made progress with the foreign HAL pin.

Thanks a lot for your help Michael. I am sure there will be more questions to sort out later. I will now start with the probing functionality and after that I will get into the tool changing process and take a deep look into the Extending EMC documentation.

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

More
23 Apr 2012 12:01 - 23 Apr 2012 12:05 #19457 by labmaster
I have now finished the first part of my tool panel and my probing tools is up and running. Next part is tool changing and I have read the Extending EMC document as the first step.

In the second step I will try to use the feature 4.6. Making minimal changes to the builtin codes .

This is my setup in the myui.ini:

[RS274NGC]
REMAP=M6 modalgroup=6 ngc=toolchange.ngc

This is my toolchange.ngc:

O<toolchange> sub
M6
(MSG, move to probe position)
(print, move to probe position)
O<toolchange> endsub

It seams that toolchange.ngc are not executed because I did not get any massage in the terminal window or a message inside the linuxcnc window. Any suggestion what mite be missing?

Do I need to remove HALFILE=axis_manualtoolchange.hal that comes from the GladeVCP demo gladevcp_panel.ini?

By the way, I have also tried REMAP=M6 modalgroup=6 ngc=toolchange
Last edit: 23 Apr 2012 12:05 by labmaster.

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

More
23 Apr 2012 12:38 #19459 by mhaberler
Which version of linuxcnc are you running?

Remapping is available only in master.



- Michael

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

More
23 Apr 2012 12:43 - 23 Apr 2012 12:43 #19460 by labmaster
LinuxCNC Version 2.5.0 on Ubuntu 10.04. What do you mean by "master"?
Last edit: 23 Apr 2012 12:43 by labmaster.

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

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