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

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

Documentation completed

File size: 16.9 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>\n"
96 "\n"
97 "General Panel keys:\n"
98 " --logFile <Logfile (full path)>\n"
99 " --rnxAppend <Append files>\n"
100 " --onTheFlyInterval <Reread configuration>\n"
101 " --autoStart <Auto start>\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> \n"
108 " --rnxSkel <Skeleton extension>\n"
109 " --rnxOnlyWithSKL <Skeleton is mandatory>\n"
110 " --rnxScript <Upload script>\n"
111 " --rnxV2Priority <Signal priority>\n"
112 " --rnxV3 <Version 3>\n"
113 " --rnxV3filenames <Version 3 filenames>\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>\n"
120 " --ephV3filenames <Version 3 filenames>\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>\n"
130 " --reqcSkyPlotSignals <Plots for signals>\n"
131 " --reqcPlotDir <QC plots directory>\n"
132 " --reqcRnxVersion <RINEX version>\n"
133 " --reqcSampling <RINEX sampling>\n"
134 " --reqcV2Priority <Version 2 signal priority>\n"
135 " --reqcStartDateTime <Start time>\n"
136 " --reqcEndDateTime <Stop time>\n"
137 " --reqcRunBy <Operators name>\n"
138 " --reqcUseObsTypes <Use observation types>\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>\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)>\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>\n"
183 " --serialFileNMEA <NMEA filename>\n"
184 " --serialHeightNMEA <Height>\n"
185 "\n"
186 "Outages Panel keys:\n"
187 " --obsRate <Observation rate> \n"
188 " --adviseFail <Failure threshold>\n"
189 " --adviseReco <Recovery threshold>\n"
190 " --adviseScript <Script (full path)>\n"
191 "\n"
192 "Miscellaneous Panel keys:\n"
193 " --miscMount <Mountpoint>\n"
194 " --perfIntr <Log latency>\n"
195 " --scanRTCM <Scan RTCM>\n"
196 " --miscPort <Mountpoint>\n"
197 "\n"
198 "PPP Client Panel 1 keys:\n"
199 " --dataSource <Switch between real-time and post processing>\n"
200 " --rinexObs <RINEX observation file>\n"
201 " --rinexNav <RINEX navigation file>\n"
202 " --corrMount <Corrections mountpoint>\n"
203 " --corrFile <Corrections file>\n"
204 " --crdFile <Coordinates file>\n"
205 " --logFilePPP <PPP logfile>\n"
206 " --antexFile <ANTEX file>\n"
207 " --nmeaFile <NMEA output file>\n"
208 " --snxtroFile <SINEX troposphere output filename>\n"
209 " --snxtroSampl <SINEX troposphere sampling rage>\n"
210 "\n"
211 "PPP Client Panel 2 keys:\n"
212 " --staTable <Stations table>\n"
213 "\n"
214 "PPP Client Panel 3 keys:\n"
215 " --lcGPS <Linear combination from GPS code data>\n"
216 " --lcGLONASS <Linear combination from GLONASS code data>\n"
217 " --lcGalileo <Linear combination from Galileo code data>\n"
218 " --lcBDS <Linear combination from BDS code data>\n"
219 " --sigmaC1 <Sigma for code observations>\n"
220 " --sigmaL1 <Sigma for phase observations>\n"
221 " --maxResC1 <Maximal residuum for code observations>\n"
222 " --maxResL1 <Maximal residuum for phase observations>\n"
223 " --eleWgtCode <Elevation dependent waiting of code observations>\n"
224 " --eleWgtPhase <Elevation dependent waiting of phase observations>\n"
225 " --minObs <Minimum number of observations>\n"
226 " --minEle <Minimum elevation>\n"
227 " --corrWaitTime <Wait for clock corrections>\n"
228 " --seedingTime <Seeding time span for Quick Start>\n"
229 "\n"
230 "PPP Client Panel 4 keys:\n"
231 " --plotCoordinates <Mountpoint for time series plot>\n"
232 " --audioResponse <Audio response>\n"
233 " --useOpenStreetMap <OSM track map>\n"
234 " --useGoogleMap <Google track map>\n"
235 " --mapWinDotSize <Size of dots on map>\n"
236 " --mapWinDotColor <Color of dots and cross hair on map>\n"
237 " --mapSpeedSlider <Offline processing speed for mapping>\n"
238 "\n"
239 "Combine Corrections Panel keys:\n"
240 " --combineStreams <Table of correction streams\n"
241 " --cmbMethodFilter <Approach\n"
242 " --cmbMaxres <Clock outlier threshold\n"
243 " --cmbSampl <Orbit and clock sampling\n"
244 " --cmbUseGlonass <Use GLONASS in combination\n"
245 "\n"
246 "Upload Corrections Panel keys:\n"
247 " --uploadMountpointsOut <Upload corrections table>\n"
248 " --uploadIntr <File interval>\n"
249 " --uploadSamplRtcmEphCorr <Orbit sampling>\n"
250 " --uploadSamplSp3 <Orbit sampling>\n"
251 " --uploadSamplClkRnx <Clock sampling>\n"
252 "\n"
253 "Custom Trafo keys:\n"
254 " --trafo_dx <Translation X>\n"
255 " --trafo_dy <Translation Y>\n"
256 " --trafo_dz <Translation Z>\n"
257 " --trafo_dxr <Translation change X>\n"
258 " --trafo_dyr <Translation change Y>\n"
259 " --trafo_dzr <Translation change Z>\n"
260 " --trafo_ox <Rotation X>\n"
261 " --trafo_oy <Rotation Y>\n"
262 " --trafo_oz <Rotation Z>\n"
263 " --trafo_oxr <Rotation change X>\n"
264 " --trafo_oyr <Rotation change Y>\n"
265 " --trafo_ozr <Rotation change Z>\n"
266 " --trafo_sc <Scale>\n"
267 " --trafo_scr <Scale change>\n"
268 " --trafo_t0 <Reference year>\n"
269 "\n"
270 "Upload Ephemeris Panel keys:\n"
271 " --uploadEphHost <Host>\n"
272 " --uploadEphPort <Port>\n"
273 " --uploadEphMountpoint <Mountpoint>\n"
274 " --uploadEphPassword <Password>\n"
275 " --uploadEphSample <Sampling>\n"
276 "\n"
277 "Add Stream keys:\n"
278 " --mountPoints <Add stream coming from ...>\n"
279 " --ntripVersion <Ntrip Version>\n";
280
281 for (int ii = 1; ii < argc; ii++) {
282 if (QRegExp("--?help").exactMatch(argv[ii])) {
283 cout << printHelp.data();
284 exit(0);
285 }
286 if (QRegExp("--?nw").exactMatch(argv[ii])) {
287 interactive = false;
288 }
289 if (QRegExp("--?version").exactMatch(argv[ii])) {
290 cout << BNCPGMNAME << endl;
291 exit(0);
292 }
293 if (QRegExp("--?display").exactMatch(argv[ii])) {
294 displaySet = true;
295 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
296 }
297 if (ii + 1 < argc) {
298 if (QRegExp("--?conf").exactMatch(argv[ii])) {
299 confFileName = QString(argv[ii+1]);
300 }
301 if (QRegExp("--?file").exactMatch(argv[ii])) {
302 interactive = false;
303 rawFileName = QByteArray(argv[ii+1]);
304 }
305 }
306 }
307
308#ifdef Q_OS_MAC
309 if (argc== 3 && interactive) {
310 confFileName = QString(argv[2]);
311 }
312#else
313 if (argc == 2 && interactive) {
314 confFileName = QString(argv[1]);
315 }
316#endif
317
318#ifdef Q_OS_MACX
319 if ( QSysInfo::MacintoshVersion > QSysInfo::MV_10_8 )
320 {
321 // fix Mac OS X 10.9 (mavericks) font issue
322 // https://bugreports.qt-project.org/browse/QTBUG-32789
323 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
324 }
325#endif
326
327 bool GUIenabled = interactive || displaySet;
328 t_app app(argc, argv, GUIenabled);
329
330 app.setApplicationName("BNC");
331 app.setOrganizationName("BKG");
332 app.setOrganizationDomain("www.bkg.bund.de");
333
334 BNC_CORE->setGUIenabled(GUIenabled);
335 BNC_CORE->setConfFileName( confFileName );
336
337 bncSettings settings;
338
339 for (int ii = 1; ii < argc - 2; ii++) {
340 if (QRegExp("--?key").exactMatch(argv[ii])) {
341 QString key(argv[ii+1]);
342 QString val(argv[ii+2]);
343 settings.setValue(key, val);
344 }
345 }
346
347 // Interactive Mode - open the main window
348 // ---------------------------------------
349 if (interactive) {
350
351 BNC_CORE->setMode(t_bncCore::interactive);
352
353 QString fontString = settings.value("font").toString();
354 if ( !fontString.isEmpty() ) {
355 QFont newFont;
356 if (newFont.fromString(fontString)) {
357 QApplication::setFont(newFont);
358 }
359 }
360
361 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
362
363 bncWindow* bncWin = new bncWindow();
364 BNC_CORE->setMainWindow(bncWin);
365 bncWin->show();
366 }
367
368 // Post-Processing PPP
369 // -------------------
370 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
371 bncCaster* caster = new bncCaster();
372 BNC_CORE->setCaster(caster);
373 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
374 BNC_CORE->startPPP();
375 }
376
377 // Post-Processing reqc edit
378 // -------------------------
379 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
380 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
381 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
382 reqcEdit->start();
383 }
384
385 // Post-Processing reqc analyze
386 // ----------------------------
387 else if (settings.value("reqcAction").toString() == "Analyze") {
388 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
389 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
390 reqcAnalyze->start();
391 }
392
393 // SP3 Files Comparison
394 // --------------------
395 else if (!settings.value("sp3CompFile").toString().isEmpty()) {
396 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
397 t_sp3Comp* sp3Comp = new t_sp3Comp(0);
398 sp3Comp->start();
399 }
400
401 // Non-Interactive (data gathering)
402 // --------------------------------
403 else {
404
405 signal(SIGINT, catch_signal);
406
407 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
408
409 bncCaster* caster = new bncCaster();
410
411 BNC_CORE->setCaster(caster);
412 BNC_CORE->setPortEph(settings.value("outEphPort").toInt());
413 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
414 BNC_CORE->initCombination();
415
416 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
417
418 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " ("BNC_OS") ==========", true);
419
420 // Normal case - data from Internet
421 // --------------------------------
422 if ( rawFileName.isEmpty() ) {
423 BNC_CORE->setMode(t_bncCore::nonInteractive);
424 BNC_CORE->startPPP();
425
426 caster->readMountPoints();
427 if (caster->numStations() == 0) {
428 exit(0);
429 }
430 }
431
432 // Special case - data from file
433 // -----------------------------
434 else {
435 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
436 BNC_CORE->startPPP();
437
438 bncRawFile* rawFile = new bncRawFile(rawFileName, "", bncRawFile::input);
439 bncGetThread* getThread = new bncGetThread(rawFile);
440 caster->addGetThread(getThread, true);
441 }
442 }
443
444 // Start the application
445 // ---------------------
446 return app.exec();
447}
Note: See TracBrowser for help on using the repository browser.