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

Last change on this file since 5871 was 5871, checked in by mervart, 10 years ago
File size: 6.5 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[35]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[35]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
[274]41#include <unistd.h>
[603]42#include <signal.h>
[35]43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
[5066]47#include "app.h"
[5070]48#include "bnccore.h"
[35]49#include "bncwindow.h"
[1535]50#include "bncsettings.h"
[2012]51#include "bncversion.h"
[3251]52#include "upload/bncephuploadcaster.h"
[3972]53#ifdef USE_POSTPROCESSING
54# include "rinex/reqcedit.h"
55# include "rinex/reqcanalyze.h"
56#endif
[5845]57#include "PPP/pppMain.h"
[35]58
59using namespace std;
60
[603]61void catch_signal(int) {
62 cout << "Program Interrupted by Ctrl-C" << endl;
[3005]63 exit(0);
[603]64}
65
[82]66// Main Program
67/////////////////////////////////////////////////////////////////////////////
[4490]68int main(int argc, char* argv[]) {
[35]69
[4446]70 bool interactive = true;
[4716]71#ifdef WIN32
72 bool displaySet = true;
73#else
[4490]74 bool displaySet = false;
[4716]75#endif
[1552]76 QByteArray rawFileName;
[1501]77 QString confFileName;
[1146]78
[3977]79 QByteArray printHelp = "Usage: bnc --nw \n"
[4490]80 " --display <XXX> \n"
[3977]81 " --conf <confFileName> \n"
82 " --file <rawFileName> \n"
83 " --key <keyName> <keyValue>\n";
84
[100]85 for (int ii = 1; ii < argc; ii++) {
[3977]86 if (QRegExp("--?help").exactMatch(argv[ii])) {
87 cout << printHelp.data();
88 exit(0);
89 }
90 if (QRegExp("--?nw").exactMatch(argv[ii])) {
[4446]91 interactive = false;
[100]92 }
[4490]93 if (QRegExp("--?display").exactMatch(argv[ii])) {
94 displaySet = true;
[4492]95 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
[4490]96 }
[1552]97 if (ii + 1 < argc) {
[3977]98 if (QRegExp("--?conf").exactMatch(argv[ii])) {
[1552]99 confFileName = QString(argv[ii+1]);
[1146]100 }
[3977]101 if (QRegExp("--?file").exactMatch(argv[ii])) {
[4446]102 interactive = false;
[1553]103 rawFileName = QByteArray(argv[ii+1]);
[1552]104 }
[1156]105 }
[1146]106 }
107
[4162]108#ifdef Q_OS_MAC
[4446]109 if (argc== 3 && interactive) {
[4162]110 confFileName = QString(argv[2]);
111 }
112#else
[4446]113 if (argc == 2 && interactive) {
[1585]114 confFileName = QString(argv[1]);
115 }
[4162]116#endif
[1585]117
[4491]118 bool GUIenabled = interactive || displaySet;
[5066]119 t_app app(argc, argv, GUIenabled);
[1516]120
[1538]121 app.setApplicationName("BNC");
122 app.setOrganizationName("BKG");
123 app.setOrganizationDomain("www.bkg.bund.de");
[5084]124
125 BNC_CORE->setGUIenabled(GUIenabled);
[5068]126 BNC_CORE->setConfFileName( confFileName );
[1538]127
[1535]128 bncSettings settings;
[1503]129
[3976]130 for (int ii = 1; ii < argc - 2; ii++) {
[3978]131 if (QRegExp("--?key").exactMatch(argv[ii])) {
[3976]132 QString key(argv[ii+1]);
133 QString val(argv[ii+2]);
134 settings.setValue(key, val);
135 }
136 }
137
[180]138 // Interactive Mode - open the main window
139 // ---------------------------------------
[4446]140 if (interactive) {
[113]141
[5072]142 BNC_CORE->setMode(t_bncCore::interactive);
[3280]143
[113]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 }
[142]151
[173]152 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]153
[82]154 bncWindow* bncWin = new bncWindow();
[5068]155 BNC_CORE->setMainWindow(bncWin);
[35]156 bncWin->show();
157 }
[180]158
[3975]159#ifdef USE_POSTPROCESSING
160
[3974]161 // Post-Processing reqc edit
162 // -------------------------
[5864]163 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
[5072]164 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3974]165 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
166 reqcEdit->start();
167 }
168
[3975]169 // Post-Processing reqc analyze
170 // ----------------------------
171 else if (settings.value("reqcAction").toString() == "Analyze") {
[5072]172 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3975]173 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
174 reqcAnalyze->start();
175 }
176
177#endif
178
[3974]179 // Non-Interactive (data gathering)
180 // --------------------------------
[35]181 else {
[621]182
[1138]183 signal(SIGINT, catch_signal);
184
[3251]185 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
[3974]186
[5729]187 bncCaster* caster = new bncCaster();
[621]188
[5068]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();
[3974]193
[5729]194 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[3974]195
[5068]196 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[5845]197
198 // PPP Client(s) (in separate threads)
199 // -----------------------------------
200 BNC_PPP::t_pppMain* pppMain = new BNC_PPP::t_pppMain();
201 pppMain->start();
202
[1170]203 // Normal case - data from Internet
204 // --------------------------------
[3974]205 if ( rawFileName.isEmpty() ) {
[5072]206 BNC_CORE->setMode(t_bncCore::nonInteractive);
[4250]207 caster->readMountPoints();
[1170]208 if (caster->numStations() == 0) {
[1552]209 exit(0);
[1170]210 }
211 }
[3974]212
[1170]213 // Special case - data from file
214 // -----------------------------
215 else {
[5072]216 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3548]217 bncRawFile* rawFile = new bncRawFile(rawFileName, "",
[3531]218 bncRawFile::input);
[2519]219 bncGetThread* getThread = new bncGetThread(rawFile);
[5871]220 QObject::connect(getThread, SIGNAL(finished()),
221 pppMain, SLOT(slotStop()), Qt::BlockingQueuedConnection);
[2528]222 caster->addGetThread(getThread, true);
[35]223 }
224 }
[180]225
226 // Start the application
227 // ---------------------
[35]228 return app.exec();
229}
Note: See TracBrowser for help on using the repository browser.