Changeset 36:29e3b676c0c2 in xplra for src
- Timestamp:
- 02/10/13 08:21:47 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/c/hu/varadiistvan/xplra/XPlane.cc
r30 r36 193 193 //------------------------------------------------------------------------------ 194 194 195 void XPlane::getVersions(int& xplaneVersion, int& xplmVersion, int& xplraVersion) 196 throw(Exception) 197 { 198 stream->writeU8(Protocol::COMMAND_GET_VERSIONS); 199 stream->flush(); 200 checkResult(); 201 202 xplaneVersion = stream->readS32(); 203 xplmVersion = stream->readS32(); 204 xplraVersion = stream->readS32(); 205 206 checkStream(); 207 } 208 209 //------------------------------------------------------------------------------ 210 195 211 void XPlane::getScalar(const char* name, uint8_t type) throw(Exception) 196 212 { -
src/client/c/hu/varadiistvan/xplra/XPlane.h
r30 r36 145 145 146 146 /** 147 * Get the versions of X-Plane, XPLM and the XPLRA plugin. 148 */ 149 void getVersions(int& xplaneVersion, int& xplmVersion, int& xplraVersion) throw(Exception); 150 151 /** 147 152 * Get the integer value of the dataref with the given name. 148 153 */ -
src/client/c/hu/varadiistvan/xplra/xplra.cc
r29 r36 498 498 //------------------------------------------------------------------------------ 499 499 500 extern "C"int xplra_get_versions(int connectionID, 501 int* xplaneVersion, int* xplmVersion, 502 int* xplraVersion) 503 { 504 Connection* connection = ConnectionSlot::getValue(connectionID); 505 if (connection==0) return -1; 506 try { 507 connection->getVersions(*xplaneVersion, *xplmVersion, *xplraVersion); 508 return 0; 509 } catch (...) { 510 connection->handleException(); 511 return -1; 512 } 513 } 514 515 //------------------------------------------------------------------------------ 516 500 517 extern "C" int xplra_get_int(int* value, int connectionID, const char* name) 501 518 { -
src/client/c/hu/varadiistvan/xplra/xplra.h
r29 r36 130 130 131 131 /*----------------------------------------------------------------------------*/ 132 133 /** 134 * Get the versions of X-Plane, the XPLM library and XPLRA 135 */ 136 int xplra_get_versions(int connectionID, 137 int* xplaneVersion, int* xplmVersion, 138 int* xplraVersion); 139 140 /*----------------------------------------------------------------------------*/ 132 141 /* Single dataref support */ 133 142 /*----------------------------------------------------------------------------*/ -
src/client/python/xplra.py
r35 r36 27 27 28 28 COMMAND_EXECUTE_SET_MULTI = 0x23 29 30 COMMAND_GET_VERSIONS = 0x31 29 31 30 32 TYPE_INT = 0x01 … … 135 137 """Create a new multi-dataref setter for this X-Plane object.""" 136 138 return MultiSetter(self) 139 140 def getVersions(self): 141 """Get the versions of X-Plane, XPLM and XPLRA as a tuple.""" 142 self._writeU8(COMMAND_GET_VERSIONS) 143 self._flush() 144 self._checkResult() 145 return (self._readS32(), self._readS32(), self._readS32()) 137 146 138 147 def getInt(self, name): … … 392 401 393 402 self._registeredID = None 403 404 @property 405 def values(self): 406 """Query the values as a list.""" 407 if self._values is None: 408 self.finalize() 409 return self._values 394 410 395 411 def addInt(self, name): -
src/plugin/src/xplra/ListenThread.cc
r13 r36 55 55 while(!quitEvent.check() && !quitEvent.failed() && !acceptor.failed()) { 56 56 if (acceptor.accept()) { 57 ServerThread* serverThread = new ServerThread(requestQueue, 57 ServerThread* serverThread = new ServerThread(*this, 58 requestQueue, 58 59 acceptor); 59 60 serverThread->start(); -
src/plugin/src/xplra/ListenThread.h
r13 r36 54 54 private: 55 55 /** 56 * The version of X-Plane. 57 */ 58 int xplaneVersion; 59 60 /** 61 * The version of the XPLM library. 62 */ 63 int xplmVersion; 64 65 /** 56 66 * The waiter used in the thread. 57 67 */ … … 73 83 * Construct the thread. 74 84 */ 75 ListenThread(); 85 ListenThread(int xplaneVersion, int xplmVersion); 86 87 /** 88 * Get the versions 89 */ 90 void getVersions(int& xplane, int& xplm) const; 76 91 77 92 /** … … 90 105 //------------------------------------------------------------------------------ 91 106 92 inline ListenThread::ListenThread( ) :107 inline ListenThread::ListenThread(int xplaneVersion, int xplmVersion) : 93 108 Thread(true), 109 xplaneVersion(xplaneVersion), 110 xplmVersion(xplmVersion), 94 111 quitEvent(&waiter) 95 112 { 113 } 114 115 //------------------------------------------------------------------------------ 116 117 inline void ListenThread::getVersions(int& xplane, int& xplm) const 118 { 119 xplane = xplaneVersion; 120 xplm = xplmVersion; 96 121 } 97 122 -
src/plugin/src/xplra/Protocol.h
r13 r36 92 92 93 93 /** 94 * Command: get the versions of the simulator 95 */ 96 static const uint8_t COMMAND_GET_VERSIONS = 0x31; 97 98 /** 94 99 * Data type: int 95 100 */ … … 176 181 */ 177 182 static const size_t MAX_MULTI_COUNT = 1024; 183 184 /** 185 * The version of the plugin. 186 */ 187 static const int version = 10; 178 188 }; 179 189 -
src/plugin/src/xplra/ServerThread.cc
r13 r36 31 31 #include "ServerThread.h" 32 32 33 #include "ListenThread.h" 33 34 #include "RequestQueue.h" 34 35 #include "Protocol.h" … … 72 73 //------------------------------------------------------------------------------ 73 74 74 ServerThread::ServerThread(RequestQueue& requestQueue, LocalAcceptor& acceptor) : 75 ServerThread::ServerThread(ListenThread& listenThread, 76 RequestQueue& requestQueue, LocalAcceptor& acceptor) : 75 77 Thread(true), 78 listenThread(listenThread), 76 79 requestQueue(requestQueue), 77 80 bufferedStream(acceptor.getSocket(&waiter)), … … 147 150 } else if (command==Protocol::COMMAND_EXECUTE_SET_MULTI) { 148 151 if (!handleExecuteSetMulti()) break; 152 } else if (command==Protocol::COMMAND_GET_VERSIONS) { 153 if (!handleGetVersions()) break; 149 154 } else { 150 155 stream.writeU8(Protocol::RESULT_INVALID_COMMAND); … … 384 389 //------------------------------------------------------------------------------ 385 390 391 bool ServerThread::handleGetVersions() 392 { 393 int xplaneVersion = 0; 394 int xplmVersion = 0; 395 396 listenThread.getVersions(xplaneVersion, xplmVersion); 397 398 stream.writeU8(Protocol::RESULT_OK); 399 stream.writeS32(xplaneVersion); 400 stream.writeS32(xplmVersion); 401 stream.writeS32(Protocol::version); 402 403 return true; 404 } 405 406 //------------------------------------------------------------------------------ 407 386 408 // Local Variables: 387 409 // mode: C++ -
src/plugin/src/xplra/ServerThread.h
r13 r36 49 49 //------------------------------------------------------------------------------ 50 50 51 class ListenThread; 52 51 53 class RequestQueue; 52 54 … … 95 97 private: 96 98 /** 99 * The listen thread this server was started by. 100 */ 101 ListenThread& listenThread; 102 103 /** 97 104 * The request queue to use. 98 105 */ … … 139 146 * given acceptor. 140 147 */ 141 ServerThread( RequestQueue& requestQueue,148 ServerThread(ListenThread& listenThread, RequestQueue& requestQueue, 142 149 hu::varadiistvan::scpl::io::LocalAcceptor& acceptor); 143 150 … … 227 234 */ 228 235 bool handleExecuteSetMulti(); 236 237 /** 238 * Handle the COMMAND_GET_VERSIONS command 239 * 240 * @return true, if we can continue, false if the thread should quit 241 */ 242 bool handleGetVersions(); 229 243 }; 230 244 -
src/plugin/src/xplra/plugin.cc
r13 r36 83 83 Util::debug("hu.varadiistvan.xplra.XPluginEnable called\n"); 84 84 // XPLMRegisterFlightLoopCallback(&callback, 5.0, 0); 85 listenThread = new ListenThread(); 85 86 int xplaneVersion = 0; 87 int xplmVersion = 0; 88 XPLMHostApplicationID hostID = 0; 89 XPLMGetVersions(&xplaneVersion, &xplmVersion, &hostID); 90 91 listenThread = new ListenThread(xplaneVersion, xplmVersion); 86 92 listenThread->start(); 87 93 }
Note:
See TracChangeset
for help on using the changeset viewer.