Package com.metratec.lib.rfidreader
Class MetratecReader<T extends RfidTag>
- java.lang.Object
-
- com.metratec.lib.rfidreader.MetratecReader<T>
-
- Type Parameters:
T
- the rfid tag instance
- Direct Known Subclasses:
MetratecReaderGen1
,MetratecReaderGen2
public abstract class MetratecReader<T extends RfidTag> extends java.lang.Object
- Author:
- jannis becke, matthias neumann
-
-
Field Summary
Fields Modifier and Type Field Description static int
STATE_CONFIGURING
the master is being configuredstatic int
STATE_CONNECTING
the master is connectingstatic int
STATE_RUNNING
the master is runningstatic int
STATE_STOPPED
the master is stoppedstatic int
STATE_WAITING_FOR_RECONNECT
the master is waiting during reconnect
-
Constructor Summary
Constructors Constructor Description MetratecReader(java.lang.String identifier, ICommConnection connection)
Construct a new StandardReader instance with the specified connection
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
connect()
Deprecated.usestartAndWait()
insteadvoid
connect(long timeout)
Deprecated.usestartAndWait(long timeout)
insteadvoid
disconnect()
Deprecated.usestop()
method insteadabstract java.lang.String
getFirmwareRevision()
get the Firmware Revisionabstract java.lang.String
getHardwareRevision()
Gets the hardware revisionjava.lang.String
getIdentifier()
abstract boolean
getInput(int pin)
Reads the current state of an input pinint
getInputDebounceTime()
abstract java.util.List<T>
getInventory()
Looks for all tags in range of the reader and get all tags backabstract ReaderType
getReaderType()
Parse the Firmware Name and return theReaderType
int
getReceiveTimeout()
abstract java.lang.String
getSerialNumber()
Gets the serial numberboolean
isConnected()
abstract void
setAntennaPort(int port)
Set the antenna port.void
setIdentifier(java.lang.String identifier)
void
setInputDebounceTime(int inputDebounceTime)
void
setMaxReconnectWaitTime(long timeInMilliseconds)
Set the minimum time before attempting to reconnect.void
setMinReconnectWaitTime(long timeInMilliseconds)
Set the minimum time before attempting to reconnect.abstract void
setMultiplexAntennas(int numberOfAntennas)
In case you want to automatically switch between multiple antennas (e.g.abstract void
setOutput(int pin, boolean state)
Sets the state of an output pinvoid
setReaderEventListener(RfidReaderEventListener listener)
set the rfid event listenervoid
setReceiveTimeout(int receiveTimeout)
void
setTagEventListener(RfidTagEventListener<T> listener)
set the rfid event listenervoid
start()
Start the readervoid
start(int heartBeatInterval)
Start the readervoid
startAndWait()
start the reader but also wait until the reader is connected and initializedvoid
startAndWait(long timeout)
connect the reader and wait until the reader is connectedvoid
startInventory()
Looks for all tags in range of the reader and call events with founded tags.abstract void
startInventory(long tagLostTime)
Looks for all tags in range of the reader and call events with founded tags.void
stop()
stop the readerabstract java.util.List<T>
stopInventory()
Stops the current continues inventory
-
-
-
Field Detail
-
STATE_CONNECTING
public static final int STATE_CONNECTING
the master is connecting- See Also:
- Constant Field Values
-
STATE_RUNNING
public static final int STATE_RUNNING
the master is running- See Also:
- Constant Field Values
-
STATE_STOPPED
public static final int STATE_STOPPED
the master is stopped- See Also:
- Constant Field Values
-
STATE_WAITING_FOR_RECONNECT
public static final int STATE_WAITING_FOR_RECONNECT
the master is waiting during reconnect- See Also:
- Constant Field Values
-
STATE_CONFIGURING
public static final int STATE_CONFIGURING
the master is being configured- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MetratecReader
public MetratecReader(java.lang.String identifier, ICommConnection connection)
Construct a new StandardReader instance with the specified connection- Parameters:
identifier
- reader identifierconnection
- connection
-
-
Method Detail
-
setReaderEventListener
public void setReaderEventListener(RfidReaderEventListener listener)
set the rfid event listener- Parameters:
listener
-RfidReaderEventListener
-
setTagEventListener
public void setTagEventListener(RfidTagEventListener<T> listener)
set the rfid event listener- Parameters:
listener
-RfidReaderEventListener
-
getIdentifier
public java.lang.String getIdentifier()
- Returns:
- the identifier
-
setIdentifier
public void setIdentifier(java.lang.String identifier)
- Parameters:
identifier
- the identifier to set
-
start
public void start()
Start the reader
-
start
public void start(int heartBeatInterval)
Start the reader- Parameters:
heartBeatInterval
- heart beat interval in seconds
-
startAndWait
public void startAndWait() throws CommConnectionException, RFIDReaderException
start the reader but also wait until the reader is connected and initialized- Throws:
CommConnectionException
- if an error occursRFIDReaderException
- if an error occurs
-
startAndWait
public void startAndWait(long timeout) throws CommConnectionException, RFIDReaderException
connect the reader and wait until the reader is connected- Parameters:
timeout
- max time to try connect and configure the reader- Throws:
CommConnectionException
- if an error occursRFIDReaderException
- if an error occurs
-
connect
@Deprecated public void connect() throws CommConnectionException, RFIDReaderException
Deprecated.usestartAndWait()
insteadstart the reader but also wait until the reader is connected and initialized- Throws:
CommConnectionException
- if an error occursRFIDReaderException
- if an error occurs
-
connect
@Deprecated public void connect(long timeout) throws CommConnectionException, RFIDReaderException
Deprecated.usestartAndWait(long timeout)
insteadconnect the reader and wait until the reader is connected- Parameters:
timeout
- max time to try connect and configure the reader- Throws:
CommConnectionException
- if an error occursRFIDReaderException
- if an error occurs
-
stop
public void stop() throws CommConnectionException
stop the reader- Throws:
CommConnectionException
- possible ICommConnection Error codes:- UNHANDLED_ERROR
-
disconnect
@Deprecated public void disconnect() throws CommConnectionException
Deprecated.usestop()
method insteadclose the connection- Throws:
CommConnectionException
- possible ICommConnection Error codes:- UNHANDLED_ERROR
-
isConnected
public boolean isConnected()
- Returns:
- the connection state
-
setMaxReconnectWaitTime
public void setMaxReconnectWaitTime(long timeInMilliseconds)
Set the minimum time before attempting to reconnect. Default value 21600000ms (6h).- Parameters:
timeInMilliseconds
- maximum reconnect wait time in milliseconds
-
setMinReconnectWaitTime
public void setMinReconnectWaitTime(long timeInMilliseconds)
Set the minimum time before attempting to reconnect. Default value 2000ms.- Parameters:
timeInMilliseconds
- minimum reconnect wait time in milliseconds
-
getReceiveTimeout
public int getReceiveTimeout()
- Returns:
- the receiveTimeout
-
setReceiveTimeout
public void setReceiveTimeout(int receiveTimeout)
- Parameters:
receiveTimeout
- the receiveTimeout to set
-
getInputDebounceTime
public int getInputDebounceTime()
- Returns:
- the inputDebounceTime
-
setInputDebounceTime
public void setInputDebounceTime(int inputDebounceTime)
- Parameters:
inputDebounceTime
- the inputDebounceTime to set (minimum 50ms)
-
getInput
public abstract 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 abstract 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, ..)
-
getReaderType
public abstract 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 abstract java.lang.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 abstract java.lang.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 abstract java.lang.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, ..)
-
setAntennaPort
public abstract 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, ..)
-
setMultiplexAntennas
public abstract void setMultiplexAntennas(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..16], 0 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, ..)
-
getInventory
public abstract java.util.List<T> getInventory() throws RFIDReaderException, CommConnectionException
Looks for all tags in range of the reader and get all tags 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, ..)
-
startInventory
public void startInventory() throws CommConnectionException, RFIDReaderException
Looks for all tags in range of the reader and call events with founded tags.- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
startInventory
public abstract void startInventory(long tagLostTime) throws CommConnectionException, RFIDReaderException
Looks for all tags in range of the reader and call events with founded tags.- Parameters:
tagLostTime
- timeout in milliseconds for tag lost event- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
stopInventory
public abstract java.util.List<T> stopInventory() throws CommConnectionException, RFIDReaderException
Stops the current continues inventory- Returns:
- the current inventory
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs
-
-