- Timestamp:
- Mar 30, 2011, 6:20:17 PM (14 years ago)
- Location:
- trunk/BNC
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncgetthread.cpp
r3204 r3206 319 319 else if (_format.indexOf("RTNET") != -1) { 320 320 emit(newMessage(_staID + ": Get data in RTNet format", true)); 321 bncRtnetDecoder* rtnetDecoder = new bncRtnetDecoder(); 322 rtnetDecoder->start(); 323 _decoder = rtnetDecoder; 321 _decoder = new bncRtnetDecoder(); 324 322 } 325 323 else { -
trunk/BNC/combination/bnccomb.cpp
r3205 r3206 119 119 120 120 _rtnetDecoder = new bncRtnetDecoder(); 121 _rtnetDecoder->start();122 121 123 122 connect(this, SIGNAL(newMessage(QByteArray,bool)), -
trunk/BNC/upload/bncrtnetdecoder.cpp
r3203 r3206 49 49 //////////////////////////////////////////////////////////////////////// 50 50 bncRtnetDecoder::bncRtnetDecoder() { 51 }52 53 // Destructor54 ////////////////////////////////////////////////////////////////////////55 bncRtnetDecoder::~bncRtnetDecoder() {56 for (int ic = 0; ic < _casters->size(); ic++) {57 delete _casters->at(ic);58 }59 delete _casters;60 }61 62 // Run63 ////////////////////////////////////////////////////////////////////////64 void bncRtnetDecoder::run() {65 66 51 bncSettings settings; 67 52 68 53 // List of upload casters 69 54 // ---------------------- 70 _casters = new QVector<bncUploadCaster*>;71 55 QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList()); 72 56 while (it.hasNext()) { … … 75 59 int outPort = hlp[1].toInt(); 76 60 bool CoM = (hlp[5].toInt() == Qt::Checked); 77 _casters->push_back(new bncUploadCaster(hlp[2], hlp[0], outPort, 78 hlp[3], hlp[4], CoM, 79 hlp[6], "", "")); 61 bncUploadCaster* newCaster = new bncUploadCaster(hlp[2], hlp[0], outPort, 62 hlp[3], hlp[4], CoM, 63 hlp[6], "", ""); 64 newCaster->start(); 65 _casters.push_back(newCaster); 80 66 } 81 67 } 68 } 82 69 83 // Endless Loop - Decode 84 // --------------------- 85 while (true) {86 DecodeInThread();87 msleep(10);70 // Destructor 71 //////////////////////////////////////////////////////////////////////// 72 bncRtnetDecoder::~bncRtnetDecoder() { 73 for (int ic = 0; ic < _casters.size(); ic++) { 74 delete _casters[ic]; 88 75 } 89 76 } … … 94 81 QMutexLocker locker(&_mutex); 95 82 errmsg.clear(); 96 _buffer.append(QByteArray(buffer, bufLen)); 83 for (int ic = 0; ic < _casters.size(); ic++) { 84 _casters[ic]->decodeRtnetStream(buffer, bufLen, _eph); 85 } 97 86 return success; 98 87 } 99 88 100 // Decode and upload in separate thread101 ////////////////////////////////////////////////////////////////////////102 void bncRtnetDecoder::DecodeInThread() {103 QMutexLocker locker(&_mutex);104 105 // Prepare list of lines with satellite positions in SP3-like format106 // -----------------------------------------------------------------107 QStringList lines;108 int iLast = _buffer.lastIndexOf('\n');109 if (iLast != -1) {110 QStringList hlpLines = _buffer.split('\n', QString::SkipEmptyParts);111 _buffer = _buffer.mid(iLast+1);112 for (int ii = 0; ii < hlpLines.size(); ii++) {113 if (hlpLines[ii].indexOf('*') != -1) {114 QTextStream in(hlpLines[ii].toAscii());115 QString hlp;116 int year, month, day, hour, min;117 double sec;118 in >> hlp >> year >> month >> day >> hour >> min >> sec;119 _epoTime.set( year, month, day, hour, min, sec);120 }121 else if (_epoTime.valid()) {122 lines << hlpLines[ii];123 }124 }125 }126 127 // Satellite positions to be processed128 // -----------------------------------129 if (lines.size() > 0) {130 for (int ic = 0; ic < _casters->size(); ic++) {131 _casters->at(ic)->uploadClockOrbitBias(_epoTime, _eph, lines);132 }133 }134 }135 -
trunk/BNC/upload/bncrtnetdecoder.h
r3203 r3206 33 33 #include "RTCM/GPSDecoder.h" 34 34 35 class bncRtnetDecoder: public GPSDecoder, public bncEphUser , public QThread{35 class bncRtnetDecoder: public GPSDecoder, public bncEphUser { 36 36 public: 37 37 bncRtnetDecoder(); 38 38 ~bncRtnetDecoder(); 39 virtual void run();40 39 virtual t_irc Decode(char* buffer, int bufLen, 41 40 std::vector<std::string>& errmsg); 42 41 private: 43 void DecodeInThread(); 44 QVector<bncUploadCaster*>* _casters; 45 QString _buffer; 46 bncTime _epoTime; 47 QMutex _mutex; 42 QVector<bncUploadCaster*> _casters; 48 43 }; 49 44 -
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 -
trunk/BNC/upload/bncuploadcaster.h
r3189 r3206 10 10 class bncSP3; 11 11 12 class bncUploadCaster : public Q Object{12 class bncUploadCaster : public QThread { 13 13 Q_OBJECT 14 14 public: … … 21 21 const QString& outFileName); 22 22 virtual ~bncUploadCaster(); 23 void open(); 24 void write(char* buffer, unsigned len); 25 void printAscii(const QString& line); 26 bool usedSocket() const {return _outSocket;} 27 void uploadClockOrbitBias(const bncTime& epoTime, 28 const QMap<QString, bncEphUser::t_ephPair*>& ephMap, 29 const QStringList& lines); 23 virtual void run(); 24 void decodeRtnetStream(char* buffer, int bufLen, 25 const QMap<QString, bncEphUser::t_ephPair*>& ephMap); 30 26 31 27 signals: … … 33 29 34 30 private: 31 void open(); 32 void write(char* buffer, unsigned len); 33 void uploadClockOrbitBias(); 35 34 void processSatellite(t_eph* eph, int GPSweek, 36 35 double GPSweeks, const QString& prn, … … 39 38 QString& outLine); 40 39 void crdTrafo(int GPSWeek, ColumnVector& xyz); 40 41 QMap<QString, t_eph*>* _ephMap; 42 QMutex _mutex; 43 QString _rtnetStreamBuffer; 44 bncTime _epoTime; 41 45 QString _mountpoint; 42 46 QString _outHost;
Note:
See TracChangeset
for help on using the changeset viewer.