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

Last change on this file since 7268 was 7268, checked in by stuerze, 9 years ago

option '--version' is added to get BNC's current version

File size: 7.1 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 = "Usage: bnc --nw \n"
78 " --version \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("--?version").exactMatch(argv[ii])) {
93 cout << BNCPGMNAME << endl;
94 exit(0);
95 }
96 if (QRegExp("--?display").exactMatch(argv[ii])) {
97 displaySet = true;
98 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
99 }
100 if (ii + 1 < argc) {
101 if (QRegExp("--?conf").exactMatch(argv[ii])) {
102 confFileName = QString(argv[ii+1]);
103 }
104 if (QRegExp("--?file").exactMatch(argv[ii])) {
105 interactive = false;
106 rawFileName = QByteArray(argv[ii+1]);
107 }
108 }
109 }
110
111#ifdef Q_OS_MAC
112 if (argc== 3 && interactive) {
113 confFileName = QString(argv[2]);
114 }
115#else
116 if (argc == 2 && interactive) {
117 confFileName = QString(argv[1]);
118 }
119#endif
120
121#ifdef Q_OS_MACX
122 if ( QSysInfo::MacintoshVersion > QSysInfo::MV_10_8 )
123 {
124 // fix Mac OS X 10.9 (mavericks) font issue
125 // https://bugreports.qt-project.org/browse/QTBUG-32789
126 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
127 }
128#endif
129
130 bool GUIenabled = interactive || displaySet;
131 t_app app(argc, argv, GUIenabled);
132
133 app.setApplicationName("BNC");
134 app.setOrganizationName("BKG");
135 app.setOrganizationDomain("www.bkg.bund.de");
136
137 BNC_CORE->setGUIenabled(GUIenabled);
138 BNC_CORE->setConfFileName( confFileName );
139
140 bncSettings settings;
141
142 for (int ii = 1; ii < argc - 2; ii++) {
143 if (QRegExp("--?key").exactMatch(argv[ii])) {
144 QString key(argv[ii+1]);
145 QString val(argv[ii+2]);
146 settings.setValue(key, val);
147 }
148 }
149
150 // Interactive Mode - open the main window
151 // ---------------------------------------
152 if (interactive) {
153
154 BNC_CORE->setMode(t_bncCore::interactive);
155
156 QString fontString = settings.value("font").toString();
157 if ( !fontString.isEmpty() ) {
158 QFont newFont;
159 if (newFont.fromString(fontString)) {
160 QApplication::setFont(newFont);
161 }
162 }
163
164 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
165
166 bncWindow* bncWin = new bncWindow();
167 BNC_CORE->setMainWindow(bncWin);
168 bncWin->show();
169 }
170
171 // Post-Processing PPP
172 // -------------------
173 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
174 bncCaster* caster = new bncCaster();
175 BNC_CORE->setCaster(caster);
176 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
177 BNC_CORE->startPPP();
178 }
179
180 // Post-Processing reqc edit
181 // -------------------------
182 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
183 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
184 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
185 reqcEdit->start();
186 }
187
188 // Post-Processing reqc analyze
189 // ----------------------------
190 else if (settings.value("reqcAction").toString() == "Analyze") {
191 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
192 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
193 reqcAnalyze->start();
194 }
195
196 // SP3 Files Comparison
197 // --------------------
198 else if (!settings.value("sp3CompFile").toString().isEmpty()) {
199 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
200 t_sp3Comp* sp3Comp = new t_sp3Comp(0);
201 sp3Comp->start();
202 }
203
204 // Non-Interactive (data gathering)
205 // --------------------------------
206 else {
207
208 signal(SIGINT, catch_signal);
209
210 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
211
212 bncCaster* caster = new bncCaster();
213
214 BNC_CORE->setCaster(caster);
215 BNC_CORE->setPortEph(settings.value("outEphPort").toInt());
216 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
217 BNC_CORE->initCombination();
218
219 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
220
221 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " ("BNC_OS") ==========", true);
222
223 // Normal case - data from Internet
224 // --------------------------------
225 if ( rawFileName.isEmpty() ) {
226 BNC_CORE->setMode(t_bncCore::nonInteractive);
227 BNC_CORE->startPPP();
228
229 caster->readMountPoints();
230 if (caster->numStations() == 0) {
231 exit(0);
232 }
233 }
234
235 // Special case - data from file
236 // -----------------------------
237 else {
238 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
239 BNC_CORE->startPPP();
240
241 bncRawFile* rawFile = new bncRawFile(rawFileName, "", bncRawFile::input);
242 bncGetThread* getThread = new bncGetThread(rawFile);
243 caster->addGetThread(getThread, true);
244 }
245 }
246
247 // Start the application
248 // ---------------------
249 return app.exec();
250}
Note: See TracBrowser for help on using the repository browser.