00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 #include "jaus/mobility/drivers/queryvelocitycommand.h" 00041 #include "jaus/core/scaledinteger.h" 00042 #include <cxutils/math/cxmath.h> 00043 00044 using namespace JAUS; 00045 00046 00055 QueryVelocityCommand::QueryVelocityCommand(const Address& dest, const Address& src) : Message(SET_VELOCITY_COMMAND, dest, src) 00056 { 00057 mPresenceVector = 0; 00058 mCommandType = SetCurrentCommand; 00059 } 00060 00061 00067 QueryVelocityCommand::QueryVelocityCommand(const QueryVelocityCommand& message) : Message(SET_VELOCITY_COMMAND) 00068 { 00069 *this = message; 00070 } 00071 00072 00078 QueryVelocityCommand::~QueryVelocityCommand() 00079 { 00080 } 00081 00082 00094 int QueryVelocityCommand::WriteMessageBody(Packet& packet) const 00095 { 00096 int expected = BYTE_SIZE; 00097 int written = 0; 00098 00099 written += packet.Write(mPresenceVector); 00100 00101 expected += BYTE_SIZE; 00102 written += packet.Write((Byte)mCommandType); 00103 00104 return expected == written ? written : -1; 00105 } 00106 00107 00119 int QueryVelocityCommand::ReadMessageBody(const Packet& packet) 00120 { 00121 int expected = BYTE_SIZE; 00122 int read = 0; 00123 00124 read += packet.Read(mPresenceVector); 00125 00126 expected += BYTE_SIZE; 00127 read += packet.Read((Byte &)mCommandType); 00128 00129 return expected == read ? read : -1; 00130 } 00131 00132 00138 void QueryVelocityCommand::ClearMessageBody() 00139 { 00140 mPresenceVector = 0; 00141 mCommandType = SetCurrentCommand; 00142 } 00143 00144 00152 int QueryVelocityCommand::RunTestCase() const 00153 { 00154 int result = 0; 00155 00156 Packet packet; 00157 QueryVelocityCommand msg1, msg2; 00158 msg1.SetCommandType(SetDefaultCommand); 00159 msg1.SetPresenceVector(0xFF & GetPresenceVectorMask()); 00160 00161 if( msg1.WriteMessageBody(packet) != -1 && 00162 msg2.ReadMessageBody(packet) != -1 && 00163 msg1.GetCommandType() == msg2.GetCommandType() && 00164 msg1.GetPresenceVector() == msg2.GetPresenceVector()) 00165 { 00166 result = 1; 00167 } 00168 00169 return result; 00170 } 00171 00172 00178 QueryVelocityCommand& QueryVelocityCommand::operator=(const QueryVelocityCommand& message) 00179 { 00180 if(this != &message) 00181 { 00182 CopyHeaderData(&message); 00183 mPresenceVector = message.mPresenceVector; 00184 mCommandType = message.mCommandType; 00185 } 00186 return *this; 00187 } 00188 00189 00190 /* End of File */