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

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