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

Last change on this file since 5727 was 5727, 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/bncpostprocess.h"
55# include "rinex/reqcedit.h"
56# include "rinex/reqcanalyze.h"
57#endif
[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
161 // Post-Processing PPP
162 // -------------------
163 else if (settings.value("pppSPP").toString() == "Post-Processing") {
[5072]164 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[5264]165 t_postProcessing* postProcessing = new t_postProcessing(0, 0, 0);
[3975]166 postProcessing->start();
167 }
168
[3974]169 // Post-Processing reqc edit
170 // -------------------------
171 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
[5072]172 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3974]173 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
174 reqcEdit->start();
175 }
176
[3975]177 // Post-Processing reqc analyze
178 // ----------------------------
179 else if (settings.value("reqcAction").toString() == "Analyze") {
[5072]180 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3975]181 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
182 reqcAnalyze->start();
183 }
184
185#endif
186
[3974]187 // Non-Interactive (data gathering)
188 // --------------------------------
[35]189 else {
[621]190
[1138]191 signal(SIGINT, catch_signal);
192
[3251]193 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
[3974]194
[5727]195 QSharedPointer<bncCaster> caster(new bncCaster());
[621]196
[5068]197 BNC_CORE->setCaster(caster);
198 BNC_CORE->setPort(settings.value("outEphPort").toInt());
199 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
200 BNC_CORE->initCombination();
[3974]201
[5727]202 BNC_CORE->connect(caster.data(), SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[3974]203
[5068]204 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[3974]205
[1170]206 // Normal case - data from Internet
207 // --------------------------------
[3974]208 if ( rawFileName.isEmpty() ) {
[5072]209 BNC_CORE->setMode(t_bncCore::nonInteractive);
[4250]210 caster->readMountPoints();
[1170]211 if (caster->numStations() == 0) {
[1552]212 exit(0);
[1170]213 }
214 }
[3974]215
[1170]216 // Special case - data from file
217 // -----------------------------
218 else {
[5072]219 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3548]220 bncRawFile* rawFile = new bncRawFile(rawFileName, "",
[3531]221 bncRawFile::input);
[2519]222 bncGetThread* getThread = new bncGetThread(rawFile);
[2528]223 caster->addGetThread(getThread, true);
[35]224 }
225 }
[180]226
227 // Start the application
228 // ---------------------
[35]229 return app.exec();
230}
Note: See TracBrowser for help on using the repository browser.