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

Last change on this file since 5066 was 5066, checked in by mervart, 11 years ago
File size: 6.6 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"
[82]48#include "bncapp.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");
[5066]124 PGM_CORE->setConfFileName( confFileName );
[1538]125
[1535]126 bncSettings settings;
[1503]127
[3976]128 for (int ii = 1; ii < argc - 2; ii++) {
[3978]129 if (QRegExp("--?key").exactMatch(argv[ii])) {
[3976]130 QString key(argv[ii+1]);
131 QString val(argv[ii+2]);
132 settings.setValue(key, val);
133 }
134 }
135
[180]136 // Interactive Mode - open the main window
137 // ---------------------------------------
[4446]138 if (interactive) {
[113]139
[5066]140 PGM_CORE->setMode(t_pgmCore::interactive);
[3280]141
[113]142 QString fontString = settings.value("font").toString();
143 if ( !fontString.isEmpty() ) {
144 QFont newFont;
145 if (newFont.fromString(fontString)) {
146 QApplication::setFont(newFont);
147 }
148 }
[142]149
[173]150 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]151
[82]152 bncWindow* bncWin = new bncWindow();
[5066]153 PGM_CORE->setMainWindow(bncWin);
[35]154 bncWin->show();
155 }
[180]156
[3975]157#ifdef USE_POSTPROCESSING
158
159 // Post-Processing PPP
160 // -------------------
161 else if (settings.value("pppSPP").toString() == "Post-Processing") {
[5066]162 PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
[3975]163 t_postProcessing* postProcessing = new t_postProcessing(0);
164 postProcessing->start();
165 }
166
[3974]167 // Post-Processing reqc edit
168 // -------------------------
169 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
[5066]170 PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
[3974]171 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
172 reqcEdit->start();
173 }
174
[3975]175 // Post-Processing reqc analyze
176 // ----------------------------
177 else if (settings.value("reqcAction").toString() == "Analyze") {
[5066]178 PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
[3975]179 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
180 reqcAnalyze->start();
181 }
182
183#endif
184
[3974]185 // Non-Interactive (data gathering)
186 // --------------------------------
[35]187 else {
[621]188
[1138]189 signal(SIGINT, catch_signal);
190
[3251]191 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
[3974]192
[621]193 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
194 settings.value("outPort").toInt());
195
[5066]196 PGM_CORE->setCaster(caster);
197 PGM_CORE->setPort(settings.value("outEphPort").toInt());
198 PGM_CORE->setPortCorr(settings.value("corrPort").toInt());
199 PGM_CORE->initCombination();
[3974]200
[5066]201 PGM_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[3974]202
[5066]203 PGM_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[3974]204
[1170]205 // Normal case - data from Internet
206 // --------------------------------
[3974]207 if ( rawFileName.isEmpty() ) {
[5066]208 PGM_CORE->setMode(t_pgmCore::nonInteractive);
[4250]209 caster->readMountPoints();
[1170]210 if (caster->numStations() == 0) {
[1552]211 exit(0);
[1170]212 }
213 }
[3974]214
[1170]215 // Special case - data from file
216 // -----------------------------
217 else {
[5066]218 PGM_CORE->setMode(t_pgmCore::batchPostProcessing);
[3548]219 bncRawFile* rawFile = new bncRawFile(rawFileName, "",
[3531]220 bncRawFile::input);
[2519]221 bncGetThread* getThread = new bncGetThread(rawFile);
[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.