Changeset 3203 in ntrip


Ignore:
Timestamp:
Mar 30, 2011, 4:49:50 PM (13 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/upload
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/upload/bncrtnetdecoder.cpp

    r3187 r3203  
    4949////////////////////////////////////////////////////////////////////////
    5050bncRtnetDecoder::bncRtnetDecoder() {
     51}
     52
     53// Destructor
     54////////////////////////////////////////////////////////////////////////
     55bncRtnetDecoder::~bncRtnetDecoder() {
     56  for (int ic = 0; ic < _casters->size(); ic++) {
     57    delete _casters->at(ic);
     58  }
     59  delete _casters;
     60}
     61
     62// Run
     63////////////////////////////////////////////////////////////////////////
     64void bncRtnetDecoder::run() {
    5165
    5266  bncSettings settings;
     
    5468  // List of upload casters
    5569  // ----------------------
     70  _casters = new QVector<bncUploadCaster*>;
    5671  QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
    5772  while (it.hasNext()) {
     
    6075      int  outPort = hlp[1].toInt();
    6176      bool CoM     = (hlp[5].toInt() == Qt::Checked);
    62       _caster.push_back(new bncUploadCaster(hlp[2], hlp[0], outPort,
    63                                             hlp[3], hlp[4], CoM,
    64                                             hlp[6], "", ""));
     77      _casters->push_back(new bncUploadCaster(hlp[2], hlp[0], outPort,
     78                                             hlp[3], hlp[4], CoM,
     79                                             hlp[6], "", ""));
    6580    }
    6681  }
    67 }
    6882
    69 // Destructor
    70 ////////////////////////////////////////////////////////////////////////
    71 bncRtnetDecoder::~bncRtnetDecoder() {
    72   for (int ic = 0; ic < _caster.size(); ic++) {
    73     delete _caster[ic];
     83  // Endless Loop - Decode
     84  // ---------------------
     85  while (true) {
     86    DecodeInThread();
     87    msleep(10);
    7488  }
    75 }
    76 
    77 //
    78 ////////////////////////////////////////////////////////////////////////
    79 void bncRtnetDecoder::readEpochTime(const QString& line) {
    80   QTextStream in(line.toAscii());
    81   QString hlp;
    82   int     year, month, day, hour, min;
    83   double  sec;
    84   in >> hlp >> year >> month >> day >> hour >> min >> sec;
    85   _epoTime.set( year, month, day, hour, min, sec);
    8689}
    8790
     
    8992////////////////////////////////////////////////////////////////////////
    9093t_irc bncRtnetDecoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
    91 
     94  QMutexLocker locker(&_mutex);
    9295  errmsg.clear();
    9396  _buffer.append(QByteArray(buffer, bufLen));
     97  return success;
     98}
     99
     100// Decode and upload in separate thread
     101////////////////////////////////////////////////////////////////////////
     102void bncRtnetDecoder::DecodeInThread() {
     103  QMutexLocker locker(&_mutex);
    94104
    95105  // Prepare list of lines with satellite positions in SP3-like format
     
    102112    for (int ii = 0; ii < hlpLines.size(); ii++) {
    103113      if      (hlpLines[ii].indexOf('*') != -1) {
    104         readEpochTime(hlpLines[ii]);
     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);
    105120      }
    106121      else if (_epoTime.valid()) {
     
    113128  // -----------------------------------
    114129  if (lines.size() > 0) {
    115     for (int ic = 0; ic < _caster.size(); ic++) {
    116       _caster[ic]->uploadClockOrbitBias(_epoTime, _eph, lines);
     130    for (int ic = 0; ic < _casters->size(); ic++) {
     131      _casters->at(ic)->uploadClockOrbitBias(_epoTime, _eph, lines);
    117132    }
    118133  }
    119 
    120   return success;
    121134}
    122135
  • trunk/BNC/upload/bncrtnetdecoder.h

    r3187 r3203  
    3333#include "RTCM/GPSDecoder.h"
    3434
    35 class bncRtnetDecoder: public GPSDecoder, public bncEphUser {
     35class bncRtnetDecoder: public GPSDecoder, public bncEphUser, public QThread {
    3636 public:
    3737  bncRtnetDecoder();
    3838  ~bncRtnetDecoder();
    39   virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
     39  virtual void run();
     40  virtual t_irc Decode(char* buffer, int bufLen,
     41                       std::vector<std::string>& errmsg);
    4042 private:
    41   void readEpochTime(const QString& line);
    42   QVector<bncUploadCaster*> _caster;
    43   QString                   _buffer;
    44   bncTime                   _epoTime;
     43  void DecodeInThread();
     44  QVector<bncUploadCaster*>* _casters;
     45  QString                    _buffer;
     46  bncTime                    _epoTime;
     47  QMutex                     _mutex;
    4548};
    4649
Note: See TracChangeset for help on using the changeset viewer.