com.ionetrics.lib.annotatorcomm
Class ResponseMessage

java.lang.Object
  extended by com.ionetrics.lib.annotatorcomm.ResponseMessage

public class ResponseMessage
extends java.lang.Object

ResponseMessage encapsulates the bytes of a response message and provides helpful methods for reading its values.


Field Summary
static int CHECKSUM_RIDX
          Checksum reverse index
static int CMD_ID_IDX
          Command ID index
static int FOOTER_LEN
          Length of the footer in bytes
static int HEADER_LEN
          Length of the header in bytes
static int MSG_LEN_IDX
          Message length index
static byte RESP_FAILED
          Response Code: Failed to execute (but the Command ID was valid), see Status Code for details
static byte RESP_SUCCESS
          Response Code: Success
static byte RESP_UNSUPPORTED
          Response Code: Unsupported Command ID
static int RESPONSE_IDX
          Response code index
static int STATUS_IDX
          Status code index
static byte STATUS_INVALID_IN_CURRENT_CONFIG
          Status Code: Invalid command in the current configuration
static byte STATUS_UNSPECIFIED
          Status Code: Unspecified failure
static byte STATUS_UNSUPPORTED
          Status Code: Unsupported command or subcommand
 
Constructor Summary
ResponseMessage(byte[] rsp)
          Construct a ResponseMessage.
 
Method Summary
 void errorCheck()
          Error check the response.
 byte[] getBytes()
          Get the response message's bytes.
 byte getChecksum()
          Get the response checksum.
 short getId()
          Get the Command ID.
 int getNextParamAsInt16()
          Get the next parameter as a 16-bit integer.
 int getNextParamAsInt32()
          Get the next parameter as a 32-bit integer.
 long getNextParamAsInt64()
          Get the next parameter as a 64-bit integer.
 byte getNextParamAsInt8()
          Get the next parameter as an 8-bit integer.
 int getNextParamAsUInt16()
          Get the next parameter as an unsigned 16-bit integer.
 long getNextParamAsUInt32()
          Get the next parameter as an unsigned 32-bit integer.
 int getNextParamAsUInt8()
          Get the next parameter as an unsigned 8-bit integer.
 byte[] getParamBytes()
          Get the response message's parameter bytes.
 byte getResponse()
          Get the response code.
 int getRespParamLen()
          Get the length of the response parameter bytes
 byte getStatus()
          Get the response status code.
 java.lang.String getStatusMessage()
          Get the status as a human readble String.
 void resetParamPointer()
          Restart the parameter index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER_LEN

public static final int HEADER_LEN
Length of the header in bytes

See Also:
Constant Field Values

FOOTER_LEN

public static final int FOOTER_LEN
Length of the footer in bytes

See Also:
Constant Field Values

MSG_LEN_IDX

public static final int MSG_LEN_IDX
Message length index

See Also:
Constant Field Values

CMD_ID_IDX

public static final int CMD_ID_IDX
Command ID index

See Also:
Constant Field Values

RESPONSE_IDX

public static final int RESPONSE_IDX
Response code index

See Also:
Constant Field Values

STATUS_IDX

public static final int STATUS_IDX
Status code index

See Also:
Constant Field Values

CHECKSUM_RIDX

public static final int CHECKSUM_RIDX
Checksum reverse index

See Also:
Constant Field Values

RESP_SUCCESS

public static final byte RESP_SUCCESS
Response Code: Success

See Also:
Constant Field Values

RESP_FAILED

public static final byte RESP_FAILED
Response Code: Failed to execute (but the Command ID was valid), see Status Code for details

See Also:
Constant Field Values

RESP_UNSUPPORTED

public static final byte RESP_UNSUPPORTED
Response Code: Unsupported Command ID

See Also:
Constant Field Values

STATUS_UNSPECIFIED

public static final byte STATUS_UNSPECIFIED
Status Code: Unspecified failure

See Also:
Constant Field Values

STATUS_UNSUPPORTED

public static final byte STATUS_UNSUPPORTED
Status Code: Unsupported command or subcommand

See Also:
Constant Field Values

STATUS_INVALID_IN_CURRENT_CONFIG

public static final byte STATUS_INVALID_IN_CURRENT_CONFIG
Status Code: Invalid command in the current configuration

See Also:
Constant Field Values
Constructor Detail

ResponseMessage

public ResponseMessage(byte[] rsp)
Construct a ResponseMessage.

Parameters:
rsp - response message bytes
Method Detail

getId

public short getId()
Get the Command ID.

Returns:
Command ID

getResponse

public byte getResponse()
Get the response code.

Returns:
response code

getStatus

public byte getStatus()
Get the response status code.

Returns:
status code

getStatusMessage

public java.lang.String getStatusMessage()
                                  throws CommandDependentStatusException
Get the status as a human readble String.

Returns:
status String
Throws:
CommandDependentStatusException - thrown on command dependent status

resetParamPointer

public void resetParamPointer()
Restart the parameter index.

See Also:
getNextParamAsInt8(), getNextParamAsUInt8(), getNextParamAsInt16(), getNextParamAsUInt16(), getNextParamAsInt32(), getNextParamAsUInt32()

getNextParamAsInt8

public byte getNextParamAsInt8()
                        throws java.io.IOException
Get the next parameter as an 8-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getNextParamAsUInt8

public int getNextParamAsUInt8()
                        throws java.io.IOException
Get the next parameter as an unsigned 8-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getNextParamAsInt16

public int getNextParamAsInt16()
                        throws java.io.IOException
Get the next parameter as a 16-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getNextParamAsUInt16

public int getNextParamAsUInt16()
                         throws java.io.IOException
Get the next parameter as an unsigned 16-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getNextParamAsInt32

public int getNextParamAsInt32()
                        throws java.io.IOException
Get the next parameter as a 32-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getNextParamAsUInt32

public long getNextParamAsUInt32()
                          throws java.io.IOException
Get the next parameter as an unsigned 32-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getNextParamAsInt64

public long getNextParamAsInt64()
                         throws java.io.IOException
Get the next parameter as a 64-bit integer.

Returns:
parameter value
Throws:
java.io.IOException

getChecksum

public byte getChecksum()
Get the response checksum.

Returns:
checksum

getRespParamLen

public int getRespParamLen()
Get the length of the response parameter bytes

Returns:
response parameter bytes length

getParamBytes

public byte[] getParamBytes()
                     throws java.io.IOException
Get the response message's parameter bytes.

Returns:
parameter bytes
Throws:
java.io.IOException

getBytes

public byte[] getBytes()
Get the response message's bytes.

Returns:
response bytes

errorCheck

public void errorCheck()
                throws CommandDependentStatusException,
                       CommandFailedException,
                       CommandUnsupportedException,
                       java.io.IOException
Error check the response. If a problem is encountered, an exception is thrown. All problems can generically be caught with an IOException, or finer granularity can be choosen from the throws list below.

Throws:
CommandChecksumFailedException - thrown if the checksum failed
CommandDependentStatusException - thrown on command dependent status code
CommandFailedException - thrown on command failure
CommandUnsupportedException - thrown on unsupported command
java.io.IOException - thrown for all other I/O failures


Copyright © 2006 Ionetrics Corp. All Rights Reserved.