source: ntrip/trunk/BNC/src/bncmain.cpp@ 7276

Last change on this file since 7276 was 7276, checked in by weber, 9 years ago

Documentation completed

File size: 17.5 KB
Line 
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: main
30 *
31 * Purpose: Application starts here
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Dec-2005
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <unistd.h>
42#include <signal.h>
43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
47#include "app.h"
48#include "bnccore.h"
49#include "bncwindow.h"
50#include "bncsettings.h"
51#include "bncversion.h"
52#include "upload/bncephuploadcaster.h"
53#include "rinex/reqcedit.h"
54#include "rinex/reqcanalyze.h"
55#include "orbComp/sp3Comp.h"
56
57using namespace std;
58
59void catch_signal(int) {
60 cout << "Program Interrupted by Ctrl-C" << endl;
61 exit(0);
62}
63
64// Main Program
65/////////////////////////////////////////////////////////////////////////////
66int main(int argc, char* argv[]) {
67
68 bool interactive = true;
69#ifdef WIN32
70 bool displaySet = true;
71#else
72 bool displaySet = false;
73#endif
74 QByteArray rawFileName;
75 QString confFileName;
76
77 QByteArray printHelp =
78 "Usage: bnc --nw \n"
79 " --version \n"
80 " --display <XXX> \n"
81 " --conf <confFileName> \n"
82 " --file <rawFileName> \n"
83 " --key <keyName> <keyValue>\n"
84 "\n"
85 "Internal keys:\n"
86 " --startTab <Top panel index number>\n"
87 " --statusTab <Bottom panel index number>\n"
88 " --font <Used font>\n"
89 " --casterUrlList <Visited URLs>\n"
90 "\n"
91 "Network Panel keys:\n"
92 " --proxyHost <Proxy host>\n"
93 " --proxyPort <Proxy port>\n"
94 " --sslCaCertPath <Path to SSL certificates>\n"
95 " --ignoreSslErrors <Ignore SSL authorization errors, 0=no, 2=yes\n"
96 "\n"
97 "General Panel keys:\n"
98 " --logFile <Logfile,full path>\n"
99 " --rnxAppend <Append files, 0=no, 2=yes>\n"
100 " --onTheFlyInterval <Reread configuration, interval>\n"
101 " --autoStart <Auto start, 0=no, 2=yes>\n"
102 " --rawOutFile <Raw output file, full path>\n"
103 "\n"
104 "RINEX Observations Panel keys:\n"
105 " --rnxPath <Directory>\n"
106 " --rnxIntr <Interval>\n"
107 " --rnxSample <Sampling [sec]> \n"
108 " --rnxSkel <Skeleton file extension>\n"
109 " --rnxOnlyWithSKL <Skeleton is mandatory, 0=no, 2=yes>\n"
110 " --rnxScript <Upload script>\n"
111 " --rnxV2Priority <Signal priority>\n"
112 " --rnxV3 <Version 3, 0=no, 2=yes>\n"
113 " --rnxV3filenames <Version 3 filenames, 0=no, 2=yes>\n"
114 "\n"
115 "RINEX Ephemeris Panel keys:\n"
116 " --ephPath <Directory>\n"
117 " --ephIntr <Interval>\n"
118 " --outEphPort <Port>\n"
119 " --ephV3 <Version 3, 0=no, 2=yes>\n"
120 " --ephV3filenames <Version 3 filenames, 0=no, 2=yes>\n"
121 "\n"
122 "RINEX Editing and QC Panel keys:\n"
123 " --reqcAction <Action>\n"
124 " --reqcObsFile <Input observations file>\n"
125 " --reqcNavFile <Input navigation file>\n"
126 " --reqcOutObsFile <Output observations file>\n"
127 " --reqcOutNavFile <Output navigation file>\n"
128 " --reqcOutLogFile <Output logfile>\n"
129 " --reqcLogSummaryOnly <Summary output logfile, 0=no, 2=yes>\n"
130 " --reqcSkyPlotSignals <Plots for signals list>\n"
131 " --reqcPlotDir <QC plots directory>\n"
132 " --reqcRnxVersion <RINEX version, 2 or 3>\n"
133 " --reqcSampling <RINEX sampling>\n"
134 " --reqcV2Priority <Version 2 signal priority list>\n"
135 " --reqcStartDateTime <Start time>\n"
136 " --reqcEndDateTime <Stop time>\n"
137 " --reqcRunBy <Operators name>\n"
138 " --reqcUseObsTypes <Use observation types list>\n"
139 " --reqcComment <Additional comments>\n"
140 " --reqcOldMarkerName <Old marker name>\n"
141 " --reqcNewMarkerName <New marker name>\n"
142 " --reqcOldAntennaName <Old antenna name>\n"
143 " --reqcNewAntennaName <New antenna name>\n"
144 " --reqcOldAntennaNumber <Old antenna number>\n"
145 " --reqcNewAntennaNumber <New antenna number>\n"
146 " --reqcOldAntennadN <Old north eccentritity>\n"
147 " --reqcNewAntennadN <New north eccentricity>\n"
148 " --reqcOldAntennadE <Old east eccentricity>\n"
149 " --reqcNewAntennadE <New east eccentricity>\n"
150 " --reqcOldAntennadU <Old up eccentritity>\n"
151 " --reqcNewAntennadU <New up eccentricity>\n"
152 " --reqcOldReceiverName <Old receiver name>\n"
153 " --reqcNewReceiverName <New receiver name>\n"
154 " --reqcOldReceiverNumber <Old receiver number>\n"
155 " --reqcNewReceiverNumber <New receiver number>\n"
156 "\n"
157 "SP3 Comparison Panel keys:\n"
158 " --sp3CompFile <SP3 input files, full path>\n"
159 " --sp3CompExclude <Satellite exclusion list>\n"
160 " --sp3CompOutLogFile <Output logfile>\n"
161 "\n"
162 "Broadcast Corrections Panel keys:\n"
163 " --corrPath <Directory, ASCII>\n"
164 " --corrIntr <Interval>\n"
165 " --corrPort <Port>\n"
166 "\n"
167 "Feed Engine Panel keys:\n"
168 " --outPort <Port>\n"
169 " --waitTime <Wait for full obs epoch>\n"
170 " --binSampl <Sampling>\n"
171 " --outFile <File, full path>\n"
172 " --outUPort <Port, unsynchronized output)>\n"
173 "\n"
174 "Serial Output Panel:\n"
175 " --serialMountPoint <Mountpoint>\n"
176 " --serialPortName <Port name>\n"
177 " --serialBaudRate <Baud rate>\n"
178 " --serialFlowControl <Flow control>\n"
179 " --serialDataBits <Data bits>\n"
180 " --serialParity <Parity>\n"
181 " --serialStopBits <Stop bits>\n"
182 " --serialAutoNMEA <NMEA, no|Auto|Manual GPGGA|Manual GNGGA>\n"
183 " --serialFileNMEA <NMEA filename>\n"
184 " --serialHeightNMEA <Height>\n"
185 " --serialHeightNMEASampling <Sampling>\n"
186 "\n"
187 "Outages Panel keys:\n"
188 " --obsRate <Observation rate> \n"
189 " --adviseFail <Failure threshold [min]>\n"
190 " --adviseReco <Recovery threshold [min]>\n"
191 " --adviseScript <Script, full path>\n"
192 "\n"
193 "Miscellaneous Panel keys:\n"
194 " --miscMount <Mountpoint>\n"
195 " --perfIntr <Log latency>\n"
196 " --scanRTCM <Scan for RTCM message numbers, 0=no, 2=yes>\n"
197 " --miscPort <Port output>\n"
198 "\n"
199 "PPP Client Panel 1 keys:\n"
200 " --dataSource <Switch between real-time and post processing>\n"
201 " --rinexObs <RINEX observation file>\n"
202 " --rinexNav <RINEX navigation file>\n"
203 " --corrMount <Corrections mountpoint>\n"
204 " --corrFile <Corrections file>\n"
205 " --crdFile <Coordinates file>\n"
206 " --logFilePPP <PPP logfile>\n"
207 " --antexFile <ANTEX file>\n"
208 " --nmeaFile <NMEA output file>\n"
209 " --snxtroFile <SINEX troposphere output filename>\n"
210 " --snxtroSampl <SINEX troposphere sampling rate>\n"
211 "\n"
212 "PPP Client Panel 2 keys:\n"
213 " --staTable <Stations table>\n"
214 "\n"
215 "PPP Client Panel 3 keys:\n"
216 " --lcGPS <Linear combination from GPS code data>\n"
217 " --lcGLONASS <Linear combination from GLONASS code data>\n"
218 " --lcGalileo <Linear combination from Galileo code data>\n"
219 " --lcBDS <Linear combination from BDS code data>\n"
220 " --sigmaC1 <Sigma for code observations [m]>\n"
221 " --sigmaL1 <Sigma for phase observations [m]>\n"
222 " --maxResC1 <Maximal residuum for code observations [m]>\n"
223 " --maxResL1 <Maximal residuum for phase observations [m]>\n"
224 " --eleWgtCode <Elevation dependent waiting of code observations, 0=no, 2=yes>\n"
225 " --eleWgtPhase <Elevation dependent waiting of phase observations, 0=no, 2=yes>\n"
226 " --minObs <Minimum number of observations>\n"
227 " --minEle <Minimum elevation>\n"
228 " --corrWaitTime <Wait for clock corrections [sec]>\n"
229 " --seedingTime <Seeding time span for Quick Start [sec]>\n"
230 "\n"
231 "PPP Client Panel 4 keys:\n"
232 " --plotCoordinates <Mountpoint for time series plot>\n"
233 " --audioResponse <Audio response [m]>\n"
234 " --useOpenStreetMap <OSM track map, false|true>\n"
235 " --useGoogleMap <Google track map, false|true>\n"
236 " --mapWinDotSize <Size of dots on map>\n"
237 " --mapWinDotColor <Color of dots and cross hair on map>\n"
238 " --mapSpeedSlider <Offline processing speed for mapping, 1-100>\n"
239 "\n"
240 "Combine Corrections Panel keys:\n"
241 " --combineStreams <Table of correction streams\n"
242 " --cmbMethodFilter <Approach, Single-Epoch|Filter\n"
243 " --cmbMaxres <Clock outlier threshold [m]\n"
244 " --cmbSampl <Orbit and clock sampling [m]\n"
245 " --cmbUseGlonass <Use GLONASS in combination, 0=no, 2=yes\n"
246 "\n"
247 "Upload Corrections Panel keys:\n"
248 " --uploadMountpointsOut <Upload corrections table>\n"
249 " --uploadIntr <File interval>\n"
250 " --uploadSamplRtcmEphCorr <Orbit sampling [sec]>\n"
251 " --uploadSamplSp3 <SP3 sampling [min]>\n"
252 " --uploadSamplClkRnx <Clock sampling [sec]>\n"
253 "\n"
254 "Custom Trafo keys:\n"
255 " --trafo_dx <Translation X [m]>\n"
256 " --trafo_dy <Translation Y [m]>\n"
257 " --trafo_dz <Translation Z [m]>\n"
258 " --trafo_dxr <Translation change X [m/y]>\n"
259 " --trafo_dyr <Translation change Y [m/y]>\n"
260 " --trafo_dzr <Translation change Z [m/y]>\n"
261 " --trafo_ox <Rotation X [as]>\n"
262 " --trafo_oy <Rotation Y [as]>\n"
263 " --trafo_oz <Rotation Z [as]>\n"
264 " --trafo_oxr <Rotation change X [as/y]>\n"
265 " --trafo_oyr <Rotation change Y [as/y]>\n"
266 " --trafo_ozr <Rotation change Z [as/y]>\n"
267 " --trafo_sc <Scale [10^-9]>\n"
268 " --trafo_scr <Scale change [10^-9/y]>\n"
269 " --trafo_t0 <Reference year [y]>\n"
270 "\n"
271 "Upload Ephemeris Panel keys:\n"
272 " --uploadEphHost <Host>\n"
273 " --uploadEphPort <Port>\n"
274 " --uploadEphMountpoint <Mountpoint>\n"
275 " --uploadEphPassword <Password>\n"
276 " --uploadEphSample <Sampling [sec]>\n"
277 "\n"
278 "Add Stream keys:\n"
279 " --mountPoints <Mountpoints list>\n"
280 " --ntripVersion <Ntrip Version>\n";
281
282 for (int ii = 1; ii < argc; ii++) {
283 if (QRegExp("--?help").exactMatch(argv[ii])) {
284 cout << printHelp.data();
285 exit(0);
286 }
287 if (QRegExp("--?nw").exactMatch(argv[ii])) {
288 interactive = false;
289 }
290 if (QRegExp("--?version").exactMatch(argv[ii])) {
291 cout << BNCPGMNAME << endl;
292 exit(0);
293 }
294 if (QRegExp("--?display").exactMatch(argv[ii])) {
295 displaySet = true;
296 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
297 }
298 if (ii + 1 < argc) {
299 if (QRegExp("--?conf").exactMatch(argv[ii])) {
300 confFileName = QString(argv[ii+1]);
301 }
302 if (QRegExp("--?file").exactMatch(argv[ii])) {
303 interactive = false;
304 rawFileName = QByteArray(argv[ii+1]);
305 }
306 }
307 }
308
309#ifdef Q_OS_MAC
310 if (argc== 3 && interactive) {
311 confFileName = QString(argv[2]);
312 }
313#else
314 if (argc == 2 && interactive) {
315 confFileName = QString(argv[1]);
316 }
317#endif
318
319#ifdef Q_OS_MACX
320 if ( QSysInfo::MacintoshVersion > QSysInfo::MV_10_8 )
321 {
322 // fix Mac OS X 10.9 (mavericks) font issue
323 // https://bugreports.qt-project.org/browse/QTBUG-32789
324 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
325 }
326#endif
327
328 bool GUIenabled = interactive || displaySet;
329 t_app app(argc, argv, GUIenabled);
330
331 app.setApplicationName("BNC");
332 app.setOrganizationName("BKG");
333 app.setOrganizationDomain("www.bkg.bund.de");
334
335 BNC_CORE->setGUIenabled(GUIenabled);
336 BNC_CORE->setConfFileName( confFileName );
337
338 bncSettings settings;
339
340 for (int ii = 1; ii < argc - 2; ii++) {
341 if (QRegExp("--?key").exactMatch(argv[ii])) {
342 QString key(argv[ii+1]);
343 QString val(argv[ii+2]);
344 settings.setValue(key, val);
345 }
346 }
347
348 // Interactive Mode - open the main window
349 // ---------------------------------------
350 if (interactive) {
351
352 BNC_CORE->setMode(t_bncCore::interactive);
353
354 QString fontString = settings.value("font").toString();
355 if ( !fontString.isEmpty() ) {
356 QFont newFont;
357 if (newFont.fromString(fontString)) {
358 QApplication::setFont(newFont);
359 }
360 }
361
362 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
363
364 bncWindow* bncWin = new bncWindow();
365 BNC_CORE->setMainWindow(bncWin);
366 bncWin->show();
367 }
368
369 // Post-Processing PPP
370 // -------------------
371 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
372 bncCaster* caster = new bncCaster();
373 BNC_CORE->setCaster(caster);
374 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
375 BNC_CORE->startPPP();
376 }
377
378 // Post-Processing reqc edit
379 // -------------------------
380 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
381 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
382 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
383 reqcEdit->start();
384 }
385
386 // Post-Processing reqc analyze
387 // ----------------------------
388 else if (settings.value("reqcAction").toString() == "Analyze") {
389 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
390 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
391 reqcAnalyze->start();
392 }
393
394 // SP3 Files Comparison
395 // --------------------
396 else if (!settings.value("sp3CompFile").toString().isEmpty()) {
397 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
398 t_sp3Comp* sp3Comp = new t_sp3Comp(0);
399 sp3Comp->start();
400 }
401
402 // Non-Interactive (data gathering)
403 // --------------------------------
404 else {
405
406 signal(SIGINT, catch_signal);
407
408 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
409
410 bncCaster* caster = new bncCaster();
411
412 BNC_CORE->setCaster(caster);
413 BNC_CORE->setPortEph(settings.value("outEphPort").toInt());
414 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
415 BNC_CORE->initCombination();
416
417 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
418
419 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " ("BNC_OS") ==========", true);
420
421 // Normal case - data from Internet
422 // --------------------------------
423 if ( rawFileName.isEmpty() ) {
424 BNC_CORE->setMode(t_bncCore::nonInteractive);
425 BNC_CORE->startPPP();
426
427 caster->readMountPoints();
428 if (caster->numStations() == 0) {
429 exit(0);
430 }
431 }
432
433 // Special case - data from file
434 // -----------------------------
435 else {
436 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
437 BNC_CORE->startPPP();
438
439 bncRawFile* rawFile = new bncRawFile(rawFileName, "", bncRawFile::input);
440 bncGetThread* getThread = new bncGetThread(rawFile);
441 caster->addGetThread(getThread, true);
442 }
443 }
444
445 // Start the application
446 // ---------------------
447 return app.exec();
448}
Note: See TracBrowser for help on using the repository browser.