|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alien.enterpriseRFID.reader.AbstractReader
com.alien.enterpriseRFID.reader.AlienClass1Reader
com.alien.enterpriseRFID.reader.AlienClass01Reader
This class allows the host to interact with Alien readers which use the RQL (Reader Query Language) protocol.
Once a valid reader object is instantiated, the user would first open a connection to it, then use any of the simple methods that implement the full command set described by the Reader Interface Guide. Without having the benefit of an ASCII-based interface controller on the reader, much of the autonomous mode functionality found on Alien's full-sized readers must be emulated (partially) by this class. Basically, this class supports autonomous operation only in that it can read tags constantly on it's own, maintaining its own TagList.
This class inherits from AlienClass1Reader
, which supports readers with
much more functionality than the Class 0/1 readers provide. As such, the
sendString() and receiveString() methods are overridden so that commands
designed to work only with ASCII-based readers are not sent to OEM readers.
Field Summary | |
int |
lastCommandByteCount
|
byte[] |
lastCommandBytes
|
int |
lastResponseByteCount
|
byte[] |
lastResponseBytes
|
TagTable |
tagTable
|
Fields inherited from class com.alien.enterpriseRFID.reader.AlienClass1Reader |
ALL_MASK, CLASS0, CLASS1GEN1_64BITS, CLASS1GEN1_96BITS, CLASS1GEN1_ALL, CLASS1GEN1_LEPTON, CLASS1GEN1_OMEGA, CLASS1GEN1_QUARK, CLASS1GEN2, CUSTOM_FORMAT, DATA_INC_ALWAYS, DATA_INC_FAIL, DATA_INC_OFF, DATA_INC_SUCCESS, DATA_INC_WRITE, DATE_FORMATTER, FUNCTION_PROGRAMMER, FUNCTION_READER, G2TARGET_A, G2TARGET_AB, G2TARGET_B, GLOBAL_SCROLL, INVENTORY, LOCKTYPE_LOCK, LOCKTYPE_PERMALOCK, LOCKTYPE_PERMAUNLOCK, LOG_OFF, LOG_ON, OFF, ON, PROG_CLASS0, PROG_CLASS1GEN1, PROG_CLASS1GEN2, RFMOD_DRM, RFMOD_HS, RFMOD_STD, TERSE_FORMAT, TEXT_FORMAT, XML_FORMAT |
Fields inherited from class com.alien.enterpriseRFID.reader.AbstractReader |
DEBUG_BYTES, DEBUG_OFF, DEBUG_TEXT, DEFAULT_TIMEOUT, TIMEOUTMODE_CHARACTER, TIMEOUTMODE_COMMAND |
Constructor Summary | |
AlienClass01Reader()
Constructs a new AlienClass01Reader object, initializing an internal TagTable, and setting AutoMode off. |
|
AlienClass01Reader(java.lang.String address)
Constructs a new AlienClass01Reader object, specifying the address. |
|
AlienClass01Reader(java.lang.String ipAddress,
int port)
|
Method Summary | |
void |
autoModeReset()
Reset all autonomous mode values to their default states, including turning autonomous mode off. |
void |
clearTagList()
Clears all the tags from the internal TagList. |
void |
eraseTag()
Erases the data in the tag's ID space, using default loop-control parameters. |
java.lang.String |
getAcquireMode()
Returns the method that the reader uses to scan for tags. |
int |
getActiveAntenna()
Returns the number of the active antenna. |
java.lang.String |
getAntennaSequence()
Returns the Antenna Sequence, as a comma-separated String of hex values. |
int |
getAutoMode()
Returns the ON/OFF status of Autonomous mode. |
int |
getPersistTime()
Returns the time, in seconds, that tags on the internal TagList will persist without having been read, before being purged from the list. |
int |
getProgAntenna()
Returns the number of the programming antenna. |
java.lang.String |
getReaderName()
Returns the reader name. |
java.lang.String |
getReaderType()
Returns the reader type. |
java.lang.String |
getReaderVersion()
Returns the firmware version of this reader. |
Tag |
getTag()
Acquires one Tag, once. |
Tag |
getTag(int multiplier)
Acquires one Tag, using a multiplier. |
java.lang.String |
getTagID()
Acquires tags, and returns the TagID of the first tag on the TagList. |
Tag[] |
getTagList()
Returns an array of tags known to the reader, once. |
Tag[] |
getTagList(int multiplier)
Fetches and returns the tag list, using a multiplier count. |
Tag[] |
getTagList(long readMillis)
Reads tags for the specified number of milliseconds. |
int |
getTagType()
High Level functions |
java.lang.String |
getTimer()
Returns the Timer text for the most recent acquire. |
java.lang.String |
issueReaderCommand(java.lang.String commandString)
Issues a string command to the reader, and returns the reader's response. |
void |
killTag(java.lang.String tagIDAndPassCode)
Kills a tag by erasing the data in a locked tag's ID space, using default loop-control parameters. |
void |
lockTag(java.lang.String passCode)
Locks a Tag, using default loop-control parameters and tagID length. |
void |
parseTagListString(java.lang.String tagListString)
|
void |
programTag(java.lang.String tagID)
Writes data to the tag ID space, using default loop-control parameters. |
java.lang.String |
readerCommandCLI()
Enables raw RQL-based command sequences to be sent to the reader. |
void |
reboot()
Causes the reader module to reboot. |
byte[] |
receiveBytes()
Receives and entire response message from the reader. |
java.lang.String |
receiveString(boolean blockForInput)
Returns the response string prepared by the sendString() method, as it if came from a reader sporting an ASCII-based interface. |
void |
run()
Run the automode function for this reader. |
void |
sendBytes(byte[] bytes)
Sends an arbitrary sequence of bytes to the reader. |
void |
sendString(java.lang.String command)
Intercepts a command string intended for the RQL-based reader, and attempts to handle the command using methods from this class. |
void |
setAcquireMode(java.lang.String acquireMode)
Specifies the method the reader uses to scan for tags. |
void |
setActiveAntenna(int antennaNumber)
Sets the active antenna to the specified value. |
void |
setAntennaSequence(java.lang.String sequenceString)
Sets the sequence of antenna ports, using a comma-separated String of integer values, that is used by the reader when responding to an Inventory command. |
void |
setAutoMode(int autoMode)
Sets the ON/OFF status of Autonomous mode. |
void |
setDebugLevel(int level)
Sets the current Debug Level. |
void |
setPersistTime(int persistTime)
Sets the time, in seconds, that tags on the internal TagList will persist without having been read, before being purged from the list. |
void |
setProgAntenna(int antennaNumber)
Sets the programming antenna to the specified value. |
void |
setTagType(int tagType)
Sets the bitmap indicating which Alien RFID tag types the reader should look for. |
java.lang.String |
toString()
Returns a String representation of this reader object (it's ReaderType). |
java.lang.String |
verifyTag()
Interrogates the state of a tag that may or may not be readable by the Acquire commands. |
Methods inherited from class com.alien.enterpriseRFID.reader.AbstractReader |
bringIntoRange, clearInputBuffer, close, doReaderCommand, getAddress, getDebugLevel, getInputStream, getOutputStream, getReaderReply, getReaderReplyKeyword, getReaderReplyValueInt, getReaderReplyValueString, getTimeOutMilliseconds, getTimeOutMode, isOpen, isValidateOpen, open, receiveLine, setAddress, setConnection, setConnection, setInputStream, setNetworkConnection, setOutputStream, setSerialBaudRate, setSerialConnection, setTimeOutMilliseconds, setTimeOutMode, setValidateOpen, test |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public TagTable tagTable
public byte[] lastResponseBytes
public byte[] lastCommandBytes
public int lastResponseByteCount
public int lastCommandByteCount
Constructor Detail |
public AlienClass01Reader(java.lang.String address)
address
- the IP Address where the reader is connectedpublic AlienClass01Reader()
public AlienClass01Reader(java.lang.String ipAddress, int port)
Method Detail |
public void setDebugLevel(int level)
AbstractReader
Setting the Debug Level to DEBUG_TEXT causes the text of every reader command/response to be echoed to stdout. For example, calling getReaderName() with Debug Level set to DEBUG_TEXT displays the following:
Write: Get ReaderName Read: ReaderName = Alien RFID ReaderSetting the Debug Level to DEBUG_BYTES causes the raw hex data of every reader command/response to be echoed to stdout. For example, the same getReaderName() call with Debug Level set to DEBUG_BYTES displays the following:
Write: 01 47 65 74 20 52 65 61 64 65 72 4E 61 6D 65 0D 0A Read: 52 65 61 64 65 72 4E 61 Read: 6D 65 20 3D 20 41 6C 69 Read: 65 6E 20 52 46 49 44 20 Read: 52 65 61 64 65 72 0D 0A Read: 00This Debug Level shows the additional bytes sent to and received from the reader that are used to prefix and terminate commands and responses.
Setting the Debug Level to DEBUG_OFF turns off these diagnostic messages, which is the default state.
setDebugLevel
in class AbstractReader
level
- the new Debug Level settingpublic java.lang.String issueReaderCommand(java.lang.String commandString) throws AlienReaderConnectionException, AlienReaderTimeoutException, AlienReaderCommandErrorException
Any responses from the reader which indicate an error cause this class to generate an exception, which must be handled by the object which made the original call.
commandString
- the command to send
AlienReaderConnectionException
- if communication fails
AlienReaderTimeoutException
- if the communication times out
AlienReaderCommandErrorException
- if the reader returns an error response to the commandpublic int getTagType()
getTagType
in class AlienClass1Reader
public void setTagType(int tagType)
AlienClass1Reader
This is primarily due to the fact that "Lepton" tags have longer id spaces (128 bits) than "Quark" and "Omega" tags (96 bits). If the reader is looking only for Leptons, or only for Quarks and Omegas, it knows beforehand how many bits of ID to expect from a tag, and can therefore operate more quickly.
The value returned is a bit map, where each bit enables a certain tag type:
Bit 0 : 64-bit Class1 (Quark) Bit 1 : 64-bit Class1 (Omega) Bit 2 : 96-bit Class1 (Lepton) Bit 3 : Class0/Class0+ Bit 4 : Class1 Gen2 Bit 5 : reserved Bit 6 : reserved Bit 7 : reservedSo, to have the reader look only for Quark and Omega tag types, use a TagType of 3 ("011" decimal). Similarly, use a TagType of 7 to specify looking for all Class1 Gen1 tag types, and a TagType of 4 to specify Lepton tags only.
The allowable range for TagType depends on the reader, and it's list of supported tag protocols.
For convenience, a series of constants are defined in this class: CLASS1GEN1_QUARK, CLASS1GEN1_OMEGA, CLASS1GEN1_64BITS, CLASS1GEN1_LEPTON, CLASS1GEN1_96BITS CLASS1GEN1_ALL, CLASS0, CLASS1GEN2. These constants facilitate selecting specific tag types or combinations of tag types, by ORing ( | ) the constants together in the call to setTagType().
setTagType
in class AlienClass1Reader
tagType
- the bitmap indicating the tag types the reader should look forpublic void setPersistTime(int persistTime)
setPersistTime
in class AlienClass1Reader
persistTime
- the time (secs) to wait before purging unseen tagsAlienClass1Reader.getPersistTime()
public int getPersistTime()
getPersistTime
in class AlienClass1Reader
AlienClass1Reader.setPersistTime(int)
public void clearTagList()
clearTagList
in class AlienClass1Reader
AlienClass1Reader.getTagList(int)
,
AlienClass1Reader.getTagList(int)
,
AlienClass1Reader.getTag(int)
,
AlienClass1Reader.getTag(int)
public Tag[] getTagList() throws AlienReaderException
getTagList
in class AlienClass1Reader
null
if no tags
AlienReaderException
- if reader communication failsgetTagList(int)
public Tag[] getTagList(int multiplier) throws AlienReaderException
getTagList
in class AlienClass1Reader
multiplier
- the number of times to acquire tags
null
if no tags
AlienReaderException
- if reader communication failsAlienClass1Reader.getTagList(int)
,
AlienClass1Reader.getTag(int)
,
AlienClass1Reader.getTag(int)
,
AlienClass1Reader.clearTagList()
public Tag[] getTagList(long readMillis) throws AlienReaderException
readMillis
- the amount of time to spend reading tags
AlienReaderException
- if reader communication failspublic Tag getTag() throws AlienReaderException
getTag
in class AlienClass1Reader
AlienReaderException
- if reader communication failsgetTag(int)
,
getTagList()
,
getTagList(int)
public Tag getTag(int multiplier) throws AlienReaderException
multiple
times), if necessary.
getTag
in class AlienClass1Reader
multiplier
- the number of times to acquire tags
AlienReaderException
- if reader communication failsgetTag()
,
getTagList()
,
getTagList(int)
public java.lang.String getTagID() throws AlienReaderException
getTagID
in class AlienClass1Reader
AlienReaderException
- if reader communication failsgetTag()
public int getAutoMode()
getAutoMode
in class AlienClass1Reader
setAutoMode(int)
,
AlienClass1Reader.resetAutoMode()
public void setAutoMode(int autoMode)
In the interests of future compatibility, you should use AlienClass1Reader.ON
and AlienClass1Reader.OFF
constants to set and test this parameter.
setAutoMode
in class AlienClass1Reader
autoMode
- the new ON/OFF status of AutoModegetAutoMode()
,
AlienClass1Reader.resetAutoMode()
public void autoModeReset()
autoModeReset
in class AlienClass1Reader
getAutoMode()
,
setAutoMode(int)
public java.lang.String getAcquireMode()
getAcquireMode
in class AlienClass1Reader
setAcquireMode(String)
public void setAcquireMode(java.lang.String acquireMode)
AlienClass1Reader.INVENTORY
and AlienClass1Reader.GLOBAL_SCROLL
to specify
and test for this parameter.
Inventory
The Inventory acquire mode performs a full anti-collision search on tags in
the reader's field of view. This method will locate and distinguish multiple
tags in front of the reader at the same time.
Global Scroll
The Global Scroll acquire mode instructs the reader to read a single tag
repeatedly. This is a very fast tag reading method which is most effective
when only one tag at a time is expected to be within reader range, as in
conveyor belt applications. Under such circumstances, the performance for
single tag reading is considerably faster than repeatedly doing a full tag
search using the Inventory mode.
NOTE: If multiple tags are in range of the reader when Global Scroll is used, the reader will either select one of the tags (usually the "strongest" or "loudest") to read and report it, or will read none of the tags.
setAcquireMode
in class AlienClass1Reader
acquireMode
- the method this reader uses to read tagsgetAcquireMode()
public java.lang.String getReaderName()
getReaderName
in class AlienClass1Reader
AlienClass1Reader.setReaderName(String)
public java.lang.String getReaderType()
getReaderType
in class AlienClass1Reader
public java.lang.String getReaderVersion() throws AlienReaderException
getReaderVersion
in class AlienClass1Reader
AlienReaderException
- if reader communication failspublic void reboot() throws AlienReaderException
AlienReaderException
- if reader communication failspublic void setActiveAntenna(int antennaNumber)
antennaNumber
- the number of the antenna to use
AlienReaderException
- if reader communication failsgetActiveAntenna()
,
setAntennaSequence(String)
,
getAntennaSequence()
public int getActiveAntenna() throws AlienReaderException
AlienReaderException
- if reader communication failssetActiveAntenna(int)
,
setAntennaSequence(String)
,
getAntennaSequence()
public void setProgAntenna(int antennaNumber) throws AlienReaderException
setProgAntenna
in class AlienClass1Reader
antennaNumber
- the number of the antenna to program on
AlienReaderException
- if reader communication failsgetProgAntenna()
public int getProgAntenna() throws AlienReaderException
getProgAntenna
in class AlienClass1Reader
AlienReaderException
- if reader communication failssetProgAntenna(int)
public void setAntennaSequence(java.lang.String sequenceString) throws AlienReaderException
It should be noted that any array element can be set to any valid antenna number, thus allowing the sequence of antennas to be executed in any order, and the same antenna can be used multiple times in response to one Inventory command.
setAntennaSequence
in class AlienClass1Reader
sequenceString
- a comma-separated list of antenna ports
AlienReaderException
- if reader communication failsgetAntennaSequence()
public java.lang.String getAntennaSequence() throws AlienReaderException
getAntennaSequence
in class AlienClass1Reader
AlienReaderException
- if reader communication failssetAntennaSequence(String)
public java.lang.String verifyTag() throws AlienReaderException
A Verify command cannot sort multiple tags; it should only be used on one tag at a time.
verifyTag
in class AlienClass1Reader
AlienReaderException
- if reader communication failspublic void programTag(java.lang.String tagID) throws AlienReaderException
The reader automatically generates the CRC for the supplied tag ID data and programs it into the first two bytes of ID space. This command does not lock the tag or program a lock code.
programTag
in class AlienClass1Reader
tagID
- the string representation of the 8- or 12-byte tag ID to program
AlienReaderException
- if reader communication failsAlienClass1Reader.programEPC(String)
,
AlienClass1Reader.programEPC()
public void eraseTag() throws AlienReaderException
eraseTag
in class AlienClass1Reader
AlienReaderException
- if reader communication failspublic void killTag(java.lang.String tagIDAndPassCode) throws AlienReaderException
killTag
in class AlienClass1Reader
tagIDAndPassCode
- a string representing the tag's ID, followed by its PassCode
AlienReaderException
- if reader communication failspublic void lockTag(java.lang.String passCode) throws AlienReaderException
lockTag
in class AlienClass1Reader
passCode
- a String representing the byte value used to lock and kill the tag
AlienReaderException
- if reader communication failsAlienClass1Reader.lockEPC(String)
,
AlienClass1Reader.lockEPC()
public void run()
run
in interface java.lang.Runnable
public void parseTagListString(java.lang.String tagListString)
public java.lang.String getTimer()
public java.lang.String readerCommandCLI()
public void sendString(java.lang.String command) throws AlienReaderConnectionException
This gives the illusion that the reader is accepting and returning ASCII-based communications.
Furthermore, if the command string is not preceeded by a \1 character (which doReaderCommand() adds automatically, then it is assumed that the command is coming from a command line interface, and appropriate "Alien>" prompts are attached to the response string.
sendString
in class AbstractReader
command
- the text string to send
AlienReaderConnectionException
- if communication failsreceiveString(boolean)
public java.lang.String receiveString(boolean blockForInput)
receiveString
in class AbstractReader
blockForInput
- ignored
sendString(String)
public void sendBytes(byte[] bytes) throws AlienReaderConnectionException
bytes
- the array of bytes to send to the reader
AlienReaderConnectionException
- if reader communication failsreceiveBytes()
public byte[] receiveBytes() throws AlienReaderConnectionException, AlienReaderTimeoutException
AlienReaderConnectionException
- if reader communication fails
AlienReaderTimeoutException
- if a timely response is not receivedsendBytes(byte[])
public java.lang.String toString()
toString
in class AlienClass1Reader
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |