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 "bncapp.h"
|
---|
48 | #include "bncwindow.h"
|
---|
49 | #include "bncsettings.h"
|
---|
50 | #include "bncversion.h"
|
---|
51 | #include "upload/bncephuploadcaster.h"
|
---|
52 | #ifdef USE_POSTPROCESSING
|
---|
53 | # include "rinex/bncpostprocess.h"
|
---|
54 | # include "rinex/reqcedit.h"
|
---|
55 | # include "rinex/reqcanalyze.h"
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | using namespace std;
|
---|
59 |
|
---|
60 | void catch_signal(int) {
|
---|
61 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
62 | exit(0);
|
---|
63 | }
|
---|
64 |
|
---|
65 | // Main Program
|
---|
66 | /////////////////////////////////////////////////////////////////////////////
|
---|
67 | int main(int argc, char* argv[]) {
|
---|
68 |
|
---|
69 | bool interactive = true;
|
---|
70 | bool displaySet = false;
|
---|
71 | QByteArray rawFileName;
|
---|
72 | QString confFileName;
|
---|
73 |
|
---|
74 | QByteArray printHelp = "Usage: bnc --nw \n"
|
---|
75 | " --display <XXX> \n"
|
---|
76 | " --conf <confFileName> \n"
|
---|
77 | " --file <rawFileName> \n"
|
---|
78 | " --key <keyName> <keyValue>\n";
|
---|
79 |
|
---|
80 | for (int ii = 1; ii < argc; ii++) {
|
---|
81 | if (QRegExp("--?help").exactMatch(argv[ii])) {
|
---|
82 | cout << printHelp.data();
|
---|
83 | exit(0);
|
---|
84 | }
|
---|
85 | if (QRegExp("--?nw").exactMatch(argv[ii])) {
|
---|
86 | interactive = false;
|
---|
87 | }
|
---|
88 | if (QRegExp("--?display").exactMatch(argv[ii])) {
|
---|
89 | displaySet = true;
|
---|
90 | strcpy(argv[ii], "-display"); // make it "-display" not "--display"
|
---|
91 | }
|
---|
92 | if (ii + 1 < argc) {
|
---|
93 | if (QRegExp("--?conf").exactMatch(argv[ii])) {
|
---|
94 | confFileName = QString(argv[ii+1]);
|
---|
95 | }
|
---|
96 | if (QRegExp("--?file").exactMatch(argv[ii])) {
|
---|
97 | interactive = false;
|
---|
98 | rawFileName = QByteArray(argv[ii+1]);
|
---|
99 | }
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | #ifdef Q_OS_MAC
|
---|
104 | if (argc== 3 && interactive) {
|
---|
105 | confFileName = QString(argv[2]);
|
---|
106 | }
|
---|
107 | #else
|
---|
108 | if (argc == 2 && interactive) {
|
---|
109 | confFileName = QString(argv[1]);
|
---|
110 | }
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | bool GUIenabled = interactive || displaySet;
|
---|
114 | bncApp app(argc, argv, GUIenabled);
|
---|
115 |
|
---|
116 | app.setApplicationName("BNC");
|
---|
117 | app.setOrganizationName("BKG");
|
---|
118 | app.setOrganizationDomain("www.bkg.bund.de");
|
---|
119 | app.setConfFileName( confFileName );
|
---|
120 |
|
---|
121 | bncSettings settings;
|
---|
122 |
|
---|
123 | for (int ii = 1; ii < argc - 2; ii++) {
|
---|
124 | if (QRegExp("--?key").exactMatch(argv[ii])) {
|
---|
125 | QString key(argv[ii+1]);
|
---|
126 | QString val(argv[ii+2]);
|
---|
127 | settings.setValue(key, val);
|
---|
128 | }
|
---|
129 | }
|
---|
130 |
|
---|
131 | // Interactive Mode - open the main window
|
---|
132 | // ---------------------------------------
|
---|
133 | if (interactive) {
|
---|
134 |
|
---|
135 | app.setMode(bncApp::interactive);
|
---|
136 |
|
---|
137 | QString fontString = settings.value("font").toString();
|
---|
138 | if ( !fontString.isEmpty() ) {
|
---|
139 | QFont newFont;
|
---|
140 | if (newFont.fromString(fontString)) {
|
---|
141 | QApplication::setFont(newFont);
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
146 |
|
---|
147 | bncWindow* bncWin = new bncWindow();
|
---|
148 | app.setMainWindow(bncWin);
|
---|
149 | bncWin->show();
|
---|
150 | }
|
---|
151 |
|
---|
152 | #ifdef USE_POSTPROCESSING
|
---|
153 |
|
---|
154 | // Post-Processing PPP
|
---|
155 | // -------------------
|
---|
156 | else if (settings.value("pppSPP").toString() == "Post-Processing") {
|
---|
157 | app.setMode(bncApp::batchPostProcessing);
|
---|
158 | t_postProcessing* postProcessing = new t_postProcessing(0);
|
---|
159 | postProcessing->start();
|
---|
160 | }
|
---|
161 |
|
---|
162 | // Post-Processing reqc edit
|
---|
163 | // -------------------------
|
---|
164 | else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
|
---|
165 | app.setMode(bncApp::batchPostProcessing);
|
---|
166 | t_reqcEdit* reqcEdit = new t_reqcEdit(0);
|
---|
167 | reqcEdit->start();
|
---|
168 | }
|
---|
169 |
|
---|
170 | // Post-Processing reqc analyze
|
---|
171 | // ----------------------------
|
---|
172 | else if (settings.value("reqcAction").toString() == "Analyze") {
|
---|
173 | app.setMode(bncApp::batchPostProcessing);
|
---|
174 | t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
|
---|
175 | reqcAnalyze->start();
|
---|
176 | }
|
---|
177 |
|
---|
178 | #endif
|
---|
179 |
|
---|
180 | // Non-Interactive (data gathering)
|
---|
181 | // --------------------------------
|
---|
182 | else {
|
---|
183 |
|
---|
184 | signal(SIGINT, catch_signal);
|
---|
185 |
|
---|
186 | bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
|
---|
187 |
|
---|
188 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
189 | settings.value("outPort").toInt());
|
---|
190 |
|
---|
191 | app.setCaster(caster);
|
---|
192 | app.setPort(settings.value("outEphPort").toInt());
|
---|
193 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
194 | app.initCombination();
|
---|
195 |
|
---|
196 | app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
|
---|
197 |
|
---|
198 | ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
|
---|
199 |
|
---|
200 | // Normal case - data from Internet
|
---|
201 | // --------------------------------
|
---|
202 | if ( rawFileName.isEmpty() ) {
|
---|
203 | app.setMode(bncApp::nonInteractive);
|
---|
204 | caster->readMountPoints();
|
---|
205 | if (caster->numStations() == 0) {
|
---|
206 | exit(0);
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|
210 | // Special case - data from file
|
---|
211 | // -----------------------------
|
---|
212 | else {
|
---|
213 | app.setMode(bncApp::batchPostProcessing);
|
---|
214 | bncRawFile* rawFile = new bncRawFile(rawFileName, "",
|
---|
215 | bncRawFile::input);
|
---|
216 | bncGetThread* getThread = new bncGetThread(rawFile);
|
---|
217 | caster->addGetThread(getThread, true);
|
---|
218 | }
|
---|
219 | }
|
---|
220 |
|
---|
221 | // Start the application
|
---|
222 | // ---------------------
|
---|
223 | return app.exec();
|
---|
224 | }
|
---|