org.llrp.ltk.types
Class LLRPMessage

java.lang.Object
  extended by org.llrp.ltk.types.LLRPMessage
Direct Known Subclasses:
ADD_ACCESSSPEC, ADD_ACCESSSPEC_RESPONSE, ADD_ROSPEC, ADD_ROSPEC_RESPONSE, CLOSE_CONNECTION, CLOSE_CONNECTION_RESPONSE, CUSTOM_MESSAGE, DELETE_ACCESSSPEC, DELETE_ACCESSSPEC_RESPONSE, DELETE_ROSPEC, DELETE_ROSPEC_RESPONSE, DISABLE_ACCESSSPEC, DISABLE_ACCESSSPEC_RESPONSE, DISABLE_ROSPEC, DISABLE_ROSPEC_RESPONSE, ENABLE_ACCESSSPEC, ENABLE_ACCESSSPEC_RESPONSE, ENABLE_EVENTS_AND_REPORTS, ENABLE_ROSPEC, ENABLE_ROSPEC_RESPONSE, ERROR_MESSAGE, GET_ACCESSSPECS, GET_ACCESSSPECS_RESPONSE, GET_READER_CAPABILITIES, GET_READER_CAPABILITIES_RESPONSE, GET_READER_CONFIG, GET_READER_CONFIG_RESPONSE, GET_REPORT, GET_ROSPECS, GET_ROSPECS_RESPONSE, KEEPALIVE, KEEPALIVE_ACK, READER_EVENT_NOTIFICATION, RO_ACCESS_REPORT, SET_READER_CONFIG, SET_READER_CONFIG_RESPONSE, START_ROSPEC, START_ROSPEC_RESPONSE, STOP_ROSPEC, STOP_ROSPEC_RESPONSE

public abstract class LLRPMessage
extends java.lang.Object

LLRPMessage represents an LLRP message in LTKJava.

The binary encoding Is always: Reserved(3 Bits) | Version (3 Bits) | Message Type (10 Bits) | Message Length (32 Bits) | Parameters call empty constructor to create new message. Use constructor taking LLRPBitList or Byte[] to create message from binary encoded message. Use constructor with JDOM document as a parameter to create message from XML encoding


Field Summary
protected  UnsignedInteger messageID
           
protected  UnsignedInteger messageLength
           
 int messageReservedLength
           
static int MINHEADERLENGTH
           
protected  BitList reserved
           
static int RESERVEDLENGTH
           
static int TYPENUMBERLENGTH
           
protected  BitList version
           
static int VERSIONLENGTH
           
 
Constructor Summary
LLRPMessage()
           
 
Method Summary
 void decodeBinary(byte[] byteArray)
          create message from byte[].
protected abstract  void decodeBinarySpecific(LLRPBitList bits)
          to be implemented by specific message.
abstract  void decodeXML(org.jdom.Document xml)
          create objects from xml.
 byte[] encodeBinary()
          encode this message to binary formate.
protected abstract  LLRPBitList encodeBinarySpecific()
          encoding function - has to be implemented by each message.
abstract  org.jdom.Document encodeXML()
          create xml representation of this parameter.
 UnsignedInteger getMessageID()
          Message ID to distinguish messages of same type.
 UnsignedInteger getMessageLength()
          number of bytes of encoded message.
abstract  java.lang.String getName()
          name of message (same as class name)
abstract  java.lang.String getResponseType()
          response message type awaited
abstract  SignedShort getTypeNum()
          type number uniquely identifies message.
 BitList getVersion()
          version of llrp.
 boolean isValidXMLMessage(org.jdom.Document jdomDoc, java.lang.String schemaPath)
          Check xml file against xml schema.
 void setMessageID(UnsignedInteger messageID)
          setMessageID.
 void setVersion(BitList version)
          create BitList easiest is to use variadic argument.
 java.lang.String toBinaryString()
          Return LLRP message as binary string in LLRP binary encoding.
 java.lang.String toHexString()
          Return LLRP message as hex string in LLRP binary encoding.
 java.lang.String toXMLString()
          Return LLRP message as string in LTK XML format If there is an error during message encoding, the error message is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESERVEDLENGTH

public static final int RESERVEDLENGTH
See Also:
Constant Field Values

VERSIONLENGTH

public static final int VERSIONLENGTH
See Also:
Constant Field Values

TYPENUMBERLENGTH

public static final int TYPENUMBERLENGTH
See Also:
Constant Field Values

MINHEADERLENGTH

public static final int MINHEADERLENGTH
See Also:
Constant Field Values

messageReservedLength

public final int messageReservedLength
See Also:
Constant Field Values

reserved

protected BitList reserved

version

protected BitList version

messageID

protected UnsignedInteger messageID

messageLength

protected UnsignedInteger messageLength
Constructor Detail

LLRPMessage

public LLRPMessage()
Method Detail

encodeBinary

public final byte[] encodeBinary()
                          throws InvalidLLRPMessageException
encode this message to binary formate.

Returns:
Byte[] which can directly be sent over a stream
Throws:
InvalidLLRPMessageException

encodeBinarySpecific

protected abstract LLRPBitList encodeBinarySpecific()
                                             throws InvalidLLRPMessageException
encoding function - has to be implemented by each message.

Returns:
LLRPBitList
Throws:
InvalidLLRPMessageException

decodeBinary

public final void decodeBinary(byte[] byteArray)
                        throws InvalidLLRPMessageException
create message from byte[]. Will also be called from Constructor taking a byte[] Argument

Parameters:
byteArray - representing message
Throws:
InvalidLLRPMessageException - if bitstring is not well formatted or has any other error

getMessageID

public UnsignedInteger getMessageID()
Message ID to distinguish messages of same type.

Returns:
UnsignedInteger

getMessageLength

public UnsignedInteger getMessageLength()
number of bytes of encoded message.

Returns:
UnsignedInteger

getTypeNum

public abstract SignedShort getTypeNum()
type number uniquely identifies message.

Returns:
SignedShort

getResponseType

public abstract java.lang.String getResponseType()
response message type awaited

Returns:
String

getName

public abstract java.lang.String getName()
name of message (same as class name)

Returns:
String

getVersion

public BitList getVersion()
version of llrp.

Returns:
BitList

setMessageID

public void setMessageID(UnsignedInteger messageID)
setMessageID.

Parameters:
messageID - of type UnsignedInteger

setVersion

public void setVersion(BitList version)
create BitList easiest is to use variadic argument. for example BitList(0,1,1) for value 3.

Parameters:
version - as bit array

decodeBinarySpecific

protected abstract void decodeBinarySpecific(LLRPBitList bits)
                                      throws InvalidLLRPMessageException
to be implemented by specific message.

Parameters:
bits - without header
Throws:
InvalidLLRPMessageException

encodeXML

public abstract org.jdom.Document encodeXML()
                                     throws InvalidLLRPMessageException
create xml representation of this parameter.

Returns:
Dom Document
Throws:
InvalidLLRPMessageException

decodeXML

public abstract void decodeXML(org.jdom.Document xml)
                        throws InvalidLLRPMessageException
create objects from xml.

Parameters:
xml - document as jdom document
Throws:
InvalidLLRPMessageException

isValidXMLMessage

public boolean isValidXMLMessage(org.jdom.Document jdomDoc,
                                 java.lang.String schemaPath)
                          throws InvalidLLRPMessageException
Check xml file against xml schema.

Parameters:
jdomDoc - to be checked
schemaPath - path to xml schema file
Returns:
boolean true if valid
Throws:
InvalidLLRPMessageException

toXMLString

public java.lang.String toXMLString()
                             throws InvalidLLRPMessageException
Return LLRP message as string in LTK XML format If there is an error during message encoding, the error message is returned.

Returns:
LRRP message in LTK XML encoding
Throws:
InvalidLLRPMessageException

toBinaryString

public java.lang.String toBinaryString()
                                throws InvalidLLRPMessageException
Return LLRP message as binary string in LLRP binary encoding. If there is an error during message encoding, the error message is returned.

Returns:
LRRP message in LLRP binary encoding
Throws:
InvalidLLRPMessageException

toHexString

public java.lang.String toHexString()
                             throws InvalidLLRPMessageException
Return LLRP message as hex string in LLRP binary encoding. If there is an error during message encoding, the error message is returned.

Returns:
LRRP message in LLRP binary encoding
Throws:
InvalidLLRPMessageException


Copyright © 2007 ETH Zurich.