source: ntrip/trunk/BNC/bncgetthread.cpp@ 1556

Last change on this file since 1556 was 1556, checked in by mervart, 15 years ago

* empty log message *

File size: 24.2 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncGetThread
30 *
31 * Purpose: Thread that retrieves data from NTRIP caster
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Dec-2005
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <stdlib.h>
42#include <iomanip>
43#include <sstream>
44
45#include <QFile>
46#include <QTextStream>
47#include <QtNetwork>
48#include <QTime>
49
50#include "bncgetthread.h"
51#include "bnctabledlg.h"
52#include "bncapp.h"
53#include "bncutils.h"
54#include "bncrinex.h"
55#include "bnczerodecoder.h"
56#include "bncnetqueryv1.h"
57#include "bncnetqueryv2.h"
58#include "bncnetqueryrtp.h"
59#include "bncsettings.h"
60
61#include "RTCM/RTCM2Decoder.h"
62#include "RTCM3/RTCM3Decoder.h"
63#include "RTIGS/RTIGSDecoder.h"
64#include "GPSS/gpssDecoder.h"
65#include "serial/qextserialport.h"
66
67using namespace std;
68
69// Constructor 1
70////////////////////////////////////////////////////////////////////////////
71bncGetThread::bncGetThread(const QByteArray& rawInpFileName,
72 const QByteArray& format) {
73
74 _rawInpFile = new QFile(rawInpFileName);
75 _rawInpFile->open(QIODevice::ReadOnly);
76 _format = format;
77 _staID = rawInpFileName.mid(
78 rawInpFileName.lastIndexOf(QDir::separator())+1,4);
79
80 initialize();
81}
82
83// Constructor 2
84////////////////////////////////////////////////////////////////////////////
85bncGetThread::bncGetThread(const QUrl& mountPoint,
86 const QByteArray& format,
87 const QByteArray& latitude,
88 const QByteArray& longitude,
89 const QByteArray& nmea,
90 const QByteArray& ntripVersion, int iMount) {
91 _rawInpFile = 0;
92 _mountPoint = mountPoint;
93 _staID = mountPoint.path().mid(1).toAscii();
94 _format = format;
95 _latitude = latitude;
96 _longitude = longitude;
97 _nmea = nmea;
98 _ntripVersion = ntripVersion;
99 _iMount = iMount; // index in mountpoints array
100
101 initialize();
102}
103
104// Initialization (common part of the constructor)
105////////////////////////////////////////////////////////////////////////////
106void bncGetThread::initialize() {
107
108 setTerminationEnabled(true);
109
110 bncApp* app = (bncApp*) qApp;
111
112 connect(this, SIGNAL(newMessage(QByteArray,bool)),
113 app, SLOT(slotMessage(const QByteArray,bool)));
114
115 _isToBeDeleted = false;
116 _decoder = 0;
117 _query = 0;
118 _nextSleep = 0;
119 _rawOutFile = 0;
120 _staID_orig = _staID;
121
122 // Check name conflict
123 // -------------------
124 bncSettings settings;
125 QListIterator<QString> it(settings.value("mountPoints").toStringList());
126 int num = 0;
127 int ind = -1;
128 while (it.hasNext()) {
129 ++ind;
130 QStringList hlp = it.next().split(" ");
131 if (hlp.size() <= 1) continue;
132 QUrl url(hlp[0]);
133 if (_mountPoint.path() == url.path()) {
134 if (_iMount > ind || _iMount < 0) {
135 ++num;
136 }
137 }
138 }
139
140 if (num > 0) {
141 _staID = _staID.left(_staID.length()-1) + QString("%1").arg(num).toAscii();
142 }
143
144 // RINEX writer
145 // ------------
146 _samplingRate = settings.value("rnxSampl").toInt();
147 if ( settings.value("rnxPath").toString().isEmpty() ) {
148 _rnx = 0;
149 if (_rawInpFile) {
150 cerr << "no RINEX path specified" << endl;
151 ::exit(1);
152 }
153 }
154 else {
155 _rnx = new bncRinex(_staID, _mountPoint, _format, _latitude,
156 _longitude, _nmea);
157 }
158
159 // Serial Port
160 // -----------
161 if (settings.value("serialMountPoint").toString() == _staID) {
162 _serialPort = new QextSerialPort(
163 settings.value("serialPortName").toString() );
164 QString hlp = settings.value("serialBaudRate").toString();
165 if (hlp == "110") {
166 _serialPort->setBaudRate(BAUD110);
167 }
168 else if (hlp == "300") {
169 _serialPort->setBaudRate(BAUD300);
170 }
171 else if (hlp == "600") {
172 _serialPort->setBaudRate(BAUD600);
173 }
174 else if (hlp == "1200") {
175 _serialPort->setBaudRate(BAUD1200);
176 }
177 else if (hlp == "2400") {
178 _serialPort->setBaudRate(BAUD2400);
179 }
180 else if (hlp == "4800") {
181 _serialPort->setBaudRate(BAUD4800);
182 }
183 else if (hlp == "9600") {
184 _serialPort->setBaudRate(BAUD9600);
185 }
186 else if (hlp == "19200") {
187 _serialPort->setBaudRate(BAUD19200);
188 }
189 else if (hlp == "38400") {
190 _serialPort->setBaudRate(BAUD38400);
191 }
192 else if (hlp == "57600") {
193 _serialPort->setBaudRate(BAUD57600);
194 }
195 else if (hlp == "115200") {
196 _serialPort->setBaudRate(BAUD115200);
197 }
198 hlp = settings.value("serialParity").toString();
199 if (hlp == "NONE") {
200 _serialPort->setParity(PAR_NONE);
201 }
202 else if (hlp == "ODD") {
203 _serialPort->setParity(PAR_ODD);
204 }
205 else if (hlp == "EVEN") {
206 _serialPort->setParity(PAR_EVEN);
207 }
208 else if (hlp == "SPACE") {
209 _serialPort->setParity(PAR_SPACE);
210 }
211 hlp = settings.value("serialDataBits").toString();
212 if (hlp == "5") {
213 _serialPort->setDataBits(DATA_5);
214 }
215 else if (hlp == "6") {
216 _serialPort->setDataBits(DATA_6);
217 }
218 else if (hlp == "7") {
219 _serialPort->setDataBits(DATA_7);
220 }
221 else if (hlp == "8") {
222 _serialPort->setDataBits(DATA_8);
223 }
224 hlp = settings.value("serialStopBits").toString();
225 if (hlp == "1") {
226 _serialPort->setStopBits(STOP_1);
227 }
228 else if (hlp == "2") {
229 _serialPort->setStopBits(STOP_2);
230 }
231 _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
232 if (!_serialPort->isOpen()) {
233 delete _serialPort;
234 _serialPort = 0;
235 emit(newMessage((_staID + ": Cannot open serial port\n"), true));
236 }
237 }
238 else {
239 _serialPort = 0;
240 }
241
242 // Raw Output
243 // ----------
244 // QByteArray rawOutFileName = "./" + _staID + ".raw";
245 // _rawOutFile = new QFile(rawOutFileName);
246 // _rawOutFile->open(QIODevice::WriteOnly);
247
248
249 // Instantiate the decoder
250 // -----------------------
251 if (_format.indexOf("RTCM_2") != -1) {
252 emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
253 _decoder = new RTCM2Decoder(_staID.data());
254 }
255 else if (_format.indexOf("RTCM_3") != -1) {
256 emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
257 _decoder = new RTCM3Decoder(_staID);
258 connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray,bool)),
259 this, SIGNAL(newMessage(QByteArray,bool)));
260 }
261 else if (_format.indexOf("RTIGS") != -1) {
262 emit(newMessage(_staID + ": Get data in RTIGS format", true));
263 _decoder = new RTIGSDecoder();
264 }
265 else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
266 emit(newMessage(_staID + ": Get Data in GPSS format", true));
267 _decoder = new gpssDecoder();
268 }
269 else if (_format.indexOf("ZERO") != -1) {
270 emit(newMessage(_staID + ": Get data in original format", true));
271 _decoder = new bncZeroDecoder(_staID);
272 }
273 else {
274 emit(newMessage(_staID + ": Unknown data format " + _format, true));
275 _isToBeDeleted = true;
276 delete this;
277 }
278
279 msleep(100); //sleep 0.1 sec
280}
281
282// Destructor
283////////////////////////////////////////////////////////////////////////////
284bncGetThread::~bncGetThread() {
285 if (_query) {
286 _query->stop();
287 delete _query;
288 }
289 delete _decoder;
290 delete _rnx;
291 delete _rawInpFile;
292 delete _rawOutFile;
293 delete _serialPort;
294 emit getThreadFinished(_staID);
295}
296
297//
298////////////////////////////////////////////////////////////////////////////
299void bncGetThread::terminate() {
300 _isToBeDeleted = true;
301}
302
303// Run
304////////////////////////////////////////////////////////////////////////////
305void bncGetThread::run() {
306
307 while (true) {
308 try {
309 if (_isToBeDeleted) {
310 QThread::exit(0);
311 this->deleteLater();
312 return;
313 }
314
315 if (tryReconnect() != success) {
316 continue;
317 }
318
319 // Delete old observations
320 // -----------------------
321 QListIterator<p_obs> itOld(_decoder->_obsList);
322 while (itOld.hasNext()) {
323 delete itOld.next();
324 }
325 _decoder->_obsList.clear();
326
327 // Read Data
328 // ---------
329 QByteArray data;
330 if (_query) {
331 _query->waitForReadyRead(data);
332 }
333 else if (_rawInpFile) {
334 const qint64 maxBytes = 1024;
335 data = _rawInpFile->read(maxBytes);
336 if (data.isEmpty()) {
337 cout << "no more data" << endl;
338 ::exit(0);
339 }
340 }
341 qint64 nBytes = data.size();
342
343 // Timeout, reconnect
344 // ------------------
345 if (nBytes == 0) {
346 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
347 continue;
348 }
349 else {
350 emit newBytes(_staID, nBytes);
351 }
352
353 // Output Data
354 // -----------
355 if (_rawOutFile) {
356 _rawOutFile->write(data);
357 _rawOutFile->flush();
358 }
359 if (_serialPort) {
360 _serialPort->write(data);
361 }
362
363 // Decode Data
364 // -----------
365 vector<string> errmsg;
366 _decoder->Decode(data.data(), data.size(), errmsg);
367
368 // Perform various scans and checks
369 // --------------------------------
370 scanRTCM();
371 checkLatency();
372
373 // Loop over all observations (observations output)
374 // ------------------------------------------------
375 QListIterator<p_obs> it(_decoder->_obsList);
376 while (it.hasNext()) {
377 p_obs obs = it.next();
378
379 // Check observation epoch
380 // -----------------------
381 if (!_rawInpFile && !dynamic_cast<gpssDecoder*>(_decoder)) {
382 int week;
383 double sec;
384 currentGPSWeeks(week, sec);
385 const double secPerWeek = 7.0 * 24.0 * 3600.0;
386
387 if (week < obs->_o.GPSWeek) {
388 week += 1;
389 sec -= secPerWeek;
390 }
391 if (week > obs->_o.GPSWeek) {
392 week -= 1;
393 sec += secPerWeek;
394 }
395 double dt = fabs(sec - obs->_o.GPSWeeks);
396 const double maxDt = 600.0;
397 if (week != obs->_o.GPSWeek || dt > maxDt) {
398 emit( newMessage(_staID + ": Wrong observation epoch(s)", true) );
399 delete obs;
400 continue;
401 }
402 }
403
404 // RINEX Output
405 // ------------
406 if (_rnx) {
407 long iSec = long(floor(obs->_o.GPSWeeks+0.5));
408 long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
409 if (_samplingRate == 0 || iSec % _samplingRate == 0) {
410 _rnx->deepCopy(obs);
411 }
412 _rnx->dumpEpoch(newTime);
413 }
414
415 // Emit new observation signal
416 // ---------------------------
417 bool firstObs = (obs == _decoder->_obsList.first());
418 obs->_status = t_obs::posted;
419 emit newObs(_staID, firstObs, obs);
420 }
421 _decoder->_obsList.clear();
422 }
423 catch (const char* msg) {
424 emit(newMessage(_staID + msg, true));
425 tryReconnect();
426 }
427 catch (...) {
428 emit(newMessage(_staID + "unknown exception", true));
429 tryReconnect();
430 }
431 }
432}
433
434// Try Re-Connect
435////////////////////////////////////////////////////////////////////////////
436t_irc bncGetThread::tryReconnect() {
437
438 // Easy Return
439 // -----------
440 if (_query && _query->status() == bncNetQuery::running) {
441 _nextSleep = 0;
442 return success;
443 }
444
445 // Start a new query
446 // -----------------
447 if (!_rawInpFile) {
448
449 sleep(_nextSleep);
450 if (_nextSleep == 0) {
451 _nextSleep = 1;
452 }
453 else {
454 _nextSleep = 2 * _nextSleep;
455 if (_nextSleep > 256) {
456 _nextSleep = 256;
457 }
458 }
459
460 delete _query;
461 if (_ntripVersion == "R") {
462 _query = new bncNetQueryRtp();
463 }
464 else if (_ntripVersion == "2") {
465 _query = new bncNetQueryV2();
466 }
467 else {
468 _query = new bncNetQueryV1();
469 }
470 if (_nmea == "yes") {
471 QByteArray gga = ggaString(_latitude, _longitude);
472 _query->startRequest(_mountPoint, gga);
473 }
474 else {
475 _query->startRequest(_mountPoint, "");
476 }
477 if (_query->status() != bncNetQuery::running) {
478 return failure;
479 }
480 }
481
482 if (_rnx) {
483 _rnx->setReconnectFlag(true);
484 }
485
486 return success;
487}
488
489// RTCM scan output
490//////////////////////////////////////////////////////////////////////////////
491void bncGetThread::scanRTCM() {
492
493 bncSettings settings;
494 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked) {
495
496 // RTCMv3 message types
497 // --------------------
498 for (int ii = 0; ii <_decoder->_typeList.size(); ii++) {
499 QString type = QString("%1 ").arg(_decoder->_typeList[ii]);
500 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
501 }
502
503 // RTCMv3 antenna descriptor
504 // -------------------------
505 for (int ii=0;ii<_decoder->_antType.size();ii++) {
506 QString ant1 = QString("%1 ").arg(_decoder->_antType[ii]);
507 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
508 }
509
510 // Antenna Coordinates
511 // -------------------
512 for (int ii=0; ii <_decoder->_antList.size(); ii++) {
513 QByteArray antT;
514 if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
515 antT = "ARP";
516 }
517 else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
518 antT = "APC";
519 }
520 emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
521 _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
522 antT));
523 }
524 }
525
526 _decoder->_typeList.clear();
527 _decoder->_antType.clear();
528 _decoder->_antList.clear();
529}
530
531//
532//////////////////////////////////////////////////////////////////////////////
533void bncGetThread::checkLatency() {
534//// // Notice threshold
535//// // ----------------
536//// _inspSegm = 50;
537//// if ( settings.value("obsRate").toString().isEmpty() ) { _inspSegm = 0; }
538//// if ( settings.value("obsRate").toString().indexOf("5 Hz") != -1 ) { _inspSegm = 2; }
539//// if ( settings.value("obsRate").toString().indexOf("1 Hz") != -1 ) { _inspSegm = 10; }
540//// if ( settings.value("obsRate").toString().indexOf("0.5 Hz") != -1 ) { _inspSegm = 20; }
541//// if ( settings.value("obsRate").toString().indexOf("0.2 Hz") != -1 ) { _inspSegm = 40; }
542//// if ( settings.value("obsRate").toString().indexOf("0.1 Hz") != -1 ) { _inspSegm = 50; }
543//// _adviseFail = settings.value("adviseFail").toInt();
544//// _adviseReco = settings.value("adviseReco").toInt();
545//// _makePause = false;
546//// if ( Qt::CheckState(settings.value("makePause").toInt()) == Qt::Checked) {_makePause = true; }
547//// _adviseScript = settings.value("adviseScript").toString();
548//// expandEnvVar(_adviseScript);
549////
550//// // Latency interval/average
551//// // ------------------------
552//// _perfIntr = 86400;
553//// if ( settings.value("perfIntr").toString().isEmpty() ) { _perfIntr = 0; }
554//// if ( settings.value("perfIntr").toString().indexOf("2 sec") != -1 ) { _perfIntr = 2; }
555//// if ( settings.value("perfIntr").toString().indexOf("10 sec") != -1 ) { _perfIntr = 10; }
556//// if ( settings.value("perfIntr").toString().indexOf("1 min") != -1 ) { _perfIntr = 60; }
557//// if ( settings.value("perfIntr").toString().indexOf("5 min") != -1 ) { _perfIntr = 300; }
558//// if ( settings.value("perfIntr").toString().indexOf("15 min") != -1 ) { _perfIntr = 900; }
559//// if ( settings.value("perfIntr").toString().indexOf("1 hour") != -1 ) { _perfIntr = 3600; }
560//// if ( settings.value("perfIntr").toString().indexOf("6 hours") != -1 ) { _perfIntr = 21600; }
561//// if ( settings.value("perfIntr").toString().indexOf("1 day") != -1 ) { _perfIntr = 86400; }
562////
563//// // RTCM message types
564//// // ------------------
565//// _checkMountPoint = settings.value("miscMount").toString();
566////
567////
568//// const double maxDt = 600.0; // Check observation epoch
569//// bool wrongEpoch = false;
570//// bool decode = true;
571//// int numSucc = 0;
572//// int secSucc = 0;
573//// int secFail = 0;
574//// int initPause = 30; // Initial pause for corrupted streams
575//// int currPause = 0;
576//// bool begCorrupt = false;
577//// bool endCorrupt = false;
578//// bool followSec = false;
579//// int oldSecGPS= 0;
580//// int newSecGPS = 0;
581//// int numGaps = 0;
582//// int diffSecGPS = 0;
583//// int numLat = 0;
584//// double sumLat = 0.;
585//// double sumLatQ = 0.;
586//// double meanDiff = 0.;
587//// double minLat = maxDt;
588//// double maxLat = -maxDt;
589//// double curLat = 0.;
590////
591////
592//// _decodeTime = QDateTime::currentDateTime();
593//// _decodeSucc = QDateTime::currentDateTime();
594////
595//// // Check - once per inspect segment
596//// // --------------------------------
597//// if (!decode) {
598//// _decodeTime = QDateTime::currentDateTime();
599//// if (numSucc>0) {
600//// secSucc += _inspSegm;
601//// _decodeSucc = QDateTime::currentDateTime();
602//// if (secSucc > _adviseReco * 60) {
603//// secSucc = _adviseReco * 60 + 1;
604//// }
605//// numSucc = 0;
606//// currPause = initPause;
607//// _decodePause.setDate(QDate());
608//// _decodePause.setTime(QTime());
609//// }
610//// else {
611//// secFail += _inspSegm;
612//// secSucc = 0;
613//// if (secFail > _adviseFail * 60) {
614//// secFail = _adviseFail * 60 + 1;
615//// }
616//// if (!_decodePause.isValid() || !_makePause) {
617//// _decodePause = QDateTime::currentDateTime();
618//// }
619//// else {
620//// _decodePause.setDate(QDate());
621//// _decodePause.setTime(QTime());
622//// secFail = secFail + currPause - _inspSegm;
623//// currPause = currPause * 2;
624//// if (currPause > 960) {
625//// currPause = 960;
626//// }
627//// }
628//// }
629////
630//// // End corrupt threshold
631//// // ---------------------
632//// if ( begCorrupt && !endCorrupt && secSucc > _adviseReco * 60 ) {
633//// _endDateCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
634//// _endTimeCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
635//// emit(newMessage((_staID + ": Recovery threshold exceeded, corruption ended "
636//// + _endDateCor + " " + _endTimeCor).toAscii(), true));
637//// callScript(("End_Corrupted " + _endDateCor + " " + _endTimeCor + " Begin was " + _begDateCor + " " + _begTimeCor).toAscii());
638//// endCorrupt = true;
639//// begCorrupt = false;
640//// secFail = 0;
641//// }
642//// else {
643////
644//// // Begin corrupt threshold
645//// // -----------------------
646//// if ( !begCorrupt && secFail > _adviseFail * 60 ) {
647//// _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
648//// _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
649//// emit(newMessage((_staID + ": Failure threshold exceeded, corrupted since "
650//// + _begDateCor + " " + _begTimeCor).toAscii(), true));
651//// callScript(("Begin_Corrupted " + _begDateCor + " " + _begTimeCor).toAscii());
652//// begCorrupt = true;
653//// endCorrupt = false;
654//// secSucc = 0;
655//// numSucc = 0;
656//// }
657//// }
658//// decode = true;
659//// }
660//// }
661//// }
662////
663//// // End outage threshold
664//// // --------------------
665//// if ( _decodeStart.isValid() && _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
666//// _decodeStart.setDate(QDate());
667//// _decodeStart.setTime(QTime());
668//// if (_inspSegm>0) {
669//// _endDateOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
670//// _endTimeOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
671//// emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended "
672//// + _endDateOut + " " + _endTimeOut).toAscii(), true));
673//// callScript(("End_Outage " + _endDateOut + " " + _endTimeOut + " Begin was " + _begDateOut + " " + _begTimeOut).toAscii());
674//// }
675//// }
676////
677//// else {
678//// wrongEpoch = false;
679////
680//// // Latency and completeness
681//// // ------------------------
682//// if (_perfIntr>0) {
683//// if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
684//// newSecGPS = static_cast<int>(obs->_o.GPSWeeks);
685//// if (newSecGPS != oldSecGPS) {
686//// if (newSecGPS % _perfIntr < oldSecGPS % _perfIntr) {
687//// if (numLat>0) {
688//// if (meanDiff>0.) {
689//// emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
690//// .arg(_staID.data())
691//// .arg(int(sumLat/numLat*100)/100.)
692//// .arg(int(minLat*100)/100.)
693//// .arg(int(maxLat*100)/100.)
694//// .arg(int((sqrt((sumLatQ - sumLat * sumLat / numLat)/numLat))*100)/100.)
695//// .arg(numLat)
696//// .arg(numGaps)
697//// .toAscii(), true) );
698//// } else {
699//// emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
700//// .arg(_staID.data())
701//// .arg(int(sumLat/numLat*100)/100.)
702//// .arg(int(minLat*100)/100.)
703//// .arg(int(maxLat*100)/100.)
704//// .arg(int((sqrt((sumLatQ - sumLat * sumLat / numLat)/numLat))*100)/100.)
705//// .arg(numLat)
706//// .toAscii(), true) );
707//// }
708//// }
709//// meanDiff = diffSecGPS/numLat;
710//// diffSecGPS = 0;
711//// numGaps = 0;
712//// sumLat = 0.;
713//// sumLatQ = 0.;
714//// numLat = 0;
715//// minLat = maxDt;
716//// maxLat = -maxDt;
717//// }
718//// if (followSec) {
719//// diffSecGPS += newSecGPS - oldSecGPS;
720//// if (meanDiff>0.) {
721//// if (newSecGPS - oldSecGPS > 1.5 * meanDiff) {
722//// numGaps += 1;
723//// }
724//// }
725//// }
726//// curLat = sec - obs->_o.GPSWeeks;
727//// sumLat += curLat;
728//// sumLatQ += curLat * curLat;
729//// if (curLat < minLat) minLat = curLat;
730//// if (curLat >= maxLat) maxLat = curLat;
731//// numLat += 1;
732//// oldSecGPS = newSecGPS;
733//// followSec = true;
734//// }
735//// }
736//// }
737////
738}
Note: See TracBrowser for help on using the repository browser.