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/queryaccelerationlimit.h" 00041 #include "jaus/core/scaledinteger.h" 00042 #include <cxutils/math/cxmath.h> 00043 00044 using namespace JAUS; 00045 00046 00055 QueryAccelerationLimit::QueryAccelerationLimit(const Address& dest, const Address& src) : Message(QUERY_ACCELERATION_LIMIT, dest, src) 00056 { 00057 mPresenceVector = 0; 00058 mCommandType = SetMaximumAllowedValues; 00059 } 00060 00061 00067 QueryAccelerationLimit::QueryAccelerationLimit(const QueryAccelerationLimit& message) : Message(QUERY_ACCELERATION_LIMIT) 00068 { 00069 *this = message; 00070 } 00071 00072 00078 QueryAccelerationLimit::~QueryAccelerationLimit() 00079 { 00080 } 00081 00082 00094 int QueryAccelerationLimit::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 QueryAccelerationLimit::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 QueryAccelerationLimit::ClearMessageBody() 00139 { 00140 mPresenceVector = 0; 00141 mCommandType = SetMaximumAllowedValues; 00142 } 00143 00144 00152 int QueryAccelerationLimit::RunTestCase() const 00153 { 00154 int result = 0; 00155 00156 Packet packet; 00157 00158 QueryAccelerationLimit msg1, msg2; 00159 msg1.SetPresenceVector(0xFF & GetPresenceVectorMask()); 00160 msg1.SetCommandType(SetMinimumAllowedValues); 00161 00162 if(msg1.WriteMessageBody(packet) != -1 && msg2.ReadMessageBody(packet) != -1) 00163 { 00164 if(msg1.GetPresenceVector() == msg2.GetPresenceVector() && 00165 msg1.GetCommandType() == msg2.GetCommandType()) 00166 { 00167 result = 1; 00168 } 00169 } 00170 00171 return result; 00172 } 00173 00174 00180 QueryAccelerationLimit& QueryAccelerationLimit::operator=(const QueryAccelerationLimit& message) 00181 { 00182 if(this != &message) 00183 { 00184 CopyHeaderData(&message); 00185 mPresenceVector = message.mPresenceVector; 00186 mCommandType = message.mCommandType; 00187 } 00188 return *this; 00189 } 00190 00191 00192 /* End of File */