| 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: bncParam, bncModel
|
|---|
| 30 | *
|
|---|
| 31 | * Purpose: Model for PPP
|
|---|
| 32 | *
|
|---|
| 33 | * Author: L. Mervart
|
|---|
| 34 | *
|
|---|
| 35 | * Created: 01-Dec-2009
|
|---|
| 36 | *
|
|---|
| 37 | * Changes:
|
|---|
| 38 | *
|
|---|
| 39 | * -----------------------------------------------------------------------*/
|
|---|
| 40 |
|
|---|
| 41 | #include <iomanip>
|
|---|
| 42 | #include <cmath>
|
|---|
| 43 | #include <newmatio.h>
|
|---|
| 44 | #include <sstream>
|
|---|
| 45 |
|
|---|
| 46 | #include "bncmodel.h"
|
|---|
| 47 | #include "bncapp.h"
|
|---|
| 48 | #include "bncpppclient.h"
|
|---|
| 49 | #include "bancroft.h"
|
|---|
| 50 | #include "bncutils.h"
|
|---|
| 51 | #include "bncsettings.h"
|
|---|
| 52 |
|
|---|
| 53 | using namespace std;
|
|---|
| 54 |
|
|---|
| 55 | const unsigned MINOBS = 4;
|
|---|
| 56 | const double MINELE = 10.0 * M_PI / 180.0;
|
|---|
| 57 | const double MAXRES_CODE_GPS = 10.0;
|
|---|
| 58 | const double MAXRES_PHASE_GPS = 0.10;
|
|---|
| 59 | const double MAXRES_PHASE_GLO = 0.10;
|
|---|
| 60 | const double sig_crd_0 = 100.0;
|
|---|
| 61 | const double sig_crd_p = 100.0;
|
|---|
| 62 | const double sig_clk_0 = 100.0;
|
|---|
| 63 | const double sig_trp_0 = 0.01;
|
|---|
| 64 | const double sig_trp_p = 1e-6;
|
|---|
| 65 | const double sig_amb_0_GPS = 100.0;
|
|---|
| 66 | const double sig_amb_0_GLO = 1000.0;
|
|---|
| 67 | const double sig_P3 = 1.0;
|
|---|
| 68 | const double sig_L3_GPS = 0.01;
|
|---|
| 69 | const double sig_L3_GLO = 0.01;
|
|---|
| 70 |
|
|---|
| 71 | // Constructor
|
|---|
| 72 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 73 | bncParam::bncParam(bncParam::parType typeIn, int indexIn,
|
|---|
| 74 | const QString& prnIn) {
|
|---|
| 75 | type = typeIn;
|
|---|
| 76 | index = indexIn;
|
|---|
| 77 | prn = prnIn;
|
|---|
| 78 | index_old = 0;
|
|---|
| 79 | xx = 0.0;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // Destructor
|
|---|
| 83 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 84 | bncParam::~bncParam() {
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | // Partial
|
|---|
| 88 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 89 | double bncParam::partial(t_satData* satData, bool phase) {
|
|---|
| 90 |
|
|---|
| 91 | // Coordinates
|
|---|
| 92 | // -----------
|
|---|
| 93 | if (type == CRD_X) {
|
|---|
| 94 | return (xx - satData->xx(1)) / satData->rho;
|
|---|
| 95 | }
|
|---|
| 96 | else if (type == CRD_Y) {
|
|---|
| 97 | return (xx - satData->xx(2)) / satData->rho;
|
|---|
| 98 | }
|
|---|
| 99 | else if (type == CRD_Z) {
|
|---|
| 100 | return (xx - satData->xx(3)) / satData->rho;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | // Receiver Clocks
|
|---|
| 104 | // ---------------
|
|---|
| 105 | else if (type == RECCLK) {
|
|---|
| 106 | return 1.0;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | // Troposphere
|
|---|
| 110 | // -----------
|
|---|
| 111 | else if (type == TROPO) {
|
|---|
| 112 | return 1.0 / sin(satData->eleSat);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // Ambiguities
|
|---|
| 116 | // -----------
|
|---|
| 117 | else if (type == AMB_L3) {
|
|---|
| 118 | if (phase && satData->prn == prn) {
|
|---|
| 119 | return 1.0;
|
|---|
| 120 | }
|
|---|
| 121 | else {
|
|---|
| 122 | return 0.0;
|
|---|
| 123 | }
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | // Default return
|
|---|
| 127 | // --------------
|
|---|
| 128 | return 0.0;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // Constructor
|
|---|
| 132 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 133 | bncModel::bncModel(QByteArray staID) {
|
|---|
| 134 |
|
|---|
| 135 | _staID = staID;
|
|---|
| 136 |
|
|---|
| 137 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 138 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| 139 |
|
|---|
| 140 | bncSettings settings;
|
|---|
| 141 |
|
|---|
| 142 | _static = false;
|
|---|
| 143 | if ( Qt::CheckState(settings.value("pppStatic").toInt()) == Qt::Checked) {
|
|---|
| 144 | _static = true;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | _usePhase = false;
|
|---|
| 148 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
|
|---|
| 149 | _usePhase = true;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | _estTropo = false;
|
|---|
| 153 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
|---|
| 154 | _estTropo = true;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
|---|
| 158 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
|---|
| 159 |
|
|---|
| 160 | if (_usePhase &&
|
|---|
| 161 | Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
|---|
| 162 | _useGlonass = true;
|
|---|
| 163 | }
|
|---|
| 164 | else {
|
|---|
| 165 | _useGlonass = false;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | int nextPar = 0;
|
|---|
| 169 | _params.push_back(new bncParam(bncParam::CRD_X, ++nextPar, ""));
|
|---|
| 170 | _params.push_back(new bncParam(bncParam::CRD_Y, ++nextPar, ""));
|
|---|
| 171 | _params.push_back(new bncParam(bncParam::CRD_Z, ++nextPar, ""));
|
|---|
| 172 | _params.push_back(new bncParam(bncParam::RECCLK, ++nextPar, ""));
|
|---|
| 173 | if (_estTropo) {
|
|---|
| 174 | _params.push_back(new bncParam(bncParam::TROPO, ++nextPar, ""));
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | unsigned nPar = _params.size();
|
|---|
| 178 |
|
|---|
| 179 | _QQ.ReSize(nPar);
|
|---|
| 180 |
|
|---|
| 181 | _QQ = 0.0;
|
|---|
| 182 |
|
|---|
| 183 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 184 | bncParam* pp = _params[iPar-1];
|
|---|
| 185 | if (pp->isCrd()) {
|
|---|
| 186 | _QQ(iPar,iPar) = sig_crd_0 * sig_crd_0;
|
|---|
| 187 | }
|
|---|
| 188 | else if (pp->type == bncParam::RECCLK) {
|
|---|
| 189 | _QQ(iPar,iPar) = sig_clk_0 * sig_clk_0;
|
|---|
| 190 | }
|
|---|
| 191 | else if (pp->type == bncParam::TROPO) {
|
|---|
| 192 | _QQ(iPar,iPar) = sig_trp_0 * sig_trp_0;
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | // NMEA Output
|
|---|
| 197 | // -----------
|
|---|
| 198 | QString nmeaFileName = settings.value("nmeaFile").toString();
|
|---|
| 199 | if (nmeaFileName.isEmpty()) {
|
|---|
| 200 | _nmeaFile = 0;
|
|---|
| 201 | _nmeaStream = 0;
|
|---|
| 202 | }
|
|---|
| 203 | else {
|
|---|
| 204 | expandEnvVar(nmeaFileName);
|
|---|
| 205 | _nmeaFile = new QFile(nmeaFileName);
|
|---|
| 206 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
|---|
| 207 | _nmeaFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
|---|
| 208 | }
|
|---|
| 209 | else {
|
|---|
| 210 | _nmeaFile->open(QIODevice::WriteOnly);
|
|---|
| 211 | }
|
|---|
| 212 | _nmeaStream = new QTextStream();
|
|---|
| 213 | _nmeaStream->setDevice(_nmeaFile);
|
|---|
| 214 | QDateTime dateTime = QDateTime::currentDateTime().toUTC();
|
|---|
| 215 | QString nmStr = "GPRMC," + dateTime.time().toString("hhmmss")
|
|---|
| 216 | + ",A,,,,,,,"
|
|---|
| 217 | + dateTime.date().toString("ddMMyy")
|
|---|
| 218 | + ",,";
|
|---|
| 219 |
|
|---|
| 220 | writeNMEAstr(nmStr);
|
|---|
| 221 | }
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | // Destructor
|
|---|
| 225 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 226 | bncModel::~bncModel() {
|
|---|
| 227 | delete _nmeaStream;
|
|---|
| 228 | delete _nmeaFile;
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | // Bancroft Solution
|
|---|
| 232 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 233 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
|---|
| 234 |
|
|---|
| 235 | if (epoData->sizeGPS() < MINOBS) {
|
|---|
| 236 | _log += "\nNot enough data";
|
|---|
| 237 | return failure;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | Matrix BB(epoData->sizeGPS(), 4);
|
|---|
| 241 |
|
|---|
| 242 | QMapIterator<QString, t_satData*> it(epoData->satDataGPS);
|
|---|
| 243 | int iObs = 0;
|
|---|
| 244 | while (it.hasNext()) {
|
|---|
| 245 | ++iObs;
|
|---|
| 246 | it.next();
|
|---|
| 247 | QString prn = it.key();
|
|---|
| 248 | t_satData* satData = it.value();
|
|---|
| 249 | BB(iObs, 1) = satData->xx(1);
|
|---|
| 250 | BB(iObs, 2) = satData->xx(2);
|
|---|
| 251 | BB(iObs, 3) = satData->xx(3);
|
|---|
| 252 | BB(iObs, 4) = satData->P3 + satData->clk;
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | bancroft(BB, _xcBanc);
|
|---|
| 256 |
|
|---|
| 257 | // Ellipsoidal Coordinates
|
|---|
| 258 | // ------------------------
|
|---|
| 259 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
|---|
| 260 |
|
|---|
| 261 | // Compute Satellite Elevations
|
|---|
| 262 | // ----------------------------
|
|---|
| 263 | QMutableMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
|---|
| 264 | while (iGPS.hasNext()) {
|
|---|
| 265 | iGPS.next();
|
|---|
| 266 | QString prn = iGPS.key();
|
|---|
| 267 | t_satData* satData = iGPS.value();
|
|---|
| 268 |
|
|---|
| 269 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
|---|
| 270 | double rho = rr.norm_Frobenius();
|
|---|
| 271 |
|
|---|
| 272 | double neu[3];
|
|---|
| 273 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
|---|
| 274 |
|
|---|
| 275 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
|---|
| 276 | if (neu[2] < 0) {
|
|---|
| 277 | satData->eleSat *= -1.0;
|
|---|
| 278 | }
|
|---|
| 279 | satData->azSat = atan2(neu[1], neu[0]);
|
|---|
| 280 |
|
|---|
| 281 | if (satData->eleSat < MINELE) {
|
|---|
| 282 | delete satData;
|
|---|
| 283 | iGPS.remove();
|
|---|
| 284 | }
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | QMutableMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
|---|
| 288 | while (iGlo.hasNext()) {
|
|---|
| 289 | iGlo.next();
|
|---|
| 290 | QString prn = iGlo.key();
|
|---|
| 291 | t_satData* satData = iGlo.value();
|
|---|
| 292 |
|
|---|
| 293 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
|---|
| 294 | double rho = rr.norm_Frobenius();
|
|---|
| 295 |
|
|---|
| 296 | double neu[3];
|
|---|
| 297 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
|---|
| 298 |
|
|---|
| 299 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
|---|
| 300 | if (neu[2] < 0) {
|
|---|
| 301 | satData->eleSat *= -1.0;
|
|---|
| 302 | }
|
|---|
| 303 | satData->azSat = atan2(neu[1], neu[0]);
|
|---|
| 304 |
|
|---|
| 305 | if (satData->eleSat < MINELE) {
|
|---|
| 306 | delete satData;
|
|---|
| 307 | iGlo.remove();
|
|---|
| 308 | }
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | return success;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | // Computed Value
|
|---|
| 315 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 316 | double bncModel::cmpValue(t_satData* satData) {
|
|---|
| 317 |
|
|---|
| 318 | ColumnVector xRec(3);
|
|---|
| 319 | xRec(1) = x();
|
|---|
| 320 | xRec(2) = y();
|
|---|
| 321 | xRec(3) = z();
|
|---|
| 322 |
|
|---|
| 323 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
|---|
| 324 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
|---|
| 325 |
|
|---|
| 326 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
|---|
| 327 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
|---|
| 328 | xRec(3) = z();
|
|---|
| 329 |
|
|---|
| 330 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
|---|
| 331 |
|
|---|
| 332 | double tropDelay = delay_saast(satData->eleSat) +
|
|---|
| 333 | trp() / sin(satData->eleSat);
|
|---|
| 334 |
|
|---|
| 335 | return satData->rho + clk() - satData->clk + tropDelay;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | // Tropospheric Model (Saastamoinen)
|
|---|
| 339 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 340 | double bncModel::delay_saast(double Ele) {
|
|---|
| 341 |
|
|---|
| 342 | double height = _ellBanc(3);
|
|---|
| 343 |
|
|---|
| 344 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
|---|
| 345 | double TT = 18.0 - height * 0.0065 + 273.15;
|
|---|
| 346 | double hh = 50.0 * exp(-6.396e-4 * height);
|
|---|
| 347 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
|---|
| 348 |
|
|---|
| 349 | double h_km = height / 1000.0;
|
|---|
| 350 |
|
|---|
| 351 | if (h_km < 0.0) h_km = 0.0;
|
|---|
| 352 | if (h_km > 5.0) h_km = 5.0;
|
|---|
| 353 | int ii = int(h_km + 1);
|
|---|
| 354 | double href = ii - 1;
|
|---|
| 355 |
|
|---|
| 356 | double bCor[6];
|
|---|
| 357 | bCor[0] = 1.156;
|
|---|
| 358 | bCor[1] = 1.006;
|
|---|
| 359 | bCor[2] = 0.874;
|
|---|
| 360 | bCor[3] = 0.757;
|
|---|
| 361 | bCor[4] = 0.654;
|
|---|
| 362 | bCor[5] = 0.563;
|
|---|
| 363 |
|
|---|
| 364 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
|---|
| 365 |
|
|---|
| 366 | double zen = M_PI/2.0 - Ele;
|
|---|
| 367 |
|
|---|
| 368 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | // Prediction Step of the Filter
|
|---|
| 372 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 373 | void bncModel::predict(t_epoData* epoData) {
|
|---|
| 374 |
|
|---|
| 375 | bool firstCrd = x() == 0.0 && y() == 0.0 && z() == 0.0;
|
|---|
| 376 |
|
|---|
| 377 | // Predict Parameter values, add white noise
|
|---|
| 378 | // -----------------------------------------
|
|---|
| 379 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 380 | bncParam* pp = _params[iPar-1];
|
|---|
| 381 |
|
|---|
| 382 | // Coordinates
|
|---|
| 383 | // -----------
|
|---|
| 384 | if (pp->type == bncParam::CRD_X) {
|
|---|
| 385 | if (firstCrd || !_static) {
|
|---|
| 386 | pp->xx = _xcBanc(1);
|
|---|
| 387 | }
|
|---|
| 388 | _QQ(iPar,iPar) += sig_crd_p * sig_crd_p;
|
|---|
| 389 | }
|
|---|
| 390 | else if (pp->type == bncParam::CRD_Y) {
|
|---|
| 391 | if (firstCrd || !_static) {
|
|---|
| 392 | pp->xx = _xcBanc(2);
|
|---|
| 393 | }
|
|---|
| 394 | _QQ(iPar,iPar) += sig_crd_p * sig_crd_p;
|
|---|
| 395 | }
|
|---|
| 396 | else if (pp->type == bncParam::CRD_Z) {
|
|---|
| 397 | if (firstCrd || !_static) {
|
|---|
| 398 | pp->xx = _xcBanc(3);
|
|---|
| 399 | }
|
|---|
| 400 | _QQ(iPar,iPar) += sig_crd_p * sig_crd_p;
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | // Receiver Clocks
|
|---|
| 404 | // ---------------
|
|---|
| 405 | else if (pp->type == bncParam::RECCLK) {
|
|---|
| 406 | pp->xx = _xcBanc(4);
|
|---|
| 407 | for (int jj = 1; jj <= _params.size(); jj++) {
|
|---|
| 408 | _QQ(iPar, jj) = 0.0;
|
|---|
| 409 | }
|
|---|
| 410 | _QQ(iPar,iPar) = sig_clk_0 * sig_clk_0;
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | // Tropospheric Delay
|
|---|
| 414 | // ------------------
|
|---|
| 415 | else if (pp->type == bncParam::TROPO) {
|
|---|
| 416 | _QQ(iPar,iPar) += sig_trp_p * sig_trp_p;
|
|---|
| 417 | }
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | // Add New Ambiguities if necessary
|
|---|
| 421 | // --------------------------------
|
|---|
| 422 | if (_usePhase) {
|
|---|
| 423 |
|
|---|
| 424 | // Make a copy of QQ and xx, set parameter indices
|
|---|
| 425 | // -----------------------------------------------
|
|---|
| 426 | SymmetricMatrix QQ_old = _QQ;
|
|---|
| 427 |
|
|---|
| 428 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 429 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
|---|
| 430 | _params[iPar-1]->index = 0;
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | // Remove Ambiguity Parameters without observations
|
|---|
| 434 | // ------------------------------------------------
|
|---|
| 435 | int iPar = 0;
|
|---|
| 436 | QMutableVectorIterator<bncParam*> it(_params);
|
|---|
| 437 | while (it.hasNext()) {
|
|---|
| 438 | bncParam* par = it.next();
|
|---|
| 439 | bool removed = false;
|
|---|
| 440 | if (par->type == bncParam::AMB_L3) {
|
|---|
| 441 | if (epoData->satDataGPS.find(par->prn) == epoData->satDataGPS.end() &&
|
|---|
| 442 | epoData->satDataGlo.find(par->prn) == epoData->satDataGlo.end() ) {
|
|---|
| 443 | removed = true;
|
|---|
| 444 | delete par;
|
|---|
| 445 | it.remove();
|
|---|
| 446 | }
|
|---|
| 447 | }
|
|---|
| 448 | if (! removed) {
|
|---|
| 449 | ++iPar;
|
|---|
| 450 | par->index = iPar;
|
|---|
| 451 | }
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | // Add new ambiguity parameters
|
|---|
| 455 | // ----------------------------
|
|---|
| 456 | QMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
|---|
| 457 | while (iGPS.hasNext()) {
|
|---|
| 458 | iGPS.next();
|
|---|
| 459 | QString prn = iGPS.key();
|
|---|
| 460 | t_satData* satData = iGPS.value();
|
|---|
| 461 | bool found = false;
|
|---|
| 462 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 463 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
|---|
| 464 | _params[iPar-1]->prn == prn) {
|
|---|
| 465 | found = true;
|
|---|
| 466 | break;
|
|---|
| 467 | }
|
|---|
| 468 | }
|
|---|
| 469 | if (!found) {
|
|---|
| 470 | bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
|
|---|
| 471 | _params.push_back(par);
|
|---|
| 472 | par->xx = satData->L3 - cmpValue(satData);
|
|---|
| 473 | }
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | QMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
|---|
| 477 | while (iGlo.hasNext()) {
|
|---|
| 478 | iGlo.next();
|
|---|
| 479 | QString prn = iGlo.key();
|
|---|
| 480 | t_satData* satData = iGlo.value();
|
|---|
| 481 | bool found = false;
|
|---|
| 482 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 483 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
|---|
| 484 | _params[iPar-1]->prn == prn) {
|
|---|
| 485 | found = true;
|
|---|
| 486 | break;
|
|---|
| 487 | }
|
|---|
| 488 | }
|
|---|
| 489 | if (!found) {
|
|---|
| 490 | bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
|
|---|
| 491 | _params.push_back(par);
|
|---|
| 492 | par->xx = satData->L3 - cmpValue(satData);
|
|---|
| 493 | }
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | int nPar = _params.size();
|
|---|
| 497 | _QQ.ReSize(nPar); _QQ = 0.0;
|
|---|
| 498 | for (int i1 = 1; i1 <= nPar; i1++) {
|
|---|
| 499 | bncParam* p1 = _params[i1-1];
|
|---|
| 500 | if (p1->index_old != 0) {
|
|---|
| 501 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
|---|
| 502 | for (int i2 = 1; i2 <= nPar; i2++) {
|
|---|
| 503 | bncParam* p2 = _params[i2-1];
|
|---|
| 504 | if (p2->index_old != 0) {
|
|---|
| 505 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
|---|
| 506 | }
|
|---|
| 507 | }
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | for (int ii = 1; ii <= nPar; ii++) {
|
|---|
| 512 | bncParam* par = _params[ii-1];
|
|---|
| 513 | if (par->index_old == 0) {
|
|---|
| 514 | if (par->prn[0] == 'R') {
|
|---|
| 515 | _QQ(par->index, par->index) = sig_amb_0_GLO * sig_amb_0_GLO;
|
|---|
| 516 | }
|
|---|
| 517 | else {
|
|---|
| 518 | _QQ(par->index, par->index) = sig_amb_0_GPS * sig_amb_0_GPS;
|
|---|
| 519 | }
|
|---|
| 520 | }
|
|---|
| 521 | par->index_old = par->index;
|
|---|
| 522 | }
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 | }
|
|---|
| 526 |
|
|---|
| 527 | // Update Step of the Filter (currently just a single-epoch solution)
|
|---|
| 528 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 529 | t_irc bncModel::update(t_epoData* epoData) {
|
|---|
| 530 |
|
|---|
| 531 | _log.clear();
|
|---|
| 532 |
|
|---|
| 533 | _time = epoData->tt;
|
|---|
| 534 |
|
|---|
| 535 | SymmetricMatrix QQsav;
|
|---|
| 536 | ColumnVector dx;
|
|---|
| 537 | ColumnVector vv;
|
|---|
| 538 |
|
|---|
| 539 | // Loop over all outliers
|
|---|
| 540 | // ----------------------
|
|---|
| 541 | do {
|
|---|
| 542 |
|
|---|
| 543 | // Bancroft Solution
|
|---|
| 544 | // -----------------
|
|---|
| 545 | if (cmpBancroft(epoData) != success) {
|
|---|
| 546 | _log += "\nBancroft failed";
|
|---|
| 547 | emit newMessage(_log, false);
|
|---|
| 548 | return failure;
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | if (epoData->sizeGPS() < MINOBS) {
|
|---|
| 552 | _log += "\nNot enough data";
|
|---|
| 553 | emit newMessage(_log, false);
|
|---|
| 554 | return failure;
|
|---|
| 555 | }
|
|---|
| 556 |
|
|---|
| 557 | // Status Prediction
|
|---|
| 558 | // -----------------
|
|---|
| 559 | predict(epoData);
|
|---|
| 560 |
|
|---|
| 561 | // Create First-Design Matrix
|
|---|
| 562 | // --------------------------
|
|---|
| 563 | unsigned nPar = _params.size();
|
|---|
| 564 | unsigned nObs = 0;
|
|---|
| 565 | if (_usePhase) {
|
|---|
| 566 | nObs = 2 * epoData->sizeGPS() + epoData->sizeGlo();
|
|---|
| 567 | }
|
|---|
| 568 | else {
|
|---|
| 569 | nObs = epoData->sizeGPS(); // Glonass pseudoranges are not used
|
|---|
| 570 | }
|
|---|
| 571 |
|
|---|
| 572 | Matrix AA(nObs, nPar); // first design matrix
|
|---|
| 573 | ColumnVector ll(nObs); // tems observed-computed
|
|---|
| 574 | SymmetricMatrix PP(nObs); PP = 0.0;
|
|---|
| 575 |
|
|---|
| 576 | unsigned iObs = 0;
|
|---|
| 577 |
|
|---|
| 578 | // GPS code and (optionally) phase observations
|
|---|
| 579 | // --------------------------------------------
|
|---|
| 580 | QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
|
|---|
| 581 | while (itGPS.hasNext()) {
|
|---|
| 582 | ++iObs;
|
|---|
| 583 | itGPS.next();
|
|---|
| 584 | QString prn = itGPS.key();
|
|---|
| 585 | t_satData* satData = itGPS.value();
|
|---|
| 586 |
|
|---|
| 587 | double rhoCmp = cmpValue(satData);
|
|---|
| 588 |
|
|---|
| 589 | ll(iObs) = satData->P3 - rhoCmp;
|
|---|
| 590 | PP(iObs,iObs) = 1.0 / (sig_P3 * sig_P3);
|
|---|
| 591 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 592 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
|---|
| 593 | }
|
|---|
| 594 |
|
|---|
| 595 | if (_usePhase) {
|
|---|
| 596 | ++iObs;
|
|---|
| 597 | ll(iObs) = satData->L3 - rhoCmp;
|
|---|
| 598 | PP(iObs,iObs) = 1.0 / (sig_L3_GPS * sig_L3_GPS);
|
|---|
| 599 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 600 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
|---|
| 601 | _params[iPar-1]->prn == prn) {
|
|---|
| 602 | ll(iObs) -= _params[iPar-1]->xx;
|
|---|
| 603 | }
|
|---|
| 604 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
|---|
| 605 | }
|
|---|
| 606 | }
|
|---|
| 607 | }
|
|---|
| 608 |
|
|---|
| 609 | // Glonass phase observations
|
|---|
| 610 | // --------------------------
|
|---|
| 611 | if (_usePhase) {
|
|---|
| 612 | QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
|
|---|
| 613 | while (itGlo.hasNext()) {
|
|---|
| 614 | ++iObs;
|
|---|
| 615 | itGlo.next();
|
|---|
| 616 | QString prn = itGlo.key();
|
|---|
| 617 | t_satData* satData = itGlo.value();
|
|---|
| 618 |
|
|---|
| 619 | double rhoCmp = cmpValue(satData);
|
|---|
| 620 |
|
|---|
| 621 | ll(iObs) = satData->L3 - rhoCmp;
|
|---|
| 622 |
|
|---|
| 623 | PP(iObs,iObs) = 1.0 / (sig_L3_GLO * sig_L3_GLO);
|
|---|
| 624 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 625 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
|---|
| 626 | _params[iPar-1]->prn == prn) {
|
|---|
| 627 | ll(iObs) -= _params[iPar-1]->xx;
|
|---|
| 628 | }
|
|---|
| 629 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
|---|
| 630 | }
|
|---|
| 631 | }
|
|---|
| 632 | }
|
|---|
| 633 |
|
|---|
| 634 | // Compute Filter Update
|
|---|
| 635 | // ---------------------
|
|---|
| 636 | QQsav = _QQ;
|
|---|
| 637 |
|
|---|
| 638 | Matrix ATP = AA.t() * PP;
|
|---|
| 639 | SymmetricMatrix NN = _QQ.i();
|
|---|
| 640 | NN << NN + ATP * AA;
|
|---|
| 641 | _QQ = NN.i();
|
|---|
| 642 | dx = _QQ * ATP * ll;
|
|---|
| 643 | vv = ll - AA * dx;
|
|---|
| 644 |
|
|---|
| 645 | ostringstream str;
|
|---|
| 646 | str.setf(ios::fixed);
|
|---|
| 647 | ColumnVector vv_code(epoData->sizeGPS());
|
|---|
| 648 | ColumnVector vv_phase(epoData->sizeGPS());
|
|---|
| 649 | ColumnVector vv_glo(epoData->sizeGlo());
|
|---|
| 650 |
|
|---|
| 651 | for (unsigned iobs = 1; iobs <= epoData->sizeGPS(); ++iobs) {
|
|---|
| 652 | if (_usePhase) {
|
|---|
| 653 | vv_code(iobs) = vv(2*iobs-1);
|
|---|
| 654 | vv_phase(iobs) = vv(2*iobs);
|
|---|
| 655 | }
|
|---|
| 656 | else {
|
|---|
| 657 | vv_code(iobs) = vv(iobs);
|
|---|
| 658 | }
|
|---|
| 659 | }
|
|---|
| 660 | if (_useGlonass) {
|
|---|
| 661 | for (unsigned iobs = 1; iobs <= epoData->sizeGlo(); ++iobs) {
|
|---|
| 662 | vv_glo(iobs) = vv(2*epoData->sizeGPS()+iobs);
|
|---|
| 663 | }
|
|---|
| 664 | }
|
|---|
| 665 |
|
|---|
| 666 | str << "\nresiduals code " << setprecision(3) << vv_code.t();
|
|---|
| 667 | if (_usePhase) {
|
|---|
| 668 | str << "residuals phase " << setprecision(3) << vv_phase.t();
|
|---|
| 669 | }
|
|---|
| 670 | if (_useGlonass) {
|
|---|
| 671 | str << "residuals glo " << setprecision(3) << vv_glo.t();
|
|---|
| 672 | }
|
|---|
| 673 | _log += str.str().c_str();
|
|---|
| 674 |
|
|---|
| 675 | } while (outlierDetection(QQsav, vv, epoData->satDataGPS,
|
|---|
| 676 | epoData->satDataGlo) != 0);
|
|---|
| 677 |
|
|---|
| 678 | // Set Solution Vector
|
|---|
| 679 | // -------------------
|
|---|
| 680 | ostringstream strB;
|
|---|
| 681 | strB.setf(ios::fixed);
|
|---|
| 682 | QVectorIterator<bncParam*> itPar(_params);
|
|---|
| 683 | while (itPar.hasNext()) {
|
|---|
| 684 | bncParam* par = itPar.next();
|
|---|
| 685 | par->xx += dx(par->index);
|
|---|
| 686 |
|
|---|
| 687 | if (par->type == bncParam::RECCLK) {
|
|---|
| 688 | strB << "\n clk = " << setw(6) << setprecision(3) << par->xx
|
|---|
| 689 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 690 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 691 | }
|
|---|
| 692 | else if (par->type == bncParam::AMB_L3) {
|
|---|
| 693 | strB << "\n amb " << par->prn.toAscii().data() << " = "
|
|---|
| 694 | << setw(6) << setprecision(3) << par->xx
|
|---|
| 695 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 696 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 697 | }
|
|---|
| 698 | else if (par->type == bncParam::TROPO) {
|
|---|
| 699 | strB << "\n trp = " << par->prn.toAscii().data()
|
|---|
| 700 | << setw(7) << setprecision(3) << delay_saast(M_PI/2.0) << " "
|
|---|
| 701 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
|---|
| 702 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 703 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 704 | }
|
|---|
| 705 | }
|
|---|
| 706 | strB << '\n';
|
|---|
| 707 |
|
|---|
| 708 | // Message (both log file and screen)
|
|---|
| 709 | // ----------------------------------
|
|---|
| 710 | ostringstream strA;
|
|---|
| 711 | strA.setf(ios::fixed);
|
|---|
| 712 | strA << _staID.data() << ": PPP "
|
|---|
| 713 | << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
|
|---|
| 714 | << setw(14) << setprecision(3) << x() << " +- "
|
|---|
| 715 | << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
|
|---|
| 716 | << setw(14) << setprecision(3) << y() << " +- "
|
|---|
| 717 | << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
|
|---|
| 718 | << setw(14) << setprecision(3) << z() << " +- "
|
|---|
| 719 | << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
|
|---|
| 720 |
|
|---|
| 721 | emit newMessage(QByteArray(strA.str().c_str()), true);
|
|---|
| 722 |
|
|---|
| 723 | _log += strB.str().c_str();
|
|---|
| 724 | emit newMessage(_log, false);
|
|---|
| 725 |
|
|---|
| 726 | // NMEA Output
|
|---|
| 727 | // -----------
|
|---|
| 728 | double xyz[3];
|
|---|
| 729 | xyz[0] = x();
|
|---|
| 730 | xyz[1] = y();
|
|---|
| 731 | xyz[2] = z();
|
|---|
| 732 | double ell[3];
|
|---|
| 733 | xyz2ell(xyz, ell);
|
|---|
| 734 | double phiDeg = ell[0] * 180 / M_PI;
|
|---|
| 735 | double lamDeg = ell[1] * 180 / M_PI;
|
|---|
| 736 |
|
|---|
| 737 | char phiCh = 'N';
|
|---|
| 738 | if (phiDeg < 0) {
|
|---|
| 739 | phiDeg = -phiDeg;
|
|---|
| 740 | phiCh = 'S';
|
|---|
| 741 | }
|
|---|
| 742 | char lamCh = 'E';
|
|---|
| 743 | if (lamDeg < 0) {
|
|---|
| 744 | lamDeg = -lamDeg;
|
|---|
| 745 | lamCh = 'W';
|
|---|
| 746 | }
|
|---|
| 747 |
|
|---|
| 748 | double dop = 2.0; // TODO
|
|---|
| 749 |
|
|---|
| 750 | ostringstream str3;
|
|---|
| 751 | str3.setf(ios::fixed);
|
|---|
| 752 | str3 << "GPGGA,"
|
|---|
| 753 | << epoData->tt.timestr(0,0) << ','
|
|---|
| 754 | << setw(2) << setfill('0') << int(phiDeg)
|
|---|
| 755 | << setw(10) << setprecision(7) << setfill('0')
|
|---|
| 756 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
|---|
| 757 | << setw(2) << setfill('0') << int(lamDeg)
|
|---|
| 758 | << setw(10) << setprecision(7) << setfill('0')
|
|---|
| 759 | << fmod(60*lamDeg,60) << ',' << lamCh
|
|---|
| 760 | << ",1," << setw(2) << setfill('0') << epoData->sizeAll() << ','
|
|---|
| 761 | << setw(3) << setprecision(1) << dop << ','
|
|---|
| 762 | << setprecision(3) << ell[2] << ",M,0.0,M,,,";
|
|---|
| 763 |
|
|---|
| 764 | writeNMEAstr(QString(str3.str().c_str()));
|
|---|
| 765 |
|
|---|
| 766 | return success;
|
|---|
| 767 | }
|
|---|
| 768 |
|
|---|
| 769 | // Outlier Detection
|
|---|
| 770 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 771 | int bncModel::outlierDetection(const SymmetricMatrix& QQsav,
|
|---|
| 772 | const ColumnVector& vv,
|
|---|
| 773 | QMap<QString, t_satData*>& satDataGPS,
|
|---|
| 774 | QMap<QString, t_satData*>& satDataGlo) {
|
|---|
| 775 |
|
|---|
| 776 | double vvMaxCodeGPS = 0.0;
|
|---|
| 777 | double vvMaxPhaseGPS = 0.0;
|
|---|
| 778 | double vvMaxPhaseGlo = 0.0;
|
|---|
| 779 | QMutableMapIterator<QString, t_satData*> itMaxCodeGPS(satDataGPS);
|
|---|
| 780 | QMutableMapIterator<QString, t_satData*> itMaxPhaseGPS(satDataGPS);
|
|---|
| 781 | QMutableMapIterator<QString, t_satData*> itMaxPhaseGlo(satDataGlo);
|
|---|
| 782 |
|
|---|
| 783 | int ii = 0;
|
|---|
| 784 |
|
|---|
| 785 | // GPS code and (optionally) phase residuals
|
|---|
| 786 | // -----------------------------------------
|
|---|
| 787 | QMutableMapIterator<QString, t_satData*> itGPS(satDataGPS);
|
|---|
| 788 | while (itGPS.hasNext()) {
|
|---|
| 789 | itGPS.next();
|
|---|
| 790 | ++ii;
|
|---|
| 791 |
|
|---|
| 792 | if (vvMaxCodeGPS == 0.0 || fabs(vv(ii)) > vvMaxCodeGPS) {
|
|---|
| 793 | vvMaxCodeGPS = fabs(vv(ii));
|
|---|
| 794 | itMaxCodeGPS = itGPS;
|
|---|
| 795 | }
|
|---|
| 796 |
|
|---|
| 797 | if (_usePhase) {
|
|---|
| 798 | ++ii;
|
|---|
| 799 | if (vvMaxPhaseGPS == 0.0 || fabs(vv(ii)) > vvMaxPhaseGPS) {
|
|---|
| 800 | vvMaxPhaseGPS = fabs(vv(ii));
|
|---|
| 801 | itMaxPhaseGPS = itGPS;
|
|---|
| 802 | }
|
|---|
| 803 | }
|
|---|
| 804 | }
|
|---|
| 805 |
|
|---|
| 806 | // Glonass phase residuals
|
|---|
| 807 | // -----------------------
|
|---|
| 808 | if (_usePhase) {
|
|---|
| 809 | QMutableMapIterator<QString, t_satData*> itGlo(satDataGlo);
|
|---|
| 810 | while (itGlo.hasNext()) {
|
|---|
| 811 | itGlo.next();
|
|---|
| 812 | ++ii;
|
|---|
| 813 | if (vvMaxPhaseGlo == 0.0 || fabs(vv(ii)) > vvMaxPhaseGlo) {
|
|---|
| 814 | vvMaxPhaseGlo = fabs(vv(ii));
|
|---|
| 815 | itMaxPhaseGlo = itGlo;
|
|---|
| 816 | }
|
|---|
| 817 | }
|
|---|
| 818 | }
|
|---|
| 819 |
|
|---|
| 820 | if (vvMaxPhaseGlo > MAXRES_PHASE_GLO) {
|
|---|
| 821 | QString prn = itMaxPhaseGlo.key();
|
|---|
| 822 | t_satData* satData = itMaxPhaseGlo.value();
|
|---|
| 823 | delete satData;
|
|---|
| 824 | itMaxPhaseGlo.remove();
|
|---|
| 825 | _QQ = QQsav;
|
|---|
| 826 |
|
|---|
| 827 | _log += "\nOutlier Phase " + prn.toAscii() + " "
|
|---|
| 828 | + QByteArray::number(vvMaxPhaseGlo, 'f', 3);
|
|---|
| 829 |
|
|---|
| 830 | return 1;
|
|---|
| 831 | }
|
|---|
| 832 |
|
|---|
| 833 | else if (vvMaxCodeGPS > MAXRES_CODE_GPS) {
|
|---|
| 834 | QString prn = itMaxCodeGPS.key();
|
|---|
| 835 | t_satData* satData = itMaxCodeGPS.value();
|
|---|
| 836 | delete satData;
|
|---|
| 837 | itMaxCodeGPS.remove();
|
|---|
| 838 | _QQ = QQsav;
|
|---|
| 839 |
|
|---|
| 840 | _log += "\nOutlier Code " + prn.toAscii() + " "
|
|---|
| 841 | + QByteArray::number(vvMaxCodeGPS, 'f', 3);
|
|---|
| 842 |
|
|---|
| 843 | return 1;
|
|---|
| 844 | }
|
|---|
| 845 | else if (vvMaxPhaseGPS > MAXRES_PHASE_GPS) {
|
|---|
| 846 | QString prn = itMaxPhaseGPS.key();
|
|---|
| 847 | t_satData* satData = itMaxPhaseGPS.value();
|
|---|
| 848 | delete satData;
|
|---|
| 849 | itMaxPhaseGPS.remove();
|
|---|
| 850 | _QQ = QQsav;
|
|---|
| 851 |
|
|---|
| 852 | _log += "\nOutlier Phase " + prn.toAscii() + " "
|
|---|
| 853 | + QByteArray::number(vvMaxPhaseGPS, 'f', 3);
|
|---|
| 854 |
|
|---|
| 855 | return 1;
|
|---|
| 856 | }
|
|---|
| 857 |
|
|---|
| 858 | return 0;
|
|---|
| 859 | }
|
|---|
| 860 |
|
|---|
| 861 | //
|
|---|
| 862 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 863 | void bncModel::writeNMEAstr(const QString& nmStr) {
|
|---|
| 864 |
|
|---|
| 865 | unsigned char XOR = 0;
|
|---|
| 866 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
|---|
| 867 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
|---|
| 868 | }
|
|---|
| 869 |
|
|---|
| 870 | QString outStr = '$' + nmStr
|
|---|
| 871 | + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
|---|
| 872 |
|
|---|
| 873 | if (_nmeaStream) {
|
|---|
| 874 | *_nmeaStream << outStr;
|
|---|
| 875 | _nmeaStream->flush();
|
|---|
| 876 | }
|
|---|
| 877 |
|
|---|
| 878 | emit newNMEAstr(outStr.toAscii());
|
|---|
| 879 | }
|
|---|