Changeset 3523 in ntrip for trunk/BNC/bncgetthread.cpp


Ignore:
Timestamp:
Dec 14, 2011, 1:19:13 PM (12 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncgetthread.cpp

    r3517 r3523  
    111111
    112112  initialize();
     113  initDecoder();
    113114}
    114115
     
    125126
    126127  _isToBeDeleted = false;
    127   _decoder       = 0;
    128   _decoderAux    = 0;
    129128  _query         = 0;
    130129  _nextSleep     = 0;
     
    294293#endif
    295294
    296   // Instantiate the decoder
    297   // -----------------------
     295  _latencyChecker = new latencyChecker(_staID);
     296}
     297
     298// Instantiate the decoder
     299//////////////////////////////////////////////////////////////////////////////
     300t_irc bncGetThread::initDecoder() {
     301
    298302  if      (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1 ||
    299303           _format.indexOf("RTCM 2") != -1 ) {
    300304    emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
    301     _decoder = new RTCM2Decoder(_staID.data());
     305    _decoders[_staID] = new RTCM2Decoder(_staID.data());
    302306  }
    303307  else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1 ||
    304308           _format.indexOf("RTCM 3") != -1 ) {
    305309    emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
    306     _decoder = new RTCM3Decoder(_staID, _rawFile);
    307     connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray,bool)),
     310    _decoders[_staID] = new RTCM3Decoder(_staID, _rawFile);
     311    connect((RTCM3Decoder*) decoder(), SIGNAL(newMessage(QByteArray,bool)),
    308312            this, SIGNAL(newMessage(QByteArray,bool)));
    309313  }
    310314  else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
    311315    emit(newMessage(_staID + ": Get Data in GPSS format", true));
    312     _decoder = new gpssDecoder();
     316    _decoders[_staID] = new gpssDecoder();
    313317  }
    314318  else if (_format.indexOf("ZERO") != -1) {
    315319    emit(newMessage(_staID + ": Get data in original format", true));
    316     _decoder = new bncZeroDecoder(_staID);
     320    _decoders[_staID] = new bncZeroDecoder(_staID);
    317321  }
    318322  else if (_format.indexOf("RTNET") != -1) {
    319323    emit(newMessage(_staID + ": Get data in RTNet format", true));
    320     _decoder = new bncRtnetDecoder();
     324    _decoders[_staID] = new bncRtnetDecoder();
    321325  }
    322326  else if (_format.indexOf("HASS2ASCII") != -1) {
    323327    emit(newMessage(_staID + ": Get data in HASS2ASCII format", true));
    324     _decoder = new hassDecoder(_staID);
     328    _decoders[_staID] = new hassDecoder(_staID);
    325329  }
    326330  else {
    327331    emit(newMessage(_staID + ": Unknown data format " + _format, true));
    328332    _isToBeDeleted = true;
    329   }
    330 
    331   _latencyChecker = new latencyChecker(_staID);
     333    return failure;
     334  }
    332335
    333336  msleep(100); //sleep 0.1 sec
     337 
     338  return success;
     339}
     340
     341// Current decoder in use
     342////////////////////////////////////////////////////////////////////////////
     343GPSDecoder* bncGetThread::decoder() {
     344  if (_decoders.contains(_staID) || initDecoder() == success) {
     345    return _decoders.value(_staID);
     346  }
     347  else {
     348    return 0;
     349  }
    334350}
    335351
     
    345361  }
    346362  delete _PPPclient;
    347   delete _decoder;
    348   delete _decoderAux;
     363  QMapIterator<QString, GPSDecoder*> it(_decoders);
     364  while (it.hasNext()) {
     365    it.next();
     366    delete it.value();
     367  }
    349368  delete _rnx;
    350369  delete _rawFile;
     
    383402      // Delete old observations
    384403      // -----------------------
    385       _decoder->_obsList.clear();
    386       if (_decoderAux) {
    387         _decoderAux->_obsList.clear();
    388       }
    389 
    390       GPSDecoder* decoderUsed = _decoder;
     404      QMapIterator<QString, GPSDecoder*> itDec(_decoders);
     405      while (itDec.hasNext()) {
     406        itDec.next();
     407        GPSDecoder* decoder = itDec.value();
     408        decoder->_obsList.clear();
     409      }
    391410
    392411      // Read Data
     
    398417      else if (_rawFile) {
    399418        data = _rawFile->readChunk();
    400         if (_rawFile->format() == "HASS2ASCII") {
    401           if (_decoderAux == 0) {
    402             emit(newMessage(_rawFile->staID() + ": Get data in HASS2ASCII format", true));
    403             _decoderAux = new hassDecoder(_rawFile->staID());
    404           }
    405           decoderUsed = _decoderAux;
    406         }
     419        _format = _rawFile->format();
     420        _staID  = _rawFile->staID();
    407421
    408422        if (data.isEmpty()) {
     
    442456      // -----------
    443457      vector<string> errmsg;
    444       decoderUsed->_obsList.clear();
    445       t_irc irc = decoderUsed->Decode(data.data(), data.size(), errmsg);
     458      decoder()->_obsList.clear();
     459      t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
    446460
    447461      // Perform various scans and checks
    448462      // --------------------------------
    449463      _latencyChecker->checkOutage(irc == success);
    450       _latencyChecker->checkObsLatency(decoderUsed->_obsList);
    451       _latencyChecker->checkCorrLatency(decoderUsed->corrGPSEpochTime());
     464      _latencyChecker->checkObsLatency(decoder()->_obsList);
     465      _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
    452466
    453467      emit newLatency(_staID, _latencyChecker->currentLatency());
     
    457471      // Loop over all observations (observations output)
    458472      // ------------------------------------------------
    459       QListIterator<t_obs> it(decoderUsed->_obsList);
     473      QListIterator<t_obs> it(decoder()->_obsList);
    460474      bool firstObs = true;
    461475      while (it.hasNext()) {
     
    469483        // Check observation epoch
    470484        // -----------------------
    471         if (!_rawFile && !dynamic_cast<gpssDecoder*>(decoderUsed)) {
     485        if (!_rawFile && !dynamic_cast<gpssDecoder*>(decoder())) {
    472486          int    week;
    473487          double sec;
     
    523537        firstObs = false;
    524538      }
    525       decoderUsed->_obsList.clear();
     539      decoder()->_obsList.clear();
    526540    }
    527541    catch (Exception& exc) {
     
    625639      // RTCM message types
    626640      // ------------------
    627       for (int ii = 0; ii <_decoder->_typeList.size(); ii++) {
    628         QString type =  QString("%1 ").arg(_decoder->_typeList[ii]);
     641      for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
     642        QString type =  QString("%1 ").arg(decoder()->_typeList[ii]);
    629643        emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
    630644      }
     
    632646      // RTCMv3 antenna descriptor
    633647      // -------------------------
    634       for (int ii=0;ii<_decoder->_antType.size();ii++) {
    635         QString ant1 =  QString("%1 ").arg(_decoder->_antType[ii]);
     648      for (int ii=0;ii<decoder()->_antType.size();ii++) {
     649        QString ant1 =  QString("%1 ").arg(decoder()->_antType[ii]);
    636650        emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
    637651      }
     
    639653      // RTCM Antenna Coordinates
    640654      // ------------------------
    641       for (int ii=0; ii <_decoder->_antList.size(); ii++) {
     655      for (int ii=0; ii <decoder()->_antList.size(); ii++) {
    642656        QByteArray antT;
    643         if      (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
     657        if      (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
    644658          antT = "ARP";
    645659        }
    646         else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
     660        else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
    647661          antT = "APC";
    648662        }
    649663        QByteArray ant1, ant2, ant3;
    650         ant1 = QString("%1 ").arg(_decoder->_antList[ii].xx,0,'f',4).toAscii();
    651         ant2 = QString("%1 ").arg(_decoder->_antList[ii].yy,0,'f',4).toAscii();
    652         ant3 = QString("%1 ").arg(_decoder->_antList[ii].zz,0,'f',4).toAscii();
     664        ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
     665        ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
     666        ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
    653667        emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
    654668        emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
    655669        emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
    656         if (_decoder->_antList[ii].height_f) {
    657           QByteArray ant4 = QString("%1 ").arg(_decoder->_antList[ii].height,0,'f',4).toAscii();
     670        if (decoder()->_antList[ii].height_f) {
     671          QByteArray ant4 = QString("%1 ").arg(decoder()->_antList[ii].height,0,'f',4).toAscii();
    658672          emit(newMessage(_staID + ": Antenna height above marker "  + ant4 + "m", true));
    659673        }
    660         emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
    661                        _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
     674        emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
     675                       decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
    662676                       antT));
    663677      }
     
    666680
    667681#ifdef MLS_SOFTWARE
    668   for (int ii=0; ii <_decoder->_antList.size(); ii++) {
     682  for (int ii=0; ii <decoder()->_antList.size(); ii++) {
    669683        QByteArray antT;
    670         if      (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
     684        if      (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
    671685          antT = "ARP";
    672686        }
    673         else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
     687        else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
    674688          antT = "APC";
    675689        }
    676         emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
    677                        _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
     690        emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
     691                       decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
    678692                       antT));
    679693  }
    680694
    681   for (int ii = 0; ii <_decoder->_typeList.size(); ii++) {
    682     emit(newRTCMMessage(_staID, _decoder->_typeList[ii]));
     695  for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
     696    emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
    683697  }
    684698#endif
     
    687701
    688702
    689   _decoder->_typeList.clear();
    690   _decoder->_antType.clear();
    691   _decoder->_antList.clear();
     703  decoder()->_typeList.clear();
     704  decoder()->_antType.clear();
     705  decoder()->_antList.clear();
    692706}
    693707
     
    722736//////////////////////////////////////////////////////////////////////////////
    723737void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
    724   RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(_decoder);
    725   RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(_decoder);
     738  RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(decoder());
     739  RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(decoder());
    726740
    727741  if ( decoder2 ) {
Note: See TracChangeset for help on using the changeset viewer.