objects not loaded or recognized

More
31 Aug 2014 03:00 #50536 by mariusl
Norbert
I am using the exact same sim example that you posted. In my case the var file is written and the value is read from the file on loading of Gmoccapy. I print the value from the python script and it is correct but it does not pass through to the hal.

I will post some screen shots next

Regards
Marius


www.bluearccnc.com

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

More
31 Aug 2014 03:11 #50538 by mariusl
Some screen shots and code

This has me really screwed up. I have been fighting for the whole day now to get this to work. Make me feel really stupid. :angry:



The terminal output
adding import dir .
module 'gearselect' imported OK
module 'gearselect' : 'get_handlers' function found
Hal pin stored value was 4
Hal pin has been set to 4
Registering handlers in module gearselect object <gearselect.GearSelect instance at 0x8fbe04c>
Register callback 'on_frame_main_destroy' in <gearselect.GearSelect instance at 0x8fbe04c>
WARNING:Config:Can't load Default loading default layout instead

the var file contents
# generated by gladevcp.persistence.create_default_ini() on Fri Aug 29 19:32:42 2014
[ini]
	version = 1
	signature = 61ca954c8852767aef44ef8e126e0926ba477a3b
[vars]
	SelectedGear = 4
# last update  by gladevcp.persistence.save_state() on Sat Aug 30 22:06:45 2014

Your python code with print extra
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
"""
    This file will control some options of the custom panel
    and should be something like a skeleton to begin with
    Please include a smal description of the file, so it is much
    easier for other developers to follow yozr style. there ar many 
    lasy people out there, not taking care of that, please do not become 
    one of them!

    Copyright 2013 Norbert Schechner
    nieson@web.de

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

"""

# Please read also the above text! And if you begin to code some new stuff
# please include comments, so others can follow you!

# Name varialbles so others do now there meaning, see the following example:
# v=f-s+(w.get_value)
# value = first_value - second_value + (widget.get_value)
# it cost no performanca, but is much easier to read!
# for coding style I recfommend to follow PEP8
# see : http://legacy.python.org/dev/peps/pep-0008/


####################################################################
# Watch the terminal output, as the error reports will apear there #
####################################################################

# We will need to import some basic stuff
import hal           # needed to make our own hal pins
import hal_glib      # needed to make our own hal pins and react with handlers

from gladevcp.persistence import IniFile


class GearSelect:

    # __init__ will set the defaults and get all relevant information, before showing the panel
    def __init__(self, halcomp, builder, useropts):
        self.builder = builder
        self.halcomp = halcomp

        self.defaults = { IniFile.vars : { "SelectedGear"       : 0 ,
                                         },
                        }

        self.ini_filename = __name__ + ".var"
        self.ini = IniFile(self.ini_filename, self.defaults, self.builder)
        self.ini.restore_state(self)

        self.halcomp.newpin("selected-gear", hal.HAL_S32, hal.HAL_OUT)
        self.halcomp["selected-gear"] = self.SelectedGear

        print("Hal pin stored value was %s" % self.SelectedGear)
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

        self.btn_1 = self.builder.get_object("btn-1")
        self.btn_1.connect("clicked", self._btn_1_clicked)

        self.btn_2 = self.builder.get_object("btn-2")
        self.btn_2.connect("clicked", self._btn_2_clicked)

        self.btn_3 = self.builder.get_object("btn-3")
        self.btn_3.connect("clicked", self._btn_3_clicked)

        self.btn_4 = self.builder.get_object("btn-4")
        self.btn_4.connect("clicked", self._btn_4_clicked)

        self.btn_5 = self.builder.get_object("btn-5")
        self.btn_5.connect("clicked", self._btn_5_clicked)

        self.btn_6 = self.builder.get_object("btn-6")
        self.btn_6.connect("clicked", self._btn_6_clicked)

        self.frame = self.builder.get_object("frame_main")
        self.frame.connect("destroy", self.on_frame_main_destroy)

    def _btn_1_clicked(self, Widget):
        print("Button %s has been clicked" % Widget.get_label())
        self.halcomp["selected-gear"] = 1
        self.SelectedGear = 1
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

    def _btn_2_clicked(self, Widget):
        print("Button %s has been clicked" % Widget.get_label())
        self.halcomp["selected-gear"] = 2
        self.SelectedGear = 2
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

    def _btn_3_clicked(self, Widget):
        print("Button %s has been clicked" % Widget.get_label())
        self.halcomp["selected-gear"] = 3
        self.SelectedGear = 3
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

    def _btn_4_clicked(self, Widget):
        print("Button %s has been clicked" % Widget.get_label())
        self.halcomp["selected-gear"] = 4
        self.SelectedGear = 4
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

    def _btn_5_clicked(self, Widget):
        print("Button %s has been clicked" % Widget.get_label())
        self.halcomp["selected-gear"] = 5
        self.SelectedGear = 5
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

    def _btn_6_clicked(self, Widget):
        print("Button %s has been clicked" % Widget.get_label())
        self.halcomp["selected-gear"] = 6
        self.SelectedGear = 6
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])

    def on_frame_main_destroy(self, Widget, data = None):
        self.ini.save_state(self)
        print("Done")

