Go to Post Robotics is my football! - Nemo [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2011, 16:47
QRohlf's Avatar
QRohlf QRohlf is offline
Registered User
FRC #1823 (PING)
Team Role: Engineer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Portland, OR
Posts: 7
QRohlf is an unknown quantity at this point
type tInterruptHandler doesn't seem to exist

Hello,

I'm trying to implement the following behavior on my team's bot:
We have a forklift. This forklift has two limit switches at the top and bottom of the track. We would like to stop the forklift motor and reset/re-calibrate the class we're using to handle the encoder attached to the motor as well whenever one of these limit switches are tripped.

To handle all of the Forklift stuff, I've created a Forklift class, which has the limit switches as members in the form of DigitalInputs. In order to get the behavior described above to occur within the Forklift class, I'm trying to use something similar to the Java Observer Pattern. It looks like the way to do this with the WPI lib is to use DigitalInput.requestInterrupts(Object handler, Object param). The documentation for this method states that the handler Object should be:
"The address of the interrupt handler function of type tInterruptHandler that will be called whenever there is an interrupt on the digitial input port. Request interrupts in synchronus mode where the user program interrupt handler will be called when an interrupt occurs. The default is interrupt on rising edges only."

However, I cannot find the type tInterruptHandler anywhere in the API or the documentation.

My questions are:
1. Has anyone here been successful at implementing this type of behavior inside of a class other than IterativeRobot, using interrupts or otherwise?
2. If not, what is the proper way to use DigitalInput.requestInterrupts(handler, param) so that I can make it do what I want it to?

My background is in Android programming, so I am very comfortable with the pattern adding change listeners to objects, then implementing an abstract method within those change listeners in order to receive callbacks when a change occurs. I figured it would be similar with the WPI interrupts, except that I haven't been able to figure it out because of the missing tInterruptHandler.

Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2011, 22:35
QRohlf's Avatar
QRohlf QRohlf is offline
Registered User
FRC #1823 (PING)
Team Role: Engineer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Portland, OR
Posts: 7
QRohlf is an unknown quantity at this point
Re: type tInterruptHandler doesn't seem to exist

Anyone? I'm drawing a blank here.

Even if you don't have the answer, if you have contact info for someone at WPI who you think might be able to help, it would be awesome if you could PM that to me.
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2011, 11:36
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: type tInterruptHandler doesn't seem to exist

The "callback" version of requestInterrupts() was not fully implemented, but you should be able to use the synchronous version of requestInterrupts().

You can then have your interrupt handling code in a loop that first calls waitForInterrupt(). Roughly:

digIn.requestInterrupts();
while (true) { // or some condition
digIn.waitForInterrupt(300.0);

// ...do your interrupt handling code...

}
digIn.cancelInterrupts();

That loop can be pushed off to another Java thread.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi