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

Last change on this file since 4491 was 4491, 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;
90 if (QRegExp("--display").exactMatch(argv[ii])) {
[4491]91 strcpy(argv[ii], "-display");
[4490]92 }
93 }
[1552]94 if (ii + 1 < argc) {
[3977]95 if (QRegExp("--?conf").exactMatch(argv[ii])) {
[1552]96 confFileName = QString(argv[ii+1]);
[1146]97 }
[3977]98 if (QRegExp("--?file").exactMatch(argv[ii])) {
[4446]99 interactive = false;
[1553]100 rawFileName = QByteArray(argv[ii+1]);
[1552]101 }
[1156]102 }
[1146]103 }
104
[4162]105#ifdef Q_OS_MAC
[4446]106 if (argc== 3 && interactive) {
[4162]107 confFileName = QString(argv[2]);
108 }
109#else
[4446]110 if (argc == 2 && interactive) {
[1585]111 confFileName = QString(argv[1]);
112 }
[4162]113#endif
[1585]114
[4491]115 bool GUIenabled = interactive || displaySet;
[4447]116 bncApp app(argc, argv, GUIenabled);
[1516]117
[1538]118 app.setApplicationName("BNC");
119 app.setOrganizationName("BKG");
120 app.setOrganizationDomain("www.bkg.bund.de");
121 app.setConfFileName( confFileName );
122
[1535]123 bncSettings settings;
[1503]124
[3976]125 for (int ii = 1; ii < argc - 2; ii++) {
[3978]126 if (QRegExp("--?key").exactMatch(argv[ii])) {
[3976]127 QString key(argv[ii+1]);
128 QString val(argv[ii+2]);
129 settings.setValue(key, val);
130 }
131 }
132
[180]133 // Interactive Mode - open the main window
134 // ---------------------------------------
[4446]135 if (interactive) {
[113]136
[3280]137 app.setMode(bncApp::interactive);
138
[113]139 QString fontString = settings.value("font").toString();
140 if ( !fontString.isEmpty() ) {
141 QFont newFont;
142 if (newFont.fromString(fontString)) {
143 QApplication::setFont(newFont);
144 }
145 }
[142]146
[173]147 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]148
[82]149 bncWindow* bncWin = new bncWindow();
[4346]150 app.setMainWindow(bncWin);
[35]151 bncWin->show();
152 }
[180]153
[3975]154#ifdef USE_POSTPROCESSING
155
156 // Post-Processing PPP
157 // -------------------
158 else if (settings.value("pppSPP").toString() == "Post-Processing") {
159 app.setMode(bncApp::batchPostProcessing);
160 t_postProcessing* postProcessing = new t_postProcessing(0);
161 postProcessing->start();
162 }
163
[3974]164 // Post-Processing reqc edit
165 // -------------------------
166 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
167 app.setMode(bncApp::batchPostProcessing);
168 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
169 reqcEdit->start();
170 }
171
[3975]172 // Post-Processing reqc analyze
173 // ----------------------------
174 else if (settings.value("reqcAction").toString() == "Analyze") {
175 app.setMode(bncApp::batchPostProcessing);
176 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
177 reqcAnalyze->start();
178 }
179
180#endif
181
[3974]182 // Non-Interactive (data gathering)
183 // --------------------------------
[35]184 else {
[621]185
[1138]186 signal(SIGINT, catch_signal);
187
[3251]188 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
[3974]189
[621]190 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
191 settings.value("outPort").toInt());
192
193 app.setCaster(caster);
[592]194 app.setPort(settings.value("outEphPort").toInt());
[937]195 app.setPortCorr(settings.value("corrPort").toInt());
[2909]196 app.initCombination();
[3974]197
[1556]198 app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[3974]199
[2012]200 ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[3974]201
[1170]202 // Normal case - data from Internet
203 // --------------------------------
[3974]204 if ( rawFileName.isEmpty() ) {
[3280]205 app.setMode(bncApp::nonInteractive);
[4250]206 caster->readMountPoints();
[1170]207 if (caster->numStations() == 0) {
[1552]208 exit(0);
[1170]209 }
210 }
[3974]211
[1170]212 // Special case - data from file
213 // -----------------------------
214 else {
[3280]215 app.setMode(bncApp::batchPostProcessing);
[3548]216 bncRawFile* rawFile = new bncRawFile(rawFileName, "",
[3531]217 bncRawFile::input);
[2519]218 bncGetThread* getThread = new bncGetThread(rawFile);
[2528]219 caster->addGetThread(getThread, true);
[35]220 }
221 }
[180]222
223 // Start the application
224 // ---------------------
[35]225 return app.exec();
226}
Note: See TracBrowser for help on using the repository browser.