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

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