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

Last change on this file since 5923 was 5905, checked in by mervart, 10 years ago
File size: 6.1 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"
[5887]53#include "rinex/reqcedit.h"
54#include "rinex/reqcanalyze.h"
[35]55
56using namespace std;
57
[603]58void catch_signal(int) {
59 cout << "Program Interrupted by Ctrl-C" << endl;
[3005]60 exit(0);
[603]61}
62
[82]63// Main Program
64/////////////////////////////////////////////////////////////////////////////
[4490]65int main(int argc, char* argv[]) {
[35]66
[4446]67 bool interactive = true;
[4716]68#ifdef WIN32
69 bool displaySet = true;
70#else
[4490]71 bool displaySet = false;
[4716]72#endif
[1552]73 QByteArray rawFileName;
[1501]74 QString confFileName;
[1146]75
[3977]76 QByteArray printHelp = "Usage: bnc --nw \n"
[4490]77 " --display <XXX> \n"
[3977]78 " --conf <confFileName> \n"
79 " --file <rawFileName> \n"
80 " --key <keyName> <keyValue>\n";
81
[100]82 for (int ii = 1; ii < argc; ii++) {
[3977]83 if (QRegExp("--?help").exactMatch(argv[ii])) {
84 cout << printHelp.data();
85 exit(0);
86 }
87 if (QRegExp("--?nw").exactMatch(argv[ii])) {
[4446]88 interactive = false;
[100]89 }
[4490]90 if (QRegExp("--?display").exactMatch(argv[ii])) {
91 displaySet = true;
[4492]92 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
[4490]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;
[5066]116 t_app app(argc, argv, GUIenabled);
[1516]117
[1538]118 app.setApplicationName("BNC");
119 app.setOrganizationName("BKG");
120 app.setOrganizationDomain("www.bkg.bund.de");
[5084]121
122 BNC_CORE->setGUIenabled(GUIenabled);
[5068]123 BNC_CORE->setConfFileName( confFileName );
[1538]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
[5072]139 BNC_CORE->setMode(t_bncCore::interactive);
[3280]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();
[5068]152 BNC_CORE->setMainWindow(bncWin);
[35]153 bncWin->show();
154 }
[180]155
[3974]156 // Post-Processing reqc edit
157 // -------------------------
[5864]158 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
[5072]159 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3974]160 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
161 reqcEdit->start();
162 }
163
[3975]164 // Post-Processing reqc analyze
165 // ----------------------------
166 else if (settings.value("reqcAction").toString() == "Analyze") {
[5072]167 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[3975]168 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
169 reqcAnalyze->start();
170 }
171
[3974]172 // Non-Interactive (data gathering)
173 // --------------------------------
[35]174 else {
[621]175
[1138]176 signal(SIGINT, catch_signal);
177
[3251]178 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
[3974]179
[5729]180 bncCaster* caster = new bncCaster();
[621]181
[5068]182 BNC_CORE->setCaster(caster);
183 BNC_CORE->setPort(settings.value("outEphPort").toInt());
184 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
185 BNC_CORE->initCombination();
[3974]186
[5729]187 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
[3974]188
[5068]189 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
[5845]190
[1170]191 // Normal case - data from Internet
192 // --------------------------------
[3974]193 if ( rawFileName.isEmpty() ) {
[5072]194 BNC_CORE->setMode(t_bncCore::nonInteractive);
[5905]195 BNC_CORE->startPPP(true);
196
[4250]197 caster->readMountPoints();
[1170]198 if (caster->numStations() == 0) {
[1552]199 exit(0);
[1170]200 }
201 }
[3974]202
[1170]203 // Special case - data from file
204 // -----------------------------
205 else {
[5072]206 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
[5905]207 BNC_CORE->startPPP(false);
208
209 bncRawFile* rawFile = new bncRawFile(rawFileName, "", bncRawFile::input);
[2519]210 bncGetThread* getThread = new bncGetThread(rawFile);
[2528]211 caster->addGetThread(getThread, true);
[35]212 }
213 }
[180]214
215 // Start the application
216 // ---------------------
[35]217 return app.exec();
218}
Note: See TracBrowser for help on using the repository browser.