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

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