Changeset 3206 in ntrip for trunk/BNC/upload/bncuploadcaster.cpp
- Timestamp:
- Mar 30, 2011, 6:20:17 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/upload/bncuploadcaster.cpp
r3192 r3206 34 34 const QString& rnxFileName, 35 35 const QString& outFileName) { 36 37 36 bncSettings settings; 38 37 … … 181 180 _t0 = settings.value("trafo_t0").toDouble(); 182 181 } 182 183 // Deep copy of ephemerides 184 // ------------------------ 185 _ephMap = 0; 183 186 } 184 187 … … 186 189 //////////////////////////////////////////////////////////////////////////// 187 190 bncUploadCaster::~bncUploadCaster() { 191 if (_ephMap) { 192 QMapIterator<QString, t_eph*> it(*_ephMap); 193 while (it.hasNext()) { 194 it.next(); 195 t_eph* eph = it.value(); 196 delete eph; 197 } 198 delete _ephMap; 199 } 188 200 delete _outFile; 189 201 delete _rnx; 190 202 delete _sp3; 203 } 204 205 // Endless Loop 206 //////////////////////////////////////////////////////////////////////////// 207 void bncUploadCaster::run() { 208 while (true) { 209 uploadClockOrbitBias(); 210 msleep(10); 211 } 191 212 } 192 213 … … 260 281 } 261 282 262 // Encode and Upload Clocks, Orbits, and Biases 263 //////////////////////////////////////////////////////////////////////////// 264 void bncUploadCaster::uploadClockOrbitBias(const bncTime& epoTime, 265 const QMap<QString, bncEphUser::t_ephPair*>& ephMap, 266 const QStringList& lines) { 283 // 284 //////////////////////////////////////////////////////////////////////////// 285 void bncUploadCaster::decodeRtnetStream(char* buffer, int bufLen, 286 const QMap<QString, bncEphUser::t_ephPair*>& ephPairMap) { 287 288 QMutexLocker locker(&_mutex); 289 290 // Delete old ephemeris 291 // -------------------- 292 if (_ephMap) { 293 QMapIterator<QString, t_eph*> it(*_ephMap); 294 while (it.hasNext()) { 295 it.next(); 296 t_eph* eph = it.value(); 297 delete eph; 298 } 299 delete _ephMap; 300 } 301 _ephMap = new QMap<QString, t_eph*>; 302 303 // Make a deep copy of ephemeris 304 // ----------------------------- 305 QMapIterator<QString, bncEphUser::t_ephPair*> it(ephPairMap); 306 while (it.hasNext()) { 307 it.next(); 308 bncEphUser::t_ephPair* pair = it.value(); 309 t_eph* ep = pair->last; 310 if (pair->prev && ep && 311 ep->receptDateTime().secsTo(QDateTime::currentDateTime()) < 60) { 312 ep = pair->prev; 313 } 314 QString prn(ep->prn().c_str()); 315 if (prn[0] == 'G') { 316 t_ephGPS* epGPS = static_cast<t_ephGPS*>(ep); 317 (*_ephMap)[prn] = new t_ephGPS(*epGPS); 318 } 319 else if (prn[0] == 'R') { 320 t_ephGlo* epGlo = static_cast<t_ephGlo*>(ep); 321 (*_ephMap)[prn] = new t_ephGlo(*epGlo); 322 } 323 else if (prn[0] == 'E') { 324 t_ephGal* epGal = static_cast<t_ephGal*>(ep); 325 (*_ephMap)[prn] = new t_ephGal(*epGal); 326 } 327 } 328 329 // Append to buffer 330 // ---------------- 331 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen)); 332 } 333 334 // Function called in separate thread 335 //////////////////////////////////////////////////////////////////////// 336 void bncUploadCaster::uploadClockOrbitBias() { 337 338 QMutexLocker locker(&_mutex); 339 340 // Prepare list of lines with satellite positions in SP3-like format 341 // ----------------------------------------------------------------- 342 QStringList lines; 343 int iLast = _rtnetStreamBuffer.lastIndexOf('\n'); 344 if (iLast != -1) { 345 QStringList hlpLines = _rtnetStreamBuffer.split('\n', QString::SkipEmptyParts); 346 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLast+1); 347 for (int ii = 0; ii < hlpLines.size(); ii++) { 348 if (hlpLines[ii].indexOf('*') != -1) { 349 QTextStream in(hlpLines[ii].toAscii()); 350 QString hlp; 351 int year, month, day, hour, min; 352 double sec; 353 in >> hlp >> year >> month >> day >> hour >> min >> sec; 354 _epoTime.set( year, month, day, hour, min, sec); 355 } 356 else if (_epoTime.valid()) { 357 lines << hlpLines[ii]; 358 } 359 } 360 } 361 362 if (lines.size() == 0) { 363 return; 364 } 365 267 366 this->open(); 268 367 269 368 unsigned year, month, day; 270 epoTime.civil_date(year, month, day);369 _epoTime.civil_date(year, month, day); 271 370 272 371 struct ClockOrbit co; 273 372 memset(&co, 0, sizeof(co)); 274 co.GPSEpochTime = static_cast<int>( epoTime.gpssec());275 co.GLONASSEpochTime = static_cast<int>(fmod( epoTime.gpssec(), 86400.0))373 co.GPSEpochTime = static_cast<int>(_epoTime.gpssec()); 374 co.GLONASSEpochTime = static_cast<int>(fmod(_epoTime.gpssec(), 86400.0)) 276 375 + 3 * 3600 - gnumleap(year, month, day); 277 376 co.ClockDataSupplied = 1; … … 288 387 QString prn; 289 388 ColumnVector xx(14); xx = 0.0; 290 bncEphUser::t_ephPair* pair = 0;291 389 292 390 QTextStream in(lines[ii].toAscii()); … … 297 395 } 298 396 299 if ( ephMap.contains(prn) ) { 397 if ( _ephMap->contains(prn) ) { 398 t_eph* ep = (*_ephMap)[prn]; 399 300 400 in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5) 301 401 >> xx(6) >> xx(7) >> xx(8) >> xx(9) >> xx(10) … … 314 414 xx(14) *= 1e3; // z-crd at time + dT 315 415 316 pair = ephMap[prn];317 }318 319 // Use old ephemeris if the new one is too recent320 // ----------------------------------------------321 t_eph* ep = 0;322 if (pair) {323 ep = pair->last;324 if (pair->prev && ep &&325 ep->receptDateTime().secsTo(QDateTime::currentDateTime()) < 60) {326 ep = pair->prev;327 }328 }329 330 if (ep != 0) {331 416 struct ClockOrbit::SatData* sd = 0; 332 417 if (prn[0] == 'G') { … … 340 425 if (sd) { 341 426 QString outLine; 342 processSatellite(ep, epoTime.gpsw(),epoTime.gpssec(), prn, xx, sd, outLine);427 processSatellite(ep, _epoTime.gpsw(), _epoTime.gpssec(), prn, xx, sd, outLine); 343 428 if (_outFile) { 344 _outFile->write( epoTime.gpsw(),epoTime.gpssec(), outLine);429 _outFile->write(_epoTime.gpsw(), _epoTime.gpssec(), outLine); 345 430 } 346 431 } … … 386 471 } 387 472 388 if ( this->usedSocket() && 389 (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) { 473 if (_outSocket && (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0)) { 390 474 char obuffer[CLOCKORBIT_BUFFERSIZE]; 391 475 … … 396 480 } 397 481 398 if ( this->usedSocket() && 399 (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) ) { 482 if (_outSocket && (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0)) { 400 483 char obuffer[CLOCKORBIT_BUFFERSIZE]; 401 484 int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer)); … … 527 610 xyz = sc * rMat * xyz + dx; 528 611 } 612
Note:
See TracChangeset
for help on using the changeset viewer.