| 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:      t_bncCore | 
|---|
| 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 |  | 
|---|
| 41 | #include <iostream> | 
|---|
| 42 | #include <QMessageBox> | 
|---|
| 43 | #include <cmath> | 
|---|
| 44 |  | 
|---|
| 45 | #include "bnccore.h" | 
|---|
| 46 | #include "bncutils.h" | 
|---|
| 47 | #include "bncrinex.h" | 
|---|
| 48 | #include "bncsettings.h" | 
|---|
| 49 | #include "bncversion.h" | 
|---|
| 50 | #include "ephemeris.h" | 
|---|
| 51 | #include "rinex/rnxobsfile.h" | 
|---|
| 52 | #include "rinex/rnxnavfile.h" | 
|---|
| 53 |  | 
|---|
| 54 | #ifdef USE_COMBINATION | 
|---|
| 55 | #include "combination/bnccomb.h" | 
|---|
| 56 | #endif | 
|---|
| 57 |  | 
|---|
| 58 | using namespace std; | 
|---|
| 59 |  | 
|---|
| 60 | // Singleton | 
|---|
| 61 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 62 | t_bncCore* t_bncCore::instance() { | 
|---|
| 63 | static t_bncCore _bncCore; | 
|---|
| 64 | return &_bncCore; | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | // Constructor | 
|---|
| 68 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 69 | t_bncCore::t_bncCore() { | 
|---|
| 70 | _GUIenabled  = true; | 
|---|
| 71 | _logFileFlag = 0; | 
|---|
| 72 | _logFile     = 0; | 
|---|
| 73 | _logStream   = 0; | 
|---|
| 74 | _rawFile     = 0; | 
|---|
| 75 | _caster      = 0; | 
|---|
| 76 | #ifdef USE_COMBINATION | 
|---|
| 77 | _bncComb     = 0; | 
|---|
| 78 | #endif | 
|---|
| 79 |  | 
|---|
| 80 | // Lists of Ephemeris | 
|---|
| 81 | // ------------------ | 
|---|
| 82 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) { | 
|---|
| 83 | _gpsEph[ii-PRN_GPS_START] = 0; | 
|---|
| 84 | } | 
|---|
| 85 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) { | 
|---|
| 86 | _glonassEph[ii-PRN_GLONASS_START] = 0; | 
|---|
| 87 | } | 
|---|
| 88 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) { | 
|---|
| 89 | _galileoEph[ii-PRN_GALILEO_START] = 0; | 
|---|
| 90 | } | 
|---|
| 91 |  | 
|---|
| 92 | // Eph file(s) | 
|---|
| 93 | // ----------- | 
|---|
| 94 | _rinexVers        = 0; | 
|---|
| 95 | _ephFileGPS       = 0; | 
|---|
| 96 | _ephStreamGPS     = 0; | 
|---|
| 97 | _ephFileGlonass   = 0; | 
|---|
| 98 | _ephStreamGlonass = 0; | 
|---|
| 99 | _ephFileGalileo   = 0; | 
|---|
| 100 | _ephStreamGalileo = 0; | 
|---|
| 101 |  | 
|---|
| 102 | _port    = 0; | 
|---|
| 103 | _server  = 0; | 
|---|
| 104 | _sockets = 0; | 
|---|
| 105 |  | 
|---|
| 106 | _portCorr    = 0; | 
|---|
| 107 | _serverCorr  = 0; | 
|---|
| 108 | _socketsCorr = 0; | 
|---|
| 109 |  | 
|---|
| 110 | _pgmName  = QString(BNCPGMNAME).leftJustified(20, ' ', true); | 
|---|
| 111 | #ifdef WIN32 | 
|---|
| 112 | _userName = QString("${USERNAME}"); | 
|---|
| 113 | #else | 
|---|
| 114 | _userName = QString("${USER}"); | 
|---|
| 115 | #endif | 
|---|
| 116 | expandEnvVar(_userName); | 
|---|
| 117 | _userName = _userName.leftJustified(20, ' ', true); | 
|---|
| 118 |  | 
|---|
| 119 | _corrs = new QMultiMap<bncTime, QString>; | 
|---|
| 120 |  | 
|---|
| 121 | _dateAndTimeGPS = 0; | 
|---|
| 122 |  | 
|---|
| 123 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) { | 
|---|
| 124 | _GLOFreq[ii] = 0; | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | _mainWindow = 0; | 
|---|
| 128 | } | 
|---|
| 129 |  | 
|---|
| 130 | // Destructor | 
|---|
| 131 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 132 | t_bncCore::~t_bncCore() { | 
|---|
| 133 | delete _logStream; | 
|---|
| 134 | delete _logFile; | 
|---|
| 135 | delete _ephStreamGPS; | 
|---|
| 136 | delete _ephFileGPS; | 
|---|
| 137 | delete _server; | 
|---|
| 138 | delete _sockets; | 
|---|
| 139 | delete _serverCorr; | 
|---|
| 140 | delete _socketsCorr; | 
|---|
| 141 | if (_rinexVers == 2) { | 
|---|
| 142 | delete _ephStreamGlonass; | 
|---|
| 143 | delete _ephFileGlonass; | 
|---|
| 144 | } | 
|---|
| 145 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) { | 
|---|
| 146 | delete _gpsEph[ii-PRN_GPS_START]; | 
|---|
| 147 | } | 
|---|
| 148 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) { | 
|---|
| 149 | delete _glonassEph[ii-PRN_GLONASS_START]; | 
|---|
| 150 | } | 
|---|
| 151 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) { | 
|---|
| 152 | delete _galileoEph[ii-PRN_GALILEO_START]; | 
|---|
| 153 | } | 
|---|
| 154 |  | 
|---|
| 155 | delete _corrs; | 
|---|
| 156 |  | 
|---|
| 157 | delete _dateAndTimeGPS; | 
|---|
| 158 |  | 
|---|
| 159 | delete _rawFile; | 
|---|
| 160 |  | 
|---|
| 161 | #ifdef USE_COMBINATION | 
|---|
| 162 | delete _bncComb; | 
|---|
| 163 | #endif | 
|---|
| 164 | } | 
|---|
| 165 |  | 
|---|
| 166 | // Write a Program Message | 
|---|
| 167 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 168 | void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) { | 
|---|
| 169 |  | 
|---|
| 170 | QMutexLocker locker(&_mutexMessage); | 
|---|
| 171 |  | 
|---|
| 172 | messagePrivate(msg); | 
|---|
| 173 | emit newMessage(msg, showOnScreen); | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 | // Write a Program Message (private, no lock) | 
|---|
| 177 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 178 | void t_bncCore::messagePrivate(const QByteArray& msg) { | 
|---|
| 179 |  | 
|---|
| 180 | // First time resolve the log file name | 
|---|
| 181 | // ------------------------------------ | 
|---|
| 182 | QDate currDate = currentDateAndTimeGPS().date(); | 
|---|
| 183 | if (_logFileFlag == 0 || _fileDate != currDate) { | 
|---|
| 184 | delete _logStream; _logStream = 0; | 
|---|
| 185 | delete _logFile;   _logFile   = 0; | 
|---|
| 186 | _logFileFlag = 1; | 
|---|
| 187 | bncSettings settings; | 
|---|
| 188 | QString logFileName = settings.value("logFile").toString(); | 
|---|
| 189 | if ( !logFileName.isEmpty() ) { | 
|---|
| 190 | expandEnvVar(logFileName); | 
|---|
| 191 | _logFile = new QFile(logFileName + "_" + | 
|---|
| 192 | currDate.toString("yyMMdd").toAscii().data()); | 
|---|
| 193 | _fileDate = currDate; | 
|---|
| 194 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) { | 
|---|
| 195 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append); | 
|---|
| 196 | } | 
|---|
| 197 | else { | 
|---|
| 198 | _logFile->open(QIODevice::WriteOnly); | 
|---|
| 199 | } | 
|---|
| 200 | _logStream = new QTextStream(); | 
|---|
| 201 | _logStream->setDevice(_logFile); | 
|---|
| 202 | } | 
|---|
| 203 | } | 
|---|
| 204 |  | 
|---|
| 205 | if (_logStream) { | 
|---|
| 206 | QByteArray msgLocal = msg; | 
|---|
| 207 | if (msg.indexOf('\n') == 0) { | 
|---|
| 208 | *_logStream << endl; | 
|---|
| 209 | msgLocal = msg.mid(1); | 
|---|
| 210 | } | 
|---|
| 211 | *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data(); | 
|---|
| 212 | *_logStream << msgLocal.data() << endl; | 
|---|
| 213 | _logStream->flush(); | 
|---|
| 214 | _logFile->flush(); | 
|---|
| 215 | } | 
|---|
| 216 | } | 
|---|
| 217 |  | 
|---|
| 218 | // New GPS Ephemeris | 
|---|
| 219 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 220 | void t_bncCore::slotNewGPSEph(gpsephemeris* gpseph) { | 
|---|
| 221 |  | 
|---|
| 222 | QMutexLocker locker(&_mutex); | 
|---|
| 223 |  | 
|---|
| 224 | gpsephemeris copy_gpseph = *gpseph; | 
|---|
| 225 | emit newEphGPS(copy_gpseph); | 
|---|
| 226 |  | 
|---|
| 227 | printEphHeader(); | 
|---|
| 228 |  | 
|---|
| 229 | gpsephemeris** ee = &_gpsEph[gpseph->satellite-1]; | 
|---|
| 230 |  | 
|---|
| 231 | if ( *ee != 0 && | 
|---|
| 232 | gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC == (*ee)->TOC ) { | 
|---|
| 233 | checkEphemeris(*ee, gpseph); | 
|---|
| 234 | } | 
|---|
| 235 |  | 
|---|
| 236 | if ( *ee == 0                         || | 
|---|
| 237 | gpseph->GPSweek > (*ee)->GPSweek || | 
|---|
| 238 | (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) { | 
|---|
| 239 | delete *ee; | 
|---|
| 240 | *ee = gpseph; | 
|---|
| 241 | printGPSEph(gpseph, true); | 
|---|
| 242 | } | 
|---|
| 243 | else { | 
|---|
| 244 | printGPSEph(gpseph, false); | 
|---|
| 245 | delete gpseph; | 
|---|
| 246 | } | 
|---|
| 247 | } | 
|---|
| 248 |  | 
|---|
| 249 | // New Glonass Ephemeris | 
|---|
| 250 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 251 | void t_bncCore::slotNewGlonassEph(glonassephemeris* glonasseph, const QString& staID) { | 
|---|
| 252 |  | 
|---|
| 253 | QMutexLocker locker(&_mutex); | 
|---|
| 254 |  | 
|---|
| 255 | // Check wrong Ephemerides | 
|---|
| 256 | // ----------------------- | 
|---|
| 257 | if (glonasseph->x_pos == 0.0 && | 
|---|
| 258 | glonasseph->y_pos == 0.0 && | 
|---|
| 259 | glonasseph->z_pos == 0.0) { | 
|---|
| 260 | delete glonasseph; | 
|---|
| 261 | return; | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | glonassephemeris copy_glonasseph = *glonasseph; | 
|---|
| 265 | emit newEphGlonass(copy_glonasseph); | 
|---|
| 266 |  | 
|---|
| 267 | printEphHeader(); | 
|---|
| 268 |  | 
|---|
| 269 | glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1]; | 
|---|
| 270 |  | 
|---|
| 271 | int wwOld, towOld, wwNew, towNew; | 
|---|
| 272 | if (*ee != 0) { | 
|---|
| 273 | wwOld  = (*ee)->GPSWeek; | 
|---|
| 274 | towOld = (*ee)->GPSTOW; | 
|---|
| 275 | updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0);  // Moscow -> GPS | 
|---|
| 276 |  | 
|---|
| 277 | wwNew  = glonasseph->GPSWeek; | 
|---|
| 278 | towNew = glonasseph->GPSTOW; | 
|---|
| 279 | updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0); // Moscow -> GPS | 
|---|
| 280 | } | 
|---|
| 281 |  | 
|---|
| 282 | if ( *ee == 0      || | 
|---|
| 283 | wwNew > wwOld || | 
|---|
| 284 | (wwNew == wwOld && towNew > towOld) ) { | 
|---|
| 285 | delete *ee; | 
|---|
| 286 | *ee = glonasseph; | 
|---|
| 287 | printGlonassEph(glonasseph, true, staID); | 
|---|
| 288 | } | 
|---|
| 289 | else { | 
|---|
| 290 | printGlonassEph(glonasseph, false, staID); | 
|---|
| 291 | delete glonasseph; | 
|---|
| 292 | } | 
|---|
| 293 | } | 
|---|
| 294 |  | 
|---|
| 295 | // New Galileo Ephemeris | 
|---|
| 296 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 297 | void t_bncCore::slotNewGalileoEph(galileoephemeris* galileoeph) { | 
|---|
| 298 |  | 
|---|
| 299 | QMutexLocker locker(&_mutex); | 
|---|
| 300 |  | 
|---|
| 301 | galileoephemeris copy_galileoeph = *galileoeph; | 
|---|
| 302 | emit newEphGalileo(copy_galileoeph); | 
|---|
| 303 |  | 
|---|
| 304 | printEphHeader(); | 
|---|
| 305 |  | 
|---|
| 306 | int galIndex = galileoeph->satellite; | 
|---|
| 307 | /* GIOVE */ | 
|---|
| 308 | if(galIndex == 51) galIndex = 1; | 
|---|
| 309 | else if(galIndex == 52) galIndex = 16; | 
|---|
| 310 | if (galIndex < 0 || galIndex > PRN_GALILEO_END - PRN_GALILEO_START) { | 
|---|
| 311 | emit( newMessage("Wrong Galileo Satellite Number", true) ); | 
|---|
| 312 | exit(1); | 
|---|
| 313 | } | 
|---|
| 314 |  | 
|---|
| 315 | galileoephemeris** ee = &_galileoEph[galIndex]; | 
|---|
| 316 |  | 
|---|
| 317 | if ( *ee == 0                       || | 
|---|
| 318 | galileoeph->Week > (*ee)->Week || | 
|---|
| 319 | (galileoeph->Week == (*ee)->Week && galileoeph->TOC > (*ee)->TOC) ) { | 
|---|
| 320 | delete *ee; | 
|---|
| 321 | *ee = galileoeph; | 
|---|
| 322 | printGalileoEph(galileoeph, true); | 
|---|
| 323 | } | 
|---|
| 324 | else { | 
|---|
| 325 | printGalileoEph(galileoeph, false); | 
|---|
| 326 | delete galileoeph; | 
|---|
| 327 | } | 
|---|
| 328 | } | 
|---|
| 329 |  | 
|---|
| 330 | // Print Header of the output File(s) | 
|---|
| 331 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 332 | void t_bncCore::printEphHeader() { | 
|---|
| 333 |  | 
|---|
| 334 | bncSettings settings; | 
|---|
| 335 |  | 
|---|
| 336 | // Initialization | 
|---|
| 337 | // -------------- | 
|---|
| 338 | if (_rinexVers == 0) { | 
|---|
| 339 |  | 
|---|
| 340 | if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) { | 
|---|
| 341 | _rinexVers = 3; | 
|---|
| 342 | } | 
|---|
| 343 | else { | 
|---|
| 344 | _rinexVers = 2; | 
|---|
| 345 | } | 
|---|
| 346 |  | 
|---|
| 347 | _ephPath = settings.value("ephPath").toString(); | 
|---|
| 348 |  | 
|---|
| 349 | if ( !_ephPath.isEmpty() ) { | 
|---|
| 350 | if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) { | 
|---|
| 351 | _ephPath += QDir::separator(); | 
|---|
| 352 | } | 
|---|
| 353 | expandEnvVar(_ephPath); | 
|---|
| 354 | } | 
|---|
| 355 | } | 
|---|
| 356 |  | 
|---|
| 357 | // (Re-)Open output File(s) | 
|---|
| 358 | // ------------------------ | 
|---|
| 359 | if (!_ephPath.isEmpty()) { | 
|---|
| 360 |  | 
|---|
| 361 | QDateTime datTim = currentDateAndTimeGPS(); | 
|---|
| 362 |  | 
|---|
| 363 | QString ephFileNameGPS = _ephPath + "BRDC" + | 
|---|
| 364 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')); | 
|---|
| 365 |  | 
|---|
| 366 | QString hlpStr = bncRinex::nextEpochStr(datTim, | 
|---|
| 367 | settings.value("ephIntr").toString()); | 
|---|
| 368 |  | 
|---|
| 369 | if (_rinexVers == 3) { | 
|---|
| 370 | ephFileNameGPS += hlpStr + datTim.toString(".yyP"); | 
|---|
| 371 | } | 
|---|
| 372 | else { | 
|---|
| 373 | ephFileNameGPS += hlpStr + datTim.toString(".yyN"); | 
|---|
| 374 | } | 
|---|
| 375 |  | 
|---|
| 376 | if (_ephFileNameGPS == ephFileNameGPS) { | 
|---|
| 377 | return; | 
|---|
| 378 | } | 
|---|
| 379 | else { | 
|---|
| 380 | _ephFileNameGPS = ephFileNameGPS; | 
|---|
| 381 | } | 
|---|
| 382 |  | 
|---|
| 383 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) { | 
|---|
| 384 | delete _gpsEph[ii-PRN_GPS_START]; | 
|---|
| 385 | _gpsEph[ii-PRN_GPS_START] = 0; | 
|---|
| 386 | } | 
|---|
| 387 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) { | 
|---|
| 388 | delete _glonassEph[ii-PRN_GLONASS_START]; | 
|---|
| 389 | _glonassEph[ii-PRN_GLONASS_START] = 0; | 
|---|
| 390 | } | 
|---|
| 391 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) { | 
|---|
| 392 | delete _galileoEph[ii-PRN_GALILEO_START]; | 
|---|
| 393 | _galileoEph[ii-PRN_GALILEO_START] = 0; | 
|---|
| 394 | } | 
|---|
| 395 |  | 
|---|
| 396 | delete _ephStreamGPS; | 
|---|
| 397 | delete _ephFileGPS; | 
|---|
| 398 |  | 
|---|
| 399 | QFlags<QIODevice::OpenModeFlag> appendFlagGPS; | 
|---|
| 400 | QFlags<QIODevice::OpenModeFlag> appendFlagGlonass; | 
|---|
| 401 | QFlags<QIODevice::OpenModeFlag> appendFlagGalileo; | 
|---|
| 402 |  | 
|---|
| 403 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked && | 
|---|
| 404 | QFile::exists(ephFileNameGPS) ) { | 
|---|
| 405 | appendFlagGPS = QIODevice::Append; | 
|---|
| 406 | } | 
|---|
| 407 |  | 
|---|
| 408 | _ephFileGPS = new QFile(ephFileNameGPS); | 
|---|
| 409 | _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS); | 
|---|
| 410 | _ephStreamGPS = new QTextStream(); | 
|---|
| 411 | _ephStreamGPS->setDevice(_ephFileGPS); | 
|---|
| 412 |  | 
|---|
| 413 | if      (_rinexVers == 3) { | 
|---|
| 414 | _ephFileGlonass   = _ephFileGPS; | 
|---|
| 415 | _ephStreamGlonass = _ephStreamGPS; | 
|---|
| 416 | _ephFileGalileo   = _ephFileGPS; | 
|---|
| 417 | _ephStreamGalileo = _ephStreamGPS; | 
|---|
| 418 | } | 
|---|
| 419 | else if (_rinexVers == 2) { | 
|---|
| 420 | QString ephFileNameGlonass = _ephPath + "BRDC" + | 
|---|
| 421 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) + | 
|---|
| 422 | hlpStr + datTim.toString(".yyG"); | 
|---|
| 423 |  | 
|---|
| 424 | delete _ephStreamGlonass; | 
|---|
| 425 | delete _ephFileGlonass; | 
|---|
| 426 |  | 
|---|
| 427 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked && | 
|---|
| 428 | QFile::exists(ephFileNameGlonass) ) { | 
|---|
| 429 | appendFlagGlonass = QIODevice::Append; | 
|---|
| 430 | } | 
|---|
| 431 |  | 
|---|
| 432 | _ephFileGlonass = new QFile(ephFileNameGlonass); | 
|---|
| 433 | _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass); | 
|---|
| 434 | _ephStreamGlonass = new QTextStream(); | 
|---|
| 435 | _ephStreamGlonass->setDevice(_ephFileGlonass); | 
|---|
| 436 | } | 
|---|
| 437 |  | 
|---|
| 438 | // Header - RINEX Version 3 | 
|---|
| 439 | // ------------------------ | 
|---|
| 440 | if (_rinexVers == 3) { | 
|---|
| 441 | if ( ! (appendFlagGPS & QIODevice::Append)) { | 
|---|
| 442 | QString line; | 
|---|
| 443 | line.sprintf( | 
|---|
| 444 | "%9.2f%11sN: GNSS NAV DATA    M: Mixed%12sRINEX VERSION / TYPE\n", | 
|---|
| 445 | 3.0, "", ""); | 
|---|
| 446 | *_ephStreamGPS << line; | 
|---|
| 447 |  | 
|---|
| 448 | QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true); | 
|---|
| 449 | *_ephStreamGPS << _pgmName.toAscii().data() | 
|---|
| 450 | << _userName.toAscii().data() | 
|---|
| 451 | << hlp.toAscii().data() | 
|---|
| 452 | << "PGM / RUN BY / DATE" << endl; | 
|---|
| 453 |  | 
|---|
| 454 | line.sprintf("%60sEND OF HEADER\n", ""); | 
|---|
| 455 | *_ephStreamGPS << line; | 
|---|
| 456 |  | 
|---|
| 457 | _ephStreamGPS->flush(); | 
|---|
| 458 | } | 
|---|
| 459 | } | 
|---|
| 460 |  | 
|---|
| 461 | // Headers - RINEX Version 2 | 
|---|
| 462 | // ------------------------- | 
|---|
| 463 | else if (_rinexVers == 2) { | 
|---|
| 464 | if (! (appendFlagGPS & QIODevice::Append)) { | 
|---|
| 465 | QString line; | 
|---|
| 466 | line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", | 
|---|
| 467 | t_rnxNavFile::defaultRnxNavVersion2, "", ""); | 
|---|
| 468 | *_ephStreamGPS << line; | 
|---|
| 469 |  | 
|---|
| 470 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true); | 
|---|
| 471 | *_ephStreamGPS << _pgmName.toAscii().data() | 
|---|
| 472 | << _userName.toAscii().data() | 
|---|
| 473 | << hlp.toAscii().data() | 
|---|
| 474 | << "PGM / RUN BY / DATE" << endl; | 
|---|
| 475 |  | 
|---|
| 476 | line.sprintf("%60sEND OF HEADER\n", ""); | 
|---|
| 477 | *_ephStreamGPS << line; | 
|---|
| 478 |  | 
|---|
| 479 | _ephStreamGPS->flush(); | 
|---|
| 480 | } | 
|---|
| 481 | if (! (appendFlagGlonass & QIODevice::Append)) { | 
|---|
| 482 | QString line; | 
|---|
| 483 | line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n", | 
|---|
| 484 | t_rnxNavFile::defaultRnxNavVersion2, "", ""); | 
|---|
| 485 | *_ephStreamGlonass << line; | 
|---|
| 486 |  | 
|---|
| 487 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true); | 
|---|
| 488 | *_ephStreamGlonass << _pgmName.toAscii().data() | 
|---|
| 489 | << _userName.toAscii().data() | 
|---|
| 490 | << hlp.toAscii().data() | 
|---|
| 491 | << "PGM / RUN BY / DATE" << endl; | 
|---|
| 492 |  | 
|---|
| 493 | line.sprintf("%60sEND OF HEADER\n", ""); | 
|---|
| 494 | *_ephStreamGlonass << line; | 
|---|
| 495 |  | 
|---|
| 496 | _ephStreamGlonass->flush(); | 
|---|
| 497 | } | 
|---|
| 498 | } | 
|---|
| 499 | } | 
|---|
| 500 | } | 
|---|
| 501 |  | 
|---|
| 502 | // Print One GPS Ephemeris | 
|---|
| 503 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 504 | void t_bncCore::printGPSEph(gpsephemeris* ep, bool printFile) { | 
|---|
| 505 |  | 
|---|
| 506 | t_ephGPS eph; | 
|---|
| 507 | eph.set(ep); | 
|---|
| 508 |  | 
|---|
| 509 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2); | 
|---|
| 510 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3); | 
|---|
| 511 |  | 
|---|
| 512 | printOutput(printFile, _ephStreamGPS, strV2, strV3); | 
|---|
| 513 | } | 
|---|
| 514 |  | 
|---|
| 515 | // Print One Glonass Ephemeris | 
|---|
| 516 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 517 | void t_bncCore::printGlonassEph(glonassephemeris* ep, bool printFile, const QString& /* staID */) { | 
|---|
| 518 |  | 
|---|
| 519 | t_ephGlo eph; | 
|---|
| 520 | eph.set(ep); | 
|---|
| 521 |  | 
|---|
| 522 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2); | 
|---|
| 523 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3); | 
|---|
| 524 |  | 
|---|
| 525 | //// beg test Dirk | 
|---|
| 526 | // QString hlp = strV2; | 
|---|
| 527 | // cout << hlp.replace('\n', ' ').toAscii().data() << ' ' << staID.toAscii().data() << endl; | 
|---|
| 528 | //// end test Dirk | 
|---|
| 529 |  | 
|---|
| 530 | printOutput(printFile, _ephStreamGlonass, strV2, strV3); | 
|---|
| 531 | } | 
|---|
| 532 |  | 
|---|
| 533 | // Print One Galileo Ephemeris | 
|---|
| 534 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 535 | void t_bncCore::printGalileoEph(galileoephemeris* ep, bool printFile) { | 
|---|
| 536 |  | 
|---|
| 537 | t_ephGal eph; | 
|---|
| 538 | eph.set(ep); | 
|---|
| 539 |  | 
|---|
| 540 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2); | 
|---|
| 541 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3); | 
|---|
| 542 |  | 
|---|
| 543 | printOutput(printFile, _ephStreamGalileo, strV2, strV3); | 
|---|
| 544 | } | 
|---|
| 545 |  | 
|---|
| 546 | // Output | 
|---|
| 547 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 548 | void t_bncCore::printOutput(bool printFile, QTextStream* stream, | 
|---|
| 549 | const QString& strV2, const QString& strV3) { | 
|---|
| 550 |  | 
|---|
| 551 | // Output into file | 
|---|
| 552 | // ---------------- | 
|---|
| 553 | if (printFile && stream) { | 
|---|
| 554 | if (_rinexVers == 2) { | 
|---|
| 555 | *stream << strV2.toAscii(); | 
|---|
| 556 | } | 
|---|
| 557 | else { | 
|---|
| 558 | *stream << strV3.toAscii(); | 
|---|
| 559 | } | 
|---|
| 560 | stream->flush(); | 
|---|
| 561 | } | 
|---|
| 562 |  | 
|---|
| 563 | // Output into the socket | 
|---|
| 564 | // ---------------------- | 
|---|
| 565 | if (_sockets) { | 
|---|
| 566 | QMutableListIterator<QTcpSocket*> is(*_sockets); | 
|---|
| 567 | while (is.hasNext()) { | 
|---|
| 568 | QTcpSocket* sock = is.next(); | 
|---|
| 569 | if (sock->state() == QAbstractSocket::ConnectedState) { | 
|---|
| 570 | if (sock->write(strV3.toAscii()) == -1) { | 
|---|
| 571 | delete sock; | 
|---|
| 572 | is.remove(); | 
|---|
| 573 | } | 
|---|
| 574 | } | 
|---|
| 575 | else if (sock->state() != QAbstractSocket::ConnectingState) { | 
|---|
| 576 | delete sock; | 
|---|
| 577 | is.remove(); | 
|---|
| 578 | } | 
|---|
| 579 | } | 
|---|
| 580 | } | 
|---|
| 581 | } | 
|---|
| 582 |  | 
|---|
| 583 | // Set Port Number | 
|---|
| 584 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 585 | void t_bncCore::setPort(int port) { | 
|---|
| 586 | _port = port; | 
|---|
| 587 | if (_port != 0) { | 
|---|
| 588 | delete _server; | 
|---|
| 589 | _server = new QTcpServer; | 
|---|
| 590 | if ( !_server->listen(QHostAddress::Any, _port) ) { | 
|---|
| 591 | slotMessage("t_bncCore: Cannot listen on ephemeris port", true); | 
|---|
| 592 | } | 
|---|
| 593 | connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); | 
|---|
| 594 | delete _sockets; | 
|---|
| 595 | _sockets = new QList<QTcpSocket*>; | 
|---|
| 596 | } | 
|---|
| 597 | } | 
|---|
| 598 |  | 
|---|
| 599 | // Set Port Number | 
|---|
| 600 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 601 | void t_bncCore::setPortCorr(int port) { | 
|---|
| 602 | _portCorr = port; | 
|---|
| 603 | if (_portCorr != 0) { | 
|---|
| 604 | delete _serverCorr; | 
|---|
| 605 | _serverCorr = new QTcpServer; | 
|---|
| 606 | if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) { | 
|---|
| 607 | slotMessage("t_bncCore: Cannot listen on correction port", true); | 
|---|
| 608 | } | 
|---|
| 609 | connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr())); | 
|---|
| 610 | delete _socketsCorr; | 
|---|
| 611 | _socketsCorr = new QList<QTcpSocket*>; | 
|---|
| 612 | } | 
|---|
| 613 | } | 
|---|
| 614 |  | 
|---|
| 615 | // New Connection | 
|---|
| 616 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 617 | void t_bncCore::slotNewConnection() { | 
|---|
| 618 | _sockets->push_back( _server->nextPendingConnection() ); | 
|---|
| 619 | } | 
|---|
| 620 |  | 
|---|
| 621 | // New Connection | 
|---|
| 622 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 623 | void t_bncCore::slotNewConnectionCorr() { | 
|---|
| 624 | _socketsCorr->push_back( _serverCorr->nextPendingConnection() ); | 
|---|
| 625 | } | 
|---|
| 626 |  | 
|---|
| 627 | // | 
|---|
| 628 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 629 | void t_bncCore::slotQuit() { | 
|---|
| 630 | cout << "t_bncCore::slotQuit" << endl; | 
|---|
| 631 | delete _caster; _caster = 0; | 
|---|
| 632 | qApp->quit(); | 
|---|
| 633 | } | 
|---|
| 634 |  | 
|---|
| 635 | // | 
|---|
| 636 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 637 | void t_bncCore::slotNewCorrLine(QString line, QString staID, bncTime coTime) { | 
|---|
| 638 |  | 
|---|
| 639 | QMutexLocker locker(&_mutex); | 
|---|
| 640 |  | 
|---|
| 641 | // Combination of Corrections | 
|---|
| 642 | // -------------------------- | 
|---|
| 643 | #ifdef USE_COMBINATION | 
|---|
| 644 | if (_bncComb) { | 
|---|
| 645 | _bncComb->processCorrLine(staID, line); | 
|---|
| 646 | } | 
|---|
| 647 | #endif | 
|---|
| 648 |  | 
|---|
| 649 | bncSettings settings; | 
|---|
| 650 | _waitCoTime = settings.value("corrTime").toDouble(); | 
|---|
| 651 | if (_waitCoTime < 0.0) { | 
|---|
| 652 | _waitCoTime = 0.0; | 
|---|
| 653 | } | 
|---|
| 654 |  | 
|---|
| 655 | // First time, set the _lastCorrDumpTime | 
|---|
| 656 | // ------------------------------------- | 
|---|
| 657 | if (!_lastCorrDumpTime[staID].valid()) { | 
|---|
| 658 | _lastCorrDumpTime[staID] = coTime - 1.0; | 
|---|
| 659 | } | 
|---|
| 660 |  | 
|---|
| 661 | // An old correction - throw it away | 
|---|
| 662 | // --------------------------------- | 
|---|
| 663 | if (_waitCoTime > 0.0 && coTime <= _lastCorrDumpTime[staID]) { | 
|---|
| 664 | if (!_bncComb) { | 
|---|
| 665 | QString line = staID + ": Correction for one sat neglected because overaged by " + | 
|---|
| 666 | QString().sprintf(" %f sec", | 
|---|
| 667 | _lastCorrDumpTime[staID] - coTime + _waitCoTime); | 
|---|
| 668 | messagePrivate(line.toAscii()); | 
|---|
| 669 | emit( newMessage(line.toAscii(), true) ); | 
|---|
| 670 | } | 
|---|
| 671 | return; | 
|---|
| 672 | } | 
|---|
| 673 |  | 
|---|
| 674 | _corrs->insert(coTime, QString(line + " " + staID)); | 
|---|
| 675 |  | 
|---|
| 676 | // Dump Corrections | 
|---|
| 677 | // ---------------- | 
|---|
| 678 | if      (_waitCoTime == 0.0) { | 
|---|
| 679 | dumpCorrs(); | 
|---|
| 680 | } | 
|---|
| 681 | else if (coTime - _waitCoTime > _lastCorrDumpTime[staID]) { | 
|---|
| 682 | dumpCorrs(_lastCorrDumpTime[staID] + 1, coTime - _waitCoTime); | 
|---|
| 683 | _lastCorrDumpTime[staID] = coTime - _waitCoTime; | 
|---|
| 684 | } | 
|---|
| 685 | } | 
|---|
| 686 |  | 
|---|
| 687 | // Dump Complete Correction Epochs | 
|---|
| 688 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 689 | void t_bncCore::dumpCorrs(bncTime minTime, bncTime maxTime) { | 
|---|
| 690 | QStringList allCorrs; | 
|---|
| 691 | QMutableMapIterator<bncTime, QString> it(*_corrs); | 
|---|
| 692 | while (it.hasNext()) { | 
|---|
| 693 | it.next(); | 
|---|
| 694 | const bncTime& corrTime = it.key(); | 
|---|
| 695 | if (minTime <= corrTime && corrTime <= maxTime) { | 
|---|
| 696 | allCorrs << it.value(); | 
|---|
| 697 | it.remove(); | 
|---|
| 698 | } | 
|---|
| 699 | } | 
|---|
| 700 | dumpCorrs(allCorrs); | 
|---|
| 701 | } | 
|---|
| 702 |  | 
|---|
| 703 | // Dump all corrections | 
|---|
| 704 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 705 | void t_bncCore::dumpCorrs() { | 
|---|
| 706 | QStringList allCorrs; | 
|---|
| 707 | QMutableMapIterator<bncTime, QString> it(*_corrs); | 
|---|
| 708 | while (it.hasNext()) { | 
|---|
| 709 | allCorrs << it.next().value(); | 
|---|
| 710 | it.remove(); | 
|---|
| 711 | } | 
|---|
| 712 | dumpCorrs(allCorrs); | 
|---|
| 713 | } | 
|---|
| 714 |  | 
|---|
| 715 | // Dump List of Corrections | 
|---|
| 716 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 717 | void t_bncCore::dumpCorrs(const QStringList& allCorrs) { | 
|---|
| 718 | emit newCorrections(allCorrs); | 
|---|
| 719 | if (_socketsCorr) { | 
|---|
| 720 | QListIterator<QString> it(allCorrs); | 
|---|
| 721 | while (it.hasNext()) { | 
|---|
| 722 | QString corrLine = it.next() + "\n"; | 
|---|
| 723 |  | 
|---|
| 724 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr); | 
|---|
| 725 | while (is.hasNext()) { | 
|---|
| 726 | QTcpSocket* sock = is.next(); | 
|---|
| 727 | if (sock->state() == QAbstractSocket::ConnectedState) { | 
|---|
| 728 | if (sock->write(corrLine.toAscii()) == -1) { | 
|---|
| 729 | delete sock; | 
|---|
| 730 | is.remove(); | 
|---|
| 731 | } | 
|---|
| 732 | } | 
|---|
| 733 | else if (sock->state() != QAbstractSocket::ConnectingState) { | 
|---|
| 734 | delete sock; | 
|---|
| 735 | is.remove(); | 
|---|
| 736 | } | 
|---|
| 737 | } | 
|---|
| 738 | } | 
|---|
| 739 | } | 
|---|
| 740 | } | 
|---|
| 741 |  | 
|---|
| 742 | // | 
|---|
| 743 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 744 | void t_bncCore::setConfFileName(const QString& confFileName) { | 
|---|
| 745 | if (confFileName.isEmpty()) { | 
|---|
| 746 | _confFileName = QDir::homePath() + QDir::separator() | 
|---|
| 747 | + ".config" + QDir::separator() | 
|---|
| 748 | + qApp->organizationName() + QDir::separator() | 
|---|
| 749 | + qApp->applicationName() + ".bnc"; | 
|---|
| 750 | } | 
|---|
| 751 | else { | 
|---|
| 752 | _confFileName = confFileName; | 
|---|
| 753 | } | 
|---|
| 754 | } | 
|---|
| 755 |  | 
|---|
| 756 | // Raw Output | 
|---|
| 757 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 758 | void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID, | 
|---|
| 759 | const QByteArray& format) { | 
|---|
| 760 |  | 
|---|
| 761 | QMutexLocker locker(&_mutex); | 
|---|
| 762 |  | 
|---|
| 763 | if (!_rawFile) { | 
|---|
| 764 | bncSettings settings; | 
|---|
| 765 | QByteArray fileName = settings.value("rawOutFile").toByteArray(); | 
|---|
| 766 | if (!fileName.isEmpty()) { | 
|---|
| 767 | _rawFile = new bncRawFile(fileName, staID, bncRawFile::output); | 
|---|
| 768 | } | 
|---|
| 769 | } | 
|---|
| 770 |  | 
|---|
| 771 | if (_rawFile) { | 
|---|
| 772 | _rawFile->writeRawData(data, staID, format); | 
|---|
| 773 | } | 
|---|
| 774 | } | 
|---|
| 775 |  | 
|---|
| 776 | // Get Glonass Slot Numbers from Global Array | 
|---|
| 777 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 778 | void t_bncCore::getGlonassSlotNums(int GLOFreq[]) { | 
|---|
| 779 |  | 
|---|
| 780 | QMutexLocker locker(&_mutex); | 
|---|
| 781 |  | 
|---|
| 782 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) { | 
|---|
| 783 | if (_GLOFreq[ii] != 0) { | 
|---|
| 784 | GLOFreq[ii] = _GLOFreq[ii]; | 
|---|
| 785 | } | 
|---|
| 786 | } | 
|---|
| 787 | } | 
|---|
| 788 |  | 
|---|
| 789 | // Store Glonass Slot Numbers to Global Array | 
|---|
| 790 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 791 | void t_bncCore::storeGlonassSlotNums(const int GLOFreq[]) { | 
|---|
| 792 |  | 
|---|
| 793 | QMutexLocker locker(&_mutex); | 
|---|
| 794 |  | 
|---|
| 795 | for (int ii = 0; ii < PRN_GLONASS_NUM; ++ii) { | 
|---|
| 796 | if (GLOFreq[ii] != 0) { | 
|---|
| 797 | _GLOFreq[ii] = GLOFreq[ii]; | 
|---|
| 798 | } | 
|---|
| 799 | } | 
|---|
| 800 | } | 
|---|
| 801 |  | 
|---|
| 802 | // | 
|---|
| 803 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 804 | void t_bncCore::initCombination() { | 
|---|
| 805 | #ifdef USE_COMBINATION | 
|---|
| 806 | _bncComb = new bncComb(); | 
|---|
| 807 | if (_bncComb->nStreams() < 1) { | 
|---|
| 808 | delete _bncComb; | 
|---|
| 809 | _bncComb = 0; | 
|---|
| 810 | } | 
|---|
| 811 | #endif | 
|---|
| 812 | } | 
|---|
| 813 |  | 
|---|
| 814 | // | 
|---|
| 815 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 816 | void t_bncCore::stopCombination() { | 
|---|
| 817 | #ifdef USE_COMBINATION | 
|---|
| 818 | delete _bncComb; | 
|---|
| 819 | _bncComb = 0; | 
|---|
| 820 | #endif | 
|---|
| 821 | } | 
|---|
| 822 |  | 
|---|
| 823 | // Check Ephemeris Consistency | 
|---|
| 824 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 825 | void t_bncCore::checkEphemeris(gpsephemeris* oldEph, gpsephemeris* newEph) { | 
|---|
| 826 | if (oldEph->clock_bias      != newEph->clock_bias      || | 
|---|
| 827 | oldEph->clock_drift     != newEph->clock_drift     || | 
|---|
| 828 | oldEph->clock_driftrate != newEph->clock_driftrate) { | 
|---|
| 829 | QString msg = currentDateAndTimeGPS().toString(Qt::ISODate) + | 
|---|
| 830 | QString(" %1 EPH DIFFERS\n").arg(oldEph->satellite); | 
|---|
| 831 | messagePrivate(msg.toAscii()); | 
|---|
| 832 | } | 
|---|
| 833 | } | 
|---|
| 834 |  | 
|---|
| 835 |  | 
|---|
| 836 | // | 
|---|
| 837 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 838 | bool t_bncCore::dateAndTimeGPSSet() const { | 
|---|
| 839 | QMutexLocker locker(&_mutexDateAndTimeGPS); | 
|---|
| 840 | if (_dateAndTimeGPS) { | 
|---|
| 841 | return true; | 
|---|
| 842 | } | 
|---|
| 843 | else { | 
|---|
| 844 | return false; | 
|---|
| 845 | } | 
|---|
| 846 | } | 
|---|
| 847 |  | 
|---|
| 848 | // | 
|---|
| 849 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 850 | QDateTime t_bncCore::dateAndTimeGPS() const { | 
|---|
| 851 | QMutexLocker locker(&_mutexDateAndTimeGPS); | 
|---|
| 852 | if (_dateAndTimeGPS) { | 
|---|
| 853 | return *_dateAndTimeGPS; | 
|---|
| 854 | } | 
|---|
| 855 | else { | 
|---|
| 856 | return QDateTime(); | 
|---|
| 857 | } | 
|---|
| 858 | } | 
|---|
| 859 |  | 
|---|
| 860 | // | 
|---|
| 861 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 862 | void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) { | 
|---|
| 863 | QMutexLocker locker(&_mutexDateAndTimeGPS); | 
|---|
| 864 | delete _dateAndTimeGPS; | 
|---|
| 865 | _dateAndTimeGPS = new QDateTime(dateTime); | 
|---|
| 866 | } | 
|---|