com.sentilla.platform.cmote
Class ByteReceiver

java.lang.Object
  extended by com.sentilla.platform.cmote.ByteReceiver
All Implemented Interfaces:
ByteMessage, ByteReceiver, Action

public class ByteReceiver
extends Object
implements Action, ByteReceiver


Field Summary
 
Fields inherited from interface com.sentilla.net.ByteReceiver
ANY_ADDR, ANY_PORT
 
Constructor Summary
ByteReceiver(int port)
           
 
Method Summary
 Action block()
          Block an indefinite amount of time until this Action is no longer pending.
 Action block(int timeoutMilli)
          Block a defined amount of time or until the Action is no longer pending.
 Action cancel()
          Cancel this Action if PENDING.
 byte getActionState()
          Get the current state of this Action: IDLE, PENDING, DONE, or ERROR.
 int getLength()
          Returns the number of bytes in the original message.
 int getLqi()
          Returns the Link Quality Indicator (LQI) of the received message.
 int getPort()
          Returns the currently set port.
 int getRssi()
          Returns the Received Signal Strength Indicator (RSSI) of the received message.
 long getTimestamp()
          Returns the message timestamp.
 boolean isDone()
          Return true is this Action is DONE.
 void receive(byte[] buf, int offset)
          Receive data into a byte array, starting at offset.
 void receive(ByteBuffer buf)
          Receive data into a ByteBuffer.
 ByteMessage setPort(int port)
          Sets the port for message transmissions.
 ByteReceiver setReceive(byte[] buf, int offset)
          Set the byte array to receive data into, but do not submit to the kernel.
 ByteReceiver setReceive(ByteBuffer buf)
          Set the ByteBuffer to receive data into, but do not submit to the kernel.
 Action submit()
          Submit this Action for processing by the action engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteReceiver

public ByteReceiver(int port)
Method Detail

getLength

public int getLength()
Description copied from interface: ByteReceiver
Returns the number of bytes in the original message.

Specified by:
getLength in interface ByteReceiver
Returns:
integer number of bytes in the message

getLqi

public int getLqi()
Description copied from interface: ByteReceiver
Returns the Link Quality Indicator (LQI) of the received message.

Specified by:
getLqi in interface ByteReceiver
Returns:
the LQI of the received message

getRssi

public int getRssi()
Description copied from interface: ByteReceiver
Returns the Received Signal Strength Indicator (RSSI) of the received message.

Specified by:
getRssi in interface ByteReceiver
Returns:
the RSSI of the received message.

receive

public void receive(ByteBuffer buf)
Description copied from interface: ByteReceiver
Receive data into a ByteBuffer.

Specified by:
receive in interface ByteReceiver
Parameters:
buf - ByteBuffer to receive data into

receive

public void receive(byte[] buf,
                    int offset)
Description copied from interface: ByteReceiver
Receive data into a byte array, starting at offset.

Specified by:
receive in interface ByteReceiver
Parameters:
buf - byte array to receive data into
offset - offset in the byte array to begin placing received data

setReceive

public ByteReceiver setReceive(ByteBuffer buf)
Description copied from interface: ByteReceiver
Set the ByteBuffer to receive data into, but do not submit to the kernel.

Specified by:
setReceive in interface ByteReceiver
Parameters:
buf - ByteBuffer to receive data into
Returns:
this

setReceive

public ByteReceiver setReceive(byte[] buf,
                               int offset)
Description copied from interface: ByteReceiver
Set the byte array to receive data into, but do not submit to the kernel.

Specified by:
setReceive in interface ByteReceiver
Parameters:
buf - the byte array to receive data into
offset - the offset in the array to begin writing the data
Returns:
this

getPort

public int getPort()
Description copied from interface: ByteMessage
Returns the currently set port.

Specified by:
getPort in interface ByteMessage
Returns:
the integer port number

getTimestamp

public long getTimestamp()
Description copied from interface: ByteMessage
Returns the message timestamp.

Specified by:
getTimestamp in interface ByteMessage
Returns:
the long value timestamp

setPort

public ByteMessage setPort(int port)
Description copied from interface: ByteMessage
Sets the port for message transmissions.

Specified by:
setPort in interface ByteMessage
Parameters:
port - the port bytes should be sent to
Returns:
returns this

block

public Action block()
             throws ActionException
Description copied from interface: Action
Block an indefinite amount of time until this Action is no longer pending. Return immediately if the Action is IDLE or DONE. Return when the Action leaves the PENDING state, either through completion or cancellation. Throw ActionException if the Action is in ERROR.

Specified by:
block in interface Action
Returns:
A pointer to this Action.
Throws:
ActionException

block

public Action block(int timeoutMilli)
             throws ActionException
Description copied from interface: Action
Block a defined amount of time or until the Action is no longer pending. Return immediately if the Action is IDLE or DONE. Return when the Action leaves the PENDING state, either through completion or cancellation, or until the timeout occurs, whichever comes first. Throw ActionException is the Action is in ERROR.

Specified by:
block in interface Action
Parameters:
timeoutMilli - the maximum number of milliseconds to block
Returns:
A pointer to this Action.
Throws:
ActionException

cancel

public Action cancel()
Description copied from interface: Action
Cancel this Action if PENDING. If cancel successfully completes, it transitions this Action to IDLE from any state. If this Action is PENDING, a best effort is made to remove it from the underlying Action engine, and failing that, exception XXX-TODO is thrown.

Specified by:
cancel in interface Action
Returns:
A pointer to this Action.

getActionState

public byte getActionState()
Description copied from interface: Action
Get the current state of this Action: IDLE, PENDING, DONE, or ERROR.

Specified by:
getActionState in interface Action

isDone

public boolean isDone()
               throws ActionException
Description copied from interface: Action
Return true is this Action is DONE. isDone can be used with block(timeoutMilli) to determine if the Action has completed. Calling isDone is equivalent to getActionState() == Action.DONE. Throw ActionException is getActionState() == Action.ERROR.

Specified by:
isDone in interface Action
Throws:
ActionException

submit

public Action submit()
Description copied from interface: Action
Submit this Action for processing by the action engine. Calling submit transitions this Action to PENDING from either IDLE, DONE, or ERROR. Nothing happens if this Action is already PENDING.

Specified by:
submit in interface Action
Returns:
A pointer to this Action.


Copyright © 2007 Sentilla Corporation. All Rights Reserved.