Changeset 3226 in ntrip
- Timestamp:
- Mar 31, 2011, 6:10:51 PM (14 years ago)
- Location:
- trunk/BNC/upload
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/upload/bncrtnetuploadcaster.cpp
r3224 r3226 35 35 bncUploadCaster(mountpoint, outHost, outPort, password) { 36 36 37 bncSettings settings;38 37 _crdTrafo = crdTrafo; 39 38 _CoM = CoM; … … 158 157 } 159 158 else if (_crdTrafo == "Custom") { 159 bncSettings settings; 160 160 _dx = settings.value("trafo_dx").toDouble(); 161 161 _dy = settings.value("trafo_dy").toDouble(); … … 188 188 } 189 189 190 // Endless Loop191 ////////////////////////////////////////////////////////////////////////////192 void bncRtnetUploadCaster::run() {193 while (true) {194 if (_isToBeDeleted) {195 QThread::quit();196 deleteLater();197 return;198 }199 open();200 uploadClockOrbitBias();201 msleep(10);202 }203 }204 205 190 // 206 191 //////////////////////////////////////////////////////////////////////////// … … 211 196 // Append to buffer 212 197 // ---------------- 213 const int MAXBUFFSIZE = 100000;214 198 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen)); 215 if (_rtnetStreamBuffer.size() > MAXBUFFSIZE) { 216 _rtnetStreamBuffer = _rtnetStreamBuffer.right(MAXBUFFSIZE); 217 } 218 } 219 220 // Function called in separate thread 221 //////////////////////////////////////////////////////////////////////// 222 void bncRtnetUploadCaster::uploadClockOrbitBias() { 223 224 QMutexLocker locker(&_mutex); 199 int iLastAsterix = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch 200 if (iLastAsterix == -1) { 201 _rtnetStreamBuffer.clear(); 202 return; 203 } 204 else { 205 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastAsterix); 206 } 225 207 226 208 // Prepare list of lines with satellite positions in SP3-like format 227 209 // ----------------------------------------------------------------- 228 QStringList lines; 229 int iLast = _rtnetStreamBuffer.lastIndexOf('\n'); 230 if (iLast != -1) { 231 QStringList hlpLines = _rtnetStreamBuffer.split('\n', QString::SkipEmptyParts); 232 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLast+1); 233 for (int ii = 0; ii < hlpLines.size(); ii++) { 234 if (hlpLines[ii].indexOf('*') != -1) { 235 lines.clear(); 236 QTextStream in(hlpLines[ii].toAscii()); 237 QString hlp; 238 int year, month, day, hour, min; 239 double sec; 240 in >> hlp >> year >> month >> day >> hour >> min >> sec; 241 _epoTime.set( year, month, day, hour, min, sec); 242 } 243 else if (_epoTime.valid()) { 244 lines << hlpLines[ii]; 245 } 246 } 247 } 248 249 if (lines.size() == 0) { 210 QStringList lines = _rtnetStreamBuffer.split('\n', QString::SkipEmptyParts); 211 212 if (lines.size() < 2) { 250 213 return; 251 214 } 252 215 253 unsigned year, month, day; 254 _epoTime.civil_date(year, month, day); 255 216 // Keep the last unfinished line in buffer 217 // --------------------------------------- 218 int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n'); 219 if (iLastEOL != -1) { 220 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1); 221 } 222 223 // Read first line (with epoch time) 224 // --------------------------------- 225 QTextStream in(lines[0].toAscii()); 226 QString hlp; 227 int year, month, day, hour, min; 228 double sec; 229 in >> hlp >> year >> month >> day >> hour >> min >> sec; 230 bncTime epoTime; epoTime.set( year, month, day, hour, min, sec); 231 256 232 struct ClockOrbit co; 257 233 memset(&co, 0, sizeof(co)); 258 co.GPSEpochTime = static_cast<int>( _epoTime.gpssec());259 co.GLONASSEpochTime = static_cast<int>(fmod( _epoTime.gpssec(), 86400.0))234 co.GPSEpochTime = static_cast<int>(epoTime.gpssec()); 235 co.GLONASSEpochTime = static_cast<int>(fmod(epoTime.gpssec(), 86400.0)) 260 236 + 3 * 3600 - gnumleap(year, month, day); 261 237 co.ClockDataSupplied = 1; … … 265 241 struct Bias bias; 266 242 memset(&bias, 0, sizeof(bias)); 267 bias.GPSEpochTime 268 bias.GLONASSEpochTime 269 270 for (int ii = 0; ii < lines.size(); ii++) {271 243 bias.GPSEpochTime = co.GPSEpochTime; 244 bias.GLONASSEpochTime = co.GLONASSEpochTime; 245 246 for (int ii = 1; ii < lines.size(); ii++) { 247 272 248 QString prn; 273 249 ColumnVector xx(14); xx = 0.0; … … 315 291 if (sd) { 316 292 QString outLine; 317 processSatellite(eph, _epoTime.gpsw(), _epoTime.gpssec(), prn,293 processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prn, 318 294 xx, sd, outLine); 319 295 if (_outFile) { 320 _outFile->write( _epoTime.gpsw(), _epoTime.gpssec(), outLine);296 _outFile->write(epoTime.gpsw(), epoTime.gpssec(), outLine); 321 297 } 322 298 } … … 367 343 int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer)); 368 344 if (len > 0) { 369 this->write(obuffer, len);345 _outBuffer.append(QByteArray(obuffer, len)); 370 346 } 371 347 } … … 375 351 int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer)); 376 352 if (len > 0) { 377 this->write(obuffer, len);353 _outBuffer.append(QByteArray(obuffer, len)); 378 354 } 379 355 } -
trunk/BNC/upload/bncrtnetuploadcaster.h
r3225 r3226 25 25 const QString& rnxFileName, 26 26 const QString& outFileName); 27 void decodeRtnetStream(char* buffer, int bufLen); 27 28 protected: 28 29 virtual ~bncRtnetUploadCaster(); 29 public:30 virtual void run();31 void decodeRtnetStream(char* buffer, int bufLen);32 30 private: 33 31 void uploadClockOrbitBias(); … … 41 39 bncEphUser* _ephUser; 42 40 QString _rtnetStreamBuffer; 43 bncTime _epoTime;44 41 QString _crdTrafo; 45 42 bool _CoM; -
trunk/BNC/upload/bncuploadcaster.cpp
r3224 r3226 38 38 _sOpenTrial = 0; 39 39 _isToBeDeleted = false; 40 41 40 } 42 41 … … 55 54 if (isRunning()) { 56 55 wait(); 56 } 57 } 58 59 // Endless Loop 60 //////////////////////////////////////////////////////////////////////////// 61 void bncUploadCaster::run() { 62 while (true) { 63 if (_isToBeDeleted) { 64 QThread::quit(); 65 deleteLater(); 66 return; 67 } 68 open(); 69 if (_outSocket && _outSocket->state() == QAbstractSocket::ConnectedState) { 70 QMutexLocker locker(&_mutex); 71 _outSocket->write(_outBuffer); 72 _outSocket->flush(); 73 _outBuffer.clear(); 74 } 75 else { 76 QMutexLocker locker(&_mutex); 77 _outBuffer.clear(); 78 } 79 sleep(5); 57 80 } 58 81 } … … 117 140 } 118 141 119 // Write buffer120 ////////////////////////////////////////////////////////////////////////////121 void bncUploadCaster::write(char* buffer, unsigned len) {122 if (_outSocket && _outSocket->state() == QAbstractSocket::ConnectedState) {123 _outSocket->write(buffer, len);124 _outSocket->flush();125 }126 }127 -
trunk/BNC/upload/bncuploadcaster.h
r3224 r3226 11 11 const QString& password); 12 12 virtual void deleteSafely(); 13 virtual void run() = 0;14 13 15 14 protected: 16 virtual ~bncUploadCaster(); 17 void open(); 18 void write(char* buffer, unsigned len); 19 QMutex _mutex; 20 bool _isToBeDeleted; 15 virtual ~bncUploadCaster(); 16 QMutex _mutex; 17 QByteArray _outBuffer; 21 18 22 19 signals: … … 24 21 25 22 private: 26 QString _mountpoint; 27 QString _outHost; 28 int _outPort; 29 QString _password; 30 QTcpSocket* _outSocket; 31 int _sOpenTrial; 32 QDateTime _outSocketOpenTime; 23 void open(); 24 virtual void run(); 25 bool _isToBeDeleted; 26 QString _mountpoint; 27 QString _outHost; 28 int _outPort; 29 QString _password; 30 QTcpSocket* _outSocket; 31 int _sOpenTrial; 32 QDateTime _outSocketOpenTime; 33 33 }; 34 34
Note:
See TracChangeset
for help on using the changeset viewer.