com.sentilla.platform.cmote
Class Receiver

java.lang.Object
  extended by com.sentilla.platform.cmote.DispatcherAction
      extended by com.sentilla.platform.cmote.Receiver
All Implemented Interfaces:
Receiver, Action
Direct Known Subclasses:
ClientRadioProtocol.Receiver, MimeoDisseminationProtocol.MimeoReceiver

public class Receiver
extends DispatcherAction
implements Receiver

Provides methods to receive messages from the mote communications interfaces.

Primary class for receiving messages and objects. Blocking and non-blocking methods for receiving a message provided. Message metadata can be obtained by calling the getNextReceiver method and accessing the Receiver metadata field directly.

See Also:
DispatcherAction, Dispatcher, ReceiverDriver, Protocol

Field Summary
 Object data
           
 Addressable destAddress
           
protected  Class msgClass
           
protected  Receiver nextData
          Dispatcher.dispatch automatically nulls out this field when this object is done receiving.
protected  Receiver nextReceiver
           
 Addressable sourceAddress
           
 
Fields inherited from class com.sentilla.platform.cmote.DispatcherAction
actionState
 
Fields inherited from interface com.sentilla.system.Action
DONE, ERROR, IDLE, PENDING
 
Constructor Summary
  Receiver()
          Provides default constructor for protocols.
protected Receiver(Class msgClass)
          Provides protected constructor instantiating a Receiver.
 
Method Summary
 void addMetadata(Receiver rcvr)
          Adds a Receiver to the list of DispatchReceiver objects.
<M> M
getData()
          Returns the received object.
 Addressable getDestAddress()
          Returns the destination address of the last received message.
<R extends Receiver>
R
getMetadata(Class<R> c)
          Returns the platform specific receiver object that contains metadata about the received message.
 Addressable getSourceAddress()
          Returns the source address of the last received message.
<M> M
receive()
          Receives an object.
 Receiver setReceive()
          Sets the Receiver object to receive.
 void signalReceive(Receiver rcvr)
          Signals that an Object has been received by this receiver.
protected  boolean subcancel()
          Cancels the receive request and removes receiver object from Dispatcher receiver queue.
protected  boolean subsubmit()
          Queues a Receiver object receive request.
 
Methods inherited from class com.sentilla.platform.cmote.DispatcherAction
block, block, cancel, getActionState, isDone, submit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sentilla.system.Action
block, block, cancel, getActionState, isDone, submit
 

Field Detail

nextReceiver

protected Receiver nextReceiver

nextData

protected Receiver nextData
Dispatcher.dispatch automatically nulls out this field when this object is done receiving.


msgClass

protected Class msgClass

sourceAddress

public Addressable sourceAddress

destAddress

public Addressable destAddress

data

public Object data
Constructor Detail

Receiver

public Receiver()
Provides default constructor for protocols. This constructor should not be explicitly called. It is called implicitly by the derived classes that extend DispathReceiver.


Receiver

protected Receiver(Class msgClass)
Provides protected constructor instantiating a Receiver.

Parameters:
msgClass - Class of expected message
Method Detail

receive

public <M> M receive()
Receives an object. Blocks until an object is received. Object class is specified when creating the receiver object.

Specified by:
receive in interface Receiver
Returns:
received object.

setReceive

public Receiver setReceive()
Sets the Receiver object to receive. Non-blocking action to receive an object. Object class is specified when creating the receiver object. Provided for consistency with Action interface.

Specified by:
setReceive in interface Receiver
Returns:
Receiver object
See Also:
DispatcherAction, Action

getData

public <M> M getData()
Returns the received object.

Specified by:
getData in interface Receiver
Returns:
received object.

getDestAddress

public Addressable getDestAddress()
Returns the destination address of the last received message.

Specified by:
getDestAddress in interface Receiver
Returns:
an Addressable object containing the destination address
See Also:
Addressable

getSourceAddress

public Addressable getSourceAddress()
Returns the source address of the last received message.

Specified by:
getSourceAddress in interface Receiver
Returns:
an Addressable object containing the source address
See Also:
Addressable

getMetadata

public <R extends Receiver> R getMetadata(Class<R> c)
Returns the platform specific receiver object that contains metadata about the received message. The metadata receiver object is used to obtain message metadata.

Specified by:
getMetadata in interface Receiver
Returns:
a receiver object containing platform metadata

addMetadata

public void addMetadata(Receiver rcvr)
Adds a Receiver to the list of DispatchReceiver objects. This method should never be called by a user application; should be called by protocols.

Parameters:
rcvr - Receiver object to be added

signalReceive

public void signalReceive(Receiver rcvr)
Signals that an Object has been received by this receiver.

Parameters:
rcvr - Receiver object that was received

subcancel

protected boolean subcancel()
Cancels the receive request and removes receiver object from Dispatcher receiver queue.

Overrides:
subcancel in class DispatcherAction
Returns:
true if subcancel succeeded

subsubmit

protected boolean subsubmit()
Queues a Receiver object receive request. Returns true if the receive request was queued by the Dispatcher. Should only be called by the Receiver base class.

Specified by:
subsubmit in class DispatcherAction
Returns:
true if the comand executed successfully.


Copyright © 2007 Sentilla Corporation. All Rights Reserved.