source: ntrip/trunk/BNC/bncpostprocess.cpp@ 3717

Last change on this file since 3717 was 3717, checked in by mervart, 12 years ago
File size: 5.4 KB
RevLine 
[3615]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 *
[3626]29 * Class: t_postProcessing
[3615]30 *
31 * Purpose: Precise Point Positioning in Post-Processing Mode
32 *
33 * Author: L. Mervart
34 *
35 * Created: 22-Jan-2012
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include "bncpostprocess.h"
[3684]43#include "bncapp.h"
[3625]44#include "bncsettings.h"
[3642]45#include "pppopt.h"
[3643]46#include "bncpppclient.h"
[3717]47#include "rinex/rnxobsfile.h"
[3646]48#include "rnxnavfile.h"
[3688]49#include "corrfile.h"
[3695]50#include "bncsettings.h"
51#include "bncutils.h"
[3615]52
53using namespace std;
54
[3626]55// Constructor
[3615]56////////////////////////////////////////////////////////////////////////////
[3626]57t_postProcessing::t_postProcessing(QObject* parent) : QThread(parent) {
[3646]58 _opt = new t_pppOpt();
59 _rnxObsFile = 0;
60 _rnxNavFile = 0;
[3688]61 _corrFile = 0;
[3646]62 _pppClient = 0;
[3695]63
64 bncSettings settings;
65
66 QString outFileName = settings.value("postOutFile").toString();
67 if (outFileName.isEmpty()) {
68 _outFile = 0;
69 _outStream = 0;
70 }
71 else {
72 expandEnvVar(outFileName);
73 _outFile = new QFile(outFileName);
74 _outFile->open(QIODevice::WriteOnly | QIODevice::Text);
75 _outStream = new QTextStream();
76 _outStream->setDevice(_outFile);
77 }
[3625]78}
79
[3626]80// Destructor
81////////////////////////////////////////////////////////////////////////////
82t_postProcessing::~t_postProcessing() {
[3646]83 delete _pppClient;
84 delete _rnxNavFile;
85 delete _rnxObsFile;
[3688]86 delete _corrFile;
[3642]87 delete _opt;
[3695]88 delete _outStream;
89 delete _outFile;
[3626]90}
91
[3644]92// Write a Program Message
93////////////////////////////////////////////////////////////////////////////
94void t_postProcessing::slotMessage(QByteArray msg, bool /* showOnScreen */) {
[3695]95 if (_outStream) {
[3696]96 *_outStream << endl << msg;
[3695]97 _outStream->flush();
98 }
99 else {
100 ((bncApp*) qApp)->slotMessage(msg, false);
101 }
[3644]102}
103
[3626]104//
105////////////////////////////////////////////////////////////////////////////
106void t_postProcessing::run() {
[3615]107
[3644]108 if (_pppClient) {
109 return;
110 }
111 else {
[3646]112 _rnxObsFile = new t_rnxObsFile(_opt->obsFileName);
113 _rnxNavFile = new t_rnxNavFile(_opt->navFileName);
114 _pppClient = new bncPPPclient("POST", _opt, false);
[3644]115
[3688]116 if (!_opt->corrFileName.isEmpty()) {
117 _corrFile = new t_corrFile(_opt->corrFileName);
118 connect(_corrFile, SIGNAL(newCorrections(QList<QString>)),
119 _pppClient, SLOT(slotNewCorrections(QList<QString>)));
120 }
[3644]121
122 connect(_pppClient, SIGNAL(newMessage(QByteArray,bool)),
123 this, SLOT(slotMessage(const QByteArray,bool)));
[3643]124 }
125
[3674]126 // Read Ephemerides
127 // ----------------
[3671]128 t_eph* eph = 0;
[3683]129 while ( (eph = _rnxNavFile->getNextEph()) != 0 ) {
[3671]130 if (_pppClient->putNewEph(eph) != success) {
131 delete eph; eph = 0;
132 }
[3661]133 }
134
[3685]135 // Read/Process Observations
136 // -------------------------
137 int nEpo = 0;
[3717]138 const t_rnxObsFile::t_rnxEpo* epo = 0;
[3683]139 while ( (epo = _rnxObsFile->nextEpoch()) != 0 ) {
[3685]140 ++nEpo;
[3689]141
142 if (_corrFile) {
143 _corrFile->syncRead(epo->tt);
144 }
145
[3717]146 for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
147 const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
[3680]148 t_obs obs;
149 strncpy(obs.StatID, _rnxObsFile->markerName().toAscii().constData(),
150 sizeof(obs.StatID));
[3717]151 obs.satSys = rnxSat.satSys;
152 obs.satNum = rnxSat.satNum;
[3680]153 obs.GPSWeek = epo->tt.gpsw();
154 obs.GPSWeeks = epo->tt.gpssec();
[3704]155 for (int iType = 0; iType < _rnxObsFile->nTypes(obs.satSys); iType++) {
156 QByteArray type = _rnxObsFile->obsType(obs.satSys,iType).toAscii();
[3710]157 if (type.indexOf("C1") == 0 && obs.C1 == 0.0) {
[3717]158 obs.C1 = rnxSat.obs[iType];
[3681]159 }
[3710]160 else if (type.indexOf("P1") == 0 && obs.P1 == 0.0) {
[3717]161 obs.P1 = rnxSat.obs[iType];
[3681]162 }
[3710]163 else if (type.indexOf("L1") == 0 && obs.L1C == 0.0) {
[3717]164 obs.L1C = rnxSat.obs[iType];
[3681]165 }
[3710]166 else if (type.indexOf("C2") == 0 && obs.C2 == 0.0) {
[3717]167 obs.C2 = rnxSat.obs[iType];
[3681]168 }
[3710]169 else if (type.indexOf("P2") == 0 && obs.P2 == 0.0) {
[3717]170 obs.P2 = rnxSat.obs[iType];
[3681]171 }
[3710]172 else if (type.indexOf("L2") == 0 && obs.L2C == 0.0) {
[3717]173 obs.L2C = rnxSat.obs[iType];
[3681]174 }
175 }
176 _pppClient->putNewObs(obs);
[3680]177 }
[3685]178 if (nEpo % 10 == 0) {
179 emit progress(nEpo);
180 }
[3674]181 }
182
[3627]183 emit finished();
[3628]184 deleteLater();
[3615]185}
Note: See TracBrowser for help on using the repository browser.