Threaded listeners and motors 'n stuff, doesn't work

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Threaded listeners and motors 'n stuff, doesn't work

Postby Tickstart » Thu Jun 07, 2012 2:22 pm

I have to ask now, been stuck with this for a while. At first I tried to get some multithreading going but now I've gone back to basics but it still doesn't work!!

Mission: Have 2 listeners listening to 1 motor. When motor rotates, each listener does something.

Tools: RegulatedMotorListener. (open for suggestions, this is the only one I know of)

Problem: Only one listener works, ever.

Is this shit like Highlander or something, why can't several listeners co-exist?? >:C

I haven't supplied any code cause that only confuses, you'll have to assume it's correct (at least grammatically) and beautiful. How do you do it?
Thank you for any help, feel free to ask questions, I've tried to make this post as easy to read as possible.
Tickstart
New User
 
Posts: 13
Joined: Tue Jul 12, 2011 4:39 pm

Re: Threaded listeners and motors 'n stuff, doesn't work

Postby gloomyandy » Thu Jun 07, 2012 2:36 pm

The current NXtRegulatedMotor class only supports a single listener.... Arguably a bug, but that is not going to help you. Should be pretty easy to create a sub class that extends the regulated motor class or whatever and supplies a listener interface that can handle multiple listeners. Don't forget you have the source code to all of leJOS, so if you don't understand why something is not working you can always look at the code, if you do that...
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
you will quickly see that only a single listener is supported...

So what is it that you are actually trying to do. Personally I'm not a big fan of the listener interface but I guess it depends on what it is you are doing...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4240
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Threaded listeners and motors 'n stuff, doesn't work

Postby Tickstart » Thu Jun 07, 2012 2:49 pm

gloomyandy wrote:The current NXtRegulatedMotor class only supports a single listener.... Arguably a bug, but that is not going to help you. Should be pretty easy to create a sub class that extends the regulated motor class or whatever and supplies a listener interface that can handle multiple listeners. Don't forget you have the source code to all of leJOS, so if you don't understand why something is not working you can always look at the code, if you do that...
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
you will quickly see that only a single listener is supported...

So what is it that you are actually trying to do. Personally I'm not a big fan of the listener interface but I guess it depends on what it is you are doing...

Andy


Oh, yeah that explains it, thanks. Listeners, well basically I want some sort of interrupt. I'm not doing anything special here, just trying to learn some basics. Like an interrupt handler. And eventually mutexes, locks etc (monitors ..?).

But basically instead of a busy-wait loop to react to events I want an interrupt handler and the listener kind of does the trick donnit? Perhaps not, but in basic implementations it does..

Thanks anyway!
Tickstart
New User
 
Posts: 13
Joined: Tue Jul 12, 2011 4:39 pm


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests

more stuff