# This is the main procedure in this case, please take care that the name within the return value
# is exactly the same as the Class Name, (case senstitive)
def get_handlers(halcomp, builder, useropts):
    return[GearSelect(halcomp, builder, useropts)]

Halshow after restart


Regards
Marius


www.bluearccnc.com

Attachments:

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

More
31 Aug 2014 17:23 #50548 by newbynobi

WARNING:Config:Can't load Default loading default layout instead


As default value is "0", it will load that value.

This message is normal if the file gearselect.var is not in the correct place or does not exist. Taht only happen on the first run. If you close the GUI the file should be written.

Delete the geraselect.var file,
start gmoccapy_marius
push button 1300
close gmoccapy

Take a look in gearselect.var, it should now have SelectedGear = 5

If you now restart gmoccapy_marius, the hal pin should have value 5

Check for the rights in the directory, may be the file is owned by "norbert"?

Please report, as you challenge me ;-)

Norbert

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

More
31 Aug 2014 23:49 - 31 Aug 2014 23:53 #50552 by mariusl
Hi Norbert

All that you ask is working. The file is changed and saved and then read again all with correct values. The problem is that although I write the hal pin with self.halcomp[pin] it does not appear in the hal layer outside of the python script at loading time. Once you have pushed a button the handler procedure will write the halpin correctly

So it would seem that the variables are all handled correctly in the python script but the hal connection is just not there for the gearselected hal pin at startup.

It does this with your example and with my code.

Regards
Marius


www.bluearccnc.com

Last edit: 31 Aug 2014 23:53 by mariusl.

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

More
01 Sep 2014 01:46 #50555 by newbynobi
I watched the values with halshow and in there the values are correct, so I can not see, where the problem is, could a be a comp matter of your comp ?

Norbert

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

More
01 Sep 2014 01:59 #50556 by mariusl
When I look at the pin with halshow directly after startup it is 0 instead of the reported value. This is what I am crying about. My comp is not even connected at this time. I am just using halshow. If you look at my picture in previous post you will see the halshow showing 0 when the python script reports the pin to be some other number.

This is just for directly after startup. The value is not passed to the pin. After any handler is called to change the pin, it actually does change. The problem is at startup only.
The file is correct but the pin is not set when the constructor was called and then assigned a value.

Regards
Marius


www.bluearccnc.com

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

More
01 Sep 2014 18:49 #50565 by mariusl
Now matter how I tried, I could not get the pin to be initiated at startrup so I did a work around.

I made another hal pin that is connected to the machine on signal. So now when the machine is switched the handler will be called and effect the pin.
sg = hal_glib.GPin(self.halcomp.newpin("selected-gear",hal.HAL_S32, hal.HAL_IO))
        self.halcomp["selected-gear"] = self.SelectedGear
        print("Hal pin stored value was %s" % self.SelectedGear)
        print("Hal pin has been set to %s" % self.halcomp["selected-gear"])
        

        kickstart = hal_glib.GPin(self.halcomp.newpin("kick-start", hal.HAL_BIT, hal.HAL_IN))
        kickstart.connect("value_changed", self._do_kickstart)

def _do_kickstart(self, kickstart):    
        self.halcomp["selected-gear"] = self.SelectedGear
        print("Set from kickstart - Hal pin stored value was %s" % self.SelectedGear)
        print("Set from kickstart - Hal pin has been set to %s" % self.halcomp["selected-gear"])


connected like this
net motion.machine-is-on  gear_select.kick-start

Regards
Marius


www.bluearccnc.com

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

More
02 Sep 2014 00:28 - 02 Sep 2014 00:56 #50592 by newbynobi
Hallo Marius,

I do not have that behavior.

Check this Video please and look at your computer.

Norbert
Last edit: 02 Sep 2014 00:56 by newbynobi.

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

More
02 Sep 2014 02:32 #50598 by mariusl
Hi Norbert
Thanks for your effort on this problem. I have all of that the same as in your video except that my halpin does not load at startup. It remains at 0.

The fix that I posted above work well so I am not wasting more time on trying to get this sorted out. I dont know why it works for you but not on my computer. It is the same code.

I am busy finishing the new component and then I will test live on the machine tomorrow. Once it works we can put it on the wiki for lathes with belts. This is important for using CSS on the lathe.

Regards
Marius


www.bluearccnc.com

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

More
06 Sep 2014 15:33 #50838 by mariusl
Hi Norbert

I moved my lathe config to 2.6 and now it does not effect the screen widgets again at startup. Not even with my kick start trick. Please have alook at some of the strange errors that I get when I run linuxcnc.
Things like connection error???
LINUXCNC - 2.6.2
Machine configuration directory is '/home/shop/linuxcnc/configs/lathe'
Machine configuration file is 'lathe.ini'
Starting LinuxCNC...
Connection error: Connection refused
/usr/bin/gmoccapy:147: GtkWarning: gtk_widget_grab_default: assertion `gtk_widget_get_can_default (widget)' failed
  self.builder.add_from_file(XMLNAME)
**** GMOCCAPY GETINIINFO **** 
 Preference file path: /home/shop/linuxcnc/configs/lathe/lathe.pref
/usr/bin/gmoccapy:220: GtkWarning: Invalid icon size 48

  self.widgets.window1.show()
**** GMOCCAPY INFO ****
**** gmoccapy screen 2 found ****
toolfile: /home/shop/linuxcnc/configs/lathe/tool.tbl
**** GMOCCAPY INFO ****
**** audio available! ****
Waiting for component 'gladevcp' to become ready......WARNING:Config:Can't load Default loading default layout instead
........adding import dir .
......module 'gearselect' imported OK
module 'gearselect' : 'get_handlers' function found
Hal pin stored value was 3
Hal pin has been set to 3
Registering handlers in module gearselect object <gearselect.GearSelect instance at 0xa73c1ac>
Register callback 'on_frame_main_destroy' in <gearselect.GearSelect instance at 0xa73c1ac>
.....Xlib.protocol.request.QueryExtension
.Xlib.protocol.request.QueryExtension
../usr/bin/gladevcp:185: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
  builder.add_from_file(xmlname)
./usr/bin/gladevcp:185: GtkWarning: gtk_radio_button_set_group: assertion `!g_slist_find (group, radio_button)' failed
  builder.add_from_file(xmlname)
pyngcgui:INTFC:linuxcnc running=1
pyngcgui:INTFC:ini_file=</home/shop/linuxcnc/configs/lathe/lathe.ini>
..Xlib.protocol.request.QueryExtension
.activating GTK bug workaround for gtkrc files
Set from kickstart - Hal pin stored value was 3
Set from kickstart - Hal pin has been set to 3
...........Xlib.protocol.request.QueryExtension
..
**** GMOCCAPY INFO ****
**** no valid probe config in INI File ****
**** disabled tool measurement ****
******************************* Gcode.lang found

(gmoccapy:1996): GtkSourceView-CRITICAL **: gtk_source_language_manager_set_search_path: assertion `lm->priv->ids == NULL' failed
**** GMOCCAPY INFO : inifile = /home/shop/linuxcnc/configs/lathe/lathe.ini ****:
**** GMOCCAPY INFO : postgui halfile = postgui_call_list.hal ****:
/usr/lib/python2.6/dist-packages/Onboard/KeyGtk.py:43: PangoWarning: pango_font_description_set_size: assertion `size >= 0' failed
  font_description.set_size(self.font_size)


Regards
Marius


www.bluearccnc.com

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

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