Changeset 17:2b7d9b08ce3f in xplra for src/client/c/hu
- Timestamp:
- 01/31/13 16:56:18 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/client/c/hu/varadiistvan/xplra
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/c/hu/varadiistvan/xplra/XPlane.cc
r16 r17 90 90 91 91 //------------------------------------------------------------------------------ 92 93 inline void XPlane::checkResult() throw(ProtocolException) 94 { 95 uint8_t result = stream->readU8(); 96 checkStream(); 97 checkResult(result); 98 } 99 100 //------------------------------------------------------------------------------ 92 101 //------------------------------------------------------------------------------ 93 102 … … 142 151 if (!stream->flush()) checkStream(); 143 152 144 uint8_t result = stream->readU8(); 145 checkStream(); 146 checkResult(result); 153 checkResult(); 147 154 } 148 155 … … 285 292 //------------------------------------------------------------------------------ 286 293 294 void XPlane::setScalar(const char* name, uint8_t type) throw(Exception) 295 { 296 stream->writeU8(Protocol::COMMAND_SET_SINGLE); 297 stream->writeString(name, strlen(name)); 298 stream->writeU8(type); 299 } 300 301 //------------------------------------------------------------------------------ 302 303 void XPlane::setInt(const char* name, int value) throw(Exception) 304 { 305 setScalar(name, Protocol::TYPE_INT); 306 stream->writeS32(value); 307 stream->flush(); 308 checkResult(); 309 } 310 311 //------------------------------------------------------------------------------ 312 313 void XPlane::setFloat(const char* name, float value) throw(Exception) 314 { 315 setScalar(name, Protocol::TYPE_FLOAT); 316 stream->writeFloat(value); 317 stream->flush(); 318 checkResult(); 319 } 320 321 //------------------------------------------------------------------------------ 322 323 void XPlane::setDouble(const char* name, double value) throw(Exception) 324 { 325 setScalar(name, Protocol::TYPE_DOUBLE); 326 stream->writeDouble(value); 327 stream->flush(); 328 checkResult(); 329 } 330 331 //------------------------------------------------------------------------------ 332 287 333 // Local Variables: 288 334 // mode: C++ -
src/client/c/hu/varadiistvan/xplra/XPlane.h
r16 r17 183 183 std::string getString(const char* name, size_t offset = 0) throw(Exception); 184 184 185 /** 186 * Set the given dataref to the given integer value. 187 */ 188 void setInt(const char* name, int value) throw(Exception); 189 190 /** 191 * Set the given dataref to the given float value. 192 */ 193 void setFloat(const char* name, float value) throw(Exception); 194 195 /** 196 * Set the given dataref to the given double value. 197 */ 198 void setDouble(const char* name, double value) throw(Exception); 199 185 200 private: 186 201 /** … … 194 209 */ 195 210 void checkResult(uint8_t result) throw(ProtocolException); 211 212 /** 213 * Read and check the result. If it signifies an error, 214 * throw a ProtocolException with the correct error code. 215 */ 216 void checkResult() throw(ProtocolException); 196 217 197 218 /** … … 211 232 ssize_t length, size_t offset) throw(Exception); 212 233 234 235 /** 236 * Issue the command to set a scalar value of the given type. 237 */ 238 void setScalar(const char* name, uint8_t type) throw(Exception); 213 239 }; 214 240
Note:
See TracChangeset
for help on using the changeset viewer.