Package jmri.jmrix.rfid
Class RfidProtocol
- java.lang.Object
-
- jmri.jmrix.rfid.RfidProtocol
-
- Direct Known Subclasses:
CoreIdRfidProtocol
,Em18RfidProtocol
,OlimexRfid1356mifareProtocol
,OlimexRfidProtocol
,ParallaxRfidProtocol
,SeeedStudioRfidProtocol
public abstract class RfidProtocol extends java.lang.Object
Basic interface to be implemented for each tag protocol.- Since:
- 3.9.2
-
-
Field Summary
Fields Modifier and Type Field Description protected char
concentratorFirst
protected char
concentratorLast
protected boolean
isConcentrator
protected int
portPosition
-
Constructor Summary
Constructors Constructor Description RfidProtocol()
Constructor for an RFID Protocol.RfidProtocol(char concentratorFirst, char concentratorLast, int portPosition)
Constructor for an RFID Protocol.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static byte[]
convertHexString(java.lang.String s)
Converts a hex string to an unsigned byte array.abstract boolean
endOfMessage(AbstractMRReply msg)
Determines if at the end of this RFID replyabstract java.lang.String
getCheckSum(AbstractMRReply msg)
When available, returns the checksum portion of an RFID replychar
getReaderPort(AbstractMRReply msg)
java.lang.String
getTag(AbstractMRReply msg)
Retrieves RFID Tag information from messageabstract java.lang.String
initString()
Returns the initialisation string to be sent to an adapter implementing the protocol.abstract boolean
isValid(AbstractMRReply msg)
Determines if this RFID reply is validboolean
providesChecksum()
Determines if this protocol provides checksum values Default is false.java.lang.String
toMonitorString(AbstractMRReply msg)
Provides a textual representation of this message for the monitor
-
-
-
Field Detail
-
isConcentrator
protected boolean isConcentrator
-
concentratorFirst
protected char concentratorFirst
-
concentratorLast
protected char concentratorLast
-
portPosition
protected int portPosition
-
-
Constructor Detail
-
RfidProtocol
public RfidProtocol()
Constructor for an RFID Protocol. Used when a single reader is connected directly to a port, not via a concentrator.
-
RfidProtocol
public RfidProtocol(char concentratorFirst, char concentratorLast, int portPosition)
Constructor for an RFID Protocol. Supports the use of concentrators where a character range is used to determine the specific reader port.- Parameters:
concentratorFirst
- character representing first concentrator portconcentratorLast
- character representing last concentrator portportPosition
- position of port character in reply string; 1 for first character
-
-
Method Detail
-
getTag
public java.lang.String getTag(AbstractMRReply msg)
Retrieves RFID Tag information from message- Parameters:
msg
- Message to decode- Returns:
- String representation of tag
-
providesChecksum
public boolean providesChecksum()
Determines if this protocol provides checksum values Default is false. Protocols that do provide them should override this method.- Returns:
- true if provided
-
getCheckSum
public abstract java.lang.String getCheckSum(AbstractMRReply msg)
When available, returns the checksum portion of an RFID reply- Parameters:
msg
- RFID reply to process- Returns:
- checksum value
-
isValid
public abstract boolean isValid(AbstractMRReply msg)
Determines if this RFID reply is valid- Parameters:
msg
- RFID reply to process- Returns:
- true if valid
-
endOfMessage
public abstract boolean endOfMessage(AbstractMRReply msg)
Determines if at the end of this RFID reply- Parameters:
msg
- RFID reply to process- Returns:
- true if at end
-
initString
public abstract java.lang.String initString()
Returns the initialisation string to be sent to an adapter implementing the protocol. For those protocols that do not require one, return a blank string- Returns:
- initialisation string
-
getReaderPort
public char getReaderPort(AbstractMRReply msg)
-
toMonitorString
public java.lang.String toMonitorString(AbstractMRReply msg)
Provides a textual representation of this message for the monitor- Parameters:
msg
- RFID reply to process- Returns:
- textual representation
-
convertHexString
protected static byte[] convertHexString(java.lang.String s)
Converts a hex string to an unsigned byte array. Both upper and lower case hex codes are permitted.- Parameters:
s
- String representation of a hex number. Must be a whole number of bytes (i.e. an even number of characters) and be formed only of digits 0..9, a..f or A..F- Returns:
- corresponding unsigned byte array
- Throws:
java.lang.IllegalArgumentException
- when s is not a valid hex string
-
-