Package com.metratec.lib.rfidreader
Class StandardReader
- java.lang.Object
-
- com.metratec.lib.rfidreader.ConnectableDevice
-
- com.metratec.lib.rfidreader.StandardReader
-
public abstract class StandardReader extends ConnectableDevice
- Author:
- Matthias Neumann (neumann@metratec.com)
-
-
Field Summary
Fields Modifier and Type Field Description static String
RESPONSE_ERROR_CER
Response crc errorstatic int
RESPONSE_ERROR_LENGHT
static String
RESPONSE_ERROR_NSS
not supported standardstatic String
RESPONSE_ERROR_TCE
Response ok tag communication errorstatic String
RESPONSE_ERROR_TOE
Response time out errorstatic String
RESPONSE_ERROR_TOR
Response tag out of rangestatic String
RESPONSE_OK
Response ok-
Fields inherited from class com.metratec.lib.rfidreader.ConnectableDevice
STATE_CONFIGURING, STATE_CONNECTING, STATE_RUNNING, STATE_STOPPED, STATE_WAITING_FOR_RECONNECT
-
-
Constructor Summary
Constructors Constructor Description StandardReader(String identifier, ICommConnection connection)
Construct a new StandardReader instance with the specified connection
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
disconnect()
close the connectionboolean
getCRCState()
Gets the state of the Cyclic Redundancy Check (CRC)boolean
getEndOfFrameState()
End of Frame StateString
getFirmwareRevision()
get the Firmware RevisionString
getHardwareRevision()
Gets the hardware revisionboolean
getInput(int pin)
Reads the current state of an input pinint
getInputDebounceTime()
abstract List<String>
getInventory()
Looks for all tags in range of the reader and get all tags as a number of strings backReaderType
getReaderType()
Parse the Firmware Name and return theReaderType
String
getRevision()
Gets the firmware revisionString
getSerialNumber()
Gets the serial numbervoid
ping()
test if the reader is alivevoid
reset()
Reset the readervoid
setAntennaPort(int port)
Set the antenna port.void
setEventListener(RfidEventListener listener)
set the rfid event listenervoid
setInputDebounceTime(int inputDebounceTime)
void
setOutput(int pin, boolean state)
Sets the state of an output pinvoid
standby()
Sets the reader in a power saving modevoid
switchAntennas(int numberOfAntennas)
In case you want to automatically switch between multiple antennas (e.g. trying to find all tags in a search area that can only be searched using multiple antennas) you can use this automatic switching mode.
Switching always starts with the lowest antenna port (0).void
wakeUp()
Ends the power saving mode-
Methods inherited from class com.metratec.lib.rfidreader.ConnectableDevice
connect, connect, getIdentifier, getReceiveTimeout, isConnected, setIdentifier, setMaxReconnectWaitTime, setMinReconnectWaitTime, setReceiveTimeout, start, start, stop
-
-
-
-
Field Detail
-
RESPONSE_ERROR_LENGHT
public static final int RESPONSE_ERROR_LENGHT
- See Also:
- Constant Field Values
-
RESPONSE_ERROR_NSS
public static final String RESPONSE_ERROR_NSS
not supported standard- See Also:
- Constant Field Values
-
RESPONSE_ERROR_TCE
public static final String RESPONSE_ERROR_TCE
Response ok tag communication error- See Also:
- Constant Field Values
-
RESPONSE_ERROR_CER
public static final String RESPONSE_ERROR_CER
Response crc error- See Also:
- Constant Field Values
-
RESPONSE_ERROR_TOR
public static final String RESPONSE_ERROR_TOR
Response tag out of range- See Also:
- Constant Field Values
-
RESPONSE_ERROR_TOE
public static final String RESPONSE_ERROR_TOE
Response time out error- See Also:
- Constant Field Values
-
RESPONSE_OK
public static final String RESPONSE_OK
Response ok- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardReader
public StandardReader(String identifier, ICommConnection connection)
Construct a new StandardReader instance with the specified connection- Parameters:
identifier
- reader identifierconnection
- connection
-
-
Method Detail
-
getInputDebounceTime
public int getInputDebounceTime()
- Returns:
- the inputDebounceTime
-
setInputDebounceTime
public void setInputDebounceTime(int inputDebounceTime)
- Parameters:
inputDebounceTime
- the inputDebounceTime to set (minimum 50ms)
-
getInventory
public abstract List<String> getInventory() throws RFIDReaderException, CommConnectionException
Looks for all tags in range of the reader and get all tags as a number of strings back- Returns:
- List with the founded tags
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
reset
public void reset() throws RFIDReaderException, CommConnectionException
Reset the reader- Throws:
RFIDReaderException
- if a error occurs, seeRFIDReaderException.getErrorCode()
andThrowable.getMessage()
for more detailsCommConnectionException
- if a error occurs, seeCommConnectionException.getErrorCode()
andThrowable.getMessage()
for more details
-
disconnect
public void disconnect() throws CommConnectionException
Description copied from class:ConnectableDevice
close the connection- Overrides:
disconnect
in classConnectableDevice
- Throws:
CommConnectionException
- possible ICommConnection Error codes:- UNHANDLED_ERROR
-
standby
public void standby() throws RFIDReaderException, CommConnectionException
Sets the reader in a power saving mode- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
wakeUp
public void wakeUp() throws RFIDReaderException, CommConnectionException
Ends the power saving mode- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
getRevision
public String getRevision() throws RFIDReaderException, CommConnectionException
Gets the firmware revision- Returns:
- the device type, hardware architecture and firmware revision of the reader
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
getReaderType
public ReaderType getReaderType() throws RFIDReaderException, CommConnectionException
Parse the Firmware Name and return theReaderType
- Returns:
- the
ReaderType
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
getFirmwareRevision
public String getFirmwareRevision() throws RFIDReaderException, CommConnectionException
get the Firmware Revision- Returns:
- the Firmware Revision as String
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
getSerialNumber
public String getSerialNumber() throws RFIDReaderException, CommConnectionException
Gets the serial number- Returns:
- the serial number of the reader. The serial number is an ASCII string of 16 characters.
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
getHardwareRevision
public String getHardwareRevision() throws RFIDReaderException, CommConnectionException
Gets the hardware revision- Returns:
- the hardware revision of the reader which corresponds to the PCB layout version printed on the board. The number is an ASCII string of four characters.
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
getEndOfFrameState
public boolean getEndOfFrameState()
End of Frame State- Returns:
- end of frame ('\n') is active state
-
getCRCState
public boolean getCRCState()
Gets the state of the Cyclic Redundancy Check (CRC)- Returns:
- the CRC State
-
getInput
public boolean getInput(int pin) throws RFIDReaderException, CommConnectionException
Reads the current state of an input pin- Parameters:
pin
- input pin to read- Returns:
- true if input is high, false if input is low
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
setOutput
public void setOutput(int pin, boolean state) throws RFIDReaderException, CommConnectionException
Sets the state of an output pin- Parameters:
pin
- output pinstate
- true for high state, false for low state- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
ping
public void ping() throws CommConnectionException
test if the reader is alive- Throws:
CommConnectionException
- possible ICommConnection Errorcodes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
setAntennaPort
public void setAntennaPort(int port) throws CommConnectionException, RFIDReaderException
Set the antenna port.- Parameters:
port
- antenna port for the connected multiplexer [0..15]- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
switchAntennas
public void switchAntennas(int numberOfAntennas) throws CommConnectionException, RFIDReaderException
In case you want to automatically switch between multiple antennas (e.g. trying to find all tags in a search area that can only be searched using multiple antennas) you can use this automatic switching mode.
Switching always starts with the lowest antenna port (0). Switching to the next antenna port oc- curs automatically with the start of every tag manipulation command. No pin state is changed until the first tag manipulation command.- Parameters:
numberOfAntennas
- number of antennas, -1 for disable; Please note that for this parameter the number given is the counted number of participating antennas, not the antenna port numbers, thus stating a number "X" would stand for "X antennas participating".- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
setEventListener
public void setEventListener(RfidEventListener listener)
set the rfid event listener- Parameters:
listener
-RfidEventListener
-
-