objects not loaded or recognized

More
29 Aug 2014 02:52 #50429 by ArcEye

Parceltongue as you say confuses the crap out of me.


Sounds almost better than python ;)

I see Kirk had a similar idea to me about self.ini never having been created, don't know if that function has a return value you can check as you would in C.

The trouble with python is that you don't seem to have to declare anything, you just allocate something to self.foo and foo is created, without even a type being specified.

I just wonder is self.ini is a type variant which contains nothing because the initialisation failed and hence why it has no member / method that you were trying to access.

Cannot happen with C, because you have to declare exactly what the variable is and will hold in advance. If the assignment does not match the data type it will error and if the assignment did not work it will return an error or can be checked to be NULL showing it did not work.

good luck

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

More
29 Aug 2014 07:40 - 29 Aug 2014 07:41 #50438 by cmorley
This last error is because of the very last line using brackets () instead of square brackets [] :

This:
def get_handlers(halcomp, builder, useropts):
    return(TwinControl(halcomp, builder, useropts))

Should be:
def get_handlers(halcomp, builder, useropts):
    return[TwinControl(halcomp, builder, useropts)]

I didn't try your other snip-it. but usually one has to 'import linuxcnc'
to access the INI file.

Chris M
Last edit: 29 Aug 2014 07:41 by cmorley. Reason: opps I made a bracket mistake too :)
The following user(s) said Thank You: mariusl

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

More
29 Aug 2014 16:34 #50450 by mariusl
Thanks Chris.
I would never in a year of Sundays have found that problem. I just dont know python well enough to even think of such a problem.

How would I have gone about discovering that kind of issue if you had not helped? Any advise?

Regards
Marius


www.bluearccnc.com

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

More
30 Aug 2014 00:52 #50489 by newbynobi
Hallo Marius and all the others,

after searching and getting crazy, I found a working solution and also the problem:

First advice to all , please load the gladevcp comand in the ini with the debug option "-d" you get more, but not all information.
Next Debugging with Aptana Studio may help.
Check for spaces and tabs, as you are not allowed to mix them in python!

OK, attached a working version, I shortened it a lot, as you do not need to save the state of the widgets, I errased all that part from the code.
The selected gear will be saved on leaving the GUI and restored after starting it again. So the hal pin will be up to date after the start.

There is one thing I do not understand and hope some of you might be able to bring some light to the darkness:

Most of the problems Marius noticed do come from:
....
        self.frame = self.builder.get_object("frame_main")
        self.frame.connect("destroy", self.on_frame_main_destroy)
....

def on_frame_main_destroy(self, Widget, data = None):
....

I do not know why, but the code will not work if you change the code to somewhat like:
....
        self.frame = self.builder.get_object("frame_main")
        self.frame.connect("destroy", self._frame_main_destroy)
....

def _frame_main_destroy(self, Widget, data = None):
....

I checked the glade file for signal handlers, but the glade file looks fine, no handlers included.

It does work, but why am I not allowed to change the names?

Just unpack the attached sim.config to your configs folder and start it.
I tested with 2.6.2

Norbert
Attachments:

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

More
30 Aug 2014 01:03 - 30 Aug 2014 01:08 #50490 by newbynobi
Hallo,

I just checked on my new development computer with Wheesy and found out, that the destroy function is not allowed to begin with an underscore, other renaming is possible.

Also if you delete the corresponding lines, the code will not work as expected, due to the reason that the destroy handler is not present,

The hell knows why.

Norbert
Last edit: 30 Aug 2014 01:08 by newbynobi.

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

More
30 Aug 2014 14:27 #50507 by mariusl
Hi Norbert
Also notice Chris's post above. Notice the square brackets.
def get_handlers(halcomp, builder, useropts):
    return[TwinControl(halcomp, builder, useropts)]

A further problem. You used this code with a variable called increment. It works for me if I test the p[anel outside of Gmoccapy but if I run it from inside Gmoccapy it says that the class does not have such an instance.
Your code
def on_btn_THC_speed_pressed(self, widget, dir):
        increment = self.thcspeedincr * dir
        self.thcspeedval = self.adj_THC_speed.get_value() + increment
        self.adj_THC_speed.set_value(self.thcspeedval)

My code
def _btn_plus_pressed(self, Widget, dir):
        increment = self.increment * dir
        self.gear_state = self.gear_state + increment
        if self.gear_state >= 6: self.gear_state = 6
        self.ini.save_state(self)
        self.halcomp["selected-gear"] = self.gear_state
        self.lbl_gear.set_label("%1.0f" % self.gear_state)

I will test your code today.

Regards
Marius


www.bluearccnc.com

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

More
30 Aug 2014 14:41 #50508 by mariusl
One problem with my approach here is that when you startup the last selected gear button is not visible. Although the selectedgear pin is restored, the user does not know what the gear was. I am trying to get the button to be on that corresponds to the selected gear.

If this does not work I will have to use labels and the increment and decrement buttons.

Regards
Marius


www.bluearccnc.com

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

More
31 Aug 2014 00:32 #50525 by newbynobi
Hallo Marius,

I did notice the post from Chris, and you are right, I made the mistake with "(" instead of "[" in gmoccapy plöasma. I do get also the error you mentioned, but still the stuff works on my PC. I changed the brackets, and the plasma panale works too. I am not able to reproduce the error "increment" does not exist.

The "making the button on" will not be possible in the actual state, as you use push button! Please use toggle button, they can be switched on. I recoment using option buttons, as in a group of them only one button can be active. You can change the design of the option buttons to be normal button. Take a look at the increment button in gmoccapy, that are option button.

May be you want even to change the background color of the active button, to mark it even more. I do that on gmoccapy with the DRO button G54 / G55 and so on. ( By default they are hidden)

Norbert

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

More
31 Aug 2014 00:49 #50529 by mariusl
Hi Norbert

I noticed that about the buttons. I have them in a button box that only allow for one button to be on at a time. It is like a group. That works ok for now.

I used you sim example that you gave me after I pulled all my hair out. I found that the hal pin does not get set although it seem so even if your it back in python. The stored value does not get put on the pin.
self.halcomp.newpin("selected-gear", hal.HAL_S32, hal.HAL_OUT)
        self.halcomp["selected-gear"] = self.SelectedGear

This seems to not work.

I even did this and it shows the correct values as expected but the pin has 0 on it at startup.
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"])

I have a small component that looks at the selected gear input and then sets a led next to each button based on the selected gear. During operation it works great but as I said on startup it is sitting at 0.

Regards
Marius


www.bluearccnc.com

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

More
31 Aug 2014 01:12 #50530 by newbynobi
Hallo Marius,

I can not understand that.

I tested my code on a brand new Debian Wheesy install and also on my old development computer and on both the file gearselect.var has been createt correctly on closing the GUI. I checked with halshow that the values do change. And if I start the GUI the Pin is set correctly on both computers.

Please look in your config folder for the file gearselect.var, open it with an editor and look for the stored value.

Now open the GUI and change a gear, close the GUI, the value have changed after closing the GUI.

In your glade file you do use GtkButton, so normal button, placing them in a buttonbox does not mean they a grouped. I am speeking of GtkRadioButton or GtkToggleButton. Only the code makes the Pin Unique.

Norbert

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

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