Changeset 10:b0048ba6f3ca in xplra for src
- Timestamp:
- 01/04/13 16:36:30 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/xplra
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplra/GetMultiDataRefRequest.cc
r8 r10 39 39 using xplra::GetMultiDataRefRequest; 40 40 41 using xplcommon::DataStream; 41 42 using xplcommon::Util; 42 43 43 44 //------------------------------------------------------------------------------ 44 45 45 GetMultiDataRefRequest::GetMultiDataRefRequest(uint8_t& result, size_t numTasks,46 xplcommon::DataStream& stream)46 GetMultiDataRefRequest::GetMultiDataRefRequest(uint8_t& result, 47 DataStream& stream) 47 48 { 48 49 result = Protocol::RESULT_OK; 50 51 uint32_t numTasks = stream.readU32(); 52 if (!stream) return; 53 if (numTasks==0 || numTasks>Protocol::MAX_MULTI_COUNT) { 54 result = Protocol::RESULT_INVALID_COUNT; 55 return; 56 } 57 49 58 for(size_t i = 0; 50 59 i<numTasks && result==Protocol::RESULT_OK && stream; ++i) -
src/xplra/GetMultiDataRefRequest.h
r8 r10 50 50 * specifications from the given stream. 51 51 */ 52 GetMultiDataRefRequest(uint8_t& result, size_t numTasks, 53 xplcommon::DataStream& stream); 52 GetMultiDataRefRequest(uint8_t& result, xplcommon::DataStream& stream); 54 53 55 54 /** -
src/xplra/Protocol.h
r9 r10 50 50 */ 51 51 static const uint8_t COMMAND_SET_SINGLE = 0x02; 52 53 /** 54 * Command: get the value of a multiple datarefs. 55 */ 56 static const uint8_t COMMAND_GET_MULTI = 0x03; 57 58 /** 59 * Command: set the value of a multiple datarefs. 60 */ 61 static const uint8_t COMMAND_SET_MULTI = 0x04; 52 62 53 63 /** -
src/xplra/ServerThread.cc
r9 r10 131 131 } else if (command==Protocol::COMMAND_SET_SINGLE) { 132 132 if (!handleSetSingle()) break; 133 } else if (command==Protocol::COMMAND_GET_MULTI) { 134 if (!handleGetMulti()) break; 135 } else if (command==Protocol::COMMAND_SET_MULTI) { 136 if (!handleSetMulti()) break; 133 137 } else if (command==Protocol::COMMAND_REGISTER_GET_MULTI) { 134 138 if (!handleRegisterGetMulti()) break; … … 209 213 //------------------------------------------------------------------------------ 210 214 215 bool ServerThread::handleGetMulti() 216 { 217 uint8_t result = Protocol::RESULT_OK; 218 GetMultiDataRefRequest* request = 219 new GetMultiDataRefRequest(result, stream); 220 if (result!=Protocol::RESULT_OK || !stream) { 221 delete request; 222 stream.writeU8(result); 223 return stream; 224 } 225 226 bool isOK = requestQueue.execute(request); 227 228 if (isOK) { 229 request->writeResult(stream); 230 } 231 232 delete request; 233 234 return isOK; 235 } 236 237 //------------------------------------------------------------------------------ 238 239 bool ServerThread::handleSetMulti() 240 { 241 uint8_t result = Protocol::RESULT_OK; 242 SetMultiDataRefRequest* request = 243 new SetMultiDataRefRequest(result, stream, true); 244 if (result!=Protocol::RESULT_OK || !stream) { 245 delete request; 246 stream.writeU8(result); 247 return stream; 248 } 249 250 bool isOK = requestQueue.execute(request); 251 252 if (isOK) { 253 request->writeResult(stream); 254 } 255 256 delete request; 257 258 return isOK; 259 } 260 261 //------------------------------------------------------------------------------ 262 211 263 bool ServerThread::handleRegisterGetMulti() 212 264 { 213 uint32_t numTasks = stream.readU32();214 if (!stream) {215 return false;216 } else if (numTasks==0 || numTasks>Protocol::MAX_MULTI_COUNT) {217 stream.writeU8(Protocol::RESULT_INVALID_COUNT);218 return true;219 }220 221 265 uint8_t result = Protocol::RESULT_OK; 222 266 GetMultiDataRefRequest* request = 223 new GetMultiDataRefRequest(result, numTasks,stream);267 new GetMultiDataRefRequest(result, stream); 224 268 if (result!=Protocol::RESULT_OK || !stream) { 225 269 delete request; … … 282 326 uint8_t result = Protocol::RESULT_OK; 283 327 SetMultiDataRefRequest* request = 284 new SetMultiDataRefRequest(result, stream );328 new SetMultiDataRefRequest(result, stream, false); 285 329 if (result!=Protocol::RESULT_OK || !stream) { 286 330 delete request; -
src/xplra/ServerThread.h
r9 r10 173 173 174 174 /** 175 * Handle the COMMAND_GET_MULTI command 176 * 177 * @return true, if we can continue, false if the thread should quit 178 */ 179 bool handleGetMulti(); 180 181 /** 182 * Handle the COMMAND_SET_MULTI command 183 * 184 * @return true, if we can continue, false if the thread should quit 185 */ 186 bool handleSetMulti(); 187 188 /** 175 189 * Handle the COMMAND_REGISTER_GET_MULTI command 176 190 * -
src/xplra/SetMultiDataRefRequest.cc
r9 r10 42 42 43 43 SetMultiDataRefRequest::SetMultiDataRefRequest(uint8_t& result, 44 DataStream& stream) 44 DataStream& stream, 45 bool readValues) 45 46 { 46 47 result = Protocol::RESULT_OK; … … 56 57 i<numTasks && result==Protocol::RESULT_OK && stream; ++i) { 57 58 SetDataRefTask* task = SetDataRefTask::create(result, stream); 58 if (task!=0) addTask(task); 59 if (task!=0) { 60 if (readValues) { 61 task->readValue(stream); 62 } 63 addTask(task); 64 } 59 65 } 60 66 } -
src/xplra/SetMultiDataRefRequest.h
r9 r10 50 50 * the given stream. 51 51 */ 52 SetMultiDataRefRequest(uint8_t& result, xplcommon::DataStream& stream); 52 SetMultiDataRefRequest(uint8_t& result, xplcommon::DataStream& stream, 53 bool readValues); 53 54 54 55 /**
Note:
See TracChangeset
for help on using the changeset viewer.