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