[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[82] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[82] | 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncApp
|
---|
| 30 | *
|
---|
| 31 | * Purpose: This class implements the main application
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 29-Aug-2006
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[1029] | 41 | #include <iostream>
|
---|
[150] | 42 | #include <QMessageBox>
|
---|
[519] | 43 | #include <cmath>
|
---|
[82] | 44 |
|
---|
| 45 | #include "bncapp.h"
|
---|
[151] | 46 | #include "bncutils.h"
|
---|
[647] | 47 | #include "bncrinex.h"
|
---|
[1535] | 48 | #include "bncsettings.h"
|
---|
[2011] | 49 | #include "bncversion.h"
|
---|
[82] | 50 |
|
---|
[2899] | 51 | #ifdef USE_COMBINATION
|
---|
| 52 | #include "combination/bnccomb.h"
|
---|
| 53 | #endif
|
---|
| 54 |
|
---|
[82] | 55 | using namespace std;
|
---|
| 56 |
|
---|
| 57 | // Constructor
|
---|
| 58 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1291] | 59 | bncApp::bncApp(int& argc, char* argv[], bool GUIenabled) :
|
---|
[82] | 60 | QApplication(argc, argv, GUIenabled) {
|
---|
[109] | 61 |
|
---|
[150] | 62 | _logFileFlag = 0;
|
---|
| 63 | _logFile = 0;
|
---|
| 64 | _logStream = 0;
|
---|
[621] | 65 | _caster = 0;
|
---|
[2519] | 66 | _rawFile = 0;
|
---|
[2922] | 67 | #ifdef USE_COMBINATION
|
---|
| 68 | _bncComb = 0;
|
---|
| 69 | #endif
|
---|
[152] | 70 |
|
---|
[516] | 71 | // Lists of Ephemeris
|
---|
| 72 | // ------------------
|
---|
| 73 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 74 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
| 75 | }
|
---|
| 76 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 77 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
| 78 | }
|
---|
[2770] | 79 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 80 | _galileoEph[ii-PRN_GALILEO_START] = 0;
|
---|
| 81 | }
|
---|
[516] | 82 |
|
---|
[533] | 83 | // Eph file(s)
|
---|
| 84 | // -----------
|
---|
[534] | 85 | _rinexVers = 0;
|
---|
[533] | 86 | _ephFileGPS = 0;
|
---|
| 87 | _ephStreamGPS = 0;
|
---|
| 88 | _ephFileGlonass = 0;
|
---|
| 89 | _ephStreamGlonass = 0;
|
---|
[2770] | 90 | _ephFileGalileo = 0;
|
---|
| 91 | _ephStreamGalileo = 0;
|
---|
[559] | 92 |
|
---|
[591] | 93 | _port = 0;
|
---|
[589] | 94 | _server = 0;
|
---|
| 95 | _sockets = 0;
|
---|
| 96 |
|
---|
[937] | 97 | _portCorr = 0;
|
---|
| 98 | _serverCorr = 0;
|
---|
| 99 | _socketsCorr = 0;
|
---|
| 100 |
|
---|
[2011] | 101 | _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
|
---|
[559] | 102 | #ifdef WIN32
|
---|
| 103 | _userName = QString("${USERNAME}");
|
---|
| 104 | #else
|
---|
| 105 | _userName = QString("${USER}");
|
---|
| 106 | #endif
|
---|
| 107 | expandEnvVar(_userName);
|
---|
| 108 | _userName = _userName.leftJustified(20, ' ', true);
|
---|
[973] | 109 |
|
---|
| 110 | _lastDumpCoSec = 0;
|
---|
[975] | 111 |
|
---|
| 112 | _corrs = new QMultiMap<long, QString>;
|
---|
[1155] | 113 |
|
---|
| 114 | _currentDateAndTimeGPS = 0;
|
---|
[2673] | 115 |
|
---|
| 116 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
|
---|
| 117 | _GLOFreq[ii] = 0;
|
---|
| 118 | }
|
---|
[3027] | 119 |
|
---|
| 120 | _bncPPPclient = 0;
|
---|
[82] | 121 | }
|
---|
| 122 |
|
---|
| 123 | // Destructor
|
---|
| 124 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 125 | bncApp::~bncApp() {
|
---|
[109] | 126 | delete _logStream;
|
---|
| 127 | delete _logFile;
|
---|
[533] | 128 | delete _ephStreamGPS;
|
---|
| 129 | delete _ephFileGPS;
|
---|
[589] | 130 | delete _server;
|
---|
| 131 | delete _sockets;
|
---|
[937] | 132 | delete _serverCorr;
|
---|
| 133 | delete _socketsCorr;
|
---|
[534] | 134 | if (_rinexVers == 2) {
|
---|
[533] | 135 | delete _ephStreamGlonass;
|
---|
| 136 | delete _ephFileGlonass;
|
---|
| 137 | }
|
---|
[516] | 138 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 139 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
| 140 | }
|
---|
| 141 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 142 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
| 143 | }
|
---|
[2770] | 144 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 145 | delete _galileoEph[ii-PRN_GALILEO_START];
|
---|
| 146 | }
|
---|
[975] | 147 |
|
---|
| 148 | delete _corrs;
|
---|
[1156] | 149 |
|
---|
| 150 | delete _currentDateAndTimeGPS;
|
---|
[2385] | 151 |
|
---|
[2519] | 152 | delete _rawFile;
|
---|
[2865] | 153 |
|
---|
[2899] | 154 | #ifdef USE_COMBINATION
|
---|
[2865] | 155 | delete _bncComb;
|
---|
[2899] | 156 | #endif
|
---|
[82] | 157 | }
|
---|
| 158 |
|
---|
| 159 | // Write a Program Message
|
---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1383] | 161 | void bncApp::slotMessage(QByteArray msg, bool showOnScreen) {
|
---|
[150] | 162 |
|
---|
[1218] | 163 | QMutexLocker locker(&_mutexMessage);
|
---|
[243] | 164 |
|
---|
[990] | 165 | messagePrivate(msg);
|
---|
[1299] | 166 | emit newMessage(msg, showOnScreen);
|
---|
[990] | 167 | }
|
---|
| 168 |
|
---|
| 169 | // Write a Program Message (private, no lock)
|
---|
| 170 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 171 | void bncApp::messagePrivate(const QByteArray& msg) {
|
---|
| 172 |
|
---|
[150] | 173 | // First time resolve the log file name
|
---|
| 174 | // ------------------------------------
|
---|
[1549] | 175 | QDate currDate = currentDateAndTimeGPS().date();
|
---|
| 176 | if (_logFileFlag == 0 || _fileDate != currDate) {
|
---|
[3034] | 177 | delete _logStream; _logStream = 0;
|
---|
| 178 | delete _logFile; _logFile = 0;
|
---|
[150] | 179 | _logFileFlag = 1;
|
---|
[1535] | 180 | bncSettings settings;
|
---|
[150] | 181 | QString logFileName = settings.value("logFile").toString();
|
---|
| 182 | if ( !logFileName.isEmpty() ) {
|
---|
[151] | 183 | expandEnvVar(logFileName);
|
---|
[1549] | 184 | _logFile = new QFile(logFileName + "_" +
|
---|
| 185 | currDate.toString("yyMMdd").toAscii().data());
|
---|
| 186 | _fileDate = currDate;
|
---|
[275] | 187 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 188 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 189 | }
|
---|
| 190 | else {
|
---|
| 191 | _logFile->open(QIODevice::WriteOnly);
|
---|
| 192 | }
|
---|
[150] | 193 | _logStream = new QTextStream();
|
---|
| 194 | _logStream->setDevice(_logFile);
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 |
|
---|
[109] | 198 | if (_logStream) {
|
---|
[3371] | 199 | QByteArray msgLocal = msg;
|
---|
| 200 | if (msg.indexOf('\n') == 0) {
|
---|
| 201 | *_logStream << endl;
|
---|
| 202 | msgLocal = msg.mid(1);
|
---|
| 203 | }
|
---|
[1154] | 204 | *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
[3371] | 205 | *_logStream << msgLocal.data() << endl;
|
---|
[109] | 206 | _logStream->flush();
|
---|
[3637] | 207 | _logFile->flush();
|
---|
[82] | 208 | }
|
---|
| 209 | }
|
---|
[511] | 210 |
|
---|
[535] | 211 | // New GPS Ephemeris
|
---|
[511] | 212 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 213 | void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
|
---|
[516] | 214 |
|
---|
| 215 | QMutexLocker locker(&_mutex);
|
---|
| 216 |
|
---|
[1044] | 217 | gpsephemeris copy_gpseph = *gpseph;
|
---|
| 218 | emit newEphGPS(copy_gpseph);
|
---|
| 219 |
|
---|
[534] | 220 | printEphHeader();
|
---|
| 221 |
|
---|
[532] | 222 | gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
|
---|
[1218] | 223 |
|
---|
[538] | 224 | if ( *ee == 0 ||
|
---|
| 225 | gpseph->GPSweek > (*ee)->GPSweek ||
|
---|
[594] | 226 | (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) {
|
---|
[516] | 227 | delete *ee;
|
---|
| 228 | *ee = gpseph;
|
---|
[600] | 229 | printGPSEph(gpseph, true);
|
---|
[516] | 230 | }
|
---|
| 231 | else {
|
---|
[600] | 232 | printGPSEph(gpseph, false);
|
---|
[516] | 233 | delete gpseph;
|
---|
| 234 | }
|
---|
[511] | 235 | }
|
---|
| 236 |
|
---|
[535] | 237 | // New Glonass Ephemeris
|
---|
[511] | 238 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 239 | void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
|
---|
[516] | 240 |
|
---|
| 241 | QMutexLocker locker(&_mutex);
|
---|
| 242 |
|
---|
[1164] | 243 | glonassephemeris copy_glonasseph = *glonasseph;
|
---|
| 244 | emit newEphGlonass(copy_glonasseph);
|
---|
| 245 |
|
---|
[534] | 246 | printEphHeader();
|
---|
| 247 |
|
---|
[532] | 248 | glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
|
---|
[531] | 249 |
|
---|
[3539] | 250 | int wwOld, towOld, wwNew, towNew;
|
---|
| 251 | if (*ee != 0) {
|
---|
| 252 | wwOld = (*ee)->GPSWeek;
|
---|
| 253 | towOld = (*ee)->GPSTOW;
|
---|
| 254 | updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0); // Moscow -> GPS
|
---|
| 255 |
|
---|
| 256 | wwNew = glonasseph->GPSWeek;
|
---|
| 257 | towNew = glonasseph->GPSTOW;
|
---|
| 258 | updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0); // Moscow -> GPS
|
---|
| 259 | }
|
---|
| 260 |
|
---|
[578] | 261 | if ( *ee == 0 ||
|
---|
[3539] | 262 | wwNew > wwOld ||
|
---|
| 263 | (wwNew == wwOld && towNew > towOld) ) {
|
---|
[531] | 264 | delete *ee;
|
---|
| 265 | *ee = glonasseph;
|
---|
[600] | 266 | printGlonassEph(glonasseph, true);
|
---|
[531] | 267 | }
|
---|
| 268 | else {
|
---|
[600] | 269 | printGlonassEph(glonasseph, false);
|
---|
[531] | 270 | delete glonasseph;
|
---|
| 271 | }
|
---|
[511] | 272 | }
|
---|
| 273 |
|
---|
[2770] | 274 | // New Galileo Ephemeris
|
---|
| 275 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 276 | void bncApp::slotNewGalileoEph(galileoephemeris* galileoeph) {
|
---|
| 277 |
|
---|
| 278 | QMutexLocker locker(&_mutex);
|
---|
| 279 |
|
---|
[2772] | 280 | galileoephemeris copy_galileoeph = *galileoeph;
|
---|
| 281 | emit newEphGalileo(copy_galileoeph);
|
---|
| 282 |
|
---|
| 283 | printEphHeader();
|
---|
| 284 |
|
---|
[2773] | 285 | int galIndex = galileoeph->satellite - 51;
|
---|
[2785] | 286 | if (galIndex < 0 || galIndex > PRN_GALILEO_END - PRN_GALILEO_START) {
|
---|
[2773] | 287 | emit( newMessage("Wrong Galileo Satellite Number", true) );
|
---|
| 288 | exit(1);
|
---|
| 289 | }
|
---|
[2772] | 290 |
|
---|
[2773] | 291 | galileoephemeris** ee = &_galileoEph[galIndex];
|
---|
| 292 |
|
---|
| 293 | if ( *ee == 0 ||
|
---|
[2772] | 294 | galileoeph->Week > (*ee)->Week ||
|
---|
| 295 | (galileoeph->Week == (*ee)->Week && galileoeph->TOC > (*ee)->TOC) ) {
|
---|
| 296 | delete *ee;
|
---|
| 297 | *ee = galileoeph;
|
---|
| 298 | printGalileoEph(galileoeph, true);
|
---|
| 299 | }
|
---|
| 300 | else {
|
---|
| 301 | printGalileoEph(galileoeph, false);
|
---|
| 302 | delete galileoeph;
|
---|
| 303 | }
|
---|
[2770] | 304 | }
|
---|
| 305 |
|
---|
[535] | 306 | // Print Header of the output File(s)
|
---|
[516] | 307 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 308 | void bncApp::printEphHeader() {
|
---|
[528] | 309 |
|
---|
[1535] | 310 | bncSettings settings;
|
---|
[535] | 311 |
|
---|
[534] | 312 | // Initialization
|
---|
| 313 | // --------------
|
---|
| 314 | if (_rinexVers == 0) {
|
---|
[528] | 315 |
|
---|
[533] | 316 | if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
|
---|
[534] | 317 | _rinexVers = 3;
|
---|
[533] | 318 | }
|
---|
| 319 | else {
|
---|
[534] | 320 | _rinexVers = 2;
|
---|
[533] | 321 | }
|
---|
[529] | 322 |
|
---|
[533] | 323 | _ephPath = settings.value("ephPath").toString();
|
---|
| 324 |
|
---|
| 325 | if ( !_ephPath.isEmpty() ) {
|
---|
| 326 | if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
|
---|
| 327 | _ephPath += QDir::separator();
|
---|
| 328 | }
|
---|
| 329 | expandEnvVar(_ephPath);
|
---|
| 330 | }
|
---|
[517] | 331 | }
|
---|
[533] | 332 |
|
---|
[534] | 333 | // (Re-)Open output File(s)
|
---|
| 334 | // ------------------------
|
---|
[533] | 335 | if (!_ephPath.isEmpty()) {
|
---|
| 336 |
|
---|
[1154] | 337 | QDateTime datTim = currentDateAndTimeGPS();
|
---|
[533] | 338 |
|
---|
[583] | 339 | QString ephFileNameGPS = _ephPath + "BRDC" +
|
---|
[563] | 340 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
|
---|
[533] | 341 |
|
---|
[647] | 342 | QString hlpStr = bncRinex::nextEpochStr(datTim,
|
---|
| 343 | settings.value("ephIntr").toString());
|
---|
[584] | 344 |
|
---|
[575] | 345 | if (_rinexVers == 3) {
|
---|
| 346 | ephFileNameGPS += hlpStr + datTim.toString(".yyP");
|
---|
| 347 | }
|
---|
| 348 | else {
|
---|
| 349 | ephFileNameGPS += hlpStr + datTim.toString(".yyN");
|
---|
| 350 | }
|
---|
[563] | 351 |
|
---|
[533] | 352 | if (_ephFileNameGPS == ephFileNameGPS) {
|
---|
| 353 | return;
|
---|
| 354 | }
|
---|
| 355 | else {
|
---|
| 356 | _ephFileNameGPS = ephFileNameGPS;
|
---|
| 357 | }
|
---|
| 358 |
|
---|
[575] | 359 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 360 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
| 361 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
| 362 | }
|
---|
| 363 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 364 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
| 365 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
| 366 | }
|
---|
[2770] | 367 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 368 | delete _galileoEph[ii-PRN_GALILEO_START];
|
---|
| 369 | _galileoEph[ii-PRN_GALILEO_START] = 0;
|
---|
| 370 | }
|
---|
[575] | 371 |
|
---|
[533] | 372 | delete _ephStreamGPS;
|
---|
| 373 | delete _ephFileGPS;
|
---|
| 374 |
|
---|
[535] | 375 | QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
|
---|
[536] | 376 | QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
|
---|
[2770] | 377 | QFlags<QIODevice::OpenModeFlag> appendFlagGalileo;
|
---|
[536] | 378 |
|
---|
[535] | 379 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 380 | QFile::exists(ephFileNameGPS) ) {
|
---|
| 381 | appendFlagGPS = QIODevice::Append;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
[533] | 384 | _ephFileGPS = new QFile(ephFileNameGPS);
|
---|
[535] | 385 | _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
|
---|
[533] | 386 | _ephStreamGPS = new QTextStream();
|
---|
| 387 | _ephStreamGPS->setDevice(_ephFileGPS);
|
---|
| 388 |
|
---|
[534] | 389 | if (_rinexVers == 3) {
|
---|
[533] | 390 | _ephFileGlonass = _ephFileGPS;
|
---|
| 391 | _ephStreamGlonass = _ephStreamGPS;
|
---|
[2770] | 392 | _ephFileGalileo = _ephFileGPS;
|
---|
| 393 | _ephStreamGalileo = _ephStreamGPS;
|
---|
[533] | 394 | }
|
---|
[534] | 395 | else if (_rinexVers == 2) {
|
---|
[583] | 396 | QString ephFileNameGlonass = _ephPath + "BRDC" +
|
---|
[563] | 397 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
[575] | 398 | hlpStr + datTim.toString(".yyG");
|
---|
[533] | 399 |
|
---|
| 400 | delete _ephStreamGlonass;
|
---|
| 401 | delete _ephFileGlonass;
|
---|
| 402 |
|
---|
[535] | 403 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 404 | QFile::exists(ephFileNameGlonass) ) {
|
---|
| 405 | appendFlagGlonass = QIODevice::Append;
|
---|
| 406 | }
|
---|
| 407 |
|
---|
[533] | 408 | _ephFileGlonass = new QFile(ephFileNameGlonass);
|
---|
[535] | 409 | _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
|
---|
[533] | 410 | _ephStreamGlonass = new QTextStream();
|
---|
| 411 | _ephStreamGlonass->setDevice(_ephFileGlonass);
|
---|
| 412 | }
|
---|
| 413 |
|
---|
[534] | 414 | // Header - RINEX Version 3
|
---|
| 415 | // ------------------------
|
---|
| 416 | if (_rinexVers == 3) {
|
---|
[537] | 417 | if ( ! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 418 | QString line;
|
---|
| 419 | line.sprintf(
|
---|
| 420 | "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
|
---|
| 421 | 3.0, "", "");
|
---|
| 422 | *_ephStreamGPS << line;
|
---|
| 423 |
|
---|
[1154] | 424 | QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
|
---|
[559] | 425 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 426 | << _userName.toAscii().data()
|
---|
| 427 | << hlp.toAscii().data()
|
---|
| 428 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 429 |
|
---|
| 430 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[537] | 431 | *_ephStreamGPS << line;
|
---|
| 432 |
|
---|
| 433 | _ephStreamGPS->flush();
|
---|
[535] | 434 | }
|
---|
[533] | 435 | }
|
---|
| 436 |
|
---|
[536] | 437 | // Headers - RINEX Version 2
|
---|
| 438 | // -------------------------
|
---|
[534] | 439 | else if (_rinexVers == 2) {
|
---|
[536] | 440 | if (! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 441 | QString line;
|
---|
| 442 | line.sprintf(
|
---|
[2405] | 443 | "%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", 2.10, "", "");
|
---|
[536] | 444 | *_ephStreamGPS << line;
|
---|
| 445 |
|
---|
[1154] | 446 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 447 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 448 | << _userName.toAscii().data()
|
---|
| 449 | << hlp.toAscii().data()
|
---|
| 450 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 451 |
|
---|
| 452 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 453 | *_ephStreamGPS << line;
|
---|
[537] | 454 |
|
---|
| 455 | _ephStreamGPS->flush();
|
---|
[536] | 456 | }
|
---|
| 457 | if (! (appendFlagGlonass & QIODevice::Append)) {
|
---|
| 458 | QString line;
|
---|
| 459 | line.sprintf(
|
---|
[2405] | 460 | "%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",2.10,"","");
|
---|
[536] | 461 | *_ephStreamGlonass << line;
|
---|
| 462 |
|
---|
[1154] | 463 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 464 | *_ephStreamGlonass << _pgmName.toAscii().data()
|
---|
| 465 | << _userName.toAscii().data()
|
---|
| 466 | << hlp.toAscii().data()
|
---|
| 467 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 468 |
|
---|
| 469 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 470 | *_ephStreamGlonass << line;
|
---|
[537] | 471 |
|
---|
| 472 | _ephStreamGlonass->flush();
|
---|
[536] | 473 | }
|
---|
[533] | 474 | }
|
---|
| 475 | }
|
---|
[516] | 476 | }
|
---|
| 477 |
|
---|
[535] | 478 | // Print One GPS Ephemeris
|
---|
[516] | 479 | ////////////////////////////////////////////////////////////////////////////
|
---|
[600] | 480 | void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
|
---|
[519] | 481 |
|
---|
[941] | 482 | QString lineV2;
|
---|
| 483 | QString lineV3;
|
---|
[533] | 484 |
|
---|
[590] | 485 | struct converttimeinfo cti;
|
---|
| 486 | converttime(&cti, ep->GPSweek, ep->TOC);
|
---|
[941] | 487 |
|
---|
[2861] | 488 | lineV3.sprintf("G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
[589] | 489 | ep->satellite, cti.year, cti.month, cti.day, cti.hour,
|
---|
| 490 | cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
|
---|
| 491 | ep->clock_driftrate);
|
---|
[941] | 492 |
|
---|
[2861] | 493 | lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
|
---|
[590] | 494 | ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
|
---|
| 495 | cti.minute, (double) cti.second, ep->clock_bias,
|
---|
| 496 | ep->clock_drift, ep->clock_driftrate);
|
---|
[520] | 497 |
|
---|
[941] | 498 | QString line;
|
---|
| 499 | QByteArray allLines;
|
---|
| 500 |
|
---|
[1316] | 501 | QByteArray fmt;
|
---|
[1321] | 502 | QByteArray fmt2;
|
---|
[1316] | 503 | if (_rinexVers == 2) {
|
---|
[2861] | 504 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
| 505 | fmt2 = " %19.12e%19.12e\n";
|
---|
[1316] | 506 | }
|
---|
| 507 | else {
|
---|
[2861] | 508 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
| 509 | fmt2 = " %19.12e%19.12e\n";
|
---|
[1316] | 510 | }
|
---|
| 511 |
|
---|
| 512 | line.sprintf(fmt.data(), (double)ep->IODE, ep->Crs, ep->Delta_n, ep->M0);
|
---|
[590] | 513 | allLines += line;
|
---|
| 514 |
|
---|
[1316] | 515 | line.sprintf(fmt.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
|
---|
[590] | 516 | allLines += line;
|
---|
[520] | 517 |
|
---|
[1316] | 518 | line.sprintf(fmt.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
|
---|
[590] | 519 | allLines += line;
|
---|
| 520 |
|
---|
[1316] | 521 | line.sprintf(fmt.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
|
---|
[590] | 522 | allLines += line;
|
---|
[520] | 523 |
|
---|
[590] | 524 | double dd = 0;
|
---|
| 525 | unsigned long ii = ep->flags;
|
---|
| 526 | if(ii & GPSEPHF_L2CACODE)
|
---|
| 527 | dd += 2.0;
|
---|
| 528 | if(ii & GPSEPHF_L2PCODE)
|
---|
| 529 | dd += 1.0;
|
---|
[1316] | 530 | line.sprintf(fmt.data(), ep->IDOT, dd, (double) ep->GPSweek,
|
---|
| 531 | ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
|
---|
[590] | 532 | allLines += line;
|
---|
[520] | 533 |
|
---|
[590] | 534 | if(ep->URAindex <= 6) /* URA index */
|
---|
| 535 | dd = ceil(10.0*pow(2.0, 1.0+((double)ep->URAindex)/2.0))/10.0;
|
---|
| 536 | else
|
---|
| 537 | dd = ceil(10.0*pow(2.0, ((double)ep->URAindex)/2.0))/10.0;
|
---|
[1316] | 538 | line.sprintf(fmt.data(), dd, ((double) ep->SVhealth), ep->TGD,
|
---|
| 539 | ((double) ep->IODC));
|
---|
[590] | 540 | allLines += line;
|
---|
[519] | 541 |
|
---|
[1321] | 542 | line.sprintf(fmt2.data(), ((double)ep->TOW), 0.0);
|
---|
[590] | 543 | allLines += line;
|
---|
[519] | 544 |
|
---|
[943] | 545 | printOutput(printFile, _ephStreamGPS, lineV2, lineV3, allLines);
|
---|
[516] | 546 | }
|
---|
| 547 |
|
---|
[535] | 548 | // Print One Glonass Ephemeris
|
---|
[516] | 549 | ////////////////////////////////////////////////////////////////////////////
|
---|
[600] | 550 | void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
|
---|
[523] | 551 |
|
---|
[590] | 552 | int ww = ep->GPSWeek;
|
---|
| 553 | int tow = ep->GPSTOW;
|
---|
| 554 | struct converttimeinfo cti;
|
---|
[523] | 555 |
|
---|
[2257] | 556 | updatetime(&ww, &tow, ep->tb*1000, 1); // Moscow -> UTC
|
---|
[590] | 557 | converttime(&cti, ww, tow);
|
---|
[525] | 558 |
|
---|
[885] | 559 | int tk = ep->tk-3*60*60;
|
---|
| 560 | if (tk < 0) {
|
---|
| 561 | tk += 86400;
|
---|
[590] | 562 | }
|
---|
[525] | 563 |
|
---|
[941] | 564 | QString lineV2;
|
---|
| 565 | QString lineV3;
|
---|
| 566 |
|
---|
[2861] | 567 | lineV3.sprintf("R%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
[590] | 568 | ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
|
---|
[885] | 569 | cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
|
---|
[941] | 570 |
|
---|
[2861] | 571 | lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
|
---|
[590] | 572 | ep->almanac_number, cti.year%100, cti.month, cti.day,
|
---|
| 573 | cti.hour, cti.minute, (double) cti.second, -ep->tau,
|
---|
[885] | 574 | ep->gamma, (double) tk);
|
---|
[590] | 575 |
|
---|
[941] | 576 | QString line;
|
---|
| 577 | QByteArray allLines;
|
---|
| 578 |
|
---|
[1316] | 579 | QByteArray fmt;
|
---|
| 580 | if (_rinexVers == 2) {
|
---|
[2861] | 581 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
[1316] | 582 | }
|
---|
| 583 | else {
|
---|
[2861] | 584 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
[1316] | 585 | }
|
---|
| 586 |
|
---|
| 587 | line.sprintf(fmt.data(), ep->x_pos, ep->x_velocity, ep->x_acceleration,
|
---|
[590] | 588 | (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
|
---|
| 589 | allLines += line;
|
---|
| 590 |
|
---|
[1316] | 591 | line.sprintf(fmt.data(), ep->y_pos, ep->y_velocity, ep->y_acceleration,
|
---|
[590] | 592 | (double) ep->frequency_number);
|
---|
| 593 | allLines += line;
|
---|
| 594 |
|
---|
[1316] | 595 | line.sprintf(fmt.data(), ep->z_pos, ep->z_velocity, ep->z_acceleration,
|
---|
| 596 | (double) ep->E);
|
---|
[590] | 597 | allLines += line;
|
---|
[525] | 598 |
|
---|
[943] | 599 | printOutput(printFile, _ephStreamGlonass, lineV2, lineV3, allLines);
|
---|
[941] | 600 | }
|
---|
| 601 |
|
---|
[2770] | 602 | // Print One Galileo Ephemeris
|
---|
| 603 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 604 | void bncApp::printGalileoEph(galileoephemeris* ep, bool printFile) {
|
---|
[2772] | 605 |
|
---|
| 606 | QString lineV2;
|
---|
| 607 | QString lineV3;
|
---|
| 608 |
|
---|
| 609 | struct converttimeinfo cti;
|
---|
| 610 | converttime(&cti, ep->Week, ep->TOC);
|
---|
| 611 |
|
---|
[2861] | 612 | lineV3.sprintf("E%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
[2772] | 613 | ep->satellite, cti.year, cti.month, cti.day, cti.hour,
|
---|
| 614 | cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
|
---|
| 615 | ep->clock_driftrate);
|
---|
| 616 |
|
---|
| 617 | QString line;
|
---|
| 618 | QByteArray allLines;
|
---|
| 619 |
|
---|
[2861] | 620 | const QByteArray fmt4 = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
| 621 | const QByteArray fmt3 = " %19.12e%19.12e%19.12e\n";
|
---|
| 622 | const QByteArray fmt1 = " %19.12e\n";
|
---|
[2772] | 623 |
|
---|
| 624 | line.sprintf(fmt4.data(), (double)ep->IODnav, ep->Crs, ep->Delta_n, ep->M0);
|
---|
| 625 | allLines += line;
|
---|
| 626 |
|
---|
| 627 | line.sprintf(fmt4.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
|
---|
| 628 | allLines += line;
|
---|
| 629 |
|
---|
| 630 | line.sprintf(fmt4.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
|
---|
| 631 | allLines += line;
|
---|
| 632 |
|
---|
| 633 | line.sprintf(fmt4.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
|
---|
| 634 | allLines += line;
|
---|
| 635 |
|
---|
| 636 | double dataSources = 0.0; // TODO
|
---|
| 637 | line.sprintf(fmt3.data(), ep->IDOT, dataSources, (double) ep->Week);
|
---|
| 638 | allLines += line;
|
---|
| 639 |
|
---|
| 640 | double health = 0.0; // TODO
|
---|
| 641 | double BGD_1_5B = ep->BGD_1_5A; // TODO
|
---|
[2774] | 642 | line.sprintf(fmt4.data(), (double) ep->SISA, health, ep->BGD_1_5A, BGD_1_5B);
|
---|
[2772] | 643 | allLines += line;
|
---|
| 644 |
|
---|
[2775] | 645 | double transmissionTimeOfMessage = 0.9999e9; // unknown (Rinex v3 standard)
|
---|
| 646 | line.sprintf(fmt1.data(), transmissionTimeOfMessage);
|
---|
[2772] | 647 | allLines += line;
|
---|
| 648 |
|
---|
| 649 | printOutput(printFile, _ephStreamGalileo, lineV2, lineV3, allLines);
|
---|
[2770] | 650 | }
|
---|
| 651 |
|
---|
[941] | 652 | // Output
|
---|
| 653 | ////////////////////////////////////////////////////////////////////////////
|
---|
[943] | 654 | void bncApp::printOutput(bool printFile, QTextStream* stream,
|
---|
| 655 | const QString& lineV2,
|
---|
[941] | 656 | const QString& lineV3,
|
---|
| 657 | const QByteArray& allLines) {
|
---|
[590] | 658 | // Output into file
|
---|
| 659 | // ----------------
|
---|
[943] | 660 | if (printFile && stream) {
|
---|
[941] | 661 | if (_rinexVers == 2) {
|
---|
[943] | 662 | *stream << lineV2.toAscii();
|
---|
[941] | 663 | }
|
---|
| 664 | else {
|
---|
[943] | 665 | *stream << lineV3.toAscii();
|
---|
[941] | 666 | }
|
---|
[943] | 667 | *stream << allLines;
|
---|
| 668 | stream->flush();
|
---|
[517] | 669 | }
|
---|
[590] | 670 |
|
---|
| 671 | // Output into the socket
|
---|
| 672 | // ----------------------
|
---|
| 673 | if (_sockets) {
|
---|
[642] | 674 | QMutableListIterator<QTcpSocket*> is(*_sockets);
|
---|
[590] | 675 | while (is.hasNext()) {
|
---|
| 676 | QTcpSocket* sock = is.next();
|
---|
| 677 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[941] | 678 | if (sock->write(lineV3.toAscii()) == -1 ||
|
---|
| 679 | sock->write(allLines) == -1) {
|
---|
[642] | 680 | delete sock;
|
---|
| 681 | is.remove();
|
---|
| 682 | }
|
---|
[590] | 683 | }
|
---|
[642] | 684 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 685 | delete sock;
|
---|
| 686 | is.remove();
|
---|
| 687 | }
|
---|
[590] | 688 | }
|
---|
| 689 | }
|
---|
[516] | 690 | }
|
---|
[589] | 691 |
|
---|
[591] | 692 | // Set Port Number
|
---|
| 693 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 694 | void bncApp::setPort(int port) {
|
---|
| 695 | _port = port;
|
---|
| 696 | if (_port != 0) {
|
---|
[942] | 697 | delete _server;
|
---|
[591] | 698 | _server = new QTcpServer;
|
---|
[1228] | 699 | if ( !_server->listen(QHostAddress::Any, _port) ) {
|
---|
[1451] | 700 | slotMessage("bncApp: Cannot listen on ephemeris port", true);
|
---|
[1228] | 701 | }
|
---|
[591] | 702 | connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
---|
[942] | 703 | delete _sockets;
|
---|
[591] | 704 | _sockets = new QList<QTcpSocket*>;
|
---|
| 705 | }
|
---|
| 706 | }
|
---|
| 707 |
|
---|
[937] | 708 | // Set Port Number
|
---|
| 709 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 710 | void bncApp::setPortCorr(int port) {
|
---|
| 711 | _portCorr = port;
|
---|
| 712 | if (_portCorr != 0) {
|
---|
[942] | 713 | delete _serverCorr;
|
---|
[937] | 714 | _serverCorr = new QTcpServer;
|
---|
[1228] | 715 | if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
|
---|
[1451] | 716 | slotMessage("bncApp: Cannot listen on correction port", true);
|
---|
[1228] | 717 | }
|
---|
[937] | 718 | connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
|
---|
[942] | 719 | delete _socketsCorr;
|
---|
[937] | 720 | _socketsCorr = new QList<QTcpSocket*>;
|
---|
| 721 | }
|
---|
| 722 | }
|
---|
| 723 |
|
---|
[589] | 724 | // New Connection
|
---|
| 725 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 726 | void bncApp::slotNewConnection() {
|
---|
| 727 | _sockets->push_back( _server->nextPendingConnection() );
|
---|
| 728 | }
|
---|
| 729 |
|
---|
[937] | 730 | // New Connection
|
---|
| 731 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 732 | void bncApp::slotNewConnectionCorr() {
|
---|
| 733 | _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
|
---|
| 734 | }
|
---|
| 735 |
|
---|
[621] | 736 | //
|
---|
| 737 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 738 | void bncApp::slotQuit() {
|
---|
[1029] | 739 | cout << "bncApp::slotQuit" << endl;
|
---|
[621] | 740 | delete _caster;
|
---|
| 741 | quit();
|
---|
| 742 | }
|
---|
| 743 |
|
---|
[936] | 744 | //
|
---|
| 745 | ////////////////////////////////////////////////////////////////////////////
|
---|
[974] | 746 | void bncApp::slotNewCorrLine(QString line, QString staID, long coTime) {
|
---|
| 747 |
|
---|
| 748 | QMutexLocker locker(&_mutex);
|
---|
| 749 |
|
---|
[2866] | 750 | // Combination of Corrections
|
---|
| 751 | // --------------------------
|
---|
[2899] | 752 | #ifdef USE_COMBINATION
|
---|
[2866] | 753 | if (_bncComb) {
|
---|
| 754 | _bncComb->processCorrLine(staID, line);
|
---|
| 755 | }
|
---|
[2899] | 756 | #endif
|
---|
[2866] | 757 |
|
---|
[1535] | 758 | bncSettings settings;
|
---|
[3109] | 759 | _waitCoTime = settings.value("corrTime").toInt();
|
---|
| 760 | if (_waitCoTime < 0) {
|
---|
| 761 | _waitCoTime = 0;
|
---|
[995] | 762 | }
|
---|
| 763 |
|
---|
[974] | 764 | // First time, set the _lastDumpSec immediately
|
---|
| 765 | // --------------------------------------------
|
---|
| 766 | if (_lastDumpCoSec == 0) {
|
---|
| 767 | _lastDumpCoSec = coTime - 1;
|
---|
| 768 | }
|
---|
| 769 |
|
---|
[975] | 770 | // An old correction - throw it away
|
---|
| 771 | // ---------------------------------
|
---|
[3109] | 772 | if (_waitCoTime > 0 && coTime <= _lastDumpCoSec) {
|
---|
[2916] | 773 | if (!_bncComb) {
|
---|
| 774 | QString line = staID + ": Correction for one sat neglected because overaged by " +
|
---|
| 775 | QString().sprintf(" %ld sec",
|
---|
| 776 | _lastDumpCoSec - coTime + _waitCoTime);
|
---|
| 777 | messagePrivate(line.toAscii());
|
---|
| 778 | emit( newMessage(line.toAscii(), true) );
|
---|
| 779 | }
|
---|
[975] | 780 | return;
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | _corrs->insert(coTime, QString(line + " " + staID));
|
---|
| 784 |
|
---|
[976] | 785 | // Dump Corrections
|
---|
| 786 | // ----------------
|
---|
[3109] | 787 | if (_waitCoTime == 0) {
|
---|
| 788 | dumpCorrs();
|
---|
| 789 | }
|
---|
| 790 | else if (coTime - _waitCoTime > _lastDumpCoSec) {
|
---|
[976] | 791 | dumpCorrs(_lastDumpCoSec + 1, coTime - _waitCoTime);
|
---|
| 792 | _lastDumpCoSec = coTime - _waitCoTime;
|
---|
| 793 | }
|
---|
| 794 | }
|
---|
| 795 |
|
---|
| 796 | // Dump Complete Correction Epochs
|
---|
| 797 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 798 | void bncApp::dumpCorrs(long minTime, long maxTime) {
|
---|
| 799 | for (long sec = minTime; sec <= maxTime; sec++) {
|
---|
| 800 | QList<QString> allCorrs = _corrs->values(sec);
|
---|
[3109] | 801 | dumpCorrs(allCorrs);
|
---|
| 802 | _corrs->remove(sec);
|
---|
| 803 | }
|
---|
| 804 | }
|
---|
| 805 |
|
---|
| 806 | // Dump all corrections
|
---|
| 807 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 808 | void bncApp::dumpCorrs() {
|
---|
[3110] | 809 | QList<QString> allCorrs;
|
---|
| 810 | QMutableMapIterator<long, QString> it(*_corrs);
|
---|
| 811 | while (it.hasNext()) {
|
---|
| 812 | allCorrs << it.next().value();
|
---|
| 813 | it.remove();
|
---|
| 814 | }
|
---|
| 815 | dumpCorrs(allCorrs);
|
---|
[3109] | 816 | }
|
---|
| 817 |
|
---|
| 818 | // Dump List of Corrections
|
---|
| 819 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 820 | void bncApp::dumpCorrs(const QList<QString>& allCorrs) {
|
---|
| 821 | emit newCorrections(allCorrs);
|
---|
| 822 | if (_socketsCorr) {
|
---|
| 823 | QListIterator<QString> it(allCorrs);
|
---|
| 824 | while (it.hasNext()) {
|
---|
| 825 | QString corrLine = it.next() + "\n";
|
---|
| 826 |
|
---|
| 827 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
|
---|
| 828 | while (is.hasNext()) {
|
---|
| 829 | QTcpSocket* sock = is.next();
|
---|
| 830 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
| 831 | if (sock->write(corrLine.toAscii()) == -1) {
|
---|
[976] | 832 | delete sock;
|
---|
| 833 | is.remove();
|
---|
| 834 | }
|
---|
| 835 | }
|
---|
[3109] | 836 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 837 | delete sock;
|
---|
| 838 | is.remove();
|
---|
| 839 | }
|
---|
[937] | 840 | }
|
---|
| 841 | }
|
---|
| 842 | }
|
---|
[936] | 843 | }
|
---|
[1538] | 844 |
|
---|
| 845 | //
|
---|
| 846 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 847 | void bncApp::setConfFileName(const QString& confFileName) {
|
---|
| 848 | if (confFileName.isEmpty()) {
|
---|
[1539] | 849 | _confFileName = QDir::homePath() + QDir::separator()
|
---|
| 850 | + ".config" + QDir::separator()
|
---|
| 851 | + organizationName() + QDir::separator()
|
---|
| 852 | + applicationName() + ".ini";
|
---|
[1538] | 853 | }
|
---|
| 854 | else {
|
---|
| 855 | _confFileName = confFileName;
|
---|
| 856 | }
|
---|
| 857 | }
|
---|
[2385] | 858 |
|
---|
| 859 | // Raw Output
|
---|
| 860 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2518] | 861 | void bncApp::writeRawData(const QByteArray& data, const QByteArray& staID,
|
---|
| 862 | const QByteArray& format) {
|
---|
[2385] | 863 |
|
---|
[2386] | 864 | QMutexLocker locker(&_mutex);
|
---|
| 865 |
|
---|
[2519] | 866 | if (!_rawFile) {
|
---|
[2386] | 867 | bncSettings settings;
|
---|
[2519] | 868 | QByteArray fileName = settings.value("rawOutFile").toByteArray();
|
---|
| 869 | if (!fileName.isEmpty()) {
|
---|
[3524] | 870 | _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
|
---|
[2407] | 871 | }
|
---|
[2386] | 872 | }
|
---|
| 873 |
|
---|
[2519] | 874 | if (_rawFile) {
|
---|
| 875 | _rawFile->writeRawData(data, staID, format);
|
---|
[2386] | 876 | }
|
---|
[2385] | 877 | }
|
---|
[2672] | 878 |
|
---|
| 879 | // Get Glonass Slot Numbers from Global Array
|
---|
| 880 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 881 | void bncApp::getGlonassSlotNums(int GLOFreq[]) {
|
---|
| 882 |
|
---|
| 883 | QMutexLocker locker(&_mutex);
|
---|
| 884 |
|
---|
[2673] | 885 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
|
---|
| 886 | if (_GLOFreq[ii] != 0) {
|
---|
| 887 | GLOFreq[ii] = _GLOFreq[ii];
|
---|
| 888 | }
|
---|
| 889 | }
|
---|
[2672] | 890 | }
|
---|
| 891 |
|
---|
| 892 | // Store Glonass Slot Numbers to Global Array
|
---|
| 893 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 894 | void bncApp::storeGlonassSlotNums(const int GLOFreq[]) {
|
---|
| 895 |
|
---|
| 896 | QMutexLocker locker(&_mutex);
|
---|
| 897 |
|
---|
[2673] | 898 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
|
---|
| 899 | if (GLOFreq[ii] != 0) {
|
---|
| 900 | _GLOFreq[ii] = GLOFreq[ii];
|
---|
| 901 | }
|
---|
| 902 | }
|
---|
[2672] | 903 | }
|
---|
[2909] | 904 |
|
---|
| 905 | //
|
---|
| 906 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 907 | void bncApp::initCombination() {
|
---|
| 908 | #ifdef USE_COMBINATION
|
---|
| 909 | _bncComb = new bncComb();
|
---|
[3142] | 910 | if (_bncComb->nStreams() < 1) {
|
---|
[2909] | 911 | delete _bncComb;
|
---|
| 912 | _bncComb = 0;
|
---|
| 913 | }
|
---|
| 914 | #endif
|
---|
| 915 | }
|
---|
[3231] | 916 |
|
---|
| 917 | //
|
---|
| 918 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 919 | void bncApp::stopCombination() {
|
---|
| 920 | #ifdef USE_COMBINATION
|
---|
| 921 | delete _bncComb;
|
---|
| 922 | _bncComb = 0;
|
---|
| 923 | #endif
|
---|
| 924 | }
|
---|