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

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