Changeset 6449 in ntrip for trunk/BNC/src
- Timestamp:
- Dec 26, 2014, 5:20:19 PM (10 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bnccaster.cpp
r6447 r6449 112 112 } 113 113 114 _epochs = new QMultiMap<long, t_satObs>;115 116 114 _samplingRate = settings.value("binSampl").toInt(); 117 _waitTime = settings.value("waitTime").toInt(); 118 _lastDumpSec = 0; 115 _waitTime = settings.value("waitTime").toDouble(); 116 if (_waitTime <= 0.0) { 117 _waitTime = 0.01; 118 } 119 119 _confInterval = -1; 120 120 … … 156 156 delete _nmeaServer; 157 157 delete _nmeaSockets; 158 delete _epochs;159 158 delete _miscServer; 160 159 delete _miscSockets; … … 175 174 t_satObs& obs = it.next(); 176 175 177 long iSec = long(floor(obs._time.gpssec()+0.5));178 long newTime = obs._time.gpsw() * 7*24*3600 + iSec;179 180 176 // Rename the Station 181 177 // ------------------ … … 212 208 } 213 209 214 // First time , set the _lastDumpSec immediately215 // --------------------------------- -----------216 if ( _lastDumpSec == 0) {217 _lastDump Sec = newTime - 1;210 // First time: set the _lastDumpTime 211 // --------------------------------- 212 if (!_lastDumpTime.valid()) { 213 _lastDumpTime = obs._time - 1.0; 218 214 } 219 215 220 216 // An old observation - throw it away 221 217 // ---------------------------------- 222 if ( newTime <= _lastDumpSec) {218 if (obs._time <= _lastDumpTime) { 223 219 if (index == 1) { 224 220 bncSettings settings; 225 221 if ( !settings.value("outFile").toString().isEmpty() || 226 222 !settings.value("outPort").toString().isEmpty() ) { 227 228 QTime enomtime = QTime(0,0,0).addSecs(iSec);229 230 223 emit( newMessage(QString("%1: Old epoch %2 (%3) thrown away") 231 .arg(staID.data()).arg(iSec) 232 .arg(enomtime.toString("HH:mm:ss")) 224 .arg(staID.data()).arg(string(obs._time).c_str()) 233 225 .toAscii(), true) ); 234 226 } … … 239 231 // Save the observation 240 232 // -------------------- 241 _epochs ->insert(newTime,obs);233 _epochs[obs._time].push_back(obs); 242 234 243 235 // Dump Epochs 244 236 // ----------- 245 if ( newTime - _waitTime > _lastDumpSec) {246 dumpEpochs( _lastDumpSec + 1, newTime - _waitTime);247 _lastDump Sec = newTime - _waitTime;237 if (obs._time - _waitTime > _lastDumpTime) { 238 dumpEpochs(obs._time - _waitTime); 239 _lastDumpTime = obs._time - _waitTime; 248 240 } 249 241 } … … 324 316 // Dump Complete Epochs 325 317 //////////////////////////////////////////////////////////////////////////// 326 void bncCaster::dumpEpochs(long minTime, long maxTime) { 327 328 for (long sec = minTime; sec <= maxTime; sec++) { 329 330 if ( (_out || _sockets) && 331 (_samplingRate == 0 || sec % _samplingRate == 0) ) { 332 333 QList<t_satObs> allObs = _epochs->values(sec); 318 void bncCaster::dumpEpochs(const bncTime& maxTime) { 319 320 QMutableMapIterator<bncTime, QList<t_satObs> > itEpo(_epochs); 321 while (itEpo.hasNext()) { 322 itEpo.next(); 323 const bncTime& epoTime = itEpo.key(); 324 if (epoTime <= maxTime) { 325 const QList<t_satObs>& allObs = itEpo.value(); 326 int sec = int(nint(epoTime.gpssec())); 327 if ( (_out || _sockets) && (_samplingRate == 0 || sec % _samplingRate == 0) ) { 334 328 335 QListIterator<t_satObs> it(allObs); 336 bool firstObs = true; 337 while (it.hasNext()) { 338 const t_satObs& obs = it.next(); 339 340 ostringstream oStr; 341 oStr.setf(ios::showpoint | ios::fixed); 342 if (firstObs) { 343 firstObs = false; 344 oStr << "> " << obs._time.gpsw() << ' ' 345 << setprecision(7) << obs._time.gpssec() << endl;; 346 } 347 oStr << obs._staID << ' ' << bncRinex::asciiSatLine(obs) << endl; 348 if (!it.hasNext()) { 349 oStr << endl; 350 } 351 string hlpStr = oStr.str(); 352 353 // Output into the File 354 // -------------------- 355 if (_out) { 356 *_out << hlpStr.c_str(); 357 _out->flush(); 358 } 359 360 // Output into the socket 361 // ---------------------- 362 if (_sockets) { 363 QMutableListIterator<QTcpSocket*> is(*_sockets); 364 while (is.hasNext()) { 365 QTcpSocket* sock = is.next(); 366 if (sock->state() == QAbstractSocket::ConnectedState) { 367 int numBytes = hlpStr.length(); 368 if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) { 329 QListIterator<t_satObs> it(allObs); 330 bool firstObs = true; 331 while (it.hasNext()) { 332 const t_satObs& obs = it.next(); 333 334 ostringstream oStr; 335 oStr.setf(ios::showpoint | ios::fixed); 336 if (firstObs) { 337 firstObs = false; 338 oStr << "> " << obs._time.gpsw() << ' ' 339 << setprecision(7) << obs._time.gpssec() << endl;; 340 } 341 oStr << obs._staID << ' ' << bncRinex::asciiSatLine(obs) << endl; 342 if (!it.hasNext()) { 343 oStr << endl; 344 } 345 string hlpStr = oStr.str(); 346 347 // Output into the File 348 // -------------------- 349 if (_out) { 350 *_out << hlpStr.c_str(); 351 _out->flush(); 352 } 353 354 // Output into the socket 355 // ---------------------- 356 if (_sockets) { 357 QMutableListIterator<QTcpSocket*> is(*_sockets); 358 while (is.hasNext()) { 359 QTcpSocket* sock = is.next(); 360 if (sock->state() == QAbstractSocket::ConnectedState) { 361 int numBytes = hlpStr.length(); 362 if (myWrite(sock, hlpStr.c_str(), numBytes) != numBytes) { 363 delete sock; 364 is.remove(); 365 } 366 } 367 else if (sock->state() != QAbstractSocket::ConnectingState) { 369 368 delete sock; 370 369 is.remove(); 371 370 } 372 371 } 373 else if (sock->state() != QAbstractSocket::ConnectingState) {374 delete sock;375 is.remove();376 }377 372 } 378 373 } 379 374 } 380 }381 _epochs->remove(sec);375 _epochs.remove(epoTime); 376 } 382 377 } 383 378 } -
trunk/BNC/src/bnccaster.h
r6447 r6449 63 63 64 64 private: 65 void dumpEpochs( long minTime, longmaxTime);65 void dumpEpochs(const bncTime& maxTime); 66 66 static int myWrite(QTcpSocket* sock, const char* buf, int bufLen); 67 67 void reopenOutFile(); 68 68 69 QFile* _outFile;70 QTextStream* _out;71 QM ultiMap<long, t_satObs>*_epochs;72 long _lastDumpSec;73 QTcpServer* _server;74 QTcpServer* _uServer;75 QTcpServer* _nmeaServer;76 QList<QTcpSocket*>* _sockets;77 QList<QTcpSocket*>* _uSockets;78 QList<QTcpSocket*>* _nmeaSockets;79 QList<QByteArray> _staIDs;80 QList<bncGetThread*> _threads;81 int _samplingRate;82 long_waitTime;83 QMutex _mutex;84 int _confInterval;85 QString _miscMount;86 int _miscPort;87 QTcpServer* _miscServer;88 QList<QTcpSocket*>* _miscSockets;69 QFile* _outFile; 70 QTextStream* _out; 71 QMap<bncTime, QList<t_satObs> > _epochs; 72 bncTime _lastDumpTime; 73 QTcpServer* _server; 74 QTcpServer* _uServer; 75 QTcpServer* _nmeaServer; 76 QList<QTcpSocket*>* _sockets; 77 QList<QTcpSocket*>* _uSockets; 78 QList<QTcpSocket*>* _nmeaSockets; 79 QList<QByteArray> _staIDs; 80 QList<bncGetThread*> _threads; 81 int _samplingRate; 82 double _waitTime; 83 QMutex _mutex; 84 int _confInterval; 85 QString _miscMount; 86 int _miscPort; 87 QTcpServer* _miscServer; 88 QList<QTcpSocket*>* _miscSockets; 89 89 }; 90 90
Note:
See TracChangeset
for help on using the changeset viewer.