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

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