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/sensors/querylocalpose.h" 00041 #include "jaus/core/scaledinteger.h" 00042 #include <cxutils/math/cxmath.h> 00043 00044 using namespace JAUS; 00045 00046 00055 QueryLocalPose::QueryLocalPose(const Address& dest, const Address& src) : Message(QUERY_LOCAL_POSE, dest, src) 00056 { 00057 mPresenceVector = 0; 00058 } 00059 00060 00066 QueryLocalPose::QueryLocalPose(const QueryLocalPose& message) : Message(QUERY_LOCAL_POSE) 00067 { 00068 *this = message; 00069 } 00070 00071 00077 QueryLocalPose::~QueryLocalPose() 00078 { 00079 } 00080 00081 00093 int QueryLocalPose::WriteMessageBody(Packet& packet) const 00094 { 00095 int expected = USHORT_SIZE; 00096 int written = 0; 00097 00098 written += packet.Write(mPresenceVector); 00099 00100 return expected == written ? written : -1; 00101 } 00102 00103 00115 int QueryLocalPose::ReadMessageBody(const Packet& packet) 00116 { 00117 int expected = USHORT_SIZE; 00118 int read = 0; 00119 00120 read += packet.Read(mPresenceVector); 00121 00122 return expected == read ? read : -1; 00123 } 00124 00125 00131 void QueryLocalPose::ClearMessageBody() 00132 { 00133 mPresenceVector = 0; 00134 } 00135 00136 00144 int QueryLocalPose::RunTestCase() const 00145 { 00146 int result = 0; 00147 00148 Packet packet; 00149 00150 QueryLocalPose msg1, msg2; 00151 msg1.SetPresenceVector(0xFFFF & GetPresenceVectorMask()); 00152 00153 if(msg1.WriteMessageBody(packet) != -1 && 00154 msg2.ReadMessageBody(packet) != -1) 00155 { 00156 if(msg1.GetPresenceVector() == msg2.GetPresenceVector()) 00157 { 00158 result = 1; 00159 } 00160 } 00161 00162 return result; 00163 } 00164 00165 00171 QueryLocalPose& QueryLocalPose::operator=(const QueryLocalPose& message) 00172 { 00173 if(this != &message) 00174 { 00175 CopyHeaderData(&message); 00176 mPresenceVector = message.mPresenceVector; 00177 } 00178 return *this; 00179 } 00180 00181 00182 /* End of File */