|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alien.enterpriseRFID.discovery.SerialDiscoveryListenerService
SerialDiscoveryListenerService
checks each serial port for a Reader.
When the SerialDiscoveryListenerService
object is instantiated
and started, it automatically gets a list of all the serial ports on the host
computer and then proceeds to interrogate each port, looking for a reader. If
a reader is found the class calls the readerAdded() method of any registered
DiscoveryListener
s. If a reader has already been found and a subsequent
search finds it again, the readerRenew() method is called. Finally, if a
reader was found and now cannot be found, the readerRemoved() method is called.
In all instances, the DiscoveryListener
methods will be passed a
DiscoveryItem
, which provides details on the reader that was discovered,
renewed, or removed.
Additionally, an ActionListener
can be registered with the
SerialDiscoveryListenerService
. The actionPerformed() method is
called when the SerialDiscoveryListenerService
scans each port,
and can be used as a progress monitor. See the example code in the Developer's
Kit for more information.
In addition to listening for events, the SerialDiscoveryListenerService
has a method, getDiscoveryItems()
, which returns an array of all
currently known readers available on the serial ports.
The setSerialPortList(String)
method is useful in limiting which
serial ports to scan, or to scan ports that aren't automatically detected.
This service operates slightly differently that the NetworkDiscoveryListenerService
:
The NetworkDiscoveryListenerService
constantly listens for readers
via UDP protocol. This service will scan the serial ports, but only on demand.
It cannot constantly run in the background for fear of interrupting with the
use of a serial port; it cannot keep opening and closing serial ports in case
another application wants to use it
Field Summary | |
boolean |
isDebug
|
static int |
SCANNING_END
Used to identify within an ActionListener that all of the
ports have been scanned. |
static int |
SCANNING_PORT
Used to identify within an ActionListener just what the action
being reported is. |
static int |
SCANNING_PORTBUSY
Used to identify within an ActionListener that a scanned port
was busy. |
Constructor Summary | |
SerialDiscoveryListenerService()
Creates a new SerialDiscoveryListenerService. |
Method Summary | |
void |
allDiscoveryItemsExpired()
|
void |
checkSerialPort(java.lang.String serialPortName)
Checks a given serial port for a Reader. |
void |
discoveryItemExpired(DiscoveryItem discoveryItem)
Removes a DiscoveryItem from the hashtable, and notifies listeners. |
java.awt.event.ActionListener |
getActionListener()
Returns the object that has been registered by this SerialDiscoveryListenerService
to receive messages about the progress of the serial port scanning. |
DiscoveryItem[] |
getDiscoveryItems()
Returns an array of DiscoveryItem s representing all of the readers
that this SerialDiscoveryListenerService knows about. |
DiscoveryListener |
getDiscoveryListener()
Returns the object that has been registered by this SerialDiscoveryListenerService
to receive messages when readers are discovered, renewed, or removed on the
serial ports. |
int |
getMaxSerialPort()
Deprecated. use getSerialPortList() instead |
int |
getSerialBaudRate()
Returns the serial baud rate used to discover serially-connected readers. |
java.lang.String |
getSerialPortList()
Returns the list of serial ports that will be scanned. |
boolean |
isRunning()
Returns true if this SerialDiscoveryListenerService
is running, and false if it is not. |
void |
run()
This SerialDiscoveryListenerService will scan all the serial ports
for Readers. |
void |
setActionListener(java.awt.event.ActionListener actionListener)
Registers an object with this SerialDiscoveryListenerService
to receive messages about the progress of the serial port scanning. |
void |
setDiscoveryListener(DiscoveryListener discoveryListener)
Registers an object with this SerialDiscoveryListenerService
to receive messages when readers are discovered, renewed, or removed on the
serial ports. |
void |
setMaxSerialPort(int maxPort)
Deprecated. use setSerialPortList(String) instead |
void |
setSerialBaudRate(int serialBaudRate)
Sets the hserial baud rate used to discover serially-connected readers. |
void |
setSerialPortList(java.lang.String portList)
Specifies which serial ports will be scanned. |
void |
startService()
Starts up this SerialDiscoveryListenerService . |
void |
stopService()
Stops this SerialDiscoveryListenerService . |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SCANNING_PORT
ActionListener
just what the action
being reported is. In this case, that a particular port is being scanned.
public static final int SCANNING_END
ActionListener
that all of the
ports have been scanned.
public static final int SCANNING_PORTBUSY
ActionListener
that a scanned port
was busy.
public boolean isDebug
Constructor Detail |
public SerialDiscoveryListenerService() throws AlienDiscoverySerialException
AlienDiscoverySerialException
- if serial classes are not presentMethod Detail |
public DiscoveryListener getDiscoveryListener()
SerialDiscoveryListenerService
to receive messages when readers are discovered, renewed, or removed on the
serial ports. Registered listeners must implement the DiscoveryListener
interface.
public void setDiscoveryListener(DiscoveryListener discoveryListener)
SerialDiscoveryListenerService
to receive messages when readers are discovered, renewed, or removed on the
serial ports. Registered listeners must implement the DiscoveryListener
interface.
discoveryListener
- the listening objectpublic java.awt.event.ActionListener getActionListener()
SerialDiscoveryListenerService
to receive messages about the progress of the serial port scanning.
public void setActionListener(java.awt.event.ActionListener actionListener)
SerialDiscoveryListenerService
to receive messages about the progress of the serial port scanning. Registered
listeners must implement the ActionListener
interface.
actionListener
- the listening objectpublic int getMaxSerialPort()
getSerialPortList()
instead
The default value for maxSerialPort is 8.
public void setMaxSerialPort(int maxPort)
setSerialPortList(String)
instead
The default value for maxSerialPort is 8.
maxPort
- the port number of the highest port to scan for readerspublic int getSerialBaudRate()
The default value for serialBaudRate is 115200, which is the default communication rate of all Alien readers.
public void setSerialBaudRate(int serialBaudRate)
The default value for serialBaudRate is 115200, which is the default communication rate of all Alien readers.
serialBaudRate
- the baud rate at which to scan for readerspublic java.lang.String getSerialPortList()
setSerialPortList(String)
public void setSerialPortList(java.lang.String portList)
portList
is a
comma-separated string of integers. For example, "1,2,3" indicates only COM1,
COM2, and COM3 serial ports should be scanned.
To scan all detected serial ports, use an empty or null string.
portList
- comma-separated list of valid serial portsgetSerialPortList()
public void startService()
SerialDiscoveryListenerService
. This service will
run until all of the serial ports have been scanned, or until its stopService()
method is called.
public void stopService()
SerialDiscoveryListenerService
.
public void run()
SerialDiscoveryListenerService
will scan all the serial ports
for Readers.
run
in interface java.lang.Runnable
public boolean isRunning()
true
if this SerialDiscoveryListenerService
is running, and false
if it is not.
public void checkSerialPort(java.lang.String serialPortName)
AlienClass1Reader
object at the port and tries
to call its open() method.
serialPortName
- the name of the serial port to scan (ex: "COM1")public void discoveryItemExpired(DiscoveryItem discoveryItem)
DiscoveryItem
from the hashtable, and notifies listeners.
This method is public so that external sources can cancel leases...
for example if an external source tries to connect and fails, it can cancel
the lease that way.
discoveryItem
- the item that has expiredpublic void allDiscoveryItemsExpired()
public DiscoveryItem[] getDiscoveryItems()
DiscoveryItem
s representing all of the readers
that this SerialDiscoveryListenerService
knows about. Items that
were discovered by a NetworkDiscoveryListenerService
are not
included in this list.
DiscoveryItems
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |