cluster::DeviceAck Class Reference

Device acknowledgement packet. More...

#include <cluster/Packets/DeviceAck.h>

Inheritance diagram for cluster::DeviceAck:

Inheritance graph
[legend]
Collaboration diagram for cluster::DeviceAck:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DeviceAck ()
 DeviceAck (const vpr::GUID &plugin_id, const vpr::GUID &id, const std::string &device_name, const std::string &device_base_type, bool ack)
 Create a DeviceAck packet to acknowledge a ApplicationDataRequest.
void serialize ()
 Serializes member variables into a data stream.
virtual void parse (vpr::BufferObjectReader *reader)
 Parses the data stream into the local member variables.
virtual void printData (int debug_level)
 Print the data to the screen in a readable form.
vpr::GUID getId ()
 Return the GUID of the Device that we are acknowledging.
std::string getDeviceName ()
 Return the name of the device that we are acknowledging.
std::string getDeviceBaseType ()
 Return the basetype of the device that we are acknowledging.
std::string getHostname ()
 Return the hostname of the node that is acknowledging the DeviceRequest.
bool getAck ()
 Return a boolean determining if this is a positive(ACK) or a negative(NACK) responce.

Static Public Member Functions

static vpr::Uint16 getPacketFactoryType ()
 Return the type of this packet.

Detailed Description

Device acknowledgement packet.

Definition at line 53 of file DeviceAck.h.


Constructor & Destructor Documentation

cluster::DeviceAck::DeviceAck (  )  [inline]

Definition at line 56 of file DeviceAck.h.

00057    {;}

cluster::DeviceAck::DeviceAck ( const vpr::GUID &  plugin_id,
const vpr::GUID &  id,
const std::string &  device_name,
const std::string &  device_base_type,
bool  ack 
)

Create a DeviceAck packet to acknowledge a ApplicationDataRequest.

Parameters:
plugin_id GUID of the ClusterPlugin that should handle this packet.
id GUID of the Device that we are acknowledging.
device_name Name of the device that we are acknowledging.
device_base_type Basetype of the device that we are acknowledging.
ack Boolean determining if this is a positive (ACK) or a negative (NACK) responce.

Definition at line 42 of file DeviceAck.cpp.

References cluster::Packet::mHeader, cluster::Packet::mPluginId, cluster::Header::RIM_DEVICE_ACK, cluster::Header::RIM_PACKET, cluster::Header::RIM_PACKET_HEAD_SIZE, and serialize().

00045    {
00046       // Set the local member variables using the given values.
00047       mPluginId = plugin_id;
00048       mId = id;
00049       mDeviceName = device_name;
00050       mDeviceBaseType = device_base_type;
00051       mAck = ack;
00052       
00053       // Get the localhost name.
00054       vpr::InetAddr local;
00055       vpr::InetAddr::getLocalHost(local);
00056 
00057       local.getHostname(mHostname);
00058 
00059       // Create a Header for this packet with the correect type and size.
00060       mHeader = new Header(Header::RIM_PACKET,
00061                                       Header::RIM_DEVICE_ACK,
00062                                       Header::RIM_PACKET_HEAD_SIZE 
00063                                       + 16 /*mPluginId*/
00064                                       + 16 /*mId*/
00065                                       + vpr::BufferObjectReader::STRING_LENGTH_SIZE
00066                                       + mDeviceName.size() /*length of mDeviceName*/
00067                                       + vpr::BufferObjectReader::STRING_LENGTH_SIZE
00068                                       + mDeviceBaseType.size() /*length of mDeviceBaseType*/
00069                                       + vpr::BufferObjectReader::STRING_LENGTH_SIZE
00070                                       + mHostname.size() /*length of mDeviceBaseType*/
00071                                       + 1 /*mAck*/,
00072                                       0/*Field not curently used*/);                      
00073       // Serialize the given data.
00074       serialize();
00075    }


Member Function Documentation

void cluster::DeviceAck::serialize (  ) 

Serializes member variables into a data stream.

Definition at line 77 of file DeviceAck.cpp.

References cluster::Packet::mHeader, cluster::Packet::mPacketWriter, cluster::Packet::mPluginId, and cluster::Header::serializeHeader().

Referenced by DeviceAck().

00078    {
00079       // Clear the data stream.
00080       mPacketWriter->getData()->clear();
00081       mPacketWriter->setCurPos(0);
00082 
00083       // Serialize the header.
00084       mHeader->serializeHeader();
00085       
00086       // Serialize plugin GUID
00087       mPluginId.writeObject(mPacketWriter);
00088       
00089       // Serialize Device GUID
00090       mId.writeObject(mPacketWriter);
00091       
00092       // Serialize the Device Name
00093       mPacketWriter->writeString(mDeviceName);
00094       
00095       // Serialize the Base Type of the acknowledged device
00096       mPacketWriter->writeString(mDeviceBaseType);
00097 
00098       // Serialize the hostname of the acknowledging node
00099       mPacketWriter->writeString(mHostname);
00100 
00101       // Serialize the Ack boolean
00102       mPacketWriter->writeBool(mAck);
00103    }

void cluster::DeviceAck::parse ( vpr::BufferObjectReader *  reader  )  [virtual]

Parses the data stream into the local member variables.

Implements cluster::Packet.

Definition at line 105 of file DeviceAck.cpp.

References cluster::Packet::mPluginId.

00106    {
00107       // De-Serialize plugin GUID
00108       mPluginId.readObject(reader);
00109 
00110       // De-Serialize Device GUID
00111       mId.readObject(reader);
00112          
00113       // De-Serialize the Device Name
00114       mDeviceName = reader->readString();
00115 
00116       // De-Serialize the Base Type of the acknowledged device
00117       mDeviceBaseType = reader->readString();
00118 
00119       // De-Serialize the hostname of the acknowledging node
00120       mHostname = reader->readString();
00121 
00122       // De-Serialize the Ack boolean
00123       mAck = reader->readBool();
00124    }

void cluster::DeviceAck::printData ( int  debug_level  )  [virtual]

Print the data to the screen in a readable form.

Implements cluster::Packet.

Definition at line 126 of file DeviceAck.cpp.

References gadgetDBG_RIM(), cluster::Packet::mPluginId, and cluster::Packet::printData().

00127    {
00128       vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level) 
00129          <<  clrOutBOLD(clrYELLOW,"==== Device Ack Packet Data ====\n") << vprDEBUG_FLUSH;
00130       
00131       Packet::printData(debug_level);
00132 
00133       vprDEBUG(gadgetDBG_RIM,debug_level) 
00134          << clrOutBOLD(clrYELLOW, "Plugin GUID:      ") << mPluginId.toString()
00135          << std::endl << vprDEBUG_FLUSH;
00136       vprDEBUG(gadgetDBG_RIM,debug_level) 
00137          << clrOutBOLD(clrYELLOW, "Device ID:        ") << mId.toString()
00138          << std::endl << vprDEBUG_FLUSH;
00139       vprDEBUG(gadgetDBG_RIM,debug_level) 
00140          << clrOutBOLD(clrYELLOW, "Device Name:      ") << mDeviceName
00141          << std::endl << vprDEBUG_FLUSH;
00142       vprDEBUG(gadgetDBG_RIM,debug_level) 
00143          << clrOutBOLD(clrYELLOW, "Device Base Type: ") << mDeviceBaseType 
00144          << std::endl << vprDEBUG_FLUSH;
00145       vprDEBUG(gadgetDBG_RIM,debug_level) 
00146          << clrOutBOLD(clrYELLOW, "Remote Hostname:  ") << mHostname
00147          << std::endl << vprDEBUG_FLUSH;
00148       vprDEBUG(gadgetDBG_RIM,debug_level) 
00149          << clrOutBOLD(clrYELLOW, "Ack or Nack:      ") << (mAck ? "Ack" : "Nack")  << std::endl
00150          << std::endl << vprDEBUG_FLUSH;
00151 
00152       vprDEBUG_END(gadgetDBG_RIM,debug_level) 
00153          <<  clrOutBOLD(clrYELLOW,"================================\n") << vprDEBUG_FLUSH;
00154    }

static vpr::Uint16 cluster::DeviceAck::getPacketFactoryType (  )  [inline, static]

Return the type of this packet.

Definition at line 92 of file DeviceAck.h.

References cluster::Header::RIM_DEVICE_ACK.

00093    {
00094       return(Header::RIM_DEVICE_ACK);
00095    }

vpr::GUID cluster::DeviceAck::getId (  )  [inline]

Return the GUID of the Device that we are acknowledging.

Definition at line 100 of file DeviceAck.h.

Referenced by gadget::RemoteInputManager::handlePacket().

00101    {
00102       return mId;
00103    }

std::string cluster::DeviceAck::getDeviceName (  )  [inline]

Return the name of the device that we are acknowledging.

Definition at line 108 of file DeviceAck.h.

Referenced by gadget::RemoteInputManager::handlePacket().

00109    {
00110       return mDeviceName;
00111    }

std::string cluster::DeviceAck::getDeviceBaseType (  )  [inline]

Return the basetype of the device that we are acknowledging.

Definition at line 116 of file DeviceAck.h.

Referenced by gadget::RemoteInputManager::handlePacket().

00117    {
00118       return mDeviceBaseType;
00119    }

std::string cluster::DeviceAck::getHostname (  )  [inline]

Return the hostname of the node that is acknowledging the DeviceRequest.

Definition at line 124 of file DeviceAck.h.

Referenced by gadget::RemoteInputManager::handlePacket().

00125    {
00126       return mHostname;
00127    }

bool cluster::DeviceAck::getAck (  )  [inline]

Return a boolean determining if this is a positive(ACK) or a negative(NACK) responce.

Definition at line 133 of file DeviceAck.h.

Referenced by gadget::RemoteInputManager::handlePacket().

00134    {
00135       return mAck;
00136    }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:44:22 2007 for Gadgeteer by  doxygen 1.5.1