Run GladeVCP from halrun

More
23 Aug 2012 15:48 #23579 by wd5jwy
Replied by wd5jwy on topic Re:Run GladeVCP from halrun
I'm still trying to figure out how to kill the HAL RTOS when closing the Glade panel. I've tried several different ways in the python handler:

def on_vbox1_destroy(self, widget, data=None):
self.halcomp.exit()

def on_unix_signal(self,signum,stack_frame):
print "on_unix_signal(): signal %d received, saving state" % (signum)
gtk.main_quit()
self.halcomp.exit()

def on_window1_destroy(self, widget, data=None):
self.halcomp.exit()
gtk.main_quit()

The call to "self.halcomp.exit()" doesn't seem to do anything. It's still necessary to go to the terminal window and type "exit" or "quit" to kill the RTOS. I've searched all the documentation for some way to do this, but haven't found anything that works.

Is there anyone out there that has found a way to do this?

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

More
23 Aug 2012 15:59 #23580 by BigJohnT
I gave up trying and just went with installing my python and glade file and running from a desktop launcher... seems to be cleaner that way. BTW, I've added some more content to the GUI tutorial that covers this.

John

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

More
23 Aug 2012 16:02 #23581 by mhaberler
I think what we need to do is to document how to create an ini which just starts/stops rtapi/hal and a UI, and doesnt start milltask and other fluff if not told to do so. I think currently you cant avoid starting milltask.

I think we should modifiy the linuxcnc startup script to allow that, it's becoming a common case.

-Michael

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

More
24 Aug 2012 06:07 #23607 by cmorley
Replied by cmorley on topic Re:Run GladeVCP from halrun
try :
raise KeyboardInterupt
or :
raise SystemExit
or simply :
sys.exit(0)

(I haven't tried them ...)

Chris M

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

More
26 Aug 2012 16:17 #23670 by mhaberler
folks looking into running HAL+GladeVCP applications might want to look here for an example:

git.mah.priv.at/gitweb/emc2-dev.git/comm...d8cf6804933b7dfd1f82

- Michael

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

More
27 Aug 2012 12:54 #23680 by BigJohnT
wd5jwy wrote:

I'm still trying to figure out how to kill the HAL RTOS when closing the Glade panel.


YEA! Michael has solved the riddle... check out his example. What is needed is the halrun waitusr name of GUI. In this example I've named it "winder". After the GUI closes the lines after "waitusr winder" are executed.
loadusr -Wn winder gladevcp -c winder -u handler.py wd.glade
...
start

# comment out the following lines while testing and use the interactive
# option halrun -I -f start.hal to be able to show pins etc.

# wait until the gladevcp GUI terminates
waitusr winder

# stop HAL threads
stop

# unload HAL all components before exiting
unloadrt all

John

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

More
28 Aug 2012 00:58 - 28 Aug 2012 01:01 #23699 by wd5jwy
Replied by wd5jwy on topic Re:Run GladeVCP from halrun
John:

This is great if I could just get it to work. I'm a bit confused with the component name both you and Michael (in his example) are using.

The loadusr command wants a component name after the -Wn flag. You are using the component name 'winder' and I'm not sure where that name came from. My gladevcp panel uses an extension of .glade instead of .ui. So, I'm not sure what component name to use after the -Wn flag. Do you just create an empty file with the extension .ui and give it a random name?

Here is the loadusr Halcmd I'm currently using:

#Loads gladevcp then python handler file and then creates glade panel
loadusr -Wn gladevcp gladevcp -c gladevcp -u handler.py wd.glade


I've tried using gladevcp as the name after the waitusr command, but that just locks up the terminal. I've attached my .hal file if that helps.

I actually did try playing with the waitusr command last week, but couldn't understand what name it wants as an argument.

File Attachment:

File Name: start.hal
File Size:2 KB
Attachments:
Last edit: 28 Aug 2012 01:01 by wd5jwy.

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

More
28 Aug 2012 11:38 - 28 Aug 2012 11:40 #23708 by BigJohnT
The name "winder" that I used and "ui" that Michael used are just names. You could call it "gnipsel" if you like. in the following example gladevcp is the program that is called and I've named it wd5jwy, the gui is wd.glade. The name gladevcp might confuse waitusr because it is a running program I don't know...
loadusr -Wn wd5jwy gladevcp -c wd5jwy -u handler.py wd.glade 
...
waitusr wd5jwy 

This could be written on one line or leave the gladevcp.start_button off of the second line.
#Enable both stepgens when start button pressed
net run-stepgen stepgen.0.enable <= gladevcp.start_button
net run-stepgen stepgen.1.enable <= gladevcp.start_button

net run-stepgen stepgen.0.enable stepgen.1.enable <= gladevcp.start_button

John
Last edit: 28 Aug 2012 11:40 by BigJohnT.

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

More
29 Aug 2012 01:23 #23732 by wd5jwy
Replied by wd5jwy on topic Re:Run GladeVCP from halrun
IT WORKS! You guys are geniuses. I was still having problems getting the Hal components to unload after closing the Glade panel. But, I forgot that I was making a call to sys.exit(1) in my python file under on_window1_destroy, so the normal call to gtk.main_quit() was never executing. Apparently the call to sys.exit(1) was never returning. Which means the waitusr Hal command was never seeing the interface fully closing and releasing the Hal components.

Anyway, as soon as I removed the sys.exit(1) call from the python file, everything works as it should.

def on_window1_destroy(self, widget, data=None):
sys.exit(1)
gtk.main_quit()

Thanks for figuring this out. Linuxcnc is really an amazing software tool to play with.

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

More
10 Jan 2013 19:12 - 10 Jan 2013 19:14 #28544 by jpalttala
Replied by jpalttala on topic Run GladeVCP from halrun
Hi guys

I have a minor problem with my stand alone gladevcp based UI


Background:

I have developed touch based UI for LinuxCNC.
I'm using version 2.5.0
I have written handler software with python 2.7 and that works well (-ish)

Anyway, my problem is that my glade UI gets loaded twise (as 2 different windows). 1 window works as it should and other just displays form default initialization data and does not do anything...

How can I prevent from loading this ghost window?

My startup command in HAL - file is following:

loadusr -Wn gladevcp gladevcp -d -u ./data/handler.py -c gladevcp ./data/gladevcp

Thanks in advance

-Jyrki-
Last edit: 10 Jan 2013 19:14 by jpalttala.

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

Moderators: mhaberlerHansU
Time to create page: 0.105 seconds
Powered by Kunena Forum