|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.nxt.NXTEvent
public class NXTEvent
This class allows communication of event data between the leJOS firmware and the leJOS low level classes. It can be used to detect I/O completion, Port values changing, button presses etc. To use create a class having the required device type and filter (this may identify a particular port, or I/O operation). Then call the waitEvent function to wait for events from the firmware. This call will block until either the firmware signals an event or the timeout occurs. Upon completion the eventData field will contain information about the event(s) that have been reported. Events themselves are normally reset by calling the associated function to read/write the associated device. If an event is not cleared, it will be reported again in subsequent calls to eventWait.
NOTE: This is a low level system interface and should probably not be used directly by user code.
Field Summary | |
---|---|
static int |
ANALOG_PORTS
Event type for the Analogue ports |
static int |
BLUETOOTH
Event type for the Bluetooth device |
static int |
BUTTONS
Event type for the NXT Buttons |
static int |
I2C_PORTS
Event type for the i2c ports |
static int |
NONE
Event type for no hardware events |
static int |
RS485
Event type for the RS485 device |
static int |
SYSTEM
Event type for system events |
static int |
TIMEOUT
|
static int |
USB
Event type for the USB device |
static int |
USER1
These bits are reserved in the eventData field to indicate that a user event has occurred. |
static int |
USER2
|
static int |
USER3
|
static int |
USER4
|
static long |
WAIT_FOREVER
Value used to make a timeout be forever. |
Constructor Summary | |
---|---|
NXTEvent()
|
Method Summary | |
---|---|
static NXTEvent |
allocate(int type,
int filter,
int update)
Create a new event ready for use. |
void |
clearEvent(int event)
Clear an event. |
void |
free()
Release an event. |
int |
getEventData()
|
int |
getFilter()
Return the current filter settings. |
void |
notifyEvent(int event)
This call can be used to raise a user event. |
int |
registerEvent()
Register this event with the system. |
void |
setFilter(int filter)
Set the filter to be applied to this event. |
int |
unregisterEvent()
Unregister this event. |
int |
waitEvent(int newFilter,
long timeout)
Wait for an event to occur using the specified filter or for the specified timeout. |
int |
waitEvent(long timeout)
Wait for an event to occur or for the specified timeout. |
static boolean |
waitEvent(NXTEvent[] events,
long timeout)
Wait for multiple events. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NONE
public static final int BLUETOOTH
public static final int USB
public static final int RS485
public static final int ANALOG_PORTS
public static final int I2C_PORTS
public static final int BUTTONS
public static final int SYSTEM
public static final int TIMEOUT
public static final int USER1
public static final int USER2
public static final int USER3
public static final int USER4
public static final long WAIT_FOREVER
Constructor Detail |
---|
public NXTEvent()
Method Detail |
---|
public int registerEvent()
public int unregisterEvent()
public int waitEvent(long timeout) throws InterruptedException
timeout
- the timeout in ms. Note a value of <= 0 will return immeadiately.
InterruptedException
public int waitEvent(int newFilter, long timeout) throws InterruptedException
newFilter
- The type specific filter for this wait.timeout
- the timeout in ms. Note a value of <= 0 will return immediately.
InterruptedException
public static boolean waitEvent(NXTEvent[] events, long timeout) throws InterruptedException
events
- an array of events to wait on.timeout
- the wait timeout. Note a value of <= 0 will return immediately.
InterruptedException
public void notifyEvent(int event)
event
- public void clearEvent(int event)
event
- The events to be cleared.public int getEventData()
public void setFilter(int filter)
filter
- The new filter value.public int getFilter()
public static NXTEvent allocate(int type, int filter, int update)
type
- The event type.filter
- The event specific filter.update
- The update period used when checking the event.
public void free()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |