[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) {
|
---|
[1154] | 199 | *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
[109] | 200 | *_logStream << msg.data() << endl;
|
---|
| 201 | _logStream->flush();
|
---|
[82] | 202 | }
|
---|
| 203 | }
|
---|
[511] | 204 |
|
---|
[535] | 205 | // New GPS Ephemeris
|
---|
[511] | 206 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 207 | void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
|
---|
[516] | 208 |
|
---|
| 209 | QMutexLocker locker(&_mutex);
|
---|
| 210 |
|
---|
[1044] | 211 | gpsephemeris copy_gpseph = *gpseph;
|
---|
| 212 | emit newEphGPS(copy_gpseph);
|
---|
| 213 |
|
---|
[534] | 214 | printEphHeader();
|
---|
| 215 |
|
---|
[532] | 216 | gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
|
---|
[1218] | 217 |
|
---|
[538] | 218 | if ( *ee == 0 ||
|
---|
| 219 | gpseph->GPSweek > (*ee)->GPSweek ||
|
---|
[594] | 220 | (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) {
|
---|
[516] | 221 | delete *ee;
|
---|
| 222 | *ee = gpseph;
|
---|
[600] | 223 | printGPSEph(gpseph, true);
|
---|
[516] | 224 | }
|
---|
| 225 | else {
|
---|
[600] | 226 | printGPSEph(gpseph, false);
|
---|
[516] | 227 | delete gpseph;
|
---|
| 228 | }
|
---|
[511] | 229 | }
|
---|
| 230 |
|
---|
[535] | 231 | // New Glonass Ephemeris
|
---|
[511] | 232 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 233 | void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
|
---|
[516] | 234 |
|
---|
| 235 | QMutexLocker locker(&_mutex);
|
---|
| 236 |
|
---|
[1164] | 237 | glonassephemeris copy_glonasseph = *glonasseph;
|
---|
| 238 | emit newEphGlonass(copy_glonasseph);
|
---|
| 239 |
|
---|
[534] | 240 | printEphHeader();
|
---|
| 241 |
|
---|
[532] | 242 | glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
|
---|
[531] | 243 |
|
---|
[578] | 244 | int wwOld, towOld, wwNew, towNew;
|
---|
[577] | 245 | if (*ee != 0) {
|
---|
[578] | 246 | wwOld = (*ee)->GPSWeek;
|
---|
| 247 | towOld = (*ee)->GPSTOW;
|
---|
[2257] | 248 | updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0); // Moscow -> GPS
|
---|
[577] | 249 |
|
---|
[578] | 250 | wwNew = glonasseph->GPSWeek;
|
---|
| 251 | towNew = glonasseph->GPSTOW;
|
---|
[2257] | 252 | updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0); // Moscow -> GPS
|
---|
[577] | 253 | }
|
---|
| 254 |
|
---|
[578] | 255 | if ( *ee == 0 ||
|
---|
| 256 | wwNew > wwOld ||
|
---|
| 257 | (wwNew == wwOld && towNew > towOld) ) {
|
---|
[531] | 258 | delete *ee;
|
---|
| 259 | *ee = glonasseph;
|
---|
[600] | 260 | printGlonassEph(glonasseph, true);
|
---|
[531] | 261 | }
|
---|
| 262 | else {
|
---|
[600] | 263 | printGlonassEph(glonasseph, false);
|
---|
[531] | 264 | delete glonasseph;
|
---|
| 265 | }
|
---|
[511] | 266 | }
|
---|
| 267 |
|
---|
[2770] | 268 | // New Galileo Ephemeris
|
---|
| 269 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 270 | void bncApp::slotNewGalileoEph(galileoephemeris* galileoeph) {
|
---|
| 271 |
|
---|
| 272 | QMutexLocker locker(&_mutex);
|
---|
| 273 |
|
---|
[2772] | 274 | galileoephemeris copy_galileoeph = *galileoeph;
|
---|
| 275 | emit newEphGalileo(copy_galileoeph);
|
---|
| 276 |
|
---|
| 277 | printEphHeader();
|
---|
| 278 |
|
---|
[2773] | 279 | int galIndex = galileoeph->satellite - 51;
|
---|
[2785] | 280 | if (galIndex < 0 || galIndex > PRN_GALILEO_END - PRN_GALILEO_START) {
|
---|
[2773] | 281 | emit( newMessage("Wrong Galileo Satellite Number", true) );
|
---|
| 282 | exit(1);
|
---|
| 283 | }
|
---|
[2772] | 284 |
|
---|
[2773] | 285 | galileoephemeris** ee = &_galileoEph[galIndex];
|
---|
| 286 |
|
---|
| 287 | if ( *ee == 0 ||
|
---|
[2772] | 288 | galileoeph->Week > (*ee)->Week ||
|
---|
| 289 | (galileoeph->Week == (*ee)->Week && galileoeph->TOC > (*ee)->TOC) ) {
|
---|
| 290 | delete *ee;
|
---|
| 291 | *ee = galileoeph;
|
---|
| 292 | printGalileoEph(galileoeph, true);
|
---|
| 293 | }
|
---|
| 294 | else {
|
---|
| 295 | printGalileoEph(galileoeph, false);
|
---|
| 296 | delete galileoeph;
|
---|
| 297 | }
|
---|
[2770] | 298 | }
|
---|
| 299 |
|
---|
[535] | 300 | // Print Header of the output File(s)
|
---|
[516] | 301 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 302 | void bncApp::printEphHeader() {
|
---|
[528] | 303 |
|
---|
[1535] | 304 | bncSettings settings;
|
---|
[535] | 305 |
|
---|
[534] | 306 | // Initialization
|
---|
| 307 | // --------------
|
---|
| 308 | if (_rinexVers == 0) {
|
---|
[528] | 309 |
|
---|
[533] | 310 | if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
|
---|
[534] | 311 | _rinexVers = 3;
|
---|
[533] | 312 | }
|
---|
| 313 | else {
|
---|
[534] | 314 | _rinexVers = 2;
|
---|
[533] | 315 | }
|
---|
[529] | 316 |
|
---|
[533] | 317 | _ephPath = settings.value("ephPath").toString();
|
---|
| 318 |
|
---|
| 319 | if ( !_ephPath.isEmpty() ) {
|
---|
| 320 | if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
|
---|
| 321 | _ephPath += QDir::separator();
|
---|
| 322 | }
|
---|
| 323 | expandEnvVar(_ephPath);
|
---|
| 324 | }
|
---|
[517] | 325 | }
|
---|
[533] | 326 |
|
---|
[534] | 327 | // (Re-)Open output File(s)
|
---|
| 328 | // ------------------------
|
---|
[533] | 329 | if (!_ephPath.isEmpty()) {
|
---|
| 330 |
|
---|
[1154] | 331 | QDateTime datTim = currentDateAndTimeGPS();
|
---|
[533] | 332 |
|
---|
[583] | 333 | QString ephFileNameGPS = _ephPath + "BRDC" +
|
---|
[563] | 334 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
|
---|
[533] | 335 |
|
---|
[647] | 336 | QString hlpStr = bncRinex::nextEpochStr(datTim,
|
---|
| 337 | settings.value("ephIntr").toString());
|
---|
[584] | 338 |
|
---|
[575] | 339 | if (_rinexVers == 3) {
|
---|
| 340 | ephFileNameGPS += hlpStr + datTim.toString(".yyP");
|
---|
| 341 | }
|
---|
| 342 | else {
|
---|
| 343 | ephFileNameGPS += hlpStr + datTim.toString(".yyN");
|
---|
| 344 | }
|
---|
[563] | 345 |
|
---|
[533] | 346 | if (_ephFileNameGPS == ephFileNameGPS) {
|
---|
| 347 | return;
|
---|
| 348 | }
|
---|
| 349 | else {
|
---|
| 350 | _ephFileNameGPS = ephFileNameGPS;
|
---|
| 351 | }
|
---|
| 352 |
|
---|
[575] | 353 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 354 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
| 355 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
| 356 | }
|
---|
| 357 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 358 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
| 359 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
| 360 | }
|
---|
[2770] | 361 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 362 | delete _galileoEph[ii-PRN_GALILEO_START];
|
---|
| 363 | _galileoEph[ii-PRN_GALILEO_START] = 0;
|
---|
| 364 | }
|
---|
[575] | 365 |
|
---|
[533] | 366 | delete _ephStreamGPS;
|
---|
| 367 | delete _ephFileGPS;
|
---|
| 368 |
|
---|
[535] | 369 | QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
|
---|
[536] | 370 | QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
|
---|
[2770] | 371 | QFlags<QIODevice::OpenModeFlag> appendFlagGalileo;
|
---|
[536] | 372 |
|
---|
[535] | 373 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 374 | QFile::exists(ephFileNameGPS) ) {
|
---|
| 375 | appendFlagGPS = QIODevice::Append;
|
---|
| 376 | }
|
---|
| 377 |
|
---|
[533] | 378 | _ephFileGPS = new QFile(ephFileNameGPS);
|
---|
[535] | 379 | _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
|
---|
[533] | 380 | _ephStreamGPS = new QTextStream();
|
---|
| 381 | _ephStreamGPS->setDevice(_ephFileGPS);
|
---|
| 382 |
|
---|
[534] | 383 | if (_rinexVers == 3) {
|
---|
[533] | 384 | _ephFileGlonass = _ephFileGPS;
|
---|
| 385 | _ephStreamGlonass = _ephStreamGPS;
|
---|
[2770] | 386 | _ephFileGalileo = _ephFileGPS;
|
---|
| 387 | _ephStreamGalileo = _ephStreamGPS;
|
---|
[533] | 388 | }
|
---|
[534] | 389 | else if (_rinexVers == 2) {
|
---|
[583] | 390 | QString ephFileNameGlonass = _ephPath + "BRDC" +
|
---|
[563] | 391 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
[575] | 392 | hlpStr + datTim.toString(".yyG");
|
---|
[533] | 393 |
|
---|
| 394 | delete _ephStreamGlonass;
|
---|
| 395 | delete _ephFileGlonass;
|
---|
| 396 |
|
---|
[535] | 397 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 398 | QFile::exists(ephFileNameGlonass) ) {
|
---|
| 399 | appendFlagGlonass = QIODevice::Append;
|
---|
| 400 | }
|
---|
| 401 |
|
---|
[533] | 402 | _ephFileGlonass = new QFile(ephFileNameGlonass);
|
---|
[535] | 403 | _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
|
---|
[533] | 404 | _ephStreamGlonass = new QTextStream();
|
---|
| 405 | _ephStreamGlonass->setDevice(_ephFileGlonass);
|
---|
| 406 | }
|
---|
| 407 |
|
---|
[534] | 408 | // Header - RINEX Version 3
|
---|
| 409 | // ------------------------
|
---|
| 410 | if (_rinexVers == 3) {
|
---|
[537] | 411 | if ( ! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 412 | QString line;
|
---|
| 413 | line.sprintf(
|
---|
| 414 | "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
|
---|
| 415 | 3.0, "", "");
|
---|
| 416 | *_ephStreamGPS << line;
|
---|
| 417 |
|
---|
[1154] | 418 | QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
|
---|
[559] | 419 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 420 | << _userName.toAscii().data()
|
---|
| 421 | << hlp.toAscii().data()
|
---|
| 422 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 423 |
|
---|
| 424 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[537] | 425 | *_ephStreamGPS << line;
|
---|
| 426 |
|
---|
| 427 | _ephStreamGPS->flush();
|
---|
[535] | 428 | }
|
---|
[533] | 429 | }
|
---|
| 430 |
|
---|
[536] | 431 | // Headers - RINEX Version 2
|
---|
| 432 | // -------------------------
|
---|
[534] | 433 | else if (_rinexVers == 2) {
|
---|
[536] | 434 | if (! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 435 | QString line;
|
---|
| 436 | line.sprintf(
|
---|
[2405] | 437 | "%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", 2.10, "", "");
|
---|
[536] | 438 | *_ephStreamGPS << line;
|
---|
| 439 |
|
---|
[1154] | 440 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 441 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 442 | << _userName.toAscii().data()
|
---|
| 443 | << hlp.toAscii().data()
|
---|
| 444 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 445 |
|
---|
| 446 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 447 | *_ephStreamGPS << line;
|
---|
[537] | 448 |
|
---|
| 449 | _ephStreamGPS->flush();
|
---|
[536] | 450 | }
|
---|
| 451 | if (! (appendFlagGlonass & QIODevice::Append)) {
|
---|
| 452 | QString line;
|
---|
| 453 | line.sprintf(
|
---|
[2405] | 454 | "%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",2.10,"","");
|
---|
[536] | 455 | *_ephStreamGlonass << line;
|
---|
| 456 |
|
---|
[1154] | 457 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 458 | *_ephStreamGlonass << _pgmName.toAscii().data()
|
---|
| 459 | << _userName.toAscii().data()
|
---|
| 460 | << hlp.toAscii().data()
|
---|
| 461 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 462 |
|
---|
| 463 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 464 | *_ephStreamGlonass << line;
|
---|
[537] | 465 |
|
---|
| 466 | _ephStreamGlonass->flush();
|
---|
[536] | 467 | }
|
---|
[533] | 468 | }
|
---|
| 469 | }
|
---|
[516] | 470 | }
|
---|
| 471 |
|
---|
[535] | 472 | // Print One GPS Ephemeris
|
---|
[516] | 473 | ////////////////////////////////////////////////////////////////////////////
|
---|
[600] | 474 | void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
|
---|
[519] | 475 |
|
---|
[941] | 476 | QString lineV2;
|
---|
| 477 | QString lineV3;
|
---|
[533] | 478 |
|
---|
[590] | 479 | struct converttimeinfo cti;
|
---|
| 480 | converttime(&cti, ep->GPSweek, ep->TOC);
|
---|
[941] | 481 |
|
---|
[2861] | 482 | lineV3.sprintf("G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
[589] | 483 | ep->satellite, cti.year, cti.month, cti.day, cti.hour,
|
---|
| 484 | cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
|
---|
| 485 | ep->clock_driftrate);
|
---|
[941] | 486 |
|
---|
[2861] | 487 | lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
|
---|
[590] | 488 | ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
|
---|
| 489 | cti.minute, (double) cti.second, ep->clock_bias,
|
---|
| 490 | ep->clock_drift, ep->clock_driftrate);
|
---|
[520] | 491 |
|
---|
[941] | 492 | QString line;
|
---|
| 493 | QByteArray allLines;
|
---|
| 494 |
|
---|
[1316] | 495 | QByteArray fmt;
|
---|
[1321] | 496 | QByteArray fmt2;
|
---|
[1316] | 497 | if (_rinexVers == 2) {
|
---|
[2861] | 498 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
| 499 | fmt2 = " %19.12e%19.12e\n";
|
---|
[1316] | 500 | }
|
---|
| 501 | else {
|
---|
[2861] | 502 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
| 503 | fmt2 = " %19.12e%19.12e\n";
|
---|
[1316] | 504 | }
|
---|
| 505 |
|
---|
| 506 | line.sprintf(fmt.data(), (double)ep->IODE, ep->Crs, ep->Delta_n, ep->M0);
|
---|
[590] | 507 | allLines += line;
|
---|
| 508 |
|
---|
[1316] | 509 | line.sprintf(fmt.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
|
---|
[590] | 510 | allLines += line;
|
---|
[520] | 511 |
|
---|
[1316] | 512 | line.sprintf(fmt.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
|
---|
[590] | 513 | allLines += line;
|
---|
| 514 |
|
---|
[1316] | 515 | line.sprintf(fmt.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
|
---|
[590] | 516 | allLines += line;
|
---|
[520] | 517 |
|
---|
[590] | 518 | double dd = 0;
|
---|
| 519 | unsigned long ii = ep->flags;
|
---|
| 520 | if(ii & GPSEPHF_L2CACODE)
|
---|
| 521 | dd += 2.0;
|
---|
| 522 | if(ii & GPSEPHF_L2PCODE)
|
---|
| 523 | dd += 1.0;
|
---|
[1316] | 524 | line.sprintf(fmt.data(), ep->IDOT, dd, (double) ep->GPSweek,
|
---|
| 525 | ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
|
---|
[590] | 526 | allLines += line;
|
---|
[520] | 527 |
|
---|
[590] | 528 | if(ep->URAindex <= 6) /* URA index */
|
---|
| 529 | dd = ceil(10.0*pow(2.0, 1.0+((double)ep->URAindex)/2.0))/10.0;
|
---|
| 530 | else
|
---|
| 531 | dd = ceil(10.0*pow(2.0, ((double)ep->URAindex)/2.0))/10.0;
|
---|
[1316] | 532 | line.sprintf(fmt.data(), dd, ((double) ep->SVhealth), ep->TGD,
|
---|
| 533 | ((double) ep->IODC));
|
---|
[590] | 534 | allLines += line;
|
---|
[519] | 535 |
|
---|
[1321] | 536 | line.sprintf(fmt2.data(), ((double)ep->TOW), 0.0);
|
---|
[590] | 537 | allLines += line;
|
---|
[519] | 538 |
|
---|
[943] | 539 | printOutput(printFile, _ephStreamGPS, lineV2, lineV3, allLines);
|
---|
[516] | 540 | }
|
---|
| 541 |
|
---|
[535] | 542 | // Print One Glonass Ephemeris
|
---|
[516] | 543 | ////////////////////////////////////////////////////////////////////////////
|
---|
[600] | 544 | void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
|
---|
[523] | 545 |
|
---|
[590] | 546 | int ww = ep->GPSWeek;
|
---|
| 547 | int tow = ep->GPSTOW;
|
---|
| 548 | struct converttimeinfo cti;
|
---|
[523] | 549 |
|
---|
[2257] | 550 | updatetime(&ww, &tow, ep->tb*1000, 1); // Moscow -> UTC
|
---|
[590] | 551 | converttime(&cti, ww, tow);
|
---|
[525] | 552 |
|
---|
[885] | 553 | int tk = ep->tk-3*60*60;
|
---|
| 554 | if (tk < 0) {
|
---|
| 555 | tk += 86400;
|
---|
[590] | 556 | }
|
---|
[525] | 557 |
|
---|
[941] | 558 | QString lineV2;
|
---|
| 559 | QString lineV3;
|
---|
| 560 |
|
---|
[2861] | 561 | lineV3.sprintf("R%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
[590] | 562 | ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
|
---|
[885] | 563 | cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
|
---|
[941] | 564 |
|
---|
[2861] | 565 | lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
|
---|
[590] | 566 | ep->almanac_number, cti.year%100, cti.month, cti.day,
|
---|
| 567 | cti.hour, cti.minute, (double) cti.second, -ep->tau,
|
---|
[885] | 568 | ep->gamma, (double) tk);
|
---|
[590] | 569 |
|
---|
[941] | 570 | QString line;
|
---|
| 571 | QByteArray allLines;
|
---|
| 572 |
|
---|
[1316] | 573 | QByteArray fmt;
|
---|
| 574 | if (_rinexVers == 2) {
|
---|
[2861] | 575 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
[1316] | 576 | }
|
---|
| 577 | else {
|
---|
[2861] | 578 | fmt = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
[1316] | 579 | }
|
---|
| 580 |
|
---|
| 581 | line.sprintf(fmt.data(), ep->x_pos, ep->x_velocity, ep->x_acceleration,
|
---|
[590] | 582 | (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
|
---|
| 583 | allLines += line;
|
---|
| 584 |
|
---|
[1316] | 585 | line.sprintf(fmt.data(), ep->y_pos, ep->y_velocity, ep->y_acceleration,
|
---|
[590] | 586 | (double) ep->frequency_number);
|
---|
| 587 | allLines += line;
|
---|
| 588 |
|
---|
[1316] | 589 | line.sprintf(fmt.data(), ep->z_pos, ep->z_velocity, ep->z_acceleration,
|
---|
| 590 | (double) ep->E);
|
---|
[590] | 591 | allLines += line;
|
---|
[525] | 592 |
|
---|
[943] | 593 | printOutput(printFile, _ephStreamGlonass, lineV2, lineV3, allLines);
|
---|
[941] | 594 | }
|
---|
| 595 |
|
---|
[2770] | 596 | // Print One Galileo Ephemeris
|
---|
| 597 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 598 | void bncApp::printGalileoEph(galileoephemeris* ep, bool printFile) {
|
---|
[2772] | 599 |
|
---|
| 600 | QString lineV2;
|
---|
| 601 | QString lineV3;
|
---|
| 602 |
|
---|
| 603 | struct converttimeinfo cti;
|
---|
| 604 | converttime(&cti, ep->Week, ep->TOC);
|
---|
| 605 |
|
---|
[2861] | 606 | lineV3.sprintf("E%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
[2772] | 607 | ep->satellite, cti.year, cti.month, cti.day, cti.hour,
|
---|
| 608 | cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
|
---|
| 609 | ep->clock_driftrate);
|
---|
| 610 |
|
---|
| 611 | QString line;
|
---|
| 612 | QByteArray allLines;
|
---|
| 613 |
|
---|
[2861] | 614 | const QByteArray fmt4 = " %19.12e%19.12e%19.12e%19.12e\n";
|
---|
| 615 | const QByteArray fmt3 = " %19.12e%19.12e%19.12e\n";
|
---|
| 616 | const QByteArray fmt1 = " %19.12e\n";
|
---|
[2772] | 617 |
|
---|
| 618 | line.sprintf(fmt4.data(), (double)ep->IODnav, ep->Crs, ep->Delta_n, ep->M0);
|
---|
| 619 | allLines += line;
|
---|
| 620 |
|
---|
| 621 | line.sprintf(fmt4.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
|
---|
| 622 | allLines += line;
|
---|
| 623 |
|
---|
| 624 | line.sprintf(fmt4.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
|
---|
| 625 | allLines += line;
|
---|
| 626 |
|
---|
| 627 | line.sprintf(fmt4.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
|
---|
| 628 | allLines += line;
|
---|
| 629 |
|
---|
| 630 | double dataSources = 0.0; // TODO
|
---|
| 631 | line.sprintf(fmt3.data(), ep->IDOT, dataSources, (double) ep->Week);
|
---|
| 632 | allLines += line;
|
---|
| 633 |
|
---|
| 634 | double health = 0.0; // TODO
|
---|
| 635 | double BGD_1_5B = ep->BGD_1_5A; // TODO
|
---|
[2774] | 636 | line.sprintf(fmt4.data(), (double) ep->SISA, health, ep->BGD_1_5A, BGD_1_5B);
|
---|
[2772] | 637 | allLines += line;
|
---|
| 638 |
|
---|
[2775] | 639 | double transmissionTimeOfMessage = 0.9999e9; // unknown (Rinex v3 standard)
|
---|
| 640 | line.sprintf(fmt1.data(), transmissionTimeOfMessage);
|
---|
[2772] | 641 | allLines += line;
|
---|
| 642 |
|
---|
| 643 | printOutput(printFile, _ephStreamGalileo, lineV2, lineV3, allLines);
|
---|
[2770] | 644 | }
|
---|
| 645 |
|
---|
[941] | 646 | // Output
|
---|
| 647 | ////////////////////////////////////////////////////////////////////////////
|
---|
[943] | 648 | void bncApp::printOutput(bool printFile, QTextStream* stream,
|
---|
| 649 | const QString& lineV2,
|
---|
[941] | 650 | const QString& lineV3,
|
---|
| 651 | const QByteArray& allLines) {
|
---|
[590] | 652 | // Output into file
|
---|
| 653 | // ----------------
|
---|
[943] | 654 | if (printFile && stream) {
|
---|
[941] | 655 | if (_rinexVers == 2) {
|
---|
[943] | 656 | *stream << lineV2.toAscii();
|
---|
[941] | 657 | }
|
---|
| 658 | else {
|
---|
[943] | 659 | *stream << lineV3.toAscii();
|
---|
[941] | 660 | }
|
---|
[943] | 661 | *stream << allLines;
|
---|
| 662 | stream->flush();
|
---|
[517] | 663 | }
|
---|
[590] | 664 |
|
---|
| 665 | // Output into the socket
|
---|
| 666 | // ----------------------
|
---|
| 667 | if (_sockets) {
|
---|
[642] | 668 | QMutableListIterator<QTcpSocket*> is(*_sockets);
|
---|
[590] | 669 | while (is.hasNext()) {
|
---|
| 670 | QTcpSocket* sock = is.next();
|
---|
| 671 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[941] | 672 | if (sock->write(lineV3.toAscii()) == -1 ||
|
---|
| 673 | sock->write(allLines) == -1) {
|
---|
[642] | 674 | delete sock;
|
---|
| 675 | is.remove();
|
---|
| 676 | }
|
---|
[590] | 677 | }
|
---|
[642] | 678 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 679 | delete sock;
|
---|
| 680 | is.remove();
|
---|
| 681 | }
|
---|
[590] | 682 | }
|
---|
| 683 | }
|
---|
[516] | 684 | }
|
---|
[589] | 685 |
|
---|
[591] | 686 | // Set Port Number
|
---|
| 687 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 688 | void bncApp::setPort(int port) {
|
---|
| 689 | _port = port;
|
---|
| 690 | if (_port != 0) {
|
---|
[942] | 691 | delete _server;
|
---|
[591] | 692 | _server = new QTcpServer;
|
---|
[1228] | 693 | if ( !_server->listen(QHostAddress::Any, _port) ) {
|
---|
[1451] | 694 | slotMessage("bncApp: Cannot listen on ephemeris port", true);
|
---|
[1228] | 695 | }
|
---|
[591] | 696 | connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
---|
[942] | 697 | delete _sockets;
|
---|
[591] | 698 | _sockets = new QList<QTcpSocket*>;
|
---|
| 699 | }
|
---|
| 700 | }
|
---|
| 701 |
|
---|
[937] | 702 | // Set Port Number
|
---|
| 703 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 704 | void bncApp::setPortCorr(int port) {
|
---|
| 705 | _portCorr = port;
|
---|
| 706 | if (_portCorr != 0) {
|
---|
[942] | 707 | delete _serverCorr;
|
---|
[937] | 708 | _serverCorr = new QTcpServer;
|
---|
[1228] | 709 | if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
|
---|
[1451] | 710 | slotMessage("bncApp: Cannot listen on correction port", true);
|
---|
[1228] | 711 | }
|
---|
[937] | 712 | connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
|
---|
[942] | 713 | delete _socketsCorr;
|
---|
[937] | 714 | _socketsCorr = new QList<QTcpSocket*>;
|
---|
| 715 | }
|
---|
| 716 | }
|
---|
| 717 |
|
---|
[589] | 718 | // New Connection
|
---|
| 719 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 720 | void bncApp::slotNewConnection() {
|
---|
| 721 | _sockets->push_back( _server->nextPendingConnection() );
|
---|
| 722 | }
|
---|
| 723 |
|
---|
[937] | 724 | // New Connection
|
---|
| 725 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 726 | void bncApp::slotNewConnectionCorr() {
|
---|
| 727 | _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
|
---|
| 728 | }
|
---|
| 729 |
|
---|
[621] | 730 | //
|
---|
| 731 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 732 | void bncApp::slotQuit() {
|
---|
[1029] | 733 | cout << "bncApp::slotQuit" << endl;
|
---|
[621] | 734 | delete _caster;
|
---|
| 735 | quit();
|
---|
| 736 | }
|
---|
| 737 |
|
---|
[936] | 738 | //
|
---|
| 739 | ////////////////////////////////////////////////////////////////////////////
|
---|
[974] | 740 | void bncApp::slotNewCorrLine(QString line, QString staID, long coTime) {
|
---|
| 741 |
|
---|
| 742 | QMutexLocker locker(&_mutex);
|
---|
| 743 |
|
---|
[2866] | 744 | // Combination of Corrections
|
---|
| 745 | // --------------------------
|
---|
[2899] | 746 | #ifdef USE_COMBINATION
|
---|
[2866] | 747 | if (_bncComb) {
|
---|
| 748 | _bncComb->processCorrLine(staID, line);
|
---|
| 749 | }
|
---|
[2899] | 750 | #endif
|
---|
[2866] | 751 |
|
---|
[1535] | 752 | bncSettings settings;
|
---|
[3109] | 753 | _waitCoTime = settings.value("corrTime").toInt();
|
---|
| 754 | if (_waitCoTime < 0) {
|
---|
| 755 | _waitCoTime = 0;
|
---|
[995] | 756 | }
|
---|
| 757 |
|
---|
[974] | 758 | // First time, set the _lastDumpSec immediately
|
---|
| 759 | // --------------------------------------------
|
---|
| 760 | if (_lastDumpCoSec == 0) {
|
---|
| 761 | _lastDumpCoSec = coTime - 1;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
[975] | 764 | // An old correction - throw it away
|
---|
| 765 | // ---------------------------------
|
---|
[3109] | 766 | if (_waitCoTime > 0 && coTime <= _lastDumpCoSec) {
|
---|
[2916] | 767 | if (!_bncComb) {
|
---|
| 768 | QString line = staID + ": Correction for one sat neglected because overaged by " +
|
---|
| 769 | QString().sprintf(" %ld sec",
|
---|
| 770 | _lastDumpCoSec - coTime + _waitCoTime);
|
---|
| 771 | messagePrivate(line.toAscii());
|
---|
| 772 | emit( newMessage(line.toAscii(), true) );
|
---|
| 773 | }
|
---|
[975] | 774 | return;
|
---|
| 775 | }
|
---|
| 776 |
|
---|
| 777 | _corrs->insert(coTime, QString(line + " " + staID));
|
---|
| 778 |
|
---|
[976] | 779 | // Dump Corrections
|
---|
| 780 | // ----------------
|
---|
[3109] | 781 | if (_waitCoTime == 0) {
|
---|
| 782 | dumpCorrs();
|
---|
| 783 | }
|
---|
| 784 | else if (coTime - _waitCoTime > _lastDumpCoSec) {
|
---|
[976] | 785 | dumpCorrs(_lastDumpCoSec + 1, coTime - _waitCoTime);
|
---|
| 786 | _lastDumpCoSec = coTime - _waitCoTime;
|
---|
| 787 | }
|
---|
| 788 | }
|
---|
| 789 |
|
---|
| 790 | // Dump Complete Correction Epochs
|
---|
| 791 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 792 | void bncApp::dumpCorrs(long minTime, long maxTime) {
|
---|
| 793 | for (long sec = minTime; sec <= maxTime; sec++) {
|
---|
| 794 | QList<QString> allCorrs = _corrs->values(sec);
|
---|
[3109] | 795 | dumpCorrs(allCorrs);
|
---|
| 796 | _corrs->remove(sec);
|
---|
| 797 | }
|
---|
| 798 | }
|
---|
| 799 |
|
---|
| 800 | // Dump all corrections
|
---|
| 801 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 802 | void bncApp::dumpCorrs() {
|
---|
[3110] | 803 | QList<QString> allCorrs;
|
---|
| 804 | QMutableMapIterator<long, QString> it(*_corrs);
|
---|
| 805 | while (it.hasNext()) {
|
---|
| 806 | allCorrs << it.next().value();
|
---|
| 807 | it.remove();
|
---|
| 808 | }
|
---|
| 809 | dumpCorrs(allCorrs);
|
---|
[3109] | 810 | }
|
---|
| 811 |
|
---|
| 812 | // Dump List of Corrections
|
---|
| 813 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 814 | void bncApp::dumpCorrs(const QList<QString>& allCorrs) {
|
---|
| 815 | emit newCorrections(allCorrs);
|
---|
| 816 | if (_socketsCorr) {
|
---|
| 817 | QListIterator<QString> it(allCorrs);
|
---|
| 818 | while (it.hasNext()) {
|
---|
| 819 | QString corrLine = it.next() + "\n";
|
---|
| 820 |
|
---|
| 821 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
|
---|
| 822 | while (is.hasNext()) {
|
---|
| 823 | QTcpSocket* sock = is.next();
|
---|
| 824 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
| 825 | if (sock->write(corrLine.toAscii()) == -1) {
|
---|
[976] | 826 | delete sock;
|
---|
| 827 | is.remove();
|
---|
| 828 | }
|
---|
| 829 | }
|
---|
[3109] | 830 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 831 | delete sock;
|
---|
| 832 | is.remove();
|
---|
| 833 | }
|
---|
[937] | 834 | }
|
---|
| 835 | }
|
---|
| 836 | }
|
---|
[936] | 837 | }
|
---|
[1538] | 838 |
|
---|
| 839 | //
|
---|
| 840 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 841 | void bncApp::setConfFileName(const QString& confFileName) {
|
---|
| 842 | if (confFileName.isEmpty()) {
|
---|
[1539] | 843 | _confFileName = QDir::homePath() + QDir::separator()
|
---|
| 844 | + ".config" + QDir::separator()
|
---|
| 845 | + organizationName() + QDir::separator()
|
---|
| 846 | + applicationName() + ".ini";
|
---|
[1538] | 847 | }
|
---|
| 848 | else {
|
---|
| 849 | _confFileName = confFileName;
|
---|
| 850 | }
|
---|
| 851 | }
|
---|
[2385] | 852 |
|
---|
| 853 | // Raw Output
|
---|
| 854 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2518] | 855 | void bncApp::writeRawData(const QByteArray& data, const QByteArray& staID,
|
---|
| 856 | const QByteArray& format) {
|
---|
[2385] | 857 |
|
---|
[2386] | 858 | QMutexLocker locker(&_mutex);
|
---|
| 859 |
|
---|
[2519] | 860 | if (!_rawFile) {
|
---|
[2386] | 861 | bncSettings settings;
|
---|
[2519] | 862 | QByteArray fileName = settings.value("rawOutFile").toByteArray();
|
---|
| 863 | if (!fileName.isEmpty()) {
|
---|
[3004] | 864 | _rawFile = new bncRawFile(fileName, staID, format, bncRawFile::output);
|
---|
[2407] | 865 | }
|
---|
[2386] | 866 | }
|
---|
| 867 |
|
---|
[2519] | 868 | if (_rawFile) {
|
---|
| 869 | _rawFile->writeRawData(data, staID, format);
|
---|
[2386] | 870 | }
|
---|
[2385] | 871 | }
|
---|
[2672] | 872 |
|
---|
| 873 | // Get Glonass Slot Numbers from Global Array
|
---|
| 874 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 875 | void bncApp::getGlonassSlotNums(int GLOFreq[]) {
|
---|
| 876 |
|
---|
| 877 | QMutexLocker locker(&_mutex);
|
---|
| 878 |
|
---|
[2673] | 879 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
|
---|
| 880 | if (_GLOFreq[ii] != 0) {
|
---|
| 881 | GLOFreq[ii] = _GLOFreq[ii];
|
---|
| 882 | }
|
---|
| 883 | }
|
---|
[2672] | 884 | }
|
---|
| 885 |
|
---|
| 886 | // Store Glonass Slot Numbers to Global Array
|
---|
| 887 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 888 | void bncApp::storeGlonassSlotNums(const int GLOFreq[]) {
|
---|
| 889 |
|
---|
| 890 | QMutexLocker locker(&_mutex);
|
---|
| 891 |
|
---|
[2673] | 892 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) {
|
---|
| 893 | if (GLOFreq[ii] != 0) {
|
---|
| 894 | _GLOFreq[ii] = GLOFreq[ii];
|
---|
| 895 | }
|
---|
| 896 | }
|
---|
[2672] | 897 | }
|
---|
[2909] | 898 |
|
---|
| 899 | //
|
---|
| 900 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 901 | void bncApp::initCombination() {
|
---|
| 902 | #ifdef USE_COMBINATION
|
---|
| 903 | _bncComb = new bncComb();
|
---|
[3142] | 904 | if (_bncComb->nStreams() < 1) {
|
---|
[2909] | 905 | delete _bncComb;
|
---|
| 906 | _bncComb = 0;
|
---|
| 907 | }
|
---|
| 908 | #endif
|
---|
| 909 | }
|
---|