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