public class DataReader extends Thread
Depending on the XBee operating mode, read data is notified as is to the subscribed listeners or is parsed to a packet using the packet parser and then notified to subscribed listeners.
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
DataReader(IConnectionInterface connectionInterface,
OperatingMode mode,
XBeeDevice xbeeDevice)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDataReceiveListener(IDataReceiveListener listener)
Adds the given data receive listener to the list of listeners that will
be notified when XBee data packets are received.
|
void |
addIOSampleReceiveListener(IIOSampleReceiveListener listener)
Adds the given IO sample receive listener to the list of listeners that
will be notified when an IO sample packet is received.
|
void |
addModemStatusReceiveListener(IModemStatusReceiveListener listener)
Adds the given Modem Status receive listener to the list of listeners
that will be notified when a modem status packet is received.
|
void |
addPacketReceiveListener(IPacketReceiveListener listener)
Adds the given packet receive listener to the list of listeners that will
be notified when any XBee packet is received.
|
void |
addPacketReceiveListener(IPacketReceiveListener listener,
int frameID)
Adds the given packet receive listener to the list of listeners that will
be notified when an XBee packet with the given frame ID is received.
|
XBeePacketsQueue |
getXBeePacketsQueue()
Returns the queue of read XBee packets.
|
boolean |
isRunning()
Returns whether this Data reader is running or not.
|
void |
removeDataReceiveListener(IDataReceiveListener listener)
Removes the given data receive listener from the list of data receive
listeners.
|
void |
removeIOSampleReceiveListener(IIOSampleReceiveListener listener)
Removes the given IO sample receive listener from the list of IO sample
receive listeners.
|
void |
removeModemStatusReceiveListener(IModemStatusReceiveListener listener)
Removes the given Modem Status receive listener from the list of Modem
Status receive listeners.
|
void |
removePacketReceiveListener(IPacketReceiveListener listener)
Removes the given packet receive listener from the list of XBee packet
receive listeners.
|
void |
run() |
void |
setXBeeReaderMode(OperatingMode mode)
Sets the XBee operating mode of this data reader.
|
void |
stopReader()
Stops the Data reader thread.
|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public DataReader(IConnectionInterface connectionInterface, OperatingMode mode, XBeeDevice xbeeDevice)
DataReader
object for the
given connection interface using the given XBee operating mode and XBee
device.connectionInterface
- Connection interface to read data from.mode
- XBee operating mode.xbeeDevice
- Reference to the XBee device containing this
DataReader
object.NullPointerException
- if connectionInterface == null
or
mode == null
.IConnectionInterface
,
XBeeDevice
,
OperatingMode
public void addDataReceiveListener(IDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener
- Listener to be notified when new XBee data packets are
received.removeDataReceiveListener(IDataReceiveListener)
,
IDataReceiveListener
public void addIOSampleReceiveListener(IIOSampleReceiveListener listener)
If the listener has been already added, this method does nothing.
listener
- Listener to be notified when new IO sample packets are
received.removeIOSampleReceiveListener(IIOSampleReceiveListener)
,
IIOSampleReceiveListener
public void addModemStatusReceiveListener(IModemStatusReceiveListener listener)
If the listener has been already added, this method does nothing.
listener
- Listener to be notified when new modem status packets are
received.removeModemStatusReceiveListener(IModemStatusReceiveListener)
,
IModemStatusReceiveListener
public void addPacketReceiveListener(IPacketReceiveListener listener)
If the listener has been already added, this method does nothing.
listener
- Listener to be notified when any XBee packet is received.addPacketReceiveListener(IPacketReceiveListener, int)
,
removePacketReceiveListener(IPacketReceiveListener)
,
IPacketReceiveListener
public void addPacketReceiveListener(IPacketReceiveListener listener, int frameID)
If the listener has been already added, this method does nothing.
listener
- Listener to be notified when an XBee packet with the
provided frame ID is received.frameID
- Frame ID for which this listener should be notified and
removed after.
Using ALL_FRAME_IDS
this listener will be
notified always and will be removed only by user request.addPacketReceiveListener(IPacketReceiveListener)
,
removePacketReceiveListener(IPacketReceiveListener)
,
IPacketReceiveListener
public XBeePacketsQueue getXBeePacketsQueue()
XBeePacketsQueue
public boolean isRunning()
true
if the Data reader is running, false
otherwise.stopReader()
public void removeDataReceiveListener(IDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener
- Data receive listener to be remove from the list.addDataReceiveListener(IDataReceiveListener)
,
IDataReceiveListener
public void removeIOSampleReceiveListener(IIOSampleReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener
- IO sample receive listener to remove from the list.addIOSampleReceiveListener(IIOSampleReceiveListener)
,
IIOSampleReceiveListener
public void removeModemStatusReceiveListener(IModemStatusReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener
- Modem Status receive listener to remove from the list.addModemStatusReceiveListener(IModemStatusReceiveListener)
,
IModemStatusReceiveListener
public void removePacketReceiveListener(IPacketReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener
- Packet receive listener to remove from the list.addPacketReceiveListener(IPacketReceiveListener)
,
addPacketReceiveListener(IPacketReceiveListener, int)
,
IPacketReceiveListener
public void setXBeeReaderMode(OperatingMode mode)
mode
- New XBee operating mode.NullPointerException
- if mode == null
.OperatingMode
public void stopReader()
isRunning()
© Copyright 2014–2014 Digi International Inc. All rights reserved.